Title: [161669] trunk
Revision
161669
Author
k...@webkit.org
Date
2014-01-10 13:29:59 -0800 (Fri, 10 Jan 2014)

Log Message

Make clipping path from basic-shapes relative to <box> value
https://bugs.webkit.org/show_bug.cgi?id=126206

Reviewed by Simon Fraser.

Source/WebCore:

Tests: css3/masking/clip-path-circle-border-box.html
       css3/masking/clip-path-circle-bounding-box.html
       css3/masking/clip-path-circle-content-box.html
       css3/masking/clip-path-circle-margin-box.html
       css3/masking/clip-path-circle-padding-box.html

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::setupClipPath): Add switch to differ between boxes
    and use different reference boxes to size the clipping path.

LayoutTests:

Add new tests to check that different reference boxes are chosen for sizing and
positioning the clipping path.

* css3/masking/clip-path-circle-border-box.html: Added.
* css3/masking/clip-path-circle-bounding-box.html: Added.
* css3/masking/clip-path-circle-content-box.html: Added.
* css3/masking/clip-path-circle-margin-box.html: Added.
* css3/masking/clip-path-circle-padding-box.html: Added.
* platform/mac/css3/masking/clip-path-circle-border-box-expected.png: Added.
* platform/mac/css3/masking/clip-path-circle-border-box-expected.txt: Added.
* platform/mac/css3/masking/clip-path-circle-bounding-box-expected.png: Added.
* platform/mac/css3/masking/clip-path-circle-bounding-box-expected.txt: Added.
* platform/mac/css3/masking/clip-path-circle-content-box-expected.png: Added.
* platform/mac/css3/masking/clip-path-circle-content-box-expected.txt: Added.
* platform/mac/css3/masking/clip-path-circle-margin-box-expected.png: Added.
* platform/mac/css3/masking/clip-path-circle-margin-box-expected.txt: Added.
* platform/mac/css3/masking/clip-path-circle-padding-box-expected.png: Added.
* platform/mac/css3/masking/clip-path-circle-padding-box-expected.txt: Added.
* platform/mac/css3/masking/mask-luminance-png-expected.png: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (161668 => 161669)


--- trunk/LayoutTests/ChangeLog	2014-01-10 21:22:18 UTC (rev 161668)
+++ trunk/LayoutTests/ChangeLog	2014-01-10 21:29:59 UTC (rev 161669)
@@ -1,3 +1,30 @@
+2014-01-10  Dirk Schulze  <k...@webkit.org>
+
+        Make clipping path from basic-shapes relative to <box> value
+        https://bugs.webkit.org/show_bug.cgi?id=126206
+
+        Reviewed by Simon Fraser.
+
+        Add new tests to check that different reference boxes are chosen for sizing and
+        positioning the clipping path.
+
+        * css3/masking/clip-path-circle-border-box.html: Added.
+        * css3/masking/clip-path-circle-bounding-box.html: Added.
+        * css3/masking/clip-path-circle-content-box.html: Added.
+        * css3/masking/clip-path-circle-margin-box.html: Added.
+        * css3/masking/clip-path-circle-padding-box.html: Added.
+        * platform/mac/css3/masking/clip-path-circle-border-box-expected.png: Added.
+        * platform/mac/css3/masking/clip-path-circle-border-box-expected.txt: Added.
+        * platform/mac/css3/masking/clip-path-circle-bounding-box-expected.png: Added.
+        * platform/mac/css3/masking/clip-path-circle-bounding-box-expected.txt: Added.
+        * platform/mac/css3/masking/clip-path-circle-content-box-expected.png: Added.
+        * platform/mac/css3/masking/clip-path-circle-content-box-expected.txt: Added.
+        * platform/mac/css3/masking/clip-path-circle-margin-box-expected.png: Added.
+        * platform/mac/css3/masking/clip-path-circle-margin-box-expected.txt: Added.
+        * platform/mac/css3/masking/clip-path-circle-padding-box-expected.png: Added.
+        * platform/mac/css3/masking/clip-path-circle-padding-box-expected.txt: Added.
+        * platform/mac/css3/masking/mask-luminance-png-expected.png: Added.
+
 2014-01-10  Youenn Fablet  <youe...@gmail.com>
 
         Correctly set XHR loadend event attributes (loaded and total).

Added: trunk/LayoutTests/css3/masking/clip-path-circle-border-box.html (0 => 161669)


--- trunk/LayoutTests/css3/masking/clip-path-circle-border-box.html	                        (rev 0)
+++ trunk/LayoutTests/css3/masking/clip-path-circle-border-box.html	2014-01-10 21:29:59 UTC (rev 161669)
@@ -0,0 +1,28 @@
+<!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%) border-box;
+    background-color: yellow;
+}
+</style>
+</head>
+<body>
+<div id="clip">
+	<div id="content"></div>
+</div>
+</body>
+</html>

Added: trunk/LayoutTests/css3/masking/clip-path-circle-bounding-box.html (0 => 161669)


--- trunk/LayoutTests/css3/masking/clip-path-circle-bounding-box.html	                        (rev 0)
+++ trunk/LayoutTests/css3/masking/clip-path-circle-bounding-box.html	2014-01-10 21:29:59 UTC (rev 161669)
@@ -0,0 +1,28 @@
+<!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>

Added: trunk/LayoutTests/css3/masking/clip-path-circle-content-box.html (0 => 161669)


--- trunk/LayoutTests/css3/masking/clip-path-circle-content-box.html	                        (rev 0)
+++ trunk/LayoutTests/css3/masking/clip-path-circle-content-box.html	2014-01-10 21:29:59 UTC (rev 161669)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<style>
+#content {
+    width: 200px;
+    height: 200px;
+    margin: 0;
+    padding: 0;
+    background-color: green;
+}
+#clip {
+    width: 200px;
+    height: 200px;
+	border: 10px solid blue;
+    -webkit-clip-path: circle(50% at 50% 50%) content-box;
+    background-color: yellow;
+}
+</style>
+</head>
+<body>
+<div id="clip">
+	<div id="content"></div>
+</div>
+</body>
+</html>

Added: trunk/LayoutTests/css3/masking/clip-path-circle-margin-box.html (0 => 161669)


--- trunk/LayoutTests/css3/masking/clip-path-circle-margin-box.html	                        (rev 0)
+++ trunk/LayoutTests/css3/masking/clip-path-circle-margin-box.html	2014-01-10 21:29:59 UTC (rev 161669)
@@ -0,0 +1,28 @@
+<!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%) margin-box;
+    background-color: yellow;
+}
+</style>
+</head>
+<body>
+<div id="clip">
+	<div id="content"></div>
+</div>
+</body>
+</html>

Added: trunk/LayoutTests/css3/masking/clip-path-circle-padding-box.html (0 => 161669)


--- trunk/LayoutTests/css3/masking/clip-path-circle-padding-box.html	                        (rev 0)
+++ trunk/LayoutTests/css3/masking/clip-path-circle-padding-box.html	2014-01-10 21:29:59 UTC (rev 161669)
@@ -0,0 +1,28 @@
+<!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%) padding-box;
+    background-color: yellow;
+}
+</style>
+</head>
+<body>
+<div id="clip">
+	<div id="content"></div>
+</div>
+</body>
+</html>

Added: trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-border-box-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-border-box-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-border-box-expected.txt (0 => 161669)


--- trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-border-box-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-border-box-expected.txt	2014-01-10 21:29:59 UTC (rev 161669)
@@ -0,0 +1,8 @@
+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]

Added: trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-bounding-box-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-bounding-box-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-bounding-box-expected.txt (0 => 161669)


--- trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-bounding-box-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-bounding-box-expected.txt	2014-01-10 21:29:59 UTC (rev 161669)
@@ -0,0 +1,8 @@
+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]

Added: trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-content-box-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-content-box-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-content-box-expected.txt (0 => 161669)


--- trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-content-box-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-content-box-expected.txt	2014-01-10 21:29:59 UTC (rev 161669)
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x236
+  RenderBlock {HTML} at (0,0) size 800x236
+    RenderBody {BODY} at (8,8) size 784x220
+layer at (8,8) size 220x220
+  RenderBlock {DIV} at (0,0) size 220x220 [bgcolor=#FFFF00] [border: (10px solid #0000FF)]
+    RenderBlock {DIV} at (10,10) size 200x200 [bgcolor=#008000]

Added: trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-margin-box-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-margin-box-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-margin-box-expected.txt (0 => 161669)


--- trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-margin-box-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-margin-box-expected.txt	2014-01-10 21:29:59 UTC (rev 161669)
@@ -0,0 +1,8 @@
+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]

Added: trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-padding-box-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-padding-box-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-padding-box-expected.txt (0 => 161669)


--- trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-padding-box-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/css3/masking/clip-path-circle-padding-box-expected.txt	2014-01-10 21:29:59 UTC (rev 161669)
@@ -0,0 +1,8 @@
+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]

