Skip to content

Commit

Permalink
InteractionRegions: elements with explicitly set border-radius shou…
Browse files Browse the repository at this point in the history
…ld not get the default radius

https://bugs.webkit.org/show_bug.cgi?id=263611
<rdar://116815739>

Reviewed by Tim Horton.

When an element has a border radius explicitly set, even when set to 0,
avoid adding the default radius to the corresponding InteractionRegion.

* Source/WebCore/page/InteractionRegion.cpp:
(WebCore::interactionRegionForRenderedRegion):
Check if the RenderStyle has an explicitly set border-radius.

* LayoutTests/interaction-region/border-radii-expected.txt:
* LayoutTests/interaction-region/border-radii.html:
Add test cases covering this change.

Canonical link: https://commits.webkit.org/269755@main
  • Loading branch information
etiennesegonzac committed Oct 25, 2023
1 parent 88f9ef0 commit e699017
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
8 changes: 6 additions & 2 deletions LayoutTests/interaction-region/border-radii-expected.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
uniform half pill diagonal tongue degenerate changing
uniform half pill diagonal tongue degenerate changing default explicit
(GraphicsLayer
(anchor 0.00 0.00)
(bounds 800.00 600.00)
Expand All @@ -23,7 +23,11 @@ uniform half pill diagonal tongue degenerate changing
(interaction (434,10) width=102 height=52)
(borderRadius 2.00),
(interaction (559,10) width=92 height=52)
(borderRadius 20.00)])
(borderRadius 20.00),
(interaction (674,10) width=77 height=52)
(borderRadius 8.00),
(interaction (10,82) width=80 height=52)
(borderRadius 0.00)])
)
)
)
Expand Down
10 changes: 10 additions & 0 deletions LayoutTests/interaction-region/border-radii.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
.changed {
border-radius: 20px;
}

.default, .explicit {
background: transparent;
color: black;
}
.explicit {
border-radius: 0;
}
</style>
<script src="../resources/ui-helper.js"></script>
<body>
Expand All @@ -37,6 +45,8 @@
<div class="tongue">tongue</div>
<div class="degenerate">degenerate</div>
<div class="changing">changing</div>
<div class="default">default</div>
<div class="explicit">explicit</div>
<pre id="results"></pre>
<script>
document.body.addEventListener("click", function(e) {
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/page/InteractionRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ std::optional<InteractionRegion> interactionRegionForRenderedRegion(RenderObject
}
}

if (!regionRenderer.hasVisibleBoxDecorations() && !renderer.hasVisibleBoxDecorations()) {
if (!regionRenderer.hasVisibleBoxDecorations() && !renderer.hasVisibleBoxDecorations() && !renderer.style().hasExplicitlySetBorderRadius()) {
// We can safely tweak the bounds and radius without causing visual mismatch.
borderRadius = std::max<float>(borderRadius, regionRenderer.document().settings().interactionRegionMinimumCornerRadius());
if (isInlineNonBlock)
Expand Down

0 comments on commit e699017

Please sign in to comment.