-webkit-clip-path should support fill, stroke, view-box keywords
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Feb 2014 06:02:42 +0000 (06:02 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Feb 2014 06:02:42 +0000 (06:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=128393

Source/WebCore:

Patch by Dirk Schulze <dschulze@chromium.org> on 2014-02-09
Reviewed by Dean Jackson.

CSS Masking uses the keywords fill, stroke and view-box for SVG shapes.
This patch updates the parser, style resolver and SVG implementation of
the prefixed clip-path property.

Remove the unexposed and obsolete keyword bounding-box.

Tests: svg/clip-path/clip-path-shape-fill-expected.svg
       svg/clip-path/clip-path-shape-fill.svg
       svg/clip-path/clip-path-shape-stroke-expected.svg
       svg/clip-path/clip-path-shape-stroke.svg
       svg/clip-path/clip-path-shape-view-box-expected.svg
       svg/clip-path/clip-path-shape-view-box.svg

* css/CSSParser.cpp: Parse fill, stroke, view-box. Remove bounding-box.
(WebCore::isBoxValue):
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator LayoutBox):
* css/CSSValueKeywords.in:
* css/DeprecatedStyleBuilder.cpp:
(WebCore::ApplyPropertyClipPath::applyValue):
* rendering/RenderLayer.cpp:
(WebCore::computeReferenceBox):
* rendering/shapes/ShapeInfo.h:
(WebCore::ShapeInfo::setShapeSize):
(WebCore::ShapeInfo::logicalTopOffset):
(WebCore::ShapeInfo::logicalLeftOffset):
* rendering/style/RenderStyleConstants.h:
* rendering/svg/SVGRenderingContext.cpp: Use different reference boxes per keyword.
(WebCore::SVGRenderingContext::prepareToRenderSVGContent):

LayoutTests:

Patch by Dirk Schulze <krit@webkit.org> on 2014-02-09
Reviewed by Dean Jackson.

Update or add new tests for changed clip-path keywords.

* css3/masking/clip-path-circle-bounding-box.html: Removed.
* fast/masking/parsing-clip-path-shape.html:
* platform/mac/css3/masking/clip-path-circle-bounding-box-expected.png: Removed.
* platform/mac/css3/masking/clip-path-circle-bounding-box-expected.txt: Removed.
* svg/clip-path/clip-path-shape-fill-expected.svg: Added.
* svg/clip-path/clip-path-shape-fill.svg: Added.
* svg/clip-path/clip-path-shape-stroke-expected.svg: Added.
* svg/clip-path/clip-path-shape-stroke.svg: Added.
* svg/clip-path/clip-path-shape-view-box-expected.svg: Added.
* svg/clip-path/clip-path-shape-view-box.svg: Added.

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

21 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/masking/clip-path-circle-bounding-box.html [deleted file]
LayoutTests/fast/masking/parsing-clip-path-shape-expected.txt
LayoutTests/fast/masking/parsing-clip-path-shape.html
LayoutTests/platform/mac/css3/masking/clip-path-circle-bounding-box-expected.png [deleted file]
LayoutTests/platform/mac/css3/masking/clip-path-circle-bounding-box-expected.txt [deleted file]
LayoutTests/svg/clip-path/clip-path-shape-fill-expected.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-fill.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-stroke-expected.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-stroke.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-view-box-expected.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-view-box.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/css/DeprecatedStyleBuilder.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/shapes/ShapeInfo.h
Source/WebCore/rendering/style/RenderStyleConstants.h
Source/WebCore/rendering/svg/SVGRenderingContext.cpp

index 8442a87..915c50e 100644 (file)
@@ -1,3 +1,23 @@
+2014-02-09  Dirk Schulze  <krit@webkit.org>
+
+        -webkit-clip-path should support fill, stroke, view-box keywords
+        https://bugs.webkit.org/show_bug.cgi?id=128393
+
+        Reviewed by Dean Jackson.
+
+        Update or add new tests for changed clip-path keywords.
+
+        * css3/masking/clip-path-circle-bounding-box.html: Removed.
+        * fast/masking/parsing-clip-path-shape.html:
+        * platform/mac/css3/masking/clip-path-circle-bounding-box-expected.png: Removed.
+        * platform/mac/css3/masking/clip-path-circle-bounding-box-expected.txt: Removed.
+        * svg/clip-path/clip-path-shape-fill-expected.svg: Added.
+        * svg/clip-path/clip-path-shape-fill.svg: Added.
+        * svg/clip-path/clip-path-shape-stroke-expected.svg: Added.
+        * svg/clip-path/clip-path-shape-stroke.svg: Added.
+        * svg/clip-path/clip-path-shape-view-box-expected.svg: Added.
+        * svg/clip-path/clip-path-shape-view-box.svg: Added.
+
 2014-02-09  Carlos Garnacho  <carlosg@gnome.org>
 
         [GTK] Enable touch features
diff --git a/LayoutTests/css3/masking/clip-path-circle-bounding-box.html b/LayoutTests/css3/masking/clip-path-circle-bounding-box.html
deleted file mode 100644 (file)
index b1b7df9..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-<style>
-#content {
-    width: 200px;
-    height: 200px;
-    margin: 0;
-    padding: 0;
-    background-color: green;
-}
-#clip {
-    width: 200px;
-    height: 200px;
-       margin: 10px;
-       padding: 10px;
-       border: 10px solid blue;
-    -webkit-clip-path: circle(50% at 50% 50%) bounding-box;
-    background-color: yellow;
-}
-</style>
-</head>
-<body>
-<div id="clip">
-       <div id="content"></div>
-</div>
-</body>
-</html>
index 32f5783..070f41c 100644 (file)
@@ -52,22 +52,26 @@ PASS innerStyle("-webkit-clip-path", "content-box") is "content-box"
 PASS innerStyle("-webkit-clip-path", "padding-box") is "padding-box"
 PASS innerStyle("-webkit-clip-path", "border-box") is "border-box"
 PASS innerStyle("-webkit-clip-path", "margin-box") is "margin-box"
