[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

eric at webkit.org eric at webkit.org
Thu Oct 29 20:43:29 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit 1f5042a405382a19cc13a60eab3b992cce13c4c0
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Oct 12 23:05:21 2009 +0000

    2009-10-12  Dirk Schulze  <krit at webkit.org>
    
            Reviewed by Nikolas Zimmermann.
    
            Three old test results give back the absolute position instead of the realtive position.
            The new test will check the correct behavior of gradients in userSpaceOnUse mode and
            values in percentage.
    
            * platform/mac/svg/custom/gradient-attr-update-expected.txt:
            * platform/mac/svg/custom/gradient-deep-referencing-expected.txt:
            * platform/mac/svg/custom/gradient-userSpaceOnUse-with-percentage-expected.checksum: Added.
            * platform/mac/svg/custom/gradient-userSpaceOnUse-with-percentage-expected.png: Added.
            * platform/mac/svg/custom/gradient-userSpaceOnUse-with-percentage-expected.txt: Added.
            * platform/mac/svg/custom/text-gradient-no-content-expected.txt:
            * svg/custom/gradient-userSpaceOnUse-with-percentage.svg: Added.
    2009-10-12  Dirk Schulze  <krit at webkit.org>
    
            Reviewed by Nikolas Zimmermann.
    
            SVG Gradients can't handle percentage values in userSpaceOnUse mode
            [https://bugs.webkit.org/show_bug.cgi?id=30286]
    
            Fixed *GradientAttributes to take SVGLength instead of double. This casues
            the problem, that we can't calculate the correct size of a gradient on
            userSpaceOnUse mode with percentage values.
    
            Test: svg/custom/gradient-userSpaceOnUse-with-percentage.svg
    
            * svg/LinearGradientAttributes.h:
            (WebCore::LinearGradientAttributes::LinearGradientAttributes):
            (WebCore::LinearGradientAttributes::x1):
            (WebCore::LinearGradientAttributes::y1):
            (WebCore::LinearGradientAttributes::x2):
            (WebCore::LinearGradientAttributes::y2):
            (WebCore::LinearGradientAttributes::setX1):
            (WebCore::LinearGradientAttributes::setY1):
            (WebCore::LinearGradientAttributes::setX2):
            (WebCore::LinearGradientAttributes::setY2):
            * svg/RadialGradientAttributes.h:
            (WebCore::RadialGradientAttributes::RadialGradientAttributes):
            (WebCore::RadialGradientAttributes::cx):
            (WebCore::RadialGradientAttributes::cy):
            (WebCore::RadialGradientAttributes::r):
            (WebCore::RadialGradientAttributes::fx):
            (WebCore::RadialGradientAttributes::fy):
            (WebCore::RadialGradientAttributes::setCx):
            (WebCore::RadialGradientAttributes::setCy):
            (WebCore::RadialGradientAttributes::setR):
            (WebCore::RadialGradientAttributes::setFx):
            (WebCore::RadialGradientAttributes::setFy):
            * svg/SVGLinearGradientElement.cpp:
            (WebCore::SVGLinearGradientElement::buildGradient):
            (WebCore::SVGLinearGradientElement::collectGradientProperties):
            * svg/SVGRadialGradientElement.cpp:
            (WebCore::SVGRadialGradientElement::buildGradient):
            (WebCore::SVGRadialGradientElement::collectGradientProperties):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49481 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 9226f10..fdfd851 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,5 +1,21 @@
 2009-10-12  Dirk Schulze  <krit at webkit.org>
 
+        Reviewed by Nikolas Zimmermann.
+
+        Three old test results give back the absolute position instead of the realtive position.
+        The new test will check the correct behavior of gradients in userSpaceOnUse mode and
+        values in percentage.
+
+        * platform/mac/svg/custom/gradient-attr-update-expected.txt:
+        * platform/mac/svg/custom/gradient-deep-referencing-expected.txt:
+        * platform/mac/svg/custom/gradient-userSpaceOnUse-with-percentage-expected.checksum: Added.
+        * platform/mac/svg/custom/gradient-userSpaceOnUse-with-percentage-expected.png: Added.
+        * platform/mac/svg/custom/gradient-userSpaceOnUse-with-percentage-expected.txt: Added.
+        * platform/mac/svg/custom/text-gradient-no-content-expected.txt:
+        * svg/custom/gradient-userSpaceOnUse-with-percentage.svg: Added.
+
+2009-10-12  Dirk Schulze  <krit at webkit.org>
+
         Reviewed by Eirc Seidel.
 
         feMergeNod has a reference to an effect that doesn't exist. This test will
diff --git a/LayoutTests/platform/mac/svg/custom/gradient-attr-update-expected.txt b/LayoutTests/platform/mac/svg/custom/gradient-attr-update-expected.txt
index c62530f..2686834 100644
--- a/LayoutTests/platform/mac/svg/custom/gradient-attr-update-expected.txt
+++ b/LayoutTests/platform/mac/svg/custom/gradient-attr-update-expected.txt
@@ -1,4 +1,4 @@
-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]}
+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]}
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 800x600
@@ -7,4 +7,4 @@ layer at (0,0) size 800x600
       RenderSVGHiddenContainer {radialGradient} at (0,0) size 0x0
         RenderSVGGradientStop {stop} at (0,0) size 0x0
         RenderSVGGradientStop {stop} at (0,0) size 0x0
