calc() doesn't work for SVG CSS properties
authorkrit@webkit.org <krit@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Aug 2014 18:18:16 +0000 (18:18 +0000)
committerkrit@webkit.org <krit@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Aug 2014 18:18:16 +0000 (18:18 +0000)
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172711 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt
LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt
LayoutTests/svg/css/getComputedStyle-basic-expected.txt
LayoutTests/svg/css/parse-calc-length-expected.txt [new file with mode: 0644]
LayoutTests/svg/css/parse-calc-length.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/DeprecatedStyleBuilder.cpp
Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp
Source/WebCore/css/SVGCSSParser.cpp
Source/WebCore/css/SVGCSSStyleSelector.cpp
Source/WebCore/page/animation/CSSPropertyAnimation.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/SVGRenderStyle.h
Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp
Source/WebCore/rendering/style/SVGRenderStyleDefs.h
Source/WebCore/rendering/svg/RenderSVGShape.cpp
Source/WebCore/rendering/svg/RenderSVGText.cpp
Source/WebCore/rendering/svg/SVGRenderSupport.cpp
Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp
Source/WebCore/svg/SVGLengthContext.cpp

index e9dda37..d65f7b6 100644 (file)
@@ -1,3 +1,16 @@
+2014-08-18  Dirk Schulze  <krit@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  <aestes@apple.com>
 
         REGRESSION (r167856): adobe.com no longer able to launch Create Cloud app using a URL with a custom scheme
index b9568eb..cef0509 100644 (file)
@@ -240,12 +240,12 @@ marker-start: none;
 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;
index 0ee439a..74e92cf 100644 (file)
@@ -239,12 +239,12 @@ marker-start: none
 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
index a909aad..11a3b63 100644 (file)
@@ -478,7 +478,7 @@ rect: style.getPropertyValue(stroke) : #ffa500
 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.getPropertyValue(stroke) : #ffa500
 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]
diff --git a/LayoutTests/svg/css/parse-calc-length-expected.txt b/LayoutTests/svg/css/parse-calc-length-expected.txt
new file mode 100644 (file)
index 0000000..4c86eef
--- /dev/null
@@ -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
+
diff --git a/LayoutTests/svg/css/parse-calc-length.html b/LayoutTests/svg/css/parse-calc-length.html
new file mode 100644 (file)
index 0000000..3cbc15d
--- /dev/null
@@ -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="../../resources/js-test-pre.js"></script>
+<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="../../resources/js-test-post.js"></script>
+</body>
+</html>
index 18279cc..571f019 100644 (file)
@@ -1,3 +1,52 @@
+2014-08-18  Dirk Schulze  <krit@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  <aestes@apple.com>
 
         REGRESSION (r167856): adobe.com no longer able to launch Create Cloud app using a URL with a custom scheme
index 6a110a3..e30188c 100644 (file)
@@ -2970,7 +2970,7 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propert
         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 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propert
             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 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propert
         case CSSPropertyShapeRendering:
         case CSSPropertyStroke:
         case CSSPropertyStrokeDasharray:
-        case CSSPropertyStrokeDashoffset:
         case CSSPropertyStrokeLinecap:
         case CSSPropertyStrokeLinejoin:
         case CSSPropertyStrokeMiterlimit:
         case CSSPropertyStrokeOpacity:
-        case CSSPropertyStrokeWidth:
         case CSSPropertyAlignmentBaseline:
         case CSSPropertyBaselineShift:
         case CSSPropertyDominantBaseline:
index 87256fa..0105580 100644 (file)
@@ -2599,6 +2599,8 @@ DeprecatedStyleBuilder::DeprecatedStyleBuilder()
     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());
 
index 9e817ed..b9d3539 100644 (file)
@@ -190,10 +190,6 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID prop
             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:
index b5bba5a..0c065b9 100644 (file)
@@ -324,12 +324,8 @@ bool CSSParser::parseSVGValue(CSSPropertyID propId, bool important)
             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()))
index de985c1..e7d1c8d 100644 (file)
@@ -289,13 +289,6 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value)
             }
             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 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value)
             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)
index cde2441..bbdee18 100644 (file)
@@ -1251,9 +1251,7 @@ CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap()
 
         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 @@ CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap()
         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),
 
index 574b3d8..a6d2ca6 100644 (file)
@@ -1656,12 +1656,12 @@ public:
     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 @@ public:
     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; }
index daa7e6b..01432fe 100644 (file)
@@ -112,20 +112,6 @@ public:
         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 @@ public:
             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 @@ public:
     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; }
index 25e7ccd..7da60d9 100644 (file)
@@ -76,8 +76,8 @@ bool StyleFillData::operator==(const StyleFillData& other) const
 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())
index 4d772f0..1e51ee1 100644 (file)
@@ -153,8 +153,8 @@ namespace WebCore {
         float opacity;
         float miterLimit;
 
-        SVGLength width;
-        SVGLength dashOffset;
+        Length width;
+        Length dashOffset;
         Vector<SVGLength> dashArray;
 
         SVGPaint::SVGPaintType paintType;
index 929d071..0336d65 100644 (file)
@@ -432,7 +432,7 @@ void RenderSVGShape::updateRepaintBoundingBox()
 float RenderSVGShape::strokeWidth() const
 {
     SVGLengthContext lengthContext(&graphicsElement());
-    return style().svgStyle().strokeWidth().value(lengthContext);
+    return lengthContext.valueForLength(style().svgStyle().strokeWidth());
 }
 
 bool RenderSVGShape::hasSmoothStroke() const
index d38ee94..2e3669c 100644 (file)
@@ -516,7 +516,7 @@ FloatRect RenderSVGText::strokeBoundingBox() const
         return strokeBoundaries;
 
     SVGLengthContext lengthContext(&textElement());
-    strokeBoundaries.inflate(svgStyle.strokeWidth().value(lengthContext));
+    strokeBoundaries.inflate(lengthContext.valueForLength(svgStyle.strokeWidth()));
     return strokeBoundaries;
 }
 
index 45d6228..0dc1077 100644 (file)
@@ -412,7 +412,7 @@ void SVGRenderSupport::applyStrokeStyleToContext(GraphicsContext* context, const
     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 @@ void SVGRenderSupport::applyStrokeStyleToContext(GraphicsContext* context, const
         for (auto& dash : dashes)
             dashArray.uncheckedAppend(dash.value(lengthContext));
 
-        context->setLineDash(dashArray, svgStyle.strokeDashOffset().value(lengthContext));
+        context->setLineDash(dashArray, lengthContext.valueForLength(svgStyle.strokeDashOffset()));
     }
 }
 
index cfeee9b..99ad160 100644 (file)
@@ -268,8 +268,8 @@ static void writeStyle(TextStream& ts, const RenderElement& renderer)
             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;
index 69a860f..76662f8 100644 (file)
@@ -89,7 +89,7 @@ float SVGLengthContext::resolveLength(const SVGElement* context, SVGUnitTypes::S
 
 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;