Changeset 20813 in webkit


Ignore:
Timestamp:
Apr 9, 2007 5:00:21 PM (17 years ago)
Author:
beidson
Message:

LayoutTests:

Reviewed by Darin

Layout test for the fix for <rdar://4921797> and http://bugs.webkit.org/show_bug.cgi?id=12005

  • http/tests/navigation/multiple-back-forward-entries-expected.txt: Added.
  • http/tests/navigation/multiple-back-forward-entries.html: Added.
  • http/tests/navigation/resources/slow-resource.pl: Added.

WebCore:

Reviewed by Darin

Fixes <rdar://4921797> and http://bugs.webkit.org/show_bug.cgi?id=12005

The original regression was to claim that more loads were the result of a "user gesture" than really
were. A lot of the ways a frame load could be kicked off didn't properly set up this flag, and it
wasn't properly propagated and respected where it should've been.

This patch cleans much of that up. One loose end is the "treatAsUserGesture" flag which is a stop
gap measure to keep "slow redirects" working to create a new history item. In the future, we need
to cleanup the meaning and use of "userGesture" and "lockHistory." This includes integrating them
in to FrameLoadRequest and being very clear of what their meaning actually is at different stages of
the Frame load process.

  • dom/Document.cpp: (WebCore::Document::processHttpEquiv): Pass only the delay for the redirect
  • html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::defaultEventHandler): Pass "lockHistory" false, "userGesture" true
  • ksvg2/svg/SVGAElement.cpp: (WebCore::SVGAElement::defaultEventHandler): Pass "lockHistory" false, "userGesture" true
  • loader/FrameLoader.cpp: (WebCore::ScheduledRedirection::ScheduledRedirection): Figure "lockHistory" and "userGesture" from the delay here, instead of at 3 other different sites that call this method (WebCore::FrameLoader::changeLocation): Set userGesture correctly (WebCore::FrameLoader::urlSelected): Propagate userGesture down (WebCore::FrameLoader::requestFrame): (WebCore::FrameLoader::receivedFirstData): (WebCore::FrameLoader::scheduleRedirection): Pass only the delay here (WebCore::FrameLoader::redirectionTimerFired): Set userGesture correctly (WebCore::FrameLoader::load): (WebCore::FrameLoader::updateHistoryForInternalLoad): Insteading of asserting we aren't a redirect, handle the case where we *are* a redirect by updating the previous history item
  • loader/FrameLoader.h:
Location:
trunk
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r20809 r20813  
     12007-04-09  Brady Eidson  <beidson@apple.com>
     2
     3        Reviewed by Darin
     4
     5        Layout test for the fix for <rdar://4921797> and http://bugs.webkit.org/show_bug.cgi?id=12005
     6
     7        * http/tests/navigation/multiple-back-forward-entries-expected.txt: Added.
     8        * http/tests/navigation/multiple-back-forward-entries.html: Added.
     9        * http/tests/navigation/resources/slow-resource.pl: Added.
     10
    1112007-04-09  Justin Garcia  <justin.garcia@apple.com>
    212
  • trunk/WebCore/ChangeLog

    r20805 r20813  
     12007-04-09  Brady Eidson  <beidson@apple.com>
     2
     3        Reviewed by Darin
     4
     5        Fixes <rdar://4921797> and http://bugs.webkit.org/show_bug.cgi?id=12005
     6
     7        The original regression was to claim that more loads were the result of a "user gesture" than really
     8        were.  A lot of the ways a frame load could be kicked off didn't properly set up this flag, and it
     9        wasn't properly propagated and respected where it should've been.
     10
     11        This patch cleans much of that up.  One loose end is the "treatAsUserGesture" flag which is a stop
     12        gap measure to keep "slow redirects" working to create a new history item.  In the future, we need
     13        to cleanup the meaning and use of "userGesture" and "lockHistory."  This includes integrating them
     14        in to FrameLoadRequest and being very clear of what their meaning actually is at different stages of
     15        the Frame load process.
     16
     17        * dom/Document.cpp:
     18        (WebCore::Document::processHttpEquiv): Pass only the delay for the redirect
     19
     20        * html/HTMLAnchorElement.cpp:
     21        (WebCore::HTMLAnchorElement::defaultEventHandler): Pass "lockHistory" false, "userGesture" true
     22
     23        * ksvg2/svg/SVGAElement.cpp:
     24        (WebCore::SVGAElement::defaultEventHandler): Pass "lockHistory" false, "userGesture" true
     25
     26        * loader/FrameLoader.cpp:
     27        (WebCore::ScheduledRedirection::ScheduledRedirection): Figure "lockHistory" and "userGesture" from the
     28          delay here, instead of at 3 other different sites that call this method
     29        (WebCore::FrameLoader::changeLocation): Set userGesture correctly
     30        (WebCore::FrameLoader::urlSelected): Propagate userGesture down
     31        (WebCore::FrameLoader::requestFrame):
     32        (WebCore::FrameLoader::receivedFirstData):
     33        (WebCore::FrameLoader::scheduleRedirection): Pass only the delay here
     34        (WebCore::FrameLoader::redirectionTimerFired): Set userGesture correctly
     35        (WebCore::FrameLoader::load):
     36        (WebCore::FrameLoader::updateHistoryForInternalLoad): Insteading of asserting we aren't a redirect,
     37          handle the case where we *are* a redirect by updating the previous history item
     38        * loader/FrameLoader.h:
     39
    1402007-04-09  Anders Carlsson  <andersca@apple.com>
    241
  • trunk/WebCore/dom/Document.cpp

    r20794 r20813  
    17461746        if (frame && parseHTTPRefresh(content, true, delay, url)) {
    17471747            if (url.isEmpty())
    1748                 frame->loader()->scheduleRedirection(delay, frame->loader()->url().url(), delay <= 1);
     1748                url = frame->loader()->url().url();
    17491749            else
    1750                 // We want a new history item if the refresh timeout > 1 second
    1751                 frame->loader()->scheduleRedirection(delay, completeURL(url), delay <= 1);
     1750                url = completeURL(url);
     1751            frame->loader()->scheduleRedirection(delay, url);
    17521752        }
    17531753    } else if (equalIgnoringCase(equiv, "set-cookie")) {
  • trunk/WebCore/html/HTMLAnchorElement.cpp

    r20729 r20813  
    216216
    217217        if (!evt->defaultPrevented() && document()->frame())
    218             document()->frame()->loader()->urlSelected(document()->completeURL(url), target, evt);
     218            document()->frame()->loader()->urlSelected(document()->completeURL(url), target, evt, false, true);
    219219
    220220        evt->setDefaultHandled();
  • trunk/WebCore/ksvg2/svg/SVGAElement.cpp

    r20725 r20813  
    116116        if (!evt->defaultPrevented())
    117117            if (document()->frame())
    118                 document()->frame()->loader()->urlSelected(document()->completeURL(url), target, evt);
     118                document()->frame()->loader()->urlSelected(document()->completeURL(url), target, evt, false, true);
    119119
    120120        evt->setDefaultHandled();
  • trunk/WebCore/loader/FrameLoader.cpp

    r20740 r20813  
    124124    bool wasUserGesture;
    125125
    126     ScheduledRedirection(double redirectDelay, const String& redirectURL, bool redirectLockHistory)
     126    ScheduledRedirection(double redirectDelay, const String& redirectURL, bool redirectLockHistory, bool userGesture)
    127127        : type(redirection)
    128128        , delay(redirectDelay)
     
    130130        , historySteps(0)
    131131        , lockHistory(redirectLockHistory)
    132         , wasUserGesture(false)
     132        , wasUserGesture(userGesture)
    133133    {
    134134    }
     
    330330    ResourceRequest request(completeURL(URL), referrer, policy);
    331331   
    332     urlSelected(request, "_self", 0, lockHistory);
    333 }
    334 
    335 void FrameLoader::urlSelected(const ResourceRequest& request, const String& _target, Event* triggeringEvent, bool lockHistory)
     332    urlSelected(request, "_self", 0, lockHistory, userGesture);
     333}
     334
     335void FrameLoader::urlSelected(const ResourceRequest& request, const String& _target, Event* triggeringEvent, bool lockHistory, bool userGesture)
    336336{
    337337    String target = _target;
     
    353353        frameRequest.resourceRequest().setHTTPReferrer(m_outgoingReferrer);
    354354
    355     urlSelected(frameRequest, triggeringEvent);
     355    urlSelected(frameRequest, triggeringEvent, userGesture);
    356356}
    357357
     
    369369    Frame* frame = m_frame->tree()->child(frameName);
    370370    if (frame)
    371         frame->loader()->scheduleLocationChange(url.url(), m_outgoingReferrer, false, false);
     371        frame->loader()->scheduleLocationChange(url.url(), m_outgoingReferrer, false, userGestureHint());
    372372    else
    373373        frame = loadSubframe(ownerElement, url, frameName, m_outgoingReferrer);
     
    773773        URL = m_frame->document()->completeURL(URL);
    774774
    775     // We want a new history item if the refresh timeout > 1 second
    776     scheduleRedirection(delay, URL, delay <= 1);
     775    scheduleRedirection(delay, URL);
    777776}
    778777
     
    11561155}
    11571156
    1158 void FrameLoader::scheduleRedirection(double delay, const String& url, bool doLockHistory)
     1157void FrameLoader::scheduleRedirection(double delay, const String& url)
    11591158{
    11601159    if (delay < 0 || delay > INT_MAX / 1000)
    11611160        return;
     1161       
     1162    // We want a new history item if the refresh timeout > 1 second.  We accomplish this
     1163    // by pretending a slow redirect is a user gesture and passing false for lockHistory
    11621164    if (!m_scheduledRedirection || delay <= m_scheduledRedirection->delay)
    1163         scheduleRedirection(new ScheduledRedirection(delay, url, doLockHistory));
     1165        scheduleRedirection(new ScheduledRedirection(delay, url, delay <= 1, delay > 1));
    11641166}
    11651167
     
    12841286            if (redirection->historySteps == 0) {
    12851287                // Special case for go(0) from a frame -> reload only the frame
    1286                 urlSelected(m_URL, "", 0);
     1288                urlSelected(m_URL, "", 0, redirection->lockHistory, redirection->wasUserGesture);
    12871289                return;
    12881290            }
     
    28292831}
    28302832
    2831 void FrameLoader::urlSelected(const FrameLoadRequest& request, Event* event)
     2833void FrameLoader::urlSelected(const FrameLoadRequest& request, Event* event, bool userGesture)
    28322834{
    28332835    FrameLoadRequest copy = request;
     
    28352837        copy.resourceRequest().setHTTPReferrer(m_outgoingReferrer);
    28362838
    2837     // FIXME: Why do we always pass true for userGesture?
    2838     load(copy, true, event, 0, HashMap<String, String>());
     2839    load(copy, userGesture, event, 0, HashMap<String, String>());
    28392840}
    28402841   
     
    40334034        LOG(History, "WebCoreHistory - Updating History for internal load in frame %s", documentLoader()->title().utf8().data());
    40344035#endif
    4035 
    4036     // Add an item to the item tree for this frame
    4037     ASSERT(!documentLoader()->isClientRedirect());
    4038     Frame* parentFrame = m_frame->tree()->parent();
    4039     // The only case where parentItem is NULL should be when a parent frame loaded an
    4040     // empty URL, which doesn't set up a current item in that parent.
    4041     if (parentFrame) {
    4042         if (parentFrame->loader()->m_currentHistoryItem)
    4043             parentFrame->loader()->m_currentHistoryItem->addChildItem(createHistoryItem(true));
     4036   
     4037    if (documentLoader()->isClientRedirect()) {
     4038        m_currentHistoryItem->setURL(documentLoader()->URL());
     4039        m_currentHistoryItem->setFormInfoFromRequest(documentLoader()->request());
    40444040    } else {
    4045         // See 3556159. It's not clear if it's valid to be in FrameLoadTypeOnLoadEvent
    4046         // for a top-level frame, but that was a likely explanation for those crashes,
    4047         // so let's guard against it.
    4048         // ...and all FrameLoadTypeOnLoadEvent uses were folded to WebFrameLoadTypeInternal
    4049         LOG_ERROR("No parent frame in transitionToCommitted:, FrameLoadTypeInternal");
     4041        // Add an item to the item tree for this frame
     4042        Frame* parentFrame = m_frame->tree()->parent();
     4043        // The only case where parentItem is NULL should be when a parent frame loaded an
     4044        // empty URL, which doesn't set up a current item in that parent.
     4045        if (parentFrame) {
     4046            if (parentFrame->loader()->m_currentHistoryItem)
     4047                parentFrame->loader()->m_currentHistoryItem->addChildItem(createHistoryItem(true));
     4048        } else {
     4049            // See 3556159. It's not clear if it's valid to be in FrameLoadTypeOnLoadEvent
     4050            // for a top-level frame, but that was a likely explanation for those crashes,
     4051            // so let's guard against it.
     4052            // ...and all FrameLoadTypeOnLoadEvent uses were folded to WebFrameLoadTypeInternal
     4053            LOG_ERROR("No parent frame in transitionToCommitted:, FrameLoadTypeInternal");
     4054        }
    40504055    }
    40514056}
  • trunk/WebCore/loader/FrameLoader.h

    r20740 r20813  
    265265
    266266        void changeLocation(const String& URL, const String& referrer, bool lockHistory = true, bool userGesture = false);
    267         void urlSelected(const ResourceRequest&, const String& target, Event*, bool lockHistory = false);
    268         void urlSelected(const FrameLoadRequest&, Event*);
     267        void urlSelected(const ResourceRequest&, const String& target, Event*, bool lockHistory, bool userGesture);
     268        void urlSelected(const FrameLoadRequest&, Event*, bool userGesture);
    269269     
    270270        bool requestFrame(HTMLFrameOwnerElement*, const String& URL, const AtomicString& frameName);
     
    288288        KURL dataURLBaseFromRequest(const ResourceRequest& request) const;
    289289
    290         void scheduleRedirection(double delay, const String& URL, bool lockHistory = true);
     290        void scheduleRedirection(double delay, const String& URL);
    291291
    292292        void scheduleLocationChange(const String& URL, const String& referrer, bool lockHistory = true, bool userGesture = false);
Note: See TracChangeset for help on using the changeset viewer.