Added: trunk/LayoutTests/platform/mac/css3/masking/mask-luminance-png-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/css3/masking/mask-luminance-png-expected.png ___________________________________________________________________

Added: svn:mime-type

Modified: trunk/Source/WebCore/ChangeLog (161668 => 161669)


--- trunk/Source/WebCore/ChangeLog	2014-01-10 21:22:18 UTC (rev 161668)
+++ trunk/Source/WebCore/ChangeLog	2014-01-10 21:29:59 UTC (rev 161669)
@@ -1,3 +1,20 @@
+2014-01-10  Dirk Schulze  <k...@webkit.org>
+
+        Make clipping path from basic-shapes relative to <box> value
+        https://bugs.webkit.org/show_bug.cgi?id=126206
+
+        Reviewed by Simon Fraser.
+
+        Tests: css3/masking/clip-path-circle-border-box.html
+               css3/masking/clip-path-circle-bounding-box.html
+               css3/masking/clip-path-circle-content-box.html
+               css3/masking/clip-path-circle-margin-box.html
+               css3/masking/clip-path-circle-padding-box.html
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::setupClipPath): Add switch to differ between boxes
+            and use different reference boxes to size the clipping path.
+
 2014-01-10  Youenn Fablet  <youe...@gmail.com>
 
 

Modified: trunk/Source/WebCore/rendering/ClipPathOperation.h (161668 => 161669)


--- trunk/Source/WebCore/rendering/ClipPathOperation.h	2014-01-10 21:22:18 UTC (rev 161668)
+++ trunk/Source/WebCore/rendering/ClipPathOperation.h	2014-01-10 21:29:59 UTC (rev 161669)
@@ -107,8 +107,6 @@
     const Path pathForReferenceRect(const FloatRect& boundingRect) const
     {
         ASSERT(m_shape);
-        // FIXME: Make clipping path from basic-shapes relative to <box> value.
-        // https://bugs.webkit.org/show_bug.cgi?id=126206
         Path path;
         m_shape->path(path, boundingRect);
         return path;

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (161668 => 161669)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2014-01-10 21:22:18 UTC (rev 161668)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2014-01-10 21:29:59 UTC (rev 161669)
@@ -3914,18 +3914,46 @@
         return false;
 
     RenderStyle& style = renderer().style();
-
     ASSERT(style.clipPath());
     if (style.clipPath()->type() == ClipPathOperation::Shape) {
-        ShapeClipPathOperation* clipPath = static_cast<ShapeClipPathOperation*>(style.clipPath());
+        ShapeClipPathOperation& clippingPath = toShapeClipPathOperation(*(style.clipPath()));
 
         if (!rootRelativeBoundsComputed) {
             rootRelativeBounds = calculateLayerBounds(paintingInfo.rootLayer, &offsetFromRoot, 0);
             rootRelativeBoundsComputed = true;
         }
 
+        LayoutRect referenceBox;
+        if (renderer().isBox()) {
+            RenderBox& box = toRenderBox(renderer());
+            switch (clippingPath.referenceBox()) {
+            case ContentBox:
+                referenceBox = box.contentBoxRect();
+                referenceBox.moveBy(rootRelativeBounds.location());
+                break;
+            case PaddingBox:
+                referenceBox = box.paddingBoxRect();
+                referenceBox.moveBy(rootRelativeBounds.location());
+                break;
+            case BorderBox:
+                referenceBox = box.borderBoxRect();
+                referenceBox.moveBy(rootRelativeBounds.location());
+                break;
+            case MarginBox:
+                // FIXME: Support margin-box. Use bounding client rect for now.
+            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
+                // bounding-box. Keep bounding-box for now.
+                referenceBox = rootRelativeBounds;
+            }
+        } else
+            // FIXME: Support different reference boxes for inline content.
+            referenceBox = rootRelativeBounds;
+
         context->save();
-        context->clipPath(clipPath->pathForReferenceRect(rootRelativeBounds), clipPath->windRule());
+        context->clipPath(clippingPath.pathForReferenceRect(referenceBox), clippingPath.windRule());
         return true;
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to