Diff
Modified: trunk/LayoutTests/ChangeLog (163204 => 163205)
--- trunk/LayoutTests/ChangeLog 2014-01-31 22:35:14 UTC (rev 163204)
+++ trunk/LayoutTests/ChangeLog 2014-01-31 22:44:26 UTC (rev 163205)
@@ -1,3 +1,20 @@
+2014-01-31 Bem Jones-Bey <[email protected]>
+
+ Create clipping path from <box> value
+ https://bugs.webkit.org/show_bug.cgi?id=126205
+
+ Reviewed by Dirk Schulze.
+
+ Tests for border, padding and content box values. Margin is
+ unimplemented as of yet.
+
+ * css3/masking/clip-path-border-box-expected.html: Added.
+ * css3/masking/clip-path-border-box.html: Added.
+ * css3/masking/clip-path-content-box-expected.html: Added.
+ * css3/masking/clip-path-content-box.html: Added.
+ * css3/masking/clip-path-padding-box-expected.html: Added.
+ * css3/masking/clip-path-padding-box.html: Added.
+
2014-01-29 Oliver Hunt <[email protected]>
Make it possible to implement JS builtins in JS
Added: trunk/LayoutTests/css3/masking/clip-path-border-box-expected.html (0 => 163205)
--- trunk/LayoutTests/css3/masking/clip-path-border-box-expected.html (rev 0)
+++ trunk/LayoutTests/css3/masking/clip-path-border-box-expected.html 2014-01-31 22:44:26 UTC (rev 163205)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<style>
+.clip {
+ width: 140px;
+ height: 140px;
+ background-color: green;
+ padding: 10px;
+ border: 10px solid green;
+ margin: 10px;
+}
+</style>
+<body>
+<div class="clip"></div>
+</body>
+</html>
Added: trunk/LayoutTests/css3/masking/clip-path-border-box.html (0 => 163205)
--- trunk/LayoutTests/css3/masking/clip-path-border-box.html (rev 0)
+++ trunk/LayoutTests/css3/masking/clip-path-border-box.html 2014-01-31 22:44:26 UTC (rev 163205)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<style>
+.clip {
+ width: 140px;
+ height: 140px;
+ background-color: green;
+ padding: 10px;
+ border: 10px solid green;
+ margin: 10px;
+ -webkit-clip-path: border-box;
+}
+</style>
+<body>
+<div class="clip"></div>
+</body>
+</html>
Added: trunk/LayoutTests/css3/masking/clip-path-content-box-expected.html (0 => 163205)
--- trunk/LayoutTests/css3/masking/clip-path-content-box-expected.html (rev 0)
+++ trunk/LayoutTests/css3/masking/clip-path-content-box-expected.html 2014-01-31 22:44:26 UTC (rev 163205)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<style>
+.clip {
+ width: 140px;
+ height: 140px;
+ background-color: green;
+ margin: 30px;
+}
+</style>
+<body>
+<div class="clip"></div>
+</body>
+</html>
Added: trunk/LayoutTests/css3/masking/clip-path-content-box.html (0 => 163205)
--- trunk/LayoutTests/css3/masking/clip-path-content-box.html (rev 0)
+++ trunk/LayoutTests/css3/masking/clip-path-content-box.html 2014-01-31 22:44:26 UTC (rev 163205)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<style>
+.clip {
+ width: 140px;
+ height: 140px;
+ background-color: green;
+ padding: 10px;
+ border: 10px solid red;
+ margin: 10px;
+ -webkit-clip-path: content-box;
+}
+</style>
+<body>
+<div class="clip"></div>
+</body>
+</html>
Added: trunk/LayoutTests/css3/masking/clip-path-padding-box-expected.html (0 => 163205)
--- trunk/LayoutTests/css3/masking/clip-path-padding-box-expected.html (rev 0)
+++ trunk/LayoutTests/css3/masking/clip-path-padding-box-expected.html 2014-01-31 22:44:26 UTC (rev 163205)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<style>
+.clip {
+ width: 140px;
+ height: 140px;
+ background-color: green;
+ padding: 10px;
+ margin: 20px;
+}
+</style>
+<body>
+<div class="clip"></div>
+</body>
+</html>
Added: trunk/LayoutTests/css3/masking/clip-path-padding-box.html (0 => 163205)
--- trunk/LayoutTests/css3/masking/clip-path-padding-box.html (rev 0)
+++ trunk/LayoutTests/css3/masking/clip-path-padding-box.html 2014-01-31 22:44:26 UTC (rev 163205)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<style>
+.clip {
+ width: 140px;
+ height: 140px;
+ background-color: green;
+ padding: 10px;
+ border: 10px solid red;
+ margin: 10px;
+ -webkit-clip-path: padding-box;
+}
+</style>
+<body>
+<div class="clip"></div>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (163204 => 163205)
--- trunk/Source/WebCore/ChangeLog 2014-01-31 22:35:14 UTC (rev 163204)
+++ trunk/Source/WebCore/ChangeLog 2014-01-31 22:44:26 UTC (rev 163205)
@@ -1,3 +1,26 @@
+2014-01-31 Bem Jones-Bey <[email protected]>
+
+ Create clipping path from <box> value
+ https://bugs.webkit.org/show_bug.cgi?id=126205
+
+ Reviewed by Dirk Schulze.
+
+ This implements <box> values for border, content, and padding boxes.
+ Since margin box is not implemented as a reference box, this does not
+ implement margin box value.
+
+ Tests: css3/masking/clip-path-border-box.html
+ css3/masking/clip-path-content-box.html
+ css3/masking/clip-path-padding-box.html
+
+ * rendering/ClipPathOperation.h:
+ (WebCore::BoxClipPathOperation::pathForReferenceRect): Implement.
+ * rendering/RenderLayer.cpp:
+ (WebCore::computeReferenceBox): Pull out reference box calculation.
+ (WebCore::RenderLayer::setupClipPath): Add support for <box> values.
+ * rendering/shapes/ShapeInfo.cpp:
+ (WebCore::ShapeInfo<RenderType>::computedShape): Add FIXME comment.
+
2014-01-29 Oliver Hunt <[email protected]>
Make it possible to implement JS builtins in JS
Modified: trunk/Source/WebCore/rendering/ClipPathOperation.h (163204 => 163205)
--- trunk/Source/WebCore/rendering/ClipPathOperation.h 2014-01-31 22:35:14 UTC (rev 163204)
+++ trunk/Source/WebCore/rendering/ClipPathOperation.h 2014-01-31 22:44:26 UTC (rev 163205)
@@ -142,11 +142,10 @@
return adoptRef(new BoxClipPathOperation(referenceBox));
}
- const Path pathForReferenceRect(const FloatRect&) const
+ const Path pathForReferenceRect(const RoundedRect& boundingRect) const
{
Path path;
- // FIXME: Create clipping path from <box>.
- // https://bugs.webkit.org/show_bug.cgi?id=126205
+ path.addRoundedRect(boundingRect);
return path;
}
LayoutBox referenceBox() const { return m_referenceBox; }
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (163204 => 163205)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2014-01-31 22:35:14 UTC (rev 163204)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2014-01-31 22:44:26 UTC (rev 163205)
@@ -3780,25 +3780,13 @@
return false;
}
-bool RenderLayer::setupClipPath(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, const LayoutPoint& offsetFromRoot, LayoutRect& rootRelativeBounds, bool& rootRelativeBoundsComputed)
+template <class ReferenceBoxClipPathOperation>
+static inline LayoutRect computeReferenceBox(const RenderObject& renderer, const ReferenceBoxClipPathOperation& clippingPath, const LayoutRect& rootRelativeBounds)
{
- if (!renderer().hasClipPath() || context->paintingDisabled())
- return false;
-
- RenderStyle& style = renderer().style();
- ASSERT(style.clipPath());
- if (style.clipPath()->type() == ClipPathOperation::Shape) {
- 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()) {
+ LayoutRect referenceBox;
+ if (renderer.isBox()) {
+ const RenderBox& box = toRenderBox(renderer);
+ switch (clippingPath.referenceBox()) {
case ContentBox:
referenceBox = box.contentBoxRect();
referenceBox.moveBy(rootRelativeBounds.location());
@@ -3813,32 +3801,60 @@
break;
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
// bounding-box. Keep bounding-box for now.
referenceBox = rootRelativeBounds;
- }
- } else
- // FIXME: Support different reference boxes for inline content.
- referenceBox = rootRelativeBounds;
+ }
+ } else
+ // FIXME: Support different reference boxes for inline content.
+ referenceBox = rootRelativeBounds;
+ return referenceBox;
+}
+
+bool RenderLayer::setupClipPath(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, const LayoutPoint& offsetFromRoot, LayoutRect& rootRelativeBounds, bool& rootRelativeBoundsComputed)
+{
+ if (!renderer().hasClipPath() || context->paintingDisabled())
+ return false;
+
+ if (!rootRelativeBoundsComputed) {
+ rootRelativeBounds = calculateLayerBounds(paintingInfo.rootLayer, &offsetFromRoot, 0);
+ rootRelativeBoundsComputed = true;
+ }
+
+ RenderStyle& style = renderer().style();
+ ASSERT(style.clipPath());
+ if (style.clipPath()->type() == ClipPathOperation::Shape) {
+ ShapeClipPathOperation& clippingPath = toShapeClipPathOperation(*(style.clipPath()));
+
+ LayoutRect referenceBox = computeReferenceBox(renderer(), clippingPath, rootRelativeBounds);
context->save();
context->clipPath(clippingPath.pathForReferenceRect(referenceBox), clippingPath.windRule());
return true;
}
+ if (style.clipPath()->type() == ClipPathOperation::Box) {
+ BoxClipPathOperation& clippingPath = toBoxClipPathOperation(*(style.clipPath()));
+
+ LayoutRect referenceBox = computeReferenceBox(renderer(), clippingPath, rootRelativeBounds);
+ // FIXME This does not properly compute the rounded corners as specified in all conditions.
+ // https://bugs.webkit.org/show_bug.cgi?id=127982
+ const RoundedRect& shapeRect = renderer().style().getRoundedBorderFor(referenceBox, &(renderer().view()));
+
+ context->save();
+ context->clipPath(clippingPath.pathForReferenceRect(shapeRect), RULE_NONZERO);
+ return true;
+ }
+
#if ENABLE(SVG)
if (style.clipPath()->type() == ClipPathOperation::Reference) {
ReferenceClipPathOperation* referenceClipPathOperation = static_cast<ReferenceClipPathOperation*>(style.clipPath());
Element* element = renderer().document().getElementById(referenceClipPathOperation->fragment());
if (element && element->hasTagName(SVGNames::clipPathTag) && element->renderer()) {
- if (!rootRelativeBoundsComputed) {
- rootRelativeBounds = calculateLayerBounds(paintingInfo.rootLayer, &offsetFromRoot, 0);
- rootRelativeBoundsComputed = true;
- }
-
// FIXME: This should use a safer cast such as toRenderSVGResourceContainer().
// FIXME: Should this do a context->save() and return true so we restore the context?
static_cast<RenderSVGResourceClipper*>(element->renderer())->applyClippingToContext(renderer(), rootRelativeBounds, paintingInfo.paintDirtyRect, context);
Modified: trunk/Source/WebCore/rendering/shapes/ShapeInfo.cpp (163204 => 163205)
--- trunk/Source/WebCore/rendering/shapes/ShapeInfo.cpp 2014-01-31 22:35:14 UTC (rev 163204)
+++ trunk/Source/WebCore/rendering/shapes/ShapeInfo.cpp 2014-01-31 22:44:26 UTC (rev 163205)
@@ -101,6 +101,8 @@
break;
}
case ShapeValue::Box: {
+ // FIXME This does not properly compute the rounded corners as specified in all conditions.
+ // https://bugs.webkit.org/show_bug.cgi?id=127982
const RoundedRect& shapeRect = m_renderer.style().getRoundedBorderFor(LayoutRect(LayoutPoint(), m_shapeLogicalSize), &(m_renderer.view()));
m_shape = Shape::createLayoutBoxShape(shapeRect, writingMode, margin, padding);
break;