Changeset 166684 in webkit


Ignore:
Timestamp:
Apr 2, 2014 5:51:04 PM (10 years ago)
Author:
mrowe@apple.com
Message:

<https://webkit.org/b/131135> Introduce LockHistory and LockBackForwardList enums to use in place of bools.

These arguments are often passed using literals at the call site, where the use of bools severely hinders
the readability of the code.

Reviewed by Andreas Kling.

Source/WebCore:

  • WebCore.exp.in:
  • html/HTMLAnchorElement.cpp:

(WebCore::HTMLAnchorElement::handleClick):

  • html/HTMLFormElement.cpp:

(WebCore::HTMLFormElement::submit):

  • html/HTMLFrameElementBase.cpp:

(WebCore::HTMLFrameElementBase::openURL):
(WebCore::HTMLFrameElementBase::setLocation):

  • html/HTMLFrameElementBase.h:
  • inspector/InspectorFrontendClientLocal.cpp:

(WebCore::InspectorFrontendClientLocal::openInNewTab):

  • inspector/InspectorPageAgent.cpp:

(WebCore::InspectorPageAgent::navigate):

  • loader/FormSubmission.cpp:

(WebCore::FormSubmission::FormSubmission):
(WebCore::FormSubmission::create):

  • loader/FormSubmission.h:

(WebCore::FormSubmission::lockHistory):

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::changeLocation):
(WebCore::FrameLoader::urlSelected):
(WebCore::FrameLoader::loadURLIntoChildFrame):
(WebCore::FrameLoader::loadFrameRequest):
(WebCore::FrameLoader::loadURL):
(WebCore::FrameLoader::loadWithNavigationAction):
(WebCore::FrameLoader::clientRedirected):
(WebCore::FrameLoader::loadPostRequest):
(WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):
(WebCore::FrameLoader::loadDifferentDocumentItem):

  • loader/FrameLoader.h:
  • loader/FrameLoaderTypes.h:
  • loader/NavigationScheduler.cpp:

(WebCore::ScheduledNavigation::ScheduledNavigation):
(WebCore::ScheduledNavigation::lockHistory):
(WebCore::ScheduledNavigation::lockBackForwardList):
(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):

  • loader/NavigationScheduler.h:
  • loader/SubframeLoader.cpp:

(WebCore::SubframeLoader::requestFrame):
(WebCore::SubframeLoader::requestObject):
(WebCore::SubframeLoader::loadOrRedirectSubframe):

  • loader/SubframeLoader.h:
  • page/ContextMenuController.cpp:

(WebCore::openNewWindow):
(WebCore::ContextMenuController::contextMenuItemSelected):

  • page/DOMWindow.cpp:

(WebCore::DOMWindow::setLocation):
(WebCore::DOMWindow::createWindow):
(WebCore::DOMWindow::open):

  • svg/SVGAElement.cpp:

(WebCore::SVGAElement::defaultEventHandler):

Source/WebKit/mac:

  • WebView/WebPDFView.mm:

(-[WebPDFView PDFViewWillClickOnLink:withURL:]):

Source/WebKit2:

  • WebProcess/Plugins/PDF/PDFPlugin.mm:

(WebKit::PDFPlugin::clickedLink):

