Skip to content

Commit

Permalink
Some dynamically sized Interaction Regions occlusions are missing
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=255457
<rdar://107960700>

Reviewed by Tim Horton.

Remove the size limit on occlusion regions (but not interaction
regions).

* LayoutTests/interaction-region/full-page-overlay-expected.txt:
* LayoutTests/interaction-region/full-page-overlay.html:
Update the test to cover this scenario.

* Source/WebCore/page/InteractionRegion.cpp:
(WebCore::interactionRegionForRenderedRegion):
Remove the "padding" added to the frame view's area, since it was
originally introduced for occlusions.
Remove the area check in the occlusion branch.

Canonical link: https://commits.webkit.org/262992@main
  • Loading branch information
etiennesegonzac committed Apr 14, 2023
1 parent 18f1b39 commit b6fce29
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 46 deletions.
44 changes: 8 additions & 36 deletions LayoutTests/interaction-region/full-page-overlay-expected.txt
@@ -1,48 +1,20 @@
(GraphicsLayer
(anchor 0.00 0.00)
(bounds 1536.00 2008.00)
(bounds 1536.00 5013.00)
(children 1
(GraphicsLayer
(bounds 1536.00 2008.00)
(bounds 1536.00 5013.00)
(contentsOpaque 1)
(drawsContent 1)
(backgroundColor #FFFFFF)
(event region
(rect (0,0) width=1536 height=2008)
)
(children 2
(GraphicsLayer
(preserves3D 1)
(children 1
(GraphicsLayer
(bounds 1536.00 2008.00)
(contentsOpaque 1)
(event region
(rect (0,0) width=1536 height=2008)

(interaction regions [
(occlusion (0,0) width=1536 height=2008)
(borderRadius 0.00)])
)
)
)
)
(GraphicsLayer
(preserves3D 1)
(children 1
(GraphicsLayer
(bounds 1536.00 2008.00)
(contentsOpaque 1)
(event region
(rect (0,0) width=1536 height=2008)
(rect (0,0) width=1536 height=5013)

(interaction regions [
(occlusion (0,0) width=1536 height=2008)
(borderRadius 0.00)])
)
)
)
)
(interaction regions [
(occlusion (0,0) width=1536 height=2008)
(borderRadius 0.00),
(occlusion (0,0) width=1536 height=5000)
(borderRadius 0.00)])
)
)
)
Expand Down
17 changes: 10 additions & 7 deletions LayoutTests/interaction-region/full-page-overlay.html
Expand Up @@ -4,18 +4,17 @@
<meta name="viewport" content="initial-scale=0.5">
<style>
html, body {
width: 100%;
height: 100%;
margin: 0;
}

.overlay {
position: fixed;
position: absolute;
top: 0;
left: 0;
z-index: 1;
width: 100%;
height: 100%;
z-index: 1;
opacity: 0.5;
background-color: purple;
}

Expand All @@ -24,21 +23,25 @@
}

.spacer {
height: 2000px;
height: 5000px;
}
</style>
</head>
<body>
<div class="overlay"></div>
<div class="tappable-overlay overlay"></div>
<div class="spacer"></div>
<div class="spacer">
<div id="dynamic" class="overlay"></div>
</div>

<pre id="results"></pre>
<script>
document.body.addEventListener("click", function(e) {
console.log(e, "event delegation");
});

let dynamicallySizedOverlay = document.querySelector("#dynamic");
dynamicallySizedOverlay.style.height = dynamicallySizedOverlay.parentElement.offsetHeight + "px";

if (window.testRunner)
testRunner.dumpAsText();

Expand Down
5 changes: 2 additions & 3 deletions Source/WebCore/page/InteractionRegion.cpp
Expand Up @@ -142,8 +142,7 @@ std::optional<InteractionRegion> interactionRegionForRenderedRegion(RenderObject
auto& mainFrameView = *localFrame->view();

FloatSize frameViewSize = mainFrameView.size();
// Adding some wiggle room, we use this to avoid extreme cases.
auto scale = 1 / mainFrameView.visibleContentScaleFactor() + 0.2;
auto scale = 1 / mainFrameView.visibleContentScaleFactor();
frameViewSize.scale(scale, scale);
auto frameViewArea = frameViewSize.area();

Expand Down Expand Up @@ -183,7 +182,7 @@ std::optional<InteractionRegion> interactionRegionForRenderedRegion(RenderObject
bool hasPointer = cursorTypeForElement(*matchedElement) == CursorType::Pointer || shouldAllowNonPointerCursorForElement(*matchedElement);
bool isTooBigForInteraction = checkedRegionArea.value() > frameViewArea / 2;
if (!hasListener || !hasPointer || isTooBigForInteraction) {
bool isOverlay = checkedRegionArea.value() <= frameViewArea && (renderer.style().specifiedZIndex() > 0 || renderer.isFixedPositioned());
bool isOverlay = renderer.style().specifiedZIndex() > 0 || renderer.isFixedPositioned();
if (isOverlay && isOriginalMatch) {
return { {
InteractionRegion::Type::Occlusion,
Expand Down

0 comments on commit b6fce29

Please sign in to comment.