http://victordarras.fr/cssgame/ doesn't work in Safari.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Jan 2016 03:50:45 +0000 (03:50 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Jan 2016 03:50:45 +0000 (03:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=153285
<rdar://problem/24212369>

Reviewed by Tim Horton.

This patch adds support for hittesting ClipPathOperation::Reference.

Source/WebCore:

Tests: svg/clip-path/hittest-clip-path-reference-miss.html

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::nodeAtPoint):
* rendering/RenderObject.h:
(WebCore::RenderObject::isSVGResourceClipper):
* rendering/svg/RenderSVGResourceClipper.h:
(isType):

LayoutTests:

* svg/clip-path/hittest-clip-path-reference-miss-expected.html: Added.
* svg/clip-path/hittest-clip-path-reference-miss.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/svg/clip-path/hittest-clip-path-reference-miss-expected.html [new file with mode: 0644]
LayoutTests/svg/clip-path/hittest-clip-path-reference-miss.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderObject.h
Source/WebCore/rendering/svg/RenderSVGResourceClipper.h

index 8e03a15..d6d3d9f 100644 (file)
@@ -1,3 +1,16 @@
+2016-01-20  Zalan Bujtas  <zalan@apple.com>
+
+        http://victordarras.fr/cssgame/ doesn't work in Safari.
+        https://bugs.webkit.org/show_bug.cgi?id=153285
+        <rdar://problem/24212369>
+
+        Reviewed by Tim Horton.
+
+        This patch adds support for hittesting ClipPathOperation::Reference.
+
+        * svg/clip-path/hittest-clip-path-reference-miss-expected.html: Added.
+        * svg/clip-path/hittest-clip-path-reference-miss.html: Added.
+
 2016-01-20  Brady Eidson  <beidson@apple.com>
 
         Modern IDB: Add -private.html variants of every storage/indexeddb test that doesn't already have them.
diff --git a/LayoutTests/svg/clip-path/hittest-clip-path-reference-miss-expected.html b/LayoutTests/svg/clip-path/hittest-clip-path-reference-miss-expected.html
new file mode 100644 (file)
index 0000000..1ff9ca3
--- /dev/null
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that we properly hittest boxes with reference clip path.</title>
+<style>
+div {
+  position: absolute;
+  top: 0px;
+  left: 0px;
+  width: 200px;
+  height: 200px;
+  background: green;
+}
+</style>
+</head>
+<body>
+<div></div>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/svg/clip-path/hittest-clip-path-reference-miss.html b/LayoutTests/svg/clip-path/hittest-clip-path-reference-miss.html
new file mode 100644 (file)
index 0000000..179cfc4
--- /dev/null
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that we properly hittest boxes with reference clip path.</title>
+<style>
+svg { 
+  position: absolute;
+  top: -10000px;
+  left: -10000px;
+}
+
+div {
+  width: 200px;
+  height: 200px;
+  background: green;
+}
+
+.greenbox {
+  position: absolute;
+  left: 0px;
+  top: 0px;
+  z-index: -1;
+}
+
+.clipbox {
+  -webkit-clip-path: url('#svgreference');
+}
+
+.clipbox:hover ~ .greenbox
+{
+  background: blue;
+}
+</style>
+</head>
+<body>
+<svg width="200px" height="200px" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+  <clippath id=svgreference><path d="M50 50 L150 50 L150 150 L50 150 Z"></path></clippath>
+</svg>
+<div id=hittestthis class=clipbox></div>
+<div class=greenbox></div>
+<script>
+  if (window.eventSender)
+    eventSender.mouseMoveTo(10, 10);
+</script>
+</body>
+</html>
\ No newline at end of file
index 008e63e..03374a7 100644 (file)
@@ -1,3 +1,22 @@
+2016-01-20  Zalan Bujtas  <zalan@apple.com>
+
+        http://victordarras.fr/cssgame/ doesn't work in Safari.
+        https://bugs.webkit.org/show_bug.cgi?id=153285
+        <rdar://problem/24212369>
+
+        Reviewed by Tim Horton.
+
+        This patch adds support for hittesting ClipPathOperation::Reference.
+
+        Tests: svg/clip-path/hittest-clip-path-reference-miss.html
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::nodeAtPoint):
+        * rendering/RenderObject.h:
+        (WebCore::RenderObject::isSVGResourceClipper):
+        * rendering/svg/RenderSVGResourceClipper.h:
+        (isType):
+
 2016-01-20  David Kilzer  <ddkilzer@apple.com>
 
         ResourceHandleCFURLConnectionDelegateWithOperationQueue delegate methods don't NULL-check m_handle->client()
index b28a179..08da8d2 100644 (file)
@@ -59,6 +59,7 @@
 #include "RenderNamedFlowFragment.h"
 #include "RenderNamedFlowThread.h"
 #include "RenderRegion.h"
+#include "RenderSVGResourceClipper.h"
 #include "RenderTableCell.h"
 #include "RenderTextFragment.h"
 #include "RenderTheme.h"
@@ -2462,8 +2463,18 @@ bool RenderBlock::nodeAtPoint(const HitTestRequest& request, HitTestResult& resu
                 return false;
             break;
         }
-        // FIXME: handle Reference/Box
-        case ClipPathOperation::Reference:
+        case ClipPathOperation::Reference: {
+            const auto& referenceClipPathOperation = downcast<ReferenceClipPathOperation>(*style().clipPath());
+            auto* element = document().getElementById(referenceClipPathOperation.fragment());
+            if (!element || !element->renderer())
+                break;
+            if (!is<SVGClipPathElement>(*element))
+                break;
+            auto& clipper = downcast<RenderSVGResourceClipper>(*element->renderer());
+            if (!clipper.hitTestClipContent(FloatRect(borderBoxRect()), FloatPoint(locationInContainer.point() - localOffset)))
+                return false;
+            break;
+        }
         case ClipPathOperation::Box:
             break;
         }
index dfb1393..2bf3e8c 100644 (file)
@@ -419,6 +419,7 @@ public:
     virtual bool isSVGForeignObject() const { return false; }
     virtual bool isSVGResourceContainer() const { return false; }
     virtual bool isSVGResourceFilter() const { return false; }
+    virtual bool isSVGResourceClipper() const { return false; }
     virtual bool isSVGResourceFilterPrimitive() const { return false; }
 
     // FIXME: Those belong into a SVG specific base-class for all renderers (see above)
index b770496..2a6ff43 100644 (file)
@@ -63,6 +63,7 @@ private:
     void element() const = delete;
 
     virtual const char* renderName() const override { return "RenderSVGResourceClipper"; }
+    bool isSVGResourceClipper() const override { return true; }
 
     bool pathOnlyClipping(GraphicsContext&, const AffineTransform&, const FloatRect&);
     bool drawContentIntoMaskImage(const ClipperMaskImage&, const FloatRect& objectBoundingBox);
@@ -75,6 +76,9 @@ private:
 
 }
 
-SPECIALIZE_TYPE_TRAITS_RENDER_SVG_RESOURCE(RenderSVGResourceClipper, ClipperResourceType)
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::RenderSVGResourceClipper)
+static bool isType(const WebCore::RenderObject& renderer) { return renderer.isSVGResourceClipper(); }
+static bool isType(const WebCore::RenderSVGResource& resource) { return resource.resourceType() == WebCore::ClipperResourceType; }
+SPECIALIZE_TYPE_TRAITS_END()
 
 #endif