Commit e862ac0f authored by lypanov's avatar lypanov

2006-03-01 Alexander Kellett <lypanov@kde.org>

        Reviewed by Maciej.

        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=5966

        Fixes already existing test:
          svg/W3C-SVG-1.1/coords-viewattr-02-b.svg

        * kcanvas/RenderSVGImage.cpp:
        (WebCore::RenderSVGImage::adjustRectsForAspectRatio):
        (WebCore::RenderSVGImage::paint):
        * kcanvas/RenderSVGImage.h:

2006-03-01  Alexander Kellett  <lypanov@kde.org>

        - http://bugzilla.opendarwin.org/show_bug.cgi?id=5966
          Update expected results

        * svg/W3C-SVG-1.1/coords-viewattr-02-b-expected.checksum:
        * svg/W3C-SVG-1.1/coords-viewattr-02-b-expected.png:
        * svg/W3C-SVG-1.1/coords-viewattr-02-b-expected.txt:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@13073 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8255a134
2006-03-01 Alexander Kellett <lypanov@kde.org>
- http://bugzilla.opendarwin.org/show_bug.cgi?id=5966
Update expected results
* svg/W3C-SVG-1.1/coords-viewattr-02-b-expected.checksum:
* svg/W3C-SVG-1.1/coords-viewattr-02-b-expected.png:
* svg/W3C-SVG-1.1/coords-viewattr-02-b-expected.txt:
2006-03-01 Alexey Proskuryakov <ap@nypop.com>
Reviewed by Darin.
......
32377a490808165b7bbc58a14fb0d7f8
\ No newline at end of file
d32a34f9d74da098f828f6328401f3b8
\ No newline at end of file
......@@ -3,96 +3,96 @@ layer at (0,0) size 480x360
KCanvasContainer {svg} at (0.50,0.50) size 479x359
KCanvasContainer {g} at (20,70) size 410x225 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,30.00)}]
KCanvasContainer {g} at (20,70) size 410x225
RenderSVGText {text} at (0,0) size 465x10
RenderSVGText {text} at (0,0) size 785x10
RenderText {TEXT} at (0,0) size 45x10
text run at (0,0) width 45: "Raster to fit"
KCanvasContainer {g} at (20,70) size 40x40 [transform={m=((1.00,0.00)(0.00,1.00)) t=(20.00,40.00)}]
RenderImage {image} at (0,0) size 40x40
RenderSVGText {text} at (0,0) size 465x10
RenderSVGText {text} at (0,0) size 785x10
RenderText {TEXT} at (0,0) size 42x10
text run at (0,0) width 42: "Viewport 1"
KCanvasContainer {g} at (10,150) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(10.00,120.00)}]
RenderSVGText {text} at (0,0) size 465x10
RenderSVGText {text} at (0,0) size 785x10
RenderText {TEXT} at (0,0) size 42x10
text run at (0,0) width 42: "Viewport 2"
KCanvasContainer {g} at (20,220) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(20.00,190.00)}]
KCanvasContainer {g} at (120,80) size 120x80 [transform={m=((1.00,0.00)(0.00,1.00)) t=(120.00,50.00)}]
RenderSVGText {text} at (0,0) size 465x10
RenderSVGText {text} at (0,0) size 785x10
RenderText {TEXT} at (0,0) size 112x10
text run at (0,0) width 112: "---------- meet --------------------"
KCanvasContainer {g} at (120,80) size 50x30
RenderSVGText {text} at (0,0) size 465x10
RenderSVGText {text} at (0,0) size 785x10
RenderText {TEXT} at (0,0) size 26x10
text run at (0,0) width 26: "xMin*"
RenderImage {image} at (0,0) size 50x30
KCanvasContainer {g} at (190,80) size 50x30 [transform={m=((1.00,0.00)(0.00,1.00)) t=(70.00,0.00)}]
RenderSVGText {text} at (0,0) size 465x10
RenderSVGText {text} at (0,0) size 785x10
RenderText {TEXT} at (0,0) size 26x10
text run at (0,0) width 26: "xMid*"
RenderImage {image} at (0,0) size 50x30
KCanvasContainer {g} at (120,130) size 50x30 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,50.00)}]
RenderSVGText {text} at (0,0) size 465x10
RenderSVGText {text} at (0,0) size 785x10
RenderText {TEXT} at (0,0) size 27x10
text run at (0,0) width 27: "xMax*"
RenderImage {image} at (0,0) size 50x30
KCanvasContainer {g} at (300,80) size 130x60 [transform={m=((1.00,0.00)(0.00,1.00)) t=(300.00,50.00)}]
RenderSVGText {text} at (0,0) size 465x10
RenderSVGText {text} at (0,0) size 785x10
RenderText {TEXT} at (0,0) size 124x10
text run at (0,0) width 124: "---------- meet ------------------------"
KCanvasContainer {g} at (300,80) size 30x60
RenderSVGText {text} at (0,0) size 465x10
RenderSVGText {text} at (0,0) size 785x10
RenderText {TEXT} at (0,0) size 27x10
text run at (0,0) width 27: "*YMin"
RenderImage {image} at (0,0) size 30x60
KCanvasContainer {g} at (350,80) size 30x60 [transform={m=((1.00,0.00)(0.00,1.00)) t=(50.00,0.00)}]
RenderSVGText {text} at (0,0) size 465x10
RenderSVGText {text} at (0,0) size 785x10
RenderText {TEXT} at (0,0) size 27x10
text run at (0,0) width 27: "*YMid"
RenderImage {image} at (0,0) size 30x60
KCanvasContainer {g} at (400,80) size 30x60 [transform={m=((1.00,0.00)(0.00,1.00)) t=(100.00,0.00)}]
RenderSVGText {text} at (0,0) size 465x10
RenderSVGText {text} at (0,0) size 785x10
RenderText {TEXT} at (0,0) size 28x10
text run at (0,0) width 28: "*YMax"
RenderImage {image} at (0,0) size 30x60
KCanvasContainer {g} at (120,215) size 130x60 [transform={m=((1.00,0.00)(0.00,1.00)) t=(120.00,185.00)}]
RenderSVGText {text} at (0,0) size 465x10
RenderSVGText {text} at (0,0) size 785x10
RenderText {TEXT} at (0,0) size 127x10
text run at (0,0) width 127: "---------- slice -------------------------"
KCanvasContainer {g} at (120,215) size 30x60
RenderSVGText {text} at (0,0) size 465x10
RenderSVGText {text} at (0,0) size 785x10
RenderText {TEXT} at (0,0) size 26x10
text run at (0,0) width 26: "xMin*"
RenderImage {image} at (0,0) size 30x60
KCanvasContainer {g} at (170,215) size 30x60 [transform={m=((1.00,0.00)(0.00,1.00)) t=(50.00,0.00)}]
RenderSVGText {text} at (0,0) size 465x10
RenderSVGText {text} at (0,0) size 785x10
RenderText {TEXT} at (0,0) size 26x10
text run at (0,0) width 26: "xMid*"
RenderImage {image} at (0,0) size 30x60
KCanvasContainer {g} at (220,215) size 30x60 [transform={m=((1.00,0.00)(0.00,1.00)) t=(100.00,0.00)}]
RenderSVGText {text} at (0,0) size 465x10
RenderSVGText {text} at (0,0) size 785x10
RenderText {TEXT} at (0,0) size 27x10
text run at (0,0) width 27: "xMax*"
RenderImage {image} at (0,0) size 30x60
KCanvasContainer {g} at (300,215) size 120x80 [transform={m=((1.00,0.00)(0.00,1.00)) t=(300.00,185.00)}]
RenderSVGText {text} at (0,0) size 465x10
RenderSVGText {text} at (0,0) size 785x10
RenderText {TEXT} at (0,0) size 115x10
text run at (0,0) width 115: "---------- slice ---------------------"
KCanvasContainer {g} at (300,215) size 50x30
RenderSVGText {text} at (0,0) size 465x10
RenderSVGText {text} at (0,0) size 785x10
RenderText {TEXT} at (0,0) size 27x10
text run at (0,0) width 27: "*YMin"
RenderImage {image} at (0,0) size 50x30
KCanvasContainer {g} at (370,215) size 50x30 [transform={m=((1.00,0.00)(0.00,1.00)) t=(70.00,0.00)}]
RenderSVGText {text} at (0,0) size 465x10
RenderSVGText {text} at (0,0) size 785x10
RenderText {TEXT} at (0,0) size 27x10
text run at (0,0) width 27: "*YMid"
RenderImage {image} at (0,0) size 50x30
KCanvasContainer {g} at (300,265) size 50x30 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,50.00)}]
RenderSVGText {text} at (0,0) size 465x10
RenderSVGText {text} at (0,0) size 785x10
RenderText {TEXT} at (0,0) size 28x10
text run at (0,0) width 28: "*YMax"
RenderImage {image} at (0,0) size 50x30
RenderSVGText {text} at (0,0) size 465x46
RenderSVGText {text} at (0,0) size 785x46
RenderText {TEXT} at (0,0) size 264x46
text run at (0,0) width 264: "$Revision: 1.1 $"
KCanvasItem {rect} at (0.50,0.50) size 479x359 [stroke={[type=SOLID] [color=#000000]}] [data="M1.00,1.00L479.00,1.00L479.00,359.00L1.00,359.00"]
2006-03-01 Alexander Kellett <lypanov@kde.org>
Reviewed by Maciej.
- fix http://bugzilla.opendarwin.org/show_bug.cgi?id=5966
Fixes already existing test:
svg/W3C-SVG-1.1/coords-viewattr-02-b.svg
* kcanvas/RenderSVGImage.cpp:
(WebCore::RenderSVGImage::adjustRectsForAspectRatio):
(WebCore::RenderSVGImage::paint):
* kcanvas/RenderSVGImage.h:
2006-03-01 Alexey Proskuryakov <ap@nypop.com>
Reviewed by Darin.
......
......@@ -26,6 +26,7 @@
#include "GraphicsContext.h"
#include "KCanvasMaskerQuartz.h"
#include "SVGAnimatedPreserveAspectRatioImpl.h"
#include "KCanvasRenderingStyle.h"
#include "KCanvasResourcesQuartz.h"
#include "KRenderingDevice.h"
......@@ -34,6 +35,10 @@
#include <kcanvas/KCanvas.h>
#include <kdom/core/AttrImpl.h>
#include "SVGImageElementImpl.h"
#include "ksvg.h"
namespace WebCore {
RenderSVGImage::RenderSVGImage(SVGImageElementImpl *impl)
......@@ -45,6 +50,81 @@ RenderSVGImage::~RenderSVGImage()
{
}
void RenderSVGImage::adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& srcRect, SVGPreserveAspectRatioImpl *aspectRatio)
{
float origDestWidth = destRect.width();
float origDestHeight = destRect.height();
if (aspectRatio->meetOrSlice() == SVG_MEETORSLICE_MEET) {
float widthToHeightMultiplier = srcRect.height() / srcRect.width();
if (origDestHeight > (origDestWidth * widthToHeightMultiplier)) {
destRect.setHeight(origDestWidth * widthToHeightMultiplier);
switch(aspectRatio->align()) {
case SVG_PRESERVEASPECTRATIO_XMINYMID:
case SVG_PRESERVEASPECTRATIO_XMIDYMID:
case SVG_PRESERVEASPECTRATIO_XMAXYMID:
destRect.setY(origDestHeight / 2 - destRect.height() / 2);
break;
case SVG_PRESERVEASPECTRATIO_XMINYMAX:
case SVG_PRESERVEASPECTRATIO_XMIDYMAX:
case SVG_PRESERVEASPECTRATIO_XMAXYMAX:
destRect.setY(origDestHeight - destRect.height());
break;
}
}
if (origDestWidth > (origDestHeight / widthToHeightMultiplier)) {
destRect.setWidth(origDestHeight / widthToHeightMultiplier);
switch(aspectRatio->align()) {
case SVG_PRESERVEASPECTRATIO_XMIDYMIN:
case SVG_PRESERVEASPECTRATIO_XMIDYMID:
case SVG_PRESERVEASPECTRATIO_XMIDYMAX:
destRect.setX(origDestWidth / 2 - destRect.width() / 2);
break;
case SVG_PRESERVEASPECTRATIO_XMAXYMIN:
case SVG_PRESERVEASPECTRATIO_XMAXYMID:
case SVG_PRESERVEASPECTRATIO_XMAXYMAX:
destRect.setX(origDestWidth - destRect.width());
break;
}
}
} else if (aspectRatio->meetOrSlice() == SVG_MEETORSLICE_SLICE) {
float widthToHeightMultiplier = srcRect.height() / srcRect.width();
// if the destination height is less than the height of the image we'll be drawing
if (origDestHeight < (origDestWidth * widthToHeightMultiplier)) {
float destToSrcMultiplier = srcRect.width() / destRect.width();
srcRect.setHeight(destRect.height() * destToSrcMultiplier);
switch(aspectRatio->align()) {
case SVG_PRESERVEASPECTRATIO_XMINYMID:
case SVG_PRESERVEASPECTRATIO_XMIDYMID:
case SVG_PRESERVEASPECTRATIO_XMAXYMID:
srcRect.setY(image()->height() / 2 - srcRect.height() / 2);
break;
case SVG_PRESERVEASPECTRATIO_XMINYMAX:
case SVG_PRESERVEASPECTRATIO_XMIDYMAX:
case SVG_PRESERVEASPECTRATIO_XMAXYMAX:
srcRect.setY(image()->height() - srcRect.height());
break;
}
}
// if the destination width is less than the width of the image we'll be drawing
if (origDestWidth < (origDestHeight / widthToHeightMultiplier)) {
float destToSrcMultiplier = srcRect.height() / destRect.height();
srcRect.setWidth(destRect.width() * destToSrcMultiplier);
switch(aspectRatio->align()) {
case SVG_PRESERVEASPECTRATIO_XMIDYMIN:
case SVG_PRESERVEASPECTRATIO_XMIDYMID:
case SVG_PRESERVEASPECTRATIO_XMIDYMAX:
srcRect.setX(image()->width() / 2 - srcRect.width() / 2);
break;
case SVG_PRESERVEASPECTRATIO_XMAXYMIN:
case SVG_PRESERVEASPECTRATIO_XMAXYMID:
case SVG_PRESERVEASPECTRATIO_XMAXYMAX:
srcRect.setX(image()->width() - srcRect.width());
break;
}
}
}
}
void RenderSVGImage::paint(PaintInfo& paintInfo, int parentX, int parentY)
{
if (paintInfo.p->paintingDisabled() || (paintInfo.phase != PaintActionForeground) || style()->visibility() == HIDDEN)
......@@ -66,7 +146,7 @@ void RenderSVGImage::paint(PaintInfo& paintInfo, int parentX, int parentY)
translateForAttributes();
FloatRect boundingBox = relativeBBox(true);
const KSVG::SVGRenderStyle *svgStyle = style()->svgStyle();
const SVGRenderStyle *svgStyle = style()->svgStyle();
if (KCanvasClipper *clipper = getClipperById(document(), svgStyle->clipPath().mid(1)))
clipper->applyClip(boundingBox);
......@@ -78,11 +158,27 @@ void RenderSVGImage::paint(PaintInfo& paintInfo, int parentX, int parentY)
if (filter)
filter->prepareFilter(boundingBox);
RenderImage::paint(paintInfo, 0, 0);
int x = 0, y = 0;
if (!shouldPaint(paintInfo, x, y))
return;
SVGImageElementImpl *imageElt = static_cast<SVGImageElementImpl *>(node());
if (imageElt->preserveAspectRatio()->baseVal()->align() == SVG_PRESERVEASPECTRATIO_NONE)
RenderImage::paint(paintInfo, 0, 0);
else {
FloatRect destRect(m_x, m_y, contentWidth(), contentHeight());
FloatRect srcRect(0, 0, image()->width(), image()->height());
adjustRectsForAspectRatio(destRect, srcRect, imageElt->preserveAspectRatio()->baseVal());
paintInfo.p->drawFloatImage(image(),
destRect.x(), destRect.y(), destRect.width(), destRect.height(),
srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height(),
Image::CompositeSourceOver);
}
if (filter)
filter->applyFilter(boundingBox);
// restore drawing state
if (shouldPopContext) {
device->popContext();
......
......@@ -30,6 +30,7 @@
namespace WebCore
{
class SVGImageElementImpl;
class SVGPreserveAspectRatioImpl;
class RenderSVGImage : public RenderImage {
public:
RenderSVGImage(SVGImageElementImpl *impl);
......@@ -42,7 +43,7 @@ namespace WebCore
virtual IntRect getAbsoluteRepaintRect();
virtual void imageChanged(CachedImage*);
void adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& srcRect, SVGPreserveAspectRatioImpl *aspectRatio);
virtual void paint(PaintInfo& paintInfo, int parentX, int parentY);
private:
void translateForAttributes();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment