Title: [172711] trunk
Revision
172711
Author
k...@webkit.org
Date
2014-08-18 11:18:16 -0700 (Mon, 18 Aug 2014)

Log Message

calc() doesn't work for SVG CSS properties
https://bugs.webkit.org/show_bug.cgi?id=136026

Reviewed by Andreas Kling.

Source/WebCore:

Make calc() work on SVG CSS properties as well. stroke-width and
stroke-dashoffset used SVGLength. SVGLength doesn't work together with
cross units length arguments like % and px (just returns 0 in these
cases). I moved these properties over to Length. All modified files
beside to SVGCSSParser are related to this switch.

Test: svg/css/parse-calc-length.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::propertyValue):
* css/DeprecatedStyleBuilder.cpp:
(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
* css/SVGCSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::svgPropertyValue):
* css/SVGCSSParser.cpp:
(WebCore::CSSParser::parseSVGValue):
* css/SVGCSSStyleSelector.cpp:
(WebCore::StyleResolver::applySVGProperty):
* page/animation/CSSPropertyAnimation.cpp:
(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
* rendering/style/RenderStyle.h:
* rendering/style/SVGRenderStyle.h:
(WebCore::SVGRenderStyle::setStrokeWidth):
(WebCore::SVGRenderStyle::setStrokeDashOffset):
(WebCore::SVGRenderStyle::strokeWidth):
(WebCore::SVGRenderStyle::strokeDashOffset):
(WebCore::SVGRenderStyle::initialStrokeDashOffset): Deleted.
(WebCore::SVGRenderStyle::initialStrokeWidth): Deleted.
* rendering/style/SVGRenderStyleDefs.cpp:
(WebCore::StyleStrokeData::StyleStrokeData):
* rendering/style/SVGRenderStyleDefs.h:
* rendering/svg/RenderSVGShape.cpp:
(WebCore::RenderSVGShape::strokeWidth):
* rendering/svg/RenderSVGText.cpp:
(WebCore::RenderSVGText::strokeBoundingBox):
* rendering/svg/SVGRenderSupport.cpp:
(WebCore::SVGRenderSupport::applyStrokeStyleToContext):
* rendering/svg/SVGRenderTreeAsText.cpp:
(WebCore::writeStyle):
* svg/SVGLengthContext.cpp:
(WebCore::SVGLengthContext::valueForLength):

LayoutTests:

Test calc() on length properties for SVG.

* svg/css/getComputedStyle-basic-expected.txt:
* svg/css/parse-calc-length-expected.txt: Added.
* svg/css/parse-calc-length.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (172710 => 172711)


--- trunk/LayoutTests/ChangeLog	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/LayoutTests/ChangeLog	2014-08-18 18:18:16 UTC (rev 172711)
@@ -1,3 +1,16 @@
+2014-08-18  Dirk Schulze  <k...@webkit.org>
+
+        calc() doesn't work for SVG CSS properties
+        https://bugs.webkit.org/show_bug.cgi?id=136026
+
+        Reviewed by Andreas Kling.
+
+        Test calc() on length properties for SVG.
+
+        * svg/css/getComputedStyle-basic-expected.txt:
+        * svg/css/parse-calc-length-expected.txt: Added.
+        * svg/css/parse-calc-length.html: Added.
+
 2014-08-18  Andy Estes  <aes...@apple.com>
 
         REGRESSION (r167856): adobe.com no longer able to launch Create Cloud app using a URL with a custom scheme

Modified: trunk/LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt (172710 => 172711)


--- trunk/LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt	2014-08-18 18:18:16 UTC (rev 172711)
@@ -240,12 +240,12 @@
 shape-rendering: auto;
 stroke: none;
 stroke-dasharray: none;
-stroke-dashoffset: 0;
+stroke-dashoffset: 0px;
 stroke-linecap: butt;
 stroke-linejoin: miter;
 stroke-miterlimit: 4;
 stroke-opacity: 1;
-stroke-width: 1;
+stroke-width: 1px;
 alignment-baseline: auto;
 baseline-shift: baseline;
 dominant-baseline: auto;

Modified: trunk/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt (172710 => 172711)


--- trunk/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt	2014-08-18 18:18:16 UTC (rev 172711)
@@ -239,12 +239,12 @@
 shape-rendering: auto
 stroke: none
 stroke-dasharray: none
-stroke-dashoffset: 0
+stroke-dashoffset: 0px
 stroke-linecap: butt
 stroke-linejoin: miter
 stroke-miterlimit: 4
 stroke-opacity: 1
-stroke-width: 1
+stroke-width: 1px
 alignment-baseline: auto
 baseline-shift: baseline
 dominant-baseline: auto

Modified: trunk/LayoutTests/svg/css/getComputedStyle-basic-expected.txt (172710 => 172711)


--- trunk/LayoutTests/svg/css/getComputedStyle-basic-expected.txt	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/LayoutTests/svg/css/getComputedStyle-basic-expected.txt	2014-08-18 18:18:16 UTC (rev 172711)
@@ -478,7 +478,7 @@
 rect: style.getPropertyCSSValue(stroke) : [object SVGPaint]
 rect: style.getPropertyValue(stroke-dasharray) : none
 rect: style.getPropertyCSSValue(stroke-dasharray) : [object CSSPrimitiveValue]
-rect: style.getPropertyValue(stroke-dashoffset) : 0
+rect: style.getPropertyValue(stroke-dashoffset) : 0px
 rect: style.getPropertyCSSValue(stroke-dashoffset) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(stroke-linecap) : butt
 rect: style.getPropertyCSSValue(stroke-linecap) : [object CSSPrimitiveValue]
@@ -990,7 +990,7 @@
 g: style.getPropertyCSSValue(stroke) : [object SVGPaint]
 g: style.getPropertyValue(stroke-dasharray) : none
 g: style.getPropertyCSSValue(stroke-dasharray) : [object CSSPrimitiveValue]
-g: style.getPropertyValue(stroke-dashoffset) : 0
+g: style.getPropertyValue(stroke-dashoffset) : 0px
 g: style.getPropertyCSSValue(stroke-dashoffset) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(stroke-linecap) : butt
 g: style.getPropertyCSSValue(stroke-linecap) : [object CSSPrimitiveValue]

Added: trunk/LayoutTests/svg/css/parse-calc-length-expected.txt (0 => 172711)


--- trunk/LayoutTests/svg/css/parse-calc-length-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/css/parse-calc-length-expected.txt	2014-08-18 18:18:16 UTC (rev 172711)
@@ -0,0 +1,87 @@
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute height="calc(500px - 400px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute rx="calc(500px - 400px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute ry="calc(500px - 400px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute width="calc(500px - 400px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute x="calc(500px - 400px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute y="calc(500px - 400px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute height="calc(40px + 60px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute rx="calc(40px + 60px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute ry="calc(40px + 60px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute width="calc(40px + 60px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute x="calc(40px + 60px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute y="calc(40px + 60px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute height="calc(0% + 100px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute rx="calc(0% + 100px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute ry="calc(0% + 100px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute width="calc(0% + 100px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute x="calc(0% + 100px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute y="calc(0% + 100px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute height="calc(100% - 100px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute rx="calc(100% - 100px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute ry="calc(100% - 100px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute width="calc(100% - 100px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute x="calc(100% - 100px)"
+CONSOLE MESSAGE: Error: Invalid value for <rect> attribute y="calc(100% - 100px)"
+Test that length values for presentation attribute accept calc.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS computedStyle("baseline-shift", "calc(500px - 400px)") is "100px"
+PASS computedStyle("cx", "calc(500px - 400px)") is "100px"
+PASS computedStyle("cy", "calc(500px - 400px)") is "100px"
+PASS computedStyle("height", "calc(500px - 400px)") is "100px"
+PASS computedStyle("kerning", "calc(500px - 400px)") is "100px"
+PASS computedStyle("r", "calc(500px - 400px)") is "100px"
+PASS computedStyle("rx", "calc(500px - 400px)") is "100px"
+PASS computedStyle("ry", "calc(500px - 400px)") is "100px"
+PASS computedStyle("stroke-width", "calc(500px - 400px)") is "100px"
+PASS computedStyle("stroke-dashoffset", "calc(500px - 400px)") is "100px"
+PASS computedStyle("width", "calc(500px - 400px)") is "100px"
+PASS computedStyle("x", "calc(500px - 400px)") is "100px"
+PASS computedStyle("y", "calc(500px - 400px)") is "100px"
+PASS computedStyle("baseline-shift", "calc(40px + 60px)") is "100px"
+PASS computedStyle("cx", "calc(40px + 60px)") is "100px"
+PASS computedStyle("cy", "calc(40px + 60px)") is "100px"
+PASS computedStyle("height", "calc(40px + 60px)") is "100px"
+PASS computedStyle("kerning", "calc(40px + 60px)") is "100px"
+PASS computedStyle("r", "calc(40px + 60px)") is "100px"
+PASS computedStyle("rx", "calc(40px + 60px)") is "100px"
+PASS computedStyle("ry", "calc(40px + 60px)") is "100px"
+PASS computedStyle("stroke-width", "calc(40px + 60px)") is "100px"
+PASS computedStyle("stroke-dashoffset", "calc(40px + 60px)") is "100px"
+PASS computedStyle("width", "calc(40px + 60px)") is "100px"
+PASS computedStyle("x", "calc(40px + 60px)") is "100px"
+PASS computedStyle("y", "calc(40px + 60px)") is "100px"
+PASS computedStyle("baseline-shift", "calc(0% + 100px)") is "0"
+PASS computedStyle("cx", "calc(0% + 100px)") is "calc(0% + 100px)"
+PASS computedStyle("cy", "calc(0% + 100px)") is "calc(0% + 100px)"
+PASS computedStyle("height", "calc(0% + 100px)") is "calc(0% + 100px)"
+PASS computedStyle("kerning", "calc(0% + 100px)") is "0"
+PASS computedStyle("r", "calc(0% + 100px)") is "calc(0% + 100px)"
+PASS computedStyle("rx", "calc(0% + 100px)") is "calc(0% + 100px)"
+PASS computedStyle("ry", "calc(0% + 100px)") is "calc(0% + 100px)"
+PASS computedStyle("stroke-width", "calc(0% + 100px)") is "calc(0% + 100px)"
+PASS computedStyle("stroke-dashoffset", "calc(0% + 100px)") is "calc(0% + 100px)"
+PASS computedStyle("width", "calc(0% + 100px)") is "calc(0% + 100px)"
+PASS computedStyle("x", "calc(0% + 100px)") is "calc(0% + 100px)"
+PASS computedStyle("y", "calc(0% + 100px)") is "calc(0% + 100px)"
+PASS computedStyle("baseline-shift", "calc(100% - 100px)") is "0"
+PASS computedStyle("cx", "calc(100% - 100px)") is "calc(100% - 100px)"
+PASS computedStyle("cy", "calc(100% - 100px)") is "calc(100% - 100px)"
+PASS computedStyle("height", "calc(100% - 100px)") is "calc(100% - 100px)"
+PASS computedStyle("kerning", "calc(100% - 100px)") is "0"
+PASS computedStyle("r", "calc(100% - 100px)") is "calc(100% - 100px)"
+PASS computedStyle("rx", "calc(100% - 100px)") is "calc(100% - 100px)"
+PASS computedStyle("ry", "calc(100% - 100px)") is "calc(100% - 100px)"
+PASS computedStyle("stroke-width", "calc(100% - 100px)") is "calc(100% - 100px)"
+PASS computedStyle("stroke-dashoffset", "calc(100% - 100px)") is "calc(100% - 100px)"
+PASS computedStyle("width", "calc(100% - 100px)") is "calc(100% - 100px)"
+PASS computedStyle("x", "calc(100% - 100px)") is "calc(100% - 100px)"
+PASS computedStyle("y", "calc(100% - 100px)") is "calc(100% - 100px)"
+PASS computedStyle("stroke-miterlimit", "calc(500 - 400)") is "100"
+PASS computedStyle("flood-opacity", "calc(500 - 400)") is "100"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/svg/css/parse-calc-length.html (0 => 172711)


--- trunk/LayoutTests/svg/css/parse-calc-length.html	                        (rev 0)
+++ trunk/LayoutTests/svg/css/parse-calc-length.html	2014-08-18 18:18:16 UTC (rev 172711)
@@ -0,0 +1,102 @@
+<!DOCTYPE html>
+<html>
+<style>
+* { font-size: 16px; }
+svg, rect { font-family: 'Ahem'; }
+div { font-size: 8px; } 
+</style>
+<html>
+<svg id="svg" width="0" height="0"></svg>
+<script src=""
+<script>
+description("Test that length values for presentation attribute accept calc.");
+
+function computedStyle(property, value) {
+    var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
+    document.getElementById('svg').appendChild(rect);
+    rect.setAttribute(property, value);
+    var computedValue = getComputedStyle(rect).getPropertyValue(property);
+    document.getElementById('svg').removeChild(rect);
+    return computedValue;
+}
+
+function testComputed(property, value, expected) {
+    shouldBeEqualToString('computedStyle("' + property + '", "' + value + '")', expected);
+}
+
+function negativeTest(property, value) {
+    testComputed(property, value, "auto");
+}
+
+function negativeTestZero(property, value) {
+    testComputed(property, value, "0px");
+}
+
+// Test 'calc(500px - 400px)'.
+testComputed("baseline-shift", "calc(500px - 400px)", "100px");
+testComputed("cx", "calc(500px - 400px)", "100px");
+testComputed("cy", "calc(500px - 400px)", "100px");
+testComputed("height", "calc(500px - 400px)", "100px");
+testComputed("kerning", "calc(500px - 400px)", "100px");
+testComputed("r", "calc(500px - 400px)", "100px");
+testComputed("rx", "calc(500px - 400px)", "100px");
+testComputed("ry", "calc(500px - 400px)", "100px");
+testComputed("stroke-width", "calc(500px - 400px)", "100px");
+testComputed("stroke-dashoffset", "calc(500px - 400px)", "100px");
+testComputed("width", "calc(500px - 400px)", "100px")
+testComputed("x", "calc(500px - 400px)", "100px");
+testComputed("y", "calc(500px - 400px)", "100px");
+
+// Test 'calc(40px + 60px)'.
+testComputed("baseline-shift", "calc(40px + 60px)", "100px");
+testComputed("cx", "calc(40px + 60px)", "100px");
+testComputed("cy", "calc(40px + 60px)", "100px");
+testComputed("height", "calc(40px + 60px)", "100px");
+testComputed("kerning", "calc(40px + 60px)", "100px");
+testComputed("r", "calc(40px + 60px)", "100px");
+testComputed("rx", "calc(40px + 60px)", "100px");
+testComputed("ry", "calc(40px + 60px)", "100px");
+testComputed("stroke-width", "calc(40px + 60px)", "100px");
+testComputed("stroke-dashoffset", "calc(40px + 60px)", "100px");
+testComputed("width", "calc(40px + 60px)", "100px")
+testComputed("x", "calc(40px + 60px)", "100px");
+testComputed("y", "calc(40px + 60px)", "100px");
+
+// Test 'calc(0% + 100px)'.
+testComputed("baseline-shift", "calc(0% + 100px)", "0");
+testComputed("cx", "calc(0% + 100px)", "calc(0% + 100px)");
+testComputed("cy", "calc(0% + 100px)", "calc(0% + 100px)");
+testComputed("height", "calc(0% + 100px)", "calc(0% + 100px)");
+testComputed("kerning", "calc(0% + 100px)", "0");
+testComputed("r", "calc(0% + 100px)", "calc(0% + 100px)");
+testComputed("rx", "calc(0% + 100px)", "calc(0% + 100px)");
+testComputed("ry", "calc(0% + 100px)", "calc(0% + 100px)");
+testComputed("stroke-width", "calc(0% + 100px)", "calc(0% + 100px)");
+testComputed("stroke-dashoffset", "calc(0% + 100px)", "calc(0% + 100px)");
+testComputed("width", "calc(0% + 100px)", "calc(0% + 100px)")
+testComputed("x", "calc(0% + 100px)", "calc(0% + 100px)");
+testComputed("y", "calc(0% + 100px)", "calc(0% + 100px)");
+
+// Test 'calc(100% - 100px)'.
+testComputed("baseline-shift", "calc(100% - 100px)", "0");
+testComputed("cx", "calc(100% - 100px)", "calc(100% - 100px)");
+testComputed("cy", "calc(100% - 100px)", "calc(100% - 100px)");
+testComputed("height", "calc(100% - 100px)", "calc(100% - 100px)");
+testComputed("kerning", "calc(100% - 100px)", "0");
+testComputed("r", "calc(100% - 100px)", "calc(100% - 100px)");
+testComputed("rx", "calc(100% - 100px)", "calc(100% - 100px)");
+testComputed("ry", "calc(100% - 100px)", "calc(100% - 100px)");
+testComputed("stroke-width", "calc(100% - 100px)", "calc(100% - 100px)");
+testComputed("stroke-dashoffset", "calc(100% - 100px)", "calc(100% - 100px)");
+testComputed("width", "calc(100% - 100px)", "calc(100% - 100px)")
+testComputed("x", "calc(100% - 100px)", "calc(100% - 100px)");
+testComputed("y", "calc(100% - 100px)", "calc(100% - 100px)");
+
+// Number value properties.
+testComputed("stroke-miterlimit", "calc(500 - 400)", "100");
+testComputed("flood-opacity", "calc(500 - 400)", "100");
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (172710 => 172711)


--- trunk/Source/WebCore/ChangeLog	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/Source/WebCore/ChangeLog	2014-08-18 18:18:16 UTC (rev 172711)
@@ -1,3 +1,52 @@
+2014-08-18  Dirk Schulze  <k...@webkit.org>
+
+        calc() doesn't work for SVG CSS properties
+        https://bugs.webkit.org/show_bug.cgi?id=136026
+
+        Reviewed by Andreas Kling.
+
+        Make calc() work on SVG CSS properties as well. stroke-width and
+        stroke-dashoffset used SVGLength. SVGLength doesn't work together with
+        cross units length arguments like % and px (just returns 0 in these
+        cases). I moved these properties over to Length. All modified files
+        beside to SVGCSSParser are related to this switch.
+
+        Test: svg/css/parse-calc-length.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::ComputedStyleExtractor::propertyValue):
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
+        * css/SVGCSSComputedStyleDeclaration.cpp:
+        (WebCore::ComputedStyleExtractor::svgPropertyValue):
+        * css/SVGCSSParser.cpp:
+        (WebCore::CSSParser::parseSVGValue):
+        * css/SVGCSSStyleSelector.cpp:
+        (WebCore::StyleResolver::applySVGProperty):
+        * page/animation/CSSPropertyAnimation.cpp:
+        (WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
+        * rendering/style/RenderStyle.h:
+        * rendering/style/SVGRenderStyle.h:
+        (WebCore::SVGRenderStyle::setStrokeWidth):
+        (WebCore::SVGRenderStyle::setStrokeDashOffset):
+        (WebCore::SVGRenderStyle::strokeWidth):
+        (WebCore::SVGRenderStyle::strokeDashOffset):
+        (WebCore::SVGRenderStyle::initialStrokeDashOffset): Deleted.
+        (WebCore::SVGRenderStyle::initialStrokeWidth): Deleted.
+        * rendering/style/SVGRenderStyleDefs.cpp:
+        (WebCore::StyleStrokeData::StyleStrokeData):
+        * rendering/style/SVGRenderStyleDefs.h:
+        * rendering/svg/RenderSVGShape.cpp:
+        (WebCore::RenderSVGShape::strokeWidth):
+        * rendering/svg/RenderSVGText.cpp:
+        (WebCore::RenderSVGText::strokeBoundingBox):
+        * rendering/svg/SVGRenderSupport.cpp:
+        (WebCore::SVGRenderSupport::applyStrokeStyleToContext):
+        * rendering/svg/SVGRenderTreeAsText.cpp:
+        (WebCore::writeStyle):
+        * svg/SVGLengthContext.cpp:
+        (WebCore::SVGLengthContext::valueForLength):
+
 2014-08-18  Andy Estes  <aes...@apple.com>
 
         REGRESSION (r167856): adobe.com no longer able to launch Create Cloud app using a URL with a custom scheme

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (172710 => 172711)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2014-08-18 18:18:16 UTC (rev 172711)
@@ -2970,7 +2970,7 @@
         case CSSPropertyBackgroundRepeatY:
             break;
 
-        // New positioning properties for SVG.
+        // Length properties for SVG.
         case CSSPropertyCx:
             return zoomAdjustedPixelValueForLength(style->svgStyle().cx(), style.get());
         case CSSPropertyCy:
@@ -2981,6 +2981,10 @@
             return zoomAdjustedPixelValueForLength(style->svgStyle().rx(), style.get());
         case CSSPropertyRy:
             return zoomAdjustedPixelValueForLength(style->svgStyle().ry(), style.get());
+        case CSSPropertyStrokeWidth:
+            return zoomAdjustedPixelValueForLength(style->svgStyle().strokeWidth(), style.get());
+        case CSSPropertyStrokeDashoffset:
+            return zoomAdjustedPixelValueForLength(style->svgStyle().strokeDashOffset(), style.get());
         case CSSPropertyX:
             return zoomAdjustedPixelValueForLength(style->svgStyle().x(), style.get());
         case CSSPropertyY:
@@ -3103,12 +3107,10 @@
         case CSSPropertyShapeRendering:
         case CSSPropertyStroke:
         case CSSPropertyStrokeDasharray:
-        case CSSPropertyStrokeDashoffset:
         case CSSPropertyStrokeLinecap:
         case CSSPropertyStrokeLinejoin:
         case CSSPropertyStrokeMiterlimit:
         case CSSPropertyStrokeOpacity:
-        case CSSPropertyStrokeWidth:
         case CSSPropertyAlignmentBaseline:
         case CSSPropertyBaselineShift:
         case CSSPropertyDominantBaseline:

Modified: trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp (172710 => 172711)


--- trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-08-18 18:18:16 UTC (rev 172711)
@@ -2599,6 +2599,8 @@
     setPropertyHandler(CSSPropertyR, ApplyPropertyLength<&RenderStyle::r, &RenderStyle::setR, &RenderStyle::initialZeroLength>::createHandler());
     setPropertyHandler(CSSPropertyRx, ApplyPropertyLength<&RenderStyle::rx, &RenderStyle::setRx, &RenderStyle::initialZeroLength>::createHandler());
     setPropertyHandler(CSSPropertyRy, ApplyPropertyLength<&RenderStyle::ry, &RenderStyle::setRy, &RenderStyle::initialZeroLength>::createHandler());
+    setPropertyHandler(CSSPropertyStrokeWidth, ApplyPropertyLength<&RenderStyle::strokeWidth, &RenderStyle::setStrokeWidth, &RenderStyle::initialOneLength>::createHandler());
+    setPropertyHandler(CSSPropertyStrokeDashoffset, ApplyPropertyLength<&RenderStyle::strokeDashOffset, &RenderStyle::setStrokeDashOffset, &RenderStyle::initialZeroLength>::createHandler());
     setPropertyHandler(CSSPropertyX, ApplyPropertyLength<&RenderStyle::x, &RenderStyle::setX, &RenderStyle::initialZeroLength>::createHandler());
     setPropertyHandler(CSSPropertyY, ApplyPropertyLength<&RenderStyle::y, &RenderStyle::setY, &RenderStyle::initialZeroLength>::createHandler());
 

Modified: trunk/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp (172710 => 172711)


--- trunk/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp	2014-08-18 18:18:16 UTC (rev 172711)
@@ -190,10 +190,6 @@
             return adjustSVGPaintForCurrentColor(SVGPaint::create(svgStyle.strokePaintType(), svgStyle.strokePaintUri(), svgStyle.strokePaintColor()), style);
         case CSSPropertyStrokeDasharray:
             return strokeDashArrayToCSSValueList(svgStyle.strokeDashArray());
-        case CSSPropertyStrokeDashoffset:
-            return SVGLength::toCSSPrimitiveValue(svgStyle.strokeDashOffset());
-        case CSSPropertyStrokeWidth:
-            return SVGLength::toCSSPrimitiveValue(svgStyle.strokeWidth());
         case CSSPropertyBaselineShift: {
             switch (svgStyle.baselineShift()) {
                 case BS_BASELINE:

Modified: trunk/Source/WebCore/css/SVGCSSParser.cpp (172710 => 172711)


--- trunk/Source/WebCore/css/SVGCSSParser.cpp	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/Source/WebCore/css/SVGCSSParser.cpp	2014-08-18 18:18:16 UTC (rev 172711)
@@ -324,12 +324,8 @@
             parsedValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
         else if (value->unit >= CSSParserValue::Q_EMS)
             parsedValue = CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPrimitiveValue::CSS_EMS);
-        if (isCalculation(value)) {
-            // FIXME calc() http://webkit.org/b/16662 : actually create a CSSPrimitiveValue here, ie
-            // parsedValue = CSSPrimitiveValue::create(m_parsedCalculation.release());
-            m_parsedCalculation.release();
-            parsedValue = 0;
-        }
+        if (isCalculation(value))
+            parsedValue = CSSPrimitiveValue::create(m_parsedCalculation.release());
         m_valueList->next();
     }
     if (!parsedValue || (m_valueList->current() && !inShorthand()))

Modified: trunk/Source/WebCore/css/SVGCSSStyleSelector.cpp (172710 => 172711)


--- trunk/Source/WebCore/css/SVGCSSStyleSelector.cpp	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/Source/WebCore/css/SVGCSSStyleSelector.cpp	2014-08-18 18:18:16 UTC (rev 172711)
@@ -289,13 +289,6 @@
             }
             break;
         }
-        case CSSPropertyStrokeWidth:
-        {
-            HANDLE_INHERIT_AND_INITIAL(strokeWidth, StrokeWidth)
-            if (primitiveValue)
-                svgStyle.setStrokeWidth(SVGLength::fromCSSPrimitiveValue(primitiveValue));
-            break;
-        }
         case CSSPropertyStrokeDasharray:
         {
             HANDLE_INHERIT_AND_INITIAL(strokeDashArray, StrokeDashArray)
@@ -320,13 +313,6 @@
             svgStyle.setStrokeDashArray(array);
             break;
         }
-        case CSSPropertyStrokeDashoffset:
-        {
-            HANDLE_INHERIT_AND_INITIAL(strokeDashOffset, StrokeDashOffset)
-            if (primitiveValue)
-                svgStyle.setStrokeDashOffset(SVGLength::fromCSSPrimitiveValue(primitiveValue));
-            break;
-        }
         case CSSPropertyFillOpacity:
         {
             HANDLE_INHERIT_AND_INITIAL(fillOpacity, FillOpacity)

Modified: trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp (172710 => 172711)


--- trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp	2014-08-18 18:18:16 UTC (rev 172711)
@@ -1251,9 +1251,7 @@
 
         new PropertyWrapperSVGPaint(CSSPropertyStroke, &RenderStyle::strokePaintType, &RenderStyle::strokePaintColor, &RenderStyle::setStrokePaintColor),
         new PropertyWrapper<float>(CSSPropertyStrokeOpacity, &RenderStyle::strokeOpacity, &RenderStyle::setStrokeOpacity),
-        new PropertyWrapper<SVGLength>(CSSPropertyStrokeWidth, &RenderStyle::strokeWidth, &RenderStyle::setStrokeWidth),
         new PropertyWrapper< Vector<SVGLength>>(CSSPropertyStrokeDasharray, &RenderStyle::strokeDashArray, &RenderStyle::setStrokeDashArray),
-        new PropertyWrapper<SVGLength>(CSSPropertyStrokeDashoffset, &RenderStyle::strokeDashOffset, &RenderStyle::setStrokeDashOffset),
         new PropertyWrapper<float>(CSSPropertyStrokeMiterlimit, &RenderStyle::strokeMiterLimit, &RenderStyle::setStrokeMiterLimit),
 
         new LengthPropertyWrapper<Length>(CSSPropertyCx, &RenderStyle::cx, &RenderStyle::setCx),
@@ -1261,6 +1259,8 @@
         new LengthPropertyWrapper<Length>(CSSPropertyR, &RenderStyle::r, &RenderStyle::setR),
         new LengthPropertyWrapper<Length>(CSSPropertyRx, &RenderStyle::rx, &RenderStyle::setRx),
         new LengthPropertyWrapper<Length>(CSSPropertyRy, &RenderStyle::ry, &RenderStyle::setRy),
+        new LengthPropertyWrapper<Length>(CSSPropertyStrokeDashoffset, &RenderStyle::strokeDashOffset, &RenderStyle::setStrokeDashOffset),
+        new LengthPropertyWrapper<Length>(CSSPropertyStrokeWidth, &RenderStyle::strokeWidth, &RenderStyle::setStrokeWidth),
         new LengthPropertyWrapper<Length>(CSSPropertyX, &RenderStyle::x, &RenderStyle::setX),
         new LengthPropertyWrapper<Length>(CSSPropertyY, &RenderStyle::y, &RenderStyle::setY),
 

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (172710 => 172711)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2014-08-18 18:18:16 UTC (rev 172711)
@@ -1656,12 +1656,12 @@
     void setStrokePaintColor(const Color& c) { accessSVGStyle().setStrokePaint(SVGPaint::SVG_PAINTTYPE_RGBCOLOR, c, ""); }
     float strokeOpacity() const { return svgStyle().strokeOpacity(); }
     void setStrokeOpacity(float f) { accessSVGStyle().setStrokeOpacity(f); }
-    SVGLength strokeWidth() const { return svgStyle().strokeWidth(); }
-    void setStrokeWidth(SVGLength w) { accessSVGStyle().setStrokeWidth(w); }
+    const Length& strokeWidth() const { return svgStyle().strokeWidth(); }
+    void setStrokeWidth(Length w) { accessSVGStyle().setStrokeWidth(w); }
     Vector<SVGLength> strokeDashArray() const { return svgStyle().strokeDashArray(); }
     void setStrokeDashArray(Vector<SVGLength> array) { accessSVGStyle().setStrokeDashArray(array); }
-    SVGLength strokeDashOffset() const { return svgStyle().strokeDashOffset(); }
-    void setStrokeDashOffset(SVGLength d) { accessSVGStyle().setStrokeDashOffset(d); }
+    const Length& strokeDashOffset() const { return svgStyle().strokeDashOffset(); }
+    void setStrokeDashOffset(Length d) { accessSVGStyle().setStrokeDashOffset(d); }
     float strokeMiterLimit() const { return svgStyle().strokeMiterLimit(); }
     void setStrokeMiterLimit(float f) { accessSVGStyle().setStrokeMiterLimit(f); }
 
@@ -1836,6 +1836,7 @@
     static Length initialPadding() { return Length(Fixed); }
     static Length initialTextIndent() { return Length(Fixed); }
     static Length initialZeroLength() { return Length(Fixed); }
+    static Length initialOneLength() { return Length(1, Fixed); }
 #if ENABLE(CSS3_TEXT)
     static TextIndentLine initialTextIndentLine() { return TextIndentFirstLine; }
     static TextIndentType initialTextIndentType() { return TextIndentNormal; }

Modified: trunk/Source/WebCore/rendering/style/SVGRenderStyle.h (172710 => 172711)


--- trunk/Source/WebCore/rendering/style/SVGRenderStyle.h	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/Source/WebCore/rendering/style/SVGRenderStyle.h	2014-08-18 18:18:16 UTC (rev 172711)
@@ -112,20 +112,6 @@
         return length;
     }
 
-    static SVGLength initialStrokeDashOffset()
-    {
-        SVGLength length;
-        length.newValueSpecifiedUnits(LengthTypeNumber, 0, ASSERT_NO_EXCEPTION);
-        return length;
-    }
-
-    static SVGLength initialStrokeWidth()
-    {
-        SVGLength length;
-        length.newValueSpecifiedUnits(LengthTypeNumber, 1, ASSERT_NO_EXCEPTION);
-        return length;
-    }
-
     // SVG CSS Property setters
     void setAlignmentBaseline(EAlignmentBaseline val) { svg_noninherited_flags.f._alignmentBaseline = val; }
     void setDominantBaseline(EDominantBaseline val) { svg_noninherited_flags.f._dominantBaseline = val; }
@@ -246,13 +232,13 @@
             stroke.access()->miterLimit = obj;
     }
 
-    void setStrokeWidth(const SVGLength& obj)
+    void setStrokeWidth(const Length& obj)
     {
         if (!(stroke->width == obj))
             stroke.access()->width = obj;
     }
 
-    void setStrokeDashOffset(const SVGLength& obj)
+    void setStrokeDashOffset(const Length& obj)
     {
         if (!(stroke->dashOffset == obj))
             stroke.access()->dashOffset = obj;
@@ -368,8 +354,8 @@
     const String& strokePaintUri() const { return stroke->paintUri; }
     Vector<SVGLength> strokeDashArray() const { return stroke->dashArray; }
     float strokeMiterLimit() const { return stroke->miterLimit; }
-    SVGLength strokeWidth() const { return stroke->width; }
-    SVGLength strokeDashOffset() const { return stroke->dashOffset; }
+    const Length& strokeWidth() const { return stroke->width; }
+    const Length& strokeDashOffset() const { return stroke->dashOffset; }
     SVGLength kerning() const { return text->kerning; }
     float stopOpacity() const { return stops->opacity; }
     const Color& stopColor() const { return stops->color; }

Modified: trunk/Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp (172710 => 172711)


--- trunk/Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp	2014-08-18 18:18:16 UTC (rev 172711)
@@ -76,8 +76,8 @@
 StyleStrokeData::StyleStrokeData()
     : opacity(SVGRenderStyle::initialStrokeOpacity())
     , miterLimit(SVGRenderStyle::initialStrokeMiterLimit())
-    , width(SVGRenderStyle::initialStrokeWidth())
-    , dashOffset(SVGRenderStyle::initialStrokeDashOffset())
+    , width(RenderStyle::initialOneLength())
+    , dashOffset(RenderStyle::initialZeroLength())
     , dashArray(SVGRenderStyle::initialStrokeDashArray())
     , paintType(SVGRenderStyle::initialStrokePaintType())
     , paintColor(SVGRenderStyle::initialStrokePaintColor())

Modified: trunk/Source/WebCore/rendering/style/SVGRenderStyleDefs.h (172710 => 172711)


--- trunk/Source/WebCore/rendering/style/SVGRenderStyleDefs.h	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/Source/WebCore/rendering/style/SVGRenderStyleDefs.h	2014-08-18 18:18:16 UTC (rev 172711)
@@ -153,8 +153,8 @@
         float opacity;
         float miterLimit;
 
-        SVGLength width;
-        SVGLength dashOffset;
+        Length width;
+        Length dashOffset;
         Vector<SVGLength> dashArray;
 
         SVGPaint::SVGPaintType paintType;

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp (172710 => 172711)


--- trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp	2014-08-18 18:18:16 UTC (rev 172711)
@@ -432,7 +432,7 @@
 float RenderSVGShape::strokeWidth() const
 {
     SVGLengthContext lengthContext(&graphicsElement());
-    return style().svgStyle().strokeWidth().value(lengthContext);
+    return lengthContext.valueForLength(style().svgStyle().strokeWidth());
 }
 
 bool RenderSVGShape::hasSmoothStroke() const

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp (172710 => 172711)


--- trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp	2014-08-18 18:18:16 UTC (rev 172711)
@@ -516,7 +516,7 @@
         return strokeBoundaries;
 
     SVGLengthContext lengthContext(&textElement());
-    strokeBoundaries.inflate(svgStyle.strokeWidth().value(lengthContext));
+    strokeBoundaries.inflate(lengthContext.valueForLength(svgStyle.strokeWidth()));
     return strokeBoundaries;
 }
 

Modified: trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp (172710 => 172711)


--- trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp	2014-08-18 18:18:16 UTC (rev 172711)
@@ -412,7 +412,7 @@
     const SVGRenderStyle& svgStyle = style.svgStyle();
 
     SVGLengthContext lengthContext(toSVGElement(renderer.element()));
-    context->setStrokeThickness(svgStyle.strokeWidth().value(lengthContext));
+    context->setStrokeThickness(lengthContext.valueForLength(svgStyle.strokeWidth()));
     context->setLineCap(svgStyle.capStyle());
     context->setLineJoin(svgStyle.joinStyle());
     if (svgStyle.joinStyle() == MiterJoin)
@@ -427,7 +427,7 @@
         for (auto& dash : dashes)
             dashArray.uncheckedAppend(dash.value(lengthContext));
 
-        context->setLineDash(dashArray, svgStyle.strokeDashOffset().value(lengthContext));
+        context->setLineDash(dashArray, lengthContext.valueForLength(svgStyle.strokeDashOffset()));
     }
 }
 

Modified: trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp (172710 => 172711)


--- trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp	2014-08-18 18:18:16 UTC (rev 172711)
@@ -268,8 +268,8 @@
             writeSVGPaintingResource(ts, strokePaintingResource);
 
             SVGLengthContext lengthContext(&shape.graphicsElement());
-            double dashOffset = svgStyle.strokeDashOffset().value(lengthContext);
-            double strokeWidth = svgStyle.strokeWidth().value(lengthContext);
+            double dashOffset = lengthContext.valueForLength(svgStyle.strokeDashOffset());
+            double strokeWidth = lengthContext.valueForLength(svgStyle.strokeWidth());
             const Vector<SVGLength>& dashes = svgStyle.strokeDashArray();
 
             DashArray dashArray;

Modified: trunk/Source/WebCore/svg/SVGLengthContext.cpp (172710 => 172711)


--- trunk/Source/WebCore/svg/SVGLengthContext.cpp	2014-08-18 17:55:05 UTC (rev 172710)
+++ trunk/Source/WebCore/svg/SVGLengthContext.cpp	2014-08-18 18:18:16 UTC (rev 172711)
@@ -89,7 +89,7 @@
 
 float SVGLengthContext::valueForLength(const Length& length, SVGLengthMode mode)
 {
-    if (length.isPercent())
+    if (length.isPercent() && !length.isCalculated())
         return convertValueFromPercentageToUserUnits(length.value() / 100, mode, IGNORE_EXCEPTION);
     if (length.isAuto())
         return 0;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to