-PASS innerStyle("-webkit-clip-path", "bounding-box") is "bounding-box"
+PASS innerStyle("-webkit-clip-path", "fill") is "fill"
+PASS innerStyle("-webkit-clip-path", "stroke") is "stroke"
+PASS innerStyle("-webkit-clip-path", "view-box") is "view-box"
 PASS innerStyle("-webkit-clip-path", "circle(50% at 50% 50%) content-box") is "circle(50% at 50% 50%) content-box"
 PASS innerStyle("-webkit-clip-path", "circle(50% at 50% 50%) padding-box") is "circle(50% at 50% 50%) padding-box"
 PASS innerStyle("-webkit-clip-path", "margin-box circle(50% at 50% 50%)") is "margin-box circle(50% at 50% 50%)"
 PASS innerStyle("-webkit-clip-path", "border-box circle(50% at 50% 50%)") is "border-box circle(50% at 50% 50%)"
-PASS innerStyle("-webkit-clip-path", "circle(50% at 50% 50%) bounding-box") is "circle(50% at 50% 50%) bounding-box"
+PASS innerStyle("-webkit-clip-path", "circle(50% at 50% 50%) view-box") is "circle(50% at 50% 50%) view-box"
 PASS computedStyle("-webkit-clip-path", "content-box") is "content-box"
 PASS computedStyle("-webkit-clip-path", "padding-box") is "padding-box"
 PASS computedStyle("-webkit-clip-path", "border-box") is "border-box"
 PASS computedStyle("-webkit-clip-path", "margin-box") is "margin-box"
-PASS computedStyle("-webkit-clip-path", "bounding-box") is "bounding-box"
+PASS computedStyle("-webkit-clip-path", "fill") is "fill"
+PASS computedStyle("-webkit-clip-path", "stroke") is "stroke"
+PASS computedStyle("-webkit-clip-path", "view-box") is "view-box"
 PASS computedStyle("-webkit-clip-path", "circle(50% at 50% 50%) content-box") is "circle(50% at 50% 50%) content-box"
 PASS computedStyle("-webkit-clip-path", "circle(50% at 50% 50%) padding-box") is "circle(50% at 50% 50%) padding-box"
 PASS computedStyle("-webkit-clip-path", "margin-box circle(50% at 50% 50%)") is "circle(50% at 50% 50%) margin-box"
 PASS computedStyle("-webkit-clip-path", "border-box circle(50% at 50% 50%)") is "circle(50% at 50% 50%) border-box"
