Changeset 171560 in webkit


Ignore:
Timestamp:
Jul 24, 2014 5:24:56 PM (10 years ago)
Author:
Simon Fraser
Message:

[iOS WK2] Header bar on nytimes articles lands in the wrong place after rubberbanding
https://bugs.webkit.org/show_bug.cgi?id=135221
<rdar://problem/17542454>

Reviewed by Benjamin Poulain.

The call to didCommitLayerTree() can cause one or two visible rect updates,
via changes to the UIScrollView contentSize and contentOffset. As a result, we
would notify the scrolling tree about a viewport change, but using the old
scrolling tree rather than the new one, so we could move layers around for
nodes which are about to be removed from the tree.

However, we also have to ensure that programmatic scrolls are applied after
didCommitLayerTree() has updated the view size, so have RemoteScrollingCoordinatorProxy
store data about programmatic scrolls and return them to the caller, which
can apply them after didCommitLayerTree().

  • UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp: Store a pointer to a RequestedScrollInfo

for the duration of the tree update, so that we can store requested scroll info in it.
(WebKit::RemoteScrollingCoordinatorProxy::RemoteScrollingCoordinatorProxy):
(WebKit::RemoteScrollingCoordinatorProxy::updateScrollingTree):
(WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeNodeRequestsScroll):

  • UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::didCommitLayerTree): Give Mac a stub implementation.

  • UIProcess/WebPageProxy.h: Group some editing-related functions together.

(WebKit::WebPageProxy::editorState):
(WebKit::WebPageProxy::canDelete):
(WebKit::WebPageProxy::hasSelectedRange):
(WebKit::WebPageProxy::isContentEditable):
(WebKit::WebPageProxy::maintainsInactiveSelection):

  • UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:

(WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree): Ordering change: update
the layer tree, then call didCommitLayerTree(), then do the viewport update, followed
by any programmatic scroll.

