Changeset 80768 in webkit


Ignore:
Timestamp:
Mar 10, 2011 2:54:13 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-03-10 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>

Reviewed by Antonio Gomes.

Simplify how QWebFrame::requestedUrl() is obtained
https://bugs.webkit.org/show_bug.cgi?id=55842

When a load starts, store the requested URL until we know that it'll be
available for us in the document loader -- after load finished.

The existing auto tests cover the three different code paths in
requestedUrl() and the new code passes the autotests. In each of those
cases, we looked for the information in a different place, but in all
of them, dispatchDidStartProvisionalLoad was called.

This simplification will be useful to fix bug 32723. The way requestedUrl()
is implementent, we can't use it as a fallback for url() when the setUrl()
was called with an invalid URL.

  • Api/qwebframe.cpp: (QWebFrame::requestedUrl):
  • WebCoreSupport/FrameLoaderClientQt.cpp: (WebCore::FrameLoaderClientQt::dispatchDidStartProvisionalLoad): (WebCore::FrameLoaderClientQt::dispatchDidFinishLoad):
  • WebCoreSupport/FrameLoaderClientQt.h: (WebCore::FrameLoaderClientQt::lastRequestedUrl):
Location:
trunk/Source/WebKit/qt
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/qt/Api/qwebframe.cpp

    r79988 r80768  
    781781QUrl QWebFrame::requestedUrl() const
    782782{
    783     // There are some possible edge cases to be handled here,
    784     // apart from checking if activeDocumentLoader is valid:
    785     //
    786     // * Method can be called while processing an unsucessful load.
    787     //   In this case, frameLoaderClient will hold the current error
    788     //   (m_loadError), and we will make use of it to recover the 'failingURL'.
    789     // * If the 'failingURL' holds a null'ed string though, we fallback
    790     //   to 'outgoingReferrer' (it yet is safer than originalRequest).
    791     FrameLoader* loader = d->frame->loader();
    792     FrameLoaderClientQt* loaderClient = d->frameLoaderClient;
    793 
    794     if (!loader->activeDocumentLoader()
    795         || !loaderClient->m_loadError.isNull()) {
    796         if (!loaderClient->m_loadError.failingURL().isNull())
    797             return QUrl(loaderClient->m_loadError.failingURL());
    798         else if (!loader->outgoingReferrer().isEmpty())
    799             return QUrl(loader->outgoingReferrer());
    800     }
    801 
    802     return loader->originalRequest().url();
     783    const KURL& lastRequestedUrl = d->frameLoaderClient->lastRequestedUrl();
     784    if (lastRequestedUrl.isValid())
     785        return lastRequestedUrl;
     786    return d->frame->loader()->originalRequest().url();
    803787}
    804788/*!
  • trunk/Source/WebKit/qt/ChangeLog

    r80716 r80768  
     12011-03-10  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
     2
     3        Reviewed by Antonio Gomes.
     4
     5        Simplify how QWebFrame::requestedUrl() is obtained
     6        https://bugs.webkit.org/show_bug.cgi?id=55842
     7
     8        When a load starts, store the requested URL until we know that it'll be
     9        available for us in the document loader -- after load finished.
     10
     11        The existing auto tests cover the three different code paths in
     12        requestedUrl() and the new code passes the autotests. In each of those
     13        cases, we looked for the information in a different place, but in all
     14        of them, dispatchDidStartProvisionalLoad was called.
     15
     16        This simplification will be useful to fix bug 32723. The way requestedUrl()
     17        is implementent, we can't use it as a fallback for url() when the setUrl()
     18        was called with an invalid URL.
     19
     20        * Api/qwebframe.cpp:
     21        (QWebFrame::requestedUrl):
     22        * WebCoreSupport/FrameLoaderClientQt.cpp:
     23        (WebCore::FrameLoaderClientQt::dispatchDidStartProvisionalLoad):
     24        (WebCore::FrameLoaderClientQt::dispatchDidFinishLoad):
     25        * WebCoreSupport/FrameLoaderClientQt.h:
     26        (WebCore::FrameLoaderClientQt::lastRequestedUrl):
     27
    1282011-03-10  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
    229
  • trunk/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp

    r80475 r80768  
    438438        printf("%s - in didStartProvisionalLoadForFrame\n", qPrintable(drtPrintFrameUserGestureStatus(m_frame)));
    439439
     440    m_lastRequestedUrl = m_frame->loader()->activeDocumentLoader()->requestURL();
     441
    440442    if (m_webFrame)
    441443        emit m_webFrame->provisionalLoad();
     
    517519    // Clears the previous error.
    518520    m_loadError = ResourceError();
     521
     522    // The requested URL will be available in the document loader that just finished, so we
     523    // don't need to keep it anymore.
     524    m_lastRequestedUrl = KURL();
    519525
    520526    if (!m_webFrame)
  • trunk/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h

    r80475 r80768  
    240240    virtual PassRefPtr<FrameNetworkingContext> createNetworkingContext();
    241241
     242    const KURL& lastRequestedUrl() const { return m_lastRequestedUrl; }
     243
    242244    static bool dumpFrameLoaderCallbacks;
    243245    static bool dumpUserGestureInFrameLoaderCallbacks;
     
    268270    bool m_hasRepresentation;
    269271
     272    KURL m_lastRequestedUrl;
    270273    ResourceError m_loadError;
    271274};
Note: See TracChangeset for help on using the changeset viewer.