Title: [127327] trunk
Revision
127327
Author
k...@webkit.org
Date
2012-08-31 15:29:48 -0700 (Fri, 31 Aug 2012)

Log Message

Introduce new CSS property for clip-path
https://bugs.webkit.org/show_bug.cgi?id=95474

Reviewed by Tim Horton.

Source/WebCore:

This path introduces the new, prefixed CSS property 'clip-path' from the
CSS Masking specification. In a first step the property just accepts
'none' and the the basic shapes from CSS Exclusion. Later it will also be
possible to reference SVG 'clipPath' elements - like Firefox already does.
To enable the parsing of the shapes, the exclusion compiler flags
around the shape parser were removed.

http://dvcs.w3.org/hg/FXTF/raw-file/tip/masking/index.html

Test: fast/masking/parsing-clip-path-shape.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Return CSSValue for CSSPropertyWebkitClipPath.
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue): Add CSSPropertyWebkitClipPath.
(WebCore::CSSParser::parseBasicShape): Modify parser function to accept CSSPropertyWebkitClipPath as well.
* css/CSSParser.h:
* css/CSSProperty.cpp:
(WebCore::CSSProperty::isInheritedProperty):
* css/CSSPropertyNames.in: Added property name -webkit-clip-path.
* css/StyleBuilder.cpp:
(ApplyPropertyClipPath): New property applier just for -webkit-clip-path.
(WebCore::ApplyPropertyClipPath::setValue):
(WebCore::ApplyPropertyClipPath::applyValue):
(WebCore::ApplyPropertyClipPath::createHandler):
(WebCore::StyleBuilder::StyleBuilder):
* rendering/style/RenderStyle.cpp: Repaint if there is a difference between two BasicShapes.
(WebCore::RenderStyle::diff):
* rendering/style/RenderStyle.h:
* rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
(WebCore::StyleRareNonInheritedData::operator==):
(WebCore::StyleRareNonInheritedData::reportMemoryUsage):
* rendering/style/StyleRareNonInheritedData.h: Add new member variable for clip shape.
(StyleRareNonInheritedData):

LayoutTests:

Test parsing behavior of basic shapes on new introduced '-webkit-clip-path' CSS property.

* fast/masking/parsing-clip-path-shape-expected.txt: Added.
* fast/masking/parsing-clip-path-shape.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (127326 => 127327)


--- trunk/LayoutTests/ChangeLog	2012-08-31 22:17:03 UTC (rev 127326)
+++ trunk/LayoutTests/ChangeLog	2012-08-31 22:29:48 UTC (rev 127327)
@@ -1,3 +1,15 @@
+2012-08-30  Dirk Schulze  <k...@webkit.org>
+
+        Introduce new CSS property for clip-path
+        https://bugs.webkit.org/show_bug.cgi?id=95474
+
+        Reviewed by Tim Horton.
+
+        Test parsing behavior of basic shapes on new introduced '-webkit-clip-path' CSS property.
+
+        * fast/masking/parsing-clip-path-shape-expected.txt: Added.
+        * fast/masking/parsing-clip-path-shape.html: Added.
+
 2012-08-31  Geoffrey Garen  <gga...@apple.com>
 
         Not reviewed.

Added: trunk/LayoutTests/fast/masking/parsing-clip-path-shape-expected.txt (0 => 127327)


