Chromium Code Reviews| 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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 { | 511 { |
| 512 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 512 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
| 513 return; | 513 return; |
| 514 | 514 |
| 515 m_page->contextMenuController().clearContextMenu(); | 515 m_page->contextMenuController().clearContextMenu(); |
| 516 | 516 |
| 517 PlatformMouseEventBuilder pme(mainFrameImpl()->frameView(), event); | 517 PlatformMouseEventBuilder pme(mainFrameImpl()->frameView(), event); |
| 518 | 518 |
| 519 // Find the right target frame. See issue 1186900. | 519 // Find the right target frame. See issue 1186900. |
| 520 HitTestResult result = hitTestResultForWindowPos(pme.position()); | 520 HitTestResult result = hitTestResultForWindowPos(pme.position()); |
| 521 LocalFrame* targetFrame; | 521 Frame* targetFrame; |
| 522 if (result.innerNonSharedNode()) | 522 if (result.innerNonSharedNode()) |
| 523 targetFrame = result.innerNonSharedNode()->document().frame(); | 523 targetFrame = result.innerNonSharedNode()->document().frame(); |
| 524 else | 524 else |
| 525 targetFrame = m_page->focusController().focusedOrMainFrame(); | 525 targetFrame = m_page->focusController().focusedOrMainFrame(); |
| 526 | 526 |
| 527 if (!targetFrame->isLocalFrame()) | |
| 528 return; | |
| 529 | |
| 530 LocalFrame* targetLocalFrame = toLocalFrame(targetFrame); | |
| 531 | |
| 527 #if OS(WIN) | 532 #if OS(WIN) |
| 528 targetFrame->view()->setCursor(pointerCursor()); | 533 targetLocalFrame->view()->setCursor(pointerCursor()); |
| 529 #endif | 534 #endif |
| 530 | 535 |
| 531 m_contextMenuAllowed = true; | 536 m_contextMenuAllowed = true; |
| 532 targetFrame->eventHandler().sendContextMenuEvent(pme); | 537 targetLocalFrame->eventHandler().sendContextMenuEvent(pme); |
| 533 m_contextMenuAllowed = false; | 538 m_contextMenuAllowed = false; |
| 534 // Actually showing the context menu is handled by the ContextMenuClient | 539 // Actually showing the context menu is handled by the ContextMenuClient |
| 535 // implementation... | 540 // implementation... |
| 536 } | 541 } |
| 537 | 542 |
| 538 void WebViewImpl::handleMouseUp(LocalFrame& mainFrame, const WebMouseEvent& even t) | 543 void WebViewImpl::handleMouseUp(LocalFrame& mainFrame, const WebMouseEvent& even t) |
| 539 { | 544 { |
| 540 PageWidgetEventHandler::handleMouseUp(mainFrame, event); | 545 PageWidgetEventHandler::handleMouseUp(mainFrame, event); |
| 541 | 546 |
| 542 #if OS(WIN) | 547 #if OS(WIN) |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 863 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) ); | 868 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) ); |
| 864 if (m_pagePopup) { | 869 if (m_pagePopup) { |
| 865 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); | 870 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); |
| 866 // We need to ignore the next Char event after this otherwise pressing | 871 // We need to ignore the next Char event after this otherwise pressing |
| 867 // enter when selecting an item in the popup will go to the page. | 872 // enter when selecting an item in the popup will go to the page. |
| 868 if (WebInputEvent::RawKeyDown == event.type) | 873 if (WebInputEvent::RawKeyDown == event.type) |
| 869 m_suppressNextKeypressEvent = true; | 874 m_suppressNextKeypressEvent = true; |
| 870 return true; | 875 return true; |
| 871 } | 876 } |
| 872 | 877 |
| 873 RefPtr<LocalFrame> frame = focusedWebCoreFrame(); | 878 // TODO(kenrb): Handle the remote frame case. Possibly move eventHandler() t o Frame? |
| 879 RefPtr<LocalFrame> frame = toLocalFrame(focusedWebCoreFrame()); | |
| 874 if (!frame) | 880 if (!frame) |
| 875 return false; | 881 return false; |
| 876 | 882 |
| 877 #if !OS(MACOSX) | 883 #if !OS(MACOSX) |
| 878 const WebInputEvent::Type contextMenuTriggeringEventType = | 884 const WebInputEvent::Type contextMenuTriggeringEventType = |
| 879 #if OS(WIN) | 885 #if OS(WIN) |
| 880 WebInputEvent::KeyUp; | 886 WebInputEvent::KeyUp; |
| 881 #else | 887 #else |
| 882 WebInputEvent::RawKeyDown; | 888 WebInputEvent::RawKeyDown; |
| 883 #endif | 889 #endif |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 918 bool suppress = m_suppressNextKeypressEvent; | 924 bool suppress = m_suppressNextKeypressEvent; |
| 919 m_suppressNextKeypressEvent = false; | 925 m_suppressNextKeypressEvent = false; |
| 920 | 926 |
| 921 // If there is a select popup, it should be the one processing the event, | 927 // If there is a select popup, it should be the one processing the event, |
| 922 // not the page. | 928 // not the page. |
| 923 if (m_selectPopup) | 929 if (m_selectPopup) |
| 924 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) ); | 930 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) ); |
| 925 if (m_pagePopup) | 931 if (m_pagePopup) |
| 926 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); | 932 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); |
| 927 | 933 |
| 928 LocalFrame* frame = focusedWebCoreFrame(); | 934 LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); |
| 929 if (!frame) | 935 if (!frame) |
| 930 return suppress; | 936 return suppress; |
| 931 | 937 |
| 932 EventHandler& handler = frame->eventHandler(); | 938 EventHandler& handler = frame->eventHandler(); |
| 933 | 939 |
| 934 PlatformKeyboardEventBuilder evt(event); | 940 PlatformKeyboardEventBuilder evt(event); |
| 935 if (!evt.isCharacterKey()) | 941 if (!evt.isCharacterKey()) |
| 936 return true; | 942 return true; |
| 937 | 943 |
| 938 // Accesskeys are triggered by char events and can't be suppressed. | 944 // Accesskeys are triggered by char events and can't be suppressed. |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1263 { | 1269 { |
| 1264 // The contextMenuController() holds onto the last context menu that was | 1270 // The contextMenuController() holds onto the last context menu that was |
| 1265 // popped up on the page until a new one is created. We need to clear | 1271 // popped up on the page until a new one is created. We need to clear |
| 1266 // this menu before propagating the event through the DOM so that we can | 1272 // this menu before propagating the event through the DOM so that we can |
| 1267 // detect if we create a new menu for this event, since we won't create | 1273 // detect if we create a new menu for this event, since we won't create |
| 1268 // a new menu if the DOM swallows the event and the defaultEventHandler does | 1274 // a new menu if the DOM swallows the event and the defaultEventHandler does |
| 1269 // not run. | 1275 // not run. |
| 1270 page()->contextMenuController().clearContextMenu(); | 1276 page()->contextMenuController().clearContextMenu(); |
| 1271 | 1277 |
| 1272 m_contextMenuAllowed = true; | 1278 m_contextMenuAllowed = true; |
| 1273 LocalFrame* focusedFrame = page()->focusController().focusedOrMainFrame(); | 1279 Frame* focusedFrame = page()->focusController().focusedOrMainFrame(); |
| 1274 bool handled = focusedFrame->eventHandler().sendContextMenuEventForKey(); | 1280 if (!focusedFrame->isLocalFrame()) |
| 1281 return false; | |
| 1282 bool handled = toLocalFrame(focusedFrame)->eventHandler().sendContextMenuEve ntForKey(); | |
| 1275 m_contextMenuAllowed = false; | 1283 m_contextMenuAllowed = false; |
| 1276 return handled; | 1284 return handled; |
| 1277 } | 1285 } |
| 1278 #endif | 1286 #endif |
| 1279 | 1287 |
| 1280 bool WebViewImpl::keyEventDefault(const WebKeyboardEvent& event) | 1288 bool WebViewImpl::keyEventDefault(const WebKeyboardEvent& event) |
| 1281 { | 1289 { |
| 1282 LocalFrame* frame = focusedWebCoreFrame(); | 1290 LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); |
|
dcheng
2014/03/17 18:17:44
Hmm... is focusedWebCoreFrame() eventually going t
kenrb
2014/03/18 20:01:19
I don't know. There might be reasons to return foc
| |
| 1283 if (!frame) | 1291 if (!frame) |
| 1284 return false; | 1292 return false; |
| 1285 | 1293 |
| 1286 switch (event.type) { | 1294 switch (event.type) { |
| 1287 case WebInputEvent::Char: | 1295 case WebInputEvent::Char: |
| 1288 if (event.windowsKeyCode == VKEY_SPACE) { | 1296 if (event.windowsKeyCode == VKEY_SPACE) { |
| 1289 int keyCode = ((event.modifiers & WebInputEvent::ShiftKey) ? VKEY_PR IOR : VKEY_NEXT); | 1297 int keyCode = ((event.modifiers & WebInputEvent::ShiftKey) ? VKEY_PR IOR : VKEY_NEXT); |
| 1290 return scrollViewWithKeyboard(keyCode, event.modifiers); | 1298 return scrollViewWithKeyboard(keyCode, event.modifiers); |
| 1291 } | 1299 } |
| 1292 break; | 1300 break; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1385 } | 1393 } |
| 1386 | 1394 |
| 1387 void WebViewImpl::hideSelectPopup() | 1395 void WebViewImpl::hideSelectPopup() |
| 1388 { | 1396 { |
| 1389 if (m_selectPopup) | 1397 if (m_selectPopup) |
| 1390 m_selectPopup->hidePopup(); | 1398 m_selectPopup->hidePopup(); |
| 1391 } | 1399 } |
| 1392 | 1400 |
| 1393 bool WebViewImpl::bubblingScroll(ScrollDirection scrollDirection, ScrollGranular ity scrollGranularity) | 1401 bool WebViewImpl::bubblingScroll(ScrollDirection scrollDirection, ScrollGranular ity scrollGranularity) |
| 1394 { | 1402 { |
| 1395 LocalFrame* frame = focusedWebCoreFrame(); | 1403 LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); |
| 1396 if (!frame) | 1404 if (!frame) |
| 1397 return false; | 1405 return false; |
| 1398 | 1406 |
| 1399 return frame->eventHandler().bubblingScroll(scrollDirection, scrollGranulari ty); | 1407 return frame->eventHandler().bubblingScroll(scrollDirection, scrollGranulari ty); |
| 1400 } | 1408 } |
| 1401 | 1409 |
| 1402 void WebViewImpl::popupOpened(PopupContainer* popupContainer) | 1410 void WebViewImpl::popupOpened(PopupContainer* popupContainer) |
| 1403 { | 1411 { |
| 1404 ASSERT(!m_selectPopup); | 1412 ASSERT(!m_selectPopup); |
| 1405 m_selectPopup = popupContainer; | 1413 m_selectPopup = popupContainer; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1438 { | 1446 { |
| 1439 ASSERT(popup); | 1447 ASSERT(popup); |
| 1440 WebPagePopupImpl* popupImpl = toWebPagePopupImpl(popup); | 1448 WebPagePopupImpl* popupImpl = toWebPagePopupImpl(popup); |
| 1441 ASSERT(m_pagePopup.get() == popupImpl); | 1449 ASSERT(m_pagePopup.get() == popupImpl); |
| 1442 if (m_pagePopup.get() != popupImpl) | 1450 if (m_pagePopup.get() != popupImpl) |
| 1443 return; | 1451 return; |
| 1444 m_pagePopup->closePopup(); | 1452 m_pagePopup->closePopup(); |
| 1445 m_pagePopup = nullptr; | 1453 m_pagePopup = nullptr; |
| 1446 } | 1454 } |
| 1447 | 1455 |
| 1448 LocalFrame* WebViewImpl::focusedWebCoreFrame() const | 1456 Frame* WebViewImpl::focusedWebCoreFrame() const |
| 1449 { | 1457 { |
| 1450 return m_page ? m_page->focusController().focusedOrMainFrame() : 0; | 1458 return m_page ? m_page->focusController().focusedOrMainFrame() : 0; |
| 1451 } | 1459 } |
| 1452 | 1460 |
| 1453 WebViewImpl* WebViewImpl::fromPage(Page* page) | 1461 WebViewImpl* WebViewImpl::fromPage(Page* page) |
| 1454 { | 1462 { |
| 1455 if (!page) | 1463 if (!page) |
| 1456 return 0; | 1464 return 0; |
| 1457 return static_cast<WebViewImpl*>(page->chrome().client().webView()); | 1465 return static_cast<WebViewImpl*>(page->chrome().client().webView()); |
| 1458 } | 1466 } |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1818 { | 1826 { |
| 1819 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this); | 1827 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this); |
| 1820 m_mouseCaptureNode = nullptr; | 1828 m_mouseCaptureNode = nullptr; |
| 1821 } | 1829 } |
| 1822 | 1830 |
| 1823 void WebViewImpl::setFocus(bool enable) | 1831 void WebViewImpl::setFocus(bool enable) |
| 1824 { | 1832 { |
| 1825 m_page->focusController().setFocused(enable); | 1833 m_page->focusController().setFocused(enable); |
| 1826 if (enable) { | 1834 if (enable) { |
| 1827 m_page->focusController().setActive(true); | 1835 m_page->focusController().setActive(true); |
| 1828 RefPtr<LocalFrame> focusedFrame = m_page->focusController().focusedFrame (); | 1836 RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame(); |
| 1829 if (focusedFrame) { | 1837 if (focusedFrame && focusedFrame->isLocalFrame()) { |
| 1830 Element* element = focusedFrame->document()->focusedElement(); | 1838 LocalFrame* localFrame = toLocalFrame(focusedFrame.get()); |
| 1831 if (element && focusedFrame->selection().selection().isNone()) { | 1839 Element* element = localFrame->document()->focusedElement(); |
| 1840 if (element && localFrame->selection().selection().isNone()) { | |
| 1832 // If the selection was cleared while the WebView was not | 1841 // If the selection was cleared while the WebView was not |
| 1833 // focused, then the focus element shows with a focus ring but | 1842 // focused, then the focus element shows with a focus ring but |
| 1834 // no caret and does respond to keyboard inputs. | 1843 // no caret and does respond to keyboard inputs. |
| 1835 if (element->isTextFormControl()) { | 1844 if (element->isTextFormControl()) { |
| 1836 element->updateFocusAppearance(true); | 1845 element->updateFocusAppearance(true); |
| 1837 } else if (element->isContentEditable()) { | 1846 } else if (element->isContentEditable()) { |
| 1838 // updateFocusAppearance() selects all the text of | 1847 // updateFocusAppearance() selects all the text of |
| 1839 // contentseditable DIVs. So we set the selection explicitly | 1848 // contentseditable DIVs. So we set the selection explicitly |
| 1840 // instead. Note that this has the side effect of moving the | 1849 // instead. Note that this has the side effect of moving the |
| 1841 // caret back to the beginning of the text. | 1850 // caret back to the beginning of the text. |
| 1842 Position position(element, 0, Position::PositionIsOffsetInAn chor); | 1851 Position position(element, 0, Position::PositionIsOffsetInAn chor); |
| 1843 focusedFrame->selection().setSelection(VisibleSelection(posi tion, SEL_DEFAULT_AFFINITY)); | 1852 localFrame->selection().setSelection(VisibleSelection(positi on, SEL_DEFAULT_AFFINITY)); |
| 1844 } | 1853 } |
| 1845 } | 1854 } |
| 1846 } | 1855 } |
| 1847 m_imeAcceptEvents = true; | 1856 m_imeAcceptEvents = true; |
| 1848 } else { | 1857 } else { |
| 1849 hidePopups(); | 1858 hidePopups(); |
| 1850 | 1859 |
| 1851 // Clear focus on the currently focused frame if any. | 1860 // Clear focus on the currently focused frame if any. |
| 1852 if (!m_page) | 1861 if (!m_page) |
| 1853 return; | 1862 return; |
| 1854 | 1863 |
| 1855 LocalFrame* frame = m_page->mainFrame(); | 1864 LocalFrame* frame = m_page->mainFrame(); |
| 1856 if (!frame) | 1865 if (!frame) |
| 1857 return; | 1866 return; |
| 1858 | 1867 |
| 1859 RefPtr<LocalFrame> focusedFrame = m_page->focusController().focusedFrame (); | 1868 RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame(); |
| 1860 if (focusedFrame) { | 1869 if (focusedFrame && focusedFrame->isLocalFrame()) { |
| 1861 // Finish an ongoing composition to delete the composition node. | 1870 // Finish an ongoing composition to delete the composition node. |
| 1862 if (focusedFrame->inputMethodController().hasComposition()) { | 1871 if (toLocalFrame(focusedFrame.get())->inputMethodController().hasCom position()) { |
| 1863 if (m_autofillClient) | 1872 if (m_autofillClient) |
| 1864 m_autofillClient->setIgnoreTextChanges(true); | 1873 m_autofillClient->setIgnoreTextChanges(true); |
| 1865 | 1874 |
| 1866 focusedFrame->inputMethodController().confirmComposition(); | 1875 toLocalFrame(focusedFrame.get())->inputMethodController().confir mComposition(); |
| 1867 | 1876 |
| 1868 if (m_autofillClient) | 1877 if (m_autofillClient) |
| 1869 m_autofillClient->setIgnoreTextChanges(false); | 1878 m_autofillClient->setIgnoreTextChanges(false); |
| 1870 } | 1879 } |
| 1871 m_imeAcceptEvents = false; | 1880 m_imeAcceptEvents = false; |
| 1872 } | 1881 } |
| 1873 } | 1882 } |
| 1874 } | 1883 } |
| 1875 | 1884 |
| 1876 bool WebViewImpl::setComposition( | 1885 bool WebViewImpl::setComposition( |
| 1877 const WebString& text, | 1886 const WebString& text, |
| 1878 const WebVector<WebCompositionUnderline>& underlines, | 1887 const WebVector<WebCompositionUnderline>& underlines, |
| 1879 int selectionStart, | 1888 int selectionStart, |
| 1880 int selectionEnd) | 1889 int selectionEnd) |
| 1881 { | 1890 { |
| 1882 LocalFrame* focused = focusedWebCoreFrame(); | 1891 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); |
| 1883 if (!focused || !m_imeAcceptEvents) | 1892 if (!focused || !m_imeAcceptEvents) |
| 1884 return false; | 1893 return false; |
| 1885 | 1894 |
| 1886 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) | 1895 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) |
| 1887 return plugin->setComposition(text, underlines, selectionStart, selectio nEnd); | 1896 return plugin->setComposition(text, underlines, selectionStart, selectio nEnd); |
| 1888 | 1897 |
| 1889 // The input focus has been moved to another WebWidget object. | 1898 // The input focus has been moved to another WebWidget object. |
| 1890 // We should use this |editor| object only to complete the ongoing | 1899 // We should use this |editor| object only to complete the ongoing |
| 1891 // composition. | 1900 // composition. |
| 1892 InputMethodController& inputMethodController = focused->inputMethodControlle r(); | 1901 InputMethodController& inputMethodController = focused->inputMethodControlle r(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1938 return confirmComposition(WebString(), selectionBehavior); | 1947 return confirmComposition(WebString(), selectionBehavior); |
| 1939 } | 1948 } |
| 1940 | 1949 |
| 1941 bool WebViewImpl::confirmComposition(const WebString& text) | 1950 bool WebViewImpl::confirmComposition(const WebString& text) |
| 1942 { | 1951 { |
| 1943 return confirmComposition(text, DoNotKeepSelection); | 1952 return confirmComposition(text, DoNotKeepSelection); |
| 1944 } | 1953 } |
| 1945 | 1954 |
| 1946 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe havior selectionBehavior) | 1955 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe havior selectionBehavior) |
| 1947 { | 1956 { |
| 1948 LocalFrame* focused = focusedWebCoreFrame(); | 1957 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); |
| 1949 if (!focused || !m_imeAcceptEvents) | 1958 if (!focused || !m_imeAcceptEvents) |
| 1950 return false; | 1959 return false; |
| 1951 | 1960 |
| 1952 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) | 1961 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) |
| 1953 return plugin->confirmComposition(text, selectionBehavior); | 1962 return plugin->confirmComposition(text, selectionBehavior); |
| 1954 | 1963 |
| 1955 return focused->inputMethodController().confirmCompositionOrInsertText(text, selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp utMethodController::DoNotKeepSelection); | 1964 return focused->inputMethodController().confirmCompositionOrInsertText(text, selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp utMethodController::DoNotKeepSelection); |
| 1956 } | 1965 } |
| 1957 | 1966 |
| 1958 bool WebViewImpl::compositionRange(size_t* location, size_t* length) | 1967 bool WebViewImpl::compositionRange(size_t* location, size_t* length) |
| 1959 { | 1968 { |
| 1960 LocalFrame* focused = focusedWebCoreFrame(); | 1969 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); |
| 1961 if (!focused || !m_imeAcceptEvents) | 1970 if (!focused || !m_imeAcceptEvents) |
| 1962 return false; | 1971 return false; |
| 1963 | 1972 |
| 1964 RefPtr<Range> range = focused->inputMethodController().compositionRange(); | 1973 RefPtr<Range> range = focused->inputMethodController().compositionRange(); |
| 1965 if (!range) | 1974 if (!range) |
| 1966 return false; | 1975 return false; |
| 1967 | 1976 |
| 1968 Element* editable = focused->selection().rootEditableElementOrDocumentElemen t(); | 1977 Element* editable = focused->selection().rootEditableElementOrDocumentElemen t(); |
| 1969 ASSERT(editable); | 1978 ASSERT(editable); |
| 1970 PlainTextRange plainTextRange(PlainTextRange::create(*editable, *range.get() )); | 1979 PlainTextRange plainTextRange(PlainTextRange::create(*editable, *range.get() )); |
| 1971 if (plainTextRange.isNull()) | 1980 if (plainTextRange.isNull()) |
| 1972 return false; | 1981 return false; |
| 1973 *location = plainTextRange.start(); | 1982 *location = plainTextRange.start(); |
| 1974 *length = plainTextRange.length(); | 1983 *length = plainTextRange.length(); |
| 1975 return true; | 1984 return true; |
| 1976 } | 1985 } |
| 1977 | 1986 |
| 1978 WebTextInputInfo WebViewImpl::textInputInfo() | 1987 WebTextInputInfo WebViewImpl::textInputInfo() |
| 1979 { | 1988 { |
| 1980 WebTextInputInfo info; | 1989 WebTextInputInfo info; |
| 1981 | 1990 |
| 1982 LocalFrame* focused = focusedWebCoreFrame(); | 1991 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); |
| 1983 if (!focused) | 1992 if (!focused) |
| 1984 return info; | 1993 return info; |
| 1985 | 1994 |
| 1986 FrameSelection& selection = focused->selection(); | 1995 FrameSelection& selection = focused->selection(); |
| 1987 Node* node = selection.selection().rootEditableElement(); | 1996 Node* node = selection.selection().rootEditableElement(); |
| 1988 if (!node) | 1997 if (!node) |
| 1989 return info; | 1998 return info; |
| 1990 | 1999 |
| 1991 info.inputMode = inputModeOfFocusedElement(); | 2000 info.inputMode = inputModeOfFocusedElement(); |
| 1992 | 2001 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2098 if (element->hasTagName(HTMLNames::textareaTag)) { | 2107 if (element->hasTagName(HTMLNames::textareaTag)) { |
| 2099 const HTMLTextAreaElement* textarea = toHTMLTextAreaElement(element); | 2108 const HTMLTextAreaElement* textarea = toHTMLTextAreaElement(element); |
| 2100 return textarea->fastGetAttribute(HTMLNames::inputmodeAttr).lower(); | 2109 return textarea->fastGetAttribute(HTMLNames::inputmodeAttr).lower(); |
| 2101 } | 2110 } |
| 2102 | 2111 |
| 2103 return WebString(); | 2112 return WebString(); |
| 2104 } | 2113 } |
| 2105 | 2114 |
| 2106 bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const | 2115 bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const |
| 2107 { | 2116 { |
| 2108 const LocalFrame* frame = focusedWebCoreFrame(); | 2117 const LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); |
| 2109 if (!frame) | 2118 if (!frame) |
| 2110 return false; | 2119 return false; |
| 2111 FrameSelection& selection = frame->selection(); | 2120 FrameSelection& selection = frame->selection(); |
| 2112 | 2121 |
| 2113 if (selection.isCaret()) { | 2122 if (selection.isCaret()) { |
| 2114 anchor = focus = selection.absoluteCaretBounds(); | 2123 anchor = focus = selection.absoluteCaretBounds(); |
| 2115 } else { | 2124 } else { |
| 2116 RefPtr<Range> selectedRange = selection.toNormalizedRange(); | 2125 RefPtr<Range> selectedRange = selection.toNormalizedRange(); |
| 2117 if (!selectedRange) | 2126 if (!selectedRange) |
| 2118 return false; | 2127 return false; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 2142 if (!selection.selection().isBaseFirst()) | 2151 if (!selection.selection().isBaseFirst()) |
| 2143 std::swap(anchor, focus); | 2152 std::swap(anchor, focus); |
| 2144 return true; | 2153 return true; |
| 2145 } | 2154 } |
| 2146 | 2155 |
| 2147 InputMethodContext* WebViewImpl::inputMethodContext() | 2156 InputMethodContext* WebViewImpl::inputMethodContext() |
| 2148 { | 2157 { |
| 2149 if (!m_imeAcceptEvents) | 2158 if (!m_imeAcceptEvents) |
| 2150 return 0; | 2159 return 0; |
| 2151 | 2160 |
| 2152 LocalFrame* focusedFrame = focusedWebCoreFrame(); | 2161 LocalFrame* focusedFrame = toLocalFrame(focusedWebCoreFrame()); |
| 2153 if (!focusedFrame) | 2162 if (!focusedFrame) |
| 2154 return 0; | 2163 return 0; |
| 2155 | 2164 |
| 2156 Element* target = focusedFrame->document()->focusedElement(); | 2165 Element* target = focusedFrame->document()->focusedElement(); |
| 2157 if (target && target->hasInputMethodContext()) | 2166 if (target && target->hasInputMethodContext()) |
| 2158 return &target->inputMethodContext(); | 2167 return &target->inputMethodContext(); |
| 2159 | 2168 |
| 2160 return 0; | 2169 return 0; |
| 2161 } | 2170 } |
| 2162 | 2171 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 2181 } | 2190 } |
| 2182 | 2191 |
| 2183 void WebViewImpl::didHideCandidateWindow() | 2192 void WebViewImpl::didHideCandidateWindow() |
| 2184 { | 2193 { |
| 2185 if (InputMethodContext* context = inputMethodContext()) | 2194 if (InputMethodContext* context = inputMethodContext()) |
| 2186 context->dispatchCandidateWindowHideEvent(); | 2195 context->dispatchCandidateWindowHideEvent(); |
| 2187 } | 2196 } |
| 2188 | 2197 |
| 2189 bool WebViewImpl::selectionTextDirection(WebTextDirection& start, WebTextDirecti on& end) const | 2198 bool WebViewImpl::selectionTextDirection(WebTextDirection& start, WebTextDirecti on& end) const |
| 2190 { | 2199 { |
| 2191 const LocalFrame* frame = focusedWebCoreFrame(); | 2200 const LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); |
| 2192 if (!frame) | 2201 if (!frame) |
| 2193 return false; | 2202 return false; |
| 2194 FrameSelection& selection = frame->selection(); | 2203 FrameSelection& selection = frame->selection(); |
| 2195 if (!selection.toNormalizedRange()) | 2204 if (!selection.toNormalizedRange()) |
| 2196 return false; | 2205 return false; |
| 2197 start = selection.start().primaryDirection() == RTL ? WebTextDirectionRightT oLeft : WebTextDirectionLeftToRight; | 2206 start = selection.start().primaryDirection() == RTL ? WebTextDirectionRightT oLeft : WebTextDirectionLeftToRight; |
| 2198 end = selection.end().primaryDirection() == RTL ? WebTextDirectionRightToLef t : WebTextDirectionLeftToRight; | 2207 end = selection.end().primaryDirection() == RTL ? WebTextDirectionRightToLef t : WebTextDirectionLeftToRight; |
| 2199 return true; | 2208 return true; |
| 2200 } | 2209 } |
| 2201 | 2210 |
| 2202 bool WebViewImpl::isSelectionAnchorFirst() const | 2211 bool WebViewImpl::isSelectionAnchorFirst() const |
| 2203 { | 2212 { |
| 2204 if (const LocalFrame* frame = focusedWebCoreFrame()) | 2213 if (const LocalFrame* frame = toLocalFrame(focusedWebCoreFrame())) |
| 2205 return frame->selection().selection().isBaseFirst(); | 2214 return frame->selection().selection().isBaseFirst(); |
| 2206 return false; | 2215 return false; |
| 2207 } | 2216 } |
| 2208 | 2217 |
| 2209 bool WebViewImpl::setEditableSelectionOffsets(int start, int end) | 2218 bool WebViewImpl::setEditableSelectionOffsets(int start, int end) |
| 2210 { | 2219 { |
| 2211 const LocalFrame* focused = focusedWebCoreFrame(); | 2220 const LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); |
| 2212 if (!focused) | 2221 if (!focused) |
| 2213 return false; | 2222 return false; |
| 2214 return focused->inputMethodController().setEditableSelectionOffsets(PlainTex tRange(start, end)); | 2223 return focused->inputMethodController().setEditableSelectionOffsets(PlainTex tRange(start, end)); |
| 2215 } | 2224 } |
| 2216 | 2225 |
| 2217 bool WebViewImpl::setCompositionFromExistingText(int compositionStart, int compo sitionEnd, const WebVector<WebCompositionUnderline>& underlines) | 2226 bool WebViewImpl::setCompositionFromExistingText(int compositionStart, int compo sitionEnd, const WebVector<WebCompositionUnderline>& underlines) |
| 2218 { | 2227 { |
| 2219 const LocalFrame* focused = focusedWebCoreFrame(); | 2228 const LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); |
| 2220 if (!focused) | 2229 if (!focused) |
| 2221 return false; | 2230 return false; |
| 2222 | 2231 |
| 2223 if (!focused->editor().canEdit()) | 2232 if (!focused->editor().canEdit()) |
| 2224 return false; | 2233 return false; |
| 2225 | 2234 |
| 2226 InputMethodController& inputMethodController = focused->inputMethodControlle r(); | 2235 InputMethodController& inputMethodController = focused->inputMethodControlle r(); |
| 2227 inputMethodController.cancelComposition(); | 2236 inputMethodController.cancelComposition(); |
| 2228 | 2237 |
| 2229 if (compositionStart == compositionEnd) | 2238 if (compositionStart == compositionEnd) |
| 2230 return true; | 2239 return true; |
| 2231 | 2240 |
| 2232 inputMethodController.setCompositionFromExistingText(CompositionUnderlineVec torBuilder(underlines), compositionStart, compositionEnd); | 2241 inputMethodController.setCompositionFromExistingText(CompositionUnderlineVec torBuilder(underlines), compositionStart, compositionEnd); |
| 2233 | 2242 |
| 2234 return true; | 2243 return true; |
| 2235 } | 2244 } |
| 2236 | 2245 |
| 2237 WebVector<WebCompositionUnderline> WebViewImpl::compositionUnderlines() const | 2246 WebVector<WebCompositionUnderline> WebViewImpl::compositionUnderlines() const |
| 2238 { | 2247 { |
| 2239 const LocalFrame* focused = focusedWebCoreFrame(); | 2248 const LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); |
| 2240 if (!focused) | 2249 if (!focused) |
| 2241 return WebVector<WebCompositionUnderline>(); | 2250 return WebVector<WebCompositionUnderline>(); |
| 2242 const Vector<CompositionUnderline>& underlines = focused->inputMethodControl ler().customCompositionUnderlines(); | 2251 const Vector<CompositionUnderline>& underlines = focused->inputMethodControl ler().customCompositionUnderlines(); |
| 2243 WebVector<WebCompositionUnderline> results(underlines.size()); | 2252 WebVector<WebCompositionUnderline> results(underlines.size()); |
| 2244 for (size_t index = 0; index < underlines.size(); ++index) { | 2253 for (size_t index = 0; index < underlines.size(); ++index) { |
| 2245 CompositionUnderline underline = underlines[index]; | 2254 CompositionUnderline underline = underlines[index]; |
| 2246 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); |
| 2247 } | 2256 } |
| 2248 return results; | 2257 return results; |
| 2249 } | 2258 } |
| 2250 | 2259 |
| 2251 void WebViewImpl::extendSelectionAndDelete(int before, int after) | 2260 void WebViewImpl::extendSelectionAndDelete(int before, int after) |
| 2252 { | 2261 { |
| 2253 LocalFrame* focused = focusedWebCoreFrame(); | 2262 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); |
| 2254 if (!focused) | 2263 if (!focused) |
| 2255 return; | 2264 return; |
| 2256 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) { | 2265 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) { |
| 2257 plugin->extendSelectionAndDelete(before, after); | 2266 plugin->extendSelectionAndDelete(before, after); |
| 2258 return; | 2267 return; |
| 2259 } | 2268 } |
| 2260 focused->inputMethodController().extendSelectionAndDelete(before, after); | 2269 focused->inputMethodController().extendSelectionAndDelete(before, after); |
| 2261 } | 2270 } |
| 2262 | 2271 |
| 2263 bool WebViewImpl::isSelectionEditable() const | 2272 bool WebViewImpl::isSelectionEditable() const |
| 2264 { | 2273 { |
| 2265 if (const LocalFrame* frame = focusedWebCoreFrame()) | 2274 if (const LocalFrame* frame = toLocalFrame(focusedWebCoreFrame())) |
| 2266 return frame->selection().isContentEditable(); | 2275 return frame->selection().isContentEditable(); |
| 2267 return false; | 2276 return false; |
| 2268 } | 2277 } |
| 2269 | 2278 |
| 2270 WebColor WebViewImpl::backgroundColor() const | 2279 WebColor WebViewImpl::backgroundColor() const |
| 2271 { | 2280 { |
| 2272 if (isTransparent()) | 2281 if (isTransparent()) |
| 2273 return Color::transparent; | 2282 return Color::transparent; |
| 2274 if (!m_page) | 2283 if (!m_page) |
| 2275 return m_baseBackgroundColor; | 2284 return m_baseBackgroundColor; |
| 2276 if (!m_page->mainFrame()) | 2285 if (!m_page->mainFrame()) |
| 2277 return m_baseBackgroundColor; | 2286 return m_baseBackgroundColor; |
| 2278 FrameView* view = m_page->mainFrame()->view(); | 2287 FrameView* view = m_page->mainFrame()->view(); |
| 2279 return view->documentBackgroundColor().rgb(); | 2288 return view->documentBackgroundColor().rgb(); |
| 2280 } | 2289 } |
| 2281 | 2290 |
| 2282 bool WebViewImpl::caretOrSelectionRange(size_t* location, size_t* length) | 2291 bool WebViewImpl::caretOrSelectionRange(size_t* location, size_t* length) |
| 2283 { | 2292 { |
| 2284 const LocalFrame* focused = focusedWebCoreFrame(); | 2293 const LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); |
| 2285 if (!focused) | 2294 if (!focused) |
| 2286 return false; | 2295 return false; |
| 2287 | 2296 |
| 2288 PlainTextRange selectionOffsets = focused->inputMethodController().getSelect ionOffsets(); | 2297 PlainTextRange selectionOffsets = focused->inputMethodController().getSelect ionOffsets(); |
| 2289 if (selectionOffsets.isNull()) | 2298 if (selectionOffsets.isNull()) |
| 2290 return false; | 2299 return false; |
| 2291 | 2300 |
| 2292 *location = selectionOffsets.start(); | 2301 *location = selectionOffsets.start(); |
| 2293 *length = selectionOffsets.length(); | 2302 *length = selectionOffsets.length(); |
| 2294 return true; | 2303 return true; |
| 2295 } | 2304 } |
| 2296 | 2305 |
| 2297 void WebViewImpl::setTextDirection(WebTextDirection direction) | 2306 void WebViewImpl::setTextDirection(WebTextDirection direction) |
| 2298 { | 2307 { |
| 2299 // The Editor::setBaseWritingDirection() function checks if we can change | 2308 // The Editor::setBaseWritingDirection() function checks if we can change |
| 2300 // the text direction of the selected node and updates its DOM "dir" | 2309 // the text direction of the selected node and updates its DOM "dir" |
| 2301 // attribute and its CSS "direction" property. | 2310 // attribute and its CSS "direction" property. |
| 2302 // So, we just call the function as Safari does. | 2311 // So, we just call the function as Safari does. |
| 2303 const LocalFrame* focused = focusedWebCoreFrame(); | 2312 const LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); |
| 2304 if (!focused) | 2313 if (!focused) |
| 2305 return; | 2314 return; |
| 2306 | 2315 |
| 2307 Editor& editor = focused->editor(); | 2316 Editor& editor = focused->editor(); |
| 2308 if (!editor.canEdit()) | 2317 if (!editor.canEdit()) |
| 2309 return; | 2318 return; |
| 2310 | 2319 |
| 2311 switch (direction) { | 2320 switch (direction) { |
| 2312 case WebTextDirectionDefault: | 2321 case WebTextDirectionDefault: |
| 2313 editor.setBaseWritingDirection(NaturalWritingDirection); | 2322 editor.setBaseWritingDirection(NaturalWritingDirection); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2430 { | 2439 { |
| 2431 if (!relativeToFrame) | 2440 if (!relativeToFrame) |
| 2432 relativeToFrame = mainFrame(); | 2441 relativeToFrame = mainFrame(); |
| 2433 LocalFrame* frame = toWebFrameImpl(relativeToFrame)->frame(); | 2442 LocalFrame* frame = toWebFrameImpl(relativeToFrame)->frame(); |
| 2434 frame = frame->tree().find(name); | 2443 frame = frame->tree().find(name); |
| 2435 return WebFrameImpl::fromFrame(frame); | 2444 return WebFrameImpl::fromFrame(frame); |
| 2436 } | 2445 } |
| 2437 | 2446 |
| 2438 WebFrame* WebViewImpl::focusedFrame() | 2447 WebFrame* WebViewImpl::focusedFrame() |
| 2439 { | 2448 { |
| 2440 return WebFrameImpl::fromFrame(focusedWebCoreFrame()); | 2449 return WebFrameImpl::fromFrame(toLocalFrame(focusedWebCoreFrame())); |
| 2441 } | 2450 } |
| 2442 | 2451 |
| 2443 void WebViewImpl::setFocusedFrame(WebFrame* frame) | 2452 void WebViewImpl::setFocusedFrame(WebFrame* frame) |
| 2444 { | 2453 { |
| 2445 if (!frame) { | 2454 if (!frame) { |
| 2446 // Clears the focused frame if any. | 2455 // Clears the focused frame if any. |
| 2447 if (LocalFrame* focusedFrame = focusedWebCoreFrame()) | 2456 Frame* focusedFrame = focusedWebCoreFrame(); |
| 2448 focusedFrame->selection().setFocused(false); | 2457 if (focusedFrame && focusedFrame->isLocalFrame()) |
| 2458 toLocalFrame(focusedFrame)->selection().setFocused(false); | |
| 2449 return; | 2459 return; |
| 2450 } | 2460 } |
| 2451 LocalFrame* webcoreFrame = toWebFrameImpl(frame)->frame(); | 2461 LocalFrame* webcoreFrame = toWebFrameImpl(frame)->frame(); |
| 2452 webcoreFrame->page()->focusController().setFocusedFrame(webcoreFrame); | 2462 webcoreFrame->page()->focusController().setFocusedFrame(webcoreFrame); |
| 2453 } | 2463 } |
| 2454 | 2464 |
| 2455 void WebViewImpl::setInitialFocus(bool reverse) | 2465 void WebViewImpl::setInitialFocus(bool reverse) |
| 2456 { | 2466 { |
| 2457 if (!m_page) | 2467 if (!m_page) |
| 2458 return; | 2468 return; |
| 2459 LocalFrame* frame = page()->focusController().focusedOrMainFrame(); | 2469 Frame* frame = page()->focusController().focusedOrMainFrame(); |
| 2460 if (Document* document = frame->document()) | 2470 if (frame->isLocalFrame()) { |
| 2461 document->setFocusedElement(nullptr); | 2471 if (Document* document = toLocalFrame(frame)->document()) |
| 2472 document->setFocusedElement(nullptr); | |
| 2473 } | |
| 2462 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu sTypeForward); | 2474 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu sTypeForward); |
| 2463 } | 2475 } |
| 2464 | 2476 |
| 2465 void WebViewImpl::clearFocusedElement() | 2477 void WebViewImpl::clearFocusedElement() |
| 2466 { | 2478 { |
| 2467 RefPtr<LocalFrame> frame = focusedWebCoreFrame(); | 2479 RefPtr<Frame> frame = focusedWebCoreFrame(); |
| 2468 if (!frame) | 2480 if (!frame || !frame->isLocalFrame()) |
| 2469 return; | 2481 return; |
| 2470 | 2482 |
| 2471 RefPtr<Document> document = frame->document(); | 2483 LocalFrame* localFrame = toLocalFrame(frame.get()); |
| 2484 | |
| 2485 RefPtr<Document> document = localFrame->document(); | |
| 2472 if (!document) | 2486 if (!document) |
| 2473 return; | 2487 return; |
| 2474 | 2488 |
| 2475 RefPtr<Element> oldFocusedElement = document->focusedElement(); | 2489 RefPtr<Element> oldFocusedElement = document->focusedElement(); |
| 2476 | 2490 |
| 2477 // Clear the focused node. | 2491 // Clear the focused node. |
| 2478 document->setFocusedElement(nullptr); | 2492 document->setFocusedElement(nullptr); |
| 2479 | 2493 |
| 2480 if (!oldFocusedElement) | 2494 if (!oldFocusedElement) |
| 2481 return; | 2495 return; |
| 2482 | 2496 |
| 2483 // If a text field has focus, we need to make sure the selection controller | 2497 // If a text field has focus, we need to make sure the selection controller |
| 2484 // knows to remove selection from it. Otherwise, the text field is still | 2498 // knows to remove selection from it. Otherwise, the text field is still |
| 2485 // processing keyboard events even though focus has been moved to the page a nd | 2499 // processing keyboard events even though focus has been moved to the page a nd |
| 2486 // keystrokes get eaten as a result. | 2500 // keystrokes get eaten as a result. |
| 2487 if (oldFocusedElement->isContentEditable() || oldFocusedElement->isTextFormC ontrol()) | 2501 if (oldFocusedElement->isContentEditable() || oldFocusedElement->isTextFormC ontrol()) |
| 2488 frame->selection().clear(); | 2502 localFrame->selection().clear(); |
| 2489 } | 2503 } |
| 2490 | 2504 |
| 2491 void WebViewImpl::scrollFocusedNodeIntoView() | 2505 void WebViewImpl::scrollFocusedNodeIntoView() |
| 2492 { | 2506 { |
| 2493 if (Element* element = focusedElement()) | 2507 if (Element* element = focusedElement()) |
| 2494 element->scrollIntoViewIfNeeded(true); | 2508 element->scrollIntoViewIfNeeded(true); |
| 2495 } | 2509 } |
| 2496 | 2510 |
| 2497 void WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rect) | 2511 void WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rect) |
| 2498 { | 2512 { |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3313 m_page->contextMenuController().clearContextMenu(); | 3327 m_page->contextMenuController().clearContextMenu(); |
| 3314 } | 3328 } |
| 3315 | 3329 |
| 3316 void WebViewImpl::showContextMenu() | 3330 void WebViewImpl::showContextMenu() |
| 3317 { | 3331 { |
| 3318 if (!page()) | 3332 if (!page()) |
| 3319 return; | 3333 return; |
| 3320 | 3334 |
| 3321 page()->contextMenuController().clearContextMenu(); | 3335 page()->contextMenuController().clearContextMenu(); |
| 3322 m_contextMenuAllowed = true; | 3336 m_contextMenuAllowed = true; |
| 3323 if (LocalFrame* focusedFrame = page()->focusController().focusedOrMainFrame( )) | 3337 if (LocalFrame* focusedFrame = toLocalFrame(page()->focusController().focuse dOrMainFrame())) |
| 3324 focusedFrame->eventHandler().sendContextMenuEventForKey(); | 3338 focusedFrame->eventHandler().sendContextMenuEventForKey(); |
| 3325 m_contextMenuAllowed = false; | 3339 m_contextMenuAllowed = false; |
| 3326 } | 3340 } |
| 3327 | 3341 |
| 3328 WebString WebViewImpl::getSmartClipData(WebRect rect) | 3342 WebString WebViewImpl::getSmartClipData(WebRect rect) |
| 3329 { | 3343 { |
| 3330 LocalFrame* frame = focusedWebCoreFrame(); | 3344 LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); |
| 3331 if (!frame) | 3345 if (!frame) |
| 3332 return WebString(); | 3346 return WebString(); |
| 3333 return WebCore::SmartClip(frame).dataForRect(rect).toString(); | 3347 return WebCore::SmartClip(frame).dataForRect(rect).toString(); |
| 3334 } | 3348 } |
| 3335 | 3349 |
| 3336 void WebViewImpl::hidePopups() | 3350 void WebViewImpl::hidePopups() |
| 3337 { | 3351 { |
| 3338 hideSelectPopup(); | 3352 hideSelectPopup(); |
| 3339 if (m_pagePopup) | 3353 if (m_pagePopup) |
| 3340 closePagePopup(m_pagePopup.get()); | 3354 closePagePopup(m_pagePopup.get()); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3553 | 3567 |
| 3554 NotificationPresenterImpl* WebViewImpl::notificationPresenterImpl() | 3568 NotificationPresenterImpl* WebViewImpl::notificationPresenterImpl() |
| 3555 { | 3569 { |
| 3556 if (!m_notificationPresenter.isInitialized() && m_client) | 3570 if (!m_notificationPresenter.isInitialized() && m_client) |
| 3557 m_notificationPresenter.initialize(m_client->notificationPresenter()); | 3571 m_notificationPresenter.initialize(m_client->notificationPresenter()); |
| 3558 return &m_notificationPresenter; | 3572 return &m_notificationPresenter; |
| 3559 } | 3573 } |
| 3560 | 3574 |
| 3561 Element* WebViewImpl::focusedElement() const | 3575 Element* WebViewImpl::focusedElement() const |
| 3562 { | 3576 { |
| 3563 LocalFrame* frame = m_page->focusController().focusedFrame(); | 3577 Frame* frame = m_page->focusController().focusedFrame(); |
| 3564 if (!frame) | 3578 if (!frame || !frame->isLocalFrame()) |
| 3565 return 0; | 3579 return 0; |
| 3566 | 3580 |
| 3567 Document* document = frame->document(); | 3581 Document* document = toLocalFrame(frame)->document(); |
| 3568 if (!document) | 3582 if (!document) |
| 3569 return 0; | 3583 return 0; |
| 3570 | 3584 |
| 3571 return document->focusedElement(); | 3585 return document->focusedElement(); |
| 3572 } | 3586 } |
| 3573 | 3587 |
| 3574 HitTestResult WebViewImpl::hitTestResultForWindowPos(const IntPoint& pos) | 3588 HitTestResult WebViewImpl::hitTestResultForWindowPos(const IntPoint& pos) |
| 3575 { | 3589 { |
| 3576 IntPoint docPoint(m_page->mainFrame()->view()->windowToContents(pos)); | 3590 IntPoint docPoint(m_page->mainFrame()->view()->windowToContents(pos)); |
| 3577 return m_page->mainFrame()->eventHandler().hitTestResultAtPoint(docPoint, Hi tTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ConfusingAndOf tenMisusedDisallowShadowContent); | 3591 return m_page->mainFrame()->eventHandler().hitTestResultAtPoint(docPoint, Hi tTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ConfusingAndOf tenMisusedDisallowShadowContent); |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3968 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); | 3982 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); |
| 3969 | 3983 |
| 3970 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 3984 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
| 3971 return false; | 3985 return false; |
| 3972 | 3986 |
| 3973 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 3987 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
| 3974 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); | 3988 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); |
| 3975 } | 3989 } |
| 3976 | 3990 |
| 3977 } // namespace blink | 3991 } // namespace blink |
| OLD | NEW |