Diff
Modified: trunk/LayoutTests/ChangeLog (130591 => 130592)
--- trunk/LayoutTests/ChangeLog 2012-10-07 00:02:44 UTC (rev 130591)
+++ trunk/LayoutTests/ChangeLog 2012-10-07 01:35:26 UTC (rev 130592)
@@ -1,3 +1,20 @@
+2012-10-06 Raul Hudea <[email protected]>
+
+ -webkit-clip-path should parse IRIs
+ https://bugs.webkit.org/show_bug.cgi?id=96381
+
+ Reviewed by Andreas Kling.
+
+ Tests for SVG referenced clipPath with both types of clipPathUnits: "userSpaceOnUse" and "objectBoundingBox".
+
+ * css3/masking/clip-path-reference-expected.html: Added.
+ * css3/masking/clip-path-reference-userSpaceOnUse-expected.html: Added.
+ * css3/masking/clip-path-reference-userSpaceOnUse.html: Added.
+ * css3/masking/clip-path-reference.html: Added.
+ * fast/masking/parsing-clip-path-iri-expected.txt: Added.
+ * fast/masking/parsing-clip-path-iri.html: Added.
+ * platform/chromium/TestExpectations:
+
2012-10-06 Raphael Kubo da Costa <[email protected]>
[EFL] Mark media/audio-garbage-collect.html as flaky on WK2.
Added: trunk/LayoutTests/css3/masking/clip-path-reference-expected.html (0 => 130592)
--- trunk/LayoutTests/css3/masking/clip-path-reference-expected.html (rev 0)
+++ trunk/LayoutTests/css3/masking/clip-path-reference-expected.html 2012-10-07 01:35:26 UTC (rev 130592)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<style>
+#d {
+ width: 180px;
+ height: 180px;
+ border: 1px solid black;
+}
+#clip {
+ width: 32px;
+ height: 32px;
+ margin: 74px;
+ background-color: green;
+}
+</style>
+</head>
+<body>
+<svg height="0"></svg>
+<div id="d"><div id="clip"></div></div>
+</body>
+</html>
\ No newline at end of file
Added: trunk/LayoutTests/css3/masking/clip-path-reference-userSpaceOnUse-expected.html (0 => 130592)
--- trunk/LayoutTests/css3/masking/clip-path-reference-userSpaceOnUse-expected.html (rev 0)
+++ trunk/LayoutTests/css3/masking/clip-path-reference-userSpaceOnUse-expected.html 2012-10-07 01:35:26 UTC (rev 130592)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<style>
+* {padding: 0; margin: 0}
+#d {
+ width: 180px;
+ height: 180px;
+ border: 1px solid black;
+ background-color: red;
+ margin-top: 104px;
+}
+#clip-ref {
+ width: 32px;
+ height: 32px;
+ margin: 74px;
+ background-color: green;
+}
+</style>
+</head>
+<body>
+<div id="d"><div id="clip-ref"></div></div>
+</body>
+</html>
\ No newline at end of file
Added: trunk/LayoutTests/css3/masking/clip-path-reference-userSpaceOnUse.html (0 => 130592)
--- trunk/LayoutTests/css3/masking/clip-path-reference-userSpaceOnUse.html (rev 0)
+++ trunk/LayoutTests/css3/masking/clip-path-reference-userSpaceOnUse.html 2012-10-07 01:35:26 UTC (rev 130592)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<style>
+* {padding: 0; margin: 0}
+#d {
+ width: 180px;
+ height: 180px;
+ border: 1px solid black;
+ background-color: red;
+}
+#clip {
+ width: 160px;
+ height: 160px;
+ margin: 10px;
+ background-color: green;
+ -webkit-clip-path: url(#c2);
+}
+#clip-ref {
+ width: 32px;
+ height: 32px;
+ margin: 74px;
+ background-color: green;
+}
+</style>
+</head>
+<body>
+<svg height="100" width="100">
+<clipPath id="c2" clipPathUnits="userSpaceOnUse">
+ <rect x="75" y="179" width="32" height="32"/>
+</clipPath>
+</svg>
+<div id="d"><div id="clip"></div></div>
+</body>
+</html>
\ No newline at end of file
Added: trunk/LayoutTests/css3/masking/clip-path-reference.html (0 => 130592)
--- trunk/LayoutTests/css3/masking/clip-path-reference.html (rev 0)
+++ trunk/LayoutTests/css3/masking/clip-path-reference.html 2012-10-07 01:35:26 UTC (rev 130592)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<style>
+#d {
+ width: 180px;
+ height: 180px;
+ border: 1px solid black;
+}
+#clip {
+ width: 160px;
+ height: 160px;
+ margin: 10px;
+ background-color: green;
+ -webkit-clip-path: url(#c1);
+}
+</style>
+</head>
+<body>
+<svg height="0">
+ <clipPath id="c1" clipPathUnits="objectBoundingBox">
+ <rect x="0.4" y="0.4" width="0.2" height="0.2"/>
+ </clipPath>
+ </svg>
+<div id="d"><div id="clip"></div></div>
+</body>
+</html>
\ No newline at end of file
Added: trunk/LayoutTests/css3/masking/resources/clip.svg (0 => 130592)
--- trunk/LayoutTests/css3/masking/resources/clip.svg (rev 0)
+++ trunk/LayoutTests/css3/masking/resources/clip.svg 2012-10-07 01:35:26 UTC (rev 130592)
@@ -0,0 +1,5 @@
+<svg height="0">
+ <clipPath id="clip1" clipPathUnits="objectBoundingBox">
+ <circle cx="0.25" cy="0.25" r="0.25" id="circle"/>
+ </clipPath>
+</svg>
\ No newline at end of file
Added: trunk/LayoutTests/fast/masking/parsing-clip-path-iri-expected.txt (0 => 130592)
--- trunk/LayoutTests/fast/masking/parsing-clip-path-iri-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/masking/parsing-clip-path-iri-expected.txt 2012-10-07 01:35:26 UTC (rev 130592)
@@ -0,0 +1,13 @@
+Test clip-path IRIs
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS innerStyle("-webkit-clip-path", "url(#clip1)") is "url(#clip1)"
+PASS innerStyle("-webkit-clip-path", "url(clip.svg#clip1)") is "url(clip.svg#clip1)"
+PASS computedStyle("-webkit-clip-path", "url(#clip1)") is "url(#clip1)"
+PASS computedStyle("-webkit-clip-path", "url(clip.svg#clip1)") is "url(clip.svg#clip1)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/masking/parsing-clip-path-iri.html (0 => 130592)
--- trunk/LayoutTests/fast/masking/parsing-clip-path-iri.html (rev 0)
+++ trunk/LayoutTests/fast/masking/parsing-clip-path-iri.html 2012-10-07 01:35:26 UTC (rev 130592)
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<style>
+* { font-size: 16px; }
+div { font-size: 8px; }
+</style>
+<body>
+<script src=""
+<script>
+description('Test clip-path IRIs');
+
+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);
+}
+
+testInner("-webkit-clip-path", "url(#clip1)", "url(#clip1)");
+testInner("-webkit-clip-path", "url(clip.svg#clip1)", "url(clip.svg#clip1)");
+
+testComputed("-webkit-clip-path", "url(#clip1)", "url(#clip1)");
+testComputed("-webkit-clip-path", "url(clip.svg#clip1)", "url(clip.svg#clip1)");
+
+</script>
+<script src=""
+</body>
+</html>
\ No newline at end of file
Modified: trunk/LayoutTests/platform/chromium/TestExpectations (130591 => 130592)
--- trunk/LayoutTests/platform/chromium/TestExpectations 2012-10-07 00:02:44 UTC (rev 130591)
+++ trunk/LayoutTests/platform/chromium/TestExpectations 2012-10-07 01:35:26 UTC (rev 130592)
@@ -1444,6 +1444,8 @@
# Windows?
crbug.com/10342 [ Android Linux Mac ] fast/loader/file-URL-with-port-number.html [ WontFix ]
+# Clipping differences between Chromium platforms. Needs investigation.
+webkit.org/b/98599 css3/masking/clip-path-reference-userSpaceOnUse.html [ ImageOnlyFailure ]
# Started timing out with agl's complex text change. Page is verrry slow.
crbug.com/10343 [ Android Linux ] fast/text/large-text-composed-char.html
Modified: trunk/Source/WebCore/ChangeLog (130591 => 130592)
--- trunk/Source/WebCore/ChangeLog 2012-10-07 00:02:44 UTC (rev 130591)
+++ trunk/Source/WebCore/ChangeLog 2012-10-07 01:35:26 UTC (rev 130592)
@@ -1,3 +1,36 @@
+2012-10-06 Raul Hudea <[email protected]>
+
+ -webkit-clip-path should parse IRIs
+ https://bugs.webkit.org/show_bug.cgi?id=96381
+
+ Reviewed by Andreas Kling.
+
+ Implemented the clipping via referencing a SVG clipPath. Currently it works only if the clipPath is defined
+ before using it on an HTML element. The forward reference issue is tracked via https://bugs.webkit.org/show_bug.cgi?id=90405.
+
+ Tests: css3/masking/clip-path-reference-userSpaceOnUse.html
+ css3/masking/clip-path-reference.html
+ fast/masking/parsing-clip-path-iri.html
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Add handling for SVG clipPath references.
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::parseValue): Add handling for SVG clipPath references.
+ * css/StyleBuilder.cpp:
+ (WebCore::ApplyPropertyClipPath::applyValue): Add handling for SVG references.
+ * rendering/ClipPathOperation.h:
+ (ReferenceClipPathOperation): Added a new class corresponding to SVG referenced clipPath.
+ (WebCore::ReferenceClipPathOperation::create):
+ (WebCore::ReferenceClipPathOperation::url):
+ (WebCore::ReferenceClipPathOperation::fragment):
+ (WebCore::ReferenceClipPathOperation::operator==):
+ (WebCore::ReferenceClipPathOperation::ReferenceClipPathOperation):
+ (WebCore):
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::paintLayerContents): Add handling for ReferenceClipPathOperation.
+ * rendering/svg/RenderSVGResourceClipper.h:
+ (RenderSVGResourceClipper): Made applyClippingToContext public as it needs to be called directly for HTML elements.
+
2012-10-06 Pratik Solanki <[email protected]>
Reduce calls to CGImageSourceCopyPropertiesAtIndex from frameSizeAtIndex
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (130591 => 130592)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2012-10-07 00:02:44 UTC (rev 130591)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2012-10-07 01:35:26 UTC (rev 130592)
@@ -2468,6 +2468,12 @@
if (ClipPathOperation* operation = style->clipPath()) {
if (operation->getOperationType() == ClipPathOperation::SHAPE)
return valueForBasicShape(static_cast<ShapeClipPathOperation*>(operation)->basicShape());
+#if ENABLE(SVG)
+ else if (operation->getOperationType() == ClipPathOperation::REFERENCE) {
+ ReferenceClipPathOperation* referenceOperation = static_cast<ReferenceClipPathOperation*>(operation);
+ return CSSPrimitiveValue::create(referenceOperation->url(), CSSPrimitiveValue::CSS_URI);
+ }
+#endif
}
return cssValuePool().createIdentifierValue(CSSValueNone);
#if ENABLE(CSS_REGIONS)
Modified: trunk/Source/WebCore/css/CSSParser.cpp (130591 => 130592)
--- trunk/Source/WebCore/css/CSSParser.cpp 2012-10-07 00:02:44 UTC (rev 130591)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2012-10-07 01:35:26 UTC (rev 130592)
@@ -2765,6 +2765,13 @@
validPrimitive = true;
else if (value->unit == CSSParserValue::Function)
return parseBasicShape(propId, important);
+#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
break;
#if ENABLE(CSS_EXCLUSIONS)
case CSSPropertyWebkitShapeInside:
Modified: trunk/Source/WebCore/css/StyleBuilder.cpp (130591 => 130592)
--- trunk/Source/WebCore/css/StyleBuilder.cpp 2012-10-07 00:02:44 UTC (rev 130591)
+++ trunk/Source/WebCore/css/StyleBuilder.cpp 2012-10-07 01:35:26 UTC (rev 130592)
@@ -1698,6 +1698,14 @@
else if (primitiveValue->isShape()) {
setValue(styleResolver->style(), ShapeClipPathOperation::create(basicShapeForValue(styleResolver, primitiveValue->getShapeValue())));
}
+#if ENABLE(SVG)
+ else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_URI) {
+ String cssURLValue = primitiveValue->getStringValue();
+ KURL url = ""
+ // FIXME: It doesn't work with forward or external SVG references (see https://bugs.webkit.org/show_bug.cgi?id=90405)
+ setValue(styleResolver->style(), ReferenceClipPathOperation::create(cssURLValue, url.fragmentIdentifier()));
+ }
+#endif
}
}
static PropertyHandler createHandler()
Modified: trunk/Source/WebCore/rendering/ClipPathOperation.h (130591 => 130592)
--- trunk/Source/WebCore/rendering/ClipPathOperation.h 2012-10-07 00:02:44 UTC (rev 130591)
+++ trunk/Source/WebCore/rendering/ClipPathOperation.h 2012-10-07 01:35:26 UTC (rev 130592)
@@ -42,7 +42,7 @@
class ClipPathOperation : public RefCounted<ClipPathOperation> {
public:
enum OperationType {
- // FIXME: Add referencing for IRI https://bugs.webkit.org/show_bug.cgi?id=96381
+ REFERENCE,
SHAPE
};
@@ -63,6 +63,36 @@
OperationType m_type;
};
+class ReferenceClipPathOperation : public ClipPathOperation {
+public:
+ static PassRefPtr<ReferenceClipPathOperation> create(const String& url, const String& fragment)
+ {
+ return adoptRef(new ReferenceClipPathOperation(url, fragment));
+ }
+
+ const String& url() const { return m_url; }
+ const String& fragment() const { return m_fragment; }
+
+private:
+ virtual bool operator==(const ClipPathOperation& o) const
+ {
+ if (!isSameType(o))
+ return false;
+ const ReferenceClipPathOperation* other = static_cast<const ReferenceClipPathOperation*>(&o);
+ return m_url == other->m_url;
+ }
+
+ ReferenceClipPathOperation(const String& url, const String& fragment)
+ : ClipPathOperation(REFERENCE)
+ , m_url(url)
+ , m_fragment(fragment)
+ {
+ }
+
+ String m_url;
+ String m_fragment;
+};
+
class ShapeClipPathOperation : public ClipPathOperation {
public:
static PassRefPtr<ShapeClipPathOperation> create(PassRefPtr<BasicShape> shape)
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (130591 => 130592)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2012-10-07 00:02:44 UTC (rev 130591)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2012-10-07 01:35:26 UTC (rev 130592)
@@ -80,6 +80,7 @@
#include "RenderInline.h"
#include "RenderMarquee.h"
#include "RenderReplica.h"
+#include "RenderSVGResourceClipper.h"
#include "RenderScrollbar.h"
#include "RenderScrollbarPart.h"
#include "RenderTheme.h"
@@ -3139,6 +3140,16 @@
ShapeClipPathOperation* clipPath = static_cast<ShapeClipPathOperation*>(style->clipPath());
context->clipPath(clipPath->path(calculateLayerBounds(this, rootLayer, 0)), clipPath->windRule());
}
+#if ENABLE(SVG)
+ else if (style->clipPath()->getOperationType() == ClipPathOperation::REFERENCE) {
+ ReferenceClipPathOperation* referenceClipPathOperation = static_cast<ReferenceClipPathOperation*>(style->clipPath());
+ Document* document = renderer()->document();
+ // FIXME: It doesn't work with forward or external SVG references (https://bugs.webkit.org/show_bug.cgi?id=90405)
+ Element* clipPath = document ? document->getElementById(referenceClipPathOperation->fragment()) : 0;
+ if (clipPath && clipPath->renderer() && clipPath->renderer()->isSVGResourceContainer())
+ static_cast<RenderSVGResourceClipper*>(clipPath->renderer())->applyClippingToContext(renderer(), calculateLayerBounds(this, rootLayer, 0), paintDirtyRect, context);
+ }
+#endif
}
#if ENABLE(CSS_FILTERS)
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.h (130591 => 130592)
--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.h 2012-10-07 00:02:44 UTC (rev 130591)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.h 2012-10-07 01:35:26 UTC (rev 130592)
@@ -52,6 +52,10 @@
virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true);
virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode);
+ // clipPath can be clipped too, but don't have a boundingBox or repaintRect. So we can't call
+ // applyResource directly and use the rects from the object, since they are empty for RenderSVGResources
+ // FIXME: We made applyClippingToContext public because we cannot call applyResource on HTML elements (it asserts on RenderObject::objectBoundingBox)
+ bool applyClippingToContext(RenderObject*, const FloatRect&, const FloatRect&, GraphicsContext*);
virtual FloatRect resourceBoundingBox(RenderObject*);
virtual RenderSVGResourceType resourceType() const { return ClipperResourceType; }
@@ -62,9 +66,6 @@
static RenderSVGResourceType s_resourceType;
private:
- // clipPath can be clipped too, but don't have a boundingBox or repaintRect. So we can't call
- // applyResource directly and use the rects from the object, since they are empty for RenderSVGResources
- bool applyClippingToContext(RenderObject*, const FloatRect&, const FloatRect&, GraphicsContext*);
bool pathOnlyClipping(GraphicsContext*, const AffineTransform&, const FloatRect&);
bool drawContentIntoMaskImage(ClipperData*, const FloatRect& objectBoundingBox);
void calculateClipContentRepaintRect();