--- trunk/LayoutTests/fast/masking/parsing-clip-path-shape-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/masking/parsing-clip-path-shape-expected.txt	2012-08-31 22:29:48 UTC (rev 127327)
@@ -0,0 +1,75 @@
+Test that clip-path shapes accept different length units
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS innerStyle("-webkit-clip-path", "circle(0, 0, 0)") is "circle(0px, 0px, 0px)"
+PASS innerStyle("-webkit-clip-path", "circle(-1px, +1px, 1px)") is "circle(-1px, 1px, 1px)"
+PASS innerStyle("-webkit-clip-path", "circle(-1.5px, +1.5px, 1.5px)") is "circle(-1.5px, 1.5px, 1.5px)"
+PASS innerStyle("-webkit-clip-path", "circle(-.5px, +.5px, .5px)") is "circle(-0.5px, 0.5px, 0.5px)"
+PASS innerStyle("-webkit-clip-path", "rectangle(1cm, 1mm, 1in, 1px, 1pt, 1pc)") is "rectangle(1cm, 1mm, 1in, 1px, 1pt, 1pc)"
+PASS innerStyle("-webkit-clip-path", "circle(-1em, +1em, 1em)") is "circle(-1em, 1em, 1em)"
+PASS innerStyle("-webkit-clip-path", "circle(-1.5em, +1.5em, 1.5em)") is "circle(-1.5em, 1.5em, 1.5em)"
+PASS innerStyle("-webkit-clip-path", "circle(-.5em, +.5em, .5em)") is "circle(-0.5em, 0.5em, 0.5em)"
+PASS innerStyle("-webkit-clip-path", "circle(1ex, 1ex, 1ex)") is "circle(1ex, 1ex, 1ex)"
+PASS innerStyle("-webkit-clip-path", "circle(1rem, 1rem, 1rem)") is "circle(1rem, 1rem, 1rem)"
+PASS computedStyle("-webkit-clip-path", "circle(.5em, 1em, 1.5em)") is "circle(4px, 8px, 12px)"
+PASS computedStyle("-webkit-clip-path", "circle(.5rem, 1rem, 1.5rem)") is "circle(8px, 16px, 24px)"
+PASS innerStyle("-webkit-clip-path", "circle(1vw, 1vw, 1vw)") is "circle(1vw, 1vw, 1vw)"
+PASS innerStyle("-webkit-clip-path", "circle(1vh, 1vh, 1vh)") is "circle(1vh, 1vh, 1vh)"
+PASS innerStyle("-webkit-clip-path", "circle(1vmin, 1vmin, 1vmin)") is "circle(1vmin, 1vmin, 1vmin)"
+PASS computedStyle("-webkit-clip-path", "circle(.5vw, 1vw, 1.5vw)") is "circle(0.5vw, 1vw, 1.5vw)"
+PASS computedStyle("-webkit-clip-path", "circle(.5vh, 1vh, 1.5vh)") is "circle(0.5vh, 1vh, 1.5vh)"
+PASS computedStyle("-webkit-clip-path", "circle(.5vmin, 1vmin, 1.5vmin)") is "circle(0.5vmin, 1vmin, 1.5vmin)"
+PASS innerStyle("-webkit-clip-path", "circle(100%, 100%, 100%)") is "circle(100%, 100%, 100%)"
+PASS innerStyle("-webkit-clip-path", "rectangle(45%, 45%, 90%, 60%, 25%, 10%)") is "rectangle(45%, 45%, 90%, 60%, 25%, 10%)"
+PASS innerStyle("-webkit-clip-path", "ellipse(100%, 100%, 100%, 100%)") is "ellipse(100%, 100%, 100%, 100%)"
+PASS innerStyle("-webkit-clip-path", "polygon(10% 20%, 30% 40%, 40% 50%)") is "polygon(nonzero, 10% 20%, 30% 40%, 40% 50%)"
+PASS computedStyle("-webkit-clip-path", "circle(50%, 100%, 150%)") is "circle(50%, 100%, 150%)"
+PASS computedStyle("-webkit-clip-path", "rectangle(45%, 45%, 90%, 60%, 25%, 10%)") is "rectangle(45%, 45%, 90%, 60%, 25%, 10%)"
+PASS computedStyle("-webkit-clip-path", "ellipse(100%, 100%, 100%, 100%)") is "ellipse(100%, 100%, 100%, 100%)"
+PASS computedStyle("-webkit-clip-path", "polygon(10% 20%, 30% 40%, 40% 50%)") is "polygon(nonzero, 10% 20%, 30% 40%, 40% 50%)"
+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
+PASS computedStyle("-webkit-clip-path", "circle(1px, 1px, px)") is "none"
+PASS innerStyle("-webkit-clip-path", "circle(1px, 1px, 1p)") is null
+PASS computedStyle("-webkit-clip-path", "circle(1px, 1px, 1p)") is "none"
+PASS innerStyle("-webkit-clip-path", "circle(1px, 1px, calc())") is null
+PASS computedStyle("-webkit-clip-path", "circle(1px, 1px, calc())") is "none"
+PASS innerStyle("-webkit-clip-path", "circle(-1.5px, +1.5px, -1.5px)") is null
+PASS computedStyle("-webkit-clip-path", "circle(-1.5px, +1.5px, -1.5px)") 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", "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", "ellipse(1em, 1em, -1em, 1em)") is null
+PASS computedStyle("-webkit-clip-path", "ellipse(1em, 1em, -1em, 1em)") is "none"
+PASS innerStyle("-webkit-clip-path", "ellipse(1em, 1em, 1em, -1em)") is null
+PASS computedStyle("-webkit-clip-path", "ellipse(1em, 1em, 1em, -1em)") 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", "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", "circle(0, 0)") is null
+PASS computedStyle("-webkit-clip-path", "circle(0, 0)") is "none"
+PASS innerStyle("-webkit-clip-path", "circle(0)") is null
+PASS computedStyle("-webkit-clip-path", "circle(0)") is "none"
+PASS innerStyle("-webkit-clip-path", "circle()") is null
+PASS computedStyle("-webkit-clip-path", "circle()") is "none"
+PASS innerStyle("-webkit-clip-path", "polygon(0, 0)") is null
+PASS computedStyle("-webkit-clip-path", "polygon(0, 0)") is "none"
+PASS innerStyle("-webkit-clip-path", "polygon(0 0, 0)") is null
+PASS computedStyle("-webkit-clip-path", "polygon(0 0, 0)") is "none"
+PASS innerStyle("-webkit-clip-path", "polygon(0)") is null
+PASS computedStyle("-webkit-clip-path", "polygon(0)") is "none"
+PASS innerStyle("-webkit-clip-path", "polygon()") is null
+PASS computedStyle("-webkit-clip-path", "polygon()") is "none"
+PASS innerStyle("-webkit-clip-path", "polygon(evenodd)") is null
+PASS computedStyle("-webkit-clip-path", "polygon(evenodd)") is "none"
+PASS innerStyle("-webkit-clip-path", "polygon(nonzero)") is null
+PASS computedStyle("-webkit-clip-path", "polygon(nonzero)") is "none"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/masking/parsing-clip-path-shape.html (0 => 127327)