-    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"]
+    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"]
diff --git a/LayoutTests/platform/mac/svg/custom/gradient-deep-referencing-expected.txt b/LayoutTests/platform/mac/svg/custom/gradient-deep-referencing-expected.txt
index 1f6e302..9330a99 100644
--- a/LayoutTests/platform/mac/svg/custom/gradient-deep-referencing-expected.txt
+++ b/LayoutTests/platform/mac/svg/custom/gradient-deep-referencing-expected.txt
@@ -1,7 +1,7 @@
 KRenderingPaintServer {id="gradient1f" [type=LINEAR-GRADIENT] [stops=[(0.00,#FF0000), (1.00,#0000FF)]] [bounding box mode=0] [start=(0,100)] [end=(100,100)]}
 KRenderingPaintServer {id="gradient1e" [type=LINEAR-GRADIENT] [stops=[(0.00,#FF0000), (1.00,#0000FF)]] [bounding box mode=0] [start=(0,100)] [end=(100,0)]}
 KRenderingPaintServer {id="gradient1d" [type=LINEAR-GRADIENT] [stops=[(0.00,#FF0000), (1.00,#0000FF)]] [bounding box mode=0] [start=(0,100)] [end=(100,0)]}
-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]}
+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]}
 KRenderingPaintServer {id="gradient1b" [type=LINEAR-GRADIENT] [stops=[]] [start=(0,0)] [end=(0,0)]}
 KRenderingPaintServer {id="gradient1a" [type=LINEAR-GRADIENT] [stops=[]] [start=(0,0)] [end=(0,0)]}
 KRenderingPaintServer {id="gradient1" [type=LINEAR-GRADIENT] [stops=[(0.00,#FF0000), (1.00,#0000FF)]] [bounding box mode=0] [start=(0,100)] [end=(100,100)]}
diff --git a/LayoutTests/platform/mac/svg/custom/gradient-userSpaceOnUse-with-percentage-expected.checksum b/LayoutTests/platform/mac/svg/custom/gradient-userSpaceOnUse-with-percentage-expected.checksum
new file mode 100644
index 0000000..befedcb
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/custom/gradient-userSpaceOnUse-with-percentage-expected.checksum
@@ -0,0 +1 @@
+536fdfd5d9140deaec9ec93ac250adaf
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/custom/gradient-userSpaceOnUse-with-percentage-expected.png b/LayoutTests/platform/mac/svg/custom/gradient-userSpaceOnUse-with-percentage-expected.png
new file mode 100644
index 0000000..1bcaf07
Binary files /dev/null and b/LayoutTests/platform/mac/svg/custom/gradient-userSpaceOnUse-with-percentage-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/custom/gradient-userSpaceOnUse-with-percentage-expected.txt b/LayoutTests/platform/mac/svg/custom/gradient-userSpaceOnUse-with-percentage-expected.txt
new file mode 100644
index 0000000..a8e3b03
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/custom/gradient-userSpaceOnUse-with-percentage-expected.txt
@@ -0,0 +1,20 @@
+KRenderingPaintServer {id="gradient1" [type=LINEAR-GRADIENT] [stops=[(0.00,#FF0000), (1.00,#00FF00)]] [bounding box mode=0] [start=(0,0)] [end=(150,0)]}
+KRenderingPaintServer {id="gradient2" [type=LINEAR-GRADIENT] [stops=[(0.00,#FF0000), (1.00,#00FF00)]] [bounding box mode=0] [start=(0,0)] [end=(150,0)]}
+KRenderingPaintServer {id="gradient3" [type=RADIAL-GRADIENT] [stops=[(0.00,#00FF00), (1.00,#FF0000)]] [bounding box mode=0] [center=(150,264)] [focal=(150,264)] [radius=282.84]}
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 300x400
+  RenderSVGRoot {svg} at (0,0) size 300x400
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderSVGHiddenContainer {linearGradient} at (0,0) size 0x0
+        RenderSVGGradientStop {stop} at (0,0) size 0x0
+        RenderSVGGradientStop {stop} at (0,0) size 0x0
+      RenderSVGHiddenContainer {linearGradient} at (0,0) size 0x0
+        RenderSVGGradientStop {stop} at (0,0) size 0x0
+        RenderSVGGradientStop {stop} at (0,0) size 0x0
+      RenderSVGHiddenContainer {radialGradient} at (0,0) size 0x0
+        RenderSVGGradientStop {stop} at (0,0) size 0x0
+        RenderSVGGradientStop {stop} at (0,0) size 0x0
+    RenderPath {rect} at (0,0) size 300x50 [fill={[type=LINEAR-GRADIENT] [stops=[(0.00,#FF0000), (1.00,#00FF00)]] [bounding box mode=0] [start=(0,0)] [end=(150,0)]}] [data="M0.00,0.00 L300.00,0.00 L300.00,50.00 L0.00,50.00 Z"]
+    RenderPath {rect} at (0,50) size 300x50 [fill={[type=LINEAR-GRADIENT] [stops=[(0.00,#FF0000), (1.00,#00FF00)]] [bounding box mode=0] [start=(0,0)] [end=(150,0)]}] [data="M0.00,50.00 L300.00,50.00 L300.00,100.00 L0.00,100.00 Z"]
+    RenderPath {rect} at (0,100) size 300x300 [fill={[type=RADIAL-GRADIENT] [stops=[(0.00,#00FF00), (1.00,#FF0000)]] [bounding box mode=0] [center=(150,264)] [focal=(150,264)] [radius=282.84]}] [data="M0.00,100.00 L300.00,100.00 L300.00,400.00 L0.00,400.00 Z"]
diff --git a/LayoutTests/platform/mac/svg/custom/text-gradient-no-content-expected.txt b/LayoutTests/platform/mac/svg/custom/text-gradient-no-content-expected.txt
index 754be20..c1f20c5 100644
--- a/LayoutTests/platform/mac/svg/custom/text-gradient-no-content-expected.txt
+++ b/LayoutTests/platform/mac/svg/custom/text-gradient-no-content-expected.txt
@@ -1,4 +1,4 @@
-KRenderingPaintServer {id="Gradient" [type=LINEAR-GRADIENT] [stops=[(0.00,#FF0000), (1.00,#FF0000)]] [bounding box mode=0] [start=(0,0)] [end=(1,0)]}
+KRenderingPaintServer {id="Gradient" [type=LINEAR-GRADIENT] [stops=[(0.00,#FF0000), (1.00,#FF0000)]] [bounding box mode=0] [start=(0,0)] [end=(800,0)]}
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 800x600
diff --git a/LayoutTests/svg/custom/gradient-userSpaceOnUse-with-percentage.svg b/LayoutTests/svg/custom/gradient-userSpaceOnUse-with-percentage.svg
new file mode 100644
index 0000000..69d9e59
--- /dev/null
+++ b/LayoutTests/svg/custom/gradient-userSpaceOnUse-with-percentage.svg
@@ -0,0 +1,23 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="300" height="400">
+
+<defs>
+<!-- tests if WebKit uses the percentage values, if gradientUnits is userSpaceOnUse-->
+<linearGradient id="gradient1" x1="0%" y1="0%" x2="50%" y2="0%" gradientUnits="userSpaceOnUse">
+    <stop offset="0%" style="stop-color:rgb(255,0,0);stop-opacity:1"/>
+    <stop offset="100%" style="stop-color:rgb(0,255,0);stop-opacity:1"/>
+</linearGradient>
+<linearGradient id="gradient2" x1="0" y1="0" x2="150" y2="0" gradientUnits="userSpaceOnUse">
+    <stop offset="0%" style="stop-color:rgb(255,0,0);stop-opacity:1"/>
+    <stop offset="100%" style="stop-color:rgb(0,255,0);stop-opacity:1"/>
+</linearGradient>
+<radialGradient id="gradient3" cx="50%" cy="66%" r="80%" gradientUnits="userSpaceOnUse">
+    <stop offset="0%" style="stop-color:rgb(0,255,0);stop-opacity:1"/>
+    <stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1"/>
+</radialGradient>
+</defs>
+
+<rect x="0" y="0" width="300" height="50" fill="url(#gradient1)"/>
+<rect x="0" y="50" width="300" height="50" fill="url(#gradient2)"/>
+<rect x="0" y="100" width="300" height="300" fill="url(#gradient3)"/>
+</svg>
+
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index bd757ff..bf5e0ef 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,45 @@
+2009-10-12  Dirk Schulze  <krit at webkit.org>
+
+        Reviewed by Nikolas Zimmermann.
+
+        SVG Gradients can't handle percentage values in userSpaceOnUse mode
+        [https://bugs.webkit.org/show_bug.cgi?id=30286]
+
+        Fixed *GradientAttributes to take SVGLength instead of double. This casues
+        the problem, that we can't calculate the correct size of a gradient on
+        userSpaceOnUse mode with percentage values.
+
+        Test: svg/custom/gradient-userSpaceOnUse-with-percentage.svg
+
+        * svg/LinearGradientAttributes.h:
+        (WebCore::LinearGradientAttributes::LinearGradientAttributes):
+        (WebCore::LinearGradientAttributes::x1):
+        (WebCore::LinearGradientAttributes::y1):
+        (WebCore::LinearGradientAttributes::x2):
+        (WebCore::LinearGradientAttributes::y2):
+        (WebCore::LinearGradientAttributes::setX1):
+        (WebCore::LinearGradientAttributes::setY1):
+        (WebCore::LinearGradientAttributes::setX2):
+        (WebCore::LinearGradientAttributes::setY2):
+        * svg/RadialGradientAttributes.h:
+        (WebCore::RadialGradientAttributes::RadialGradientAttributes):
+        (WebCore::RadialGradientAttributes::cx):
+        (WebCore::RadialGradientAttributes::cy):
+        (WebCore::RadialGradientAttributes::r):
+        (WebCore::RadialGradientAttributes::fx):
+        (WebCore::RadialGradientAttributes::fy):
+        (WebCore::RadialGradientAttributes::setCx):
+        (WebCore::RadialGradientAttributes::setCy):
+        (WebCore::RadialGradientAttributes::setR):
+        (WebCore::RadialGradientAttributes::setFx):
+        (WebCore::RadialGradientAttributes::setFy):
+        * svg/SVGLinearGradientElement.cpp:
+        (WebCore::SVGLinearGradientElement::buildGradient):
+        (WebCore::SVGLinearGradientElement::collectGradientProperties):
+        * svg/SVGRadialGradientElement.cpp:
+        (WebCore::SVGRadialGradientElement::buildGradient):
+        (WebCore::SVGRadialGradientElement::collectGradientProperties):
+
 2009-10-12  Brian Weinstein  <bweinstein at apple.com>
 
         Reviewed by Timothy Hatcher.
diff --git a/WebCore/svg/LinearGradientAttributes.h b/WebCore/svg/LinearGradientAttributes.h
index fc59465..0aefbac 100644
--- a/WebCore/svg/LinearGradientAttributes.h
+++ b/WebCore/svg/LinearGradientAttributes.h
@@ -29,10 +29,10 @@
 namespace WebCore {
     struct LinearGradientAttributes : GradientAttributes {
         LinearGradientAttributes()
-            : m_x1(0.0)
-            , m_y1(0.0)
-            , m_x2(1.0)
-            , m_y2(0.0)
+            : m_x1()
+            , m_y1()
+            , m_x2(LengthModeWidth, "100%")
+            , m_y2()
             , m_x1Set(false)
             , m_y1Set(false)
             , m_x2Set(false)
@@ -40,15 +40,15 @@ namespace WebCore {
         {
         }
 
-        double x1() const { return m_x1; }
-        double y1() const { return m_y1; }
-        double x2() const { return m_x2; }
-        double y2() const { return m_y2; }
+        SVGLength x1() const { return m_x1; }
+        SVGLength y1() const { return m_y1; }
+        SVGLength x2() const { return m_x2; }
+        SVGLength y2() const { return m_y2; }
 
-        void setX1(double value) { m_x1 = value; m_x1Set = true; }
-        void setY1(double value) { m_y1 = value; m_y1Set = true; }
-        void setX2(double value) { m_x2 = value; m_x2Set = true; }
-        void setY2(double value) { m_y2 = value; m_y2Set = true; }
+        void setX1(const SVGLength& value) { m_x1 = value; m_x1Set = true; }
+        void setY1(const SVGLength& value) { m_y1 = value; m_y1Set = true; }
+        void setX2(const SVGLength& value) { m_x2 = value; m_x2Set = true; }
+        void setY2(const SVGLength& value) { m_y2 = value; m_y2Set = true; }
 
         bool hasX1() const { return m_x1Set; }
         bool hasY1() const { return m_y1Set; }
@@ -57,10 +57,10 @@ namespace WebCore {
 
     private:
         // Properties
-        double m_x1;
-        double m_y1;
-        double m_x2;
-        double m_y2;
+        SVGLength m_x1;
+        SVGLength m_y1;
+        SVGLength m_x2;
+        SVGLength m_y2;
 
         // Property states
         bool m_x1Set : 1;
diff --git a/WebCore/svg/RadialGradientAttributes.h b/WebCore/svg/RadialGradientAttributes.h
index 273cd29..7645721 100644
--- a/WebCore/svg/RadialGradientAttributes.h
+++ b/WebCore/svg/RadialGradientAttributes.h
@@ -29,11 +29,11 @@
 namespace WebCore {
     struct RadialGradientAttributes : GradientAttributes {
         RadialGradientAttributes()
-            : m_cx(0.5)
-            , m_cy(0.5)
-            , m_r(0.5)
-            , m_fx(0.0)
-            , m_fy(0.0)
+            : m_cx(LengthModeWidth, "50%")
+            , m_cy(LengthModeWidth, "50%")
+            , m_r(LengthModeWidth, "50%")
+            , m_fx()
+            , m_fy()
             , m_cxSet(false)
             , m_cySet(false)
             , m_rSet(false)
@@ -42,17 +42,17 @@ namespace WebCore {
         {
         }
 
-        double cx() const { return m_cx; }
-        double cy() const { return m_cy; }
-        double r() const { return m_r; }
-        double fx() const { return m_fx; }
-        double fy() const { return m_fy; }
+        SVGLength cx() const { return m_cx; }
+        SVGLength cy() const { return m_cy; }
+        SVGLength r() const { return m_r; }
+        SVGLength fx() const { return m_fx; }
+        SVGLength fy() const { return m_fy; }
 
-        void setCx(double value) { m_cx = value; m_cxSet = true; }
-        void setCy(double value) { m_cy = value; m_cySet = true; }
-        void setR(double value) { m_r = value; m_rSet = true; }
-        void setFx(double value) { m_fx = value; m_fxSet = true; }
-        void setFy(double value) { m_fy = value; m_fySet = true; }
+        void setCx(const SVGLength& value) { m_cx = value; m_cxSet = true; }
+        void setCy(const SVGLength& value) { m_cy = value; m_cySet = true; }
+        void setR(const SVGLength& value) { m_r = value; m_rSet = true; }
+        void setFx(const SVGLength& value) { m_fx = value; m_fxSet = true; }
+        void setFy(const SVGLength& value) { m_fy = value; m_fySet = true; }
 
         bool hasCx() const { return m_cxSet; }
         bool hasCy() const { return m_cySet; }
@@ -62,11 +62,11 @@ namespace WebCore {
 
     private:
         // Properties
-        double m_cx;
-        double m_cy;
-        double m_r;
-        double m_fx;
-        double m_fy;
+        SVGLength m_cx;
+        SVGLength m_cy;
+        SVGLength m_r;
+        SVGLength m_fx;
+        SVGLength m_fy;
 
         // Property states
         bool m_cxSet : 1;
diff --git a/WebCore/svg/SVGLinearGradientElement.cpp b/WebCore/svg/SVGLinearGradientElement.cpp
index 9927a50..f5c8cee 100644
--- a/WebCore/svg/SVGLinearGradientElement.cpp
+++ b/WebCore/svg/SVGLinearGradientElement.cpp
@@ -84,8 +84,15 @@ void SVGLinearGradientElement::buildGradient() const
 
     RefPtr<SVGPaintServerLinearGradient> linearGradient = WTF::static_pointer_cast<SVGPaintServerLinearGradient>(m_resource);
 
-    FloatPoint startPoint = FloatPoint::narrowPrecision(attributes.x1(), attributes.y1());
-    FloatPoint endPoint = FloatPoint::narrowPrecision(attributes.x2(), attributes.y2());
+    FloatPoint startPoint;
+    FloatPoint endPoint;
+    if (attributes.boundingBoxMode()) {
+        startPoint = FloatPoint(attributes.x1().valueAsPercentage(), attributes.y1().valueAsPercentage());
+        endPoint = FloatPoint(attributes.x2().valueAsPercentage(), attributes.y2().valueAsPercentage());
+    } else {
+        startPoint = FloatPoint(attributes.x1().value(this), attributes.y1().value(this));
+        endPoint = FloatPoint(attributes.x2().value(this), attributes.y2().value(this));
+    }
 
     RefPtr<Gradient> gradient = Gradient::create(startPoint, endPoint);
     gradient->setSpreadMethod(attributes.spreadMethod());
@@ -142,16 +149,16 @@ LinearGradientAttributes SVGLinearGradientElement::collectGradientProperties() c
             const SVGLinearGradientElement* linear = static_cast<const SVGLinearGradientElement*>(current);
 
             if (!attributes.hasX1() && current->hasAttribute(SVGNames::x1Attr))
-                attributes.setX1(linear->x1().valueAsPercentage());
+                attributes.setX1(linear->x1());
 
             if (!attributes.hasY1() && current->hasAttribute(SVGNames::y1Attr))
-                attributes.setY1(linear->y1().valueAsPercentage());
+                attributes.setY1(linear->y1());
 
             if (!attributes.hasX2() && current->hasAttribute(SVGNames::x2Attr))
-                attributes.setX2(linear->x2().valueAsPercentage());
+                attributes.setX2(linear->x2());
 
             if (!attributes.hasY2() && current->hasAttribute(SVGNames::y2Attr))
-                attributes.setY2(linear->y2().valueAsPercentage());
+                attributes.setY2(linear->y2());
         }
 
         processedGradients.add(current);
diff --git a/WebCore/svg/SVGRadialGradientElement.cpp b/WebCore/svg/SVGRadialGradientElement.cpp
index 23a8579..a9b5cff 100644
--- a/WebCore/svg/SVGRadialGradientElement.cpp
+++ b/WebCore/svg/SVGRadialGradientElement.cpp
@@ -92,29 +92,39 @@ void SVGRadialGradientElement::buildGradient() const
 
     RefPtr<SVGPaintServerRadialGradient> radialGradient = WTF::static_pointer_cast<SVGPaintServerRadialGradient>(m_resource);
 
-    double adjustedFocusX = attributes.fx();
-    double adjustedFocusY = attributes.fy();
+    FloatPoint focalPoint;
+    FloatPoint centerPoint;
+    float radius;
+    if (attributes.boundingBoxMode()) {
+        focalPoint = FloatPoint(attributes.fx().valueAsPercentage(), attributes.fy().valueAsPercentage());
+        centerPoint = FloatPoint(attributes.cx().valueAsPercentage(), attributes.cy().valueAsPercentage());
+        radius = attributes.r().valueAsPercentage();
+    } else {
+        focalPoint = FloatPoint(attributes.fx().value(this), attributes.fy().value(this));
+        centerPoint = FloatPoint(attributes.cx().value(this), attributes.cy().value(this));
+        radius = attributes.r().value(this);
+    }
+
+    float adjustedFocusX = focalPoint.x();
+    float adjustedFocusY = focalPoint.y();
 
-    double fdx = attributes.fx() - attributes.cx();
-    double fdy = attributes.fy() - attributes.cy();
+    float fdx = focalPoint.x() - centerPoint.x();
+    float fdy = focalPoint.y() - centerPoint.y();
 
     // Spec: If (fx, fy) lies outside the circle defined by (cx, cy) and
     // r, set (fx, fy) to the point of intersection of the line through
     // (fx, fy) and the circle.
-    if (sqrt(fdx * fdx + fdy * fdy) > attributes.r()) {
-        double angle = atan2(attributes.fy() * 100.0, attributes.fx() * 100.0);
-        adjustedFocusX = cos(angle) * attributes.r();
-        adjustedFocusY = sin(angle) * attributes.r();
+    if (sqrt(fdx * fdx + fdy * fdy) > radius) {
+        float angle = atan2f(focalPoint.y() * 100.0f, focalPoint.x() * 100.0f);
+        adjustedFocusX = cosf(angle) * radius;
+        adjustedFocusY = sinf(angle) * radius;
     }
 
-    FloatPoint focalPoint = FloatPoint::narrowPrecision(attributes.fx(), attributes.fy());
-    FloatPoint centerPoint = FloatPoint::narrowPrecision(attributes.cx(), attributes.cy());
-
     RefPtr<Gradient> gradient = Gradient::create(
-        FloatPoint::narrowPrecision(adjustedFocusX, adjustedFocusY),
+        FloatPoint(adjustedFocusX, adjustedFocusY),
         0.f, // SVG does not support a "focus radius"
         centerPoint,
-        narrowPrecisionToFloat(attributes.r()));
+        radius);
     gradient->setSpreadMethod(attributes.spreadMethod());
 
     Vector<SVGGradientStop> stops = attributes.stops();
@@ -134,7 +144,7 @@ void SVGRadialGradientElement::buildGradient() const
     radialGradient->setGradientTransform(attributes.gradientTransform());
     radialGradient->setGradientCenter(centerPoint);
     radialGradient->setGradientFocal(focalPoint);
-    radialGradient->setGradientRadius(narrowPrecisionToFloat(attributes.r()));
+    radialGradient->setGradientRadius(radius);
     radialGradient->setGradientStops(attributes.stops());
 }
 
@@ -166,19 +176,19 @@ RadialGradientAttributes SVGRadialGradientElement::collectGradientProperties() c
             const SVGRadialGradientElement* radial = static_cast<const SVGRadialGradientElement*>(current);
 
             if (!attributes.hasCx() && current->hasAttribute(SVGNames::cxAttr))
-                attributes.setCx(radial->cx().valueAsPercentage());
+                attributes.setCx(radial->cx());
 
             if (!attributes.hasCy() && current->hasAttribute(SVGNames::cyAttr))
-                attributes.setCy(radial->cy().valueAsPercentage());
+                attributes.setCy(radial->cy());
 
             if (!attributes.hasR() && current->hasAttribute(SVGNames::rAttr))
-                attributes.setR(radial->r().valueAsPercentage());
+                attributes.setR(radial->r());
 
             if (!attributes.hasFx() && current->hasAttribute(SVGNames::fxAttr))
-                attributes.setFx(radial->fx().valueAsPercentage());
+                attributes.setFx(radial->fx());
 
             if (!attributes.hasFy() && current->hasAttribute(SVGNames::fyAttr))
-                attributes.setFy(radial->fy().valueAsPercentage());
+                attributes.setFy(radial->fy());
         }
 
         processedGradients.add(current);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list