Changeset 150282 in webkit


Ignore:
Timestamp:
May 17, 2013, 12:15:45 PM (12 years ago)
Author:
beidson@apple.com
Message:

Replace WebFrameLoaderClient static_casts with a function that might return null.
https://bugs.webkit.org/show_bug.cgi?id=116253

The general approach here is:
1 - Introduce a toWebFrameLoaderClient() function to convert FrameLoaderClients, and that may return null.
2 - Adopt toWebFrameLoaderClient() everywhere we used to do a direct static_cast<WebFrameLoaderClient*>
3 - In functions that already support a "return 0" scenario, a failed cast results in a return 0.
4 - In other functions that assume no failure to get the WebFrameLoaderClient, add an ASSERT.

Reviewed by Alexey Proskuryakov.

Add the utility function to cast:

  • WebProcess/WebCoreSupport/WebFrameLoaderClient.h:

(WebKit::toWebFrameLoaderClient):

Adopt it everywhere:

  • WebProcess/Geolocation/GeolocationPermissionRequestManager.cpp:

(WebKit::GeolocationPermissionRequestManager::startRequestForGeolocation):

  • WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:

(WebKit::InjectedBundleNodeHandle::documentFrame):
(WebKit::InjectedBundleNodeHandle::htmlFrameElementContentFrame):
(WebKit::InjectedBundleNodeHandle::htmlIFrameElementContentFrame):

  • WebProcess/InjectedBundle/InjectedBundle.cpp:

(WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner):

  • WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.cpp:

(WebKit::InjectedBundleDOMWindowExtension::frame):

  • WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp:

(WebKit::InjectedBundleHitTestResult::frame):
(WebKit::InjectedBundleHitTestResult::targetFrame):

  • WebProcess/Network/WebResourceLoadScheduler.cpp:

(WebKit::WebResourceLoadScheduler::scheduleLoad):

  • WebProcess/Plugins/PluginView.cpp:

(WebKit::webPage):
(WebKit::PluginView::performFrameLoadURLRequest):

  • WebProcess/WebCoreSupport/WebChromeClient.cpp:

(WebKit::WebChromeClient::focusedNodeChanged):
(WebKit::WebChromeClient::focusedFrameChanged):
(WebKit::WebChromeClient::runBeforeUnloadConfirmPanel):
(WebKit::WebChromeClient::runJavaScriptAlert):
(WebKit::WebChromeClient::runJavaScriptConfirm):
(WebKit::WebChromeClient::runJavaScriptPrompt):
(WebKit::WebChromeClient::print):
(WebKit::WebChromeClient::exceededDatabaseQuota):
(WebKit::WebChromeClient::runOpenPanel):

  • WebProcess/WebCoreSupport/WebEditorClient.cpp:

(WebKit::WebEditorClient::textFieldDidBeginEditing):
(WebKit::WebEditorClient::textFieldDidEndEditing):
(WebKit::WebEditorClient::textDidChangeInTextField):
(WebKit::WebEditorClient::textDidChangeInTextArea):
(WebKit::WebEditorClient::doTextFieldCommandFromEvent):
(WebKit::WebEditorClient::textWillBeDeletedInTextField):

  • WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:

(WebKit::WebFrameLoaderClient::dispatchWillSendSubmitEvent):
(WebKit::WebFrameLoaderClient::dispatchWillSubmitForm):

  • WebProcess/WebPage/WebFrame.cpp:

(WebKit::WebFrame::contentsAsString):
(WebKit::WebFrame::parentFrame):
(WebKit::WebFrame::childFrames):
(WebKit::WebFrame::frameForContext):
(WebKit::WebFrameFilter::shouldIncludeSubframe):

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::mainFrameHasCustomRepresentation):

