Changeset 69938 in webkit


Ignore:
Timestamp:
Oct 17, 2010 7:59:32 PM (14 years ago)
Author:
abarth@webkit.org
Message:

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

Reviewed by Dimitri Glazkov.

Remove explicit passing of user gesture in NavigationScheduler
https://bugs.webkit.org/show_bug.cgi?id=47786

As requested by Mr. Glazkov, remove more explicit passing of the user
gesture state. We now use a static to pass this information around.

  • bindings/generic/BindingFrame.h: (WebCore::::navigateIfAllowed):
  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::setLocation):
  • bindings/js/JSLocationCustom.cpp: (WebCore::JSLocation::reload):
  • bindings/v8/custom/V8LocationCustom.cpp: (WebCore::V8Location::reloadCallback):
  • inspector/InspectorController.cpp: (WebCore::InspectorController::setResourceTrackingEnabled): (WebCore::InspectorController::reloadPage):
  • loader/NavigationScheduler.cpp: (WebCore::ScheduledNavigation::ScheduledNavigation): (WebCore::ScheduledURLNavigation::ScheduledURLNavigation): (WebCore::ScheduledRedirect::ScheduledRedirect): (WebCore::ScheduledLocationChange::ScheduledLocationChange): (WebCore::ScheduledRefresh::ScheduledRefresh): (WebCore::ScheduledHistoryNavigation::ScheduledHistoryNavigation): (WebCore::ScheduledFormSubmission::ScheduledFormSubmission): (WebCore::NavigationScheduler::scheduleRedirect): (WebCore::NavigationScheduler::mustLockBackForwardList): (WebCore::NavigationScheduler::scheduleLocationChange): (WebCore::NavigationScheduler::scheduleFormSubmission): (WebCore::NavigationScheduler::scheduleRefresh): (WebCore::NavigationScheduler::scheduleHistoryNavigation):
  • loader/NavigationScheduler.h:
  • loader/SubframeLoader.cpp: (WebCore::SubframeLoader::loadOrRedirectSubframe):
