Hit-testing on layers overlapping scrollers should hit-test on text boxes
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Mar 2019 07:12:47 +0000 (07:12 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Mar 2019 07:12:47 +0000 (07:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195373
<rdar://problem/48649865>

Reviewed by Simon Fraser.

Source/WebCore:

* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::paint):
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::paint):

Collect event region for overflowing line boxes.

* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::paintFlow):

Collect event region for overflowing simple lines.

LayoutTests:

* fast/scrolling/ios/overflow-scroll-overlap-3.html:

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

LayoutTests/ChangeLog
LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-3-expected.txt
LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-3.html
Source/WebCore/ChangeLog
Source/WebCore/rendering/InlineFlowBox.cpp
Source/WebCore/rendering/InlineTextBox.cpp
Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp

index 409a73e..ccdd668 100644 (file)
@@ -1,3 +1,13 @@
+2019-03-26  Antti Koivisto  <antti@apple.com>
+
+        Hit-testing on layers overlapping scrollers should hit-test on text boxes
+        https://bugs.webkit.org/show_bug.cgi?id=195373
+        <rdar://problem/48649865>
+
+        Reviewed by Simon Fraser.
+
+        * fast/scrolling/ios/overflow-scroll-overlap-3.html:
+
 2019-03-25  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         Unreviewed, rolling out r243450.
index 0261016..c38f96c 100644 (file)
@@ -1,5 +1,11 @@
 Test that scrollable areas with text overlap are correctly targeted.
 
-case 1: Scrollable 1 
+case 1: 
 case 2: Scrollable 2 
+case 3: Scrollable 3 
+case 4: 
+case 5: Scrollable 5 
+case 6: Scrollable 6 
+case 7: 
+case 8: Scrollable 8 
 
index e0e84c9..41d43b0 100644 (file)
@@ -71,6 +71,75 @@ Test that scrollable areas with text overlap are correctly targeted.
     </div>
 </div>
 
+<div class="case">
+    <div class="overflowscroll target">
+        <div class="scrollcontent"></div>
+    </div>
+    <div class="overlapping" style="top:-60px; pointer-events:none">
+    Text text text text text text text text text text text text text text text text text text text text text text
+    </div>
+</div>
+
+<div class="case">
+    <div class="overflowscroll target">
+        <div class="scrollcontent"></div>
+    </div>
+    <div class="overlapping" style="top:-60px">
+        <b>
+            Text text text text text text text text text text text text
+            <i>text text text text text text text text text text</i>
+        </b>
+    </div>
+</div>
+
+<div class="case">
+    <div class="overflowscroll target">
+        <div class="scrollcontent"></div>
+    </div>
+    <div class="overlapping" style="top:-60px; padding-left:40px">
+        <b>
+            Text text text text text text text text text text text text
+            <i>text text text text text text text text text text</i>
+        </b>
+    </div>
+</div>
+
+<div class="case">
+    <div class="overflowscroll target">
+        <div class="scrollcontent"></div>
+    </div>
+    <div class="overlapping" style="top:-60px; pointer-events:none">
+        <b>
+            Text text text text text text text text text text text text
+            <i>text text text text text text text text text text</i>
+        </b>
+    </div>
+</div>
+
+<div class="case">
+    <div class="overflowscroll target">
+        <div class="scrollcontent"></div>
+    </div>
+    <div class="overlapping" style="top:-60px; visibility:hidden">
+        <b style="visibility:visible">
+            Text text text text text text text text text text text text
+            <i>text text text text text text text text text text</i>
+        </b>
+    </div>
+</div>
+
+<div class="case">
+    <div class="overflowscroll target">
+        <div class="scrollcontent"></div>
+    </div>
+    <div class="overlapping" style="top:-60px; visibility:hidden">
+        <b style="visibility:visible">
+            Text text text text text text text text text text text text
+            <i style="visibility:hidden">text text text text text text text text text text</i>
+        </b>
+    </div>
+</div>
+
 <div id=log></div>
 
 </body>
index 8babd8a..1018436 100644 (file)
@@ -1,3 +1,23 @@
+2019-03-26  Antti Koivisto  <antti@apple.com>
+
+        Hit-testing on layers overlapping scrollers should hit-test on text boxes
+        https://bugs.webkit.org/show_bug.cgi?id=195373
+        <rdar://problem/48649865>
+
+        Reviewed by Simon Fraser.
+
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::paint):
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::paint):
+
+        Collect event region for overflowing line boxes.
+
+        * rendering/SimpleLineLayoutFunctions.cpp:
+        (WebCore::SimpleLineLayout::paintFlow):
+
+        Collect event region for overflowing simple lines.
+
 2019-03-25  Alex Christensen  <achristensen@webkit.org>
 
         Expected shouldn't assume its contained types are copyable
index 1ef25ad..1ce8de7 100644 (file)
@@ -1150,7 +1150,7 @@ bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
 
 void InlineFlowBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
 {
-    if (paintInfo.phase != PaintPhase::Foreground && paintInfo.phase != PaintPhase::Selection && paintInfo.phase != PaintPhase::Outline && paintInfo.phase != PaintPhase::SelfOutline && paintInfo.phase != PaintPhase::ChildOutlines && paintInfo.phase != PaintPhase::TextClip && paintInfo.phase != PaintPhase::Mask)
+    if (paintInfo.phase != PaintPhase::Foreground && paintInfo.phase != PaintPhase::Selection && paintInfo.phase != PaintPhase::Outline && paintInfo.phase != PaintPhase::SelfOutline && paintInfo.phase != PaintPhase::ChildOutlines && paintInfo.phase != PaintPhase::TextClip && paintInfo.phase != PaintPhase::Mask && paintInfo.phase != PaintPhase::EventRegion)
         return;
 
     LayoutRect overflowRect(visualOverflowRect(lineTop, lineBottom));
index 3ced78d..1302c5b 100644 (file)
@@ -502,6 +502,12 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
     boxOrigin.moveBy(localPaintOffset);
     FloatRect boxRect(boxOrigin, FloatSize(logicalWidth(), logicalHeight()));
 
+    if (paintInfo.phase == PaintPhase::EventRegion) {
+        if (visibleToHitTesting())
+            paintInfo.eventRegion->unite(enclosingIntRect(boxRect));
+        return;
+    }
+
     auto* combinedText = this->combinedText();
 
     bool shouldRotate = !isHorizontal() && !combinedText;
index fc22555..66e9502 100644 (file)
@@ -76,6 +76,18 @@ FloatRect computeOverflow(const RenderBlockFlow& flow, const FloatRect& layoutRe
 
 void paintFlow(const RenderBlockFlow& flow, const Layout& layout, PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
+    if (paintInfo.phase == PaintPhase::EventRegion) {
+        if (!flow.visibleToHitTesting())
+            return;
+        auto paintRect = paintInfo.rect;
+        paintRect.moveBy(-paintOffset);
+        for (auto run : layout.runResolver().rangeForRect(paintRect)) {
+            FloatRect visualOverflowRect = computeOverflow(flow, run.rect());
+            paintInfo.eventRegion->unite(enclosingIntRect(visualOverflowRect));
+        }
+        return;
+    }
+
     if (paintInfo.phase != PaintPhase::Foreground)
         return;