Changeset 69924 in webkit


Ignore:
Timestamp:
Oct 17, 2010 9:02:51 AM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-10-17 Adam Barth <abarth@webkit.org>

Reviewed by Dimitri Glazkov.

FrameLoader doesn't need an explicit userGesture parameter
https://bugs.webkit.org/show_bug.cgi?id=47777

We used to pass around the user gesture state explicitly. Now we use
static state. Explicitly passing the user gesture state to FrameLoader
in these methods is pretty out-dated.

  • bindings/ScriptControllerBase.cpp: (WebCore::ScriptController::executeIfJavaScriptURL):
  • bindings/generic/BindingDOMWindow.h: (WebCore::::createWindow): (WebCore::::open):
  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::createWindow): (WebCore::JSDOMWindow::open):
  • bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::setLocation):
  • bindings/js/ScriptController.h:
  • bindings/v8/ScriptController.h:
  • html/HTMLAnchorElement.cpp: (WebCore::handleLinkClick):
  • inspector/InspectorController.cpp: (WebCore::InspectorController::openInInspectedWindow):
  • loader/FrameLoader.cpp: (WebCore::FrameLoader::changeLocation): (WebCore::FrameLoader::urlSelected): (WebCore::FrameLoader::submitForm):
  • loader/FrameLoader.h:
  • loader/NavigationScheduler.cpp: (WebCore::ScheduledURLNavigation::fire): (WebCore::ScheduledRefresh::fire): (WebCore::ScheduledHistoryNavigation::fire): (WebCore::NavigationScheduler::scheduleLocationChange):

2010-10-17 Adam Barth <abarth@webkit.org>

Reviewed by Dimitri Glazkov.

FrameLoader doesn't need an explicit userGesture parameter
https://bugs.webkit.org/show_bug.cgi?id=47777