Location:
trunk/Source/WebKit2
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r171557 r171560  
     12014-07-24  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS WK2] Header bar on nytimes articles lands in the wrong place after rubberbanding
     4        https://bugs.webkit.org/show_bug.cgi?id=135221
     5        <rdar://problem/17542454>
     6
     7        Reviewed by Benjamin Poulain.
     8       
     9        The call to didCommitLayerTree() can cause one or two visible rect updates,
     10        via changes to the UIScrollView contentSize and contentOffset. As a result, we
     11        would notify the scrolling tree about a viewport change, but using the old
     12        scrolling tree rather than the new one, so we could move layers around for
     13        nodes which are about to be removed from the tree.
     14       
     15        However, we also have to ensure that programmatic scrolls are applied after
     16        didCommitLayerTree() has updated the view size, so have RemoteScrollingCoordinatorProxy
     17        store data about programmatic scrolls and return them to the caller, which
     18        can apply them after didCommitLayerTree().
     19
     20        * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp: Store a pointer to a RequestedScrollInfo
     21        for the duration of the tree update, so that we can store requested scroll info in it.
     22        (WebKit::RemoteScrollingCoordinatorProxy::RemoteScrollingCoordinatorProxy):
     23        (WebKit::RemoteScrollingCoordinatorProxy::updateScrollingTree):
     24        (WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeNodeRequestsScroll):
     25        * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
     26        * UIProcess/WebPageProxy.cpp:
     27        (WebKit::WebPageProxy::didCommitLayerTree): Give Mac a stub implementation.
     28        * UIProcess/WebPageProxy.h: Group some editing-related functions together.
     29        (WebKit::WebPageProxy::editorState):
     30        (WebKit::WebPageProxy::canDelete):
     31        (WebKit::WebPageProxy::hasSelectedRange):
     32        (WebKit::WebPageProxy::isContentEditable):
     33        (WebKit::WebPageProxy::maintainsInactiveSelection):
     34        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
     35        (WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree): Ordering change: update
     36        the layer tree, then call didCommitLayerTree(), then do the viewport update, followed
     37        by any programmatic scroll.
     38
    1392014-07-24  Peyton Randolph  <prandolph@apple.com>
    240
  • trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp

    r171532 r171560  
    5050    : m_webPageProxy(webPageProxy)
    5151    , m_scrollingTree(RemoteScrollingTree::create(*this))
     52    , m_requestedScrollInfo(nullptr)
    5253    , m_propagatesMainFrameScrolls(true)
    5354{
     
    7879}
    7980
    80 void RemoteScrollingCoordinatorProxy::updateScrollingTree(const RemoteScrollingCoordinatorTransaction& transaction)
     81void RemoteScrollingCoordinatorProxy::updateScrollingTree(const RemoteScrollingCoordinatorTransaction& transaction, RequestedScrollInfo& requestedScrollInfo)
    8182{
     83    m_requestedScrollInfo = &requestedScrollInfo;
     84
    8285    OwnPtr<ScrollingStateTree> stateTree = const_cast<RemoteScrollingCoordinatorTransaction&>(transaction).scrollingStateTree().release();
    8386   
     
    9093    connectStateNodeLayers(*stateTree, *layerTreeHost);
    9194    m_scrollingTree->commitNewTreeState(stateTree.release());
     95
     96    m_requestedScrollInfo = nullptr;
    9297}
    9398
     
    170175void RemoteScrollingCoordinatorProxy::scrollingTreeNodeRequestsScroll(ScrollingNodeID scrolledNodeID, const FloatPoint& scrollPosition, bool representsProgrammaticScroll)
    171176{
    172     if (scrolledNodeID == rootScrollingNodeID())
    173         m_webPageProxy.requestScroll(scrollPosition, representsProgrammaticScroll);
     177    if (scrolledNodeID == rootScrollingNodeID() && m_requestedScrollInfo) {
     178        m_requestedScrollInfo->requestsScrollPositionUpdate = true;
     179        m_requestedScrollInfo->requestIsProgrammaticScroll = representsProgrammaticScroll;
     180        m_requestedScrollInfo->requestedScrollPosition = scrollPosition;
     181    }
    174182}
    175183
  • trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h

    r171532 r171560  
    6969    const RemoteLayerTreeHost* layerTreeHost() const;
    7070
    71     void updateScrollingTree(const RemoteScrollingCoordinatorTransaction&);
     71    struct RequestedScrollInfo {
     72        bool requestsScrollPositionUpdate { };
     73        bool requestIsProgrammaticScroll { };
     74        WebCore::FloatPoint requestedScrollPosition;
     75    };
     76    void updateScrollingTree(const RemoteScrollingCoordinatorTransaction&, RequestedScrollInfo&);
    7277
    7378    void setPropagatesMainFrameScrolls(bool propagatesMainFrameScrolls) { m_propagatesMainFrameScrolls = propagatesMainFrameScrolls; }
     
    8792    WebPageProxy& m_webPageProxy;
    8893    RefPtr<RemoteScrollingTree> m_scrollingTree;
     94    RequestedScrollInfo* m_requestedScrollInfo;
    8995    bool m_propagatesMainFrameScrolls;
    9096};
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r171471 r171560  
    13141314    m_process->send(Messages::WebPage::ExecuteEditCommand(commandName), m_pageID);
    13151315}
    1316    
     1316
     1317#if !PLATFORM(IOS)
     1318void WebPageProxy::didCommitLayerTree(const RemoteLayerTreeTransaction&)
     1319{
     1320}
     1321#endif
     1322
    13171323#if USE(TILED_BACKING_STORE)
    13181324void WebPageProxy::commitPageTransitionViewport()
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r171471 r171560  
    378378    void executeEditCommand(const String& commandName);
    379379    void validateCommand(const String& commandName, std::function<void (const String&, bool, int32_t, CallbackBase::Error)>);
     380
     381    const EditorState& editorState() const { return m_editorState; }
     382    bool canDelete() const { return hasSelectedRange() && isContentEditable(); }
     383    bool hasSelectedRange() const { return m_editorState.selectionIsRange; }
     384    bool isContentEditable() const { return m_editorState.isContentEditable; }
     385   
     386    bool maintainsInactiveSelection() const { return m_maintainsInactiveSelection; }
     387    void setMaintainsInactiveSelection(bool);
     388
    380389#if PLATFORM(IOS)
    381390    void executeEditCommand(const String& commandName, std::function<void (CallbackBase::Error)>);
     
    403412    int32_t deviceOrientation() const { return m_deviceOrientation; }
    404413    void willCommitLayerTree(uint64_t transactionID);
    405     void didCommitLayerTree(const WebKit::RemoteLayerTreeTransaction&);
    406414
    407415    void selectWithGesture(const WebCore::IntPoint, WebCore::TextGranularity, uint32_t gestureType, uint32_t gestureState, std::function<void (const WebCore::IntPoint&, uint32_t, uint32_t, uint32_t, CallbackBase::Error)>);
     
    443451#endif
    444452
    445     const EditorState& editorState() const { return m_editorState; }
    446     bool canDelete() const { return hasSelectedRange() && isContentEditable(); }
    447     bool hasSelectedRange() const { return m_editorState.selectionIsRange; }
    448     bool isContentEditable() const { return m_editorState.isContentEditable; }
    449    
    450     bool maintainsInactiveSelection() const { return m_maintainsInactiveSelection; }
    451     void setMaintainsInactiveSelection(bool);
     453    void didCommitLayerTree(const WebKit::RemoteLayerTreeTransaction&);
     454
    452455#if USE(TILED_BACKING_STORE)
    453456    void didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect);
  • trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm

    r171532 r171560  
    201201        m_webPageProxy->setAcceleratedCompositingRootLayer(m_remoteLayerTreeHost.rootLayer());
    202202
    203 #if PLATFORM(IOS)
     203#if ENABLE(ASYNC_SCROLLING)
     204    RemoteScrollingCoordinatorProxy::RequestedScrollInfo requestedScrollInfo;
     205    m_webPageProxy->scrollingCoordinatorProxy()->updateScrollingTree(scrollingTreeTransaction, requestedScrollInfo);
     206#endif
     207
    204208    m_webPageProxy->didCommitLayerTree(layerTreeTransaction);
    205 #endif
    206209
    207210#if ENABLE(ASYNC_SCROLLING)
    208     m_webPageProxy->scrollingCoordinatorProxy()->updateScrollingTree(scrollingTreeTransaction);
    209 
    210211#if PLATFORM(IOS)
    211212    if (m_webPageProxy->scrollingCoordinatorProxy()->hasFixedOrSticky()) {
     213        // If we got a new layer for a fixed or sticky node, its position from the WebProcess is probably stale. We need to re-run the "viewport" changed logic to udpate it with our UI-side state.
    212214        FloatRect customFixedPositionRect = m_webPageProxy->computeCustomFixedPositionRect(m_webPageProxy->unobscuredContentRect(), m_webPageProxy->displayedContentScale());
    213         // If we got a new layer for a fixed or sticky node, its position from the WebProcess is probably stale. We need to re-run the "viewport" changed logic to udpate it with our UI-side state.
    214215        m_webPageProxy->scrollingCoordinatorProxy()->viewportChangedViaDelegatedScrolling(m_webPageProxy->scrollingCoordinatorProxy()->rootScrollingNodeID(), customFixedPositionRect, m_webPageProxy->displayedContentScale());
    215216    }
    216217#endif
     218
     219    // Handle requested scroll position updates from the scrolling tree transaction after didCommitLayerTree()
     220    // has updated the view size based on the content size.
     221    if (requestedScrollInfo.requestsScrollPositionUpdate)
     222        m_webPageProxy->requestScroll(requestedScrollInfo.requestedScrollPosition, requestedScrollInfo.requestIsProgrammaticScroll);
    217223#endif // ENABLE(ASYNC_SCROLLING)
    218224
Note: See TracChangeset for help on using the changeset viewer.