--- trunk/LayoutTests/fast/masking/parsing-clip-path-shape.html	                        (rev 0)
+++ trunk/LayoutTests/fast/masking/parsing-clip-path-shape.html	2012-08-31 22:29:48 UTC (rev 127327)
@@ -0,0 +1,114 @@
+<!DOCTYPE html>
+<html>
+<style>
+* { font-size: 16px; }
+div { font-size: 8px; }
+</style>
+<body>
+<script src=""
+<script>
+description('Test that clip-path shapes accept different length units');
+
+function computedStyle(property, value) {
+    var div = document.createElement("div");
+    document.body.appendChild(div);
+    div.style.setProperty(property, value);
+    var computedValue = getComputedStyle(div).getPropertyValue(property);
+    document.body.removeChild(div);
+    return computedValue;
+}
+
+function innerStyle(property, value) {
+    var div = document.createElement("div");
+    div.style.setProperty(property, value);
+    return div.style.getPropertyValue(property);
+}
+
+function testComputed(property, value, expected) {
+    shouldBeEqualToString('computedStyle("' + property + '", "' + value + '")', expected);
+}
+
+function testInner(property, value, expected) {
+    if (expected === null)
+        shouldBeNull('innerStyle("' + property + '", "' + value + '")');
+    else
+        shouldBeEqualToString('innerStyle("' + property + '", "' + value + '")', expected);
+}
+
+function negativeTest(property, value) {
+    testInner(property, value, null);
+    testComputed(property, value, 'none');
+}
+
+// absolute lengths - number serialization, units
+testInner("-webkit-clip-path", "circle(0, 0, 0)", "circle(0px, 0px, 0px)");
+testInner("-webkit-clip-path", "circle(-1px, +1px, 1px)", "circle(-1px, 1px, 1px)");
+testInner("-webkit-clip-path", "circle(-1.5px, +1.5px, 1.5px)", "circle(-1.5px, 1.5px, 1.5px)");
+testInner("-webkit-clip-path", "circle(-.5px, +.5px, .5px)", "circle(-0.5px, 0.5px, 0.5px)");
+
+testInner("-webkit-clip-path", "rectangle(1cm, 1mm, 1in, 1px, 1pt, 1pc)", "rectangle(1cm, 1mm, 1in, 1px, 1pt, 1pc)");
+
+// font-relative lengths - number serialization, units, resolution
+testInner("-webkit-clip-path", "circle(-1em, +1em, 1em)", "circle(-1em, 1em, 1em)");
+testInner("-webkit-clip-path", "circle(-1.5em, +1.5em, 1.5em)", "circle(-1.5em, 1.5em, 1.5em)");
+testInner("-webkit-clip-path", "circle(-.5em, +.5em, .5em)", "circle(-0.5em, 0.5em, 0.5em)");
+
+testInner("-webkit-clip-path", "circle(1ex, 1ex, 1ex)", "circle(1ex, 1ex, 1ex)");
+// FIXME: Add ch test when it is supported
+testInner("-webkit-clip-path", "circle(1rem, 1rem, 1rem)", "circle(1rem, 1rem, 1rem)");
+
+testComputed("-webkit-clip-path", "circle(.5em, 1em, 1.5em)", "circle(4px, 8px, 12px)");
+testComputed("-webkit-clip-path", "circle(.5rem, 1rem, 1.5rem)", "circle(8px, 16px, 24px)");
+
+// viewport-percentage lengths - units, resolution
+testInner("-webkit-clip-path", "circle(1vw, 1vw, 1vw)", "circle(1vw, 1vw, 1vw)");
+testInner("-webkit-clip-path", "circle(1vh, 1vh, 1vh)", "circle(1vh, 1vh, 1vh)");
+testInner("-webkit-clip-path", "circle(1vmin, 1vmin, 1vmin)", "circle(1vmin, 1vmin, 1vmin)");
+
+testComputed("-webkit-clip-path", "circle(.5vw, 1vw, 1.5vw)", "circle(0.5vw, 1vw, 1.5vw)");
+testComputed("-webkit-clip-path", "circle(.5vh, 1vh, 1.5vh)", "circle(0.5vh, 1vh, 1.5vh)");
+testComputed("-webkit-clip-path", "circle(.5vmin, 1vmin, 1.5vmin)", "circle(0.5vmin, 1vmin, 1.5vmin)");
+
+// percentage lengths - units
+testInner("-webkit-clip-path", "circle(100%, 100%, 100%)", "circle(100%, 100%, 100%)");
+testInner("-webkit-clip-path", "rectangle(45%, 45%, 90%, 60%, 25%, 10%)", "rectangle(45%, 45%, 90%, 60%, 25%, 10%)");
+testInner("-webkit-clip-path", "ellipse(100%, 100%, 100%, 100%)", "ellipse(100%, 100%, 100%, 100%)");
+testInner("-webkit-clip-path", "polygon(10% 20%, 30% 40%, 40% 50%)", "polygon(nonzero, 10% 20%, 30% 40%, 40% 50%)");
+
+testComputed("-webkit-clip-path", "circle(50%, 100%, 150%)", "circle(50%, 100%, 150%)");
+testComputed("-webkit-clip-path", "rectangle(45%, 45%, 90%, 60%, 25%, 10%)", "rectangle(45%, 45%, 90%, 60%, 25%, 10%)");
+testComputed("-webkit-clip-path", "ellipse(100%, 100%, 100%, 100%)", "ellipse(100%, 100%, 100%, 100%)");
+testComputed("-webkit-clip-path", "polygon(10% 20%, 30% 40%, 40% 50%)", "polygon(nonzero, 10% 20%, 30% 40%, 40% 50%)");
+
+// reject non-lengths
+negativeTest("-webkit-clip-path", "circle(1px, 1px, 1)");
+negativeTest("-webkit-clip-path", "circle(1px, 1px, px)");
+negativeTest("-webkit-clip-path", "circle(1px, 1px, 1p)");
+negativeTest("-webkit-clip-path", "circle(1px, 1px, calc())");
+
+// reject negative radiuses
+negativeTest("-webkit-clip-path", "circle(-1.5px, +1.5px, -1.5px)");
+negativeTest("-webkit-clip-path", "rectangle(1cm, 1mm, 1in, 1px, -1pt, 1pc)");
+negativeTest("-webkit-clip-path", "rectangle(1cm, 1mm, 1in, 1px, 1pt, -1pc)");
+negativeTest("-webkit-clip-path", "ellipse(1em, 1em, -1em, 1em)");
+negativeTest("-webkit-clip-path", "ellipse(1em, 1em, 1em, -1em)");
+
+// reject negative height and width
+negativeTest("-webkit-clip-path", "rectangle(1cm, 1mm, -1in, 1px, 1pt, 1pc)");
+negativeTest("-webkit-clip-path", "rectangle(1cm, 1mm, 1in, -1px, 1pt, 1pc)");
+
+// general negative tests
+negativeTest("-webkit-clip-path", "circle(0, 0)");
+negativeTest("-webkit-clip-path", "circle(0)");
+negativeTest("-webkit-clip-path", "circle()");
+negativeTest("-webkit-clip-path", "polygon(0, 0)");
+negativeTest("-webkit-clip-path", "polygon(0 0, 0)");
+negativeTest("-webkit-clip-path", "polygon(0)");
+negativeTest("-webkit-clip-path", "polygon()");
+negativeTest("-webkit-clip-path", "polygon(evenodd)");
+negativeTest("-webkit-clip-path", "polygon(nonzero)");
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (127326 => 127327)


