Skip to content
Permalink
Browse files
Stop propagating scroll-snap style from <body> to viewport
https://bugs.webkit.org/show_bug.cgi?id=200643
<rdar://problem/54277211>

Reviewed by Simon Fraser.

Only the document element should be allowed to propagate to the viewport.

Test changes:
- iframe tests changes match https://commits.webkit.org/r269506 to reflect new behavior
- remove legacy tests for old behavior that is now unsupported

* LayoutTests/TestExpectations:
* LayoutTests/tiled-drawing/scrolling/scroll-snap/resources/horizontal-mainframe.html:
* LayoutTests/tiled-drawing/scrolling/scroll-snap/resources/vertical-mainframe.html:
* LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-async-iframe.html:
* LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-legacy-expected.txt: Removed.
* LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-legacy.html: Removed.
* LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-legacy-expected.txt: Removed.
* LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-legacy.html: Removed.
* LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe-legacy-expected.txt: Removed.
* LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe-legacy.html: Removed.
* Source/WebCore/page/FrameView.cpp:
(WebCore::FrameView::updateSnapOffsets):

Canonical link: https://commits.webkit.org/253430@main
  • Loading branch information
nt1m committed Aug 15, 2022
1 parent 750fbdd commit 54380c8088010df43b471d7b18c7bb3817115a8f
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 261 deletions.
@@ -4765,7 +4765,6 @@ webkit.org/b/215531 imported/w3c/web-platform-tests/css/css-backgrounds/backgrou
webkit.org/b/215531 imported/w3c/web-platform-tests/css/css-backgrounds/background-size/vector/wide--contain--width.html [ ImageOnlyFailure ]

# Newly imported scroll-snap tests that are failing
imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-snap-root-003.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-align-001.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-align-002.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-snap-001.html [ ImageOnlyFailure ]
@@ -2,12 +2,14 @@
<html>
<head>
<style>
html {
scroll-snap-type: x mandatory;
}
.horizontalGallery {
width: 600vw;
height: 100vh;
margin: 0;
padding: 0;
scroll-snap-type: x mandatory;
}
.colorBox {
height: 100vh;
@@ -2,12 +2,14 @@
<html>
<head>
<style>
html {
scroll-snap-type: y mandatory;
}
.verticalGallery {
width: 100vw;
height: 600vh;
margin: 0;
padding: 0;
scroll-snap-type: y mandatory;
}
.colorBox {
height: 100vh;
@@ -1,5 +1,4 @@
<!DOCTYPE html> <!-- webkit-test-runner [ AsyncFrameScrollingEnabled=true ] -->
<!DOCTYPE html>
<html>
<head>
<style>
@@ -9,7 +8,7 @@
height: 250px;
margin: 5px;
}

/* It's important for the test that the main frame does not become scrollable */
#console {
height: 1em;
@@ -18,7 +17,7 @@
</style>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../../resources/ui-helper.js"></script>

<script>
window.jsTestIsAsync = true;

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -916,21 +916,11 @@ void FrameView::updateSnapOffsets()
if (!frame().document())
return;

auto& document = *frame().document();
auto* documentElement = document.documentElement();
RenderBox* bodyRenderer = document.bodyOrFrameset() ? document.bodyOrFrameset()->renderBox() : nullptr;
RenderBox* rootRenderer = documentElement ? documentElement->renderBox() : nullptr;
auto hasScrollSnap = [](const RenderObject* renderer) {
return renderer && renderer->style().scrollSnapType().strictness != ScrollSnapStrictness::None;
};
auto* documentElement = frame().document()->documentElement();
auto* rootRenderer = documentElement ? documentElement->renderBox() : nullptr;

const RenderStyle* styleToUse = nullptr;
if (hasScrollSnap(bodyRenderer)) {
// The specification doesn't allow setting scroll-snap-type on the body, but
// we do this to ensure backwards compatibility with an earlier version of the
// specification: See webkit.org/b/200643.
styleToUse = &bodyRenderer->style();
} else if (hasScrollSnap(rootRenderer))
if (rootRenderer && rootRenderer->style().scrollSnapType().strictness != ScrollSnapStrictness::None)
styleToUse = &rootRenderer->style();

if (!styleToUse || !documentElement) {

0 comments on commit 54380c8

Please sign in to comment.