-PASS computedStyle("-webkit-clip-path", "circle(50% at 50% 50%) bounding-box") is "circle(50% at 50% 50%) bounding-box"
+PASS computedStyle("-webkit-clip-path", "circle(50% at 50% 50%) fill") is "circle(50% at 50% 50%) fill"
 PASS innerStyle("-webkit-clip-path", "circle(1px, 1px, 1)") is null
 PASS computedStyle("-webkit-clip-path", "circle(1px, 1px, 1)") is "none"
 PASS innerStyle("-webkit-clip-path", "circle(1px, 1px, px)") is null
@@ -100,14 +104,14 @@ PASS innerStyle("-webkit-clip-path", "rectangle(1cm, 1mm, -1in, 1px, 1pt, 1pc)")
 PASS computedStyle("-webkit-clip-path", "rectangle(1cm, 1mm, -1in, 1px, 1pt, 1pc)") is "none"
 PASS innerStyle("-webkit-clip-path", "rectangle(1cm, 1mm, 1in, -1px, 1pt, 1pc)") is null
 PASS computedStyle("-webkit-clip-path", "rectangle(1cm, 1mm, 1in, -1px, 1pt, 1pc)") is "none"
-PASS innerStyle("-webkit-clip-path", "bounding-box circle(50% at 50% 50%) content-box") is null
-PASS computedStyle("-webkit-clip-path", "bounding-box circle(50% at 50% 50%) content-box") is "none"
+PASS innerStyle("-webkit-clip-path", "fill circle(50% at 50% 50%) content-box") is null
+PASS computedStyle("-webkit-clip-path", "fill circle(50% at 50% 50%) content-box") is "none"
 PASS innerStyle("-webkit-clip-path", "margin-box padding-box") is null
 PASS computedStyle("-webkit-clip-path", "margin-box padding-box") is "none"
 PASS innerStyle("-webkit-clip-path", "padding-box border-box circle(50% at 50% 50%)") is null
 PASS computedStyle("-webkit-clip-path", "padding-box border-box circle(50% at 50% 50%)") is "none"
-PASS innerStyle("-webkit-clip-path", "circle(50% at 50% 50%) content-box bounding-box") is null
-PASS computedStyle("-webkit-clip-path", "circle(50% at 50% 50%) content-box bounding-box") is "none"
+PASS innerStyle("-webkit-clip-path", "circle(50% at 50% 50%) content-box stroke") is null
+PASS computedStyle("-webkit-clip-path", "circle(50% at 50% 50%) content-box stroke") is "none"
 PASS innerStyle("-webkit-clip-path", "content-box margin-box padding-box") is null
 PASS computedStyle("-webkit-clip-path", "content-box margin-box padding-box") is "none"
 PASS innerStyle("-webkit-clip-path", "none content-box") is null
index 6c6cbb4..850c808 100644 (file)
@@ -111,23 +111,27 @@ testInner("-webkit-clip-path", "content-box", "content-box");
 testInner("-webkit-clip-path", "padding-box", "padding-box");
 testInner("-webkit-clip-path", "border-box", "border-box");
 testInner("-webkit-clip-path", "margin-box", "margin-box");
-testInner("-webkit-clip-path", "bounding-box", "bounding-box");
+testInner("-webkit-clip-path", "fill", "fill");
+testInner("-webkit-clip-path", "stroke", "stroke");
+testInner("-webkit-clip-path", "view-box", "view-box");
 testInner("-webkit-clip-path", "circle(50% at 50% 50%) content-box", "circle(50% at 50% 50%) content-box");
 testInner("-webkit-clip-path", "circle(50% at 50% 50%) padding-box", "circle(50% at 50% 50%) padding-box");
 testInner("-webkit-clip-path", "margin-box circle(50% at 50% 50%)", "margin-box circle(50% at 50% 50%)");
 testInner("-webkit-clip-path", "border-box circle(50% at 50% 50%)", "border-box circle(50% at 50% 50%)");