Location:
trunk/Source
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r166682 r166684  
     12014-04-02  Mark Rowe  <mrowe@apple.com>
     2
     3        <https://webkit.org/b/131135> Introduce LockHistory and LockBackForwardList enums to use in place of bools.
     4
     5        These arguments are often passed using literals at the call site, where the use of bools severely hinders
     6        the readability of the code.
     7
     8        Reviewed by Andreas Kling.
     9
     10        * WebCore.exp.in:
     11        * html/HTMLAnchorElement.cpp:
     12        (WebCore::HTMLAnchorElement::handleClick):
     13        * html/HTMLFormElement.cpp:
     14        (WebCore::HTMLFormElement::submit):
     15        * html/HTMLFrameElementBase.cpp:
     16        (WebCore::HTMLFrameElementBase::openURL):
     17        (WebCore::HTMLFrameElementBase::setLocation):
     18        * html/HTMLFrameElementBase.h:
     19        * inspector/InspectorFrontendClientLocal.cpp:
     20        (WebCore::InspectorFrontendClientLocal::openInNewTab):
     21        * inspector/InspectorPageAgent.cpp:
     22        (WebCore::InspectorPageAgent::navigate):
     23        * loader/FormSubmission.cpp:
     24        (WebCore::FormSubmission::FormSubmission):
     25        (WebCore::FormSubmission::create):
     26        * loader/FormSubmission.h:
     27        (WebCore::FormSubmission::lockHistory):
     28        * loader/FrameLoader.cpp:
     29        (WebCore::FrameLoader::changeLocation):
     30        (WebCore::FrameLoader::urlSelected):
     31        (WebCore::FrameLoader::loadURLIntoChildFrame):
     32        (WebCore::FrameLoader::loadFrameRequest):
     33        (WebCore::FrameLoader::loadURL):
     34        (WebCore::FrameLoader::loadWithNavigationAction):
     35        (WebCore::FrameLoader::clientRedirected):
     36        (WebCore::FrameLoader::loadPostRequest):
     37        (WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):
     38        (WebCore::FrameLoader::loadDifferentDocumentItem):
     39        * loader/FrameLoader.h:
     40        * loader/FrameLoaderTypes.h:
     41        * loader/NavigationScheduler.cpp:
     42        (WebCore::ScheduledNavigation::ScheduledNavigation):
     43        (WebCore::ScheduledNavigation::lockHistory):
     44        (WebCore::ScheduledNavigation::lockBackForwardList):
     45        (WebCore::ScheduledURLNavigation::ScheduledURLNavigation):
     46        (WebCore::ScheduledRedirect::ScheduledRedirect):
     47        (WebCore::ScheduledLocationChange::ScheduledLocationChange):
     48        (WebCore::ScheduledRefresh::ScheduledRefresh):
     49        (WebCore::ScheduledHistoryNavigation::ScheduledHistoryNavigation):
     50        (WebCore::ScheduledFormSubmission::ScheduledFormSubmission):
     51        (WebCore::NavigationScheduler::scheduleRedirect):
     52        (WebCore::NavigationScheduler::mustLockBackForwardList):
     53        (WebCore::NavigationScheduler::scheduleLocationChange):
     54        (WebCore::NavigationScheduler::scheduleFormSubmission):
     55        * loader/NavigationScheduler.h:
     56        * loader/SubframeLoader.cpp:
     57        (WebCore::SubframeLoader::requestFrame):
     58        (WebCore::SubframeLoader::requestObject):
     59        (WebCore::SubframeLoader::loadOrRedirectSubframe):
     60        * loader/SubframeLoader.h:
     61        * page/ContextMenuController.cpp:
     62        (WebCore::openNewWindow):
     63        (WebCore::ContextMenuController::contextMenuItemSelected):
     64        * page/DOMWindow.cpp:
     65        (WebCore::DOMWindow::setLocation):
     66        (WebCore::DOMWindow::createWindow):
     67        (WebCore::DOMWindow::open):
     68        * svg/SVGAElement.cpp:
     69        (WebCore::SVGAElement::defaultEventHandler):
     70
    1712014-04-02  Tim Horton  <timothy_horton@apple.com>
    272
  • trunk/Source/WebCore/WebCore.exp.in

    r166682 r166684  
    131131__ZN7WebCore11FrameLoader11loadArchiveEN3WTF10PassRefPtrINS_7ArchiveEEE
    132132__ZN7WebCore11FrameLoader11shouldCloseEv
    133 __ZN7WebCore11FrameLoader11urlSelectedERKNS_3URLERKN3WTF6StringENS4_10PassRefPtrINS_5EventEEEbbNS_18ShouldSendReferrerE
     133__ZN7WebCore11FrameLoader11urlSelectedERKNS_3URLERKN3WTF6StringENS4_10PassRefPtrINS_5EventEEENS_11LockHistoryENS_19LockBackForwardListENS_18ShouldSendReferrerE
    134134__ZN7WebCore11FrameLoader14detachChildrenEv
    135135__ZN7WebCore11FrameLoader14stopAllLoadersENS_26ClearProvisionalItemPolicyE
    136136__ZN7WebCore11FrameLoader16detachFromParentEv
    137 __ZN7WebCore11FrameLoader16loadFrameRequestERKNS_16FrameLoadRequestEbbN3WTF10PassRefPtrINS_5EventEEENS5_INS_9FormStateEEENS_18ShouldSendReferrerE
     137__ZN7WebCore11FrameLoader16loadFrameRequestERKNS_16FrameLoadRequestENS_11LockHistoryENS_19LockBackForwardListEN3WTF10PassRefPtrINS_5EventEEENS7_INS_9FormStateEEENS_18ShouldSendReferrerE
    138138__ZN7WebCore11FrameLoader17stopForUserCancelEb
    139139__ZN7WebCore11FrameLoader21loadURLIntoChildFrameERKNS_3URLERKN3WTF6StringEPNS_5FrameE
     
    11991199__ZN7WebCore7IntRectC1ERKNS_9FloatRectE
    12001200__ZN7WebCore7IntSizeC1ERK6CGSize
     1201__ZN7WebCore7IntSizeC1ERKNS_9FloatSizeE
    12011202__ZN7WebCore7TextRun19allowsRoundingHacksEv
    12021203__ZN7WebCore7TextRun21s_allowsRoundingHacksE
     
    13071308__ZN7WebCore9FloatRectC1ERK6CGRect
    13081309__ZN7WebCore9FloatRectC1ERKNS_7IntRectE
    1309 __ZNK7WebCore9FloatRect8containsERKNS_10FloatPointENS0_12ContainsModeE
    13101310__ZN7WebCore9FloatSizeC1ERK6CGSize
    13111311__ZN7WebCore9FloatSizeC1ERKNS_7IntSizeE
    1312 __ZN7WebCore7IntSizeC1ERKNS_9FloatSizeE
    13131312__ZN7WebCore9FontCache10invalidateEv
    13141313__ZN7WebCore9FontCache13fontDataCountEv
     
    19091908__ZNK7WebCore9FloatQuad11boundingBoxEv
    19101909__ZNK7WebCore9FloatRect10intersectsERKS0_
     1910__ZNK7WebCore9FloatRect8containsERKNS_10FloatPointENS0_12ContainsModeE
    19111911__ZNK7WebCore9FloatRect8containsERKS0_
    19121912__ZNK7WebCore9FloatRectcv6CGRectEv
  • trunk/Source/WebCore/html/HTMLAnchorElement.cpp

    r165607 r166684  
    548548    } else
    549549#endif
    550         frame->loader().urlSelected(kurl, target(), event, false, false, hasRel(RelationNoReferrer) ? NeverSendReferrer : MaybeSendReferrer);
     550        frame->loader().urlSelected(kurl, target(), event, LockHistory::No, LockBackForwardList::No, hasRel(RelationNoReferrer) ? NeverSendReferrer : MaybeSendReferrer);
    551551
    552552    sendPings(kurl);
  • trunk/Source/WebCore/html/HTMLFormElement.cpp

    r166615 r166684  
    348348        firstSuccessfulSubmitButton->setActivatedSubmit(true);
    349349
    350     bool lockHistory = !processingUserGesture;
     350    LockHistory lockHistory = processingUserGesture ? LockHistory::No : LockHistory::Yes;
    351351    frame->loader().submitForm(FormSubmission::create(this, m_attributes, event, lockHistory, formSubmissionTrigger));
    352352
  • trunk/Source/WebCore/html/HTMLFrameElementBase.cpp

    r165045 r166684  
    7474}
    7575
    76 void HTMLFrameElementBase::openURL(bool lockHistory, bool lockBackForwardList)
     76void HTMLFrameElementBase::openURL(LockHistory lockHistory, LockBackForwardList lockBackForwardList)
    7777{
    7878    if (!isURLAllowed())
     
    182182
    183183    if (inDocument())
    184         openURL(false, false);
     184        openURL(LockHistory::No, LockBackForwardList::No);
    185185}
    186186
  • trunk/Source/WebCore/html/HTMLFrameElementBase.h

    r164254 r166684  
    2525#define HTMLFrameElementBase_h
    2626
     27#include "FrameLoaderTypes.h"
    2728#include "HTMLFrameOwnerElement.h"
    2829#include "ScrollTypes.h"
     
    6566
    6667    void setNameAndOpenURL();
    67     void openURL(bool lockHistory = true, bool lockBackForwardList = true);
     68    void openURL(LockHistory = LockHistory::Yes, LockBackForwardList = LockBackForwardList::Yes);
    6869
    6970    AtomicString m_URL;
  • trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.cpp

    r164245 r166684  
    225225
    226226    // FIXME: Why does one use mainFrame and the other frame?
    227     frame->loader().changeLocation(mainFrame.document()->securityOrigin(), frame->document()->completeURL(url), "", false, false);
     227    frame->loader().changeLocation(mainFrame.document()->securityOrigin(), frame->document()->completeURL(url), "", LockHistory::No, LockBackForwardList::No);
    228228}
    229229
  • trunk/Source/WebCore/inspector/InspectorPageAgent.cpp

    r166329 r166684  
    430430    UserGestureIndicator indicator(DefinitelyProcessingUserGesture);
    431431    Frame& frame = m_page->mainFrame();
    432     frame.loader().changeLocation(frame.document()->securityOrigin(), frame.document()->completeURL(url), "", false, false);
     432    frame.loader().changeLocation(frame.document()->securityOrigin(), frame.document()->completeURL(url), "", LockHistory::No, LockBackForwardList::No);
    433433}
    434434
  • trunk/Source/WebCore/loader/FormSubmission.cpp

    r166047 r166684  
    125125}
    126126
    127 inline FormSubmission::FormSubmission(Method method, const URL& action, const String& target, const String& contentType, PassRefPtr<FormState> state, PassRefPtr<FormData> data, const String& boundary, bool lockHistory, PassRefPtr<Event> event)
     127inline FormSubmission::FormSubmission(Method method, const URL& action, const String& target, const String& contentType, PassRefPtr<FormState> state, PassRefPtr<FormData> data, const String& boundary, LockHistory lockHistory, PassRefPtr<Event> event)
    128128    : m_method(method)
    129129    , m_action(action)
     
    138138}
    139139
    140 PassRefPtr<FormSubmission> FormSubmission::create(HTMLFormElement* form, const Attributes& attributes, PassRefPtr<Event> event, bool lockHistory, FormSubmissionTrigger trigger)
     140PassRefPtr<FormSubmission> FormSubmission::create(HTMLFormElement* form, const Attributes& attributes, PassRefPtr<Event> event, LockHistory lockHistory, FormSubmissionTrigger trigger)
    141141{
    142142    ASSERT(form);
  • trunk/Source/WebCore/loader/FormSubmission.h

    r156550 r166684  
    3333
    3434#include "FormState.h"
     35#include "FrameLoaderTypes.h"
    3536#include "URL.h"
    3637
     
    8990    };
    9091
    91     static PassRefPtr<FormSubmission> create(HTMLFormElement*, const Attributes&, PassRefPtr<Event> event, bool lockHistory, FormSubmissionTrigger);
     92    static PassRefPtr<FormSubmission> create(HTMLFormElement*, const Attributes&, PassRefPtr<Event> event, LockHistory, FormSubmissionTrigger);
    9293
    9394    void populateFrameLoadRequest(FrameLoadRequest&);
     
    103104    FormData* data() const { return m_formData.get(); }
    104105    const String boundary() const { return m_boundary; }
    105     bool lockHistory() const { return m_lockHistory; }
     106    LockHistory lockHistory() const { return m_lockHistory; }
    106107    Event* event() const { return m_event.get(); }
    107108
     
    112113
    113114private:
    114     FormSubmission(Method, const URL& action, const String& target, const String& contentType, PassRefPtr<FormState>, PassRefPtr<FormData>, const String& boundary, bool lockHistory, PassRefPtr<Event>);
     115    FormSubmission(Method, const URL& action, const String& target, const String& contentType, PassRefPtr<FormState>, PassRefPtr<FormData>, const String& boundary, LockHistory, PassRefPtr<Event>);
    115116
    116117    // FIXME: Hold an instance of Attributes instead of individual members.
     
    122123    RefPtr<FormData> m_formData;
    123124    String m_boundary;
    124     bool m_lockHistory;
     125    LockHistory m_lockHistory;
    125126    RefPtr<Event> m_event;
    126127    String m_referrer;
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r166600 r166684  
    318318}
    319319
    320 void FrameLoader::changeLocation(SecurityOrigin* securityOrigin, const URL& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool refresh)
     320void FrameLoader::changeLocation(SecurityOrigin* securityOrigin, const URL& url, const String& referrer, LockHistory lockHistory, LockBackForwardList lockBackForwardList, bool refresh)
    321321{
    322322    urlSelected(FrameLoadRequest(securityOrigin, ResourceRequest(url, referrer, refresh ? ReloadIgnoringCacheData : UseProtocolCachePolicy), "_self"),
     
    324324}
    325325
    326 void FrameLoader::urlSelected(const URL& url, const String& passedTarget, PassRefPtr<Event> triggeringEvent, bool lockHistory, bool lockBackForwardList, ShouldSendReferrer shouldSendReferrer)
     326void FrameLoader::urlSelected(const URL& url, const String& passedTarget, PassRefPtr<Event> triggeringEvent, LockHistory lockHistory, LockBackForwardList lockBackForwardList, ShouldSendReferrer shouldSendReferrer)
    327327{
    328328    urlSelected(FrameLoadRequest(m_frame.document()->securityOrigin(), ResourceRequest(url), passedTarget),
     
    332332// The shouldReplaceDocumentIfJavaScriptURL parameter will go away when the FIXME to eliminate the
    333333// corresponding parameter from ScriptController::executeIfJavaScriptURL() is addressed.
    334 void FrameLoader::urlSelected(const FrameLoadRequest& passedRequest, PassRefPtr<Event> triggeringEvent, bool lockHistory, bool lockBackForwardList, ShouldSendReferrer shouldSendReferrer, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL)
     334void FrameLoader::urlSelected(const FrameLoadRequest& passedRequest, PassRefPtr<Event> triggeringEvent, LockHistory lockHistory, LockBackForwardList lockBackForwardList, ShouldSendReferrer shouldSendReferrer, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL)
    335335{
    336336    ASSERT(!m_suppressOpenerInNewFrame);
     
    915915    }
    916916
    917     childFrame->loader().loadURL(url, referer, "_self", false, FrameLoadTypeRedirectWithLockedBackForwardList, 0, 0);
     917    childFrame->loader().loadURL(url, referer, "_self", LockHistory::No, FrameLoadTypeRedirectWithLockedBackForwardList, 0, 0);
    918918}
    919919
     
    11931193}
    11941194
    1195 void FrameLoader::loadFrameRequest(const FrameLoadRequest& request, bool lockHistory, bool lockBackForwardList,
     1195void FrameLoader::loadFrameRequest(const FrameLoadRequest& request, LockHistory lockHistory, LockBackForwardList lockBackForwardList,
    11961196    PassRefPtr<Event> event, PassRefPtr<FormState> formState, ShouldSendReferrer shouldSendReferrer)
    11971197{   
     
    12181218    if (request.resourceRequest().cachePolicy() == ReloadIgnoringCacheData)
    12191219        loadType = FrameLoadTypeReload;
    1220     else if (lockBackForwardList)
     1220    else if (lockBackForwardList == LockBackForwardList::Yes)
    12211221        loadType = FrameLoadTypeRedirectWithLockedBackForwardList;
    12221222    else
     
    12401240}
    12411241
    1242 void FrameLoader::loadURL(const URL& newURL, const String& referrer, const String& frameName, bool lockHistory, FrameLoadType newLoadType,
     1242void FrameLoader::loadURL(const URL& newURL, const String& referrer, const String& frameName, LockHistory lockHistory, FrameLoadType newLoadType,
    12431243    PassRefPtr<Event> event, PassRefPtr<FormState> prpFormState)
    12441244{
     
    13631363}
    13641364
    1365 void FrameLoader::loadWithNavigationAction(const ResourceRequest& request, const NavigationAction& action, bool lockHistory, FrameLoadType type, PassRefPtr<FormState> formState)
     1365void FrameLoader::loadWithNavigationAction(const ResourceRequest& request, const NavigationAction& action, LockHistory lockHistory, FrameLoadType type, PassRefPtr<FormState> formState)
    13661366{
    13671367    RefPtr<DocumentLoader> loader = m_client.createDocumentLoader(request, defaultSubstituteDataForURL(request.url()));
    1368     if (lockHistory && m_documentLoader)
     1368    if (lockHistory == LockHistory::Yes && m_documentLoader)
    13691369        loader->setClientRedirectSourceForHistory(m_documentLoader->didCreateGlobalHistoryEntry() ? m_documentLoader->urlForHistory().string() : m_documentLoader->clientRedirectSourceForHistory());
    13701370
     
    19971997}
    19981998
    1999 void FrameLoader::clientRedirected(const URL& url, double seconds, double fireDate, bool lockBackForwardList)
     1999void FrameLoader::clientRedirected(const URL& url, double seconds, double fireDate, LockBackForwardList lockBackForwardList)
    20002000{
    20012001    m_client.dispatchWillPerformClientRedirect(url, seconds, fireDate);
     
    20092009    // no "original" load on which to base a redirect, so we treat the redirect as a normal load.
    20102010    // Loads triggered by JavaScript form submissions never count as quick redirects.
    2011     m_quickRedirectComing = (lockBackForwardList || history().currentItemShouldBeReplaced()) && m_documentLoader && !m_isExecutingJavaScriptFormAction;
     2011    m_quickRedirectComing = (lockBackForwardList == LockBackForwardList::Yes || history().currentItemShouldBeReplaced()) && m_documentLoader && !m_isExecutingJavaScriptFormAction;
    20122012}
    20132013
     
    26082608}
    26092609
    2610 void FrameLoader::loadPostRequest(const ResourceRequest& inRequest, const String& referrer, const String& frameName, bool lockHistory, FrameLoadType loadType, PassRefPtr<Event> event, PassRefPtr<FormState> prpFormState)
     2610void FrameLoader::loadPostRequest(const ResourceRequest& inRequest, const String& referrer, const String& frameName, LockHistory lockHistory, FrameLoadType loadType, PassRefPtr<Event> event, PassRefPtr<FormState> prpFormState)
    26112611{
    26122612    RefPtr<FormState> formState = prpFormState;
     
    29752975        mainFrame->document()->setReferrerPolicy(frame->document()->referrerPolicy());
    29762976    }
    2977     mainFrame->loader().loadWithNavigationAction(request, NavigationAction(request), false, FrameLoadTypeStandard, formState);
     2977    mainFrame->loader().loadWithNavigationAction(request, NavigationAction(request), LockHistory::No, FrameLoadTypeStandard, formState);
    29782978}
    29792979
     
    32293229    }
    32303230
    3231     loadWithNavigationAction(request, action, false, loadType, 0);
     3231    loadWithNavigationAction(request, action, LockHistory::No, loadType, 0);
    32323232}
    32333233
  • trunk/Source/WebCore/loader/FrameLoader.h

    r165676 r166684  
    108108    // FIXME: These are all functions which start loads. We have too many.
    109109    void loadURLIntoChildFrame(const URL&, const String& referer, Frame*);
    110     void loadFrameRequest(const FrameLoadRequest&, bool lockHistory, bool lockBackForwardList,  // Called by submitForm, calls loadPostRequest and loadURL.
     110    void loadFrameRequest(const FrameLoadRequest&, LockHistory, LockBackForwardList,  // Called by submitForm, calls loadPostRequest and loadURL.
    111111        PassRefPtr<Event>, PassRefPtr<FormState>, ShouldSendReferrer);
    112112
     
    118118    unsigned long loadResourceSynchronously(const ResourceRequest&, StoredCredentials, ClientCredentialPolicy, ResourceError&, ResourceResponse&, Vector<char>& data);
    119119
    120     void changeLocation(SecurityOrigin*, const URL&, const String& referrer, bool lockHistory = true, bool lockBackForwardList = true, bool refresh = false);
    121     void urlSelected(const URL&, const String& target, PassRefPtr<Event>, bool lockHistory, bool lockBackForwardList, ShouldSendReferrer);
     120    void changeLocation(SecurityOrigin*, const URL&, const String& referrer, LockHistory = LockHistory::Yes,
     121        LockBackForwardList = LockBackForwardList::Yes, bool refresh = false);
     122    void urlSelected(const URL&, const String& target, PassRefPtr<Event>, LockHistory, LockBackForwardList, ShouldSendReferrer);
    122123    void submitForm(PassRefPtr<FormSubmission>);
    123124
     
    256257    void completed();
    257258    bool allAncestorsAreComplete() const; // including this
    258     void clientRedirected(const URL&, double delay, double fireDate, bool lockBackForwardList);
     259    void clientRedirected(const URL&, double delay, double fireDate, LockBackForwardList);
    259260    void clientRedirectCancelledOrFinished(bool cancelWithLoadInProgress);
    260261
     
    342343    void dispatchDidCommitLoad();
    343344
    344     void urlSelected(const FrameLoadRequest&, PassRefPtr<Event>, bool lockHistory, bool lockBackForwardList, ShouldSendReferrer, ShouldReplaceDocumentIfJavaScriptURL);
     345    void urlSelected(const FrameLoadRequest&, PassRefPtr<Event>, LockHistory, LockBackForwardList, ShouldSendReferrer, ShouldReplaceDocumentIfJavaScriptURL);
    345346
    346347    void loadWithDocumentLoader(DocumentLoader*, FrameLoadType, PassRefPtr<FormState>); // Calls continueLoadAfterNavigationPolicy
     
    348349
    349350    void loadWithNavigationAction(const ResourceRequest&, const NavigationAction&,      // Calls loadWithDocumentLoader
    350         bool lockHistory, FrameLoadType, PassRefPtr<FormState>);
     351        LockHistory, FrameLoadType, PassRefPtr<FormState>);
    351352
    352353    void loadPostRequest(const ResourceRequest&, const String& referrer,                // Called by loadFrameRequest, calls loadWithNavigationAction
    353         const String& frameName, bool lockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>);
     354        const String& frameName, LockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>);
    354355    void loadURL(const URL&, const String& referrer, const String& frameName,          // Called by loadFrameRequest, calls loadWithNavigationAction or dispatches to navigation policy delegate
    355         bool lockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>);                                                         
     356        LockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>);
    356357
    357358    bool shouldReload(const URL& currentURL, const URL& destinationURL);
  • trunk/Source/WebCore/loader/FrameLoaderTypes.h

    r165676 r166684  
    113113    };
    114114
     115    enum class LockHistory {
     116        Yes,
     117        No
     118    };
     119
     120    enum class LockBackForwardList {
     121        Yes,
     122        No
     123    };
    115124}
    116125
  • trunk/Source/WebCore/loader/NavigationScheduler.cpp

    r165676 r166684  
    6060    WTF_MAKE_NONCOPYABLE(ScheduledNavigation); WTF_MAKE_FAST_ALLOCATED;
    6161public:
    62     ScheduledNavigation(double delay, bool lockHistory, bool lockBackForwardList, bool wasDuringLoad, bool isLocationChange)
     62    ScheduledNavigation(double delay, LockHistory lockHistory, LockBackForwardList lockBackForwardList, bool wasDuringLoad, bool isLocationChange)
    6363        : m_delay(delay)
    6464        , m_lockHistory(lockHistory)
     
    7878
    7979    double delay() const { return m_delay; }
    80     bool lockHistory() const { return m_lockHistory; }
    81     bool lockBackForwardList() const { return m_lockBackForwardList; }
     80    LockHistory lockHistory() const { return m_lockHistory; }
     81    LockBackForwardList lockBackForwardList() const { return m_lockBackForwardList; }
    8282    bool wasDuringLoad() const { return m_wasDuringLoad; }
    8383    bool isLocationChange() const { return m_isLocationChange; }
     
    8989private:
    9090    double m_delay;
    91     bool m_lockHistory;
    92     bool m_lockBackForwardList;
     91    LockHistory m_lockHistory;
     92    LockBackForwardList m_lockBackForwardList;
    9393    bool m_wasDuringLoad;
    9494    bool m_isLocationChange;
     
    9898class ScheduledURLNavigation : public ScheduledNavigation {
    9999protected:
    100     ScheduledURLNavigation(double delay, SecurityOrigin* securityOrigin, const String& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool duringLoad, bool isLocationChange)
     100    ScheduledURLNavigation(double delay, SecurityOrigin* securityOrigin, const String& url, const String& referrer, LockHistory lockHistory, LockBackForwardList lockBackForwardList, bool duringLoad, bool isLocationChange)
    101101        : ScheduledNavigation(delay, lockHistory, lockBackForwardList, duringLoad, isLocationChange)
    102102        , m_securityOrigin(securityOrigin)
     
    150150class ScheduledRedirect : public ScheduledURLNavigation {
    151151public:
    152     ScheduledRedirect(double delay, SecurityOrigin* securityOrigin, const String& url, bool lockHistory, bool lockBackForwardList)
     152    ScheduledRedirect(double delay, SecurityOrigin* securityOrigin, const String& url, LockHistory lockHistory, LockBackForwardList lockBackForwardList)
    153153        : ScheduledURLNavigation(delay, securityOrigin, url, String(), lockHistory, lockBackForwardList, false, false)
    154154    {
     
    171171class ScheduledLocationChange : public ScheduledURLNavigation {
    172172public:
    173     ScheduledLocationChange(SecurityOrigin* securityOrigin, const String& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool duringLoad)
     173    ScheduledLocationChange(SecurityOrigin* securityOrigin, const String& url, const String& referrer, LockHistory lockHistory, LockBackForwardList lockBackForwardList, bool duringLoad)
    174174        : ScheduledURLNavigation(0.0, securityOrigin, url, referrer, lockHistory, lockBackForwardList, duringLoad, true) { }
    175175};
     
    178178public:
    179179    ScheduledRefresh(SecurityOrigin* securityOrigin, const String& url, const String& referrer)
    180         : ScheduledURLNavigation(0.0, securityOrigin, url, referrer, true, true, false, true)
     180        : ScheduledURLNavigation(0.0, securityOrigin, url, referrer, LockHistory::Yes, LockBackForwardList::Yes, false, true)
    181181    {
    182182    }
     
    192192public:
    193193    explicit ScheduledHistoryNavigation(int historySteps)
    194         : ScheduledNavigation(0, false, false, false, true)
     194        : ScheduledNavigation(0, LockHistory::No, LockBackForwardList::No, false, true)
    195195        , m_historySteps(historySteps)
    196196    {
     
    219219class ScheduledFormSubmission : public ScheduledNavigation {
    220220public:
    221     ScheduledFormSubmission(PassRefPtr<FormSubmission> submission, bool lockBackForwardList, bool duringLoad)
     221    ScheduledFormSubmission(PassRefPtr<FormSubmission> submission, LockBackForwardList lockBackForwardList, bool duringLoad)
    222222        : ScheduledNavigation(0, submission->lockHistory(), lockBackForwardList, duringLoad, true)
    223223        , m_submission(submission)
     
    320320
    321321    // We want a new back/forward list item if the refresh timeout is > 1 second.
    322     if (!m_redirect || delay <= m_redirect->delay())
    323         schedule(std::make_unique<ScheduledRedirect>(delay, m_frame.document()->securityOrigin(), url, true, delay <= 1));
    324 }
    325 
    326 bool NavigationScheduler::mustLockBackForwardList(Frame& targetFrame)
     322    if (!m_redirect || delay <= m_redirect->delay()) {
     323        LockBackForwardList lockBackForwardList = delay <= 1 ? LockBackForwardList::Yes : LockBackForwardList::No;
     324        schedule(std::make_unique<ScheduledRedirect>(delay, m_frame.document()->securityOrigin(), url, LockHistory::Yes, lockBackForwardList));
     325    }
     326}
     327
     328LockBackForwardList NavigationScheduler::mustLockBackForwardList(Frame& targetFrame)
    327329{
    328330    // Non-user navigation before the page has finished firing onload should not create a new back/forward item.
    329331    // See https://webkit.org/b/42861 for the original motivation for this.   
    330332    if (!ScriptController::processingUserGesture() && targetFrame.loader().documentLoader() && !targetFrame.loader().documentLoader()->wasOnloadHandled())
    331         return true;
     333        return LockBackForwardList::Yes;
    332334   
    333335    // Navigation of a subframe during loading of an ancestor frame does not create a new back/forward item.
     
    337339        Document* document = ancestor->document();
    338340        if (!ancestor->loader().isComplete() || (document && document->processingLoadEvent()))
    339             return true;
    340     }
    341     return false;
    342 }
    343 
    344 void NavigationScheduler::scheduleLocationChange(SecurityOrigin* securityOrigin, const String& url, const String& referrer, bool lockHistory, bool lockBackForwardList)
     341            return LockBackForwardList::Yes;
     342    }
     343    return LockBackForwardList::No;
     344}
     345
     346void NavigationScheduler::scheduleLocationChange(SecurityOrigin* securityOrigin, const String& url, const String& referrer, LockHistory lockHistory, LockBackForwardList lockBackForwardList)
    345347{
    346348    if (!shouldScheduleNavigation(url))
     
    349351        return;
    350352
    351     lockBackForwardList = lockBackForwardList || mustLockBackForwardList(m_frame);
     353    if (lockBackForwardList == LockBackForwardList::No)
     354        lockBackForwardList = mustLockBackForwardList(m_frame);
    352355
    353356    FrameLoader& loader = m_frame.loader();
     
    382385    // to match IE and Opera.
    383386    // See https://bugs.webkit.org/show_bug.cgi?id=32383 for the original motivation for this.
    384     bool lockBackForwardList = mustLockBackForwardList(m_frame)
    385         || (submission->state()->formSubmissionTrigger() == SubmittedByJavaScript
    386             && m_frame.tree().parent() && !ScriptController::processingUserGesture());
    387 
     387    LockBackForwardList lockBackForwardList = mustLockBackForwardList(m_frame);
     388    if (lockBackForwardList == LockBackForwardList::No
     389        && (submission->state()->formSubmissionTrigger() == SubmittedByJavaScript && m_frame.tree().parent() && !ScriptController::processingUserGesture())) {
     390        lockBackForwardList = LockBackForwardList::Yes;
     391    }
     392   
    388393    schedule(std::make_unique<ScheduledFormSubmission>(submission, lockBackForwardList, duringLoad));
    389394}
  • trunk/Source/WebCore/loader/NavigationScheduler.h

    r165676 r166684  
    3232#define NavigationScheduler_h
    3333
     34#include "FrameLoaderTypes.h"
    3435#include "Timer.h"
    3536#include <wtf/Forward.h>
     
    7475
    7576    void scheduleRedirect(double delay, const String& url);
    76     void scheduleLocationChange(SecurityOrigin*, const String& url, const String& referrer, bool lockHistory = true, bool lockBackForwardList = true);
     77    void scheduleLocationChange(SecurityOrigin*, const String& url, const String& referrer, LockHistory = LockHistory::Yes,
     78        LockBackForwardList = LockBackForwardList::Yes);
    7779    void scheduleFormSubmission(PassRefPtr<FormSubmission>);
    7880    void scheduleRefresh();
     
    9193    void schedule(std::unique_ptr<ScheduledNavigation>);
    9294
    93     static bool mustLockBackForwardList(Frame& targetFrame);
     95    static LockBackForwardList mustLockBackForwardList(Frame& targetFrame);
    9496
    9597    Frame& m_frame;
  • trunk/Source/WebCore/loader/SubframeLoader.cpp

    r166049 r166684  
    7777}
    7878
    79 bool SubframeLoader::requestFrame(HTMLFrameOwnerElement& ownerElement, const String& urlString, const AtomicString& frameName, bool lockHistory, bool lockBackForwardList)
     79bool SubframeLoader::requestFrame(HTMLFrameOwnerElement& ownerElement, const String& urlString, const AtomicString& frameName, LockHistory lockHistory, LockBackForwardList lockBackForwardList)
    8080{
    8181    // Support for <frame src="javascript:string">
     
    231231    // it will create a new frame and set it as the RenderWidget's Widget, causing what was previously
    232232    // in the widget to be torn down.
    233     return loadOrRedirectSubframe(ownerElement, completedURL, frameName, true, true);
     233    return loadOrRedirectSubframe(ownerElement, completedURL, frameName, LockHistory::Yes, LockBackForwardList::Yes);
    234234}
    235235
     
    321321}
    322322
    323 Frame* SubframeLoader::loadOrRedirectSubframe(HTMLFrameOwnerElement& ownerElement, const URL& url, const AtomicString& frameName, bool lockHistory, bool lockBackForwardList)
     323Frame* SubframeLoader::loadOrRedirectSubframe(HTMLFrameOwnerElement& ownerElement, const URL& url, const AtomicString& frameName, LockHistory lockHistory, LockBackForwardList lockBackForwardList)
    324324{
    325325    Frame* frame = ownerElement.contentFrame();
  • trunk/Source/WebCore/loader/SubframeLoader.h

    r165676 r166684  
    6060    void clear();
    6161
    62     bool requestFrame(HTMLFrameOwnerElement&, const String& url, const AtomicString& frameName, bool lockHistory = true, bool lockBackForwardList = true);
     62    bool requestFrame(HTMLFrameOwnerElement&, const String& url, const AtomicString& frameName, LockHistory = LockHistory::Yes, LockBackForwardList = LockBackForwardList::Yes);
    6363    bool requestObject(HTMLPlugInImageElement&, const String& url, const AtomicString& frameName,
    6464        const String& serviceType, const Vector<String>& paramNames, const Vector<String>& paramValues);
     
    7878private:
    7979    bool requestPlugin(HTMLPlugInImageElement&, const URL&, const String& serviceType, const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback);
    80     Frame* loadOrRedirectSubframe(HTMLFrameOwnerElement&, const URL&, const AtomicString& frameName, bool lockHistory, bool lockBackForwardList);
     80    Frame* loadOrRedirectSubframe(HTMLFrameOwnerElement&, const URL&, const AtomicString& frameName, LockHistory, LockBackForwardList);
    8181    Frame* loadSubframe(HTMLFrameOwnerElement&, const URL&, const String& name, const String& referrer);
    8282    bool loadPlugin(HTMLPlugInImageElement&, const URL&, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback);
  • trunk/Source/WebCore/page/ContextMenuController.cpp

    r165676 r166684  
    207207        return;
    208208    newPage->chrome().show();
    209     newPage->mainFrame().loader().loadFrameRequest(request, false, false, 0, 0, MaybeSendReferrer);
     209    newPage->mainFrame().loader().loadFrameRequest(request, LockHistory::No, LockBackForwardList::No, 0, 0, MaybeSendReferrer);
    210210}
    211211
     
    406406    case ContextMenuItemTagOpenLink:
    407407        if (Frame* targetFrame = m_context.hitTestResult().targetFrame())
    408             targetFrame->loader().loadFrameRequest(FrameLoadRequest(frame->document()->securityOrigin(), ResourceRequest(m_context.hitTestResult().absoluteLinkURL(), frame->loader().outgoingReferrer())), false, false, 0, 0, MaybeSendReferrer);
     408            targetFrame->loader().loadFrameRequest(FrameLoadRequest(frame->document()->securityOrigin(), ResourceRequest(m_context.hitTestResult().absoluteLinkURL(), frame->loader().outgoingReferrer())), LockHistory::No, LockBackForwardList::No, 0, 0, MaybeSendReferrer);
    409409        else
    410410            openNewWindow(m_context.hitTestResult().absoluteLinkURL(), frame);
    411411        break;
    412412    case ContextMenuItemTagOpenLinkInThisWindow:
    413         frame->loader().loadFrameRequest(FrameLoadRequest(frame->document()->securityOrigin(), ResourceRequest(m_context.hitTestResult().absoluteLinkURL(), frame->loader().outgoingReferrer())), false, false, 0, 0, MaybeSendReferrer);
     413        frame->loader().loadFrameRequest(FrameLoadRequest(frame->document()->securityOrigin(), ResourceRequest(m_context.hitTestResult().absoluteLinkURL(), frame->loader().outgoingReferrer())), LockHistory::No, LockBackForwardList::No, 0, 0, MaybeSendReferrer);
    414414        break;
    415415    case ContextMenuItemTagBold:
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r166551 r166684  
    19281928
    19291929    // We want a new history item if we are processing a user gesture.
     1930    LockHistory lockHistory = (locking != LockHistoryBasedOnGestureState || !ScriptController::processingUserGesture()) ? LockHistory::Yes : LockHistory::No;
     1931    LockBackForwardList lockBackForwardList = (locking != LockHistoryBasedOnGestureState) ? LockBackForwardList::Yes : LockBackForwardList::No;
    19301932    m_frame->navigationScheduler().scheduleLocationChange(activeDocument->securityOrigin(),
    19311933        // FIXME: What if activeDocument()->frame() is 0?
    19321934        completedURL, activeDocument->frame()->loader().outgoingReferrer(),
    1933         locking != LockHistoryBasedOnGestureState || !ScriptController::processingUserGesture(),
    1934         locking != LockHistoryBasedOnGestureState);
     1935        lockHistory, lockBackForwardList);
    19351936}
    19361937
     
    20442045
    20452046    if (created)
    2046         newFrame->loader().changeLocation(activeWindow.document()->securityOrigin(), completedURL, referrer, false, false);
     2047        newFrame->loader().changeLocation(activeWindow.document()->securityOrigin(), completedURL, referrer, LockHistory::No, LockBackForwardList::No);
    20472048    else if (!urlString.isEmpty()) {
    2048         bool lockHistory = !ScriptController::processingUserGesture();
    2049         newFrame->navigationScheduler().scheduleLocationChange(activeWindow.document()->securityOrigin(), completedURL.string(), referrer, lockHistory, false);
     2049        LockHistory lockHistory = ScriptController::processingUserGesture() ? LockHistory::No : LockHistory::Yes;
     2050        newFrame->navigationScheduler().scheduleLocationChange(activeWindow.document()->securityOrigin(), completedURL.string(), referrer, lockHistory, LockBackForwardList::No);
    20502051    }
    20512052
     
    21012102        // For whatever reason, Firefox uses the first window rather than the active window to
    21022103        // determine the outgoing referrer. We replicate that behavior here.
    2103         bool lockHistory = !ScriptController::processingUserGesture();
    2104         targetFrame->navigationScheduler().scheduleLocationChange(
    2105             activeDocument->securityOrigin(),
    2106             completedURL,
    2107             firstFrame->loader().outgoingReferrer(),
    2108             lockHistory,
    2109             false);
     2104        LockHistory lockHistory = ScriptController::processingUserGesture() ? LockHistory::No : LockHistory::Yes;
     2105        targetFrame->navigationScheduler().scheduleLocationChange(activeDocument->securityOrigin(), completedURL, firstFrame->loader().outgoingReferrer(),
     2106            lockHistory, LockBackForwardList::No);
    21102107        return targetFrame->document()->domWindow();
    21112108    }
  • trunk/Source/WebCore/svg/SVGAElement.cpp

    r165607 r166684  
    178178            if (!frame)
    179179                return;
    180             frame->loader().urlSelected(document().completeURL(url), target, event, false, false, MaybeSendReferrer);
     180            frame->loader().urlSelected(document().completeURL(url), target, event, LockHistory::No, LockBackForwardList::No, MaybeSendReferrer);
    181181            return;
    182182        }
  • trunk/Source/WebKit/mac/ChangeLog

    r166680 r166684  
     12014-04-02  Mark Rowe  <mrowe@apple.com>
     2
     3        <https://webkit.org/b/131135> Introduce LockHistory and LockBackForwardList enums to use in place of bools.
     4
     5        These arguments are often passed using literals at the call site, where the use of bools severely hinders
     6        the readability of the code.
     7
     8        Reviewed by Andreas Kling.
     9
     10        * WebView/WebPDFView.mm:
     11        (-[WebPDFView PDFViewWillClickOnLink:withURL:]):
     12
    1132014-04-02  Stephanie Lewis  <slewis@apple.com>
    214
  • trunk/Source/WebKit/mac/WebView/WebPDFView.mm

    r165676 r166684  
    10571057    // Call to the frame loader because this is where our security checks are made.
    10581058    Frame* frame = core([dataSource webFrame]);
    1059     frame->loader().loadFrameRequest(FrameLoadRequest(frame->document()->securityOrigin(), ResourceRequest(URL)), false, false, event.get(), 0, MaybeSendReferrer);
     1059    frame->loader().loadFrameRequest(FrameLoadRequest(frame->document()->securityOrigin(), ResourceRequest(URL)), LockHistory::No, LockBackForwardList::No, event.get(), 0, MaybeSendReferrer);
    10601060}
    10611061
  • trunk/Source/WebKit2/ChangeLog

    r166682 r166684  
     12014-04-02  Mark Rowe  <mrowe@apple.com>
     2
     3        <https://webkit.org/b/131135> Introduce LockHistory and LockBackForwardList enums to use in place of bools.
     4
     5        These arguments are often passed using literals at the call site, where the use of bools severely hinders
     6        the readability of the code.
     7
     8        Reviewed by Andreas Kling.
     9
     10        * WebProcess/Plugins/PDF/PDFPlugin.mm:
     11        (WebKit::PDFPlugin::clickedLink):
     12
    1132014-04-02  Tim Horton  <timothy_horton@apple.com>
    214
  • trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm

    r165014 r166684  
    15591559        coreEvent = MouseEvent::create(eventNames().clickEvent, frame->document()->defaultView(), platform(m_lastMouseEvent), 0, 0);
    15601560
    1561     frame->loader().urlSelected(url, emptyString(), coreEvent.get(), false, false, MaybeSendReferrer);
     1561    frame->loader().urlSelected(url, emptyString(), coreEvent.get(), LockHistory::No, LockBackForwardList::No, MaybeSendReferrer);
    15621562}
    15631563
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.cpp

    r164192 r166684  
    8787    if (Page* page = frame->page()) {
    8888        UserGestureIndicator indicator(DefinitelyProcessingUserGesture);
    89         page->mainFrame().loader().urlSelected(URL(ParsedURLString, url), String(), 0, false, false, MaybeSendReferrer);
     89        page->mainFrame().loader().urlSelected(URL(ParsedURLString, url), String(), 0, LockHistory::No, LockBackForwardList::No, MaybeSendReferrer);
    9090    }
    9191}
Note: See TracChangeset for help on using the changeset viewer.