[Cherry-pick] Introduce new CSS property for clip-path
authorkrit@webkit.org <krit@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 31 Aug 2012 22:29:48 +0000 (22:29 +0000)
committerGerrit Code Review <gerrit2@kim11>
Wed, 27 Mar 2013 06:14:12 +0000 (15:14 +0900)
[Title] Introduce new CSS property for clip-path
[Issues] N/A
[Problem] N/A
[Solution] Cherry picked.
[Cherry-Picker] Sanghyup Lee <sh53.lee@samsung.com>

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.

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

Conflicts:

LayoutTests/ChangeLog
Source/WebCore/ChangeLog
Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp

Change-Id: I3c619eabf8c1b4e3243dd1b003d50fe0f7cff1ed

12 files changed:
LayoutTests/fast/masking/parsing-clip-path-shape-expected.txt [new file with mode: 0644]
LayoutTests/fast/masking/parsing-clip-path-shape.html [new file with mode: 0644]
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSParser.h
Source/WebCore/css/CSSProperty.cpp
Source/WebCore/css/CSSPropertyNames.in
Source/WebCore/css/StyleBuilder.cpp
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp
Source/WebCore/rendering/style/StyleRareNonInheritedData.h

diff --git a/LayoutTests/fast/masking/parsing-clip-path-shape-expected.txt b/LayoutTests/fast/masking/parsing-clip-path-shape-expected.txt
new file mode 100644 (file)
index 0000000..215fabd
--- /dev/null
@@ -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
+
diff --git a/LayoutTests/fast/masking/parsing-clip-path-shape.html b/LayoutTests/fast/masking/parsing-clip-path-shape.html
new file mode 100644 (file)
index 0000000..0b01421
--- /dev/null
@@ -0,0 +1,114 @@
+<!DOCTYPE html>
+<html>
+<style>
+* { font-size: 16px; }
+div { font-size: 8px; }
+</style>
+<body>
+<script src="../js/resources/js-test-pre.js"></script>
+<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="../js/resources/js-test-post.js"></script>
+</body>
+</html>
index 93713fa..4764746 100644 (file)
 #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"
 #include "WebKitCSSTransformValue.h"
 #include "WebKitFontFamilyNames.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"
@@ -227,6 +224,7 @@ static const CSSPropertyID computedProperties[] = {
     CSSPropertyWebkitBoxPack,
     CSSPropertyWebkitBoxReflect,
     CSSPropertyWebkitBoxShadow,
+    CSSPropertyWebkitClipPath,
     CSSPropertyWebkitColorCorrection,
     CSSPropertyWebkitColumnBreakAfter,
     CSSPropertyWebkitColumnBreakBefore,
@@ -2372,6 +2370,10 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
             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())
index 2e043fc..65c8381 100644 (file)
@@ -2691,6 +2691,12 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
         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:
@@ -2699,7 +2705,7 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
         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:
@@ -4478,8 +4484,6 @@ bool CSSParser::parseClipShape(CSSPropertyID propId, bool important)
     return false;
 }
 
-#if ENABLE(CSS_EXCLUSIONS)
-
 PassRefPtr<CSSBasicShape> CSSParser::parseBasicShapeRectangle(CSSParserValueList* args)
 {
     ASSERT(args);
@@ -4690,16 +4694,16 @@ PassRefPtr<CSSBasicShape> CSSParser::parseBasicShapePolygon(CSSParserValueList*
     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("))
@@ -4709,17 +4713,14 @@ bool CSSParser::parseBasicShape(bool shapeInside, bool important)
     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)
 {
index 86503da..30f538c 100644 (file)
@@ -142,7 +142,7 @@ public:
 
     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);
index 326af52..a9016d1 100644 (file)
@@ -552,6 +552,7 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID)
     case CSSPropertyWebkitBoxPack:
     case CSSPropertyWebkitBoxReflect:
     case CSSPropertyWebkitBoxShadow:
+    case CSSPropertyWebkitClipPath:
     case CSSPropertyWebkitColumnAxis:
     case CSSPropertyWebkitColumnBreakAfter:
     case CSSPropertyWebkitColumnBreakBefore:
index ce13293..612c3cc 100644 (file)
@@ -95,6 +95,7 @@ caption-side
 -epub-caption-side = caption-side
 clear
 clip
+-webkit-clip-path
 content
 counter-increment
 counter-reset
index 05b2845..9d3518a 100644 (file)
 #include "config.h"
 #include "StyleBuilder.h"
 
+#include "BasicShapeFunctions.h"
+#include "BasicShapes.h"
 #include "CSSAspectRatioValue.h"
+#include "CSSBasicShapes.h"
 #include "CSSCalculationValue.h"
 #include "CSSCursorImageValue.h"
 #include "CSSPrimitiveValueMappings.h"
 #include <wtf/StdLibExtras.h>
 #include <wtf/UnusedParam.h>
 
-#if ENABLE(CSS_EXCLUSIONS)
-#include "BasicShapeFunctions.h"
-#include "BasicShapes.h"
-#include "CSSBasicShapes.h"
-#endif
-
 using namespace std;
 
 namespace WebCore {
@@ -1735,6 +1732,29 @@ public:
     }
 };
 
+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 {
@@ -2076,6 +2096,8 @@ StyleBuilder::StyleBuilder()
     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());
index 0784339..fb4290a 100644 (file)
@@ -667,6 +667,10 @@ StyleDifference RenderStyle::diff(const RenderStyle* other, unsigned& changedCon
             || 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
index 0726336..48686a9 100644 (file)
@@ -1451,6 +1451,15 @@ public:
     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); }
index 22b3272..576a48e 100644 (file)
@@ -49,6 +49,7 @@ StyleRareNonInheritedData::StyleRareNonInheritedData()
     , 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())
@@ -115,6 +116,7 @@ StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInherited
     , 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)
@@ -192,6 +194,7 @@ bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) c
         && 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
index 36f0d64..ca8131c 100644 (file)
@@ -138,7 +138,9 @@ public:
     RefPtr<BasicShape> m_wrapShapeOutside;
     Length m_wrapMargin;
     Length m_wrapPadding;
-    
+
+    RefPtr<BasicShape> m_clipPath;
+
     Color m_visitedLinkBackgroundColor;
     Color m_visitedLinkOutlineColor;
     Color m_visitedLinkBorderLeftColor;