-testInner("-webkit-clip-path", "circle(50% at 50% 50%) bounding-box", "circle(50% at 50% 50%) bounding-box");
+testInner("-webkit-clip-path", "circle(50% at 50% 50%) view-box", "circle(50% at 50% 50%) view-box");
 
 testComputed("-webkit-clip-path", "content-box", "content-box");
 testComputed("-webkit-clip-path", "padding-box", "padding-box");
 testComputed("-webkit-clip-path", "border-box", "border-box");
 testComputed("-webkit-clip-path", "margin-box", "margin-box");
-testComputed("-webkit-clip-path", "bounding-box", "bounding-box");
+testComputed("-webkit-clip-path", "fill", "fill");
+testComputed("-webkit-clip-path", "stroke", "stroke");
+testComputed("-webkit-clip-path", "view-box", "view-box");
 testComputed("-webkit-clip-path", "circle(50% at 50% 50%) content-box", "circle(50% at 50% 50%) content-box");
 testComputed("-webkit-clip-path", "circle(50% at 50% 50%) padding-box", "circle(50% at 50% 50%) padding-box");
 testComputed("-webkit-clip-path", "margin-box circle(50% at 50% 50%)", "circle(50% at 50% 50%) margin-box");
 testComputed("-webkit-clip-path", "border-box circle(50% at 50% 50%)", "circle(50% at 50% 50%) border-box");
-testComputed("-webkit-clip-path", "circle(50% at 50% 50%) bounding-box", "circle(50% at 50% 50%) bounding-box");
+testComputed("-webkit-clip-path", "circle(50% at 50% 50%) fill", "circle(50% at 50% 50%) fill");
 
 // reject non-lengths
 negativeTest("-webkit-clip-path", "circle(1px, 1px, 1)");
@@ -153,10 +157,10 @@ negativeTest("-webkit-clip-path", "rectangle(1cm, 1mm, -1in, 1px, 1pt, 1pc)");
 negativeTest("-webkit-clip-path", "rectangle(1cm, 1mm, 1in, -1px, 1pt, 1pc)");
 
 // reject multiple <box> values
-negativeTest("-webkit-clip-path", "bounding-box circle(50% at 50% 50%) content-box");
+negativeTest("-webkit-clip-path", "fill circle(50% at 50% 50%) content-box");
 negativeTest("-webkit-clip-path", "margin-box padding-box");
 negativeTest("-webkit-clip-path", "padding-box border-box circle(50% at 50% 50%)");
-negativeTest("-webkit-clip-path", "circle(50% at 50% 50%) content-box bounding-box");
+negativeTest("-webkit-clip-path", "circle(50% at 50% 50%) content-box stroke");
 negativeTest("-webkit-clip-path", "content-box margin-box padding-box");
 negativeTest("-webkit-clip-path", "none content-box");
 negativeTest("-webkit-clip-path", "url(#test) padding-box");