Update for the new API.

  • WebCoreSupport/WebContextMenuClient.cpp: (WebContextMenuClient::searchWithGoogle):
Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r69923 r69924  
     12010-10-17  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        FrameLoader doesn't need an explicit userGesture parameter
     6        https://bugs.webkit.org/show_bug.cgi?id=47777
     7
     8        We used to pass around the user gesture state explicitly.  Now we use
     9        static state.  Explicitly passing the user gesture state to FrameLoader
     10        in these methods is pretty out-dated.
     11
     12        * bindings/ScriptControllerBase.cpp:
     13        (WebCore::ScriptController::executeIfJavaScriptURL):
     14        * bindings/generic/BindingDOMWindow.h:
     15        (WebCore::::createWindow):
     16        (WebCore::::open):
     17        * bindings/js/JSDOMWindowCustom.cpp:
     18        (WebCore::createWindow):
     19        (WebCore::JSDOMWindow::open):
     20        * bindings/js/JSDocumentCustom.cpp:
     21        (WebCore::JSDocument::setLocation):
     22        * bindings/js/ScriptController.h:
     23        * bindings/v8/ScriptController.h:
     24        * html/HTMLAnchorElement.cpp:
     25        (WebCore::handleLinkClick):
     26        * inspector/InspectorController.cpp:
     27        (WebCore::InspectorController::openInInspectedWindow):
     28        * loader/FrameLoader.cpp:
     29        (WebCore::FrameLoader::changeLocation):
     30        (WebCore::FrameLoader::urlSelected):
     31        (WebCore::FrameLoader::submitForm):
     32        * loader/FrameLoader.h:
     33        * loader/NavigationScheduler.cpp:
     34        (WebCore::ScheduledURLNavigation::fire):
     35        (WebCore::ScheduledRefresh::fire):
     36        (WebCore::ScheduledHistoryNavigation::fire):
     37        (WebCore::NavigationScheduler::scheduleLocationChange):
     38
    1392010-10-17  Sergey A. Sukiyazov  <sergey.sukiyazov@gmail.com>
    240
  • trunk/WebCore/bindings/ScriptControllerBase.cpp

    r65381 r69924  
    6868}
    6969
    70 bool ScriptController::executeIfJavaScriptURL(const KURL& url, bool userGesture, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL)
     70bool ScriptController::executeIfJavaScriptURL(const KURL& url, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL)
    7171{
    7272    if (!protocolIsJavaScript(url))
     
    9191    ScriptValue result;
    9292    if (xssAuditor()->canEvaluateJavaScriptURL(decodedURL))
    93         result = executeScript(decodedURL.substring(javascriptSchemeLength), userGesture, AllowXSS);
     93        result = executeScript(decodedURL.substring(javascriptSchemeLength), processingUserGesture(), AllowXSS);
    9494
    9595    // If executing script caused this frame to be removed from the page, we
  • trunk/WebCore/bindings/generic/BindingDOMWindow.h

    r69039 r69924  
    120120        KURL completedUrl =
    121121            url.isEmpty() ? KURL(ParsedURLString, "") : completeURL(state, url);
    122         bool userGesture = state->processingUserGesture();
    123 
    124122        if (created)
    125             newFrame->loader()->changeLocation(completedUrl, referrer, false, false, userGesture);
     123            newFrame->loader()->changeLocation(completedUrl, referrer, false, false);
    126124        else if (!url.isEmpty())
    127             newFrame->navigationScheduler()->scheduleLocationChange(completedUrl.string(), referrer, false, false, userGesture);
     125            newFrame->navigationScheduler()->scheduleLocationChange(completedUrl.string(), referrer, false, false);
    128126    }
    129127
     
    188186            && (!protocolIsJavaScript(completedUrl)
    189187                || BindingSecurity<Binding>::canAccessFrame(state, frame, true))) {
    190             bool userGesture = state->processingUserGesture();
    191 
    192188            // For whatever reason, Firefox uses the first frame to determine
    193189            // the outgoingReferrer.  We replicate that behavior here.
    194190            String referrer = firstFrame->loader()->outgoingReferrer();
    195191
    196             frame->navigationScheduler()->scheduleLocationChange(completedUrl, referrer, false, false, userGesture);
     192            frame->navigationScheduler()->scheduleLocationChange(completedUrl, referrer, false, false);
    197193        }
    198194        return frame->domWindow();
  • trunk/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r69782 r69924  
    701701    if (!protocolIsJavaScript(url) || newWindow->allowsAccessFrom(exec)) {
    702702        KURL completedURL = url.isEmpty() ? KURL(ParsedURLString, "") : completeURL(exec, url);
    703         bool userGesture = processingUserGesture();
    704 
    705703        if (created)
    706             newFrame->loader()->changeLocation(completedURL, referrer, false, false, userGesture);
     704            newFrame->loader()->changeLocation(completedURL, referrer, false, false);
    707705        else if (!url.isEmpty())
    708             newFrame->navigationScheduler()->scheduleLocationChange(completedURL.string(), referrer, !lexicalFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture);
     706            newFrame->navigationScheduler()->scheduleLocationChange(completedURL.string(), referrer, !lexicalFrame->script()->anyPageIsProcessingUserGesture(), false);
    709707    }
    710708
     
    764762        const JSDOMWindow* targetedWindow = toJSDOMWindow(frame, currentWorld(exec));
    765763        if (!completedURL.isEmpty() && (!protocolIsJavaScript(completedURL) || (targetedWindow && targetedWindow->allowsAccessFrom(exec)))) {
    766             bool userGesture = processingUserGesture();
    767 
    768764            // For whatever reason, Firefox uses the dynamicGlobalObject to
    769765            // determine the outgoingReferrer.  We replicate that behavior
     
    771767            String referrer = dynamicFrame->loader()->outgoingReferrer();
    772768
    773             frame->navigationScheduler()->scheduleLocationChange(completedURL, referrer, !lexicalFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture);
     769            frame->navigationScheduler()->scheduleLocationChange(completedURL, referrer, !lexicalFrame->script()->anyPageIsProcessingUserGesture(), false);
    774770        }
    775771        return toJS(exec, frame->domWindow());
  • trunk/WebCore/bindings/js/JSDocumentCustom.cpp

    r69039 r69924  
    8989        str = activeFrame->document()->completeURL(str).string();
    9090
    91     bool userGesture = ScriptController::processingUserGesture();
    92     frame->navigationScheduler()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !activeFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture);
     91    frame->navigationScheduler()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !activeFrame->script()->anyPageIsProcessingUserGesture(), false);
    9392}
    9493
  • trunk/WebCore/bindings/js/ScriptController.h

    r65082 r69924  
    9999
    100100    // Returns true if argument is a JavaScript URL.
    101     bool executeIfJavaScriptURL(const KURL&, bool userGesture = false, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL = ReplaceDocumentIfJavaScriptURL);
     101    bool executeIfJavaScriptURL(const KURL&, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL = ReplaceDocumentIfJavaScriptURL);
    102102
    103103    // This function must be called from the main thread. It is safe to call it repeatedly.
  • trunk/WebCore/bindings/v8/ScriptController.h

    r68630 r69924  
    7777
    7878    // Returns true if argument is a JavaScript URL.
    79     bool executeIfJavaScriptURL(const KURL&, bool userGesture = false, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL = ReplaceDocumentIfJavaScriptURL);
     79    bool executeIfJavaScriptURL(const KURL&, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL = ReplaceDocumentIfJavaScriptURL);
    8080
    8181    // This function must be called from the main thread. It is safe to call it repeatedly.
  • trunk/WebCore/html/HTMLAnchorElement.cpp

    r69749 r69924  
    3939#include "ResourceHandle.h"
    4040#include "Settings.h"
     41#include "UserGestureIndicator.h"
    4142
    4243namespace WebCore {
     
    551552    if (!frame)
    552553        return;
    553     frame->loader()->urlSelected(document->completeURL(url), target, event, false, false, true, hideReferrer ? NoReferrer : SendReferrer);
    554 }
    555 
    556 }
     554    // FIXME: This seems wrong.  Why are we manufactuing a user gesture?
     555    UserGestureIndicator indicator(DefinitelyProcessingUserGesture);
     556    frame->loader()->urlSelected(document->completeURL(url), target, event, false, false, hideReferrer ? NoReferrer : SendReferrer);
     557}
     558
     559}
  • trunk/WebCore/inspector/InspectorController.cpp

    r69853 r69924  
    9494#include "TextEncoding.h"
    9595#include "TextIterator.h"
     96#include "UserGestureIndicator.h"
    9697#include "WindowFeatures.h"
    9798#include <wtf/text/StringConcatenate.h>
     
    19891990        return;
    19901991
     1992    UserGestureIndicator indicator(DefinitelyProcessingUserGesture);
    19911993    newFrame->loader()->setOpener(mainFrame);
    19921994    newFrame->page()->setOpenedByDOM();
    1993     newFrame->loader()->changeLocation(newFrame->loader()->completeURL(url), "", false, false, true);
     1995    newFrame->loader()->changeLocation(newFrame->loader()->completeURL(url), "", false, false);
    19941996}
    19951997
  • trunk/WebCore/loader/FrameLoader.cpp

    r69798 r69924  
    265265}
    266266
    267 void FrameLoader::changeLocation(const KURL& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool userGesture, bool refresh)
     267void FrameLoader::changeLocation(const KURL& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool refresh)
    268268{
    269269    RefPtr<Frame> protect(m_frame);
     
    271271    ResourceRequest request(url, referrer, refresh ? ReloadIgnoringCacheData : UseProtocolCachePolicy);
    272272   
    273     urlSelected(request, "_self", 0, lockHistory, lockBackForwardList, userGesture, SendReferrer, ReplaceDocumentIfJavaScriptURL);
    274 }
    275 
    276 void FrameLoader::urlSelected(const KURL& url, const String& passedTarget, PassRefPtr<Event> triggeringEvent, bool lockHistory, bool lockBackForwardList, bool userGesture, ReferrerPolicy referrerPolicy)
    277 {
    278     urlSelected(ResourceRequest(url), passedTarget, triggeringEvent, lockHistory, lockBackForwardList, userGesture, referrerPolicy, DoNotReplaceDocumentIfJavaScriptURL);
     273    urlSelected(request, "_self", 0, lockHistory, lockBackForwardList, SendReferrer, ReplaceDocumentIfJavaScriptURL);
     274}
     275
     276void FrameLoader::urlSelected(const KURL& url, const String& passedTarget, PassRefPtr<Event> triggeringEvent, bool lockHistory, bool lockBackForwardList, ReferrerPolicy referrerPolicy)
     277{
     278    urlSelected(ResourceRequest(url), passedTarget, triggeringEvent, lockHistory, lockBackForwardList, referrerPolicy, DoNotReplaceDocumentIfJavaScriptURL);
    279279}
    280280
    281281// The shouldReplaceDocumentIfJavaScriptURL parameter will go away when the FIXME to eliminate the
    282282// corresponding parameter from ScriptController::executeIfJavaScriptURL() is addressed.
    283 void FrameLoader::urlSelected(const ResourceRequest& request, const String& passedTarget, PassRefPtr<Event> triggeringEvent, bool lockHistory, bool lockBackForwardList, bool userGesture, ReferrerPolicy referrerPolicy, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL)
     283void FrameLoader::urlSelected(const ResourceRequest& request, const String& passedTarget, PassRefPtr<Event> triggeringEvent, bool lockHistory, bool lockBackForwardList, ReferrerPolicy referrerPolicy, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL)
    284284{
    285285    ASSERT(!m_suppressOpenerInNewFrame);
    286286
    287     if (m_frame->script()->executeIfJavaScriptURL(request.url(), userGesture, shouldReplaceDocumentIfJavaScriptURL))
     287    if (m_frame->script()->executeIfJavaScriptURL(request.url(), shouldReplaceDocumentIfJavaScriptURL))
    288288        return;
    289289
     
    325325    if (protocolIsJavaScript(submission->action())) {
    326326        m_isExecutingJavaScriptFormAction = true;
    327         m_frame->script()->executeIfJavaScriptURL(submission->action(), false, DoNotReplaceDocumentIfJavaScriptURL);
     327        m_frame->script()->executeIfJavaScriptURL(submission->action(), DoNotReplaceDocumentIfJavaScriptURL);
    328328        m_isExecutingJavaScriptFormAction = false;
    329329        return;
  • trunk/WebCore/loader/FrameLoader.h

    r69688 r69924  
    212212    void setDefersLoading(bool);
    213213
    214     void changeLocation(const KURL&, const String& referrer, bool lockHistory = true, bool lockBackForwardList = true, bool userGesture = false, bool refresh = false);
    215     void urlSelected(const KURL&, const String& target, PassRefPtr<Event>, bool lockHistory, bool lockBackForwardList, bool userGesture, ReferrerPolicy);
     214    void changeLocation(const KURL&, const String& referrer, bool lockHistory = true, bool lockBackForwardList = true, bool refresh = false);
     215    void urlSelected(const KURL&, const String& target, PassRefPtr<Event>, bool lockHistory, bool lockBackForwardList, ReferrerPolicy);
    216216
    217217    void submitForm(PassRefPtr<FormSubmission>);
     
    391391    void dispatchDidCommitLoad();
    392392
    393     void urlSelected(const ResourceRequest&, const String& target, PassRefPtr<Event>, bool lockHistory, bool lockBackForwardList, bool userGesture, ReferrerPolicy, ShouldReplaceDocumentIfJavaScriptURL);
     393    void urlSelected(const ResourceRequest&, const String& target, PassRefPtr<Event>, bool lockHistory, bool lockBackForwardList, ReferrerPolicy, ShouldReplaceDocumentIfJavaScriptURL);
    394394
    395395    void loadWithDocumentLoader(DocumentLoader*, FrameLoadType, PassRefPtr<FormState>); // Calls continueLoadAfterNavigationPolicy
  • trunk/WebCore/loader/NavigationScheduler.cpp

    r69039 r69924  
    9999    virtual void fire(Frame* frame)
    100100    {
    101         frame->loader()->changeLocation(KURL(ParsedURLString, m_url), m_referrer, lockHistory(), lockBackForwardList(), wasUserGesture(), false);
     101        UserGestureIndicator gestureIndicator(wasUserGesture() ? DefinitelyProcessingUserGesture : DefinitelyNotProcessingUserGesture);
     102        frame->loader()->changeLocation(KURL(ParsedURLString, m_url), m_referrer, lockHistory(), lockBackForwardList(), false);
    102103    }
    103104
     
    147148    virtual void fire(Frame* frame)
    148149    {
    149         frame->loader()->changeLocation(KURL(ParsedURLString, url()), referrer(), lockHistory(), lockBackForwardList(), wasUserGesture(), true);
     150        UserGestureIndicator gestureIndicator(wasUserGesture() ? DefinitelyProcessingUserGesture : DefinitelyNotProcessingUserGesture);
     151        frame->loader()->changeLocation(KURL(ParsedURLString, url()), referrer(), lockHistory(), lockBackForwardList(), true);
    150152    }
    151153};
     
    163165            // Special case for go(0) from a frame -> reload only the frame
    164166            // To follow Firefox and IE's behavior, history reload can only navigate the self frame.
    165             loader->urlSelected(loader->url(), "_self", 0, lockHistory(), lockBackForwardList(), wasUserGesture(), SendReferrer);
     167            loader->urlSelected(loader->url(), "_self", 0, lockHistory(), lockBackForwardList(), SendReferrer);
    166168            return;
    167169        }
     
    293295    KURL parsedURL(ParsedURLString, url);
    294296    if (parsedURL.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(loader->url(), parsedURL)) {
    295         loader->changeLocation(loader->completeURL(url), referrer, lockHistory, lockBackForwardList, wasUserGesture);
     297        loader->changeLocation(loader->completeURL(url), referrer, lockHistory, lockBackForwardList);
    296298        return;
    297299    }
  • trunk/WebKit/win/ChangeLog

    r69900 r69924  
     12010-10-17  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        FrameLoader doesn't need an explicit userGesture parameter
     6        https://bugs.webkit.org/show_bug.cgi?id=47777
     7
     8        Update for the new API.
     9
     10        * WebCoreSupport/WebContextMenuClient.cpp:
     11        (WebContextMenuClient::searchWithGoogle):
     12
    1132010-10-15  Brian Weinstein  <bweinstein@apple.com>
    214
  • trunk/WebKit/win/WebCoreSupport/WebContextMenuClient.cpp

    r67122 r69924  
    2727#include "WebContextMenuClient.h"
    2828
     29#include "UserGestureIndicator.h"
    2930#include "WebElementPropertyBag.h"
    3031#include "WebLocalizableStrings.h"
     
    141142    url.append("&ie=UTF-8&oe=UTF-8");
    142143
    143     if (Page* page = frame->page())
    144         page->mainFrame()->loader()->urlSelected(KURL(ParsedURLString, url), String(), 0, false, false, true, SendReferrer);
     144    if (Page* page = frame->page()) {
     145        UserGestureIndicator indicator(DefinitelyProcessingUserGesture);
     146        page->mainFrame()->loader()->urlSelected(KURL(ParsedURLString, url), String(), 0, false, false, SendReferrer);
     147    }
    145148}
    146149
Note: See TracChangeset for help on using the changeset viewer.