Changeset 278193 in webkit


Ignore:
Timestamp:
May 28, 2021 1:59:20 AM (14 months ago)
Author:
Martin Robinson
Message:

More readily layout when scroll-snap properties change
https://bugs.webkit.org/show_bug.cgi?id=225950

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

  • web-platform-tests/css/css-scroll-snap/scroll-snap-type-change-expected.txt: Updated expectation

for newly passing test.

Source/WebCore:

Do a layout when scroll-snap properties change instead of trying
to update scroll positions without a layout.

Test: css3/scroll-snap/scroll-snap-style-change-crash.html

  • rendering/RenderLayerModelObject.cpp:

(WebCore::RenderLayerModelObject::styleDidChange): Remove code dealing with scrollports
as this is now handled by the RenderStyle diff. Now trigger a layout for scrollports
when the scrolled children change their snap properties.

  • rendering/RenderObject.cpp:

(WebCore::RenderObject::enclosingScrollableContainerForSnapping const): Made this return a non-const.

  • rendering/RenderObject.h:
  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::changeRequiresLayout const): Added code to handle scrollport specific
properties.

LayoutTests:

  • css3/scroll-snap/scroll-snap-style-change-crash-expected.txt: Added.
  • css3/scroll-snap/scroll-snap-style-change-crash.html: Added.
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r278182 r278193  
     12021-05-28  Martin Robinson  <mrobinson@webkit.org>
     2
     3        More readily layout when scroll-snap properties change
     4        https://bugs.webkit.org/show_bug.cgi?id=225950
     5
     6        Reviewed by Simon Fraser.
     7
     8        * css3/scroll-snap/scroll-snap-style-change-crash-expected.txt: Added.
     9        * css3/scroll-snap/scroll-snap-style-change-crash.html: Added.
     10
    1112021-05-27  Amir Mark Jr  <amir_mark@apple.com>
    212
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r278188 r278193  
     12021-05-28  Martin Robinson  <mrobinson@webkit.org>
     2
     3        More readily layout when scroll-snap properties change
     4        https://bugs.webkit.org/show_bug.cgi?id=225950
     5
     6        Reviewed by Simon Fraser.
     7
     8        * web-platform-tests/css/css-scroll-snap/scroll-snap-type-change-expected.txt: Updated expectation
     9        for newly passing test.
     10
    1112021-05-27  Said Abou-Hallawa  <said@apple.com>
    212
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-snap-type-change-expected.txt

    r271480 r278193  
    11
    2 FAIL scroll-snap-type on HTML should control snapping behavior and changing it takes effect assert_equals: scrolling should not snap expected 100 but got 200
     2PASS scroll-snap-type on HTML should control snapping behavior and changing it takes effect
    33PASS scroll-snap-type on DIV should control snapping behavior and changing it takes effect
    44
  • trunk/Source/WebCore/ChangeLog

    r278190 r278193  
     12021-05-28  Martin Robinson  <mrobinson@webkit.org>
     2
     3        More readily layout when scroll-snap properties change
     4        https://bugs.webkit.org/show_bug.cgi?id=225950
     5
     6        Reviewed by Simon Fraser.
     7
     8        Do a layout when scroll-snap properties change instead of trying
     9        to update scroll positions without a layout.
     10
     11        Test: css3/scroll-snap/scroll-snap-style-change-crash.html
     12
     13        * rendering/RenderLayerModelObject.cpp:
     14        (WebCore::RenderLayerModelObject::styleDidChange): Remove code dealing with scrollports
     15        as this is now handled by the RenderStyle diff. Now trigger a layout for scrollports
     16        when the scrolled children change their snap properties.
     17        * rendering/RenderObject.cpp:
     18        (WebCore::RenderObject::enclosingScrollableContainerForSnapping const): Made this return a non-const.
     19        * rendering/RenderObject.h:
     20        * rendering/style/RenderStyle.cpp:
     21        (WebCore::RenderStyle::changeRequiresLayout const): Added code to handle scrollport specific
     22        properties.
     23
    1242021-05-27  Wenson Hsieh  <wenson_hsieh@apple.com>
    225
  • trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp

    r278185 r278193  
    108108}
    109109
    110 #if ENABLE(CSS_SCROLL_SNAP)
    111 static bool scrollSnapContainerRequiresUpdateForStyleUpdate(const RenderStyle& oldStyle, const RenderStyle& newStyle)
    112 {
    113     return oldStyle.scrollPadding() != newStyle.scrollPadding() || oldStyle.scrollSnapType() != newStyle.scrollSnapType();
    114 }
    115 #endif
    116 
    117110void RenderLayerModelObject::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
    118111{
     
    172165
    173166#if ENABLE(CSS_SCROLL_SNAP)
    174     if (oldStyle && scrollSnapContainerRequiresUpdateForStyleUpdate(*oldStyle, newStyle)) {
    175         if (RenderLayer* renderLayer = layer()) {
    176             if (auto* scrollableArea = renderLayer->scrollableArea()) {
    177                 scrollableArea->updateSnapOffsets();
    178                 scrollableArea->updateScrollSnapState();
    179             }
    180         } else if (isBody() || isDocumentElementRenderer()) {
    181             FrameView& frameView = view().frameView();
    182             frameView.updateSnapOffsets();
    183             frameView.updateScrollSnapState();
    184             frameView.updateScrollingCoordinatorScrollSnapProperties();
    185         }
    186     }
    187 
    188167    bool scrollMarginChanged = oldStyle && oldStyle->scrollMargin() != newStyle.scrollMargin();
    189168    bool scrollAlignChanged = oldStyle && oldStyle->scrollSnapAlign() != newStyle.scrollSnapAlign();
    190169    bool scrollSnapStopChanged = oldStyle && oldStyle->scrollSnapStop() != newStyle.scrollSnapStop();
    191170    if (scrollMarginChanged || scrollAlignChanged || scrollSnapStopChanged) {
    192         auto* scrollSnapBox = enclosingScrollableContainerForSnapping();
    193         if (scrollSnapBox && scrollSnapBox->layer()) {
    194             const RenderStyle& style = scrollSnapBox->style();
    195             if (style.scrollSnapType().strictness != ScrollSnapStrictness::None) {
    196                 if (auto* scrollableArea = scrollSnapBox->layer()->scrollableArea()) {
    197                     scrollableArea->updateSnapOffsets();
    198                     scrollableArea->updateScrollSnapState();
    199                 }
    200                 if (scrollSnapBox->isBody() || scrollSnapBox->isDocumentElementRenderer())
    201                     scrollSnapBox->view().frameView().updateSnapOffsets();
    202                     scrollSnapBox->view().frameView().updateScrollSnapState();
    203                     scrollSnapBox->view().frameView().updateScrollingCoordinatorScrollSnapProperties();
    204             }
    205         }
     171        if (auto* scrollSnapBox = enclosingScrollableContainerForSnapping())
     172            scrollSnapBox->setNeedsLayout();
    206173    }
    207174#endif
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r278185 r278193  
    470470}
    471471
    472 const RenderBox* RenderObject::enclosingScrollableContainerForSnapping() const
     472RenderBox* RenderObject::enclosingScrollableContainerForSnapping() const
    473473{
    474474    // Walk up the container chain to find the scrollable container that contains
  • trunk/Source/WebCore/rendering/RenderObject.h

    r278185 r278193  
    156156    WEBCORE_EXPORT RenderBox& enclosingBox() const;
    157157    RenderBoxModelObject& enclosingBoxModelObject() const;
    158     const RenderBox* enclosingScrollableContainerForSnapping() const;
     158    RenderBox* enclosingScrollableContainerForSnapping() const;
    159159
    160160    // Return our enclosing flow thread if we are contained inside one. Follows the containing block chain.
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r277538 r278193  
    952952            return true;
    953953    }
     954
     955#if ENABLE(CSS_SCROLL_SNAP)
     956    if (scrollPadding() != other.scrollPadding() || scrollSnapType() != other.scrollSnapType())
     957        return true;
     958#endif
    954959
    955960    return false;
Note: See TracChangeset for help on using the changeset viewer.