diff --git a/LayoutTests/platform/mac/css3/masking/clip-path-circle-bounding-box-expected.png b/LayoutTests/platform/mac/css3/masking/clip-path-circle-bounding-box-expected.png
deleted file mode 100644 (file)
index 8afd0df..0000000
Binary files a/LayoutTests/platform/mac/css3/masking/clip-path-circle-bounding-box-expected.png and /dev/null differ
diff --git a/LayoutTests/platform/mac/css3/masking/clip-path-circle-bounding-box-expected.txt b/LayoutTests/platform/mac/css3/masking/clip-path-circle-bounding-box-expected.txt
deleted file mode 100644 (file)
index 6d22a97..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x260
-  RenderBlock {HTML} at (0,0) size 800x260
-    RenderBody {BODY} at (8,10) size 784x240
-layer at (18,10) size 240x240
-  RenderBlock {DIV} at (10,0) size 240x240 [bgcolor=#FFFF00] [border: (10px solid #0000FF)]
-    RenderBlock {DIV} at (20,20) size 200x200 [bgcolor=#008000]
diff --git a/LayoutTests/svg/clip-path/clip-path-shape-fill-expected.svg b/LayoutTests/svg/clip-path/clip-path-shape-fill-expected.svg
new file mode 100644 (file)
index 0000000..d8781dd
--- /dev/null
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<rect width="200" height="200" fill="green" stroke="green" stroke-width="10" style="-webkit-clip-path: circle();"/>
+</svg>
\ No newline at end of file
diff --git a/LayoutTests/svg/clip-path/clip-path-shape-fill.svg b/LayoutTests/svg/clip-path/clip-path-shape-fill.svg
new file mode 100644 (file)
index 0000000..e709dcd
--- /dev/null
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<rect width="200" height="200" fill="green" stroke="green" stroke-width="10" style="-webkit-clip-path: circle() fill;"/>
+</svg>
\ No newline at end of file
diff --git a/LayoutTests/svg/clip-path/clip-path-shape-stroke-expected.svg b/LayoutTests/svg/clip-path/clip-path-shape-stroke-expected.svg
new file mode 100644 (file)
index 0000000..0c995fc
--- /dev/null
@@ -0,0 +1,8 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<defs>
+    <clipPath id="clip">
+        <circle cx="100" cy="100" r="100"/>
+    </clipPath>
+</defs>
+<rect x="10" y="10" width="180" height="180" fill="green" stroke="green" stroke-width="20" style="-webkit-clip-path: circle() stroke;"/>
+</svg>
\ No newline at end of file
diff --git a/LayoutTests/svg/clip-path/clip-path-shape-stroke.svg b/LayoutTests/svg/clip-path/clip-path-shape-stroke.svg
new file mode 100644 (file)
index 0000000..7dbb9f7
--- /dev/null
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400">
+<rect x="10" y="10" width="180" height="180" fill="green" stroke="green" stroke-width="20" style="-webkit-clip-path: circle() stroke;"/>
+</svg>
\ No newline at end of file
diff --git a/LayoutTests/svg/clip-path/clip-path-shape-view-box-expected.svg b/LayoutTests/svg/clip-path/clip-path-shape-view-box-expected.svg
new file mode 100644 (file)
index 0000000..acda397
--- /dev/null
@@ -0,0 +1,8 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<defs>
+    <clipPath id="clip">
+        <circle cx="200" cy="200" r="200"/>
+    </clipPath>
+</defs>
+<rect width="200" height="200" fill="green" clip-path="url(#clip)"/>
+</svg>
\ No newline at end of file
diff --git a/LayoutTests/svg/clip-path/clip-path-shape-view-box.svg b/LayoutTests/svg/clip-path/clip-path-shape-view-box.svg
new file mode 100644 (file)
index 0000000..47db2a3
--- /dev/null
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400">
+<rect width="200" height="200" fill="green" style="-webkit-clip-path: circle() view-box;"/>
+</svg>
\ No newline at end of file
index a371200..8a57e16 100644 (file)
@@ -1,3 +1,41 @@
+2014-02-09  Dirk Schulze  <dschulze@chromium.org>
+
+        -webkit-clip-path should support fill, stroke, view-box keywords
+        https://bugs.webkit.org/show_bug.cgi?id=128393
+
+        Reviewed by Dean Jackson.
+
+        CSS Masking uses the keywords fill, stroke and view-box for SVG shapes.
+        This patch updates the parser, style resolver and SVG implementation of
+        the prefixed clip-path property.
+
+        Remove the unexposed and obsolete keyword bounding-box.
+
+        Tests: svg/clip-path/clip-path-shape-fill-expected.svg
+               svg/clip-path/clip-path-shape-fill.svg
+               svg/clip-path/clip-path-shape-stroke-expected.svg
+               svg/clip-path/clip-path-shape-stroke.svg
+               svg/clip-path/clip-path-shape-view-box-expected.svg
+               svg/clip-path/clip-path-shape-view-box.svg
+
+        * css/CSSParser.cpp: Parse fill, stroke, view-box. Remove bounding-box.
+        (WebCore::isBoxValue):
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator LayoutBox):
+        * css/CSSValueKeywords.in:
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::ApplyPropertyClipPath::applyValue):
+        * rendering/RenderLayer.cpp:
+        (WebCore::computeReferenceBox):
+        * rendering/shapes/ShapeInfo.h:
+        (WebCore::ShapeInfo::setShapeSize):
+        (WebCore::ShapeInfo::logicalTopOffset):
+        (WebCore::ShapeInfo::logicalLeftOffset):
+        * rendering/style/RenderStyleConstants.h:
+        * rendering/svg/SVGRenderingContext.cpp: Use different reference boxes per keyword.
+        (WebCore::SVGRenderingContext::prepareToRenderSVGContent):
+
 2014-02-09  Dean Jackson  <dino@apple.com>
 
         [WebGL] Remove state restorer code
