Title: [119733] trunk
Revision
119733
Author
commit-qu...@webkit.org
Date
2012-06-07 10:02:19 -0700 (Thu, 07 Jun 2012)

Log Message

Incorrect rect-based hit-test result for culled-inline elements
https://bugs.webkit.org/show_bug.cgi?id=85849

Patch by Raymes Khoury <ray...@chromium.org> on 2012-06-07
Reviewed by Levi Weintraub.

Source/WebCore:

Modified code which blindly adds culled inlines to rect-based hit-test
results so that it only does so if the child node does not fully cover
the hit-test region.

Test: fast/dom/nodesFromRect-culled-inline.html

* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::addNodeToRectBasedTestResult):

LayoutTests:

Added tests for rect-based hit-testing for the case when the child of a
culled inline element is in the hit-test result. One of these tests is
expected to fail due to https://bugs.webkit.org/show_bug.cgi?id=88376.

* fast/dom/nodesFromRect-culled-inline-expected.txt: Added.
* fast/dom/nodesFromRect-culled-inline.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (119732 => 119733)


--- trunk/LayoutTests/ChangeLog	2012-06-07 16:58:43 UTC (rev 119732)
+++ trunk/LayoutTests/ChangeLog	2012-06-07 17:02:19 UTC (rev 119733)
@@ -1,3 +1,17 @@
+2012-06-07  Raymes Khoury  <ray...@chromium.org>
+
+        Incorrect rect-based hit-test result for culled-inline elements
+        https://bugs.webkit.org/show_bug.cgi?id=85849
+
+        Reviewed by Levi Weintraub.
+
+        Added tests for rect-based hit-testing for the case when the child of a
+        culled inline element is in the hit-test result. One of these tests is
+        expected to fail due to https://bugs.webkit.org/show_bug.cgi?id=88376.
+
+        * fast/dom/nodesFromRect-culled-inline-expected.txt: Added.
+        * fast/dom/nodesFromRect-culled-inline.html: Added.
+
 2012-06-07  Daniel Erat  <de...@chromium.org>
 
         [chromium] Add test for subpixel positioning.

Added: trunk/LayoutTests/fast/dom/nodesFromRect-culled-inlines-expected.txt (0 => 119733)


--- trunk/LayoutTests/fast/dom/nodesFromRect-culled-inlines-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/nodesFromRect-culled-inlines-expected.txt	2012-06-07 17:02:19 UTC (rev 119733)
@@ -0,0 +1,10 @@
+  PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS All correct nodes found for rect
+PASS All correct nodes found for rect
+PASS All correct nodes found for rect
+PASS All correct nodes found for rect
+FAIL Different number of nodes for rect[0,98], [0,1,2,0]: '2' vs '3'
+PASS All correct nodes found for rect
+

Added: trunk/LayoutTests/fast/dom/nodesFromRect-culled-inlines.html (0 => 119733)


--- trunk/LayoutTests/fast/dom/nodesFromRect-culled-inlines.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/nodesFromRect-culled-inlines.html	2012-06-07 17:02:19 UTC (rev 119733)
@@ -0,0 +1,56 @@
+<html>
+<head>
+  <title>Document::nodesFromRect test - bug 85849</title>
+  <script src=""
+  <script src=""
+  <script type="application/_javascript_">
+    function runTest()
+    {
+      if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+      }
+
+      var e = {};
+
+      // Set up shortcut access to elements
+      e['html'] = document.getElementsByTagName("html")[0];
+      ['body', 'span', 'img'].forEach(function(a) {
+        e[a] = document.getElementById(a);
+      });
+
+      window.scrollTo(0, 0);
+
+      /* Point based test over the img only. */
+      check(20, 20, 0, 0, 0, 0, [e.img]);
+      /* Rect based test over the img only. */
+      check(20, 20, 5, 5, 5, 5, [e.img]);
+
+      /* Note that for the tests below, the img bounds are considered to be (99, 99). */
+      /* Point based test over the img and the span. */
+      check(0, 99, 0, 0, 0, 0, [e.img]);
+      /* Rect based test over the img and the span with the img fully covering the hit region. */
+      check(0, 98, 0, 1, 1, 0, [e.img]);
+      /* Rect based test over the img and the span with the img not fully covering the hit region. */
+      /* FIXME: This fails due to: https://bugs.webkit.org/show_bug.cgi?id=88376 */
+      check(0, 98, 0, 1, 2, 0, [e.img, e.span]);
+      /* Rect based test over the entire img. */
+      check(0, 0, 0, 99, 99, 0, [e.img]);
+
+      if (window.layoutTestController)
+        layoutTestController.notifyDone();
+    }
+
+    window._onload_ = runTest;
+  </script>
+</head>
+<body id="body" style="padding: 0; margin: 0;">
+  <span id="span" style="margin: 0; padding: 0; font-size:36px">
+    <img id="img" width="100" height="100" style="background-color: black; margin: 0; padding: 0;" />
+  </span>
+
+  <span id="console" style="position: absolute; top: 150px;"></span>
+  <script src=""
+</body>
+</html>
+

