Changeset 49481 in webkit
- Timestamp:
- Oct 12, 2009 4:05:21 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r49472 r49481 1 2009-10-12 Dirk Schulze <krit@webkit.org> 2 3 Reviewed by Nikolas Zimmermann. 4 5 Three old test results give back the absolute position instead of the realtive position. 6 The new test will check the correct behavior of gradients in userSpaceOnUse mode and 7 values in percentage. 8 9 * platform/mac/svg/custom/gradient-attr-update-expected.txt: 10 * platform/mac/svg/custom/gradient-deep-referencing-expected.txt: 11 * platform/mac/svg/custom/gradient-userSpaceOnUse-with-percentage-expected.checksum: Added. 12 * platform/mac/svg/custom/gradient-userSpaceOnUse-with-percentage-expected.png: Added. 13 * platform/mac/svg/custom/gradient-userSpaceOnUse-with-percentage-expected.txt: Added. 14 * platform/mac/svg/custom/text-gradient-no-content-expected.txt: 15 * svg/custom/gradient-userSpaceOnUse-with-percentage.svg: Added. 16 1 17 2009-10-12 Dirk Schulze <krit@webkit.org> 2 18 -
trunk/LayoutTests/platform/mac/svg/custom/gradient-attr-update-expected.txt
r38794 r49481 1 KRenderingPaintServer {id="gradient1" [type=RADIAL-GRADIENT] [stops=[(0.00,#008000), (1.00,#008000)]][method=REFLECT] [bounding box mode=0] [center=( 0.45,0.48)] [focal=(0.50,0.52)] [radius=200.00]}1 KRenderingPaintServer {id="gradient1" [type=RADIAL-GRADIENT] [stops=[(0.00,#008000), (1.00,#008000)]][method=REFLECT] [bounding box mode=0] [center=(360,288)] [focal=(400,312)] [radius=200.00]} 2 2 layer at (0,0) size 800x600 3 3 RenderView at (0,0) size 800x600 … … 8 8 RenderSVGGradientStop {stop} at (0,0) size 0x0 9 9 RenderSVGGradientStop {stop} at (0,0) size 0x0 10 RenderPath {rect} at (0,0) size 100x100 [fill={[type=RADIAL-GRADIENT] [stops=[(0.00,#008000), (1.00,#008000)]][method=REFLECT] [bounding box mode=0] [center=( 0.45,0.48)] [focal=(0.50,0.52)] [radius=200.00]}] [data="M0.00,0.00 L100.00,0.00 L100.00,100.00 L0.00,100.00 Z"]10 RenderPath {rect} at (0,0) size 100x100 [fill={[type=RADIAL-GRADIENT] [stops=[(0.00,#008000), (1.00,#008000)]][method=REFLECT] [bounding box mode=0] [center=(360,288)] [focal=(400,312)] [radius=200.00]}] [data="M0.00,0.00 L100.00,0.00 L100.00,100.00 L0.00,100.00 Z"] -
trunk/LayoutTests/platform/mac/svg/custom/gradient-deep-referencing-expected.txt
r38794 r49481 2 2 KRenderingPaintServer {id="gradient1e" [type=LINEAR-GRADIENT] [stops=[(0.00,#FF0000), (1.00,#0000FF)]] [bounding box mode=0] [start=(0,100)] [end=(100,0)]} 3 3 KRenderingPaintServer {id="gradient1d" [type=LINEAR-GRADIENT] [stops=[(0.00,#FF0000), (1.00,#0000FF)]] [bounding box mode=0] [start=(0,100)] [end=(100,0)]} 4 KRenderingPaintServer {id="gradient1c" [type=RADIAL-GRADIENT] [stops=[(0.00,#FF0000), (1.00,#0000FF)]] [bounding box mode=0] [center=( 0.50,0.50)] [focal=(0.50,0.50)] [radius=0.50]}4 KRenderingPaintServer {id="gradient1c" [type=RADIAL-GRADIENT] [stops=[(0.00,#FF0000), (1.00,#0000FF)]] [bounding box mode=0] [center=(400,400)] [focal=(400,400)] [radius=400.00]} 5 5 KRenderingPaintServer {id="gradient1b" [type=LINEAR-GRADIENT] [stops=[]] [start=(0,0)] [end=(0,0)]} 6 6 KRenderingPaintServer {id="gradient1a" [type=LINEAR-GRADIENT] [stops=[]] [start=(0,0)] [end=(0,0)]} -
trunk/LayoutTests/platform/mac/svg/custom/text-gradient-no-content-expected.txt
r38794 r49481 1 KRenderingPaintServer {id="Gradient" [type=LINEAR-GRADIENT] [stops=[(0.00,#FF0000), (1.00,#FF0000)]] [bounding box mode=0] [start=(0,0)] [end=( 1,0)]}1 KRenderingPaintServer {id="Gradient" [type=LINEAR-GRADIENT] [stops=[(0.00,#FF0000), (1.00,#FF0000)]] [bounding box mode=0] [start=(0,0)] [end=(800,0)]} 2 2 layer at (0,0) size 800x600 3 3 RenderView at (0,0) size 800x600 -
trunk/WebCore/ChangeLog
r49479 r49481 1 2009-10-12 Dirk Schulze <krit@webkit.org> 2 3 Reviewed by Nikolas Zimmermann. 4 5 SVG Gradients can't handle percentage values in userSpaceOnUse mode 6 [https://bugs.webkit.org/show_bug.cgi?id=30286] 7 8 Fixed *GradientAttributes to take SVGLength instead of double. This casues 9 the problem, that we can't calculate the correct size of a gradient on 10 userSpaceOnUse mode with percentage values. 11 12 Test: svg/custom/gradient-userSpaceOnUse-with-percentage.svg 13 14 * svg/LinearGradientAttributes.h: 15 (WebCore::LinearGradientAttributes::LinearGradientAttributes): 16 (WebCore::LinearGradientAttributes::x1): 17 (WebCore::LinearGradientAttributes::y1): 18 (WebCore::LinearGradientAttributes::x2): 19 (WebCore::LinearGradientAttributes::y2): 20 (WebCore::LinearGradientAttributes::setX1): 21 (WebCore::LinearGradientAttributes::setY1): 22 (WebCore::LinearGradientAttributes::setX2): 23 (WebCore::LinearGradientAttributes::setY2): 24 * svg/RadialGradientAttributes.h: 25 (WebCore::RadialGradientAttributes::RadialGradientAttributes): 26 (WebCore::RadialGradientAttributes::cx): 27 (WebCore::RadialGradientAttributes::cy): 28 (WebCore::RadialGradientAttributes::r): 29 (WebCore::RadialGradientAttributes::fx): 30 (WebCore::RadialGradientAttributes::fy): 31 (WebCore::RadialGradientAttributes::setCx): 32 (WebCore::RadialGradientAttributes::setCy): 33 (WebCore::RadialGradientAttributes::setR): 34 (WebCore::RadialGradientAttributes::setFx): 35 (WebCore::RadialGradientAttributes::setFy): 36 * svg/SVGLinearGradientElement.cpp: 37 (WebCore::SVGLinearGradientElement::buildGradient): 38 (WebCore::SVGLinearGradientElement::collectGradientProperties): 39 * svg/SVGRadialGradientElement.cpp: 40 (WebCore::SVGRadialGradientElement::buildGradient): 41 (WebCore::SVGRadialGradientElement::collectGradientProperties): 42 1 43 2009-10-12 Brian Weinstein <bweinstein@apple.com> 2 44 -
trunk/WebCore/svg/LinearGradientAttributes.h
r45747 r49481 30 30 struct LinearGradientAttributes : GradientAttributes { 31 31 LinearGradientAttributes() 32 : m_x1( 0.0)33 , m_y1( 0.0)34 , m_x2( 1.0)35 , m_y2( 0.0)32 : m_x1() 33 , m_y1() 34 , m_x2(LengthModeWidth, "100%") 35 , m_y2() 36 36 , m_x1Set(false) 37 37 , m_y1Set(false) … … 41 41 } 42 42 43 doublex1() const { return m_x1; }44 doubley1() const { return m_y1; }45 doublex2() const { return m_x2; }46 doubley2() const { return m_y2; }43 SVGLength x1() const { return m_x1; } 44 SVGLength y1() const { return m_y1; } 45 SVGLength x2() const { return m_x2; } 46 SVGLength y2() const { return m_y2; } 47 47 48 void setX1( doublevalue) { m_x1 = value; m_x1Set = true; }49 void setY1( doublevalue) { m_y1 = value; m_y1Set = true; }50 void setX2( doublevalue) { m_x2 = value; m_x2Set = true; }51 void setY2( doublevalue) { m_y2 = value; m_y2Set = true; }48 void setX1(const SVGLength& value) { m_x1 = value; m_x1Set = true; } 49 void setY1(const SVGLength& value) { m_y1 = value; m_y1Set = true; } 50 void setX2(const SVGLength& value) { m_x2 = value; m_x2Set = true; } 51 void setY2(const SVGLength& value) { m_y2 = value; m_y2Set = true; } 52 52 53 53 bool hasX1() const { return m_x1Set; } … … 58 58 private: 59 59 // Properties 60 doublem_x1;61 doublem_y1;62 doublem_x2;63 doublem_y2;60 SVGLength m_x1; 61 SVGLength m_y1; 62 SVGLength m_x2; 63 SVGLength m_y2; 64 64 65 65 // Property states -
trunk/WebCore/svg/RadialGradientAttributes.h
r45747 r49481 30 30 struct RadialGradientAttributes : GradientAttributes { 31 31 RadialGradientAttributes() 32 : m_cx( 0.5)33 , m_cy( 0.5)34 , m_r( 0.5)35 , m_fx( 0.0)36 , m_fy( 0.0)32 : m_cx(LengthModeWidth, "50%") 33 , m_cy(LengthModeWidth, "50%") 34 , m_r(LengthModeWidth, "50%") 35 , m_fx() 36 , m_fy() 37 37 , m_cxSet(false) 38 38 , m_cySet(false) … … 43 43 } 44 44 45 doublecx() const { return m_cx; }46 doublecy() const { return m_cy; }47 doubler() const { return m_r; }48 doublefx() const { return m_fx; }49 doublefy() const { return m_fy; }45 SVGLength cx() const { return m_cx; } 46 SVGLength cy() const { return m_cy; } 47 SVGLength r() const { return m_r; } 48 SVGLength fx() const { return m_fx; } 49 SVGLength fy() const { return m_fy; } 50 50 51 void setCx( doublevalue) { m_cx = value; m_cxSet = true; }52 void setCy( doublevalue) { m_cy = value; m_cySet = true; }53 void setR( doublevalue) { m_r = value; m_rSet = true; }54 void setFx( doublevalue) { m_fx = value; m_fxSet = true; }55 void setFy( doublevalue) { m_fy = value; m_fySet = true; }51 void setCx(const SVGLength& value) { m_cx = value; m_cxSet = true; } 52 void setCy(const SVGLength& value) { m_cy = value; m_cySet = true; } 53 void setR(const SVGLength& value) { m_r = value; m_rSet = true; } 54 void setFx(const SVGLength& value) { m_fx = value; m_fxSet = true; } 55 void setFy(const SVGLength& value) { m_fy = value; m_fySet = true; } 56 56 57 57 bool hasCx() const { return m_cxSet; } … … 63 63 private: 64 64 // Properties 65 doublem_cx;66 doublem_cy;67 doublem_r;68 doublem_fx;69 doublem_fy;65 SVGLength m_cx; 66 SVGLength m_cy; 67 SVGLength m_r; 68 SVGLength m_fx; 69 SVGLength m_fy; 70 70 71 71 // Property states -
trunk/WebCore/svg/SVGLinearGradientElement.cpp
r43187 r49481 85 85 RefPtr<SVGPaintServerLinearGradient> linearGradient = WTF::static_pointer_cast<SVGPaintServerLinearGradient>(m_resource); 86 86 87 FloatPoint startPoint = FloatPoint::narrowPrecision(attributes.x1(), attributes.y1()); 88 FloatPoint endPoint = FloatPoint::narrowPrecision(attributes.x2(), attributes.y2()); 87 FloatPoint startPoint; 88 FloatPoint endPoint; 89 if (attributes.boundingBoxMode()) { 90 startPoint = FloatPoint(attributes.x1().valueAsPercentage(), attributes.y1().valueAsPercentage()); 91 endPoint = FloatPoint(attributes.x2().valueAsPercentage(), attributes.y2().valueAsPercentage()); 92 } else { 93 startPoint = FloatPoint(attributes.x1().value(this), attributes.y1().value(this)); 94 endPoint = FloatPoint(attributes.x2().value(this), attributes.y2().value(this)); 95 } 89 96 90 97 RefPtr<Gradient> gradient = Gradient::create(startPoint, endPoint); … … 143 150 144 151 if (!attributes.hasX1() && current->hasAttribute(SVGNames::x1Attr)) 145 attributes.setX1(linear->x1() .valueAsPercentage());152 attributes.setX1(linear->x1()); 146 153 147 154 if (!attributes.hasY1() && current->hasAttribute(SVGNames::y1Attr)) 148 attributes.setY1(linear->y1() .valueAsPercentage());155 attributes.setY1(linear->y1()); 149 156 150 157 if (!attributes.hasX2() && current->hasAttribute(SVGNames::x2Attr)) 151 attributes.setX2(linear->x2() .valueAsPercentage());158 attributes.setX2(linear->x2()); 152 159 153 160 if (!attributes.hasY2() && current->hasAttribute(SVGNames::y2Attr)) 154 attributes.setY2(linear->y2() .valueAsPercentage());161 attributes.setY2(linear->y2()); 155 162 } 156 163 -
trunk/WebCore/svg/SVGRadialGradientElement.cpp
r43187 r49481 93 93 RefPtr<SVGPaintServerRadialGradient> radialGradient = WTF::static_pointer_cast<SVGPaintServerRadialGradient>(m_resource); 94 94 95 double adjustedFocusX = attributes.fx(); 96 double adjustedFocusY = attributes.fy(); 97 98 double fdx = attributes.fx() - attributes.cx(); 99 double fdy = attributes.fy() - attributes.cy(); 95 FloatPoint focalPoint; 96 FloatPoint centerPoint; 97 float radius; 98 if (attributes.boundingBoxMode()) { 99 focalPoint = FloatPoint(attributes.fx().valueAsPercentage(), attributes.fy().valueAsPercentage()); 100 centerPoint = FloatPoint(attributes.cx().valueAsPercentage(), attributes.cy().valueAsPercentage()); 101 radius = attributes.r().valueAsPercentage(); 102 } else { 103 focalPoint = FloatPoint(attributes.fx().value(this), attributes.fy().value(this)); 104 centerPoint = FloatPoint(attributes.cx().value(this), attributes.cy().value(this)); 105 radius = attributes.r().value(this); 106 } 107 108 float adjustedFocusX = focalPoint.x(); 109 float adjustedFocusY = focalPoint.y(); 110 111 float fdx = focalPoint.x() - centerPoint.x(); 112 float fdy = focalPoint.y() - centerPoint.y(); 100 113 101 114 // Spec: If (fx, fy) lies outside the circle defined by (cx, cy) and 102 115 // r, set (fx, fy) to the point of intersection of the line through 103 116 // (fx, fy) and the circle. 104 if (sqrt(fdx * fdx + fdy * fdy) > attributes.r()) { 105 double angle = atan2(attributes.fy() * 100.0, attributes.fx() * 100.0); 106 adjustedFocusX = cos(angle) * attributes.r(); 107 adjustedFocusY = sin(angle) * attributes.r(); 108 } 109 110 FloatPoint focalPoint = FloatPoint::narrowPrecision(attributes.fx(), attributes.fy()); 111 FloatPoint centerPoint = FloatPoint::narrowPrecision(attributes.cx(), attributes.cy()); 117 if (sqrt(fdx * fdx + fdy * fdy) > radius) { 118 float angle = atan2f(focalPoint.y() * 100.0f, focalPoint.x() * 100.0f); 119 adjustedFocusX = cosf(angle) * radius; 120 adjustedFocusY = sinf(angle) * radius; 121 } 112 122 113 123 RefPtr<Gradient> gradient = Gradient::create( 114 FloatPoint ::narrowPrecision(adjustedFocusX, adjustedFocusY),124 FloatPoint(adjustedFocusX, adjustedFocusY), 115 125 0.f, // SVG does not support a "focus radius" 116 126 centerPoint, 117 narrowPrecisionToFloat(attributes.r()));127 radius); 118 128 gradient->setSpreadMethod(attributes.spreadMethod()); 119 129 … … 135 145 radialGradient->setGradientCenter(centerPoint); 136 146 radialGradient->setGradientFocal(focalPoint); 137 radialGradient->setGradientRadius( narrowPrecisionToFloat(attributes.r()));147 radialGradient->setGradientRadius(radius); 138 148 radialGradient->setGradientStops(attributes.stops()); 139 149 } … … 167 177 168 178 if (!attributes.hasCx() && current->hasAttribute(SVGNames::cxAttr)) 169 attributes.setCx(radial->cx() .valueAsPercentage());179 attributes.setCx(radial->cx()); 170 180 171 181 if (!attributes.hasCy() && current->hasAttribute(SVGNames::cyAttr)) 172 attributes.setCy(radial->cy() .valueAsPercentage());182 attributes.setCy(radial->cy()); 173 183 174 184 if (!attributes.hasR() && current->hasAttribute(SVGNames::rAttr)) 175 attributes.setR(radial->r() .valueAsPercentage());185 attributes.setR(radial->r()); 176 186 177 187 if (!attributes.hasFx() && current->hasAttribute(SVGNames::fxAttr)) 178 attributes.setFx(radial->fx() .valueAsPercentage());188 attributes.setFx(radial->fx()); 179 189 180 190 if (!attributes.hasFy() && current->hasAttribute(SVGNames::fyAttr)) 181 attributes.setFy(radial->fy() .valueAsPercentage());191 attributes.setFy(radial->fy()); 182 192 } 183 193
Note: See TracChangeset
for help on using the changeset viewer.