Location:
trunk/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r69937 r69938  
     12010-10-17  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Remove explicit passing of user gesture in NavigationScheduler
     6        https://bugs.webkit.org/show_bug.cgi?id=47786
     7
     8        As requested by Mr. Glazkov, remove more explicit passing of the user
     9        gesture state.  We now use a static to pass this information around.
     10
     11        * bindings/generic/BindingFrame.h:
     12        (WebCore::::navigateIfAllowed):
     13        * bindings/js/JSDOMWindowCustom.cpp:
     14        (WebCore::JSDOMWindow::setLocation):
     15        * bindings/js/JSLocationCustom.cpp:
     16        (WebCore::JSLocation::reload):
     17        * bindings/v8/custom/V8LocationCustom.cpp:
     18        (WebCore::V8Location::reloadCallback):
     19        * inspector/InspectorController.cpp:
     20        (WebCore::InspectorController::setResourceTrackingEnabled):
     21        (WebCore::InspectorController::reloadPage):
     22        * loader/NavigationScheduler.cpp:
     23        (WebCore::ScheduledNavigation::ScheduledNavigation):
     24        (WebCore::ScheduledURLNavigation::ScheduledURLNavigation):
     25        (WebCore::ScheduledRedirect::ScheduledRedirect):
     26        (WebCore::ScheduledLocationChange::ScheduledLocationChange):
     27        (WebCore::ScheduledRefresh::ScheduledRefresh):
     28        (WebCore::ScheduledHistoryNavigation::ScheduledHistoryNavigation):
     29        (WebCore::ScheduledFormSubmission::ScheduledFormSubmission):
     30        (WebCore::NavigationScheduler::scheduleRedirect):
     31        (WebCore::NavigationScheduler::mustLockBackForwardList):
     32        (WebCore::NavigationScheduler::scheduleLocationChange):
     33        (WebCore::NavigationScheduler::scheduleFormSubmission):
     34        (WebCore::NavigationScheduler::scheduleRefresh):
     35        (WebCore::NavigationScheduler::scheduleHistoryNavigation):
     36        * loader/NavigationScheduler.h:
     37        * loader/SubframeLoader.cpp:
     38        (WebCore::SubframeLoader::loadOrRedirectSubframe):
     39
    1402010-10-17  Julien Chaffraix  <jchaffraix@codeaurora.org>
    241
  • trunk/WebCore/bindings/generic/BindingFrame.h

    r69039 r69938  
    5050        return;
    5151    if (!protocolIsJavaScript(url) || state->allowsAccessFromFrame(frame))
    52         frame->navigationScheduler()->scheduleLocationChange(url.string(), activeFrame->loader()->outgoingReferrer(), lockHistory, lockBackForwardList, state->processingUserGesture());
     52        frame->navigationScheduler()->scheduleLocationChange(url.string(), activeFrame->loader()->outgoingReferrer(), lockHistory, lockBackForwardList);
    5353}
    5454
  • trunk/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r69924 r69938  
    513513    if (!protocolIsJavaScript(url) || allowsAccessFrom(exec)) {
    514514        // We want a new history item if this JS was called via a user gesture
    515         frame->navigationScheduler()->scheduleLocationChange(url, lexicalFrame->loader()->outgoingReferrer(), !lexicalFrame->script()->anyPageIsProcessingUserGesture(), false, processingUserGesture());
     515        frame->navigationScheduler()->scheduleLocationChange(url, lexicalFrame->loader()->outgoingReferrer(), !lexicalFrame->script()->anyPageIsProcessingUserGesture(), false);
    516516    }
    517517}
  • trunk/WebCore/bindings/js/JSLocationCustom.cpp

    r69039 r69938  
    314314
    315315    if (!protocolIsJavaScript(frame->loader()->url()))
    316         frame->navigationScheduler()->scheduleRefresh(processingUserGesture());
     316        frame->navigationScheduler()->scheduleRefresh();
    317317    return jsUndefined();
    318318}
  • trunk/WebCore/bindings/v8/custom/V8LocationCustom.cpp

    r69039 r69938  
    283283
    284284    if (!protocolIsJavaScript(frame->loader()->url()))
    285         frame->navigationScheduler()->scheduleRefresh(processingUserGesture());
     285        frame->navigationScheduler()->scheduleRefresh();
    286286    return v8::Undefined();
    287287}
  • trunk/WebCore/inspector/InspectorController.cpp

    r69924 r69938  
    11631163
    11641164    if (enable)
    1165         m_inspectedPage->mainFrame()->navigationScheduler()->scheduleRefresh(true);
     1165        reloadPage();
    11661166}
    11671167
     
    21232123void InspectorController::reloadPage()
    21242124{
    2125     m_inspectedPage->mainFrame()->navigationScheduler()->scheduleRefresh(true);
     2125    // FIXME: Why do we set the user gesture indicator here?
     2126    UserGestureIndicator indicator(DefinitelyProcessingUserGesture);
     2127    m_inspectedPage->mainFrame()->navigationScheduler()->scheduleRefresh();
    21262128}
    21272129
  • trunk/WebCore/loader/NavigationScheduler.cpp

    r69924 r69938  
    5454class ScheduledNavigation : public Noncopyable {
    5555public:
    56     ScheduledNavigation(double delay, bool lockHistory, bool lockBackForwardList, bool wasDuringLoad, bool isLocationChange, bool wasUserGesture)
     56    ScheduledNavigation(double delay, bool lockHistory, bool lockBackForwardList, bool wasDuringLoad, bool isLocationChange)
    5757        : m_delay(delay)
    5858        , m_lockHistory(lockHistory)
     
    6060        , m_wasDuringLoad(wasDuringLoad)
    6161        , m_isLocationChange(isLocationChange)
    62         , m_wasUserGesture(wasUserGesture)
     62        , m_wasUserGesture(ScriptController::processingUserGesture())
    6363    {
    6464    }
     
    8989class ScheduledURLNavigation : public ScheduledNavigation {
    9090public:
    91     ScheduledURLNavigation(double delay, const String& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool wasUserGesture, bool duringLoad, bool isLocationChange)
    92         : ScheduledNavigation(delay, lockHistory, lockBackForwardList, duringLoad, isLocationChange, wasUserGesture)
     91    ScheduledURLNavigation(double delay, const String& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool duringLoad, bool isLocationChange)
     92        : ScheduledNavigation(delay, lockHistory, lockBackForwardList, duringLoad, isLocationChange)
    9393        , m_url(url)
    9494        , m_referrer(referrer)
     
    129129class ScheduledRedirect : public ScheduledURLNavigation {
    130130public:
    131     ScheduledRedirect(double delay, const String& url, bool lockHistory, bool lockBackForwardList, bool wasUserGesture)
    132         : ScheduledURLNavigation(delay, url, String(), lockHistory, lockBackForwardList, wasUserGesture, false, false) { }
     131    ScheduledRedirect(double delay, const String& url, bool lockHistory, bool lockBackForwardList)
     132        : ScheduledURLNavigation(delay, url, String(), lockHistory, lockBackForwardList, false, false)
     133    {
     134    }
    133135
    134136    virtual bool shouldStartTimer(Frame* frame) { return frame->loader()->allAncestorsAreComplete(); }
     
    137139class ScheduledLocationChange : public ScheduledURLNavigation {
    138140public:
    139     ScheduledLocationChange(const String& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool wasUserGesture, bool duringLoad)
    140         : ScheduledURLNavigation(0.0, url, referrer, lockHistory, lockBackForwardList, wasUserGesture, duringLoad, true) { }
     141    ScheduledLocationChange(const String& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool duringLoad)
     142        : ScheduledURLNavigation(0.0, url, referrer, lockHistory, lockBackForwardList, duringLoad, true) { }
    141143};
    142144
    143145class ScheduledRefresh : public ScheduledURLNavigation {
    144146public:
    145     ScheduledRefresh(const String& url, const String& referrer, bool wasUserGesture)
    146         : ScheduledURLNavigation(0.0, url, referrer, true, true, wasUserGesture, false, true) { }
     147    ScheduledRefresh(const String& url, const String& referrer)
     148        : ScheduledURLNavigation(0.0, url, referrer, true, true, false, true)
     149    {
     150    }
    147151
    148152    virtual void fire(Frame* frame)
     
    155159class ScheduledHistoryNavigation : public ScheduledNavigation {
    156160public:
    157     explicit ScheduledHistoryNavigation(int historySteps, bool wasUserGesture) : ScheduledNavigation(0, false, false, false, true, wasUserGesture), m_historySteps(historySteps) { }
     161    explicit ScheduledHistoryNavigation(int historySteps)
     162        : ScheduledNavigation(0, false, false, false, true)
     163        , m_historySteps(historySteps)
     164    {
     165    }
    158166
    159167    virtual void fire(Frame* frame)
     
    179187class ScheduledFormSubmission : public ScheduledNavigation {
    180188public:
    181     ScheduledFormSubmission(PassRefPtr<FormSubmission> submission, bool lockBackForwardList, bool duringLoad, bool wasUserGesture)
    182         : ScheduledNavigation(0, submission->lockHistory(), lockBackForwardList, duringLoad, true, wasUserGesture)
     189    ScheduledFormSubmission(PassRefPtr<FormSubmission> submission, bool lockBackForwardList, bool duringLoad)
     190        : ScheduledNavigation(0, submission->lockHistory(), lockBackForwardList, duringLoad, true)
    183191        , m_submission(submission)
    184192        , m_haveToldClient(false)
     
    259267    // We want a new back/forward list item if the refresh timeout is > 1 second.
    260268    if (!m_redirect || delay <= m_redirect->delay())
    261         schedule(adoptPtr(new ScheduledRedirect(delay, url, true, delay <= 1, false)));
    262 }
    263 
    264 bool NavigationScheduler::mustLockBackForwardList(Frame* targetFrame, bool wasUserGesture)
     269        schedule(adoptPtr(new ScheduledRedirect(delay, url, true, delay <= 1)));
     270}
     271
     272bool NavigationScheduler::mustLockBackForwardList(Frame* targetFrame)
    265273{
    266274    // Non-user navigation before the page has finished firing onload should not create a new back/forward item.
    267275    // See https://webkit.org/b/42861 for the original motivation for this.   
    268     if (!wasUserGesture && targetFrame->loader()->documentLoader() && !targetFrame->loader()->documentLoader()->wasOnloadHandled())
     276    if (!ScriptController::processingUserGesture() && targetFrame->loader()->documentLoader() && !targetFrame->loader()->documentLoader()->wasOnloadHandled())
    269277        return true;
    270278   
     
    280288}
    281289
    282 void NavigationScheduler::scheduleLocationChange(const String& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool wasUserGesture)
     290void NavigationScheduler::scheduleLocationChange(const String& url, const String& referrer, bool lockHistory, bool lockBackForwardList)
    283291{
    284292    if (!m_frame->page())
     
    287295        return;
    288296
    289     lockBackForwardList = lockBackForwardList || mustLockBackForwardList(m_frame, wasUserGesture);
     297    lockBackForwardList = lockBackForwardList || mustLockBackForwardList(m_frame);
    290298
    291299    FrameLoader* loader = m_frame->loader();
     
    303311    bool duringLoad = !loader->stateMachine()->committedFirstRealDocumentLoad();
    304312
    305     schedule(adoptPtr(new ScheduledLocationChange(url, referrer, lockHistory, lockBackForwardList, wasUserGesture, duringLoad)));
     313    schedule(adoptPtr(new ScheduledLocationChange(url, referrer, lockHistory, lockBackForwardList, duringLoad)));
    306314}
    307315
     
    320328    // to match IE and Opera.
    321329    // See https://bugs.webkit.org/show_bug.cgi?id=32383 for the original motivation for this.
    322     bool isUserGesture = m_frame->loader()->isProcessingUserGesture();
    323     bool lockBackForwardList = mustLockBackForwardList(m_frame, isUserGesture) || (submission->state()->formSubmissionTrigger() == SubmittedByJavaScript && m_frame->tree()->parent() && !isUserGesture);
    324 
    325     schedule(adoptPtr(new ScheduledFormSubmission(submission, lockBackForwardList, duringLoad, isUserGesture)));
    326 }
    327 
    328 void NavigationScheduler::scheduleRefresh(bool wasUserGesture)
     330    bool lockBackForwardList = mustLockBackForwardList(m_frame)
     331        || (submission->state()->formSubmissionTrigger() == SubmittedByJavaScript
     332            && m_frame->tree()->parent() && !ScriptController::processingUserGesture());
     333
     334    schedule(adoptPtr(new ScheduledFormSubmission(submission, lockBackForwardList, duringLoad)));
     335}
     336
     337void NavigationScheduler::scheduleRefresh()
    329338{
    330339    if (!m_frame->page())
     
    334343        return;
    335344
    336     schedule(adoptPtr(new ScheduledRefresh(url.string(), m_frame->loader()->outgoingReferrer(), wasUserGesture)));
     345    schedule(adoptPtr(new ScheduledRefresh(url.string(), m_frame->loader()->outgoingReferrer())));
    337346}
    338347
     
    351360
    352361    // In all other cases, schedule the history traversal to occur asynchronously.
    353     schedule(adoptPtr(new ScheduledHistoryNavigation(steps, m_frame->loader()->isProcessingUserGesture())));
     362    schedule(adoptPtr(new ScheduledHistoryNavigation(steps)));
    354363}
    355364
  • trunk/WebCore/loader/NavigationScheduler.h

    r69039 r69938  
    5757
    5858    void scheduleRedirect(double delay, const String& url);
    59     void scheduleLocationChange(const String& url, const String& referrer, bool lockHistory = true, bool lockBackForwardList = true, bool userGesture = false);
     59    void scheduleLocationChange(const String& url, const String& referrer, bool lockHistory = true, bool lockBackForwardList = true);
    6060    void scheduleFormSubmission(PassRefPtr<FormSubmission>);
    61     void scheduleRefresh(bool userGesture = false);
     61    void scheduleRefresh();
    6262    void scheduleHistoryNavigation(int steps);
    6363
     
    7171    void schedule(PassOwnPtr<ScheduledNavigation>);
    7272
    73     static bool mustLockBackForwardList(Frame* targetFrame, bool mustLockIfDuringLoad);
     73    static bool mustLockBackForwardList(Frame* targetFrame);
    7474
    7575    Frame* m_frame;
  • trunk/WebCore/loader/SubframeLoader.cpp

    r69039 r69938  
    240240    Frame* frame = ownerElement->contentFrame();
    241241    if (frame)
    242         frame->navigationScheduler()->scheduleLocationChange(url.string(), m_frame->loader()->outgoingReferrer(), lockHistory, lockBackForwardList, m_frame->loader()->isProcessingUserGesture());
     242        frame->navigationScheduler()->scheduleLocationChange(url.string(), m_frame->loader()->outgoingReferrer(), lockHistory, lockBackForwardList);
    243243    else
    244244        frame = loadSubframe(ownerElement, url, frameName, m_frame->loader()->outgoingReferrer());
Note: See TracChangeset for help on using the changeset viewer.