index 256a52d..4114618 100644 (file)
@@ -5821,7 +5821,9 @@ static bool isBoxValue(CSSValueID valueId, CSSPropertyID propId)
     case CSSValueBorderBox:
     case CSSValueMarginBox:
         return true;
-    case CSSValueBoundingBox:
+    case CSSValueFill:
+    case CSSValueStroke:
+    case CSSValueViewBox:
         return propId == CSSPropertyWebkitClipPath;
     default: break;
     }
index 123f026..83671b4 100644 (file)
@@ -5126,9 +5126,6 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LayoutBox layoutBox)
 {
     m_primitiveUnitType = CSS_VALUE_ID;
     switch (layoutBox) {
-    case BoundingBox:
-        m_value.valueID = CSSValueBoundingBox;
-        break;
     case MarginBox:
         m_value.valueID = CSSValueMarginBox;
         break;
@@ -5141,6 +5138,15 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LayoutBox layoutBox)
     case ContentBox:
         m_value.valueID = CSSValueContentBox;
         break;
+    case Fill:
+        m_value.valueID = CSSValueFill;
+        break;
+    case Stroke:
+        m_value.valueID = CSSValueStroke;
+        break;
+    case ViewBox:
+        m_value.valueID = CSSValueViewBox;
+        break;
     case BoxMissing:
         ASSERT_NOT_REACHED();
         m_value.valueID = CSSValueNone;
@@ -5151,8 +5157,6 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LayoutBox layoutBox)
 template<> inline CSSPrimitiveValue::operator LayoutBox() const
 {
     switch (getValueID()) {
-    case CSSValueBoundingBox:
-        return BoundingBox;
     case CSSValueMarginBox:
         return MarginBox;
     case CSSValueBorderBox:
@@ -5161,6 +5165,13 @@ template<> inline CSSPrimitiveValue::operator LayoutBox() const
         return PaddingBox;
     case CSSValueContentBox:
         return ContentBox;
+    // The following are used in an SVG context.
+    case CSSValueFill:
+        return Fill;
+    case CSSValueStroke:
+        return Stroke;
+    case CSSValueViewBox:
+        return ViewBox;
     default:
         break;
     }
index 888b627..2675565 100644 (file)
@@ -745,7 +745,7 @@ padding-box
 margin-box
 
 // clip-path
-bounding-box
+view-box
 
 //
 // background-size
index 2117b96..77d6bd1 100644 (file)
@@ -2139,7 +2139,9 @@ public:
                 || primitiveValue.getValueID() == CSSValueBorderBox
                 || primitiveValue.getValueID() == CSSValuePaddingBox
                 || primitiveValue.getValueID() == CSSValueMarginBox
-                || primitiveValue.getValueID() == CSSValueBoundingBox)
+                || primitiveValue.getValueID() == CSSValueFill
+                || primitiveValue.getValueID() == CSSValueStroke
+                || primitiveValue.getValueID() == CSSValueViewBox)
                 && referenceBox == BoxMissing)
                 referenceBox = LayoutBox(primitiveValue);
             else