--- trunk/Source/WebCore/ChangeLog	2012-08-31 22:17:03 UTC (rev 127326)
+++ trunk/Source/WebCore/ChangeLog	2012-08-31 22:29:48 UTC (rev 127327)
@@ -1,3 +1,46 @@
+2012-08-30  Dirk Schulze  <k...@webkit.org>
+
+        Introduce new CSS property for clip-path
+        https://bugs.webkit.org/show_bug.cgi?id=95474
+
+        Reviewed by Tim Horton.
+
+        This path introduces the new, prefixed CSS property 'clip-path' from the
+        CSS Masking specification. In a first step the property just accepts
+        'none' and the the basic shapes from CSS Exclusion. Later it will also be
+        possible to reference SVG 'clipPath' elements - like Firefox already does.
+        To enable the parsing of the shapes, the exclusion compiler flags
+        around the shape parser were removed.
+
+        http://dvcs.w3.org/hg/FXTF/raw-file/tip/masking/index.html
+
+        Test: fast/masking/parsing-clip-path-shape.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Return CSSValue for CSSPropertyWebkitClipPath.
+        * css/CSSParser.cpp: 
+        (WebCore::CSSParser::parseValue): Add CSSPropertyWebkitClipPath.
+        (WebCore::CSSParser::parseBasicShape): Modify parser function to accept CSSPropertyWebkitClipPath as well.
+        * css/CSSParser.h:
+        * css/CSSProperty.cpp:
+        (WebCore::CSSProperty::isInheritedProperty):
+        * css/CSSPropertyNames.in: Added property name -webkit-clip-path.
+        * css/StyleBuilder.cpp:
+        (ApplyPropertyClipPath): New property applier just for -webkit-clip-path.
+        (WebCore::ApplyPropertyClipPath::setValue):
+        (WebCore::ApplyPropertyClipPath::applyValue):
+        (WebCore::ApplyPropertyClipPath::createHandler):
+        (WebCore::StyleBuilder::StyleBuilder):
+        * rendering/style/RenderStyle.cpp: Repaint if there is a difference between two BasicShapes.
+        (WebCore::RenderStyle::diff):
+        * rendering/style/RenderStyle.h:
+        * rendering/style/StyleRareNonInheritedData.cpp: 
+        (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
+        (WebCore::StyleRareNonInheritedData::operator==):
+        (WebCore::StyleRareNonInheritedData::reportMemoryUsage):
+        * rendering/style/StyleRareNonInheritedData.h: Add new member variable for clip shape.
+        (StyleRareNonInheritedData):
+
 2012-08-31  Joshua Netterfield  <jnetterfi...@rim.com>
 
         [BlackBerry] Eliminate WebGL IT policy

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (127326 => 127327)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2012-08-31 22:17:03 UTC (rev 127326)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2012-08-31 22:29:48 UTC (rev 127327)
@@ -25,7 +25,10 @@
 #include "CSSComputedStyleDeclaration.h"
 
 #include "AnimationController.h"
+#include "BasicShapeFunctions.h"
+#include "BasicShapes.h"
 #include "CSSAspectRatioValue.h"
+#include "CSSBasicShapes.h"
 #include "CSSBorderImage.h"
 #include "CSSLineBoxContainValue.h"
 #include "CSSParser.h"
@@ -60,12 +63,6 @@
 #include "WebKitFontFamilyNames.h"
 #include <wtf/text/StringBuilder.h>
 
-#if ENABLE(CSS_EXCLUSIONS)
-#include "BasicShapeFunctions.h"
-#include "BasicShapes.h"
-#include "CSSBasicShapes.h"
-#endif
-
 #if ENABLE(CSS_SHADERS)
 #include "CustomFilterNumberParameter.h"
 #include "CustomFilterOperation.h"
@@ -235,6 +232,7 @@
     CSSPropertyWebkitBoxPack,
     CSSPropertyWebkitBoxReflect,
     CSSPropertyWebkitBoxShadow,
+    CSSPropertyWebkitClipPath,
     CSSPropertyWebkitColorCorrection,
     CSSPropertyWebkitColumnBreakAfter,
     CSSPropertyWebkitColumnBreakBefore,
@@ -2403,6 +2401,10 @@
             return counterToCSSValue(style.get(), propertyID);
         case CSSPropertyCounterReset:
             return counterToCSSValue(style.get(), propertyID);
+        case CSSPropertyWebkitClipPath:
+            if (!style->clipPath())
+                return cssValuePool().createIdentifierValue(CSSValueNone);
+            return valueForBasicShape(style->clipPath());
 #if ENABLE(CSS_REGIONS)
         case CSSPropertyWebkitFlowInto:
             if (style->flowThread().isNull())

Modified: trunk/Source/WebCore/css/CSSParser.cpp (127326 => 127327)


--- trunk/Source/WebCore/css/CSSParser.cpp	2012-08-31 22:17:03 UTC (rev 127326)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2012-08-31 22:29:48 UTC (rev 127327)
@@ -2743,6 +2743,12 @@
         else
             return parseFontVariantLigatures(important);
         break;
+    case CSSPropertyWebkitClipPath:
+        if (id == CSSValueNone)
+            validPrimitive = true;
+        else if (value->unit == CSSParserValue::Function)
+            return parseBasicShape(propId, important);
+        break;
 #if ENABLE(CSS_EXCLUSIONS)
     case CSSPropertyWebkitShapeInside:
     case CSSPropertyWebkitShapeOutside:
@@ -2751,7 +2757,7 @@
         if (id == CSSValueAuto)
             validPrimitive = true;
         else if (value->unit == CSSParserValue::Function)
-            return parseBasicShape((propId == CSSPropertyWebkitShapeInside), important);
+            return parseBasicShape(propId, important);
         break;
     case CSSPropertyWebkitWrapMargin:
     case CSSPropertyWebkitWrapPadding:
@@ -4535,8 +4541,6 @@
     return false;
 }
 
