Title: [275214] trunk
Revision
275214
Author
[email protected]
Date
2021-03-30 10:34:53 -0700 (Tue, 30 Mar 2021)

Log Message

[LFC][Integration] Elements that overflow inline-blocks are not hit tested correctly
https://bugs.webkit.org/show_bug.cgi?id=223932
rdar://75888718

Reviewed by Zalan Bujtas.
Source/WebCore:

If an inline block has overflowing children (for example due to negative margin) we may fail to hit test them.

Test: fast/inline-block/hit-test-negative-margin-child.html

* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::hitTest):

Always descend into inline blocks even if their run didn't hit.

LayoutTests:

* fast/inline-block/hit-test-negative-margin-child-expected.txt: Added.
* fast/inline-block/hit-test-negative-margin-child.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (275213 => 275214)


--- trunk/LayoutTests/ChangeLog	2021-03-30 17:32:37 UTC (rev 275213)
+++ trunk/LayoutTests/ChangeLog	2021-03-30 17:34:53 UTC (rev 275214)
@@ -1,3 +1,14 @@
+2021-03-30  Antti Koivisto  <[email protected]>
+
+        [LFC][Integration] Elements that overflow inline-blocks are not hit tested correctly
+        https://bugs.webkit.org/show_bug.cgi?id=223932
+        rdar://75888718
+
+        Reviewed by Zalan Bujtas.
+
+        * fast/inline-block/hit-test-negative-margin-child-expected.txt: Added.
+        * fast/inline-block/hit-test-negative-margin-child.html: Added.
+
 2021-03-30  Chris Gambrell  <[email protected]>
 
         [LayoutTests] Convert http/tests/contentextensions convert PHP to Python

Added: trunk/LayoutTests/fast/inline-block/hit-test-negative-margin-child-expected.txt (0 => 275214)


--- trunk/LayoutTests/fast/inline-block/hit-test-negative-margin-child-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/inline-block/hit-test-negative-margin-child-expected.txt	2021-03-30 17:34:53 UTC (rev 275214)
@@ -0,0 +1,2 @@
+X
+PASS

Added: trunk/LayoutTests/fast/inline-block/hit-test-negative-margin-child.html (0 => 275214)


--- trunk/LayoutTests/fast/inline-block/hit-test-negative-margin-child.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline-block/hit-test-negative-margin-child.html	2021-03-30 17:34:53 UTC (rev 275214)
@@ -0,0 +1,12 @@
+<style>
+div { border: 2px solid blue; display:inline-block; margin-left:100px; width:200px; }
+button { margin-left:-75px; width:50px; height:50px; }
+</style>
+<div><button>X</button></div>
+<pre id=log></pre>
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+const hitTestElement = document.elementFromPoint(50, 50);
+log.innerText = hitTestElement == document.querySelector('button') ? "PASS" : "FAIL";
+</script>

Modified: trunk/Source/WebCore/ChangeLog (275213 => 275214)


--- trunk/Source/WebCore/ChangeLog	2021-03-30 17:32:37 UTC (rev 275213)
+++ trunk/Source/WebCore/ChangeLog	2021-03-30 17:34:53 UTC (rev 275214)
@@ -1,3 +1,20 @@
+2021-03-30  Antti Koivisto  <[email protected]>
+
+        [LFC][Integration] Elements that overflow inline-blocks are not hit tested correctly
+        https://bugs.webkit.org/show_bug.cgi?id=223932
+        rdar://75888718
+
+        Reviewed by Zalan Bujtas.
+        
+        If an inline block has overflowing children (for example due to negative margin) we may fail to hit test them.
+
+        Test: fast/inline-block/hit-test-negative-margin-child.html
+
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::hitTest):
+        
+        Always descend into inline blocks even if their run didn't hit.
+
 2021-03-30  Mark Lam  <[email protected]>
 
         Ensure that GlobalPropertyInfo is allocated on the stack.

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (275213 => 275214)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2021-03-30 17:32:37 UTC (rev 275213)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2021-03-30 17:34:53 UTC (rev 275214)
@@ -526,15 +526,15 @@
 
     // FIXME: This should do something efficient to find the run range.
     for (auto& run : WTF::makeReversedRange(inlineContent.runs)) {
-        auto runRect = Layout::toLayoutRect(run.rect());
-        runRect.moveBy(accumulatedOffset);
-
-        if (!locationInContainer.intersects(runRect))
-            continue;
-
         auto& renderer = m_boxTree.rendererForLayoutBox(run.layoutBox());
 
         if (is<RenderText>(renderer)) {
+            auto runRect = Layout::toLayoutRect(run.rect());
+            runRect.moveBy(accumulatedOffset);
+
+            if (!locationInContainer.intersects(runRect))
+                continue;
+            
             auto& style = run.style();
             if (style.visibility() != Visibility::Visible || style.pointerEvents() == PointerEvents::None)
                 continue;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to