Changeset 169913 in webkit


Ignore:
Timestamp:
Jun 12, 2014 3:24:13 PM (10 years ago)
Author:
Simon Fraser
Message:

[iOS WK2] Fix crash on back/foward swipe
https://bugs.webkit.org/show_bug.cgi?id=133826
<rdar://problem/17032752>

Reviewed by Tim Horton.

AsyncScrollingCoordinator::frameViewForScrollingNode() would crash with a null root
state node, because HistoryController::restoreScrollPositionAndViewState() tried
to restore scroll position (via restoreViewState()) before hooking up the scrolling
coordinator.

Fix by doing the scrollingCoordinator->frameViewRootLayerDidChange() before
calling restoreViewState().

Also add a defensive null-check on the root state node in updateScrollPositionAfterAsyncScrollTimerFired().

  • loader/HistoryController.cpp:

(WebCore::HistoryController::restoreScrollPositionAndViewState):

  • page/scrolling/AsyncScrollingCoordinator.cpp:

(WebCore::AsyncScrollingCoordinator::frameViewForScrollingNode):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r169911 r169913  
     12014-06-12  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS WK2] Fix crash on back/foward swipe
     4        https://bugs.webkit.org/show_bug.cgi?id=133826
     5        <rdar://problem/17032752>
     6
     7        Reviewed by Tim Horton.
     8
     9        AsyncScrollingCoordinator::frameViewForScrollingNode() would crash with a null root
     10        state node, because HistoryController::restoreScrollPositionAndViewState() tried
     11        to restore scroll position (via restoreViewState()) before hooking up the scrolling
     12        coordinator.
     13       
     14        Fix by doing the scrollingCoordinator->frameViewRootLayerDidChange() before
     15        calling restoreViewState().
     16       
     17        Also add a defensive null-check on the root state node in updateScrollPositionAfterAsyncScrollTimerFired().
     18
     19        * loader/HistoryController.cpp:
     20        (WebCore::HistoryController::restoreScrollPositionAndViewState):
     21        * page/scrolling/AsyncScrollingCoordinator.cpp:
     22        (WebCore::AsyncScrollingCoordinator::frameViewForScrollingNode):
     23
    1242014-06-12  Anders Carlsson  <andersca@apple.com>
    225
  • trunk/Source/WebCore/loader/HistoryController.cpp

    r169603 r169913  
    125125    if (!m_currentItem)
    126126        return;
    127    
    128     // FIXME: It would be great to work out a way to put this code in WebCore instead of calling
    129     // through to the client. It's currently used only for the PDF view on Mac.
    130     m_frame.loader().client().restoreViewState();
     127
     128    FrameView* view = m_frame.view();
    131129
    132130    // FIXME: There is some scrolling related work that needs to happen whenever a page goes into the
     
    135133    // Document::setIsInPageCache(bool). It would be nice if there was more symmetry in these spots.
    136134    // https://bugs.webkit.org/show_bug.cgi?id=98698
    137     if (FrameView* view = m_frame.view()) {
     135    if (view) {
    138136        Page* page = m_frame.page();
    139137        if (page && m_frame.isMainFrame()) {
     
    141139                scrollingCoordinator->frameViewRootLayerDidChange(view);
    142140        }
     141    }
     142
     143    // FIXME: It would be great to work out a way to put this code in WebCore instead of calling
     144    // through to the client.
     145    m_frame.loader().client().restoreViewState();
    143146
    144147#if !PLATFORM(IOS)
    145         // Don't restore scroll point on iOS as FrameLoaderClient::restoreViewState() does that.
    146         if (!view->wasScrolledByUser()) {
    147             if (page && m_frame.isMainFrame() && m_currentItem->pageScaleFactor())
    148                 page->setPageScaleFactor(m_currentItem->pageScaleFactor(), m_currentItem->scrollPoint());
    149             else
    150                 view->setScrollPosition(m_currentItem->scrollPoint());
    151         }
     148    // Don't restore scroll point on iOS as FrameLoaderClient::restoreViewState() does that.
     149    if (view && !view->wasScrolledByUser()) {
     150        if (page && m_frame.isMainFrame() && m_currentItem->pageScaleFactor())
     151            page->setPageScaleFactor(m_currentItem->pageScaleFactor(), m_currentItem->scrollPoint());
     152        else
     153            view->setScrollPosition(m_currentItem->scrollPoint());
     154    }
    152155#endif
    153     }
    154156}
    155157
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp

    r169733 r169913  
    198198FrameView* AsyncScrollingCoordinator::frameViewForScrollingNode(ScrollingNodeID scrollingNodeID) const
    199199{
     200    if (!m_scrollingStateTree->rootStateNode())
     201        return nullptr;
     202   
    200203    if (scrollingNodeID == m_scrollingStateTree->rootStateNode()->scrollingNodeID())
    201204        return m_page->mainFrame().view();
Note: See TracChangeset for help on using the changeset viewer.