Changeset 269506 in webkit
- Timestamp:
- Nov 6, 2020 1:44:54 AM (21 months ago)
- Location:
- trunk
- Files:
-
- 3 added
- 18 edited
- 3 copied
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/css3/scroll-snap/scroll-snap-positions-mainframe.html (modified) (1 diff)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-legacy-expected.txt (added)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-legacy.html (copied) (copied from trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html (modified) (2 diffs)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html (modified) (2 diffs)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html (modified) (2 diffs)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-legacy-expected.txt (added)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-legacy.html (copied) (copied from trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html (modified) (2 diffs)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html (modified) (2 diffs)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe-legacy-expected.txt (added)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe-legacy.html (copied) (copied from trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe.html) (2 diffs)
-
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe.html (modified) (3 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/page/FrameView.cpp (modified) (1 diff)
-
Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp (modified) (3 diffs)
-
Source/WebCore/page/scrolling/AxisScrollSnapOffsets.h (modified) (2 diffs)
-
Source/WebCore/platform/ScrollableArea.cpp (modified) (1 diff)
-
Source/WebCore/platform/ScrollableArea.h (modified) (1 diff)
-
Source/WebCore/rendering/RenderBox.cpp (modified) (2 diffs)
-
Source/WebCore/rendering/RenderBox.h (modified) (1 diff)
-
Source/WebCore/rendering/RenderLayer.cpp (modified) (1 diff)
-
Source/WebCore/rendering/RenderObject.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r269499 r269506 1 2020-11-06 Martin Robinson <mrobinson@igalia.com> 2 3 Scroll snap specified on :root doesn't work 4 https://bugs.webkit.org/show_bug.cgi?id=210469 5 <rdar://problem/61746676> 6 7 Reviewed by Simon Fraser. 8 9 Modified main frame scroll snap tests to reflect the specification and add a 10 few more tests to test the legacy behavior which this change maintains for 11 backwards compatibility. 12 13 * css3/scroll-snap/scroll-snap-positions-mainframe.html: 14 * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-legacy-expected.txt: Added. 15 * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-legacy.html: Copied from LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html. 16 * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html: 17 * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html: 18 * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html: 19 * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-legacy-expected.txt: Added. 20 * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-legacy.html: Copied from LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html. 21 * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html: 22 * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html: 23 * tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe-legacy-expected.txt: Added. 24 * tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe-legacy.html: Copied from LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe.html. 25 * tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe.html: 26 1 27 2020-11-05 Alex Christensen <achristensen@webkit.org> 2 28 -
trunk/LayoutTests/css3/scroll-snap/scroll-snap-positions-mainframe.html
r217150 r269506 2 2 <head> 3 3 <style> 4 body{4 html { 5 5 margin: 0; 6 6 scroll-snap-type: y mandatory; 7 7 } 8 8 body { 9 margin: 0; 10 } 9 11 .vertical { 10 12 width: 100%; -
trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal.html
r258701 r269506 3 3 <head> 4 4 <style> 5 html { 6 scroll-snap-type: x mandatory; 7 } 5 8 .horizontalGallery { 6 9 width: 600vw; … … 8 11 margin: 0; 9 12 padding: 0; 10 scroll-snap-type: x mandatory;11 13 } 12 14 .colorBox { -
trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-horizontal.html
r258701 r269506 3 3 <head> 4 4 <style> 5 html { 6 scroll-snap-type: x mandatory; 7 } 5 8 .horizontalGallery { 6 9 width: 600vw; … … 8 11 margin: 0; 9 12 padding: 0; 10 scroll-snap-type: x mandatory;11 13 } 12 14 .colorBox { -
trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html
r258701 r269506 3 3 <head> 4 4 <style> 5 html { 6 scroll-snap-type: y mandatory; 7 } 5 8 .verticalGallery { 6 9 width: 100vw; … … 8 11 margin: 0; 9 12 padding: 0; 10 scroll-snap-type: y mandatory;11 13 } 12 14 .colorBox { -
trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html
r258701 r269506 3 3 <head> 4 4 <style> 5 html { 6 scroll-snap-type: y mandatory; 7 } 5 8 .verticalGallery { 6 9 width: 100vw; … … 8 11 margin: 0; 9 12 padding: 0; 10 scroll-snap-type: y mandatory;11 13 } 12 14 .colorBox { -
trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical.html
r258701 r269506 3 3 <head> 4 4 <style> 5 html { 6 scroll-snap-type: y mandatory; 7 } 5 8 .verticalGallery { 6 9 width: 100vw; … … 8 11 margin: 0; 9 12 padding: 0; 10 scroll-snap-type: y mandatory;11 13 } 12 14 .colorBox { -
trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe-legacy.html
r269505 r269506 11 11 position: absolute; 12 12 scroll-snap-type: y proximity; 13 -webkit-scroll-snap-type: proximity;14 scroll-snap-type: proximity;15 13 } 16 14 … … 21 19 opacity: 0.5; 22 20 scroll-snap-align: start; 23 -webkit-scroll-snap-coordinate: 0 0;24 scroll-snap-coordinate: 0 0;25 21 } 26 22 -
trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe.html
r235893 r269506 3 3 <head> 4 4 <style> 5 html { 6 scroll-snap-type: y proximity; 7 } 5 8 body { 6 9 margin: 0; … … 10 13 overflow-y: scroll; 11 14 position: absolute; 12 scroll-snap-type: y proximity;13 -webkit-scroll-snap-type: proximity;14 scroll-snap-type: proximity;15 15 } 16 16 … … 21 21 opacity: 0.5; 22 22 scroll-snap-align: start; 23 -webkit-scroll-snap-coordinate: 0 0;24 scroll-snap-coordinate: 0 0;25 23 } 26 24 -
trunk/Source/WebCore/ChangeLog
r269503 r269506 1 2020-11-06 Martin Robinson <mrobinson@igalia.com> 2 3 Scroll snap specified on :root doesn't work 4 https://bugs.webkit.org/show_bug.cgi?id=210469 5 <rdar://problem/61746676> 6 7 Properly handle scroll-snap-type on the root element. 8 9 This change is originally based on a patch by Simon Fraser. 10 11 Reviewed by Simon Fraser. 12 13 Tests: tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-legacy.html 14 tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-legacy.html 15 tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-mainframe-legacy.html 16 17 * page/FrameView.cpp: 18 (WebCore::FrameView::updateSnapOffsets): Send the body or root element style depending 19 on where the scroll-snap properties are set, but always use the FrameView viewport 20 when calculating geometry for scroll snap. 21 * page/scrolling/AxisScrollSnapOffsets.cpp: 22 (WebCore::updateSnapOffsetsForScrollableArea): Accept a viewport rectangle from the 23 caller and also eliminate redundant argument that was causing a bit of confusion. 24 * page/scrolling/AxisScrollSnapOffsets.h: Update the function declaration. 25 * platform/ScrollableArea.cpp: 26 (WebCore::ScrollableArea::clearSnapOffsets): Added a helper to clear both vertical and horizontal snap info. 27 * platform/ScrollableArea.h: 28 * rendering/RenderBox.cpp: 29 (WebCore::RenderBox::findEnclosingScrollableContainerForSnapping const): Renamed findEnclosingScrollableContainer 30 to this because now it is only useful for scroll snapping. The only preexisting caller was 31 the scroll snap code. 32 (WebCore::RenderBox::findEnclosingScrollableContainer const): Deleted. 33 * rendering/RenderBox.h: Updated method name. 34 * rendering/RenderLayer.cpp: 35 (WebCore::RenderLayer::updateSnapOffsets): Update to reflect changes to updateSnapOffsetsForScrollableArea. 36 * rendering/RenderObject.cpp: 37 (WebCore::RenderObject::enclosingScrollableContainerForSnapping const): Always return the 38 document root as the container instead of the body. The body never captures scroll 39 snap points. 40 1 41 2020-11-05 Said Abou-Hallawa <said@apple.com> 2 42 -
trunk/Source/WebCore/page/FrameView.cpp
r269437 r269506 920 920 return; 921 921 922 // FIXME: Should we allow specifying snap points through <html> tags too? 923 HTMLElement* body = frame().document()->bodyOrFrameset(); 924 if (!renderView() || !body || !body->renderer()) 925 return; 926 927 updateSnapOffsetsForScrollableArea(*this, *body, *renderView(), body->renderer()->style()); 922 auto& document = *frame().document(); 923 auto* documentElement = document.documentElement(); 924 RenderBox* bodyRenderer = document.bodyOrFrameset() ? document.bodyOrFrameset()->renderBox() : nullptr; 925 RenderBox* rootRenderer = documentElement ? documentElement->renderBox() : nullptr; 926 auto rendererSyleHasScrollSnap = [](const RenderObject* renderer) { 927 return renderer && renderer->style().scrollSnapType().strictness != ScrollSnapStrictness::None; 928 }; 929 930 const RenderStyle* styleToUse = nullptr; 931 if (rendererSyleHasScrollSnap(bodyRenderer)) { 932 // The specification doesn't allow setting scroll-snap-type on the body, but 933 // we do this to ensure backwards compatibility with an earlier version of the 934 // specification: See webkit.org/b/200643. 935 styleToUse = &bodyRenderer->style(); 936 } else if (rendererSyleHasScrollSnap(rootRenderer)) 937 styleToUse = &rootRenderer->style(); 938 939 if (!styleToUse || !documentElement) { 940 clearSnapOffsets(); 941 return; 942 } 943 944 LayoutRect viewport = LayoutRect(IntPoint(), baseLayoutViewportSize()); 945 updateSnapOffsetsForScrollableArea(*this, *rootRenderer, *styleToUse, viewport); 928 946 } 929 947 -
trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp
r268889 r269506 161 161 } 162 162 163 void updateSnapOffsetsForScrollableArea(ScrollableArea& scrollableArea, HTMLElement& scrollingElement, const RenderBox& scrollingElementBox, const RenderStyle& scrollingElementStyle) 164 { 165 auto* scrollContainer = scrollingElement.renderer(); 163 void updateSnapOffsetsForScrollableArea(ScrollableArea& scrollableArea, const RenderBox& scrollingElementBox, const RenderStyle& scrollingElementStyle, LayoutRect viewportRectInBorderBoxCoordinates) 164 { 166 165 auto scrollSnapType = scrollingElementStyle.scrollSnapType(); 167 if (!scrollContainer || scrollSnapType.strictness == ScrollSnapStrictness::None || scrollContainer->view().boxesWithScrollSnapPositions().isEmpty()) {168 scrollableArea.clearHorizontalSnapOffsets();169 scrollableArea.clear VerticalSnapOffsets();166 const auto& boxesWithScrollSnapPositions = scrollingElementBox.view().boxesWithScrollSnapPositions(); 167 if (scrollSnapType.strictness == ScrollSnapStrictness::None || boxesWithScrollSnapPositions.isEmpty()) { 168 scrollableArea.clearSnapOffsets(); 170 169 return; 171 170 } … … 185 184 186 185 // The bounds of the scrolling container's snap port, where the top left of the scrolling container's border box is the origin. 187 auto scrollSnapPort = computeScrollSnapPortOrAreaRect( scrollingElementBox.paddingBoxRect(), scrollingElementStyle.scrollPadding(), InsetOrOutset::Inset);186 auto scrollSnapPort = computeScrollSnapPortOrAreaRect(viewportRectInBorderBoxCoordinates, scrollingElementStyle.scrollPadding(), InsetOrOutset::Inset); 188 187 LOG_WITH_STREAM(ScrollSnap, stream << "Computing scroll snap offsets for " << scrollableArea << " in snap port " << scrollSnapPort); 189 for (auto* child : scrollContainer->view().boxesWithScrollSnapPositions()) {190 if (child->enclosingScrollableContainerForSnapping() != scrollContainer)188 for (auto* child : boxesWithScrollSnapPositions) { 189 if (child->enclosingScrollableContainerForSnapping() != &scrollingElementBox) 191 190 continue; 192 191 … … 194 193 // The snap area is the bounding box of the child element's border box, after applying transformations. 195 194 // FIXME: For now, just consider whether the scroller is RTL. The behavior of LTR boxes inside a RTL scroller is poorly defined: https://github.com/w3c/csswg-drafts/issues/5361. 196 auto scrollSnapArea = LayoutRect(child->localToContainerQuad(FloatQuad(child->borderBoundingBox()), scrollingElement.renderBox()).boundingBox());195 auto scrollSnapArea = LayoutRect(child->localToContainerQuad(FloatQuad(child->borderBoundingBox()), &scrollingElementBox).boundingBox()); 197 196 198 197 // localToContainerQuad will transform the scroll snap area by the scroll position, except in the case that this position is -
trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.h
r222113 r269506 28 28 #if ENABLE(CSS_SCROLL_SNAP) 29 29 30 #include "LayoutRect.h" 30 31 #include "LayoutUnit.h" 31 32 #include "ScrollSnapOffsetsInfo.h" … … 40 41 class ScrollableArea; 41 42 42 void updateSnapOffsetsForScrollableArea(ScrollableArea&, HTMLElement& scrollingElement, const RenderBox& scrollingElementBox, const RenderStyle& scrollingElementStyle); 43 // Update the snap offsets for this scrollable area, given the RenderBox of the scroll container, the RenderStyle 44 // which defines the scroll-snap properties, and the viewport rectangle with the origin at the top left of 45 // the scrolling container's border box. 46 void updateSnapOffsetsForScrollableArea(ScrollableArea&, const RenderBox& scrollingElementBox, const RenderStyle& scrollingElementStyle, LayoutRect viewportRectInBorderBoxCoordinates); 43 47 44 48 const unsigned invalidSnapOffsetIndex = UINT_MAX; -
trunk/Source/WebCore/platform/ScrollableArea.cpp
r269437 r269506 531 531 } 532 532 533 void ScrollableArea::clearSnapOffsets() 534 { 535 clearHorizontalSnapOffsets(); 536 clearVerticalSnapOffsets(); 537 } 538 533 539 void ScrollableArea::clearHorizontalSnapOffsets() 534 540 { -
trunk/Source/WebCore/platform/ScrollableArea.h
r269437 r269506 97 97 void setHorizontalSnapOffsetRanges(const Vector<ScrollOffsetRange<LayoutUnit>>&); 98 98 void setVerticalSnapOffsetRanges(const Vector<ScrollOffsetRange<LayoutUnit>>&); 99 void clearSnapOffsets(); 99 100 void clearHorizontalSnapOffsets(); 100 101 void clearVerticalSnapOffsets(); -
trunk/Source/WebCore/rendering/RenderBox.cpp
r269450 r269506 5034 5034 } 5035 5035 5036 const RenderBox* RenderBox::findEnclosingScrollableContainer () const5036 const RenderBox* RenderBox::findEnclosingScrollableContainerForSnapping() const 5037 5037 { 5038 5038 for (auto& candidate : lineageOfType<RenderBox>(*this)) { … … 5040 5040 return &candidate; 5041 5041 } 5042 // If all parent elements are not overflow scrollable, check the body. 5043 // FIXME: We should not treat the body as the scrollable element (see webkit.org/b/210469). 5044 if (document().body() && frame().view() && frame().view()->isScrollable()) 5045 return document().body()->renderBox(); 5046 5042 5043 // If all parent elements are not overflow scrollable and the frame is, then return 5044 // the root element. 5045 if (document().documentElement() && frame().view() && frame().view()->isScrollable()) 5046 return document().documentElement()->renderBox(); 5047 5047 5048 return nullptr; 5048 5049 } -
trunk/Source/WebCore/rendering/RenderBox.h
r269144 r269506 638 638 virtual bool needsLayoutAfterFragmentRangeChange() const { return false; } 639 639 640 const RenderBox* findEnclosingScrollableContainer () const;640 const RenderBox* findEnclosingScrollableContainerForSnapping() const; 641 641 642 642 bool isGridItem() const { return parent() && parent()->isRenderGrid() && !isExcludedFromNormalLayout(); } -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r269070 r269506 3593 3593 3594 3594 RenderBox* box = enclosingElement()->renderBox(); 3595 updateSnapOffsetsForScrollableArea(*this, * downcast<HTMLElement>(enclosingElement()), *box, box->style());3595 updateSnapOffsetsForScrollableArea(*this, *box, box->style(), box->paddingBoxRect()); 3596 3596 } 3597 3597 -
trunk/Source/WebCore/rendering/RenderObject.cpp
r269442 r269506 456 456 { 457 457 auto& renderBox = enclosingBox(); 458 if (auto* scrollableContainer = renderBox.findEnclosingScrollableContainer ()) {458 if (auto* scrollableContainer = renderBox.findEnclosingScrollableContainerForSnapping()) { 459 459 // The scrollable container for snapping cannot be the node itself. 460 460 if (scrollableContainer != this) 461 461 return scrollableContainer; 462 462 if (renderBox.parentBox()) 463 return renderBox.parentBox()->findEnclosingScrollableContainer ();463 return renderBox.parentBox()->findEnclosingScrollableContainerForSnapping(); 464 464 } 465 465 return nullptr;
Note: See TracChangeset
for help on using the changeset viewer.