Title: [293642] trunk
- Revision
- 293642
- Author
- [email protected]
- Date
- 2022-04-29 23:07:26 -0700 (Fri, 29 Apr 2022)
Log Message
REGRESSION(r290770): element.scrollIntoViewIfNeeded() scrolls to top even when element is already in viewport
https://bugs.webkit.org/show_bug.cgi?id=238985
Patch by Rob Buis <[email protected]> on 2022-04-29
Reviewed by Simon Fraser.
LayoutTests/imported/w3c:
* web-platform-tests/css/cssom-view/scrollintoview-zero-height-item-expected.txt: Added.
* web-platform-tests/css/cssom-view/scrollintoview-zero-height-item.html: Added.
Source/WebCore:
This mostly reverts to the code as it was before r290770, but adds code to
treat non-intersections as hidden, including zero width/height rects.
Test: imported/w3c/web-platform-tests/css/cssom-view/scrollintoview-zero-height-item.html
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::getRectToExpose const):
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (293641 => 293642)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2022-04-30 03:37:19 UTC (rev 293641)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2022-04-30 06:07:26 UTC (rev 293642)
@@ -1,3 +1,13 @@
+2022-04-29 Rob Buis <[email protected]>
+
+ REGRESSION(r290770): element.scrollIntoViewIfNeeded() scrolls to top even when element is already in viewport
+ https://bugs.webkit.org/show_bug.cgi?id=238985
+
+ Reviewed by Simon Fraser.
+
+ * web-platform-tests/css/cssom-view/scrollintoview-zero-height-item-expected.txt: Added.
+ * web-platform-tests/css/cssom-view/scrollintoview-zero-height-item.html: Added.
+
2022-04-29 Youenn Fablet <[email protected]>
Make sure to fail importScripts as per https://w3c.github.io/ServiceWorker/#importscripts step 4
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollintoview-zero-height-item-expected.txt (0 => 293642)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollintoview-zero-height-item-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollintoview-zero-height-item-expected.txt 2022-04-30 06:07:26 UTC (rev 293642)
@@ -0,0 +1,3 @@
+
+PASS scrollIntoView on zero height item
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollintoview-zero-height-item.html (0 => 293642)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollintoview-zero-height-item.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollintoview-zero-height-item.html 2022-04-30 06:07:26 UTC (rev 293642)
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<title>CSSOM View - scrollIntoView does not scroll to zero height item</title>
+<meta charset="UTF-8">
+<link rel="help" href=""
+<script src=""
+<script src=""
+<body>
+<div style="border: 1px solid black; height: 300px; width: 200px; overflow-y: auto;visibility: hidden" id="box">
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+ <div id="text">--- Clicking here should NOT scroll to top ---</div>
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+ <div>text</div>
+</div>
+<script>
+test(() => {
+box.scrollTop = 40;
+
+let div = document.createElement("div");
+div.textContent = "div";
+text.parentNode.insertBefore(div, text);
+
+let span = document.createElement("span");
+span.tabIndex = 0;
+div.append(span);
+
+span.scrollIntoViewIfNeeded();
+
+assert_equals(box.scrollTop, 40, 'box.scrollTop');
+}, `scrollIntoView on zero height item`);
+
+</script>
+</body>
Modified: trunk/Source/WebCore/ChangeLog (293641 => 293642)
--- trunk/Source/WebCore/ChangeLog 2022-04-30 03:37:19 UTC (rev 293641)
+++ trunk/Source/WebCore/ChangeLog 2022-04-30 06:07:26 UTC (rev 293642)
@@ -1,3 +1,18 @@
+2022-04-29 Rob Buis <[email protected]>
+
+ REGRESSION(r290770): element.scrollIntoViewIfNeeded() scrolls to top even when element is already in viewport
+ https://bugs.webkit.org/show_bug.cgi?id=238985
+
+ Reviewed by Simon Fraser.
+
+ This mostly reverts to the code as it was before r290770, but adds code to
+ treat non-intersections as hidden, including zero width/height rects.
+
+ Test: imported/w3c/web-platform-tests/css/cssom-view/scrollintoview-zero-height-item.html
+
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::getRectToExpose const):
+
2022-04-29 Don Olmstead <[email protected]>
The isYahooMail quirk is specific to PLATFORM(IOS_FAMILY)
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (293641 => 293642)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2022-04-30 03:37:19 UTC (rev 293641)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2022-04-30 06:07:26 UTC (rev 293642)
@@ -2651,12 +2651,12 @@
}
}
+ ScrollAlignment::Behavior scrollX = alignX.getHiddenBehavior();
+ bool intersectsInX = exposeRect.maxX() >= visibleRect.x() && exposeRect.x() <= visibleRect.maxX();
+
// Determine the appropriate X behavior.
- ScrollAlignment::Behavior scrollX = alignX.getHiddenBehavior();
- LayoutRect exposeRectX(exposeRect.x(), visibleRect.y(), exposeRect.width(), visibleRect.height());
- LayoutRect intersectRect = intersection(visibleRect, exposeRectX);
- if (!intersectRect.isEmpty()) {
- LayoutUnit intersectWidth = intersectRect.width();
+ if (intersectsInX) {
+ LayoutUnit intersectWidth = std::max(LayoutUnit(), std::min(visibleRect.maxX(), exposeRect.maxX()) - std::max(visibleRect.x(), exposeRect.x()));
if (intersectWidth == exposeRect.width() || (alignX.legacyHorizontalVisibilityThresholdEnabled() && intersectWidth >= MIN_INTERSECT_FOR_REVEAL)) {
// If the rectangle is fully visible, use the specified visible behavior.
// If the rectangle is partially visible, but over a certain threshold,
@@ -2688,12 +2688,12 @@
else
x = exposeRect.x();
+ ScrollAlignment::Behavior scrollY = alignY.getHiddenBehavior();
+ bool intersectsInY = exposeRect.maxY() >= visibleRect.y() && exposeRect.y() <= visibleRect.maxY();
+
// Determine the appropriate Y behavior.
- ScrollAlignment::Behavior scrollY = alignY.getHiddenBehavior();
- LayoutRect exposeRectY(visibleRect.x(), exposeRect.y(), visibleRect.width(), exposeRect.height());
- intersectRect = intersection(visibleRect, exposeRectY);
- if (!intersectRect.isEmpty()) {
- LayoutUnit intersectHeight = intersectRect.height();
+ if (intersectsInY) {
+ LayoutUnit intersectHeight = std::max(LayoutUnit(), std::min(visibleRect.maxY(), exposeRect.maxY()) - std::max(visibleRect.y(), exposeRect.y()));
if (intersectHeight == exposeRect.height()) {
// If the rectangle is fully visible, use the specified visible behavior.
scrollY = alignY.getVisibleBehavior();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes