| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 { | 515 { |
| 516 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 516 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
| 517 return; | 517 return; |
| 518 | 518 |
| 519 m_page->contextMenuController().clearContextMenu(); | 519 m_page->contextMenuController().clearContextMenu(); |
| 520 | 520 |
| 521 PlatformMouseEventBuilder pme(mainFrameImpl()->frameView(), event); | 521 PlatformMouseEventBuilder pme(mainFrameImpl()->frameView(), event); |
| 522 | 522 |
| 523 // Find the right target frame. See issue 1186900. | 523 // Find the right target frame. See issue 1186900. |
| 524 HitTestResult result = hitTestResultForWindowPos(pme.position()); | 524 HitTestResult result = hitTestResultForWindowPos(pme.position()); |
| 525 Frame* targetFrame; | 525 LocalFrame* targetFrame; |
| 526 if (result.innerNonSharedNode()) | 526 if (result.innerNonSharedNode()) |
| 527 targetFrame = result.innerNonSharedNode()->document().frame(); | 527 targetFrame = result.innerNonSharedNode()->document().frame(); |
| 528 else | 528 else |
| 529 targetFrame = m_page->focusController().focusedOrMainFrame(); | 529 targetFrame = m_page->focusController().focusedOrMainFrame(); |
| 530 | 530 |
| 531 if (!targetFrame->isLocalFrame()) | |
| 532 return; | |
| 533 | |
| 534 LocalFrame* targetLocalFrame = toLocalFrame(targetFrame); | |
| 535 | |
| 536 #if OS(WIN) | 531 #if OS(WIN) |
| 537 targetLocalFrame->view()->setCursor(pointerCursor()); | 532 targetFrame->view()->setCursor(pointerCursor()); |
| 538 #endif | 533 #endif |
| 539 | 534 |
| 540 m_contextMenuAllowed = true; | 535 m_contextMenuAllowed = true; |
| 541 targetLocalFrame->eventHandler().sendContextMenuEvent(pme); | 536 targetFrame->eventHandler().sendContextMenuEvent(pme); |
| 542 m_contextMenuAllowed = false; | 537 m_contextMenuAllowed = false; |
| 543 // Actually showing the context menu is handled by the ContextMenuClient | 538 // Actually showing the context menu is handled by the ContextMenuClient |
| 544 // implementation... | 539 // implementation... |
| 545 } | 540 } |
| 546 | 541 |
| 547 void WebViewImpl::handleMouseUp(LocalFrame& mainFrame, const WebMouseEvent& even
t) | 542 void WebViewImpl::handleMouseUp(LocalFrame& mainFrame, const WebMouseEvent& even
t) |
| 548 { | 543 { |
| 549 PageWidgetEventHandler::handleMouseUp(mainFrame, event); | 544 PageWidgetEventHandler::handleMouseUp(mainFrame, event); |
| 550 | 545 |
| 551 #if OS(WIN) | 546 #if OS(WIN) |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 | 845 |
| 851 void WebViewImpl::setShowScrollBottleneckRects(bool show) | 846 void WebViewImpl::setShowScrollBottleneckRects(bool show) |
| 852 { | 847 { |
| 853 if (m_layerTreeView) | 848 if (m_layerTreeView) |
| 854 m_layerTreeView->setShowScrollBottleneckRects(show); | 849 m_layerTreeView->setShowScrollBottleneckRects(show); |
| 855 m_showScrollBottleneckRects = show; | 850 m_showScrollBottleneckRects = show; |
| 856 } | 851 } |
| 857 | 852 |
| 858 void WebViewImpl::getSelectionRootBounds(WebRect& bounds) const | 853 void WebViewImpl::getSelectionRootBounds(WebRect& bounds) const |
| 859 { | 854 { |
| 860 const Frame* frame = focusedWebCoreFrame(); | 855 const LocalFrame* frame = focusedWebCoreFrame(); |
| 861 if (!frame || !frame->isLocalFrame()) | 856 if (!frame) |
| 862 return; | 857 return; |
| 863 | 858 |
| 864 Element* root = toLocalFrame(frame)->selection().rootEditableElementOrDocume
ntElement(); | 859 Element* root = frame->selection().rootEditableElementOrDocumentElement(); |
| 865 if (!root) | 860 if (!root) |
| 866 return; | 861 return; |
| 867 | 862 |
| 868 // If the selection is inside a form control, the root will be a <div> that | 863 // If the selection is inside a form control, the root will be a <div> that |
| 869 // behaves as the editor but we want to return the actual element's bounds. | 864 // behaves as the editor but we want to return the actual element's bounds. |
| 870 // In practice, that means <textarea> and <input> controls that behave like | 865 // In practice, that means <textarea> and <input> controls that behave like |
| 871 // a text field. | 866 // a text field. |
| 872 Element* shadowHost = root->shadowHost(); | 867 Element* shadowHost = root->shadowHost(); |
| 873 if (shadowHost | 868 if (shadowHost |
| 874 && (isHTMLTextAreaElement(*shadowHost) | 869 && (isHTMLTextAreaElement(*shadowHost) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 905 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)
); | 900 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)
); |
| 906 if (m_pagePopup) { | 901 if (m_pagePopup) { |
| 907 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); | 902 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); |
| 908 // We need to ignore the next Char event after this otherwise pressing | 903 // We need to ignore the next Char event after this otherwise pressing |
| 909 // enter when selecting an item in the popup will go to the page. | 904 // enter when selecting an item in the popup will go to the page. |
| 910 if (WebInputEvent::RawKeyDown == event.type) | 905 if (WebInputEvent::RawKeyDown == event.type) |
| 911 m_suppressNextKeypressEvent = true; | 906 m_suppressNextKeypressEvent = true; |
| 912 return true; | 907 return true; |
| 913 } | 908 } |
| 914 | 909 |
| 915 // TODO(kenrb): Handle the remote frame case. Possibly move eventHandler() t
o Frame? | 910 RefPtr<LocalFrame> frame = focusedWebCoreFrame(); |
| 916 RefPtr<LocalFrame> frame = toLocalFrame(focusedWebCoreFrame()); | |
| 917 if (!frame) | 911 if (!frame) |
| 918 return false; | 912 return false; |
| 919 | 913 |
| 920 #if !OS(MACOSX) | 914 #if !OS(MACOSX) |
| 921 const WebInputEvent::Type contextMenuTriggeringEventType = | 915 const WebInputEvent::Type contextMenuTriggeringEventType = |
| 922 #if OS(WIN) | 916 #if OS(WIN) |
| 923 WebInputEvent::KeyUp; | 917 WebInputEvent::KeyUp; |
| 924 #else | 918 #else |
| 925 WebInputEvent::RawKeyDown; | 919 WebInputEvent::RawKeyDown; |
| 926 #endif | 920 #endif |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 bool suppress = m_suppressNextKeypressEvent; | 955 bool suppress = m_suppressNextKeypressEvent; |
| 962 m_suppressNextKeypressEvent = false; | 956 m_suppressNextKeypressEvent = false; |
| 963 | 957 |
| 964 // If there is a select popup, it should be the one processing the event, | 958 // If there is a select popup, it should be the one processing the event, |
| 965 // not the page. | 959 // not the page. |
| 966 if (m_selectPopup) | 960 if (m_selectPopup) |
| 967 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)
); | 961 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)
); |
| 968 if (m_pagePopup) | 962 if (m_pagePopup) |
| 969 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); | 963 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); |
| 970 | 964 |
| 971 LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); | 965 LocalFrame* frame = focusedWebCoreFrame(); |
| 972 if (!frame) | 966 if (!frame) |
| 973 return suppress; | 967 return suppress; |
| 974 | 968 |
| 975 EventHandler& handler = frame->eventHandler(); | 969 EventHandler& handler = frame->eventHandler(); |
| 976 | 970 |
| 977 PlatformKeyboardEventBuilder evt(event); | 971 PlatformKeyboardEventBuilder evt(event); |
| 978 if (!evt.isCharacterKey()) | 972 if (!evt.isCharacterKey()) |
| 979 return true; | 973 return true; |
| 980 | 974 |
| 981 // Accesskeys are triggered by char events and can't be suppressed. | 975 // Accesskeys are triggered by char events and can't be suppressed. |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1306 { | 1300 { |
| 1307 // The contextMenuController() holds onto the last context menu that was | 1301 // The contextMenuController() holds onto the last context menu that was |
| 1308 // popped up on the page until a new one is created. We need to clear | 1302 // popped up on the page until a new one is created. We need to clear |
| 1309 // this menu before propagating the event through the DOM so that we can | 1303 // this menu before propagating the event through the DOM so that we can |
| 1310 // detect if we create a new menu for this event, since we won't create | 1304 // detect if we create a new menu for this event, since we won't create |
| 1311 // a new menu if the DOM swallows the event and the defaultEventHandler does | 1305 // a new menu if the DOM swallows the event and the defaultEventHandler does |
| 1312 // not run. | 1306 // not run. |
| 1313 page()->contextMenuController().clearContextMenu(); | 1307 page()->contextMenuController().clearContextMenu(); |
| 1314 | 1308 |
| 1315 m_contextMenuAllowed = true; | 1309 m_contextMenuAllowed = true; |
| 1316 Frame* focusedFrame = page()->focusController().focusedOrMainFrame(); | 1310 LocalFrame* focusedFrame = page()->focusController().focusedOrMainFrame(); |
| 1317 if (!focusedFrame->isLocalFrame()) | 1311 bool handled = focusedFrame->eventHandler().sendContextMenuEventForKey(); |
| 1318 return false; | |
| 1319 bool handled = toLocalFrame(focusedFrame)->eventHandler().sendContextMenuEve
ntForKey(); | |
| 1320 m_contextMenuAllowed = false; | 1312 m_contextMenuAllowed = false; |
| 1321 return handled; | 1313 return handled; |
| 1322 } | 1314 } |
| 1323 #endif | 1315 #endif |
| 1324 | 1316 |
| 1325 bool WebViewImpl::keyEventDefault(const WebKeyboardEvent& event) | 1317 bool WebViewImpl::keyEventDefault(const WebKeyboardEvent& event) |
| 1326 { | 1318 { |
| 1327 LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); | 1319 LocalFrame* frame = focusedWebCoreFrame(); |
| 1328 if (!frame) | 1320 if (!frame) |
| 1329 return false; | 1321 return false; |
| 1330 | 1322 |
| 1331 switch (event.type) { | 1323 switch (event.type) { |
| 1332 case WebInputEvent::Char: | 1324 case WebInputEvent::Char: |
| 1333 if (event.windowsKeyCode == VKEY_SPACE) { | 1325 if (event.windowsKeyCode == VKEY_SPACE) { |
| 1334 int keyCode = ((event.modifiers & WebInputEvent::ShiftKey) ? VKEY_PR
IOR : VKEY_NEXT); | 1326 int keyCode = ((event.modifiers & WebInputEvent::ShiftKey) ? VKEY_PR
IOR : VKEY_NEXT); |
| 1335 return scrollViewWithKeyboard(keyCode, event.modifiers); | 1327 return scrollViewWithKeyboard(keyCode, event.modifiers); |
| 1336 } | 1328 } |
| 1337 break; | 1329 break; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1430 } | 1422 } |
| 1431 | 1423 |
| 1432 void WebViewImpl::hideSelectPopup() | 1424 void WebViewImpl::hideSelectPopup() |
| 1433 { | 1425 { |
| 1434 if (m_selectPopup) | 1426 if (m_selectPopup) |
| 1435 m_selectPopup->hidePopup(); | 1427 m_selectPopup->hidePopup(); |
| 1436 } | 1428 } |
| 1437 | 1429 |
| 1438 bool WebViewImpl::bubblingScroll(ScrollDirection scrollDirection, ScrollGranular
ity scrollGranularity) | 1430 bool WebViewImpl::bubblingScroll(ScrollDirection scrollDirection, ScrollGranular
ity scrollGranularity) |
| 1439 { | 1431 { |
| 1440 LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); | 1432 LocalFrame* frame = focusedWebCoreFrame(); |
| 1441 if (!frame) | 1433 if (!frame) |
| 1442 return false; | 1434 return false; |
| 1443 | 1435 |
| 1444 return frame->eventHandler().bubblingScroll(scrollDirection, scrollGranulari
ty); | 1436 return frame->eventHandler().bubblingScroll(scrollDirection, scrollGranulari
ty); |
| 1445 } | 1437 } |
| 1446 | 1438 |
| 1447 void WebViewImpl::popupOpened(PopupContainer* popupContainer) | 1439 void WebViewImpl::popupOpened(PopupContainer* popupContainer) |
| 1448 { | 1440 { |
| 1449 ASSERT(!m_selectPopup); | 1441 ASSERT(!m_selectPopup); |
| 1450 m_selectPopup = popupContainer; | 1442 m_selectPopup = popupContainer; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 { | 1475 { |
| 1484 ASSERT(popup); | 1476 ASSERT(popup); |
| 1485 WebPagePopupImpl* popupImpl = toWebPagePopupImpl(popup); | 1477 WebPagePopupImpl* popupImpl = toWebPagePopupImpl(popup); |
| 1486 ASSERT(m_pagePopup.get() == popupImpl); | 1478 ASSERT(m_pagePopup.get() == popupImpl); |
| 1487 if (m_pagePopup.get() != popupImpl) | 1479 if (m_pagePopup.get() != popupImpl) |
| 1488 return; | 1480 return; |
| 1489 m_pagePopup->closePopup(); | 1481 m_pagePopup->closePopup(); |
| 1490 m_pagePopup = nullptr; | 1482 m_pagePopup = nullptr; |
| 1491 } | 1483 } |
| 1492 | 1484 |
| 1493 Frame* WebViewImpl::focusedWebCoreFrame() const | 1485 LocalFrame* WebViewImpl::focusedWebCoreFrame() const |
| 1494 { | 1486 { |
| 1495 return m_page ? m_page->focusController().focusedOrMainFrame() : 0; | 1487 return m_page ? m_page->focusController().focusedOrMainFrame() : 0; |
| 1496 } | 1488 } |
| 1497 | 1489 |
| 1498 WebViewImpl* WebViewImpl::fromPage(Page* page) | 1490 WebViewImpl* WebViewImpl::fromPage(Page* page) |
| 1499 { | 1491 { |
| 1500 if (!page) | 1492 if (!page) |
| 1501 return 0; | 1493 return 0; |
| 1502 return static_cast<WebViewImpl*>(page->chrome().client().webView()); | 1494 return static_cast<WebViewImpl*>(page->chrome().client().webView()); |
| 1503 } | 1495 } |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1863 { | 1855 { |
| 1864 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this); | 1856 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this); |
| 1865 m_mouseCaptureNode = nullptr; | 1857 m_mouseCaptureNode = nullptr; |
| 1866 } | 1858 } |
| 1867 | 1859 |
| 1868 void WebViewImpl::setFocus(bool enable) | 1860 void WebViewImpl::setFocus(bool enable) |
| 1869 { | 1861 { |
| 1870 m_page->focusController().setFocused(enable); | 1862 m_page->focusController().setFocused(enable); |
| 1871 if (enable) { | 1863 if (enable) { |
| 1872 m_page->focusController().setActive(true); | 1864 m_page->focusController().setActive(true); |
| 1873 RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame(); | 1865 RefPtr<LocalFrame> focusedFrame = m_page->focusController().focusedFrame
(); |
| 1874 if (focusedFrame && focusedFrame->isLocalFrame()) { | 1866 if (focusedFrame) { |
| 1875 LocalFrame* localFrame = toLocalFrame(focusedFrame.get()); | 1867 Element* element = focusedFrame->document()->focusedElement(); |
| 1876 Element* element = localFrame->document()->focusedElement(); | 1868 if (element && focusedFrame->selection().selection().isNone()) { |
| 1877 if (element && localFrame->selection().selection().isNone()) { | |
| 1878 // If the selection was cleared while the WebView was not | 1869 // If the selection was cleared while the WebView was not |
| 1879 // focused, then the focus element shows with a focus ring but | 1870 // focused, then the focus element shows with a focus ring but |
| 1880 // no caret and does respond to keyboard inputs. | 1871 // no caret and does respond to keyboard inputs. |
| 1881 if (element->isTextFormControl()) { | 1872 if (element->isTextFormControl()) { |
| 1882 element->updateFocusAppearance(true); | 1873 element->updateFocusAppearance(true); |
| 1883 } else if (element->isContentEditable()) { | 1874 } else if (element->isContentEditable()) { |
| 1884 // updateFocusAppearance() selects all the text of | 1875 // updateFocusAppearance() selects all the text of |
| 1885 // contentseditable DIVs. So we set the selection explicitly | 1876 // contentseditable DIVs. So we set the selection explicitly |
| 1886 // instead. Note that this has the side effect of moving the | 1877 // instead. Note that this has the side effect of moving the |
| 1887 // caret back to the beginning of the text. | 1878 // caret back to the beginning of the text. |
| 1888 Position position(element, 0, Position::PositionIsOffsetInAn
chor); | 1879 Position position(element, 0, Position::PositionIsOffsetInAn
chor); |
| 1889 localFrame->selection().setSelection(VisibleSelection(positi
on, SEL_DEFAULT_AFFINITY)); | 1880 focusedFrame->selection().setSelection(VisibleSelection(posi
tion, SEL_DEFAULT_AFFINITY)); |
| 1890 } | 1881 } |
| 1891 } | 1882 } |
| 1892 } | 1883 } |
| 1893 m_imeAcceptEvents = true; | 1884 m_imeAcceptEvents = true; |
| 1894 } else { | 1885 } else { |
| 1895 hidePopups(); | 1886 hidePopups(); |
| 1896 | 1887 |
| 1897 // Clear focus on the currently focused frame if any. | 1888 // Clear focus on the currently focused frame if any. |
| 1898 if (!m_page) | 1889 if (!m_page) |
| 1899 return; | 1890 return; |
| 1900 | 1891 |
| 1901 LocalFrame* frame = m_page->mainFrame(); | 1892 LocalFrame* frame = m_page->mainFrame(); |
| 1902 if (!frame) | 1893 if (!frame) |
| 1903 return; | 1894 return; |
| 1904 | 1895 |
| 1905 RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame(); | 1896 RefPtr<LocalFrame> focusedFrame = m_page->focusController().focusedFrame
(); |
| 1906 if (focusedFrame && focusedFrame->isLocalFrame()) { | 1897 if (focusedFrame) { |
| 1907 // Finish an ongoing composition to delete the composition node. | 1898 // Finish an ongoing composition to delete the composition node. |
| 1908 if (toLocalFrame(focusedFrame.get())->inputMethodController().hasCom
position()) { | 1899 if (focusedFrame->inputMethodController().hasComposition()) { |
| 1909 if (m_autofillClient) | 1900 if (m_autofillClient) |
| 1910 m_autofillClient->setIgnoreTextChanges(true); | 1901 m_autofillClient->setIgnoreTextChanges(true); |
| 1911 | 1902 |
| 1912 toLocalFrame(focusedFrame.get())->inputMethodController().confir
mComposition(); | 1903 focusedFrame->inputMethodController().confirmComposition(); |
| 1913 | 1904 |
| 1914 if (m_autofillClient) | 1905 if (m_autofillClient) |
| 1915 m_autofillClient->setIgnoreTextChanges(false); | 1906 m_autofillClient->setIgnoreTextChanges(false); |
| 1916 } | 1907 } |
| 1917 m_imeAcceptEvents = false; | 1908 m_imeAcceptEvents = false; |
| 1918 } | 1909 } |
| 1919 } | 1910 } |
| 1920 } | 1911 } |
| 1921 | 1912 |
| 1922 bool WebViewImpl::setComposition( | 1913 bool WebViewImpl::setComposition( |
| 1923 const WebString& text, | 1914 const WebString& text, |
| 1924 const WebVector<WebCompositionUnderline>& underlines, | 1915 const WebVector<WebCompositionUnderline>& underlines, |
| 1925 int selectionStart, | 1916 int selectionStart, |
| 1926 int selectionEnd) | 1917 int selectionEnd) |
| 1927 { | 1918 { |
| 1928 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); | 1919 LocalFrame* focused = focusedWebCoreFrame(); |
| 1929 if (!focused || !m_imeAcceptEvents) | 1920 if (!focused || !m_imeAcceptEvents) |
| 1930 return false; | 1921 return false; |
| 1931 | 1922 |
| 1932 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) | 1923 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) |
| 1933 return plugin->setComposition(text, underlines, selectionStart, selectio
nEnd); | 1924 return plugin->setComposition(text, underlines, selectionStart, selectio
nEnd); |
| 1934 | 1925 |
| 1935 // The input focus has been moved to another WebWidget object. | 1926 // The input focus has been moved to another WebWidget object. |
| 1936 // We should use this |editor| object only to complete the ongoing | 1927 // We should use this |editor| object only to complete the ongoing |
| 1937 // composition. | 1928 // composition. |
| 1938 InputMethodController& inputMethodController = focused->inputMethodControlle
r(); | 1929 InputMethodController& inputMethodController = focused->inputMethodControlle
r(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1984 return confirmComposition(WebString(), selectionBehavior); | 1975 return confirmComposition(WebString(), selectionBehavior); |
| 1985 } | 1976 } |
| 1986 | 1977 |
| 1987 bool WebViewImpl::confirmComposition(const WebString& text) | 1978 bool WebViewImpl::confirmComposition(const WebString& text) |
| 1988 { | 1979 { |
| 1989 return confirmComposition(text, DoNotKeepSelection); | 1980 return confirmComposition(text, DoNotKeepSelection); |
| 1990 } | 1981 } |
| 1991 | 1982 |
| 1992 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe
havior selectionBehavior) | 1983 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe
havior selectionBehavior) |
| 1993 { | 1984 { |
| 1994 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); | 1985 LocalFrame* focused = focusedWebCoreFrame(); |
| 1995 if (!focused || !m_imeAcceptEvents) | 1986 if (!focused || !m_imeAcceptEvents) |
| 1996 return false; | 1987 return false; |
| 1997 | 1988 |
| 1998 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) | 1989 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) |
| 1999 return plugin->confirmComposition(text, selectionBehavior); | 1990 return plugin->confirmComposition(text, selectionBehavior); |
| 2000 | 1991 |
| 2001 return focused->inputMethodController().confirmCompositionOrInsertText(text,
selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp
utMethodController::DoNotKeepSelection); | 1992 return focused->inputMethodController().confirmCompositionOrInsertText(text,
selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp
utMethodController::DoNotKeepSelection); |
| 2002 } | 1993 } |
| 2003 | 1994 |
| 2004 bool WebViewImpl::compositionRange(size_t* location, size_t* length) | 1995 bool WebViewImpl::compositionRange(size_t* location, size_t* length) |
| 2005 { | 1996 { |
| 2006 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); | 1997 LocalFrame* focused = focusedWebCoreFrame(); |
| 2007 if (!focused || !m_imeAcceptEvents) | 1998 if (!focused || !m_imeAcceptEvents) |
| 2008 return false; | 1999 return false; |
| 2009 | 2000 |
| 2010 RefPtr<Range> range = focused->inputMethodController().compositionRange(); | 2001 RefPtr<Range> range = focused->inputMethodController().compositionRange(); |
| 2011 if (!range) | 2002 if (!range) |
| 2012 return false; | 2003 return false; |
| 2013 | 2004 |
| 2014 Element* editable = focused->selection().rootEditableElementOrDocumentElemen
t(); | 2005 Element* editable = focused->selection().rootEditableElementOrDocumentElemen
t(); |
| 2015 ASSERT(editable); | 2006 ASSERT(editable); |
| 2016 PlainTextRange plainTextRange(PlainTextRange::create(*editable, *range.get()
)); | 2007 PlainTextRange plainTextRange(PlainTextRange::create(*editable, *range.get()
)); |
| 2017 if (plainTextRange.isNull()) | 2008 if (plainTextRange.isNull()) |
| 2018 return false; | 2009 return false; |
| 2019 *location = plainTextRange.start(); | 2010 *location = plainTextRange.start(); |
| 2020 *length = plainTextRange.length(); | 2011 *length = plainTextRange.length(); |
| 2021 return true; | 2012 return true; |
| 2022 } | 2013 } |
| 2023 | 2014 |
| 2024 WebTextInputInfo WebViewImpl::textInputInfo() | 2015 WebTextInputInfo WebViewImpl::textInputInfo() |
| 2025 { | 2016 { |
| 2026 WebTextInputInfo info; | 2017 WebTextInputInfo info; |
| 2027 | 2018 |
| 2028 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); | 2019 LocalFrame* focused = focusedWebCoreFrame(); |
| 2029 if (!focused) | 2020 if (!focused) |
| 2030 return info; | 2021 return info; |
| 2031 | 2022 |
| 2032 FrameSelection& selection = focused->selection(); | 2023 FrameSelection& selection = focused->selection(); |
| 2033 Node* node = selection.selection().rootEditableElement(); | 2024 Node* node = selection.selection().rootEditableElement(); |
| 2034 if (!node) | 2025 if (!node) |
| 2035 return info; | 2026 return info; |
| 2036 | 2027 |
| 2037 info.inputMode = inputModeOfFocusedElement(); | 2028 info.inputMode = inputModeOfFocusedElement(); |
| 2038 | 2029 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2144 if (isHTMLTextAreaElement(*element)) { | 2135 if (isHTMLTextAreaElement(*element)) { |
| 2145 const HTMLTextAreaElement& textarea = toHTMLTextAreaElement(*element); | 2136 const HTMLTextAreaElement& textarea = toHTMLTextAreaElement(*element); |
| 2146 return textarea.fastGetAttribute(HTMLNames::inputmodeAttr).lower(); | 2137 return textarea.fastGetAttribute(HTMLNames::inputmodeAttr).lower(); |
| 2147 } | 2138 } |
| 2148 | 2139 |
| 2149 return WebString(); | 2140 return WebString(); |
| 2150 } | 2141 } |
| 2151 | 2142 |
| 2152 bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const | 2143 bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const |
| 2153 { | 2144 { |
| 2154 const LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); | 2145 const LocalFrame* frame = focusedWebCoreFrame(); |
| 2155 if (!frame) | 2146 if (!frame) |
| 2156 return false; | 2147 return false; |
| 2157 FrameSelection& selection = frame->selection(); | 2148 FrameSelection& selection = frame->selection(); |
| 2158 | 2149 |
| 2159 if (selection.isCaret()) { | 2150 if (selection.isCaret()) { |
| 2160 anchor = focus = selection.absoluteCaretBounds(); | 2151 anchor = focus = selection.absoluteCaretBounds(); |
| 2161 } else { | 2152 } else { |
| 2162 RefPtr<Range> selectedRange = selection.toNormalizedRange(); | 2153 RefPtr<Range> selectedRange = selection.toNormalizedRange(); |
| 2163 if (!selectedRange) | 2154 if (!selectedRange) |
| 2164 return false; | 2155 return false; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2188 if (!selection.selection().isBaseFirst()) | 2179 if (!selection.selection().isBaseFirst()) |
| 2189 std::swap(anchor, focus); | 2180 std::swap(anchor, focus); |
| 2190 return true; | 2181 return true; |
| 2191 } | 2182 } |
| 2192 | 2183 |
| 2193 InputMethodContext* WebViewImpl::inputMethodContext() | 2184 InputMethodContext* WebViewImpl::inputMethodContext() |
| 2194 { | 2185 { |
| 2195 if (!m_imeAcceptEvents) | 2186 if (!m_imeAcceptEvents) |
| 2196 return 0; | 2187 return 0; |
| 2197 | 2188 |
| 2198 LocalFrame* focusedFrame = toLocalFrame(focusedWebCoreFrame()); | 2189 LocalFrame* focusedFrame = focusedWebCoreFrame(); |
| 2199 if (!focusedFrame) | 2190 if (!focusedFrame) |
| 2200 return 0; | 2191 return 0; |
| 2201 | 2192 |
| 2202 Element* target = focusedFrame->document()->focusedElement(); | 2193 Element* target = focusedFrame->document()->focusedElement(); |
| 2203 if (target && target->hasInputMethodContext()) | 2194 if (target && target->hasInputMethodContext()) |
| 2204 return &target->inputMethodContext(); | 2195 return &target->inputMethodContext(); |
| 2205 | 2196 |
| 2206 return 0; | 2197 return 0; |
| 2207 } | 2198 } |
| 2208 | 2199 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2227 } | 2218 } |
| 2228 | 2219 |
| 2229 void WebViewImpl::didHideCandidateWindow() | 2220 void WebViewImpl::didHideCandidateWindow() |
| 2230 { | 2221 { |
| 2231 if (InputMethodContext* context = inputMethodContext()) | 2222 if (InputMethodContext* context = inputMethodContext()) |
| 2232 context->dispatchCandidateWindowHideEvent(); | 2223 context->dispatchCandidateWindowHideEvent(); |
| 2233 } | 2224 } |
| 2234 | 2225 |
| 2235 bool WebViewImpl::selectionTextDirection(WebTextDirection& start, WebTextDirecti
on& end) const | 2226 bool WebViewImpl::selectionTextDirection(WebTextDirection& start, WebTextDirecti
on& end) const |
| 2236 { | 2227 { |
| 2237 const LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); | 2228 const LocalFrame* frame = focusedWebCoreFrame(); |
| 2238 if (!frame) | 2229 if (!frame) |
| 2239 return false; | 2230 return false; |
| 2240 FrameSelection& selection = frame->selection(); | 2231 FrameSelection& selection = frame->selection(); |
| 2241 if (!selection.toNormalizedRange()) | 2232 if (!selection.toNormalizedRange()) |
| 2242 return false; | 2233 return false; |
| 2243 start = selection.start().primaryDirection() == RTL ? WebTextDirectionRightT
oLeft : WebTextDirectionLeftToRight; | 2234 start = selection.start().primaryDirection() == RTL ? WebTextDirectionRightT
oLeft : WebTextDirectionLeftToRight; |
| 2244 end = selection.end().primaryDirection() == RTL ? WebTextDirectionRightToLef
t : WebTextDirectionLeftToRight; | 2235 end = selection.end().primaryDirection() == RTL ? WebTextDirectionRightToLef
t : WebTextDirectionLeftToRight; |
| 2245 return true; | 2236 return true; |
| 2246 } | 2237 } |
| 2247 | 2238 |
| 2248 bool WebViewImpl::isSelectionAnchorFirst() const | 2239 bool WebViewImpl::isSelectionAnchorFirst() const |
| 2249 { | 2240 { |
| 2250 if (const LocalFrame* frame = toLocalFrame(focusedWebCoreFrame())) | 2241 if (const LocalFrame* frame = focusedWebCoreFrame()) |
| 2251 return frame->selection().selection().isBaseFirst(); | 2242 return frame->selection().selection().isBaseFirst(); |
| 2252 return false; | 2243 return false; |
| 2253 } | 2244 } |
| 2254 | 2245 |
| 2255 WebVector<WebCompositionUnderline> WebViewImpl::compositionUnderlines() const | 2246 WebVector<WebCompositionUnderline> WebViewImpl::compositionUnderlines() const |
| 2256 { | 2247 { |
| 2257 const LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); | 2248 const LocalFrame* focused = focusedWebCoreFrame(); |
| 2258 if (!focused) | 2249 if (!focused) |
| 2259 return WebVector<WebCompositionUnderline>(); | 2250 return WebVector<WebCompositionUnderline>(); |
| 2260 const Vector<CompositionUnderline>& underlines = focused->inputMethodControl
ler().customCompositionUnderlines(); | 2251 const Vector<CompositionUnderline>& underlines = focused->inputMethodControl
ler().customCompositionUnderlines(); |
| 2261 WebVector<WebCompositionUnderline> results(underlines.size()); | 2252 WebVector<WebCompositionUnderline> results(underlines.size()); |
| 2262 for (size_t index = 0; index < underlines.size(); ++index) { | 2253 for (size_t index = 0; index < underlines.size(); ++index) { |
| 2263 CompositionUnderline underline = underlines[index]; | 2254 CompositionUnderline underline = underlines[index]; |
| 2264 results[index] = WebCompositionUnderline(underline.startOffset, underlin
e.endOffset, static_cast<WebColor>(underline.color.rgb()), underline.thick); | 2255 results[index] = WebCompositionUnderline(underline.startOffset, underlin
e.endOffset, static_cast<WebColor>(underline.color.rgb()), underline.thick); |
| 2265 } | 2256 } |
| 2266 return results; | 2257 return results; |
| 2267 } | 2258 } |
| 2268 | 2259 |
| 2269 WebColor WebViewImpl::backgroundColor() const | 2260 WebColor WebViewImpl::backgroundColor() const |
| 2270 { | 2261 { |
| 2271 if (isTransparent()) | 2262 if (isTransparent()) |
| 2272 return Color::transparent; | 2263 return Color::transparent; |
| 2273 if (!m_page) | 2264 if (!m_page) |
| 2274 return m_baseBackgroundColor; | 2265 return m_baseBackgroundColor; |
| 2275 if (!m_page->mainFrame()) | 2266 if (!m_page->mainFrame()) |
| 2276 return m_baseBackgroundColor; | 2267 return m_baseBackgroundColor; |
| 2277 FrameView* view = m_page->mainFrame()->view(); | 2268 FrameView* view = m_page->mainFrame()->view(); |
| 2278 return view->documentBackgroundColor().rgb(); | 2269 return view->documentBackgroundColor().rgb(); |
| 2279 } | 2270 } |
| 2280 | 2271 |
| 2281 bool WebViewImpl::caretOrSelectionRange(size_t* location, size_t* length) | 2272 bool WebViewImpl::caretOrSelectionRange(size_t* location, size_t* length) |
| 2282 { | 2273 { |
| 2283 const LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); | 2274 const LocalFrame* focused = focusedWebCoreFrame(); |
| 2284 if (!focused) | 2275 if (!focused) |
| 2285 return false; | 2276 return false; |
| 2286 | 2277 |
| 2287 PlainTextRange selectionOffsets = focused->inputMethodController().getSelect
ionOffsets(); | 2278 PlainTextRange selectionOffsets = focused->inputMethodController().getSelect
ionOffsets(); |
| 2288 if (selectionOffsets.isNull()) | 2279 if (selectionOffsets.isNull()) |
| 2289 return false; | 2280 return false; |
| 2290 | 2281 |
| 2291 *location = selectionOffsets.start(); | 2282 *location = selectionOffsets.start(); |
| 2292 *length = selectionOffsets.length(); | 2283 *length = selectionOffsets.length(); |
| 2293 return true; | 2284 return true; |
| 2294 } | 2285 } |
| 2295 | 2286 |
| 2296 void WebViewImpl::setTextDirection(WebTextDirection direction) | 2287 void WebViewImpl::setTextDirection(WebTextDirection direction) |
| 2297 { | 2288 { |
| 2298 // The Editor::setBaseWritingDirection() function checks if we can change | 2289 // The Editor::setBaseWritingDirection() function checks if we can change |
| 2299 // the text direction of the selected node and updates its DOM "dir" | 2290 // the text direction of the selected node and updates its DOM "dir" |
| 2300 // attribute and its CSS "direction" property. | 2291 // attribute and its CSS "direction" property. |
| 2301 // So, we just call the function as Safari does. | 2292 // So, we just call the function as Safari does. |
| 2302 const LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); | 2293 const LocalFrame* focused = focusedWebCoreFrame(); |
| 2303 if (!focused) | 2294 if (!focused) |
| 2304 return; | 2295 return; |
| 2305 | 2296 |
| 2306 Editor& editor = focused->editor(); | 2297 Editor& editor = focused->editor(); |
| 2307 if (!editor.canEdit()) | 2298 if (!editor.canEdit()) |
| 2308 return; | 2299 return; |
| 2309 | 2300 |
| 2310 switch (direction) { | 2301 switch (direction) { |
| 2311 case WebTextDirectionDefault: | 2302 case WebTextDirectionDefault: |
| 2312 editor.setBaseWritingDirection(NaturalWritingDirection); | 2303 editor.setBaseWritingDirection(NaturalWritingDirection); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2426 { | 2417 { |
| 2427 if (!relativeToFrame) | 2418 if (!relativeToFrame) |
| 2428 relativeToFrame = mainFrame(); | 2419 relativeToFrame = mainFrame(); |
| 2429 LocalFrame* frame = toWebFrameImpl(relativeToFrame)->frame(); | 2420 LocalFrame* frame = toWebFrameImpl(relativeToFrame)->frame(); |
| 2430 frame = frame->tree().find(name); | 2421 frame = frame->tree().find(name); |
| 2431 return WebFrameImpl::fromFrame(frame); | 2422 return WebFrameImpl::fromFrame(frame); |
| 2432 } | 2423 } |
| 2433 | 2424 |
| 2434 WebFrame* WebViewImpl::focusedFrame() | 2425 WebFrame* WebViewImpl::focusedFrame() |
| 2435 { | 2426 { |
| 2436 return WebFrameImpl::fromFrame(toLocalFrame(focusedWebCoreFrame())); | 2427 return WebFrameImpl::fromFrame(focusedWebCoreFrame()); |
| 2437 } | 2428 } |
| 2438 | 2429 |
| 2439 void WebViewImpl::setFocusedFrame(WebFrame* frame) | 2430 void WebViewImpl::setFocusedFrame(WebFrame* frame) |
| 2440 { | 2431 { |
| 2441 if (!frame) { | 2432 if (!frame) { |
| 2442 // Clears the focused frame if any. | 2433 // Clears the focused frame if any. |
| 2443 Frame* focusedFrame = focusedWebCoreFrame(); | 2434 if (LocalFrame* focusedFrame = focusedWebCoreFrame()) |
| 2444 if (focusedFrame && focusedFrame->isLocalFrame()) | 2435 focusedFrame->selection().setFocused(false); |
| 2445 toLocalFrame(focusedFrame)->selection().setFocused(false); | |
| 2446 return; | 2436 return; |
| 2447 } | 2437 } |
| 2448 LocalFrame* webcoreFrame = toWebFrameImpl(frame)->frame(); | 2438 LocalFrame* webcoreFrame = toWebFrameImpl(frame)->frame(); |
| 2449 webcoreFrame->page()->focusController().setFocusedFrame(webcoreFrame); | 2439 webcoreFrame->page()->focusController().setFocusedFrame(webcoreFrame); |
| 2450 } | 2440 } |
| 2451 | 2441 |
| 2452 void WebViewImpl::setInitialFocus(bool reverse) | 2442 void WebViewImpl::setInitialFocus(bool reverse) |
| 2453 { | 2443 { |
| 2454 if (!m_page) | 2444 if (!m_page) |
| 2455 return; | 2445 return; |
| 2456 Frame* frame = page()->focusController().focusedOrMainFrame(); | 2446 LocalFrame* frame = page()->focusController().focusedOrMainFrame(); |
| 2457 if (frame->isLocalFrame()) { | 2447 if (Document* document = frame->document()) |
| 2458 if (Document* document = toLocalFrame(frame)->document()) | 2448 document->setFocusedElement(nullptr); |
| 2459 document->setFocusedElement(nullptr); | |
| 2460 } | |
| 2461 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu
sTypeForward); | 2449 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu
sTypeForward); |
| 2462 } | 2450 } |
| 2463 | 2451 |
| 2464 void WebViewImpl::clearFocusedElement() | 2452 void WebViewImpl::clearFocusedElement() |
| 2465 { | 2453 { |
| 2466 RefPtr<Frame> frame = focusedWebCoreFrame(); | 2454 RefPtr<LocalFrame> frame = focusedWebCoreFrame(); |
| 2467 if (!frame || !frame->isLocalFrame()) | 2455 if (!frame) |
| 2468 return; | 2456 return; |
| 2469 | 2457 |
| 2470 LocalFrame* localFrame = toLocalFrame(frame.get()); | 2458 RefPtr<Document> document = frame->document(); |
| 2471 | |
| 2472 RefPtr<Document> document = localFrame->document(); | |
| 2473 if (!document) | 2459 if (!document) |
| 2474 return; | 2460 return; |
| 2475 | 2461 |
| 2476 RefPtr<Element> oldFocusedElement = document->focusedElement(); | 2462 RefPtr<Element> oldFocusedElement = document->focusedElement(); |
| 2477 | 2463 |
| 2478 // Clear the focused node. | 2464 // Clear the focused node. |
| 2479 document->setFocusedElement(nullptr); | 2465 document->setFocusedElement(nullptr); |
| 2480 | 2466 |
| 2481 if (!oldFocusedElement) | 2467 if (!oldFocusedElement) |
| 2482 return; | 2468 return; |
| 2483 | 2469 |
| 2484 // If a text field has focus, we need to make sure the selection controller | 2470 // If a text field has focus, we need to make sure the selection controller |
| 2485 // knows to remove selection from it. Otherwise, the text field is still | 2471 // knows to remove selection from it. Otherwise, the text field is still |
| 2486 // processing keyboard events even though focus has been moved to the page a
nd | 2472 // processing keyboard events even though focus has been moved to the page a
nd |
| 2487 // keystrokes get eaten as a result. | 2473 // keystrokes get eaten as a result. |
| 2488 if (oldFocusedElement->isContentEditable() || oldFocusedElement->isTextFormC
ontrol()) | 2474 if (oldFocusedElement->isContentEditable() || oldFocusedElement->isTextFormC
ontrol()) |
| 2489 localFrame->selection().clear(); | 2475 frame->selection().clear(); |
| 2490 } | 2476 } |
| 2491 | 2477 |
| 2492 void WebViewImpl::scrollFocusedNodeIntoView() | 2478 void WebViewImpl::scrollFocusedNodeIntoView() |
| 2493 { | 2479 { |
| 2494 if (Element* element = focusedElement()) | 2480 if (Element* element = focusedElement()) |
| 2495 element->scrollIntoViewIfNeeded(true); | 2481 element->scrollIntoViewIfNeeded(true); |
| 2496 } | 2482 } |
| 2497 | 2483 |
| 2498 void WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rect) | 2484 void WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rect) |
| 2499 { | 2485 { |
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3315 m_page->contextMenuController().clearContextMenu(); | 3301 m_page->contextMenuController().clearContextMenu(); |
| 3316 } | 3302 } |
| 3317 | 3303 |
| 3318 void WebViewImpl::showContextMenu() | 3304 void WebViewImpl::showContextMenu() |
| 3319 { | 3305 { |
| 3320 if (!page()) | 3306 if (!page()) |
| 3321 return; | 3307 return; |
| 3322 | 3308 |
| 3323 page()->contextMenuController().clearContextMenu(); | 3309 page()->contextMenuController().clearContextMenu(); |
| 3324 m_contextMenuAllowed = true; | 3310 m_contextMenuAllowed = true; |
| 3325 if (LocalFrame* focusedFrame = toLocalFrame(page()->focusController().focuse
dOrMainFrame())) | 3311 if (LocalFrame* focusedFrame = page()->focusController().focusedOrMainFrame(
)) |
| 3326 focusedFrame->eventHandler().sendContextMenuEventForKey(); | 3312 focusedFrame->eventHandler().sendContextMenuEventForKey(); |
| 3327 m_contextMenuAllowed = false; | 3313 m_contextMenuAllowed = false; |
| 3328 } | 3314 } |
| 3329 | 3315 |
| 3330 WebString WebViewImpl::getSmartClipData(WebRect rect) | 3316 WebString WebViewImpl::getSmartClipData(WebRect rect) |
| 3331 { | 3317 { |
| 3332 LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); | 3318 LocalFrame* frame = focusedWebCoreFrame(); |
| 3333 if (!frame) | 3319 if (!frame) |
| 3334 return WebString(); | 3320 return WebString(); |
| 3335 return WebCore::SmartClip(frame).dataForRect(rect).toString(); | 3321 return WebCore::SmartClip(frame).dataForRect(rect).toString(); |
| 3336 } | 3322 } |
| 3337 | 3323 |
| 3338 void WebViewImpl::hidePopups() | 3324 void WebViewImpl::hidePopups() |
| 3339 { | 3325 { |
| 3340 hideSelectPopup(); | 3326 hideSelectPopup(); |
| 3341 if (m_pagePopup) | 3327 if (m_pagePopup) |
| 3342 closePagePopup(m_pagePopup.get()); | 3328 closePagePopup(m_pagePopup.get()); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3555 | 3541 |
| 3556 NotificationPresenterImpl* WebViewImpl::notificationPresenterImpl() | 3542 NotificationPresenterImpl* WebViewImpl::notificationPresenterImpl() |
| 3557 { | 3543 { |
| 3558 if (!m_notificationPresenter.isInitialized() && m_client) | 3544 if (!m_notificationPresenter.isInitialized() && m_client) |
| 3559 m_notificationPresenter.initialize(m_client->notificationPresenter()); | 3545 m_notificationPresenter.initialize(m_client->notificationPresenter()); |
| 3560 return &m_notificationPresenter; | 3546 return &m_notificationPresenter; |
| 3561 } | 3547 } |
| 3562 | 3548 |
| 3563 Element* WebViewImpl::focusedElement() const | 3549 Element* WebViewImpl::focusedElement() const |
| 3564 { | 3550 { |
| 3565 Frame* frame = m_page->focusController().focusedFrame(); | 3551 LocalFrame* frame = m_page->focusController().focusedFrame(); |
| 3566 if (!frame || !frame->isLocalFrame()) | 3552 if (!frame) |
| 3567 return 0; | 3553 return 0; |
| 3568 | 3554 |
| 3569 Document* document = toLocalFrame(frame)->document(); | 3555 Document* document = frame->document(); |
| 3570 if (!document) | 3556 if (!document) |
| 3571 return 0; | 3557 return 0; |
| 3572 | 3558 |
| 3573 return document->focusedElement(); | 3559 return document->focusedElement(); |
| 3574 } | 3560 } |
| 3575 | 3561 |
| 3576 HitTestResult WebViewImpl::hitTestResultForWindowPos(const IntPoint& pos) | 3562 HitTestResult WebViewImpl::hitTestResultForWindowPos(const IntPoint& pos) |
| 3577 { | 3563 { |
| 3578 IntPoint docPoint(m_page->mainFrame()->view()->windowToContents(pos)); | 3564 IntPoint docPoint(m_page->mainFrame()->view()->windowToContents(pos)); |
| 3579 return m_page->mainFrame()->eventHandler().hitTestResultAtPoint(docPoint, Hi
tTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ConfusingAndOf
tenMisusedDisallowShadowContent); | 3565 return m_page->mainFrame()->eventHandler().hitTestResultAtPoint(docPoint, Hi
tTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ConfusingAndOf
tenMisusedDisallowShadowContent); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3980 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); | 3966 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); |
| 3981 | 3967 |
| 3982 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 3968 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
| 3983 return false; | 3969 return false; |
| 3984 | 3970 |
| 3985 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 3971 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
| 3986 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 3972 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
| 3987 } | 3973 } |
| 3988 | 3974 |
| 3989 } // namespace blink | 3975 } // namespace blink |
| OLD | NEW |