Modified: trunk/Source/WebCore/ChangeLog (119732 => 119733)


--- trunk/Source/WebCore/ChangeLog	2012-06-07 16:58:43 UTC (rev 119732)
+++ trunk/Source/WebCore/ChangeLog	2012-06-07 17:02:19 UTC (rev 119733)
@@ -1,3 +1,19 @@
+2012-06-07  Raymes Khoury  <ray...@chromium.org>
+
+        Incorrect rect-based hit-test result for culled-inline elements
+        https://bugs.webkit.org/show_bug.cgi?id=85849
+
+        Reviewed by Levi Weintraub.
+
+        Modified code which blindly adds culled inlines to rect-based hit-test
+        results so that it only does so if the child node does not fully cover
+        the hit-test region.
+
+        Test: fast/dom/nodesFromRect-culled-inline.html
+
+        * rendering/HitTestResult.cpp:
+        (WebCore::HitTestResult::addNodeToRectBasedTestResult):
+
 2012-06-07  Daniel Erat  <de...@chromium.org>
 
         Make Skia backend honor requests for subpixel-positioned text.

Modified: trunk/Source/WebCore/rendering/HitTestResult.cpp (119732 => 119733)


--- trunk/Source/WebCore/rendering/HitTestResult.cpp	2012-06-07 16:58:43 UTC (rev 119732)
+++ trunk/Source/WebCore/rendering/HitTestResult.cpp	2012-06-07 17:02:19 UTC (rev 119733)
@@ -622,21 +622,23 @@
 
     mutableRectBasedTestResult().add(node);
 
-    if (node->renderer()->isInline()) {
+    bool regionFilled = rect.contains(rectForPoint(pointInContainer));
+    // FIXME: This code (incorrectly) attempts to correct for culled inline nodes. See https://bugs.webkit.org/show_bug.cgi?id=85849.
+    if (node->renderer()->isInline() && !regionFilled) {
         for (RenderObject* curr = node->renderer()->parent(); curr; curr = curr->parent()) {
             if (!curr->isRenderInline())
                 break;
-            
+
             // We need to make sure the nodes for culled inlines get included.
             RenderInline* currInline = toRenderInline(curr);
             if (currInline->alwaysCreateLineBoxes())
                 break;
-            
+
             if (currInline->visibleToHitTesting() && currInline->node())
                 mutableRectBasedTestResult().add(currInline->node()->shadowAncestorNode());
         }
     }
-    return !rect.contains(rectForPoint(pointInContainer));
+    return !regionFilled;
 }
 
 bool HitTestResult::addNodeToRectBasedTestResult(Node* node, const LayoutPoint& pointInContainer, const FloatRect& rect)
@@ -655,21 +657,23 @@
 
     mutableRectBasedTestResult().add(node);
 
-    if (node->renderer()->isInline()) {
+    bool regionFilled = rect.contains(rectForPoint(pointInContainer));
+    // FIXME: This code (incorrectly) attempts to correct for culled inline nodes. See https://bugs.webkit.org/show_bug.cgi?id=85849.
+    if (node->renderer()->isInline() && !regionFilled) {
         for (RenderObject* curr = node->renderer()->parent(); curr; curr = curr->parent()) {
             if (!curr->isRenderInline())
                 break;
-            
+
             // We need to make sure the nodes for culled inlines get included.
             RenderInline* currInline = toRenderInline(curr);
             if (currInline->alwaysCreateLineBoxes())
                 break;
-            
+
             if (currInline->visibleToHitTesting() && currInline->node())
                 mutableRectBasedTestResult().add(currInline->node()->shadowAncestorNode());
         }
     }
-    return !rect.contains(rectForPoint(pointInContainer));
+    return !regionFilled;
 }
 
 void HitTestResult::append(const HitTestResult& other)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to