Changeset 21454 in webkit


Ignore:
Timestamp:
May 14, 2007 6:30:41 AM (17 years ago)
Author:
darin
Message:

Reviewed by Antti.

  • fix <rdar://problem/3109180> VIP: after go back, page jumps after loading even if I scrolled while loading
  • history/CachedPage.cpp: (WebCore::CachedPage::clear): Call clearFrame rather than clearPart -- the "part" term was leftover prehistoric terminology.
  • loader/FrameLoader.cpp: (WebCore::FrameLoader::open): Call setWasScrolledByUser(false) on the page, so that we can detect any user scrolling that happens during the "go back" process. (WebCore::FrameLoader::restoreScrollPositionAndViewState): Don't scroll if the view's wasScrolledByUser flag is set. (WebCore::FrameLoader::loadItem): Call setWasScrolledByUser(false) false when we do a new "load" (actually just a scroll) using the same frame. Also moved the line of code that sets m_currentHistoryItem to make this code path mroe similar to recursiveGoToItem. (WebCore::FrameLoader::recursiveGoToItem): Ditto.
  • page/Frame.cpp: (WebCore::Frame::~Frame): Call clearFrame rather than stting m_frame directly. (WebCore::Frame::sendScrollEvent): Call setWasScrolledByUser(true) on FrameView. The FrameView itself knows to ignore this if the scrolling is being done programmatically instead of by the user.
  • page/FrameView.h: Added wasScrolledByUser and setWasScrolledByUser. Also removed unneeded include and class forward declarations, renamed clearPart to clearFrame, removed uneeded function haveDelayedLayoutScheduled, and removed unneeded friend declarations.
  • page/FrameView.cpp: (WebCore::FrameViewPrivate::FrameViewPrivate): Added m_inProgrammaticScroll and m_wasScrolledByUser. (WebCore::FrameViewPrivate::reset): Set m_wasScrolledByUser to false. (WebCore::FrameView::clearFrame): Renamed from clearPart. (WebCore::FrameView::scrollRectIntoViewRecursively): Added code to set the m_inProgrammaticScroll flag. (WebCore::FrameView::setContentsPos): Ditto. (WebCore::FrameView::wasScrolledByUser): Added. (WebCore::FrameView::setWasScrolledByUser): Added. Does nothing if called when m_inProgrammaticScroll is true.
Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r21452 r21454  
     12007-05-14  Darin Adler  <darin@apple.com>
     2
     3        Reviewed by Antti.
     4
     5        - fix <rdar://problem/3109180> VIP: after go back, page jumps after loading even if I scrolled while loading
     6
     7        * history/CachedPage.cpp: (WebCore::CachedPage::clear): Call clearFrame rather than
     8        clearPart -- the "part" term was leftover prehistoric terminology.
     9
     10        * loader/FrameLoader.cpp:
     11        (WebCore::FrameLoader::open): Call setWasScrolledByUser(false) on the page, so that we
     12        can detect any user scrolling that happens during the "go back" process.
     13        (WebCore::FrameLoader::restoreScrollPositionAndViewState): Don't scroll if the view's
     14        wasScrolledByUser flag is set.
     15        (WebCore::FrameLoader::loadItem): Call setWasScrolledByUser(false) false when we do
     16        a new "load" (actually just a scroll) using the same frame. Also moved the line of code that
     17        sets m_currentHistoryItem to make this code path mroe similar to recursiveGoToItem.
     18        (WebCore::FrameLoader::recursiveGoToItem): Ditto.
     19
     20        * page/Frame.cpp:
     21        (WebCore::Frame::~Frame): Call clearFrame rather than stting m_frame directly.
     22        (WebCore::Frame::sendScrollEvent): Call setWasScrolledByUser(true) on FrameView. The FrameView
     23        itself knows to ignore this if the scrolling is being done programmatically instead of by the user.
     24
     25        * page/FrameView.h: Added wasScrolledByUser and setWasScrolledByUser. Also removed unneeded
     26        include and class forward declarations, renamed clearPart to clearFrame, removed uneeded function
     27        haveDelayedLayoutScheduled, and removed unneeded friend declarations.
     28        * page/FrameView.cpp:
     29        (WebCore::FrameViewPrivate::FrameViewPrivate): Added m_inProgrammaticScroll and m_wasScrolledByUser.
     30        (WebCore::FrameViewPrivate::reset): Set m_wasScrolledByUser to false.
     31        (WebCore::FrameView::clearFrame): Renamed from clearPart.
     32        (WebCore::FrameView::scrollRectIntoViewRecursively): Added code to set the m_inProgrammaticScroll flag.
     33        (WebCore::FrameView::setContentsPos): Ditto.
     34        (WebCore::FrameView::wasScrolledByUser): Added.
     35        (WebCore::FrameView::setWasScrolledByUser): Added. Does nothing if called when m_inProgrammaticScroll
     36        is true.
     37
    1382007-05-14  Darin Adler  <darin@apple.com>
    239
  • trunk/WebCore/history/CachedPage.cpp

    r21179 r21454  
    145145        }
    146146
    147         m_view->clearPart();
     147        m_view->clearFrame();
    148148    }
    149149
  • trunk/WebCore/loader/FrameLoader.cpp

    r21430 r21454  
    25592559    m_wasLoadEventEmitted = false;
    25602560    m_outgoingReferrer = URL.url();
    2561    
    2562     m_frame->setView(cachedPage.view());
     2561
     2562    FrameView* view = cachedPage.view();
     2563    if (view)
     2564        view->setWasScrolledByUser(false);
     2565    m_frame->setView(view);
    25632566   
    25642567    m_frame->setDocument(document);
     
    35893592    }
    35903593
    3591     LOG (History, "WebCoreHistory: Creating item for %s", url.url().ascii());
     3594    LOG(History, "WebCoreHistory: Creating item for %s", url.url().ascii());
    35923595   
    35933596    // Frames that have never successfully loaded any content
     
    36803683        return;
    36813684   
    3682     // FIXME: It would be great to work out a way to put this code in WebCore instead of calling through to the client.
     3685    // FIXME: It would be great to work out a way to put this code in WebCore instead of calling
     3686    // through to the client. It's currently used only for the PDF view on Mac.
    36833687    m_client->restoreViewState();
    36843688   
    3685     if (m_frame->view()) {
    3686         const IntPoint& scrollPoint = m_currentHistoryItem->scrollPoint();
    3687         m_frame->view()->setContentsPos(scrollPoint.x(), scrollPoint.y());
    3688     }
     3689    if (FrameView* view = m_frame->view())
     3690        if (!view->wasScrolledByUser()) {
     3691            const IntPoint& scrollPoint = m_currentHistoryItem->scrollPoint();
     3692            view->setContentsPos(scrollPoint.x(), scrollPoint.y());
     3693        }
    36893694}
    36903695
     
    37853790    // We also do not do anchor-style navigation if we're posting a form.
    37863791   
    3787     // FIXME: These checks don't match the ones in _loadURL:referrer:loadType:target:triggeringEvent:isFormSubmission:
    3788     // Perhaps they should.
    37893792    if (!formData && !shouldReload(itemURL, currentURL) && urlsMatchItem(item)) {
    3790 #if 0
    3791         // FIXME:  We need to normalize the code paths for anchor navigation.  Something
    3792         // like the following line of code should be done, but also accounting for correct
    3793         // updates to the back/forward list and scroll position.
    3794         // rjw 4/9/03 See 3223929.
    3795         [self _loadURL:itemURL referrer:[[[self dataSource] request] HTTPReferrer] loadType:loadType target:nil triggeringEvent:nil form:nil formValues:nil];
    3796 #endif
    3797 
    37983793        // Must do this maintenance here, since we don't go through a real page reload
    37993794        saveScrollPositionAndViewStateToItem(m_currentHistoryItem.get());
    38003795
    3801         // FIXME: form state might want to be saved here too
     3796        if (FrameView* view = m_frame->view())
     3797            view->setWasScrolledByUser(false);
     3798
     3799        m_currentHistoryItem = item;
     3800
     3801        // FIXME: Form state might need to be saved here too.
    38023802
    38033803        // We always call scrollToAnchor here, even if the URL doesn't have an
     
    38063806   
    38073807        // must do this maintenance here, since we don't go through a real page reload
    3808         m_currentHistoryItem = item;
    38093808        restoreScrollPositionAndViewState();
    38103809       
     
    38303829            double interval = currentTime() - cachedPage->timeStamp();
    38313830           
    3832             // FIXME: 1800 is the current backforwardcache expiration time, but we actually store as a pref -
    3833             // previously, this code was -
    3834             //if (interval <= [[getWebView(self) preferences] _backForwardCacheExpirationInterval]) {
     3831            // FIXME: 1800 should not be hardcoded, it should come from
     3832            // WebKitBackForwardCacheExpirationIntervalKey in WebKit.
     3833            // Or we should remove WebKitBackForwardCacheExpirationIntervalKey.
    38353834            if (interval <= 1800) {
    38363835                load(cachedPage->documentLoader(), loadType, 0);   
    38373836                inPageCache = true;
    38383837            } else {
    3839                 LOG (PageCache, "Not restoring page for %s from back/forward cache because cache entry has expired", m_provisionalHistoryItem->url().url().ascii());
     3838                LOG(PageCache, "Not restoring page for %s from back/forward cache because cache entry has expired", m_provisionalHistoryItem->url().url().ascii());
    38403839                item->setCachedPage(0);
    38413840            }
     
    39713970        saveDocumentState();
    39723971        saveScrollPositionAndViewStateToItem(m_currentHistoryItem.get());
     3972
     3973        if (FrameView* view = m_frame->view())
     3974            view->setWasScrolledByUser(false);
     3975
    39733976        m_currentHistoryItem = item;
    39743977               
     
    39763979        restoreDocumentState();
    39773980       
    3978         // Restore the scroll position (taken in favor of going back to the anchor)
     3981        // Restore the scroll position (we choose to do this rather than going back to the anchor point)
    39793982        restoreScrollPositionAndViewState();
    39803983       
  • trunk/WebCore/page/Frame.cpp

    r21430 r21454  
    243243    if (d->m_view) {
    244244        d->m_view->hide();
    245         d->m_view->m_frame = 0;
     245        d->m_view->clearFrame();
    246246    }
    247247 
     
    13971397void Frame::sendScrollEvent()
    13981398{
    1399     FrameView *v = d->m_view.get();
    1400     if (v) {
    1401         Document *doc = document();
    1402         if (!doc)
    1403             return;
    1404         doc->dispatchHTMLEvent(scrollEvent, true, false);
    1405     }
     1399    FrameView* v = d->m_view.get();
     1400    if (!v)
     1401        return;
     1402    v->setWasScrolledByUser(true);
     1403    Document* doc = document();
     1404    if (!doc)
     1405        return;
     1406    doc->dispatchHTMLEvent(scrollEvent, true, false);
    14061407}
    14071408
  • trunk/WebCore/page/FrameView.cpp

    r21390 r21454  
    6161        , m_overflowStatusDirty(true)
    6262        , m_viewportRenderer(0)
     63        , m_wasScrolledByUser(false)
     64        , m_inProgrammaticScroll(false)
    6365    {
    6466        isTransparent = false;
     
    8183        firstLayout = true;
    8284        repaintRects.clear();
     85        m_wasScrolledByUser = false;
    8386    }
    8487
     
    117120    bool m_verticalOverflow;   
    118121    RenderObject* m_viewportRenderer;
     122
     123    bool m_wasScrolledByUser;
     124    bool m_inProgrammaticScroll;
    119125};
    120126
     
    151157}
    152158
    153 void FrameView::clearPart()
     159void FrameView::clearFrame()
    154160{
    155161    m_frame = 0;
     
    600606    if (frame()->prohibitsScrolling())
    601607        return;
     608    bool wasInProgrammaticScroll = d->m_inProgrammaticScroll;
     609    d->m_inProgrammaticScroll = true;
    602610    ScrollView::scrollRectIntoViewRecursively(r);
     611    d->m_inProgrammaticScroll = wasInProgrammaticScroll;
    603612}
    604613
    605614void FrameView::setContentsPos(int x, int y)
    606615{
     616    ASSERT(!d->m_inProgrammaticScroll);
    607617    if (frame()->prohibitsScrolling())
    608618        return;
     619    bool wasInProgrammaticScroll = d->m_inProgrammaticScroll;
     620    d->m_inProgrammaticScroll = true;
    609621    ScrollView::setContentsPos(x, y);
     622    d->m_inProgrammaticScroll = wasInProgrammaticScroll;
    610623}
    611624
     
    703716}
    704717
    705 bool FrameView::haveDelayedLayoutScheduled()
    706 {
    707     return d->layoutTimer.isActive() && d->delayedLayout;
    708 }
    709 
    710718void FrameView::unscheduleRelayout()
    711719{
     
    902910}
    903911
    904 }
     912bool FrameView::wasScrolledByUser() const
     913{
     914    return d->m_wasScrolledByUser;
     915}
     916
     917void FrameView::setWasScrolledByUser(bool wasScrolledByUser)
     918{
     919    if (d->m_inProgrammaticScroll)
     920        return;
     921    d->m_wasScrolledByUser = wasScrolledByUser;
     922}
     923
     924}
  • trunk/WebCore/page/FrameView.h

    r20901 r21454  
    1 /* This file is part of the KDE project
    2 
     1/*
    32   Copyright (C) 1997 Martin Jones (mjones@kde.org)
    43             (C) 1998 Waldo Bastian (bastian@kde.org)
     
    65             (C) 1999 Lars Knoll (knoll@kde.org)
    76             (C) 1999 Antti Koivisto (koivisto@kde.org)
    8    Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
     7   Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
    98
    109   This library is free software; you can redistribute it and/or
     
    2928#include "ScrollView.h"
    3029#include "IntSize.h"
    31 #include "PlatformString.h"
     30#include <wtf/Forward.h>
    3231
    3332namespace WebCore {
    3433
    35 class AtomicString;
    3634class Color;
    37 class Clipboard;
    3835class Event;
    3936class EventTargetNode;
    4037class Frame;
    4138class FrameViewPrivate;
    42 class HTMLFrameSetElement;
    43 class IntPoint;
    4439class IntRect;
    45 class KeyboardEvent;
    4640class PlatformMouseEvent;
    47 class MouseEventWithHitTestResults;
    4841class Node;
    4942class RenderLayer;
    5043class RenderObject;
    51 class PlatformWheelEvent;
     44class String;
    5245
    5346template <typename T> class Timer;
     
    5952
    6053    Frame* frame() const { return m_frame.get(); }
     54    void clearFrame();
    6155
    6256    void ref() { ++m_refCount; }
     
    7266    virtual void setHScrollbarMode(ScrollbarMode);
    7367    virtual void setScrollbarsMode(ScrollbarMode);
    74    
     68
    7569    void layout(bool allowSubtree = true);
    7670    bool didFirstLayout() const;
     
    7973    void scheduleRelayoutOfSubtree(Node*);
    8074    void unscheduleRelayout();
    81     bool haveDelayedLayoutScheduled();
    8275    bool layoutPending() const;
    8376
     
    9689
    9790    void clear();
    98     void clearPart();
    9991
    10092    bool isTransparent() const;
     
    111103    IntRect windowClipRectForLayer(const RenderLayer*, bool clipToLayerContents) const;
    112104
    113     virtual void scrollRectIntoViewRecursively(const IntRect& r);
     105    virtual void scrollRectIntoViewRecursively(const IntRect&);
    114106    virtual void setContentsPos(int x, int y);
    115107
    116108    String mediaType() const;
     109    void setMediaType(const String&);
    117110
    118111    void setUseSlowRepaints();
     
    126119    void restoreScrollbar();
    127120
    128     void setMediaType(const String&);
    129 
    130121    virtual bool handleMouseMoveEvent(const PlatformMouseEvent&);
    131122    virtual bool handleMouseReleaseEvent(const PlatformMouseEvent&);
     
    134125    void pauseScheduledEvents();
    135126    void resumeScheduledEvents();
     127
     128    bool wasScrolledByUser() const;
     129    void setWasScrolledByUser(bool);
    136130
    137131private:
     
    157151    RefPtr<Frame> m_frame;
    158152    FrameViewPrivate* d;
    159 
    160     friend class Frame;
    161     friend class FrameMac;
    162 
    163153};
    164154
     
    166156
    167157#endif
    168 
Note: See TracChangeset for help on using the changeset viewer.