index 717bee5..ad62595 100644 (file)
@@ -3790,6 +3790,10 @@ static inline LayoutRect computeReferenceBox(const RenderObject& renderer, const
                 referenceBox = box.paddingBoxRect();
                 referenceBox.moveBy(rootRelativeBounds.location());
                 break;
+            // fill, stroke, view-box compute to border-box for HTML elements.
+            case Fill:
+            case Stroke:
+            case ViewBox:
             case BorderBox:
                 referenceBox = box.borderBoxRect();
                 referenceBox.moveBy(rootRelativeBounds.location());
@@ -3797,7 +3801,6 @@ static inline LayoutRect computeReferenceBox(const RenderObject& renderer, const
             case MarginBox:
                 // FIXME: Support margin-box. Use bounding client rect for now.
                 // https://bugs.webkit.org/show_bug.cgi?id=127984
-            case BoundingBox:
             case BoxMissing:
                 // FIXME: If no reference box was specified the spec demands to use
                 // the border-box. However, the current prefixed version of clip-path uses
index f571f24..87834d9 100644 (file)
@@ -89,7 +89,9 @@ public:
             logicalHeight -= m_renderer.borderAndPaddingLogicalHeight();
             logicalWidth -= m_renderer.borderAndPaddingLogicalWidth();
             break;
-        case BoundingBox:
+        case Fill:
+        case Stroke:
+        case ViewBox:
         case BoxMissing:
             ASSERT_NOT_REACHED();
             break;
@@ -176,7 +178,9 @@ protected:
         case BorderBox: return LayoutUnit();
         case PaddingBox: return m_renderer.borderBefore();
         case ContentBox: return m_renderer.borderAndPaddingBefore();
-        case BoundingBox: break;
+        case Fill: break;
+        case Stroke: break;
+        case ViewBox: break;
         case BoxMissing: break;
         }
         ASSERT_NOT_REACHED();
@@ -193,7 +197,9 @@ protected:
         case BorderBox: return LayoutUnit();
         case PaddingBox: return m_renderer.borderStart();
         case ContentBox: return m_renderer.borderAndPaddingStart();
-        case BoundingBox: break;
+        case Fill: break;
+        case Stroke: break;
+        case ViewBox: break;
         case BoxMissing: break;
         }
         ASSERT_NOT_REACHED();
index 6a90f2e..9d337bb 100644 (file)
@@ -544,7 +544,8 @@ enum TextIndentLine { TextIndentFirstLine, TextIndentEachLine };
 enum TextIndentType { TextIndentNormal, TextIndentHanging };
 #endif
 
-enum LayoutBox { BoxMissing = 0, MarginBox, BorderBox, PaddingBox, ContentBox, BoundingBox };
+// Fill, Stroke, ViewBox are just used for SVG.
+enum LayoutBox { BoxMissing = 0, MarginBox, BorderBox, PaddingBox, ContentBox, Fill, Stroke, ViewBox };
 
 } // namespace WebCore
 
index 6486bdc..f36f757 100644 (file)
@@ -35,6 +35,7 @@
 #include "RenderSVGResourceFilter.h"
 #include "RenderSVGResourceMasker.h"
 #include "RenderView.h"
+#include "SVGLengthContext.h"
 #include "SVGResources.h"
 #include "SVGResourcesCache.h"
 
@@ -121,8 +122,19 @@ void SVGRenderingContext::prepareToRenderSVGContent(RenderElement& renderer, Pai
 
     ClipPathOperation* clipPathOperation = style.clipPath();
     if (clipPathOperation && clipPathOperation->type() == ClipPathOperation::Shape) {
-        ShapeClipPathOperation* clipPath = static_cast<ShapeClipPathOperation*>(clipPathOperation);
-        m_paintInfo->context->clipPath(clipPath->pathForReferenceRect(renderer.objectBoundingBox()), clipPath->windRule());
+        ShapeClipPathOperation& clipPath = toShapeClipPathOperation(*clipPathOperation);
+        FloatRect referenceBox;
+        if (clipPath.referenceBox() == Stroke)
+            // FIXME: strokeBoundingBox() takes dasharray into account but shouldn't.
+            referenceBox = renderer.strokeBoundingBox();
+        else if (clipPath.referenceBox() == ViewBox && renderer.element()) {
+            FloatSize viewportSize;
+            SVGLengthContext(toSVGElement(renderer.element())).determineViewport(viewportSize);
+            referenceBox.setWidth(viewportSize.width());
+            referenceBox.setHeight(viewportSize.height());
+        } else
+            referenceBox = renderer.objectBoundingBox();
+        m_paintInfo->context->clipPath(clipPath.pathForReferenceRect(referenceBox), clipPath.windRule());
     }
 
     SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(*m_renderer);