-#if ENABLE(CSS_EXCLUSIONS)
-
 PassRefPtr<CSSBasicShape> CSSParser::parseBasicShapeRectangle(CSSParserValueList* args)
 {
     ASSERT(args);
@@ -4747,16 +4751,16 @@
     return shape;
 }
 
-bool CSSParser::parseBasicShape(bool shapeInside, bool important)
+bool CSSParser::parseBasicShape(CSSPropertyID propId, bool important)
 {
     CSSParserValue* value = m_valueList->current();
+    ASSERT(value->unit == CSSParserValue::Function);
     CSSParserValueList* args = value->function->args.get();
 
     if (!args)
         return false;
 
     RefPtr<CSSBasicShape> shape;
-
     if (equalIgnoringCase(value->function->name, "rectangle("))
         shape = parseBasicShapeRectangle(args);
     else if (equalIgnoringCase(value->function->name, "circle("))
@@ -4766,17 +4770,14 @@
     else if (equalIgnoringCase(value->function->name, "polygon("))
         shape = parseBasicShapePolygon(args);
 
-    if (shape) {
-        addProperty(shapeInside ? CSSPropertyWebkitShapeInside : CSSPropertyWebkitShapeOutside, cssValuePool().createValue(shape.release()), important);
-        m_valueList->next();
-        return true;
-    }
+    if (!shape)
+        return false;
 
-    return false;
+    addProperty(propId, cssValuePool().createValue(shape.release()), important);
+    m_valueList->next();
+    return true;
 }
 
