| Index: Source/web/WebViewImpl.cpp
|
| ===================================================================
|
| --- Source/web/WebViewImpl.cpp (revision 170478)
|
| +++ Source/web/WebViewImpl.cpp (working copy)
|
| @@ -522,23 +522,18 @@
|
|
|
| // Find the right target frame. See issue 1186900.
|
| HitTestResult result = hitTestResultForWindowPos(pme.position());
|
| - Frame* targetFrame;
|
| + LocalFrame* targetFrame;
|
| if (result.innerNonSharedNode())
|
| targetFrame = result.innerNonSharedNode()->document().frame();
|
| else
|
| targetFrame = m_page->focusController().focusedOrMainFrame();
|
|
|
| - if (!targetFrame->isLocalFrame())
|
| - return;
|
| -
|
| - LocalFrame* targetLocalFrame = toLocalFrame(targetFrame);
|
| -
|
| #if OS(WIN)
|
| - targetLocalFrame->view()->setCursor(pointerCursor());
|
| + targetFrame->view()->setCursor(pointerCursor());
|
| #endif
|
|
|
| m_contextMenuAllowed = true;
|
| - targetLocalFrame->eventHandler().sendContextMenuEvent(pme);
|
| + targetFrame->eventHandler().sendContextMenuEvent(pme);
|
| m_contextMenuAllowed = false;
|
| // Actually showing the context menu is handled by the ContextMenuClient
|
| // implementation...
|
| @@ -857,11 +852,11 @@
|
|
|
| void WebViewImpl::getSelectionRootBounds(WebRect& bounds) const
|
| {
|
| - const Frame* frame = focusedWebCoreFrame();
|
| - if (!frame || !frame->isLocalFrame())
|
| + const LocalFrame* frame = focusedWebCoreFrame();
|
| + if (!frame)
|
| return;
|
|
|
| - Element* root = toLocalFrame(frame)->selection().rootEditableElementOrDocumentElement();
|
| + Element* root = frame->selection().rootEditableElementOrDocumentElement();
|
| if (!root)
|
| return;
|
|
|
| @@ -912,8 +907,7 @@
|
| return true;
|
| }
|
|
|
| - // TODO(kenrb): Handle the remote frame case. Possibly move eventHandler() to Frame?
|
| - RefPtr<LocalFrame> frame = toLocalFrame(focusedWebCoreFrame());
|
| + RefPtr<LocalFrame> frame = focusedWebCoreFrame();
|
| if (!frame)
|
| return false;
|
|
|
| @@ -968,7 +962,7 @@
|
| if (m_pagePopup)
|
| return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
|
|
|
| - LocalFrame* frame = toLocalFrame(focusedWebCoreFrame());
|
| + LocalFrame* frame = focusedWebCoreFrame();
|
| if (!frame)
|
| return suppress;
|
|
|
| @@ -1313,10 +1307,8 @@
|
| page()->contextMenuController().clearContextMenu();
|
|
|
| m_contextMenuAllowed = true;
|
| - Frame* focusedFrame = page()->focusController().focusedOrMainFrame();
|
| - if (!focusedFrame->isLocalFrame())
|
| - return false;
|
| - bool handled = toLocalFrame(focusedFrame)->eventHandler().sendContextMenuEventForKey();
|
| + LocalFrame* focusedFrame = page()->focusController().focusedOrMainFrame();
|
| + bool handled = focusedFrame->eventHandler().sendContextMenuEventForKey();
|
| m_contextMenuAllowed = false;
|
| return handled;
|
| }
|
| @@ -1324,7 +1316,7 @@
|
|
|
| bool WebViewImpl::keyEventDefault(const WebKeyboardEvent& event)
|
| {
|
| - LocalFrame* frame = toLocalFrame(focusedWebCoreFrame());
|
| + LocalFrame* frame = focusedWebCoreFrame();
|
| if (!frame)
|
| return false;
|
|
|
| @@ -1437,7 +1429,7 @@
|
|
|
| bool WebViewImpl::bubblingScroll(ScrollDirection scrollDirection, ScrollGranularity scrollGranularity)
|
| {
|
| - LocalFrame* frame = toLocalFrame(focusedWebCoreFrame());
|
| + LocalFrame* frame = focusedWebCoreFrame();
|
| if (!frame)
|
| return false;
|
|
|
| @@ -1490,7 +1482,7 @@
|
| m_pagePopup = nullptr;
|
| }
|
|
|
| -Frame* WebViewImpl::focusedWebCoreFrame() const
|
| +LocalFrame* WebViewImpl::focusedWebCoreFrame() const
|
| {
|
| return m_page ? m_page->focusController().focusedOrMainFrame() : 0;
|
| }
|
| @@ -1870,11 +1862,10 @@
|
| m_page->focusController().setFocused(enable);
|
| if (enable) {
|
| m_page->focusController().setActive(true);
|
| - RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame();
|
| - if (focusedFrame && focusedFrame->isLocalFrame()) {
|
| - LocalFrame* localFrame = toLocalFrame(focusedFrame.get());
|
| - Element* element = localFrame->document()->focusedElement();
|
| - if (element && localFrame->selection().selection().isNone()) {
|
| + RefPtr<LocalFrame> focusedFrame = m_page->focusController().focusedFrame();
|
| + if (focusedFrame) {
|
| + Element* element = focusedFrame->document()->focusedElement();
|
| + if (element && focusedFrame->selection().selection().isNone()) {
|
| // If the selection was cleared while the WebView was not
|
| // focused, then the focus element shows with a focus ring but
|
| // no caret and does respond to keyboard inputs.
|
| @@ -1886,7 +1877,7 @@
|
| // instead. Note that this has the side effect of moving the
|
| // caret back to the beginning of the text.
|
| Position position(element, 0, Position::PositionIsOffsetInAnchor);
|
| - localFrame->selection().setSelection(VisibleSelection(position, SEL_DEFAULT_AFFINITY));
|
| + focusedFrame->selection().setSelection(VisibleSelection(position, SEL_DEFAULT_AFFINITY));
|
| }
|
| }
|
| }
|
| @@ -1902,14 +1893,14 @@
|
| if (!frame)
|
| return;
|
|
|
| - RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame();
|
| - if (focusedFrame && focusedFrame->isLocalFrame()) {
|
| + RefPtr<LocalFrame> focusedFrame = m_page->focusController().focusedFrame();
|
| + if (focusedFrame) {
|
| // Finish an ongoing composition to delete the composition node.
|
| - if (toLocalFrame(focusedFrame.get())->inputMethodController().hasComposition()) {
|
| + if (focusedFrame->inputMethodController().hasComposition()) {
|
| if (m_autofillClient)
|
| m_autofillClient->setIgnoreTextChanges(true);
|
|
|
| - toLocalFrame(focusedFrame.get())->inputMethodController().confirmComposition();
|
| + focusedFrame->inputMethodController().confirmComposition();
|
|
|
| if (m_autofillClient)
|
| m_autofillClient->setIgnoreTextChanges(false);
|
| @@ -1925,7 +1916,7 @@
|
| int selectionStart,
|
| int selectionEnd)
|
| {
|
| - LocalFrame* focused = toLocalFrame(focusedWebCoreFrame());
|
| + LocalFrame* focused = focusedWebCoreFrame();
|
| if (!focused || !m_imeAcceptEvents)
|
| return false;
|
|
|
| @@ -1991,7 +1982,7 @@
|
|
|
| bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBehavior selectionBehavior)
|
| {
|
| - LocalFrame* focused = toLocalFrame(focusedWebCoreFrame());
|
| + LocalFrame* focused = focusedWebCoreFrame();
|
| if (!focused || !m_imeAcceptEvents)
|
| return false;
|
|
|
| @@ -2003,7 +1994,7 @@
|
|
|
| bool WebViewImpl::compositionRange(size_t* location, size_t* length)
|
| {
|
| - LocalFrame* focused = toLocalFrame(focusedWebCoreFrame());
|
| + LocalFrame* focused = focusedWebCoreFrame();
|
| if (!focused || !m_imeAcceptEvents)
|
| return false;
|
|
|
| @@ -2025,7 +2016,7 @@
|
| {
|
| WebTextInputInfo info;
|
|
|
| - LocalFrame* focused = toLocalFrame(focusedWebCoreFrame());
|
| + LocalFrame* focused = focusedWebCoreFrame();
|
| if (!focused)
|
| return info;
|
|
|
| @@ -2151,7 +2142,7 @@
|
|
|
| bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const
|
| {
|
| - const LocalFrame* frame = toLocalFrame(focusedWebCoreFrame());
|
| + const LocalFrame* frame = focusedWebCoreFrame();
|
| if (!frame)
|
| return false;
|
| FrameSelection& selection = frame->selection();
|
| @@ -2195,7 +2186,7 @@
|
| if (!m_imeAcceptEvents)
|
| return 0;
|
|
|
| - LocalFrame* focusedFrame = toLocalFrame(focusedWebCoreFrame());
|
| + LocalFrame* focusedFrame = focusedWebCoreFrame();
|
| if (!focusedFrame)
|
| return 0;
|
|
|
| @@ -2234,7 +2225,7 @@
|
|
|
| bool WebViewImpl::selectionTextDirection(WebTextDirection& start, WebTextDirection& end) const
|
| {
|
| - const LocalFrame* frame = toLocalFrame(focusedWebCoreFrame());
|
| + const LocalFrame* frame = focusedWebCoreFrame();
|
| if (!frame)
|
| return false;
|
| FrameSelection& selection = frame->selection();
|
| @@ -2247,14 +2238,14 @@
|
|
|
| bool WebViewImpl::isSelectionAnchorFirst() const
|
| {
|
| - if (const LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()))
|
| + if (const LocalFrame* frame = focusedWebCoreFrame())
|
| return frame->selection().selection().isBaseFirst();
|
| return false;
|
| }
|
|
|
| WebVector<WebCompositionUnderline> WebViewImpl::compositionUnderlines() const
|
| {
|
| - const LocalFrame* focused = toLocalFrame(focusedWebCoreFrame());
|
| + const LocalFrame* focused = focusedWebCoreFrame();
|
| if (!focused)
|
| return WebVector<WebCompositionUnderline>();
|
| const Vector<CompositionUnderline>& underlines = focused->inputMethodController().customCompositionUnderlines();
|
| @@ -2280,7 +2271,7 @@
|
|
|
| bool WebViewImpl::caretOrSelectionRange(size_t* location, size_t* length)
|
| {
|
| - const LocalFrame* focused = toLocalFrame(focusedWebCoreFrame());
|
| + const LocalFrame* focused = focusedWebCoreFrame();
|
| if (!focused)
|
| return false;
|
|
|
| @@ -2299,7 +2290,7 @@
|
| // the text direction of the selected node and updates its DOM "dir"
|
| // attribute and its CSS "direction" property.
|
| // So, we just call the function as Safari does.
|
| - const LocalFrame* focused = toLocalFrame(focusedWebCoreFrame());
|
| + const LocalFrame* focused = focusedWebCoreFrame();
|
| if (!focused)
|
| return;
|
|
|
| @@ -2433,16 +2424,15 @@
|
|
|
| WebFrame* WebViewImpl::focusedFrame()
|
| {
|
| - return WebFrameImpl::fromFrame(toLocalFrame(focusedWebCoreFrame()));
|
| + return WebFrameImpl::fromFrame(focusedWebCoreFrame());
|
| }
|
|
|
| void WebViewImpl::setFocusedFrame(WebFrame* frame)
|
| {
|
| if (!frame) {
|
| // Clears the focused frame if any.
|
| - Frame* focusedFrame = focusedWebCoreFrame();
|
| - if (focusedFrame && focusedFrame->isLocalFrame())
|
| - toLocalFrame(focusedFrame)->selection().setFocused(false);
|
| + if (LocalFrame* focusedFrame = focusedWebCoreFrame())
|
| + focusedFrame->selection().setFocused(false);
|
| return;
|
| }
|
| LocalFrame* webcoreFrame = toWebFrameImpl(frame)->frame();
|
| @@ -2453,23 +2443,19 @@
|
| {
|
| if (!m_page)
|
| return;
|
| - Frame* frame = page()->focusController().focusedOrMainFrame();
|
| - if (frame->isLocalFrame()) {
|
| - if (Document* document = toLocalFrame(frame)->document())
|
| - document->setFocusedElement(nullptr);
|
| - }
|
| + LocalFrame* frame = page()->focusController().focusedOrMainFrame();
|
| + if (Document* document = frame->document())
|
| + document->setFocusedElement(nullptr);
|
| page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : FocusTypeForward);
|
| }
|
|
|
| void WebViewImpl::clearFocusedElement()
|
| {
|
| - RefPtr<Frame> frame = focusedWebCoreFrame();
|
| - if (!frame || !frame->isLocalFrame())
|
| + RefPtr<LocalFrame> frame = focusedWebCoreFrame();
|
| + if (!frame)
|
| return;
|
|
|
| - LocalFrame* localFrame = toLocalFrame(frame.get());
|
| -
|
| - RefPtr<Document> document = localFrame->document();
|
| + RefPtr<Document> document = frame->document();
|
| if (!document)
|
| return;
|
|
|
| @@ -2486,7 +2472,7 @@
|
| // processing keyboard events even though focus has been moved to the page and
|
| // keystrokes get eaten as a result.
|
| if (oldFocusedElement->isContentEditable() || oldFocusedElement->isTextFormControl())
|
| - localFrame->selection().clear();
|
| + frame->selection().clear();
|
| }
|
|
|
| void WebViewImpl::scrollFocusedNodeIntoView()
|
| @@ -3322,14 +3308,14 @@
|
|
|
| page()->contextMenuController().clearContextMenu();
|
| m_contextMenuAllowed = true;
|
| - if (LocalFrame* focusedFrame = toLocalFrame(page()->focusController().focusedOrMainFrame()))
|
| + if (LocalFrame* focusedFrame = page()->focusController().focusedOrMainFrame())
|
| focusedFrame->eventHandler().sendContextMenuEventForKey();
|
| m_contextMenuAllowed = false;
|
| }
|
|
|
| WebString WebViewImpl::getSmartClipData(WebRect rect)
|
| {
|
| - LocalFrame* frame = toLocalFrame(focusedWebCoreFrame());
|
| + LocalFrame* frame = focusedWebCoreFrame();
|
| if (!frame)
|
| return WebString();
|
| return WebCore::SmartClip(frame).dataForRect(rect).toString();
|
| @@ -3562,11 +3548,11 @@
|
|
|
| Element* WebViewImpl::focusedElement() const
|
| {
|
| - Frame* frame = m_page->focusController().focusedFrame();
|
| - if (!frame || !frame->isLocalFrame())
|
| + LocalFrame* frame = m_page->focusController().focusedFrame();
|
| + if (!frame)
|
| return 0;
|
|
|
| - Document* document = toLocalFrame(frame)->document();
|
| + Document* document = frame->document();
|
| if (!document)
|
| return 0;
|
|
|
|
|