Location:
trunk/Source/WebKit2
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r150277 r150282  
     12013-05-17  Brady Eidson  <beidson@apple.com>
     2
     3        Replace WebFrameLoaderClient static_casts with a function that might return null.
     4        https://bugs.webkit.org/show_bug.cgi?id=116253
     5
     6        The general approach here is:
     7        1 - Introduce a toWebFrameLoaderClient() function to convert FrameLoaderClients, and that may return null.
     8        2 - Adopt toWebFrameLoaderClient() everywhere we used to do a direct static_cast<WebFrameLoaderClient*>
     9        3 - In functions that already support a "return 0" scenario, a failed cast results in a return 0.
     10        4 - In other functions that assume no failure to get the WebFrameLoaderClient, add an ASSERT.
     11
     12        Reviewed by Alexey Proskuryakov.
     13
     14        Add the utility function to cast:
     15        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
     16        (WebKit::toWebFrameLoaderClient):
     17
     18        Adopt it everywhere:
     19        * WebProcess/Geolocation/GeolocationPermissionRequestManager.cpp:
     20        (WebKit::GeolocationPermissionRequestManager::startRequestForGeolocation):
     21
     22        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
     23        (WebKit::InjectedBundleNodeHandle::documentFrame):
     24        (WebKit::InjectedBundleNodeHandle::htmlFrameElementContentFrame):
     25        (WebKit::InjectedBundleNodeHandle::htmlIFrameElementContentFrame):
     26
     27        * WebProcess/InjectedBundle/InjectedBundle.cpp:
     28        (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner):
     29
     30        * WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.cpp:
     31        (WebKit::InjectedBundleDOMWindowExtension::frame):
     32
     33        * WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp:
     34        (WebKit::InjectedBundleHitTestResult::frame):
     35        (WebKit::InjectedBundleHitTestResult::targetFrame):
     36
     37        * WebProcess/Network/WebResourceLoadScheduler.cpp:
     38        (WebKit::WebResourceLoadScheduler::scheduleLoad):
     39
     40        * WebProcess/Plugins/PluginView.cpp:
     41        (WebKit::webPage):
     42        (WebKit::PluginView::performFrameLoadURLRequest):
     43
     44        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
     45        (WebKit::WebChromeClient::focusedNodeChanged):
     46        (WebKit::WebChromeClient::focusedFrameChanged):
     47        (WebKit::WebChromeClient::runBeforeUnloadConfirmPanel):
     48        (WebKit::WebChromeClient::runJavaScriptAlert):
     49        (WebKit::WebChromeClient::runJavaScriptConfirm):
     50        (WebKit::WebChromeClient::runJavaScriptPrompt):
     51        (WebKit::WebChromeClient::print):
     52        (WebKit::WebChromeClient::exceededDatabaseQuota):
     53        (WebKit::WebChromeClient::runOpenPanel):
     54
     55        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
     56        (WebKit::WebEditorClient::textFieldDidBeginEditing):
     57        (WebKit::WebEditorClient::textFieldDidEndEditing):
     58        (WebKit::WebEditorClient::textDidChangeInTextField):
     59        (WebKit::WebEditorClient::textDidChangeInTextArea):
     60        (WebKit::WebEditorClient::doTextFieldCommandFromEvent):
     61        (WebKit::WebEditorClient::textWillBeDeletedInTextField):
     62
     63        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     64        (WebKit::WebFrameLoaderClient::dispatchWillSendSubmitEvent):
     65        (WebKit::WebFrameLoaderClient::dispatchWillSubmitForm):
     66
     67        * WebProcess/WebPage/WebFrame.cpp:
     68        (WebKit::WebFrame::contentsAsString):
     69        (WebKit::WebFrame::parentFrame):
     70        (WebKit::WebFrame::childFrames):
     71        (WebKit::WebFrame::frameForContext):
     72        (WebKit::WebFrameFilter::shouldIncludeSubframe):
     73
     74        * WebProcess/WebPage/WebPage.cpp:
     75        (WebKit::WebPage::mainFrameHasCustomRepresentation):
     76
    1772013-05-17  Sam Weinig  <sam@webkit.org>
    278
  • trunk/Source/WebKit2/WebProcess/Geolocation/GeolocationPermissionRequestManager.cpp

    r144568 r150282  
    6363    Frame* frame = geolocation->frame();
    6464
    65     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
     65    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader()->client());
     66    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     67    ASSERT(webFrame);
     68
    6669    SecurityOrigin* origin = frame->document()->securityOrigin();
    6770
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp

    r148238 r150282  
    236236        return 0;
    237237
    238     return static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
     238    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader()->client());
     239    return webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
    239240}
    240241
     
    248249        return 0;
    249250
    250     return static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
     251    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader()->client());
     252    return webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
    251253}
    252254
     
    260262        return 0;
    261263
    262     return static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
     264    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader()->client());
     265    return webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
    263266}
    264267
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp

    r149848 r150282  
    162162
    163163    if (preference == "WebKitTabToLinksPreferenceKey") {
    164        WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::tabsToLinksKey(), enabled);
    165        for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) {
    166             WebPage* webPage = static_cast<WebFrameLoaderClient*>((*i)->mainFrame()->loader()->client())->webFrame()->page();
    167             webPage->setTabToLinksEnabled(enabled);
     164        WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::tabsToLinksKey(), enabled);
     165        for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) {
     166            WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient((*i)->mainFrame()->loader()->client());
     167            ASSERT(webFrameLoaderClient);
     168            webFrameLoaderClient->webFrame()->page()->setTabToLinksEnabled(enabled);
    168169        }
    169170    }
     
    172173        WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::asynchronousPluginInitializationEnabledKey(), enabled);
    173174        for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) {
    174             WebPage* webPage = static_cast<WebFrameLoaderClient*>((*i)->mainFrame()->loader()->client())->webFrame()->page();
    175             webPage->setAsynchronousPluginInitializationEnabled(enabled);
     175            WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient((*i)->mainFrame()->loader()->client());
     176            ASSERT(webFrameLoaderClient);
     177            webFrameLoaderClient->webFrame()->page()->setAsynchronousPluginInitializationEnabled(enabled);
    176178        }
    177179    }
     
    180182        WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::asynchronousPluginInitializationEnabledForAllPluginsKey(), enabled);
    181183        for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) {
    182             WebPage* webPage = static_cast<WebFrameLoaderClient*>((*i)->mainFrame()->loader()->client())->webFrame()->page();
    183             webPage->setAsynchronousPluginInitializationEnabledForAllPlugins(enabled);
     184            WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient((*i)->mainFrame()->loader()->client());
     185            ASSERT(webFrameLoaderClient);
     186            webFrameLoaderClient->webFrame()->page()->setAsynchronousPluginInitializationEnabledForAllPlugins(enabled);
    184187        }
    185188    }
     
    188191        WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::artificialPluginInitializationDelayEnabledKey(), enabled);
    189192        for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) {
    190             WebPage* webPage = static_cast<WebFrameLoaderClient*>((*i)->mainFrame()->loader()->client())->webFrame()->page();
    191             webPage->setArtificialPluginInitializationDelayEnabled(enabled);
     193            WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient((*i)->mainFrame()->loader()->client());
     194            ASSERT(webFrameLoaderClient);
     195            webFrameLoaderClient->webFrame()->page()->setArtificialPluginInitializationDelayEnabled(enabled);
    192196        }
    193197    }
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.cpp

    r148373 r150282  
    7272WebFrame* InjectedBundleDOMWindowExtension::frame() const
    7373{
    74     WebCore::Frame* frame = m_coreExtension->frame();
    75     return frame ? static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame() : 0;
     74    Frame* frame = m_coreExtension->frame();
     75    WebFrameLoaderClient* webFrameLoaderClient = frame ? toWebFrameLoaderClient(frame->loader()->client()) : 0;
     76    return webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
    7677}
    7778
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp

    r97810 r150282  
    6565        return 0;
    6666
    67     return static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
     67    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader()->client());
     68    return webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
    6869}
    6970
     
    7475        return 0;
    7576
    76     return static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
     77    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader()->client());
     78    return webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
    7779}
    7880
  • trunk/Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.cpp

    r150206 r150282  
    109109    // EmptyFrameLoaderClient shouldn't exist and everything should be using a WebFrameLoaderClient,
    110110    // but in the meantime we have to make sure not to mis-cast.
    111     WebFrame* webFrame = 0;
    112     WebPage* webPage = 0;
    113     if (!resourceLoader->frameLoader()->client()->isEmptyFrameLoaderClient()) {
    114         webFrame = static_cast<WebFrameLoaderClient*>(resourceLoader->frameLoader()->client())->webFrame();
    115         webPage = webFrame->page();
    116     }
     111    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(resourceLoader->frameLoader()->client());
     112    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     113    WebPage* webPage = webFrame ? webFrame->page() : 0;
    117114
    118115    NetworkResourceLoadParameters loadParameters;
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp

    r150214 r150282  
    254254    ASSERT(frame);
    255255
    256     WebPage* webPage = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame()->page();
     256    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader()->client());
     257    WebPage* webPage = webFrameLoaderClient ? webFrameLoaderClient->webFrame()->page() : 0;
    257258    ASSERT(webPage);
    258259
     
    11041105    targetFrame->loader()->load(FrameLoadRequest(targetFrame, request->request()));
    11051106
    1106     WebFrame* targetWebFrame = static_cast<WebFrameLoaderClient*>(targetFrame->loader()->client())->webFrame();
     1107    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(targetFrame->loader()->client());
     1108    WebFrame* targetWebFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     1109    ASSERT(targetWebFrame);
     1110
    11071111    if (WebFrame::LoadListener* loadListener = targetWebFrame->loadListener()) {
    11081112        // Check if another plug-in view or even this view is waiting for the frame to load.
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r149971 r150282  
    171171        return;
    172172
    173     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(node->document()->frame()->loader()->client())->webFrame();
     173    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(node->document()->frame()->loader()->client());
     174    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     175    ASSERT(webFrame);
    174176    m_page->injectedBundleFormClient().didFocusTextField(m_page, inputElement, webFrame);
    175177}
     
    177179void WebChromeClient::focusedFrameChanged(Frame* frame)
    178180{
    179     WebFrame* webFrame = frame ? static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame() : 0;
     181    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader()->client());
     182    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
    180183
    181184    WebProcess::shared().connection()->send(Messages::WebPageProxy::FocusedFrameChanged(webFrame ? webFrame->frameID() : 0), m_page->pageID());
     
    299302bool WebChromeClient::runBeforeUnloadConfirmPanel(const String& message, Frame* frame)
    300303{
    301     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
     304    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader()->client());
     305    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     306    ASSERT(webFrame);
    302307
    303308    bool shouldClose = false;
     
    329334void WebChromeClient::runJavaScriptAlert(Frame* frame, const String& alertText)
    330335{
    331     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
     336    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader()->client());
     337    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     338    ASSERT(webFrame);
    332339
    333340    // Notify the bundle client.
     
    340347bool WebChromeClient::runJavaScriptConfirm(Frame* frame, const String& message)
    341348{
    342     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
     349    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader()->client());
     350    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     351    ASSERT(webFrame);
    343352
    344353    // Notify the bundle client.
     
    355364bool WebChromeClient::runJavaScriptPrompt(Frame* frame, const String& message, const String& defaultValue, String& result)
    356365{
    357     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
     366    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader()->client());
     367    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     368    ASSERT(webFrame);
    358369
    359370    // Notify the bundle client.
     
    560571void WebChromeClient::print(Frame* frame)
    561572{
    562     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
     573    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader()->client());
     574    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     575    ASSERT(webFrame);
     576
    563577    m_page->sendSync(Messages::WebPageProxy::PrintFrame(webFrame->frameID()), Messages::WebPageProxy::PrintFrame::Reply());
    564578}
     
    567581void WebChromeClient::exceededDatabaseQuota(Frame* frame, const String& databaseName, DatabaseDetails details)
    568582{
    569     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
     583    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader()->client());
     584    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     585    ASSERT(webFrame);
     586   
    570587    SecurityOrigin* origin = frame->document()->securityOrigin();
    571588
     
    660677
    661678    m_page->setActiveOpenPanelResultListener(WebOpenPanelResultListener::create(m_page, fileChooser.get()));
    662     m_page->send(Messages::WebPageProxy::RunOpenPanel(static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame()->frameID(), fileChooser->settings()));
     679
     680    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader()->client());
     681    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     682    ASSERT(webFrame);
     683
     684    m_page->send(Messages::WebPageProxy::RunOpenPanel(webFrame->frameID(), fileChooser->settings()));
    663685}
    664686
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp

    r150140 r150282  
    321321        return;
    322322
    323     WebFrame* webFrame =  static_cast<WebFrameLoaderClient*>(element->document()->frame()->loader()->client())->webFrame();
     323    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(element->document()->frame()->loader()->client());
     324    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     325    ASSERT(webFrame);
     326
    324327    m_page->injectedBundleFormClient().textFieldDidBeginEditing(m_page, static_cast<HTMLInputElement*>(element), webFrame);
    325328}
     
    330333        return;
    331334
    332     WebFrame* webFrame =  static_cast<WebFrameLoaderClient*>(element->document()->frame()->loader()->client())->webFrame();
     335    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(element->document()->frame()->loader()->client());
     336    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     337    ASSERT(webFrame);
     338
    333339    m_page->injectedBundleFormClient().textFieldDidEndEditing(m_page, static_cast<HTMLInputElement*>(element), webFrame);
    334340}
     
    342348        return;
    343349
    344     WebFrame* webFrame =  static_cast<WebFrameLoaderClient*>(element->document()->frame()->loader()->client())->webFrame();
     350    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(element->document()->frame()->loader()->client());
     351    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     352    ASSERT(webFrame);
     353
    345354    m_page->injectedBundleFormClient().textDidChangeInTextField(m_page, static_cast<HTMLInputElement*>(element), webFrame);
    346355}
     
    351360        return;
    352361
    353     WebFrame* webFrame =  static_cast<WebFrameLoaderClient*>(element->document()->frame()->loader()->client())->webFrame();
     362    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(element->document()->frame()->loader()->client());
     363    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     364    ASSERT(webFrame);
     365
    354366    m_page->injectedBundleFormClient().textDidChangeInTextArea(m_page, static_cast<HTMLTextAreaElement*>(element), webFrame);
    355367}
     
    386398        return false;
    387399
    388     WebFrame* webFrame =  static_cast<WebFrameLoaderClient*>(element->document()->frame()->loader()->client())->webFrame();
     400    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(element->document()->frame()->loader()->client());
     401    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     402    ASSERT(webFrame);
     403
    389404    return m_page->injectedBundleFormClient().shouldPerformActionInTextField(m_page, static_cast<HTMLInputElement*>(element), actionType, webFrame);
    390405}
     
    395410        return;
    396411
    397     WebFrame* webFrame =  static_cast<WebFrameLoaderClient*>(element->document()->frame()->loader()->client())->webFrame();
     412    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(element->document()->frame()->loader()->client());
     413    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     414    ASSERT(webFrame);
     415
    398416    m_page->injectedBundleFormClient().shouldPerformActionInTextField(m_page, static_cast<HTMLInputElement*>(element), WKInputFieldActionTypeInsertDelete, webFrame);
    399417}
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r150227 r150282  
    736736    RefPtr<FormState> formState = prpFormState;
    737737    HTMLFormElement* form = formState->form();
    738     WebFrame* sourceFrame = static_cast<WebFrameLoaderClient*>(formState->sourceDocument()->frame()->loader()->client())->webFrame();
     738
     739    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(formState->sourceDocument()->frame()->loader()->client());
     740    WebFrame* sourceFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     741    ASSERT(sourceFrame);
    739742
    740743    webPage->injectedBundleFormClient().willSendSubmitEvent(webPage, form, m_frame, sourceFrame, formState->textFieldValues());
     
    751754   
    752755    HTMLFormElement* form = formState->form();
    753     WebFrame* sourceFrame = static_cast<WebFrameLoaderClient*>(formState->sourceDocument()->frame()->loader()->client())->webFrame();
     756
     757    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(formState->sourceDocument()->frame()->loader()->client());
     758    WebFrame* sourceFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     759    ASSERT(sourceFrame);
     760
    754761    const Vector<std::pair<String, String>>& values = formState->textFieldValues();
    755762
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h

    r149830 r150282  
    233233};
    234234
     235// As long as EmptyFrameLoaderClient exists in WebCore, this can return 0.
     236inline WebFrameLoaderClient* toWebFrameLoaderClient(WebCore::FrameLoaderClient* client)
     237{
     238    return client->isEmptyFrameLoaderClient() ? 0 : static_cast<WebFrameLoaderClient*>(client);
     239}
     240
    235241} // namespace WebKit
    236242
  • trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp

    r150140 r150282  
    296296            if (!builder.isEmpty())
    297297                builder.append(' ');
    298             builder.append(static_cast<WebFrameLoaderClient*>(child->loader()->client())->webFrame()->contentsAsString());
     298
     299            WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(child->loader()->client());
     300            WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     301            ASSERT(webFrame);
     302
     303            builder.append(webFrame->contentsAsString());
    299304        }
    300305        // FIXME: It may make sense to use toStringPreserveCapacity() here.
     
    395400        return 0;
    396401
    397     return static_cast<WebFrameLoaderClient*>(m_coreFrame->ownerElement()->document()->frame()->loader()->client())->webFrame();
     402    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(m_coreFrame->ownerElement()->document()->frame()->loader()->client());
     403    return webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
    398404}
    399405
     
    411417
    412418    for (Frame* child = m_coreFrame->tree()->firstChild(); child; child = child->tree()->nextSibling()) {
    413         WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(child->loader()->client())->webFrame();
     419        WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(child->loader()->client());
     420        WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     421        ASSERT(webFrame);
    414422        vector.uncheckedAppend(webFrame);
    415423    }
     
    614622
    615623    Frame* coreFrame = static_cast<JSDOMWindowShell*>(globalObjectObj)->window()->impl()->frame();
    616     return static_cast<WebFrameLoaderClient*>(coreFrame->loader()->client())->webFrame();
     624
     625    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(coreFrame->loader()->client());
     626    return webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
    617627}
    618628
     
    737747    if (!m_callback)
    738748        return true;
    739        
    740     WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
     749
     750    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader()->client());
     751    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
     752    ASSERT(webFrame);
     753
    741754    return m_callback(toAPI(m_topLevelWebFrame), toAPI(webFrame), m_context);
    742755}
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r150271 r150282  
    29762976bool WebPage::mainFrameHasCustomRepresentation() const
    29772977{
    2978     if (Frame* frame = mainFrame())
    2979         return static_cast<WebFrameLoaderClient*>(frame->loader()->client())->frameHasCustomRepresentation();
     2978    if (Frame* frame = mainFrame()) {
     2979        WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader()->client());
     2980        ASSERT(webFrameLoaderClient);
     2981        return webFrameLoaderClient->frameHasCustomRepresentation();
     2982    }
    29802983
    29812984    return false;
Note: See TracChangeset for help on using the changeset viewer.