-#endif
-
 // [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]? 'font-family'
 bool CSSParser::parseFont(bool important)
 {

Modified: trunk/Source/WebCore/css/CSSParser.h (127326 => 127327)


--- trunk/Source/WebCore/css/CSSParser.h	2012-08-31 22:17:03 UTC (rev 127326)
+++ trunk/Source/WebCore/css/CSSParser.h	2012-08-31 22:29:48 UTC (rev 127327)
@@ -150,7 +150,7 @@
 
     bool parseClipShape(CSSPropertyID, bool important);
 
-    bool parseBasicShape(bool shapeInside, bool important);
+    bool parseBasicShape(CSSPropertyID, bool important);
     PassRefPtr<CSSBasicShape> parseBasicShapeRectangle(CSSParserValueList* args);
     PassRefPtr<CSSBasicShape> parseBasicShapeCircle(CSSParserValueList* args);
     PassRefPtr<CSSBasicShape> parseBasicShapeEllipse(CSSParserValueList* args);

Modified: trunk/Source/WebCore/css/CSSProperty.cpp (127326 => 127327)


--- trunk/Source/WebCore/css/CSSProperty.cpp	2012-08-31 22:17:03 UTC (rev 127326)
+++ trunk/Source/WebCore/css/CSSProperty.cpp	2012-08-31 22:29:48 UTC (rev 127327)
@@ -561,6 +561,7 @@
     case CSSPropertyWebkitBoxPack:
     case CSSPropertyWebkitBoxReflect:
     case CSSPropertyWebkitBoxShadow:
+    case CSSPropertyWebkitClipPath:
     case CSSPropertyWebkitColumnAxis:
     case CSSPropertyWebkitColumnBreakAfter:
     case CSSPropertyWebkitColumnBreakBefore:

Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (127326 => 127327)


--- trunk/Source/WebCore/css/CSSPropertyNames.in	2012-08-31 22:17:03 UTC (rev 127326)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in	2012-08-31 22:29:48 UTC (rev 127327)
@@ -95,6 +95,7 @@
 -epub-caption-side = caption-side
 clear
 clip
+-webkit-clip-path
 content
 counter-increment
 counter-reset

Modified: trunk/Source/WebCore/css/StyleBuilder.cpp (127326 => 127327)


--- trunk/Source/WebCore/css/StyleBuilder.cpp	2012-08-31 22:17:03 UTC (rev 127326)
+++ trunk/Source/WebCore/css/StyleBuilder.cpp	2012-08-31 22:29:48 UTC (rev 127327)
@@ -1704,6 +1704,29 @@
     }
 };
 
