Diff
Modified: trunk/LayoutTests/ChangeLog (161066 => 161067)
--- trunk/LayoutTests/ChangeLog 2013-12-25 18:58:00 UTC (rev 161066)
+++ trunk/LayoutTests/ChangeLog 2013-12-25 19:03:50 UTC (rev 161067)
@@ -1,3 +1,16 @@
+2013-12-25 Dirk Schulze <[email protected]>
+
+ Support <box> values parsing on 'clip-path' property
+ https://bugs.webkit.org/show_bug.cgi?id=126147
+
+ Reviewed by Ryosuke Niwa.
+
+ Add test to check different combinations of the reference boxes
+ content-box, padding-box, border-box, margin-box and bounding-box
+ with other clip-path values.
+
+ * fast/masking/parsing-clip-path-shape.html:
+
2013-12-24 Ryosuke Niwa <[email protected]>
Remove the test expectations added after r161051 now that the changeset has been rolled out.
Modified: trunk/LayoutTests/fast/masking/parsing-clip-path-shape-expected.txt (161066 => 161067)
--- trunk/LayoutTests/fast/masking/parsing-clip-path-shape-expected.txt 2013-12-25 18:58:00 UTC (rev 161066)
+++ trunk/LayoutTests/fast/masking/parsing-clip-path-shape-expected.txt 2013-12-25 19:03:50 UTC (rev 161067)
@@ -48,6 +48,16 @@
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", "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", "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(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
@@ -80,6 +90,20 @@
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", "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", "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
+PASS computedStyle("-webkit-clip-path", "none content-box") is "none"
+PASS innerStyle("-webkit-clip-path", "url(#test) padding-box") is null
+PASS computedStyle("-webkit-clip-path", "url(#test) padding-box") 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", "polygon(0, 0)") is null
Modified: trunk/LayoutTests/fast/masking/parsing-clip-path-shape.html (161066 => 161067)
--- trunk/LayoutTests/fast/masking/parsing-clip-path-shape.html 2013-12-25 18:58:00 UTC (rev 161066)
+++ trunk/LayoutTests/fast/masking/parsing-clip-path-shape.html 2013-12-25 19:03:50 UTC (rev 161067)
@@ -106,6 +106,18 @@
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%)");
+// boxes
+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", "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");
+
// reject non-lengths
negativeTest("-webkit-clip-path", "circle(1px, 1px, 1)");
negativeTest("-webkit-clip-path", "circle(1px, 1px, px)");
@@ -129,6 +141,15 @@
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", "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", "content-box margin-box padding-box");
+negativeTest("-webkit-clip-path", "none content-box");
+negativeTest("-webkit-clip-path", "url(#test) padding-box");
+
// general negative tests
negativeTest("-webkit-clip-path", "circle(0, 0)");
negativeTest("-webkit-clip-path", "polygon(0, 0)");
Modified: trunk/Source/WebCore/ChangeLog (161066 => 161067)
--- trunk/Source/WebCore/ChangeLog 2013-12-25 18:58:00 UTC (rev 161066)
+++ trunk/Source/WebCore/ChangeLog 2013-12-25 19:03:50 UTC (rev 161067)
@@ -1,3 +1,27 @@
+2013-12-25 Dirk Schulze <[email protected]>
+
+ Support <box> values parsing on 'clip-path' property
+ https://bugs.webkit.org/show_bug.cgi?id=126147
+
+ Reviewed by Ryosuke Niwa.
+
+ Support parsing of the background reference boxes, margin-box and bounding-box.
+ A box will be a reference box and define the origin for a basic shape.
+ If no basic shape is specified, the box defines the clipping path itself.
+ The specification text follows the changes to CSS Shapes now.
+
+ https://dvcs.w3.org/hg/FXTF/raw-file/3f213145303e/css-masking-1/index.html#the-clip-path
+
+ Existing parsing test have been extended to test box values as well.
+
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::parseValue):
+ (WebCore::CSSParser::parseClipPath):
+ * css/CSSParser.h:
+ * css/CSSValueKeywords.in:
+ * css/DeprecatedStyleBuilder.cpp:
+ (WebCore::ApplyPropertyClipPath::applyValue):
+
2013-12-25 David Kilzer <[email protected]>
[iOS] Upstream WebCore/pdf changes
Modified: trunk/Source/WebCore/css/CSSParser.cpp (161066 => 161067)
--- trunk/Source/WebCore/css/CSSParser.cpp 2013-12-25 18:58:00 UTC (rev 161066)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2013-12-25 19:03:50 UTC (rev 161067)
@@ -2919,20 +2919,7 @@
return parseFontVariantLigatures(important);
break;
case CSSPropertyWebkitClipPath:
- if (id == CSSValueNone)
- validPrimitive = true;
- else if (value->unit == CSSParserValue::Function) {
- RefPtr<CSSBasicShape> shapeValue = parseBasicShape();
- if (shapeValue)
- parsedValue = cssValuePool().createValue(shapeValue.release());
- }
-#if ENABLE(SVG)
- else if (value->unit == CSSPrimitiveValue::CSS_URI) {
- parsedValue = CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::CSS_URI);
- addProperty(propId, parsedValue.release(), important);
- return true;
- }
-#endif
+ parsedValue = parseClipPath();
break;
#if ENABLE(CSS_SHAPES)
case CSSPropertyWebkitShapeInside:
@@ -5897,6 +5884,49 @@
}
#endif
+PassRefPtr<CSSValue> CSSParser::parseClipPath()
+{
+ CSSParserValue* value = m_valueList->current();
+ CSSValueID valueId = value->id;
+
+ if (valueId == CSSValueNone) {
+ m_valueList->next();
+ return parseValidPrimitive(valueId, value);
+ }
+#if ENABLE(SVG)
+ if (value->unit == CSSPrimitiveValue::CSS_URI) {
+ m_valueList->next();
+ return CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::CSS_URI);
+ }
+#endif
+
+ bool shapeFound = false;
+ bool boxFound = false;
+ RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
+ for (unsigned i = 0; i < 2; ++i) {
+ if (!value)
+ break;
+ valueId = value->id;
+ if (value->unit == CSSParserValue::Function && !shapeFound) {
+ // parseBasicShape already asks for the next value list item.
+ RefPtr<CSSBasicShape> shapeValue = parseBasicShape();
+ if (!shapeValue)
+ return nullptr;
+ list->append(cssValuePool().createValue(shapeValue.release()));
+ shapeFound = true;
+ } else if ((isBoxValue(valueId) || valueId == CSSValueBoundingBox) && !boxFound) {
+ list->append(parseValidPrimitive(valueId, value));
+ boxFound = true;
+ m_valueList->next();
+ } else
+ return nullptr;
+ value = m_valueList->current();
+ }
+ if (value)
+ return nullptr;
+ return list.release();
+}
+
// FIXME This function is temporary to allow for an orderly transition between
// the new CSS Shapes circle and ellipse syntax. It will be removed when the
// old syntax is removed.
Modified: trunk/Source/WebCore/css/CSSParser.h (161066 => 161067)
--- trunk/Source/WebCore/css/CSSParser.h 2013-12-25 18:58:00 UTC (rev 161066)
+++ trunk/Source/WebCore/css/CSSParser.h 2013-12-25 19:03:50 UTC (rev 161067)
@@ -277,6 +277,8 @@
#endif
#endif
+ PassRefPtr<CSSValue> parseClipPath();
+
static bool isBlendMode(CSSValueID);
static bool isCompositeOperator(CSSValueID);
Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (161066 => 161067)
--- trunk/Source/WebCore/css/CSSValueKeywords.in 2013-12-25 18:58:00 UTC (rev 161066)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in 2013-12-25 19:03:50 UTC (rev 161067)
@@ -730,6 +730,9 @@
// CSS_SHAPES
margin-box
+// clip-path
+bounding-box
+
//
// background-size
//
Modified: trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp (161066 => 161067)
--- trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp 2013-12-25 18:58:00 UTC (rev 161066)
+++ trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp 2013-12-25 19:03:50 UTC (rev 161067)
@@ -2047,21 +2047,31 @@
static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
{
if (value->isPrimitiveValue()) {
- CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
- if (primitiveValue->getValueID() == CSSValueNone)
+ auto& primitiveValue = toCSSPrimitiveValue(*value);
+ if (primitiveValue.getValueID() == CSSValueNone)
setValue(styleResolver->style(), 0);
- else if (primitiveValue->isShape()) {
- setValue(styleResolver->style(), ShapeClipPathOperation::create(basicShapeForValue(styleResolver->style(), styleResolver->rootElementStyle(), primitiveValue->getShapeValue())));
- }
#if ENABLE(SVG)
- else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_URI) {
- String cssURLValue = primitiveValue->getStringValue();
+ else if (primitiveValue.primitiveType() == CSSPrimitiveValue::CSS_URI) {
+ String cssURLValue = primitiveValue.getStringValue();
URL url = ""
- // FIXME: It doesn't work with forward or external SVG references (see https://bugs.webkit.org/show_bug.cgi?id=90405)
+ // FIXME: It doesn't work with external SVG references (see https://bugs.webkit.org/show_bug.cgi?id=126133)
setValue(styleResolver->style(), ReferenceClipPathOperation::create(cssURLValue, url.fragmentIdentifier()));
}
#endif
+ return;
}
+ if (!value->isValueList())
+ return;
+ auto& valueList = toCSSValueList(*value);
+ for (unsigned i = 0; i < valueList.length(); ++i) {
+ // FIXME: <box> values are not supported yet.
+ // https://bugs.webkit.org/show_bug.cgi?id=126148
+ auto& primitiveValue = toCSSPrimitiveValue(*valueList.itemWithoutBoundsCheck(i));
+ if (!primitiveValue.isShape())
+ continue;
+ setValue(styleResolver->style(), ShapeClipPathOperation::create(basicShapeForValue(styleResolver->style(), styleResolver->rootElementStyle(), primitiveValue.getShapeValue())));
+ break;
+ }
}
static PropertyHandler createHandler()
{