⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 288536 in webkit


Ignore:
Timestamp:
Jan 24, 2022, 8:59:14 PM (5 years ago)
Author:
Simon Fraser
Message:

REGRESSION (r286932): Fixed position elements jiggle sometimes (Twitter, Facebook)
​https://bugs.webkit.org/show_bug.cgi?id=235543
<rdar://87981122>

Reviewed by Tim Horton.

In r286932 we ensure that the scrolling layer's position gets committed in the scrolling
thread to reduce stutters. However, we also have to do the same for fixed and sticky
layers, because they need to committed in synchrony with the scrolling layer.

Also change some 'override' to 'final' and add locking annotations.

  • page/scrolling/cocoa/ScrollingTreeFixedNode.h:
  • page/scrolling/cocoa/ScrollingTreeFixedNode.mm:

(WebCore::ScrollingTreeFixedNode::applyLayerPositions):

  • page/scrolling/cocoa/ScrollingTreeStickyNodeCocoa.h:
  • page/scrolling/cocoa/ScrollingTreeStickyNodeCocoa.mm:

(WebCore::ScrollingTreeStickyNodeCocoa::applyLayerPositions):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r288532 r288536  
     12022-01-24  Simon Fraser  <simon.fraser@apple.com>
     2
     3        REGRESSION (r286932): Fixed position elements jiggle sometimes (Twitter, Facebook)
     4        https://bugs.webkit.org/show_bug.cgi?id=235543
     5        <rdar://87981122>
     6
     7        Reviewed by Tim Horton.
     8
     9        In r286932 we ensure that the scrolling layer's position gets committed in the scrolling
     10        thread to reduce stutters. However, we also have to do the same for fixed and sticky
     11        layers, because they need to committed in synchrony with the scrolling layer.
     12
     13        Also change some 'override' to 'final' and add locking annotations.
     14
     15        * page/scrolling/cocoa/ScrollingTreeFixedNode.h:
     16        * page/scrolling/cocoa/ScrollingTreeFixedNode.mm:
     17        (WebCore::ScrollingTreeFixedNode::applyLayerPositions):
     18        * page/scrolling/cocoa/ScrollingTreeStickyNodeCocoa.h:
     19        * page/scrolling/cocoa/ScrollingTreeStickyNodeCocoa.mm:
     20        (WebCore::ScrollingTreeStickyNodeCocoa::applyLayerPositions):
     21
    1222022-01-24  Diego Pino Garcia  <dpino@igalia.com>
    223
  • trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.h

    r284534 r288536  
    2929
    3030#include "ScrollingConstraints.h"
     31#include "ScrollingTree.h"
    3132#include "ScrollingTreeNode.h"
    3233#include <wtf/RetainPtr.h>
    … …  
    4748    ScrollingTreeFixedNode(ScrollingTree&, ScrollingNodeID);
    4849
    49     void commitStateBeforeChildren(const ScrollingStateNode&) override;
    50     void applyLayerPositions() override;
     50    void commitStateBeforeChildren(const ScrollingStateNode&) final;
     51    void applyLayerPositions() final WTF_REQUIRES_LOCK(scrollingTree().treeLock());
    5152
    52     void dumpProperties(WTF::TextStream&, OptionSet<ScrollingStateTreeAsTextBehavior>) const override;
     53    void dumpProperties(WTF::TextStream&, OptionSet<ScrollingStateTreeAsTextBehavior>) const final;
    5354
    5455    FixedPositionViewportConstraints m_constraints;
  • trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.mm

    r284920 r288536  
    3131#import "Logging.h"
    3232#import "ScrollingStateFixedNode.h"
     33#import "ScrollingThread.h"
    3334#import "ScrollingTree.h"
    3435#import "ScrollingTreeFrameScrollingNode.h"
    … …  
    127128    LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeFixedNode " << scrollingNodeID() << " relatedNodeScrollPositionDidChange: viewportRectAtLastLayout " << m_constraints.viewportRectAtLastLayout() << " last layer pos " << m_constraints.layerPositionAtLastLayout() << " layerPosition " << layerPosition);
    128129
     130#if ENABLE(SCROLLING_THREAD)
     131    if (ScrollingThread::isCurrentThread()) {
     132        // Match the behavior of ScrollingTreeFrameScrollingNodeMac::repositionScrollingLayers().
     133        if (!scrollingTree().isScrollingSynchronizedWithMainThread())
     134            [m_layer _web_setLayerTopLeftPosition:CGPointZero];
     135    }
     136#endif
     137
    129138    [m_layer _web_setLayerTopLeftPosition:layerPosition - m_constraints.alignmentOffset()];
    130139}
  • trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNodeCocoa.h

    r284920 r288536  
    2929
    3030#include "ScrollingConstraints.h"
     31#include "ScrollingTree.h"
    3132#include "ScrollingTreeStickyNode.h"
    3233#include <wtf/RetainPtr.h>
    … …  
    4748    ScrollingTreeStickyNodeCocoa(ScrollingTree&, ScrollingNodeID);
    4849
    49     void commitStateBeforeChildren(const ScrollingStateNode&) override;
    50     void applyLayerPositions() override;
    51     FloatPoint layerTopLeft() const override;
     50    void commitStateBeforeChildren(const ScrollingStateNode&) final;
     51    void applyLayerPositions() final WTF_REQUIRES_LOCK(scrollingTree().treeLock());
     52    FloatPoint layerTopLeft() const final;
    5253
    5354    RetainPtr<CALayer> m_layer;
  • trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNodeCocoa.mm

    r284920 r288536  
    3131#import "Logging.h"
    3232#import "ScrollingStateStickyNode.h"
     33#import "ScrollingThread.h"
    3334#import "ScrollingTree.h"
    3435#import "WebCoreCALayerExtras.h"
    … …  
    6364    LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeStickyNodeCocoa " << scrollingNodeID() << " constrainingRectAtLastLayout " << m_constraints.constrainingRectAtLastLayout() << " last layer pos " << m_constraints.layerPositionAtLastLayout() << " layerPosition " << layerPosition);
    6465
     66#if ENABLE(SCROLLING_THREAD)
     67    if (ScrollingThread::isCurrentThread()) {
     68        // Match the behavior of ScrollingTreeFrameScrollingNodeMac::repositionScrollingLayers().
     69        if (!scrollingTree().isScrollingSynchronizedWithMainThread())
     70            [m_layer _web_setLayerTopLeftPosition:CGPointZero];
     71    }
     72#endif
     73
    6574    [m_layer _web_setLayerTopLeftPosition:layerPosition - m_constraints.alignmentOffset()];
    6675}
Note: See TracChangeset for help on using the changeset viewer.