+template <BasicShape* (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(PassRefPtr<BasicShape>), BasicShape* (*initialFunction)()>
+class ApplyPropertyClipPath {
+public:
+    static void setValue(RenderStyle* style, PassRefPtr<BasicShape> value) { (style->*setterFunction)(value); }
+    static void applyValue(StyleResolver* styleResolver, CSSValue* value)
+    {
+        if (value->isPrimitiveValue()) {
+            CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
+            if (primitiveValue->getIdent() == CSSValueNone)
+                setValue(styleResolver->style(), 0);
+            else if (primitiveValue->isShape()) {
+                RefPtr<BasicShape> clipPathShape = basicShapeForValue(styleResolver, primitiveValue->getShapeValue());
+                setValue(styleResolver->style(), clipPathShape.release());
+            }
+        }
+    }
+    static PropertyHandler createHandler()
+    {
+        PropertyHandler handler = ApplyPropertyDefaultBase<BasicShape*, getterFunction, PassRefPtr<BasicShape>, setterFunction, BasicShape*, initialFunction>::createHandler();
+        return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
+    }
+};
+
 #if ENABLE(CSS_EXCLUSIONS)
 template <BasicShape* (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(PassRefPtr<BasicShape>), BasicShape* (*initialFunction)()>
 class ApplyPropertyWrapShape {
@@ -2048,6 +2071,8 @@
     setPropertyHandler(CSSPropertyWebkitUserDrag, ApplyPropertyDefault<EUserDrag, &RenderStyle::userDrag, EUserDrag, &RenderStyle::setUserDrag, EUserDrag, &RenderStyle::initialUserDrag>::createHandler());
     setPropertyHandler(CSSPropertyWebkitUserModify, ApplyPropertyDefault<EUserModify, &RenderStyle::userModify, EUserModify, &RenderStyle::setUserModify, EUserModify, &RenderStyle::initialUserModify>::createHandler());
     setPropertyHandler(CSSPropertyWebkitUserSelect, ApplyPropertyDefault<EUserSelect, &RenderStyle::userSelect, EUserSelect, &RenderStyle::setUserSelect, EUserSelect, &RenderStyle::initialUserSelect>::createHandler());
+    setPropertyHandler(CSSPropertyWebkitClipPath, ApplyPropertyClipPath<&RenderStyle::clipPath, &RenderStyle::setClipPath, &RenderStyle::initialClipPath>::createHandler());
+
 #if ENABLE(CSS_EXCLUSIONS)
     setPropertyHandler(CSSPropertyWebkitWrap, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitWrapFlow, CSSPropertyWebkitWrapMargin, CSSPropertyWebkitWrapPadding>::createHandler());
     setPropertyHandler(CSSPropertyWebkitWrapFlow, ApplyPropertyDefault<WrapFlow, &RenderStyle::wrapFlow, WrapFlow, &RenderStyle::setWrapFlow, WrapFlow, &RenderStyle::initialWrapFlow>::createHandler());

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (127326 => 127327)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2012-08-31 22:17:03 UTC (rev 127326)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2012-08-31 22:29:48 UTC (rev 127327)
@@ -681,6 +681,10 @@
         if (rareNonInheritedData->m_wrapShapeOutside != other->rareNonInheritedData->m_wrapShapeOutside)
             return StyleDifferenceRepaint;
 
+        if (rareNonInheritedData->m_clipPath != other->rareNonInheritedData->m_clipPath)
+            return StyleDifferenceRepaint;
+
+
 #if USE(ACCELERATED_COMPOSITING)
     if (rareNonInheritedData.get() != other->rareNonInheritedData.get()) {
         if (rareNonInheritedData->m_transformStyle3D != other->rareNonInheritedData->m_transformStyle3D

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (127326 => 127327)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2012-08-31 22:17:03 UTC (rev 127326)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2012-08-31 22:29:48 UTC (rev 127327)
@@ -1464,6 +1464,15 @@
     static BasicShape* initialWrapShapeInside() { return 0; }
     static BasicShape* initialWrapShapeOutside() { return 0; }
 
+    void setClipPath(PassRefPtr<BasicShape> shape)
+    {
+        if (rareNonInheritedData->m_clipPath != shape)
+            rareNonInheritedData.access()->m_clipPath = shape;
+    }
+    BasicShape* clipPath() const { return rareNonInheritedData->m_clipPath.get(); }
+
+    static BasicShape* initialClipPath() { return 0; }
+
     Length wrapPadding() const { return rareNonInheritedData->m_wrapPadding; }
     void setWrapPadding(Length wrapPadding) { SET_VAR(rareNonInheritedData, m_wrapPadding, wrapPadding); }
     static Length initialWrapPadding() { return Length(0, Fixed); }

Modified: trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp (127326 => 127327)


--- trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp	2012-08-31 22:17:03 UTC (rev 127326)
+++ trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp	2012-08-31 22:29:48 UTC (rev 127327)
@@ -48,6 +48,7 @@
     , m_wrapShapeOutside(RenderStyle::initialWrapShapeOutside())
     , m_wrapMargin(RenderStyle::initialWrapMargin())
     , m_wrapPadding(RenderStyle::initialWrapPadding())
+    , m_clipPath(RenderStyle::initialClipPath())
     , m_visitedLinkBackgroundColor(RenderStyle::initialBackgroundColor())
     , m_order(RenderStyle::initialOrder())
     , m_flowThread(RenderStyle::initialFlowThread())
@@ -118,6 +119,7 @@
     , m_wrapShapeOutside(o.m_wrapShapeOutside)
     , m_wrapMargin(o.m_wrapMargin)
     , m_wrapPadding(o.m_wrapPadding)
+    , m_clipPath(o.m_clipPath)
     , m_visitedLinkBackgroundColor(o.m_visitedLinkBackgroundColor)
     , m_visitedLinkOutlineColor(o.m_visitedLinkOutlineColor)
     , m_visitedLinkBorderLeftColor(o.m_visitedLinkBorderLeftColor)
@@ -199,6 +201,7 @@
         && m_wrapShapeOutside == o.m_wrapShapeOutside
         && m_wrapMargin == o.m_wrapMargin
         && m_wrapPadding == o.m_wrapPadding
+        && m_clipPath == o.m_clipPath
         && m_visitedLinkBackgroundColor == o.m_visitedLinkBackgroundColor
         && m_visitedLinkOutlineColor == o.m_visitedLinkOutlineColor
         && m_visitedLinkBorderLeftColor == o.m_visitedLinkBorderLeftColor
@@ -323,6 +326,7 @@
     info.addMember(m_transitions);
     info.addMember(m_wrapShapeInside);
     info.addMember(m_wrapShapeOutside);
+    info.addMember(m_clipPath);
     info.addInstrumentedMember(m_flowThread);
     info.addInstrumentedMember(m_regionThread);
 }

Modified: trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h (127326 => 127327)


--- trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h	2012-08-31 22:17:03 UTC (rev 127326)
+++ trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h	2012-08-31 22:29:48 UTC (rev 127327)
@@ -138,7 +138,9 @@
     RefPtr<BasicShape> m_wrapShapeOutside;
     Length m_wrapMargin;
     Length m_wrapPadding;
-    
+
+    RefPtr<BasicShape> m_clipPath;
+
     Color m_visitedLinkBackgroundColor;
     Color m_visitedLinkOutlineColor;
     Color m_visitedLinkBorderLeftColor;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to