Changeset 84296 in webkit


Ignore:
Timestamp:
Apr 19, 2011 2:30:54 PM (13 years ago)
Author:
Beth Dakin
Message:

https://bugs.webkit.org/show_bug.cgi?id=57898
REGRESSION (r82185): Scroll position not restored on navigation back to a page in
the page cache
-and corresponding-
<rdar://problem/9226652>

Reviewed by Maciej Stachowiak.

Source/WebCore:

Setting the contentsSize of a ScrollView to (0, 0) necessarily causes the scroll
position to be lost. (The scroll position is computed based on the
visibleContentSize.) This patch provides a mechanism to cache the current scroll
position, and then the HistoryController accesses only the cached position rather
than calling scrollPosition() which does a computation based on the
visibleContentSize.

  • loader/HistoryController.cpp:

(WebCore::HistoryController::saveScrollPositionAndViewStateToItem):

  • page/FrameView.cpp:

(WebCore::FrameView::resetScrollbarsAndClearContentsSize):

  • platform/ScrollView.h:

(WebCore::ScrollView::cacheCurrentScrollPosition):
(WebCore::ScrollView::cachedScrollPosition):

LayoutTests:

  • fast/loader/resources/empty-document-goes-back.html: Added.
  • fast/loader/scroll-position-restored-on-back-expected.txt: Added.
  • fast/loader/scroll-position-restored-on-back.html: Added.
Location:
trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r84292 r84296  
     12011-04-19  Beth Dakin  <bdakin@apple.com>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=57898
     6        REGRESSION (r82185): Scroll position not restored on navigation back to a page in
     7        the page cache
     8        -and corresponding-
     9        <rdar://problem/9226652>
     10
     11        * fast/loader/resources/empty-document-goes-back.html: Added.
     12        * fast/loader/scroll-position-restored-on-back-expected.txt: Added.
     13        * fast/loader/scroll-position-restored-on-back.html: Added.
     14
    1152011-04-19  Ryosuke Niwa  <rniwa@webkit.org>
    216
  • trunk/Source/WebCore/ChangeLog

    r84290 r84296  
     12011-04-19  Beth Dakin  <bdakin@apple.com>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=57898
     6        REGRESSION (r82185): Scroll position not restored on navigation back to a page in
     7        the page cache
     8        -and corresponding-
     9        <rdar://problem/9226652>
     10
     11        Setting the contentsSize of a ScrollView to (0, 0) necessarily causes the scroll
     12        position to be lost. (The scroll position is computed based on the
     13        visibleContentSize.) This patch provides a mechanism to cache the current scroll
     14        position, and then the HistoryController accesses only the cached position rather
     15        than calling scrollPosition() which does a computation based on the
     16        visibleContentSize.
     17
     18        * loader/HistoryController.cpp:
     19        (WebCore::HistoryController::saveScrollPositionAndViewStateToItem):
     20        * page/FrameView.cpp:
     21        (WebCore::FrameView::resetScrollbarsAndClearContentsSize):
     22        * platform/ScrollView.h:
     23        (WebCore::ScrollView::cacheCurrentScrollPosition):
     24        (WebCore::ScrollView::cachedScrollPosition):
     25
    1262011-04-19  Renata Hodovan  <reni@webkit.org>
    227
  • trunk/Source/WebCore/loader/HistoryController.cpp

    r83547 r84296  
    8080        return;
    8181       
    82     item->setScrollPoint(m_frame->view()->scrollPosition());
     82    item->setScrollPoint(m_frame->view()->cachedScrollPosition());
    8383    item->setPageScaleFactor(m_frame->pageScaleFactor());
    8484   
  • trunk/Source/WebCore/page/FrameView.cpp

    r84066 r84296  
    259259void FrameView::resetScrollbarsAndClearContentsSize()
    260260{
     261    // Since the contents size is being cleared, the scroll position will lost as a consequence.
     262    // Cache the scroll position so it can be restored by the page cache if necessary.
     263    cacheCurrentScrollPosition();
     264
    261265    resetScrollbars();
    262266
  • trunk/Source/WebCore/platform/ScrollView.h

    r83899 r84296  
    180180    IntSize overhangAmount() const;
    181181
     182    void cacheCurrentScrollPosition() { m_cachedScrollPosition = scrollPosition(); }
     183    IntPoint cachedScrollPosition() const { return m_cachedScrollPosition; }
     184
    182185    // Functions for scrolling the view.
    183186    void setScrollPosition(const IntPoint&);
     
    339342    IntRect m_actualVisibleContentRect;
    340343    IntSize m_scrollOffset; // FIXME: Would rather store this as a position, but we will wait to make this change until more code is shared.
     344    IntPoint m_cachedScrollPosition;
    341345    IntSize m_fixedLayoutSize;
    342346    IntSize m_contentsSize;
Note: See TracChangeset for help on using the changeset viewer.