Changeset 154678 in webkit


Ignore:
Timestamp:
Aug 27, 2013 6:00:34 AM (11 years ago)
Author:
akling@apple.com
Message:

FocusController::focusedOrMainFrame() should return a reference.
<https://webkit.org/b/120339>

Reviewed by Antti Koivisto.

Now that Page::mainFrame() returns a reference, we can make this return a reference
too, since there's always either a focused or a main frame.

One hectogram of null checks removed as a result.

Location:
trunk/Source
Files:
30 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r154676 r154678  
     12013-08-26  Andreas Kling  <akling@apple.com>
     2
     3        FocusController::focusedOrMainFrame() should return a reference.
     4        <https://webkit.org/b/120339>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Now that Page::mainFrame() returns a reference, we can make this return a reference
     9        too, since there's always either a focused or a main frame.
     10
     11        One hectogram of null checks removed as a result.
     12
    1132013-08-26  Andreas Kling  <akling@apple.com>
    214
  • trunk/Source/WebCore/accessibility/AXObjectCache.cpp

    r154580 r154678  
    162162
    163163    // get the focused node in the page
    164     Document* focusedDocument = page->focusController().focusedOrMainFrame()->document();
     164    Document* focusedDocument = page->focusController().focusedOrMainFrame().document();
    165165    Element* focusedElement = focusedDocument->focusedElement();
    166166    if (focusedElement && isHTMLAreaElement(focusedElement))
  • trunk/Source/WebCore/editing/Editor.cpp

    r154663 r154678  
    985985            if (Frame* editedFrame = document->frame())
    986986                if (Page* page = editedFrame->page())
    987                     page->focusController().focusedOrMainFrame()->selection().revealSelection(ScrollAlignment::alignCenterIfNeeded);
     987                    page->focusController().focusedOrMainFrame().selection().revealSelection(ScrollAlignment::alignCenterIfNeeded);
    988988        }
    989989    }
  • trunk/Source/WebCore/history/CachedPage.cpp

    r154658 r154678  
    8585    // Restore the focus appearance for the focused element.
    8686    // FIXME: Right now we don't support pages w/ frames in the b/f cache.  This may need to be tweaked when we add support for that.
    87     Document* focusedDocument = page->focusController().focusedOrMainFrame()->document();
     87    Document* focusedDocument = page->focusController().focusedOrMainFrame().document();
    8888    if (Element* element = focusedDocument->focusedElement())
    8989        element->updateFocusAppearance(true);
  • trunk/Source/WebCore/page/EventHandler.cpp

    r154673 r154678  
    19661966    if (!m_frame->page())
    19671967        return false;
    1968     Frame* focusFrame = m_frame->page()->focusController().focusedOrMainFrame();
     1968    Frame& focusFrame = m_frame->page()->focusController().focusedOrMainFrame();
    19691969    // Do not paste here if the focus was moved somewhere else.
    1970     if (m_frame == focusFrame && m_frame->editor().client()->supportsGlobalSelection())
     1970    if (m_frame == &focusFrame && m_frame->editor().client()->supportsGlobalSelection())
    19711971        return m_frame->editor().command(ASCIILiteral("PasteGlobalSelection")).execute();
    19721972
     
    33373337        node->dispatchEvent(keydown, IGNORE_EXCEPTION);
    33383338        // If frame changed as a result of keydown dispatch, then return true to avoid sending a subsequent keypress message to the new frame.
    3339         bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()->focusController().focusedOrMainFrame();
     3339        bool changedFocusedFrame = m_frame->page() && m_frame != &m_frame->page()->focusController().focusedOrMainFrame();
    33403340        return keydown->defaultHandled() || keydown->defaultPrevented() || changedFocusedFrame;
    33413341    }
     
    33593359    node->dispatchEvent(keydown, IGNORE_EXCEPTION);
    33603360    // If frame changed as a result of keydown dispatch, then return early to avoid sending a subsequent keypress message to the new frame.
    3361     bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()->focusController().focusedOrMainFrame();
     3361    bool changedFocusedFrame = m_frame->page() && m_frame != &m_frame->page()->focusController().focusedOrMainFrame();
    33623362    bool keydownResult = keydown->defaultHandled() || keydown->defaultPrevented() || changedFocusedFrame;
    33633363    if (handledByInputMethod || (keydownResult && !backwardCompatibilityMode))
  • trunk/Source/WebCore/page/FocusController.cpp

    r154658 r154678  
    205205}
    206206
    207 Frame* FocusController::focusedOrMainFrame() const
     207Frame& FocusController::focusedOrMainFrame() const
    208208{
    209209    if (Frame* frame = focusedFrame())
    210         return frame;
    211     return &m_page->mainFrame();
     210        return *frame;
     211    return m_page->mainFrame();
    212212}
    213213
     
    220220
    221221    if (!m_isFocused)
    222         focusedOrMainFrame()->eventHandler().stopAutoscrollTimer();
     222        focusedOrMainFrame().eventHandler().stopAutoscrollTimer();
    223223
    224224    if (!m_focusedFrame)
     
    256256    // into the web area again, even if focus did not change within WebCore. PostNotification is called instead
    257257    // of handleFocusedUIElementChanged, because this will send the notification even if the element is the same.
    258     if (AXObjectCache* cache = focusedOrMainFrame()->document()->existingAXObjectCache())
    259         cache->postNotification(focusedOrMainFrame()->document(), AXObjectCache::AXFocusedUIElementChanged, true);
     258    if (AXObjectCache* cache = focusedOrMainFrame().document()->existingAXObjectCache())
     259        cache->postNotification(focusedOrMainFrame().document(), AXObjectCache::AXFocusedUIElementChanged, true);
    260260
    261261    return didAdvanceFocus;
     
    282282bool FocusController::advanceFocusInDocumentOrder(FocusDirection direction, KeyboardEvent* event, bool initialFocus)
    283283{
    284     Frame* frame = focusedOrMainFrame();
    285     ASSERT(frame);
    286     Document* document = frame->document();
     284    Frame& frame = focusedOrMainFrame();
     285    Document* document = frame.document();
    287286
    288287    Node* currentNode = document->focusedElement();
    289288    // FIXME: Not quite correct when it comes to focus transitions leaving/entering the WebView itself
    290     bool caretBrowsing = frame->settings().caretBrowsingEnabled();
     289    bool caretBrowsing = frame.settings().caretBrowsingEnabled();
    291290
    292291    if (caretBrowsing && !currentNode)
    293         currentNode = frame->selection().start().deprecatedNode();
     292        currentNode = frame.selection().start().deprecatedNode();
    294293
    295294    document->updateLayoutIgnorePendingStylesheets();
     
    350349        Position position = firstPositionInOrBeforeNode(element.get());
    351350        VisibleSelection newSelection(position, position, DOWNSTREAM);
    352         if (frame->selection().shouldChangeSelection(newSelection))
    353             frame->selection().setSelection(newSelection);
     351        if (frame.selection().shouldChangeSelection(newSelection))
     352            frame.selection().setSelection(newSelection);
    354353    }
    355354
     
    661660    }
    662661
    663     focusedOrMainFrame()->selection().pageActivationChanged();
     662    focusedOrMainFrame().selection().pageActivationChanged();
    664663   
    665664    if (m_focusedFrame && isFocused())
     
    829828        // Navigate into a new frame.
    830829        LayoutRect rect;
    831         Element* focusedElement = focusedOrMainFrame()->document()->focusedElement();
     830        Element* focusedElement = focusedOrMainFrame().document()->focusedElement();
    832831        if (focusedElement && !hasOffscreenRect(focusedElement))
    833832            rect = nodeRectInAbsoluteCoordinates(focusedElement, true /* ignore border */);
     
    847846        // Navigate into a new scrollable container.
    848847        LayoutRect startingRect;
    849         Element* focusedElement = focusedOrMainFrame()->document()->focusedElement();
     848        Element* focusedElement = focusedOrMainFrame().document()->focusedElement();
    850849        if (focusedElement && !hasOffscreenRect(focusedElement))
    851850            startingRect = nodeRectInAbsoluteCoordinates(focusedElement, true);
     
    868867bool FocusController::advanceFocusDirectionally(FocusDirection direction, KeyboardEvent* event)
    869868{
    870     Frame* curFrame = focusedOrMainFrame();
    871     ASSERT(curFrame);
    872 
    873     Document* focusedDocument = curFrame->document();
     869    Document* focusedDocument = focusedOrMainFrame().document();
    874870    if (!focusedDocument)
    875871        return false;
  • trunk/Source/WebCore/page/FocusController.h

    r150869 r154678  
    6767    void setFocusedFrame(PassRefPtr<Frame>);
    6868    Frame* focusedFrame() const { return m_focusedFrame.get(); }
    69     Frame* focusedOrMainFrame() const;
     69    Frame& focusedOrMainFrame() const;
    7070
    7171    bool setInitialFocus(FocusDirection, KeyboardEvent*);
  • trunk/Source/WebCore/page/Page.cpp

    r154658 r154678  
    566566
    567567    bool shouldWrap = options & WrapAround;
    568     Frame* frame = focusController().focusedOrMainFrame();
     568    Frame* frame = &focusController().focusedOrMainFrame();
    569569    Frame* startFrame = frame;
    570570    do {
     
    698698const VisibleSelection& Page::selection() const
    699699{
    700     return focusController().focusedOrMainFrame()->selection().selection();
     700    return focusController().focusedOrMainFrame().selection().selection();
    701701}
    702702
  • trunk/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp

    r154558 r154678  
    300300    DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page);
    301301
    302     page->focusController().focusedOrMainFrame()->editor().command(name).execute(value);
     302    page->focusController().focusedOrMainFrame().editor().command(name).execute(value);
    303303}
    304304
     
    349349    DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page, false);
    350350
    351     return page->focusController().focusedOrMainFrame()->editor().command(name).isEnabled();
     351    return page->focusController().focusedOrMainFrame().editor().command(name).isEnabled();
    352352}
    353353
     
    566566    DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page);
    567567
    568     if (!page->focusController().focusedOrMainFrame())
    569         return;
    570 
    571     WebCore::Editor& editor = page->focusController().focusedOrMainFrame()->editor();
     568    WebCore::Editor& editor = page->focusController().focusedOrMainFrame().editor();
    572569    if (!editor.canEdit() && !editor.hasComposition())
    573570        return;
     
    583580    DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page, false);
    584581
    585     if (!page->focusController().focusedOrMainFrame())
    586         return false;
    587 
    588     return page->focusController().focusedOrMainFrame()->editor().hasComposition();
     582    return page->focusController().focusedOrMainFrame().editor().hasComposition();
    589583}
    590584
     
    595589    DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page, false);
    596590
    597     if (!page->focusController().focusedOrMainFrame())
    598         return false;
    599 
    600     WebCore::Editor& editor = page->focusController().focusedOrMainFrame()->editor();
     591    WebCore::Editor& editor = page->focusController().focusedOrMainFrame().editor();
    601592    if (!editor.hasComposition())
    602593        return false;
     
    611602    DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page);
    612603
    613     if (!page->focusController().focusedOrMainFrame())
    614         return;
    615 
    616     WebCore::Editor& editor = page->focusController().focusedOrMainFrame()->editor();
     604    WebCore::Editor& editor = page->focusController().focusedOrMainFrame().editor();
    617605
    618606    if (!editor.hasComposition()) {
     
    632620    DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page, WebCore::IntRect());
    633621
    634     if (!page->focusController().focusedOrMainFrame())
    635         return WebCore::IntRect();
    636 
    637622    if ((location + length < location) && (location + length))
    638623        length = 0;
    639624
    640     WebCore::Frame* frame = page->focusController().focusedOrMainFrame();
    641 
    642     RefPtr<WebCore::Range> range = WebCore::TextIterator::rangeFromLocationAndLength(frame->selection().rootEditableElementOrDocumentElement(), location, length);
     625    WebCore::Frame& frame = page->focusController().focusedOrMainFrame();
     626
     627    RefPtr<WebCore::Range> range = WebCore::TextIterator::rangeFromLocationAndLength(frame.selection().rootEditableElementOrDocumentElement(), location, length);
    643628    if (!range)
    644629        return WebCore::IntRect();
    645630
    646     return frame->editor().firstRectForRange(range.get());
     631    return frame.editor().firstRectForRange(range.get());
    647632}
    648633
     
    654639    DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page, false);
    655640
    656     if (!page->focusController().focusedOrMainFrame())
    657         return false;
    658 
    659     WebCore::Frame* frame = page->focusController().focusedOrMainFrame();
    660     RefPtr<WebCore::Range> range = frame->selection().toNormalizedRange().get();
     641    WebCore::Frame& frame = page->focusController().focusedOrMainFrame();
     642    RefPtr<WebCore::Range> range = frame.selection().toNormalizedRange().get();
    661643    if (!range)
    662644        return false;
    663645
    664     WebCore::Element* selectionRoot = frame->selection().rootEditableElement();
    665     WebCore::Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement();
     646    WebCore::Element* selectionRoot = frame.selection().rootEditableElement();
     647    WebCore::Element* scope = selectionRoot ? selectionRoot : frame.document()->documentElement();
    666648
    667649    RefPtr<WebCore::Range> testRange = WebCore::Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset());
  • trunk/Source/WebKit/efl/ewk/ewk_view.cpp

    r154658 r154678  
    15741574    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
    15751575    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
    1576     CString selectedString = priv->page->focusController().focusedOrMainFrame()->editor().selectedText().utf8();
     1576    CString selectedString = priv->page->focusController().focusedOrMainFrame().editor().selectedText().utf8();
    15771577    if (selectedString.isNull())
    15781578        return 0;
     
    15891589        return false;
    15901590
    1591     return priv->page->focusController().focusedOrMainFrame()->editor().command(commandString).execute(WTF::String::fromUTF8(value));
     1591    return priv->page->focusController().focusedOrMainFrame().editor().command(commandString).execute(WTF::String::fromUTF8(value));
    15921592}
    15931593
     
    29462946    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
    29472947    EWK_VIEW_PRIV_GET(smartData, priv);
    2948     WebCore::Frame* focusedFrame = priv->page->focusController().focusedOrMainFrame();
     2948    WebCore::Frame& focusedFrame = priv->page->focusController().focusedOrMainFrame();
    29492949
    29502950    priv->imh = 0;
    2951     if (focusedFrame
    2952         && focusedFrame->document()
    2953         && focusedFrame->document()->focusedElement()
    2954         && isHTMLInputElement(focusedFrame->document()->focusedElement())) {
     2951    if (focusedFrame.document()
     2952        && focusedFrame.document()->focusedElement()
     2953        && isHTMLInputElement(focusedFrame.document()->focusedElement())) {
    29552954        WebCore::HTMLInputElement* inputElement;
    29562955
    2957         inputElement = static_cast<WebCore::HTMLInputElement*>(focusedFrame->document()->focusedElement());
     2956        inputElement = static_cast<WebCore::HTMLInputElement*>(focusedFrame.document()->focusedElement());
    29582957        if (inputElement) {
    29592958            // for password fields, active == false
     
    40124011    // attribute and its CSS "direction" property.
    40134012    // So, we just call the function as Safari does.
    4014     WebCore::Frame* focusedFrame = priv->page->focusController().focusedOrMainFrame();
    4015     if (!focusedFrame)
    4016         return;
    4017 
    4018     WebCore::Editor& editor = focusedFrame->editor();
     4013    WebCore::Frame& focusedFrame = priv->page->focusController().focusedOrMainFrame();
     4014
     4015    WebCore::Editor& editor = focusedFrame.editor();
    40194016    if (!editor.canEdit())
    40204017        return;
  • trunk/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp

    r154658 r154678  
    624624    // synced with cursor movement. For instance, a text field can move without
    625625    // the selection changing.
    626     Frame* focusedFrame = core(m_webView)->focusController().focusedOrMainFrame();
    627     if (focusedFrame && focusedFrame->editor().canEdit())
     626    Frame& focusedFrame = core(m_webView)->focusController().focusedOrMainFrame();
     627    if (focusedFrame.editor().canEdit())
    628628        m_webView->priv->imFilter.setCursorRect(frame.selection().absoluteCaretBounds());
    629629}
  • trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp

    r154558 r154678  
    277277    g_return_if_fail(value);
    278278
    279     core(webView)->focusController().focusedOrMainFrame()->editor().command(name).execute(value);
     279    core(webView)->focusController().focusedOrMainFrame().editor().command(name).execute(value);
    280280}
    281281
     
    285285    g_return_val_if_fail(name, FALSE);
    286286
    287     return core(webView)->focusController().focusedOrMainFrame()->editor().command(name).isEnabled();
     287    return core(webView)->focusController().focusedOrMainFrame().editor().command(name).isEnabled();
    288288}
    289289
     
    293293    g_return_if_fail(text);
    294294
    295     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    296     if (!frame)
    297         return;
    298 
    299     Editor& editor = frame->editor();
     295    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     296    Editor& editor = frame.editor();
    300297    if (!editor.canEdit() && !editor.hasComposition())
    301298        return;
     
    310307{
    311308    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), false);
    312     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    313     if (!frame)
    314         return false;
    315 
    316     return frame->editor().hasComposition();
     309    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     310    return frame.editor().hasComposition();
    317311}
    318312
     
    323317
    324318    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), false);
    325     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    326     if (!frame)
    327         return false;
    328 
    329     Editor& editor = frame->editor();
     319    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     320    Editor& editor = frame.editor();
    330321    if (!editor.hasComposition())
    331322        return false;
     
    340331    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
    341332
    342     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    343     if (!frame)
    344         return;
    345 
    346     Editor& editor = frame->editor();
     333    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     334    Editor& editor = frame.editor();
    347335
    348336    if (!editor.hasComposition()) {
     
    360348{
    361349    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
    362     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    363     if (!frame)
    364         return;
    365 
    366     Editor& editor = frame->editor();
     350    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     351    Editor& editor = frame.editor();
    367352
    368353    String commandString(command);
     
    388373        length = 0;
    389374
    390     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    391     if (!frame)
    392         return false;
    393 
    394     Editor& editor = frame->editor();
    395 
    396     RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame->selection().rootEditableElementOrDocumentElement(), location, length);
     375    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     376    Editor& editor = frame.editor();
     377
     378    RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame.selection().rootEditableElementOrDocumentElement(), location, length);
    397379    if (!range)
    398380        return false;
     
    407389    g_return_val_if_fail(start && length, false);
    408390
    409     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    410     if (!frame)
    411         return false;
    412 
    413     RefPtr<Range> range = frame->selection().toNormalizedRange().get();
     391    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     392
     393    RefPtr<Range> range = frame.selection().toNormalizedRange().get();
    414394    if (!range)
    415395        return false;
    416396
    417     Element* selectionRoot = frame->selection().rootEditableElement();
    418     Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement();
     397    Element* selectionRoot = frame.selection().rootEditableElement();
     398    Element* scope = selectionRoot ? selectionRoot : frame.document()->documentElement();
    419399
    420400    RefPtr<Range> testRange = Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset());
  • trunk/Source/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp

    r154286 r154678  
    213213        return;
    214214
    215     Frame* frame = corePage->focusController().focusedOrMainFrame();
     215    Frame& frame = corePage->focusController().focusedOrMainFrame();
    216216
    217217    // Collapse the selection without clearing it
    218     ASSERT(frame);
    219     frame->selection().setBase(frame->selection().extent(), frame->selection().affinity());
     218    frame.selection().setBase(frame.selection().extent(), frame.selection().affinity());
    220219}
    221220
     
    229228    DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);
    230229    WebCore::Page* corePage = core(webView);
    231     Frame* targetFrame = corePage->focusController().focusedOrMainFrame();
    232 
    233     if (!targetFrame->selection().isRange())
     230    Frame& targetFrame = corePage->focusController().focusedOrMainFrame();
     231
     232    if (!targetFrame.selection().isRange())
    234233        return;
    235234
    236235    dataObject->clearAll();
    237     dataObject->setRange(targetFrame->selection().toNormalizedRange());
     236    dataObject->setRange(targetFrame.selection().toNormalizedRange());
    238237
    239238    viewSettingClipboard = webView;
  • trunk/Source/WebKit/gtk/WebCoreSupport/WebViewInputMethodFilter.cpp

    r154178 r154678  
    4040        return 0;
    4141
    42     return page->focusController().focusedOrMainFrame();
     42    return &page->focusController().focusedOrMainFrame();
    4343}
    4444
  • trunk/Source/WebKit/gtk/webkit/webkitwebinspector.cpp

    r154122 r154678  
    486486    WebKitWebInspectorPrivate* priv = webInspector->priv;
    487487
    488     Frame* frame = priv->page->focusController().focusedOrMainFrame();
    489     FrameView* view = frame->view();
     488    Frame& frame = priv->page->focusController().focusedOrMainFrame();
     489    FrameView* view = frame.view();
    490490
    491491    if (!view)
     
    536536    WebKitWebInspectorPrivate* priv = webInspector->priv;
    537537
    538     Frame* frame = priv->page->focusController().focusedOrMainFrame();
    539     FrameView* view = frame->view();
     538    Frame& frame = priv->page->focusController().focusedOrMainFrame();
     539    FrameView* view = frame.view();
    540540
    541541    if (!view)
     
    546546    HitTestResult result(documentPoint);
    547547
    548     frame->contentRenderer()->layer()->hitTest(request, result);
     548    frame.contentRenderer()->layer()->hitTest(request, result);
    549549    priv->page->inspectorController()->inspect(result.innerNonSharedNode());
    550550}
  • trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp

    r154658 r154678  
    362362            targetFrame = mainFrame;
    363363
    364         focusedFrame = page->focusController().focusedOrMainFrame();
     364        focusedFrame = &page->focusController().focusedOrMainFrame();
    365365        if (targetFrame != focusedFrame) {
    366366            page->focusController().setFocusedFrame(targetFrame);
     
    448448static gboolean webkit_web_view_popup_menu_handler(GtkWidget* widget)
    449449{
    450     Frame* frame = core(WEBKIT_WEB_VIEW(widget))->focusController().focusedOrMainFrame();
    451     IntPoint location = getLocationForKeyboardGeneratedContextMenu(frame);
    452 
    453     FrameView* view = frame->view();
     450    Frame& frame = core(WEBKIT_WEB_VIEW(widget))->focusController().focusedOrMainFrame();
     451    IntPoint location = getLocationForKeyboardGeneratedContextMenu(&frame);
     452
     453    FrameView* view = frame.view();
    454454    if (!view)
    455455        return FALSE;
     
    11801180static void webkit_web_view_real_select_all(WebKitWebView* webView)
    11811181{
    1182     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    1183     frame->editor().command("SelectAll").execute();
     1182    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     1183    frame.editor().command("SelectAll").execute();
    11841184}
    11851185
    11861186static void webkit_web_view_real_cut_clipboard(WebKitWebView* webView)
    11871187{
    1188     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    1189     frame->editor().command("Cut").execute();
     1188    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     1189    frame.editor().command("Cut").execute();
    11901190}
    11911191
    11921192static void webkit_web_view_real_copy_clipboard(WebKitWebView* webView)
    11931193{
    1194     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    1195     frame->editor().command("Copy").execute();
     1194    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     1195    frame.editor().command("Copy").execute();
    11961196}
    11971197
    11981198static void webkit_web_view_real_undo(WebKitWebView* webView)
    11991199{
    1200     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    1201     frame->editor().command("Undo").execute();
     1200    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     1201    frame.editor().command("Undo").execute();
    12021202}
    12031203
    12041204static void webkit_web_view_real_redo(WebKitWebView* webView)
    12051205{
    1206     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    1207     frame->editor().command("Redo").execute();
     1206    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     1207    frame.editor().command("Redo").execute();
    12081208}
    12091209
     
    12541254    }
    12551255
    1256     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    1257     if (!frame->eventHandler().scrollOverflow(direction, granularity))
    1258         frame->view()->scroll(direction, granularity);
     1256    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     1257    if (!frame.eventHandler().scrollOverflow(direction, granularity))
     1258        frame.view()->scroll(direction, granularity);
    12591259
    12601260    return true;
     
    12631263static void webkit_web_view_real_paste_clipboard(WebKitWebView* webView)
    12641264{
    1265     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    1266     frame->editor().command("Paste").execute();
     1265    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     1266    frame.editor().command("Paste").execute();
    12671267}
    12681268
     
    14911491        return;
    14921492
    1493     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    1494     if (!frame)
    1495         return;
     1493    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
    14961494
    14971495    // Synthesize a button release event to send with the drag end action.
     
    15181516
    15191517    PlatformMouseEvent platformEvent(&event->button);
    1520     frame->eventHandler().dragSourceEndedAt(platformEvent, gdkDragActionToDragOperation(gdk_drag_context_get_selected_action(context)));
     1518    frame.eventHandler().dragSourceEndedAt(platformEvent, gdkDragActionToDragOperation(gdk_drag_context_get_selected_action(context)));
    15211519}
    15221520
     
    15901588
    15911589        // Get the title of the current focused element.
    1592         Frame* coreFrame = core(webView)->focusController().focusedOrMainFrame();
    1593         if (!coreFrame)
    1594             return FALSE;
    1595 
    1596         Node* node = getFocusedNode(coreFrame);
     1590        Frame& coreFrame = core(webView)->focusController().focusedOrMainFrame();
     1591
     1592        Node* node = getFocusedNode(&coreFrame);
    15971593        if (!node)
    15981594            return FALSE;
     
    16021598                String title = toElement(titleNode)->title();
    16031599                if (!title.isEmpty()) {
    1604                     if (FrameView* view = coreFrame->view()) {
     1600                    if (FrameView* view = coreFrame.view()) {
    16051601                        GdkRectangle area = view->contentsToWindow(node->pixelSnappedBoundingBox());
    16061602                        gtk_tooltip_set_tip_area(tooltip, &area);
     
    44624458    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
    44634459
    4464     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    4465     return frame->editor().canCut() || frame->editor().canDHTMLCut();
     4460    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     4461    return frame.editor().canCut() || frame.editor().canDHTMLCut();
    44664462}
    44674463
     
    44784474    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
    44794475
    4480     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    4481     return frame->editor().canCopy() || frame->editor().canDHTMLCopy();
     4476    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     4477    return frame.editor().canCopy() || frame.editor().canDHTMLCopy();
    44824478}
    44834479
     
    44944490    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
    44954491
    4496     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    4497     return frame->editor().canPaste() || frame->editor().canDHTMLPaste();
     4492    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     4493    return frame.editor().canPaste() || frame.editor().canDHTMLPaste();
    44984494}
    44994495
     
    45504546    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
    45514547
    4552     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    4553     frame->editor().performDelete();
     4548    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     4549    frame.editor().performDelete();
    45544550}
    45554551
     
    50815077    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
    50825078
    5083     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    5084     return frame->editor().canUndo();
     5079    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     5080    return frame.editor().canUndo();
    50855081}
    50865082
     
    51165112    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
    51175113
    5118     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
    5119     return frame->editor().canRedo();
     5114    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
     5115    return frame.editor().canRedo();
    51205116}
    51215117
     
    53005296
    53015297    PlatformMouseEvent mouseEvent = PlatformMouseEvent(event);
    5302     Frame* frame = core(webView)->focusController().focusedOrMainFrame();
     5298    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
    53035299    HitTestRequest request(HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
    5304     IntPoint documentPoint = documentPointForWindowPoint(frame, mouseEvent.position());
    5305     MouseEventWithHitTestResults mev = frame->document()->prepareMouseEvent(request, documentPoint, mouseEvent);
     5300    IntPoint documentPoint = documentPointForWindowPoint(&frame, mouseEvent.position());
     5301    MouseEventWithHitTestResults mev = frame.document()->prepareMouseEvent(request, documentPoint, mouseEvent);
    53065302
    53075303    return kit(mev.hitTestResult());
  • trunk/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp

    r154658 r154678  
    330330void DumpRenderTreeSupportQt::executeCoreCommandByName(QWebPageAdapter* adapter, const QString& name, const QString& value)
    331331{
    332     adapter->page->focusController().focusedOrMainFrame()->editor().command(name).execute(value);
     332    adapter->page->focusController().focusedOrMainFrame().editor().command(name).execute(value);
    333333}
    334334
    335335bool DumpRenderTreeSupportQt::isCommandEnabled(QWebPageAdapter *adapter, const QString& name)
    336336{
    337     return adapter->page->focusController().focusedOrMainFrame()->editor().command(name).isEnabled();
     337    return adapter->page->focusController().focusedOrMainFrame().editor().command(name).isEnabled();
    338338}
    339339
    340340QVariantList DumpRenderTreeSupportQt::selectedRange(QWebPageAdapter *adapter)
    341341{
    342     WebCore::Frame* frame = adapter->page->focusController().focusedOrMainFrame();
     342    WebCore::Frame& frame = adapter->page->focusController().focusedOrMainFrame();
    343343    QVariantList selectedRange;
    344     RefPtr<Range> range = frame->selection().toNormalizedRange().get();
    345 
    346     Element* selectionRoot = frame->selection().rootEditableElement();
    347     Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement();
     344    RefPtr<Range> range = frame.selection().toNormalizedRange().get();
     345
     346    Element* selectionRoot = frame.selection().rootEditableElement();
     347    Element* scope = selectionRoot ? selectionRoot : frame.document()->documentElement();
    348348
    349349    RefPtr<Range> testRange = Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset());
     
    364364QVariantList DumpRenderTreeSupportQt::firstRectForCharacterRange(QWebPageAdapter *adapter, int location, int length)
    365365{
    366     WebCore::Frame* frame = adapter->page->focusController().focusedOrMainFrame();
     366    WebCore::Frame& frame = adapter->page->focusController().focusedOrMainFrame();
    367367    QVariantList rect;
    368368
     
    370370        length = 0;
    371371
    372     RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame->selection().rootEditableElementOrDocumentElement(), location, length);
     372    RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame.selection().rootEditableElementOrDocumentElement(), location, length);
    373373
    374374    if (!range)
    375375        return QVariantList();
    376376
    377     QRect resultRect = frame->editor().firstRectForRange(range.get());
     377    QRect resultRect = frame.editor().firstRectForRange(range.get());
    378378    rect << resultRect.x() << resultRect.y() << resultRect.width() << resultRect.height();
    379379    return rect;
     
    745745void DumpRenderTreeSupportQt::confirmComposition(QWebPageAdapter *adapter, const char* text)
    746746{
    747     Frame* frame = adapter->page->focusController().focusedOrMainFrame();
    748     if (!frame)
    749         return;
    750 
    751     Editor& editor = frame->editor();
     747    Frame& frame = adapter->page->focusController().focusedOrMainFrame();
     748
     749    Editor& editor = frame.editor();
    752750    if (!editor.hasComposition() && !text)
    753751        return;
  • trunk/Source/WebKit/qt/WebCoreSupport/EditorClientQt.cpp

    r154286 r154678  
    248248{
    249249#ifndef QT_NO_UNDOSTACK
    250     Frame* frame = m_page->page->focusController().focusedOrMainFrame();
    251     if (m_inUndoRedo || (frame && !frame->editor().lastEditCommand() /* HACK!! Don't recreate undos */))
     250    Frame& frame = m_page->page->focusController().focusedOrMainFrame();
     251    if (m_inUndoRedo || !frame.editor().lastEditCommand() /* HACK!! Don't recreate undos */)
    252252        return;
    253253    m_page->registerUndoStep(step);
     
    423423void EditorClientQt::handleKeyboardEvent(KeyboardEvent* event)
    424424{
    425     Frame* frame = m_page->page->focusController().focusedOrMainFrame();
    426     if (!frame)
    427         return;
     425    Frame& frame = m_page->page->focusController().focusedOrMainFrame();
    428426
    429427    const PlatformKeyboardEvent* kevent = event->keyEvent();
     
    431429        return;
    432430
    433     Node* start = frame->selection().start().containerNode();
     431    Node* start = frame.selection().start().containerNode();
    434432    if (!start)
    435433        return;
     
    438436    if (start->isContentEditable()) {
    439437        bool doSpatialNavigation = false;
    440         if (isSpatialNavigationEnabled(frame)) {
     438        if (isSpatialNavigationEnabled(&frame)) {
    441439            if (!kevent->modifiers()) {
    442440                switch (kevent->windowsVirtualKeyCode()) {
     
    456454            // so we leave it upon WebCore to either handle them immediately (e.g. Tab that changes focus) or let a keypress event be generated
    457455            // (e.g. Tab that inserts a Tab character, or Enter).
    458             if (frame->editor().command(cmd).isTextInsertion()
     456            if (frame.editor().command(cmd).isTextInsertion()
    459457                && kevent->type() == PlatformEvent::RawKeyDown)
    460458                return;
     
    468466            String commandName = editorCommandForKeyDownEvent(event);
    469467            if (!commandName.isEmpty()) {
    470                 if (frame->editor().command(commandName).execute()) // Event handled.
     468                if (frame.editor().command(commandName).execute()) // Event handled.
    471469                    event->setDefaultHandled();
    472470                return;
     
    496494
    497495            if (shouldInsertText) {
    498                 frame->editor().insertText(kevent->text(), event);
     496                frame.editor().insertText(kevent->text(), event);
    499497                event->setDefaultHandled();
    500498                return;
     
    527525                String commandName = editorCommandForKeyDownEvent(event);
    528526                ASSERT(!commandName.isEmpty());
    529                 frame->editor().command(commandName).execute();
     527                frame.editor().command(commandName).execute();
    530528                event->setDefaultHandled();
    531529                return;
     
    618616
    619617        HTMLInputElement* inputElement = 0;
    620         Frame* frame = m_page->page->focusController().focusedOrMainFrame();
    621         if (frame && frame->document() && frame->document()->focusedElement())
    622             if (isHTMLInputElement(frame->document()->focusedElement()))
    623                 inputElement = toHTMLInputElement(frame->document()->focusedElement());
     618        Frame& frame = m_page->page->focusController().focusedOrMainFrame();
     619        if (frame.document() && frame.document()->focusedElement())
     620            if (isHTMLInputElement(frame.document()->focusedElement()))
     621                inputElement = toHTMLInputElement(frame.document()->focusedElement());
    624622
    625623        if (inputElement) {
  • trunk/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp

    r154671 r154678  
    354354bool QWebPageAdapter::hasSelection() const
    355355{
    356     Frame* frame = page->focusController().focusedOrMainFrame();
    357     if (frame)
    358         return (frame->selection().selection().selectionType() != VisibleSelection::NoSelection);
    359     return false;
     356    Frame& frame = page->focusController().focusedOrMainFrame();
     357    return frame.selection().selection().selectionType() != VisibleSelection::NoSelection;
    360358}
    361359
    362360QString QWebPageAdapter::selectedText() const
    363361{
    364     Frame* frame = page->focusController().focusedOrMainFrame();
    365     if (frame->selection().selection().selectionType() == VisibleSelection::NoSelection)
     362    Frame& frame = page->focusController().focusedOrMainFrame();
     363    if (frame.selection().selection().selectionType() == VisibleSelection::NoSelection)
    366364        return QString();
    367     return frame->editor().selectedText();
     365    return frame.editor().selectedText();
    368366}
    369367
    370368QString QWebPageAdapter::selectedHtml() const
    371369{
    372     return page->focusController().focusedOrMainFrame()->editor().selectedRange()->toHTML();
     370    return page->focusController().focusedOrMainFrame().editor().selectedRange()->toHTML();
    373371}
    374372
     
    619617void QWebPageAdapter::inputMethodEvent(QInputMethodEvent *ev)
    620618{
    621     WebCore::Frame *frame = page->focusController().focusedOrMainFrame();
    622     WebCore::Editor &editor = frame->editor();
     619    WebCore::Frame& frame = page->focusController().focusedOrMainFrame();
     620    WebCore::Editor& editor = frame.editor();
    623621
    624622    if (!editor.canEdit()) {
     
    628626
    629627    Node* node = 0;
    630     if (frame->selection().rootEditableElement())
    631         node = frame->selection().rootEditableElement()->deprecatedShadowAncestorNode();
     628    if (frame.selection().rootEditableElement())
     629        node = frame.selection().rootEditableElement()->deprecatedShadowAncestorNode();
    632630
    633631    Vector<CompositionUnderline> underlines;
     
    644642        }
    645643        case QInputMethodEvent::Cursor: {
    646             frame->selection().setCaretVisible(a.length); // if length is 0 cursor is invisible
     644            frame.selection().setCaretVisible(a.length); // if length is 0 cursor is invisible
    647645            if (a.length > 0) {
    648                 RenderObject* caretRenderer = frame->selection().caretRenderer();
     646                RenderObject* caretRenderer = frame.selection().caretRenderer();
    649647                if (caretRenderer) {
    650648                    QColor qcolor = a.value.value<QColor>();
     
    678676
    679677    if (node && ev->replacementLength() > 0) {
    680         int cursorPos = frame->selection().extent().offsetInContainerNode();
     678        int cursorPos = frame.selection().extent().offsetInContainerNode();
    681679        int start = cursorPos + ev->replacementStart();
    682680        if (isHTMLTextFormControlElement(node))
     
    909907{
    910908    ASSERT(visitedWebActions);
    911     WebCore::Frame* focusedFrame = page->focusController().focusedOrMainFrame();
    912     HitTestResult result = focusedFrame->eventHandler().hitTestResultAtPoint(focusedFrame->view()->windowToContents(pos));
     909    WebCore::Frame& focusedFrame = page->focusController().focusedOrMainFrame();
     910    HitTestResult result = focusedFrame.eventHandler().hitTestResultAtPoint(focusedFrame.view()->windowToContents(pos));
    913911    page->contextMenuController().setHitTestResult(result);
    914912
     
    10101008{
    10111009    WebCore::FrameLoader& loader = mainFrameAdapter()->frame->loader();
    1012     WebCore::Editor& editor = page->focusController().focusedOrMainFrame()->editor();
     1010    WebCore::Editor& editor = page->focusController().focusedOrMainFrame().editor();
    10131011
    10141012    switch (action) {
     
    10491047void QWebPageAdapter::triggerAction(QWebPageAdapter::MenuAction action, QWebHitTestResultPrivate* hitTestResult, const char* commandName, bool endToEndReload)
    10501048{
    1051     Frame* frame = page->focusController().focusedOrMainFrame();
    1052     if (!frame)
    1053         return;
    1054     Editor& editor = frame->editor();
     1049    Frame& frame = page->focusController().focusedOrMainFrame();
     1050    Editor& editor = frame.editor();
    10551051
    10561052    // Convenience
     
    10671063        // fall through
    10681064    case OpenLinkInNewWindow:
    1069         openNewWindow(hitTestResult->linkUrl, frame);
     1065        openNewWindow(hitTestResult->linkUrl, &frame);
    10701066        break;
    10711067    case OpenLinkInThisWindow:
    1072         frame->loader().loadFrameRequest(frameLoadRequest(hitTestResult->linkUrl, frame), /*lockHistory*/ false, /*lockBackForwardList*/ false, /*event*/ 0, /*FormState*/ 0, MaybeSendReferrer);
     1068        frame.loader().loadFrameRequest(frameLoadRequest(hitTestResult->linkUrl, &frame), /*lockHistory*/ false, /*lockBackForwardList*/ false, /*event*/ 0, /*FormState*/ 0, MaybeSendReferrer);
    10731069        break;
    10741070    case OpenFrameInNewWindow: {
    1075         KURL url = frame->loader().documentLoader()->unreachableURL();
     1071        KURL url = frame.loader().documentLoader()->unreachableURL();
    10761072        if (url.isEmpty())
    1077             url = frame->loader().documentLoader()->url();
    1078         openNewWindow(url, frame);
     1073            url = frame.loader().documentLoader()->url();
     1074        openNewWindow(url, &frame);
    10791075        break;
    10801076        }
     
    10901086    }
    10911087    case OpenImageInNewWindow:
    1092         openNewWindow(hitTestResult->imageUrl, frame);
     1088        openNewWindow(hitTestResult->imageUrl, &frame);
    10931089        break;
    10941090    case DownloadImageToDisk:
    1095         frame->loader().client().startDownload(WebCore::ResourceRequest(hitTestResult->imageUrl, frame->loader().outgoingReferrer()));
     1091        frame.loader().client().startDownload(WebCore::ResourceRequest(hitTestResult->imageUrl, frame.loader().outgoingReferrer()));
    10961092        break;
    10971093    case DownloadLinkToDisk:
    1098         frame->loader().client().startDownload(WebCore::ResourceRequest(hitTestResult->linkUrl, frame->loader().outgoingReferrer()));
     1094        frame.loader().client().startDownload(WebCore::ResourceRequest(hitTestResult->linkUrl, frame.loader().outgoingReferrer()));
    10991095        break;
    11001096    case Back:
     
    12541250QObject* QWebPageAdapter::currentFrame() const
    12551251{
    1256     Frame* frame = page->focusController().focusedOrMainFrame();
    1257     return frame->loader().networkingContext()->originatingObject();
     1252    Frame& frame = page->focusController().focusedOrMainFrame();
     1253    return frame.loader().networkingContext()->originatingObject();
    12581254}
    12591255
     
    12951291bool QWebPageAdapter::handleKeyEvent(QKeyEvent *ev)
    12961292{
    1297     Frame* frame = page->focusController().focusedOrMainFrame();
    1298     return frame->eventHandler().keyEvent(PlatformKeyboardEvent(ev, m_useNativeVirtualKeyAsDOMKey));
     1293    Frame& frame = page->focusController().focusedOrMainFrame();
     1294    return frame.eventHandler().keyEvent(PlatformKeyboardEvent(ev, m_useNativeVirtualKeyAsDOMKey));
    12991295}
    13001296
    13011297bool QWebPageAdapter::handleScrolling(QKeyEvent *ev)
    13021298{
    1303     Frame* frame = page->focusController().focusedOrMainFrame();
     1299    Frame& frame = page->focusController().focusedOrMainFrame();
    13041300    WebCore::ScrollDirection direction;
    13051301    WebCore::ScrollGranularity granularity;
     
    13431339    }
    13441340
    1345     return frame->eventHandler().scrollRecursively(direction, granularity);
     1341    return frame.eventHandler().scrollRecursively(direction, granularity);
    13461342}
    13471343
     
    13681364bool QWebPageAdapter::handleShortcutOverrideEvent(QKeyEvent* event)
    13691365{
    1370     WebCore::Frame* frame = page->focusController().focusedOrMainFrame();
    1371     WebCore::Editor& editor = frame->editor();
     1366    WebCore::Frame& frame = page->focusController().focusedOrMainFrame();
     1367    WebCore::Editor& editor = frame.editor();
    13721368    if (!editor.canEdit())
    13731369        return false;
     
    14511447    }
    14521448
    1453     WebCore::Frame* focusedFrame = page->focusController().focusedOrMainFrame();
    1454     focusedFrame->eventHandler().sendContextMenuEvent(convertMouseEvent(event, 1));
     1449    WebCore::Frame& focusedFrame = page->focusController().focusedOrMainFrame();
     1450    focusedFrame.eventHandler().sendContextMenuEvent(convertMouseEvent(event, 1));
    14551451    ContextMenu* menu = page->contextMenuController().contextMenu();
    14561452    // If the website defines its own handler then sendContextMenuEvent takes care of
  • trunk/Source/WebKit/win/WebView.cpp

    r154661 r154678  
    13351335        m_page->contextMenuController().clearContextMenu();
    13361336
    1337         Frame* focusedFrame = m_page->focusController().focusedOrMainFrame();
    1338         return focusedFrame->eventHandler().sendContextMenuEventForKey();
     1337        Frame& focusedFrame = m_page->focusController().focusedOrMainFrame();
     1338        return focusedFrame.eventHandler().sendContextMenuEventForKey();
    13391339
    13401340    } else {
     
    13491349    IntPoint documentPoint(m_page->mainFrame().view()->windowToContents(coords));
    13501350    HitTestResult result = m_page->mainFrame().eventHandler().hitTestResultAtPoint(documentPoint);
    1351     Frame* targetFrame = result.innerNonSharedNode() ? result.innerNonSharedNode()->document()->frame() : m_page->focusController().focusedOrMainFrame();
     1351    Frame* targetFrame = result.innerNonSharedNode() ? result.innerNonSharedNode()->document()->frame() : &m_page->focusController().focusedOrMainFrame();
    13521352
    13531353    targetFrame->view()->setCursor(pointerCursor());
     
    17871787    }
    17881788   
    1789     Frame* frame = m_page->focusController().focusedOrMainFrame();
    1790     return frame->eventHandler().scrollRecursively(direction, granularity);
     1789    Frame& frame = m_page->focusController().focusedOrMainFrame();
     1790    return frame.eventHandler().scrollRecursively(direction, granularity);
    17911791}
    17921792
     
    18161816    }
    18171817
    1818     Frame* frame = m_page->focusController().focusedOrMainFrame();
    1819     return frame->eventHandler().scrollRecursively(direction, granularity);
     1818    Frame& frame = m_page->focusController().focusedOrMainFrame();
     1819    return frame.eventHandler().scrollRecursively(direction, granularity);
    18201820}
    18211821
     
    18231823bool WebView::execCommand(WPARAM wParam, LPARAM /*lParam*/)
    18241824{
    1825     Frame* frame = m_page->focusController().focusedOrMainFrame();
     1825    Frame& frame = m_page->focusController().focusedOrMainFrame();
    18261826    switch (LOWORD(wParam)) {
    18271827        case SelectAll:
    1828             return frame->editor().command("SelectAll").execute();
     1828            return frame.editor().command("SelectAll").execute();
    18291829        case Undo:
    1830             return frame->editor().command("Undo").execute();
     1830            return frame.editor().command("Undo").execute();
    18311831        case Redo:
    1832             return frame->editor().command("Redo").execute();
     1832            return frame.editor().command("Redo").execute();
    18331833    }
    18341834    return false;
     
    18391839    PlatformKeyboardEvent keyEvent(m_viewWindow, virtualKeyCode, keyData, PlatformEvent::KeyUp, systemKeyDown);
    18401840
    1841     Frame* frame = m_page->focusController().focusedOrMainFrame();
     1841    Frame& frame = m_page->focusController().focusedOrMainFrame();
    18421842    m_currentCharacterCode = 0;
    18431843
    1844     return frame->eventHandler().keyEvent(keyEvent);
     1844    return frame.eventHandler().keyEvent(keyEvent);
    18451845}
    18461846
     
    20052005    }
    20062006#endif
    2007     Frame* frame = m_page->focusController().focusedOrMainFrame();
     2007    Frame& frame = m_page->focusController().focusedOrMainFrame();
    20082008
    20092009    PlatformKeyboardEvent keyEvent(m_viewWindow, virtualKeyCode, keyData, PlatformEvent::RawKeyDown, systemKeyDown);
    2010     bool handled = frame->eventHandler().keyEvent(keyEvent);
     2010    bool handled = frame.eventHandler().keyEvent(keyEvent);
    20112011
    20122012    // These events cannot be canceled, and we have no default handling for them.
     
    20722072    }
    20732073
    2074     return frame->eventHandler().scrollRecursively(direction, granularity);
     2074    return frame.eventHandler().scrollRecursively(direction, granularity);
    20752075}
    20762076
    20772077bool WebView::keyPress(WPARAM charCode, LPARAM keyData, bool systemKeyDown)
    20782078{
    2079     Frame* frame = m_page->focusController().focusedOrMainFrame();
     2079    Frame& frame = m_page->focusController().focusedOrMainFrame();
    20802080
    20812081    PlatformKeyboardEvent keyEvent(m_viewWindow, charCode, keyData, PlatformEvent::Char, systemKeyDown);
    20822082    // IE does not dispatch keypress event for WM_SYSCHAR.
    20832083    if (systemKeyDown)
    2084         return frame->eventHandler().handleAccessKey(keyEvent);
    2085     return frame->eventHandler().keyEvent(keyEvent);
     2084        return frame.eventHandler().handleAccessKey(keyEvent);
     2085    return frame.eventHandler().keyEvent(keyEvent);
    20862086}
    20872087
     
    22882288
    22892289            FocusController& focusController = webView->page()->focusController();
    2290             Frame* frame = focusController.focusedOrMainFrame();
    2291             webView->resetIME(frame);
     2290            Frame& frame = focusController.focusedOrMainFrame();
     2291            webView->resetIME(&frame);
    22922292            // Send blur events unless we're losing focus to a child of ours.
    22932293            if (!IsChild(hWnd, newFocusWnd))
     
    22952295
    22962296            // If we are pan-scrolling when we lose focus, stop the pan scrolling.
    2297             frame->eventHandler().stopAutoscrollTimer();
     2297            frame.eventHandler().stopAutoscrollTimer();
    22982298
    22992299            break;
     
    34883488    bool active = m_page->focusController().isActive();
    34893489    Frame& mainFrame = m_page->mainFrame();
    3490     Frame* focusedFrame = m_page->focusController().focusedOrMainFrame();
    3491     mainFrame.selection().setFocused(active && &mainFrame == focusedFrame);
     3490    Frame& focusedFrame = m_page->focusController().focusedOrMainFrame();
     3491    mainFrame.selection().setFocused(active && &mainFrame == &focusedFrame);
    34923492
    34933493    return S_OK;
     
    34963496HRESULT STDMETHODCALLTYPE WebView::executeCoreCommandByName(BSTR name, BSTR value)
    34973497{
    3498     m_page->focusController().focusedOrMainFrame()->editor().command(toString(name)).execute(toString(value));
     3498    m_page->focusController().focusedOrMainFrame().editor().command(toString(name)).execute(toString(value));
    34993499
    35003500    return S_OK;
     
    35623562    *hBitmap = 0;
    35633563
    3564     WebCore::Frame* frame = m_page->focusController().focusedOrMainFrame();
    3565 
    3566     if (frame) {
    3567         OwnPtr<HBITMAP> bitmap = imageFromSelection(frame, forceWhiteText ? TRUE : FALSE);
    3568         *hBitmap = static_cast<OLE_HANDLE>(reinterpret_cast<ULONG64>(bitmap.leakPtr()));
    3569     }
     3564    WebCore::Frame& frame = m_page->focusController().focusedOrMainFrame();
     3565
     3566    OwnPtr<HBITMAP> bitmap = imageFromSelection(&frame, forceWhiteText ? TRUE : FALSE);
     3567    *hBitmap = static_cast<OLE_HANDLE>(reinterpret_cast<ULONG64>(bitmap.leakPtr()));
    35703568
    35713569    return S_OK;
     
    35743572HRESULT STDMETHODCALLTYPE WebView::selectionRect(RECT* rc)
    35753573{
    3576     WebCore::Frame* frame = m_page->focusController().focusedOrMainFrame();
    3577 
    3578     if (frame) {
    3579         IntRect ir = enclosingIntRect(frame->selection().bounds());
    3580         ir = frame->view()->convertToContainingWindow(ir);
    3581         ir.move(-frame->view()->scrollOffset().width(), -frame->view()->scrollOffset().height());
    3582         rc->left = ir.x();
    3583         rc->top = ir.y();
    3584         rc->bottom = rc->top + ir.height();
    3585         rc->right = rc->left + ir.width();
    3586     }
     3574    WebCore::Frame& frame = m_page->focusController().focusedOrMainFrame();
     3575
     3576    IntRect ir = enclosingIntRect(frame.selection().bounds());
     3577    ir = frame.view()->convertToContainingWindow(ir);
     3578    ir.move(-frame.view()->scrollOffset().width(), -frame.view()->scrollOffset().height());
     3579    rc->left = ir.x();
     3580    rc->top = ir.y();
     3581    rc->bottom = rc->top + ir.height();
     3582    rc->right = rc->left + ir.width();
    35873583
    35883584    return S_OK;
     
    37193715    *text = 0;
    37203716
    3721     Frame* focusedFrame = m_page ? m_page->focusController().focusedOrMainFrame() : 0;
     3717    Frame* focusedFrame = m_page ? &m_page->focusController().focusedOrMainFrame() : 0;
    37223718    if (!focusedFrame)
    37233719        return E_FAIL;
     
    43084304        /* [retval][out] */ BOOL* enabled)
    43094305{
    4310     Editor& editor = m_page->focusController().focusedOrMainFrame()->editor();
     4306    Editor& editor = m_page->focusController().focusedOrMainFrame().editor();
    43114307    *enabled = editor.canCut() || editor.canDHTMLCut();
    43124308    return S_OK;
     
    43164312        /* [retval][out] */ BOOL* enabled)
    43174313{
    4318     Editor& editor = m_page->focusController().focusedOrMainFrame()->editor();
     4314    Editor& editor = m_page->focusController().focusedOrMainFrame().editor();
    43194315    *enabled = editor.canCopy() || editor.canDHTMLCopy();
    43204316    return S_OK;
     
    43244320        /* [retval][out] */ BOOL* enabled)
    43254321{
    4326     Editor& editor = m_page->focusController().focusedOrMainFrame()->editor();
     4322    Editor& editor = m_page->focusController().focusedOrMainFrame().editor();
    43274323    *enabled = editor.canPaste() || editor.canDHTMLPaste();
    43284324    return S_OK;
     
    43324328        /* [retval][out] */ BOOL* enabled)
    43334329{
    4334     *enabled = m_page->focusController().focusedOrMainFrame()->editor().canDelete();
     4330    *enabled = m_page->focusController().focusedOrMainFrame().editor().canDelete();
    43354331    return S_OK;
    43364332}
     
    43394335        /* [retval][out] */ BOOL* enabled)
    43404336{
    4341     *enabled = m_page->focusController().focusedOrMainFrame()->editor().canEdit();
     4337    *enabled = m_page->focusController().focusedOrMainFrame().editor().canEdit();
    43424338    return S_OK;
    43434339}
     
    43914387{
    43924388    Position start = m_page->mainFrame().selection().selection().start();
    4393     m_page->focusController().focusedOrMainFrame()->editor().insertText(toString(text), 0);
     4389    m_page->focusController().focusedOrMainFrame().editor().insertText(toString(text), 0);
    43944390    m_page->mainFrame().selection().setBase(start);
    43954391    return S_OK;
     
    44124408HRESULT STDMETHODCALLTYPE WebView::deleteSelection( void)
    44134409{
    4414     Editor& editor = m_page->focusController().focusedOrMainFrame()->editor();
     4410    Editor& editor = m_page->focusController().focusedOrMainFrame().editor();
    44154411    editor.deleteSelectionWithSmartDelete(editor.canSmartCopyOrDelete());
    44164412    return S_OK;
     
    44194415HRESULT STDMETHODCALLTYPE WebView::clearSelection( void)
    44204416{
    4421     m_page->focusController().focusedOrMainFrame()->selection().clear();
     4417    m_page->focusController().focusedOrMainFrame().selection().clear();
    44224418    return S_OK;
    44234419}
     
    44354431        /* [in] */ IUnknown* /*sender*/)
    44364432{
    4437     m_page->focusController().focusedOrMainFrame()->editor().command("Copy").execute();
     4433    m_page->focusController().focusedOrMainFrame().editor().command("Copy").execute();
    44384434    return S_OK;
    44394435}
     
    44424438        /* [in] */ IUnknown* /*sender*/)
    44434439{
    4444     m_page->focusController().focusedOrMainFrame()->editor().command("Cut").execute();
     4440    m_page->focusController().focusedOrMainFrame().editor().command("Cut").execute();
    44454441    return S_OK;
    44464442}
     
    44494445        /* [in] */ IUnknown* /*sender*/)
    44504446{
    4451     m_page->focusController().focusedOrMainFrame()->editor().command("Paste").execute();
     4447    m_page->focusController().focusedOrMainFrame().editor().command("Paste").execute();
    44524448    return S_OK;
    44534449}
     
    44564452        /* [in] */ BSTR url)
    44574453{
    4458     m_page->focusController().focusedOrMainFrame()->editor().copyURL(MarshallingHelpers::BSTRToKURL(url), "");
     4454    m_page->focusController().focusedOrMainFrame().editor().copyURL(MarshallingHelpers::BSTRToKURL(url), "");
    44594455    return S_OK;
    44604456}
     
    44784474        /* [in] */ IUnknown* /*sender*/)
    44794475{
    4480     m_page->focusController().focusedOrMainFrame()->editor().command("Delete").execute();
     4476    m_page->focusController().focusedOrMainFrame().editor().command("Delete").execute();
    44814477    return S_OK;
    44824478}
     
    53145310{
    53155311    if (m_page) {
    5316         Frame* frame = m_page->focusController().focusedOrMainFrame();
    5317         frame->document()->setFocusedElement(0);
     5312        Frame& frame = m_page->focusController().focusedOrMainFrame();
     5313        frame.document()->setFocusedElement(0);
    53185314        m_page->focusController().setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, 0);
    53195315    }
     
    54005396HRESULT STDMETHODCALLTYPE WebView::clearUndoRedoOperations()
    54015397{
    5402     if (Frame* frame = m_page->focusController().focusedOrMainFrame())
    5403         frame->editor().clearUndoRedoOperations();
     5398    Frame& frame = m_page->focusController().focusedOrMainFrame();
     5399    frame.editor().clearUndoRedoOperations();
    54045400    return S_OK;
    54055401}
     
    55425538void WebView::updateSelectionForIME()
    55435539{
    5544     Frame* targetFrame = m_page->focusController().focusedOrMainFrame();
    5545    
    5546     if (!targetFrame)
    5547         return;
    5548 
    5549     if (!targetFrame->editor().cancelCompositionIfSelectionIsInvalid())
    5550         resetIME(targetFrame);
     5540    Frame& targetFrame = m_page->focusController().focusedOrMainFrame();
     5541    if (!targetFrame.editor().cancelCompositionIfSelectionIsInvalid())
     5542        resetIME(&targetFrame);
    55515543}
    55525544
     
    55655557    LOG(TextInput, "onIMEStartComposition");
    55665558    m_inIMEComposition++;
    5567     Frame* targetFrame = m_page->focusController().focusedOrMainFrame();
    5568     if (!targetFrame)
    5569         return true;
     5559    Frame& targetFrame = m_page->focusController().focusedOrMainFrame();
    55705560
    55715561    HIMC hInputContext = getIMMContext();
    5572     prepareCandidateWindow(targetFrame, hInputContext);
     5562    prepareCandidateWindow(&targetFrame, hInputContext);
    55735563    releaseIMMContext(hInputContext);
    55745564    return true;
     
    57025692        return true;
    57035693
    5704     Frame* targetFrame = m_page->focusController().focusedOrMainFrame();
    5705     if (!targetFrame || !targetFrame->editor().canEdit())
     5694    Frame& targetFrame = m_page->focusController().focusedOrMainFrame();
     5695    if (!targetFrame.editor().canEdit())
    57065696        return true;
    57075697
    5708     prepareCandidateWindow(targetFrame, hInputContext);
     5698    prepareCandidateWindow(&targetFrame, hInputContext);
    57095699
    57105700    if (lparam & GCS_RESULTSTR || !lparam) {
     
    57135703            return true;
    57145704       
    5715         targetFrame->editor().confirmComposition(compositionString);
     5705        targetFrame.editor().confirmComposition(compositionString);
    57165706    } else {
    57175707        String compositionString;
     
    57345724        int cursorPosition = LOWORD(IMMDict::dict().getCompositionString(hInputContext, GCS_CURSORPOS, 0, 0));
    57355725
    5736         targetFrame->editor().setComposition(compositionString, underlines, cursorPosition, 0);
     5726        targetFrame.editor().setComposition(compositionString, underlines, cursorPosition, 0);
    57375727    }
    57385728
     
    57455735    // If the composition hasn't been confirmed yet, it needs to be cancelled.
    57465736    // This happens after deleting the last character from inline input hole.
    5747     Frame* targetFrame = m_page->focusController().focusedOrMainFrame();
    5748     if (targetFrame && targetFrame->editor().hasComposition())
    5749         targetFrame->editor().confirmComposition(String());
     5737    Frame& targetFrame = m_page->focusController().focusedOrMainFrame();
     5738    if (targetFrame.editor().hasComposition())
     5739        targetFrame.editor().confirmComposition(String());
    57505740
    57515741    if (m_inIMEComposition)
     
    58115801{
    58125802    LOG(TextInput, "onIMERequest %s", imeRequestName(request).latin1().data());
    5813     Frame* targetFrame = m_page->focusController().focusedOrMainFrame();
    5814     if (!targetFrame || !targetFrame->editor().canEdit())
     5803    Frame& targetFrame = m_page->focusController().focusedOrMainFrame();
     5804    if (!targetFrame.editor().canEdit())
    58155805        return 0;
    58165806
    58175807    switch (request) {
    58185808        case IMR_RECONVERTSTRING:
    5819             return onIMERequestReconvertString(targetFrame, (RECONVERTSTRING*)data);
     5809            return onIMERequestReconvertString(&targetFrame, (RECONVERTSTRING*)data);
    58205810
    58215811        case IMR_QUERYCHARPOSITION:
    5822             return onIMERequestCharPosition(targetFrame, (IMECHARPOSITION*)data);
     5812            return onIMERequestCharPosition(&targetFrame, (IMECHARPOSITION*)data);
    58235813    }
    58245814    return 0;
     
    69586948        return E_FAIL;
    69596949
    6960     Frame* frame = m_page->focusController().focusedOrMainFrame();
    6961     if (!frame || !frame->editor().canEdit())
     6950    Frame& frame = m_page->focusController().focusedOrMainFrame();
     6951    if (!frame.editor().canEdit())
    69626952        return E_FAIL;
    69636953
     
    69666956    Vector<CompositionUnderline> underlines;
    69676957    underlines.append(CompositionUnderline(0, compositionStr.length(), Color(Color::black), false));
    6968     frame->editor().setComposition(compositionStr, underlines, from, from + length);
     6958    frame.editor().setComposition(compositionStr, underlines, from, from + length);
    69696959
    69706960    return S_OK;
     
    69766966        return E_FAIL;
    69776967
    6978     Frame* frame = m_page->focusController().focusedOrMainFrame();
    6979      if (!frame)
    6980         return E_FAIL;
    6981 
    6982     *result = frame && frame->editor().hasComposition();
    6983 
     6968    Frame& frame = m_page->focusController().focusedOrMainFrame();
     6969    *result = frame.editor().hasComposition();
    69846970    return S_OK;
    69856971}
     
    69906976        return E_FAIL;
    69916977
    6992     Frame* frame = m_page->focusController().focusedOrMainFrame();
    6993     if (!frame || !frame->editor().canEdit())
     6978    Frame& frame = m_page->focusController().focusedOrMainFrame();
     6979    if (!frame.editor().canEdit())
    69946980        return E_FAIL;
    69956981
     
    69976983
    69986984    if (compositionStr.isNull())
    6999         frame->editor().confirmComposition();
    7000 
    7001     frame->editor().confirmComposition(compositionStr);
     6985        frame.editor().confirmComposition();
     6986
     6987    frame.editor().confirmComposition(compositionStr);
    70026988
    70036989    return S_OK;
     
    70096995        return E_FAIL;
    70106996
    7011     Frame* frame = m_page->focusController().focusedOrMainFrame();
    7012     if (!frame || !frame->editor().canEdit())
    7013         return E_FAIL;
    7014 
    7015     RefPtr<Range> range = frame->editor().compositionRange();
     6997    Frame& frame = m_page->focusController().focusedOrMainFrame();
     6998    if (!frame.editor().canEdit())
     6999        return E_FAIL;
     7000
     7001    RefPtr<Range> range = frame.editor().compositionRange();
    70167002
    70177003    if (!range)
     
    70337019        return E_FAIL;
    70347020
    7035     Frame* frame = m_page->focusController().focusedOrMainFrame();
    7036     if (!frame)
    7037         return E_FAIL;
    7038 
    70397021    IntRect resultIntRect;
    70407022    resultIntRect.setLocation(IntPoint(0, 0));
     
    70467028        length = INT_MAX - location;
    70477029       
    7048     RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame->selection().rootEditableElementOrDocumentElement(), location, length);
     7030    Frame& frame = m_page->focusController().focusedOrMainFrame();
     7031    RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame.selection().rootEditableElementOrDocumentElement(), location, length);
    70497032
    70507033    if (!range)
     
    70547037    ASSERT(range->endContainer());
    70557038     
    7056     IntRect rect = frame->editor().firstRectForRange(range.get());
    7057     resultIntRect = frame->view()->contentsToWindow(rect);
     7039    IntRect rect = frame.editor().firstRectForRange(range.get());
     7040    resultIntRect = frame.view()->contentsToWindow(rect);
    70587041
    70597042    resultRect->left = resultIntRect.x();
     
    70707053        return E_FAIL;
    70717054
    7072     Frame* frame = m_page->focusController().focusedOrMainFrame();
    7073     if (!frame)
    7074         return E_FAIL;
    7075 
    7076     RefPtr<Range> range = frame->editor().selectedRange();
     7055    Frame& frame = m_page->focusController().focusedOrMainFrame();
     7056
     7057    RefPtr<Range> range = frame.editor().selectedRange();
    70777058
    70787059    size_t locationSize;
    70797060    size_t lengthSize;
    7080     if (range && TextIterator::getLocationAndLengthFromRange(frame->selection().rootEditableElementOrDocumentElement(), range.get(), locationSize, lengthSize)) {
     7061    if (range && TextIterator::getLocationAndLengthFromRange(frame.selection().rootEditableElementOrDocumentElement(), range.get(), locationSize, lengthSize)) {
    70817062        *location = static_cast<UINT>(locationSize);
    70827063        *length = static_cast<UINT>(lengthSize);
  • trunk/Source/WebKit/wince/WebView.cpp

    r154658 r154678  
    350350bool WebView::handleKeyDown(WPARAM virtualKeyCode, LPARAM keyData, bool systemKeyDown)
    351351{
    352     Frame* frame = m_page->focusController().focusedOrMainFrame();
     352    Frame& frame = m_page->focusController().focusedOrMainFrame();
    353353
    354354    PlatformKeyboardEvent keyEvent(m_windowHandle, virtualKeyCode, keyData, PlatformEvent::RawKeyDown, systemKeyDown);
    355     bool handled = frame->eventHandler().keyEvent(keyEvent);
     355    bool handled = frame.eventHandler().keyEvent(keyEvent);
    356356
    357357    // These events cannot be canceled, and we have no default handling for them.
     
    372372bool WebView::handleKeyPress(WPARAM charCode, LPARAM keyData, bool systemKeyDown)
    373373{
    374     Frame* frame = m_page->focusController().focusedOrMainFrame();
     374    Frame& frame = m_page->focusController().focusedOrMainFrame();
    375375
    376376    PlatformKeyboardEvent keyEvent(m_windowHandle, charCode, keyData, PlatformEvent::Char, systemKeyDown);
    377377    // IE does not dispatch keypress event for WM_SYSCHAR.
    378378    if (systemKeyDown)
    379         return frame->eventHandler().handleAccessKey(keyEvent);
    380     if (frame->eventHandler().keyEvent(keyEvent))
     379        return frame.eventHandler().handleAccessKey(keyEvent);
     380    if (frame.eventHandler().keyEvent(keyEvent))
    381381        return true;
    382382
     
    388388    PlatformKeyboardEvent keyEvent(m_windowHandle, virtualKeyCode, keyData, PlatformEvent::KeyUp, systemKeyDown);
    389389
    390     Frame* frame = m_page->focusController().focusedOrMainFrame();
    391     return frame->eventHandler().keyEvent(keyEvent);
     390    Frame& frame = m_page->focusController().focusedOrMainFrame();
     391    return frame.eventHandler().keyEvent(keyEvent);
    392392}
    393393
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/efl/WebEditorClientEfl.cpp

    r154122 r154678  
    5050void WebEditorClient::handleInputMethodKeydown(KeyboardEvent* event)
    5151{
    52     Frame* frame = m_page->corePage()->focusController().focusedOrMainFrame();
    53     if (!frame || !frame->editor().canEdit())
     52    Frame& frame = m_page->corePage()->focusController().focusedOrMainFrame();
     53    if (!frame.editor().canEdit())
    5454        return;
    5555
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm

    r154658 r154678  
    134134static void changeWordCase(WebPage* page, SEL selector)
    135135{
    136     Frame* frame = page->corePage()->focusController().focusedOrMainFrame();
    137     if (!frame->editor().canEdit())
     136    Frame& frame = page->corePage()->focusController().focusedOrMainFrame();
     137    if (!frame.editor().canEdit())
    138138        return;
    139139
    140     frame->editor().command("selectWord").execute();
    141 
    142     NSString *selectedString = frame->displayStringModifiedByEncoding(frame->editor().selectedText());
    143     page->replaceSelectionWithText(frame, [selectedString performSelector:selector]);
     140    frame.editor().command("selectWord").execute();
     141
     142    NSString *selectedString = frame.displayStringModifiedByEncoding(frame.editor().selectedText());
     143    page->replaceSelectionWithText(&frame, [selectedString performSelector:selector]);
    144144}
    145145
  • trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp

    r154658 r154678  
    329329void FindController::showFindIndicatorInSelection()
    330330{
    331     Frame* selectedFrame = m_webPage->corePage()->focusController().focusedOrMainFrame();
    332     if (!selectedFrame)
    333         return;
    334    
    335     updateFindIndicator(selectedFrame, false);
     331    Frame& selectedFrame = m_webPage->corePage()->focusController().focusedOrMainFrame();
     332    updateFindIndicator(&selectedFrame, false);
    336333}
    337334
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r154658 r154678  
    588588EditorState WebPage::editorState() const
    589589{
    590     Frame* frame = m_page->focusController().focusedOrMainFrame();
    591     ASSERT(frame);
     590    Frame& frame = m_page->focusController().focusedOrMainFrame();
    592591
    593592    EditorState result;
     
    602601    }
    603602
    604     result.selectionIsNone = frame->selection().isNone();
    605     result.selectionIsRange = frame->selection().isRange();
    606     result.isContentEditable = frame->selection().isContentEditable();
    607     result.isContentRichlyEditable = frame->selection().isContentRichlyEditable();
    608     result.isInPasswordField = frame->selection().isInPasswordField();
    609     result.hasComposition = frame->editor().hasComposition();
    610     result.shouldIgnoreCompositionSelectionChange = frame->editor().ignoreCompositionSelectionChange();
     603    result.selectionIsNone = frame.selection().isNone();
     604    result.selectionIsRange = frame.selection().isRange();
     605    result.isContentEditable = frame.selection().isContentEditable();
     606    result.isContentRichlyEditable = frame.selection().isContentRichlyEditable();
     607    result.isInPasswordField = frame.selection().isInPasswordField();
     608    result.hasComposition = frame.editor().hasComposition();
     609    result.shouldIgnoreCompositionSelectionChange = frame.editor().ignoreCompositionSelectionChange();
    611610
    612611#if PLATFORM(QT)
     
    614613    size_t length = 0;
    615614
    616     Element* selectionRoot = frame->selection().rootEditableElementRespectingShadowTree();
    617     Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement();
     615    Element* selectionRoot = frame.selection().rootEditableElementRespectingShadowTree();
     616    Element* scope = selectionRoot ? selectionRoot : frame.document()->documentElement();
    618617
    619618    if (!scope)
     
    644643
    645644    if (selectionRoot)
    646         result.editorRect = frame->view()->contentsToWindow(selectionRoot->pixelSnappedBoundingBox());
     645        result.editorRect = frame.view()->contentsToWindow(selectionRoot->pixelSnappedBoundingBox());
    647646
    648647    RefPtr<Range> range;
    649     if (result.hasComposition && (range = frame->editor().compositionRange())) {
    650         frame->editor().getCompositionSelection(result.anchorPosition, result.cursorPosition);
    651 
    652         result.compositionRect = frame->view()->contentsToWindow(range->boundingBox());
    653     }
    654 
    655     if (!result.hasComposition && !result.selectionIsNone && (range = frame->selection().selection().firstRange())) {
     648    if (result.hasComposition && (range = frame.editor().compositionRange())) {
     649        frame.editor().getCompositionSelection(result.anchorPosition, result.cursorPosition);
     650
     651        result.compositionRect = frame.view()->contentsToWindow(range->boundingBox());
     652    }
     653
     654    if (!result.hasComposition && !result.selectionIsNone && (range = frame.selection().selection().firstRange())) {
    656655        TextIterator::getLocationAndLengthFromRange(scope, range.get(), location, length);
    657         bool baseIsFirst = frame->selection().selection().isBaseFirst();
     656        bool baseIsFirst = frame.selection().selection().isBaseFirst();
    658657
    659658        result.cursorPosition = (baseIsFirst) ? location + length : location;
     
    663662
    664663    if (range)
    665         result.cursorRect = frame->view()->contentsToWindow(frame->editor().firstRectForRange(range.get()));
     664        result.cursorRect = frame.view()->contentsToWindow(frame.editor().firstRectForRange(range.get()));
    666665
    667666    // FIXME: We should only transfer innerText when it changes and do this on the UI side.
     
    676675
    677676#if PLATFORM(GTK)
    678     result.cursorRect = frame->selection().absoluteCaretBounds();
     677    result.cursorRect = frame.selection().absoluteCaretBounds();
    679678#endif
    680679
     
    739738}
    740739
    741 PluginView* WebPage::focusedPluginViewForFrame(Frame* frame)
    742 {
    743     if (!frame->document()->isPluginDocument())
     740PluginView* WebPage::focusedPluginViewForFrame(Frame& frame)
     741{
     742    if (!frame.document()->isPluginDocument())
    744743        return 0;
    745744
    746     PluginDocument* pluginDocument = static_cast<PluginDocument*>(frame->document());
     745    PluginDocument* pluginDocument = static_cast<PluginDocument*>(frame.document());
    747746
    748747    if (pluginDocument->focusedElement() != pluginDocument->pluginElement())
     
    765764void WebPage::executeEditingCommand(const String& commandName, const String& argument)
    766765{
    767     Frame* frame = m_page->focusController().focusedOrMainFrame();
    768     if (!frame)
    769         return;
     766    Frame& frame = m_page->focusController().focusedOrMainFrame();
    770767
    771768    if (PluginView* pluginView = focusedPluginViewForFrame(frame)) {
     
    774771    }
    775772   
    776     frame->editor().command(commandName).execute(argument);
     773    frame.editor().command(commandName).execute(argument);
    777774}
    778775
    779776bool WebPage::isEditingCommandEnabled(const String& commandName)
    780777{
    781     Frame* frame = m_page->focusController().focusedOrMainFrame();
    782     if (!frame)
    783         return false;
     778    Frame& frame = m_page->focusController().focusedOrMainFrame();
    784779
    785780    if (PluginView* pluginView = focusedPluginViewForFrame(frame))
    786781        return pluginView->isEditingCommandEnabled(commandName);
    787782   
    788     Editor::Command command = frame->editor().command(commandName);
     783    Editor::Command command = frame.editor().command(commandName);
    789784    return command.isSupported() && command.isEnabled();
    790785}
     
    17671762
    17681763    if (keyboardEvent.type() == WebEvent::Char && keyboardEvent.isSystemKey())
    1769         return page->focusController().focusedOrMainFrame()->eventHandler().handleAccessKey(platform(keyboardEvent));
    1770     return page->focusController().focusedOrMainFrame()->eventHandler().keyEvent(platform(keyboardEvent));
     1764        return page->focusController().focusedOrMainFrame().eventHandler().handleAccessKey(platform(keyboardEvent));
     1765    return page->focusController().focusedOrMainFrame().eventHandler().keyEvent(platform(keyboardEvent));
    17711766}
    17721767
     
    18491844    bool isEnabled = false;
    18501845    int32_t state = 0;
    1851     Frame* frame = m_page->focusController().focusedOrMainFrame();
    1852     if (frame) {
    1853         if (PluginView* pluginView = focusedPluginViewForFrame(frame))
    1854             isEnabled = pluginView->isEditingCommandEnabled(commandName);
    1855         else {
    1856             Editor::Command command = frame->editor().command(commandName);
    1857             state = command.state();
    1858             isEnabled = command.isSupported() && command.isEnabled();
    1859         }
     1846    Frame& frame = m_page->focusController().focusedOrMainFrame();
     1847    if (PluginView* pluginView = focusedPluginViewForFrame(frame))
     1848        isEnabled = pluginView->isEditingCommandEnabled(commandName);
     1849    else {
     1850        Editor::Command command = frame.editor().command(commandName);
     1851        state = command.state();
     1852        isEnabled = command.isSupported() && command.isEnabled();
    18601853    }
    18611854
     
    19741967bool WebPage::scroll(Page* page, ScrollDirection direction, ScrollGranularity granularity)
    19751968{
    1976     return page->focusController().focusedOrMainFrame()->eventHandler().scrollRecursively(direction, granularity);
     1969    return page->focusController().focusedOrMainFrame().eventHandler().scrollRecursively(direction, granularity);
    19771970}
    19781971
    19791972bool WebPage::logicalScroll(Page* page, ScrollLogicalDirection direction, ScrollGranularity granularity)
    19801973{
    1981     return page->focusController().focusedOrMainFrame()->eventHandler().logicalScrollRecursively(direction, granularity);
     1974    return page->focusController().focusedOrMainFrame().eventHandler().logicalScrollRecursively(direction, granularity);
    19821975}
    19831976
     
    19891982void WebPage::centerSelectionInVisibleArea()
    19901983{
    1991     Frame* frame = m_page->focusController().focusedOrMainFrame();
    1992     if (!frame)
    1993         return;
    1994    
    1995     frame->selection().revealSelection(ScrollAlignment::alignCenterAlways);
     1984    Frame& frame = m_page->focusController().focusedOrMainFrame();
     1985    frame.selection().revealSelection(ScrollAlignment::alignCenterAlways);
    19961986    m_findController.showFindIndicatorInSelection();
    19971987}
     
    20472037
    20482038    // FIXME: This should propagate to all ScrollableAreas.
    2049     if (Frame* frame = m_page->focusController().focusedOrMainFrame()) {
    2050         if (FrameView* view = frame->view())
    2051             view->willStartLiveResize();
    2052     }
     2039    Frame& frame = m_page->focusController().focusedOrMainFrame();
     2040    if (FrameView* view = frame.view())
     2041        view->willStartLiveResize();
    20532042}
    20542043
     
    20592048
    20602049    // FIXME: This should propagate to all ScrollableAreas.
    2061     if (Frame* frame = m_page->focusController().focusedOrMainFrame()) {
    2062         if (FrameView* view = frame->view())
    2063             view->willEndLiveResize();
    2064     }
     2050    Frame& frame = m_page->focusController().focusedOrMainFrame();
     2051    if (FrameView* view = frame.view())
     2052        view->willEndLiveResize();
    20652053}
    20662054
     
    20752063        return;
    20762064
    2077     Frame* frame = m_page->focusController().focusedOrMainFrame();
    2078     frame->document()->setFocusedElement(0);
     2065    Frame& frame = m_page->focusController().focusedOrMainFrame();
     2066    frame.document()->setFocusedElement(0);
    20792067
    20802068    if (isKeyboardEventValid && event.type() == WebEvent::KeyDown) {
    20812069        PlatformKeyboardEvent platformEvent(platform(event));
    20822070        platformEvent.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown);
    2083         m_page->focusController().setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, KeyboardEvent::create(platformEvent, frame->document()->defaultView()).get());
     2071        m_page->focusController().setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, KeyboardEvent::create(platformEvent, frame.document()->defaultView()).get());
    20842072        return;
    20852073    }
     
    29352923void WebPage::advanceToNextMisspelling(bool startBeforeSelection)
    29362924{
    2937     Frame* frame = m_page->focusController().focusedOrMainFrame();
    2938     frame->editor().advanceToNextMisspelling(startBeforeSelection);
     2925    Frame& frame = m_page->focusController().focusedOrMainFrame();
     2926    frame.editor().advanceToNextMisspelling(startBeforeSelection);
    29392927}
    29402928
    29412929void WebPage::changeSpellingToWord(const String& word)
    29422930{
    2943     replaceSelectionWithText(m_page->focusController().focusedOrMainFrame(), word);
     2931    replaceSelectionWithText(&m_page->focusController().focusedOrMainFrame(), word);
    29442932}
    29452933
     
    29632951void WebPage::uppercaseWord()
    29642952{
    2965     m_page->focusController().focusedOrMainFrame()->editor().uppercaseWord();
     2953    m_page->focusController().focusedOrMainFrame().editor().uppercaseWord();
    29662954}
    29672955
    29682956void WebPage::lowercaseWord()
    29692957{
    2970     m_page->focusController().focusedOrMainFrame()->editor().lowercaseWord();
     2958    m_page->focusController().focusedOrMainFrame().editor().lowercaseWord();
    29712959}
    29722960
    29732961void WebPage::capitalizeWord()
    29742962{
    2975     m_page->focusController().focusedOrMainFrame()->editor().capitalizeWord();
     2963    m_page->focusController().focusedOrMainFrame().editor().capitalizeWord();
    29762964}
    29772965#endif
     
    30153003void WebPage::clearSelection()
    30163004{
    3017     m_page->focusController().focusedOrMainFrame()->selection().clear();
     3005    m_page->focusController().focusedOrMainFrame().selection().clear();
    30183006}
    30193007
     
    36073595void WebPage::handleAlternativeTextUIResult(const String& result)
    36083596{
    3609     Frame* frame = m_page->focusController().focusedOrMainFrame();
    3610     if (!frame)
    3611         return;
    3612     frame->editor().handleAlternativeTextUIResult(result);
     3597    Frame& frame = m_page->focusController().focusedOrMainFrame();
     3598    frame.editor().handleAlternativeTextUIResult(result);
    36133599}
    36143600#endif
     
    36313617void WebPage::setCompositionForTesting(const String& compositionString, uint64_t from, uint64_t length)
    36323618{
    3633     Frame* frame = m_page->focusController().focusedOrMainFrame();
    3634     if (!frame || !frame->editor().canEdit())
     3619    Frame& frame = m_page->focusController().focusedOrMainFrame();
     3620    if (!frame.editor().canEdit())
    36353621        return;
    36363622
    36373623    Vector<CompositionUnderline> underlines;
    36383624    underlines.append(CompositionUnderline(0, compositionString.length(), Color(Color::black), false));
    3639     frame->editor().setComposition(compositionString, underlines, from, from + length);
     3625    frame.editor().setComposition(compositionString, underlines, from, from + length);
    36403626}
    36413627
    36423628bool WebPage::hasCompositionForTesting()
    36433629{
    3644     Frame* frame = m_page->focusController().focusedOrMainFrame();
    3645     return frame && frame->editor().hasComposition();
     3630    Frame& frame = m_page->focusController().focusedOrMainFrame();
     3631    return frame.editor().hasComposition();
    36463632}
    36473633
    36483634void WebPage::confirmCompositionForTesting(const String& compositionString)
    36493635{
    3650     Frame* frame = m_page->focusController().focusedOrMainFrame();
    3651     if (!frame || !frame->editor().canEdit())
     3636    Frame& frame = m_page->focusController().focusedOrMainFrame();
     3637    if (!frame.editor().canEdit())
    36523638        return;
    36533639
    36543640    if (compositionString.isNull())
    3655         frame->editor().confirmComposition();
    3656     frame->editor().confirmComposition(compositionString);
     3641        frame.editor().confirmComposition();
     3642    frame.editor().confirmComposition(compositionString);
    36573643}
    36583644
     
    38073793static Frame* targetFrameForEditing(WebPage* page)
    38083794{
    3809     Frame* targetFrame = page->corePage()->focusController().focusedOrMainFrame();
    3810 
    3811     if (!targetFrame)
    3812         return 0;
    3813 
    3814     Editor& editor = targetFrame->editor();
     3795    Frame& targetFrame = page->corePage()->focusController().focusedOrMainFrame();
     3796
     3797    Editor& editor = targetFrame.editor();
    38153798    if (!editor.canEdit())
    38163799        return 0;
     
    38273810        }
    38283811    }
    3829     return targetFrame;
     3812    return &targetFrame;
    38303813}
    38313814
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r154085 r154678  
    844844    static bool platformCanHandleRequest(const WebCore::ResourceRequest&);
    845845
    846     static PluginView* focusedPluginViewForFrame(WebCore::Frame*);
     846    static PluginView* focusedPluginViewForFrame(WebCore::Frame&);
    847847    static PluginView* pluginViewForFrame(WebCore::Frame*);
    848848
  • trunk/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp

    r154178 r154678  
    7878static inline void scroll(Page* page, ScrollDirection direction, ScrollGranularity granularity)
    7979{
    80     page->focusController().focusedOrMainFrame()->eventHandler().scrollRecursively(direction, granularity);
     80    page->focusController().focusedOrMainFrame().eventHandler().scrollRecursively(direction, granularity);
    8181}
    8282
     
    175175static Frame* targetFrameForEditing(WebPage* page)
    176176{
    177     Frame* frame = page->corePage()->focusController().focusedOrMainFrame();
    178     if (!frame)
    179         return 0;
    180 
    181     Editor& editor = frame->editor();
     177    Frame& frame = page->corePage()->focusController().focusedOrMainFrame();
     178
     179    Editor& editor = frame.editor();
    182180    if (!editor.canEdit())
    183181        return 0;
     
    195193    }
    196194
    197     return frame;
     195    return &frame;
    198196}
    199197
     
    218216void WebPage::cancelComposition()
    219217{
    220     Frame* frame = m_page->focusController().focusedOrMainFrame();
    221     if (!frame)
    222         return;
    223 
    224     frame->editor().cancelComposition();
     218    Frame& frame = m_page->focusController().focusedOrMainFrame();
     219    frame.editor().cancelComposition();
    225220}
    226221
  • trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp

    r154178 r154678  
    7878static inline void scroll(Page* page, ScrollDirection direction, ScrollGranularity granularity)
    7979{
    80     page->focusController().focusedOrMainFrame()->eventHandler().scrollRecursively(direction, granularity);
     80    page->focusController().focusedOrMainFrame().eventHandler().scrollRecursively(direction, granularity);
    8181}
    8282
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm

    r154658 r154678  
    260260void WebPage::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, EditorState& newState)
    261261{
    262     Frame* frame = m_page->focusController().focusedOrMainFrame();
    263 
    264     if (frame->selection().isContentEditable()) {
     262    Frame& frame = m_page->focusController().focusedOrMainFrame();
     263
     264    if (frame.selection().isContentEditable()) {
    265265        RefPtr<Range> replacementRange;
    266266        if (replacementRangeStart != NSNotFound) {
    267             replacementRange = convertToRange(frame, NSMakeRange(replacementRangeStart, replacementRangeEnd - replacementRangeStart));
    268             frame->selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY));
     267            replacementRange = convertToRange(&frame, NSMakeRange(replacementRangeStart, replacementRangeEnd - replacementRangeStart));
     268            frame.selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY));
    269269        }
    270270
    271         frame->editor().setComposition(text, underlines, selectionStart, selectionEnd);
     271        frame.editor().setComposition(text, underlines, selectionStart, selectionEnd);
    272272    }
    273273
     
    277277void WebPage::confirmComposition(EditorState& newState)
    278278{
    279     Frame* frame = m_page->focusController().focusedOrMainFrame();
    280     frame->editor().confirmComposition();
     279    Frame& frame = m_page->focusController().focusedOrMainFrame();
     280    frame.editor().confirmComposition();
    281281    newState = editorState();
    282282}
     
    284284void WebPage::cancelComposition(EditorState& newState)
    285285{
    286     Frame* frame = m_page->focusController().focusedOrMainFrame();
    287     frame->editor().cancelComposition();
     286    Frame& frame = m_page->focusController().focusedOrMainFrame();
     287    frame.editor().cancelComposition();
    288288    newState = editorState();
    289289}
     
    291291void WebPage::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, bool& handled, EditorState& newState)
    292292{
    293     Frame* frame = m_page->focusController().focusedOrMainFrame();
     293    Frame& frame = m_page->focusController().focusedOrMainFrame();
    294294
    295295    if (replacementRangeStart != NSNotFound) {
    296         RefPtr<Range> replacementRange = convertToRange(frame, NSMakeRange(replacementRangeStart, replacementRangeEnd - replacementRangeStart));
     296        RefPtr<Range> replacementRange = convertToRange(&frame, NSMakeRange(replacementRangeStart, replacementRangeEnd - replacementRangeStart));
    297297        if (replacementRange)
    298             frame->selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY));
    299     }
    300 
    301     if (!frame->editor().hasComposition()) {
     298            frame.selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY));
     299    }
     300
     301    if (!frame.editor().hasComposition()) {
    302302        // An insertText: might be handled by other responders in the chain if we don't handle it.
    303303        // One example is space bar that results in scrolling down the page.
    304         handled = frame->editor().insertText(text, m_keyboardEventBeingInterpreted);
     304        handled = frame.editor().insertText(text, m_keyboardEventBeingInterpreted);
    305305    } else {
    306306        handled = true;
    307         frame->editor().confirmComposition(text);
     307        frame.editor().confirmComposition(text);
    308308    }
    309309
     
    313313void WebPage::insertDictatedText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool& handled, EditorState& newState)
    314314{
    315     Frame* frame = m_page->focusController().focusedOrMainFrame();
     315    Frame& frame = m_page->focusController().focusedOrMainFrame();
    316316
    317317    if (replacementRangeStart != NSNotFound) {
    318         RefPtr<Range> replacementRange = convertToRange(frame, NSMakeRange(replacementRangeStart, replacementRangeEnd - replacementRangeStart));
     318        RefPtr<Range> replacementRange = convertToRange(&frame, NSMakeRange(replacementRangeStart, replacementRangeEnd - replacementRangeStart));
    319319        if (replacementRange)
    320             frame->selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY));
    321     }
    322 
    323     ASSERT(!frame->editor().hasComposition());
    324     handled = frame->editor().insertDictatedText(text, dictationAlternativeLocations, m_keyboardEventBeingInterpreted);
     320            frame.selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY));
     321    }
     322
     323    ASSERT(!frame.editor().hasComposition());
     324    handled = frame.editor().insertDictatedText(text, dictationAlternativeLocations, m_keyboardEventBeingInterpreted);
    325325    newState = editorState();
    326326}
     
    328328void WebPage::getMarkedRange(uint64_t& location, uint64_t& length)
    329329{
    330     location = NSNotFound;
    331     length = 0;
    332     Frame* frame = m_page->focusController().focusedOrMainFrame();
    333     if (!frame)
    334         return;
    335 
    336     RefPtr<Range> range = frame->editor().compositionRange();
     330    Frame& frame = m_page->focusController().focusedOrMainFrame();
     331
     332    RefPtr<Range> range = frame.editor().compositionRange();
    337333    size_t locationSize;
    338334    size_t lengthSize;
    339     if (range && TextIterator::getLocationAndLengthFromRange(frame->selection().rootEditableElementOrDocumentElement(), range.get(), locationSize, lengthSize)) {
     335    if (range && TextIterator::getLocationAndLengthFromRange(frame.selection().rootEditableElementOrDocumentElement(), range.get(), locationSize, lengthSize)) {
    340336        location = static_cast<uint64_t>(locationSize);
    341337        length = static_cast<uint64_t>(lengthSize);
     338    } else {
     339        location = NSNotFound;
     340        length = 0;
    342341    }
    343342}
     
    345344void WebPage::getSelectedRange(uint64_t& location, uint64_t& length)
    346345{
    347     location = NSNotFound;
    348     length = 0;
    349     Frame* frame = m_page->focusController().focusedOrMainFrame();
    350     if (!frame)
    351         return;
     346    Frame& frame = m_page->focusController().focusedOrMainFrame();
    352347
    353348    size_t locationSize;
    354349    size_t lengthSize;
    355     RefPtr<Range> range = frame->selection().toNormalizedRange();
    356     if (range && TextIterator::getLocationAndLengthFromRange(frame->selection().rootEditableElementOrDocumentElement(), range.get(), locationSize, lengthSize)) {
     350    RefPtr<Range> range = frame.selection().toNormalizedRange();
     351    if (range && TextIterator::getLocationAndLengthFromRange(frame.selection().rootEditableElementOrDocumentElement(), range.get(), locationSize, lengthSize)) {
    357352        location = static_cast<uint64_t>(locationSize);
    358353        length = static_cast<uint64_t>(lengthSize);
     354    } else {
     355        location = NSNotFound;
     356        length = 0;
    359357    }
    360358}
     
    362360void WebPage::getAttributedSubstringFromRange(uint64_t location, uint64_t length, AttributedString& result)
    363361{
     362    Frame& frame = m_page->focusController().focusedOrMainFrame();
     363
     364    if (frame.selection().isNone() || !frame.selection().isContentEditable() || frame.selection().isInPasswordField())
     365        return;
     366
    364367    NSRange nsRange = NSMakeRange(location, length - location);
    365 
    366     Frame* frame = m_page->focusController().focusedOrMainFrame();
    367     if (!frame)
    368         return;
    369 
    370     if (frame->selection().isNone() || !frame->selection().isContentEditable() || frame->selection().isInPasswordField())
    371         return;
    372 
    373     RefPtr<Range> range = convertToRange(frame, nsRange);
     368    RefPtr<Range> range = convertToRange(&frame, nsRange);
    374369    if (!range)
    375370        return;
     
    393388
    394389    HitTestResult result = m_page->mainFrame().eventHandler().hitTestResultAtPoint(point);
    395     Frame* frame = result.innerNonSharedNode() ? result.innerNodeFrame() : m_page->focusController().focusedOrMainFrame();
     390    Frame* frame = result.innerNonSharedNode() ? result.innerNodeFrame() : &m_page->focusController().focusedOrMainFrame();
    396391   
    397392    RefPtr<Range> range = frame->rangeForPoint(result.roundedPointInInnerNodeFrame());
     
    423418void WebPage::firstRectForCharacterRange(uint64_t location, uint64_t length, WebCore::IntRect& resultRect)
    424419{
    425     Frame* frame = m_page->focusController().focusedOrMainFrame();
     420    Frame& frame = m_page->focusController().focusedOrMainFrame();
    426421    resultRect.setLocation(IntPoint(0, 0));
    427422    resultRect.setSize(IntSize(0, 0));
    428423   
    429     RefPtr<Range> range = convertToRange(frame, NSMakeRange(location, length));
     424    RefPtr<Range> range = convertToRange(&frame, NSMakeRange(location, length));
    430425    if (!range)
    431426        return;
     
    434429    ASSERT(range->endContainer());
    435430     
    436     IntRect rect = frame->editor().firstRectForRange(range.get());
    437     resultRect = frame->view()->contentsToWindow(rect);
     431    IntRect rect = frame.editor().firstRectForRange(range.get());
     432    resultRect = frame.view()->contentsToWindow(rect);
    438433}
    439434
     
    483478    IntPoint point = roundedIntPoint(floatPoint);
    484479    HitTestResult result = m_page->mainFrame().eventHandler().hitTestResultAtPoint(m_page->mainFrame().view()->windowToContents(point));
    485     Frame* frame = result.innerNonSharedNode() ? result.innerNonSharedNode()->document()->frame() : m_page->focusController().focusedOrMainFrame();
     480    Frame* frame = result.innerNonSharedNode() ? result.innerNonSharedNode()->document()->frame() : &m_page->focusController().focusedOrMainFrame();
    486481
    487482    IntPoint translatedPoint = frame->view()->windowToContents(point);
     
    492487
    493488    VisiblePosition position = frame->visiblePositionForPoint(translatedPoint);
    494     VisibleSelection selection = m_page->focusController().focusedOrMainFrame()->selection().selection();
     489    VisibleSelection selection = m_page->focusController().focusedOrMainFrame().selection().selection();
    495490    if (shouldUseSelection(position, selection)) {
    496491        performDictionaryLookupForSelection(frame, selection);
     
    674669void WebPage::readSelectionFromPasteboard(const String& pasteboardName, bool& result)
    675670{
    676     Frame* frame = m_page->focusController().focusedOrMainFrame();
    677     if (!frame || frame->selection().isNone()) {
     671    Frame& frame = m_page->focusController().focusedOrMainFrame();
     672    if (frame.selection().isNone()) {
    678673        result = false;
    679674        return;
    680675    }
    681     frame->editor().readSelectionFromPasteboard(pasteboardName);
     676    frame.editor().readSelectionFromPasteboard(pasteboardName);
    682677    result = true;
    683678}
     
    685680void WebPage::getStringSelectionForPasteboard(String& stringValue)
    686681{
    687     Frame* frame = m_page->focusController().focusedOrMainFrame();
    688 
    689     if (!frame)
    690         return;
     682    Frame& frame = m_page->focusController().focusedOrMainFrame();
    691683
    692684    if (PluginView* pluginView = focusedPluginViewForFrame(frame)) {
     
    698690    }
    699691
    700     if (frame->selection().isNone())
    701         return;
    702 
    703     stringValue = frame->editor().stringSelectionForPasteboard();
     692    if (frame.selection().isNone())
     693        return;
     694
     695    stringValue = frame.editor().stringSelectionForPasteboard();
    704696}
    705697
    706698void WebPage::getDataSelectionForPasteboard(const String pasteboardType, SharedMemory::Handle& handle, uint64_t& size)
    707699{
    708     Frame* frame = m_page->focusController().focusedOrMainFrame();
    709     if (!frame || frame->selection().isNone())
    710         return;
    711 
    712     RefPtr<SharedBuffer> buffer = frame->editor().dataSelectionForPasteboard(pasteboardType);
     700    Frame& frame = m_page->focusController().focusedOrMainFrame();
     701    if (frame.selection().isNone())
     702        return;
     703
     704    RefPtr<SharedBuffer> buffer = frame.editor().dataSelectionForPasteboard(pasteboardType);
    713705    if (!buffer) {
    714706        size = 0;
     
    777769void WebPage::shouldDelayWindowOrderingEvent(const WebKit::WebMouseEvent& event, bool& result)
    778770{
     771    Frame& frame = m_page->focusController().focusedOrMainFrame();
     772
     773#if ENABLE(DRAG_SUPPORT)
     774    HitTestResult hitResult = frame.eventHandler().hitTestResultAtPoint(frame.view()->windowToContents(event.position()), HitTestRequest::ReadOnly | HitTestRequest::Active);
     775    if (hitResult.isSelected())
     776        result = frame.eventHandler().eventMayStartDrag(platform(event));
     777    else
     778#endif
     779        result = false;
     780}
     781
     782void WebPage::acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent& event, bool& result)
     783{
    779784    result = false;
    780     Frame* frame = m_page->focusController().focusedOrMainFrame();
    781     if (!frame)
    782         return;
    783 
    784 #if ENABLE(DRAG_SUPPORT)
    785     HitTestResult hitResult = frame->eventHandler().hitTestResultAtPoint(frame->view()->windowToContents(event.position()), HitTestRequest::ReadOnly | HitTestRequest::Active);
    786     if (hitResult.isSelected())
    787         result = frame->eventHandler().eventMayStartDrag(platform(event));
    788 #endif
    789 }
    790 
    791 void WebPage::acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent& event, bool& result)
    792 {
    793     result = false;
    794     Frame* frame = m_page->focusController().focusedOrMainFrame();
    795     if (!frame)
    796         return;
    797    
    798     HitTestResult hitResult = frame->eventHandler().hitTestResultAtPoint(frame->view()->windowToContents(event.position()), HitTestRequest::ReadOnly | HitTestRequest::Active);
    799     frame->eventHandler().setActivationEventNumber(eventNumber);
     785    Frame& frame = m_page->focusController().focusedOrMainFrame();
     786
     787    HitTestResult hitResult = frame.eventHandler().hitTestResultAtPoint(frame.view()->windowToContents(event.position()), HitTestRequest::ReadOnly | HitTestRequest::Active);
     788    frame.eventHandler().setActivationEventNumber(eventNumber);
    800789#if ENABLE(DRAG_SUPPORT)
    801790    if (hitResult.isSelected())
    802         result = frame->eventHandler().eventMayStartDrag(platform(event));
     791        result = frame.eventHandler().eventMayStartDrag(platform(event));
    803792    else
    804793#endif
  • trunk/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp

    r154178 r154678  
    224224static inline void scroll(Page* page, ScrollDirection direction, ScrollGranularity granularity)
    225225{
    226     page->focusController().focusedOrMainFrame()->eventHandler().scrollRecursively(direction, granularity);
     226    page->focusController().focusedOrMainFrame().eventHandler().scrollRecursively(direction, granularity);
    227227}
    228228
    229229static inline void logicalScroll(Page* page, ScrollLogicalDirection direction, ScrollGranularity granularity)
    230230{
    231     page->focusController().focusedOrMainFrame()->eventHandler().logicalScrollRecursively(direction, granularity);
     231    page->focusController().focusedOrMainFrame().eventHandler().logicalScrollRecursively(direction, granularity);
    232232}
    233233
Note: See TracChangeset for help on using the changeset viewer.