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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 #include "core/inspector/InspectorController.h" | 59 #include "core/inspector/InspectorController.h" |
60 #include "core/loader/DocumentLoader.h" | 60 #include "core/loader/DocumentLoader.h" |
61 #include "core/loader/FrameLoader.h" | 61 #include "core/loader/FrameLoader.h" |
62 #include "core/loader/UniqueIdentifier.h" | 62 #include "core/loader/UniqueIdentifier.h" |
63 #include "core/page/Chrome.h" | 63 #include "core/page/Chrome.h" |
64 #include "core/page/ContextMenuController.h" | 64 #include "core/page/ContextMenuController.h" |
65 #include "core/page/DragController.h" | 65 #include "core/page/DragController.h" |
66 #include "core/page/DragData.h" | 66 #include "core/page/DragData.h" |
67 #include "core/page/DragSession.h" | 67 #include "core/page/DragSession.h" |
68 #include "core/page/EventHandler.h" | 68 #include "core/page/EventHandler.h" |
| 69 #include "core/page/EventWithHitTestResults.h" |
69 #include "core/page/FocusController.h" | 70 #include "core/page/FocusController.h" |
70 #include "core/page/FrameTree.h" | 71 #include "core/page/FrameTree.h" |
71 #include "core/page/InjectedStyleSheets.h" | 72 #include "core/page/InjectedStyleSheets.h" |
72 #include "core/page/Page.h" | 73 #include "core/page/Page.h" |
73 #include "core/page/PagePopupClient.h" | 74 #include "core/page/PagePopupClient.h" |
74 #include "core/page/PointerLockController.h" | 75 #include "core/page/PointerLockController.h" |
75 #include "core/page/ScopedPageLoadDeferrer.h" | 76 #include "core/page/ScopedPageLoadDeferrer.h" |
76 #include "core/page/TouchDisambiguation.h" | 77 #include "core/page/TouchDisambiguation.h" |
77 #include "core/rendering/FastTextAutosizer.h" | 78 #include "core/rendering/FastTextAutosizer.h" |
78 #include "core/rendering/RenderView.h" | 79 #include "core/rendering/RenderView.h" |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 eventSwallowed = true; | 648 eventSwallowed = true; |
648 | 649 |
649 m_client->didHandleGestureEvent(event, eventCancelled); | 650 m_client->didHandleGestureEvent(event, eventCancelled); |
650 return eventSwallowed; | 651 return eventSwallowed; |
651 default: | 652 default: |
652 break; | 653 break; |
653 } | 654 } |
654 | 655 |
655 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even
t); | 656 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even
t); |
656 | 657 |
| 658 // FIXME: Remove redundant hit tests by pushing the call to EventHandler::ta
rgetGestureEvent |
| 659 // up to this point and pass GestureEventWithHitTestResults around. |
| 660 |
657 // Handle link highlighting outside the main switch to avoid getting lost in
the | 661 // Handle link highlighting outside the main switch to avoid getting lost in
the |
658 // complicated set of cases handled below. | 662 // complicated set of cases handled below. |
659 switch (event.type) { | 663 switch (event.type) { |
660 case WebInputEvent::GestureShowPress: | 664 case WebInputEvent::GestureShowPress: |
661 // Queue a highlight animation, then hand off to regular handler. | 665 // Queue a highlight animation, then hand off to regular handler. |
662 if (settingsImpl()->gestureTapHighlightEnabled()) | 666 if (settingsImpl()->gestureTapHighlightEnabled()) |
663 enableTapHighlightAtPoint(platformEvent); | 667 enableTapHighlightAtPoint(platformEvent); |
664 break; | 668 break; |
665 case WebInputEvent::GestureTapCancel: | 669 case WebInputEvent::GestureTapCancel: |
666 case WebInputEvent::GestureTap: | 670 case WebInputEvent::GestureTap: |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 if (!node || !node->renderer()) | 1168 if (!node || !node->renderer()) |
1165 return false; | 1169 return false; |
1166 | 1170 |
1167 ECursor cursor = node->renderer()->style()->cursor(); | 1171 ECursor cursor = node->renderer()->style()->cursor(); |
1168 return cursor == CURSOR_POINTER | 1172 return cursor == CURSOR_POINTER |
1169 || (cursor == CURSOR_AUTO && frame->eventHandler().useHandCursor(node, n
ode->isLink())); | 1173 || (cursor == CURSOR_AUTO && frame->eventHandler().useHandCursor(node, n
ode->isLink())); |
1170 } | 1174 } |
1171 | 1175 |
1172 Node* WebViewImpl::bestTapNode(const PlatformGestureEvent& tapEvent) | 1176 Node* WebViewImpl::bestTapNode(const PlatformGestureEvent& tapEvent) |
1173 { | 1177 { |
1174 if (!m_page || !m_page->mainFrame() || !m_page->mainFrame()->isLocalFrame()) | 1178 TRACE_EVENT0("input", "WebViewImpl::bestTapNode"); |
| 1179 |
| 1180 if (!m_page || !m_page->mainFrame()) |
1175 return 0; | 1181 return 0; |
1176 | 1182 |
1177 Node* bestTouchNode = 0; | 1183 Node* bestTouchNode = 0; |
1178 | 1184 |
1179 IntPoint touchEventLocation(tapEvent.position()); | 1185 // FIXME: Rely on earlier hit test instead of hit testing again. |
1180 m_page->deprecatedLocalMainFrame()->eventHandler().adjustGesturePosition(tap
Event, touchEventLocation); | 1186 GestureEventWithHitTestResults targetedEvent = m_page->deprecatedLocalMainFr
ame()->eventHandler().targetGestureEvent(tapEvent, true); |
1181 | 1187 bestTouchNode = targetedEvent.hitTestResult().targetNode(); |
1182 IntPoint hitTestPoint = m_page->deprecatedLocalMainFrame()->view()->windowTo
Contents(touchEventLocation); | |
1183 HitTestResult result = m_page->deprecatedLocalMainFrame()->eventHandler().hi
tTestResultAtPoint(hitTestPoint, HitTestRequest::TouchEvent); | |
1184 bestTouchNode = result.targetNode(); | |
1185 | 1188 |
1186 // We might hit something like an image map that has no renderer on it | 1189 // We might hit something like an image map that has no renderer on it |
1187 // Walk up the tree until we have a node with an attached renderer | 1190 // Walk up the tree until we have a node with an attached renderer |
1188 while (bestTouchNode && !bestTouchNode->renderer()) | 1191 while (bestTouchNode && !bestTouchNode->renderer()) |
1189 bestTouchNode = bestTouchNode->parentNode(); | 1192 bestTouchNode = bestTouchNode->parentNode(); |
1190 | 1193 |
1191 // Check if we're in the subtree of a node with a hand cursor | 1194 // Check if we're in the subtree of a node with a hand cursor |
1192 // this is the heuristic we use to determine if we show a highlight on tap | 1195 // this is the heuristic we use to determine if we show a highlight on tap |
1193 while (bestTouchNode && !invokesHandCursor(bestTouchNode, m_page->deprecated
LocalMainFrame())) | 1196 while (bestTouchNode && !invokesHandCursor(bestTouchNode, m_page->deprecated
LocalMainFrame())) |
1194 bestTouchNode = bestTouchNode->parentNode(); | 1197 bestTouchNode = bestTouchNode->parentNode(); |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1809 | 1812 |
1810 bool WebViewImpl::hasVerticalScrollbar() | 1813 bool WebViewImpl::hasVerticalScrollbar() |
1811 { | 1814 { |
1812 return mainFrameImpl()->frameView()->verticalScrollbar(); | 1815 return mainFrameImpl()->frameView()->verticalScrollbar(); |
1813 } | 1816 } |
1814 | 1817 |
1815 const WebInputEvent* WebViewImpl::m_currentInputEvent = 0; | 1818 const WebInputEvent* WebViewImpl::m_currentInputEvent = 0; |
1816 | 1819 |
1817 // FIXME: autogenerate this kind of code, and use it throughout Blink rather tha
n | 1820 // FIXME: autogenerate this kind of code, and use it throughout Blink rather tha
n |
1818 // the one-offs for subsets of these values. | 1821 // the one-offs for subsets of these values. |
1819 static const AtomicString* inputTypeToName(WebInputEvent::Type type) | 1822 static String inputTypeToName(WebInputEvent::Type type) |
1820 { | 1823 { |
1821 switch (type) { | 1824 switch (type) { |
1822 case WebInputEvent::MouseDown: | 1825 case WebInputEvent::MouseDown: |
1823 return &EventTypeNames::mousedown; | 1826 return EventTypeNames::mousedown; |
1824 case WebInputEvent::MouseUp: | 1827 case WebInputEvent::MouseUp: |
1825 return &EventTypeNames::mouseup; | 1828 return EventTypeNames::mouseup; |
1826 case WebInputEvent::MouseMove: | 1829 case WebInputEvent::MouseMove: |
1827 return &EventTypeNames::mousemove; | 1830 return EventTypeNames::mousemove; |
1828 case WebInputEvent::MouseEnter: | 1831 case WebInputEvent::MouseEnter: |
1829 return &EventTypeNames::mouseenter; | 1832 return EventTypeNames::mouseenter; |
1830 case WebInputEvent::MouseLeave: | 1833 case WebInputEvent::MouseLeave: |
1831 return &EventTypeNames::mouseleave; | 1834 return EventTypeNames::mouseleave; |
1832 case WebInputEvent::ContextMenu: | 1835 case WebInputEvent::ContextMenu: |
1833 return &EventTypeNames::contextmenu; | 1836 return EventTypeNames::contextmenu; |
1834 case WebInputEvent::MouseWheel: | 1837 case WebInputEvent::MouseWheel: |
1835 return &EventTypeNames::mousewheel; | 1838 return EventTypeNames::mousewheel; |
1836 case WebInputEvent::KeyDown: | 1839 case WebInputEvent::KeyDown: |
1837 return &EventTypeNames::keydown; | 1840 return EventTypeNames::keydown; |
1838 case WebInputEvent::KeyUp: | 1841 case WebInputEvent::KeyUp: |
1839 return &EventTypeNames::keyup; | 1842 return EventTypeNames::keyup; |
1840 case WebInputEvent::GestureScrollBegin: | 1843 case WebInputEvent::GestureScrollBegin: |
1841 return &EventTypeNames::gesturescrollstart; | 1844 return EventTypeNames::gesturescrollstart; |
1842 case WebInputEvent::GestureScrollEnd: | 1845 case WebInputEvent::GestureScrollEnd: |
1843 return &EventTypeNames::gesturescrollend; | 1846 return EventTypeNames::gesturescrollend; |
1844 case WebInputEvent::GestureScrollUpdate: | 1847 case WebInputEvent::GestureScrollUpdate: |
1845 return &EventTypeNames::gesturescrollupdate; | 1848 return EventTypeNames::gesturescrollupdate; |
| 1849 case WebInputEvent::GestureTapDown: |
| 1850 return EventTypeNames::gesturetapdown; |
| 1851 case WebInputEvent::GestureShowPress: |
| 1852 return EventTypeNames::gestureshowpress; |
| 1853 case WebInputEvent::GestureTap: |
| 1854 return EventTypeNames::gesturetap; |
| 1855 case WebInputEvent::GestureTapUnconfirmed: |
| 1856 return EventTypeNames::gesturetapunconfirmed; |
1846 case WebInputEvent::TouchStart: | 1857 case WebInputEvent::TouchStart: |
1847 return &EventTypeNames::touchstart; | 1858 return EventTypeNames::touchstart; |
1848 case WebInputEvent::TouchMove: | 1859 case WebInputEvent::TouchMove: |
1849 return &EventTypeNames::touchmove; | 1860 return EventTypeNames::touchmove; |
1850 case WebInputEvent::TouchEnd: | 1861 case WebInputEvent::TouchEnd: |
1851 return &EventTypeNames::touchend; | 1862 return EventTypeNames::touchend; |
1852 case WebInputEvent::TouchCancel: | 1863 case WebInputEvent::TouchCancel: |
1853 return &EventTypeNames::touchcancel; | 1864 return EventTypeNames::touchcancel; |
1854 default: | 1865 default: |
1855 return 0; | 1866 return String("unknown"); |
1856 } | 1867 } |
1857 } | 1868 } |
1858 | 1869 |
1859 bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent) | 1870 bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent) |
1860 { | 1871 { |
1861 UserGestureNotifier notifier(m_autofillClient, &m_userGestureObserved); | 1872 UserGestureNotifier notifier(m_autofillClient, &m_userGestureObserved); |
1862 // On the first input event since page load, |notifier| instructs the | 1873 // On the first input event since page load, |notifier| instructs the |
1863 // autofill client to unblock values of password input fields of any forms | 1874 // autofill client to unblock values of password input fields of any forms |
1864 // on the page. There is a single input event, GestureTap, which can both | 1875 // on the page. There is a single input event, GestureTap, which can both |
1865 // be the first event after page load, and cause a form submission. In that | 1876 // be the first event after page load, and cause a form submission. In that |
1866 // case, the form submission happens before the autofill client is told | 1877 // case, the form submission happens before the autofill client is told |
1867 // to unblock the password values, and so the password values are not | 1878 // to unblock the password values, and so the password values are not |
1868 // submitted. To avoid that, GestureTap is handled explicitly: | 1879 // submitted. To avoid that, GestureTap is handled explicitly: |
1869 if (inputEvent.type == WebInputEvent::GestureTap && m_autofillClient) { | 1880 if (inputEvent.type == WebInputEvent::GestureTap && m_autofillClient) { |
1870 m_userGestureObserved = true; | 1881 m_userGestureObserved = true; |
1871 m_autofillClient->firstUserGestureObserved(); | 1882 m_autofillClient->firstUserGestureObserved(); |
1872 } | 1883 } |
1873 | 1884 |
1874 const AtomicString* inputEventName = inputTypeToName(inputEvent.type); | 1885 TRACE_EVENT1("input", "WebViewImpl::handleInputEvent", "type", inputTypeToNa
me(inputEvent.type).ascii()); |
1875 TRACE_EVENT1("input", "WebViewImpl::handleInputEvent", "type", inputEventNam
e ? inputEventName->ascii() : "unknown"); | |
1876 // If we've started a drag and drop operation, ignore input events until | 1886 // If we've started a drag and drop operation, ignore input events until |
1877 // we're done. | 1887 // we're done. |
1878 if (m_doingDragAndDrop) | 1888 if (m_doingDragAndDrop) |
1879 return true; | 1889 return true; |
1880 | 1890 |
1881 if (m_devToolsAgent && m_devToolsAgent->handleInputEvent(m_page.get(), input
Event)) | 1891 if (m_devToolsAgent && m_devToolsAgent->handleInputEvent(m_page.get(), input
Event)) |
1882 return true; | 1892 return true; |
1883 | 1893 |
1884 // Report the event to be NOT processed by WebKit, so that the browser can h
andle it appropriately. | 1894 // Report the event to be NOT processed by WebKit, so that the browser can h
andle it appropriately. |
1885 if (m_ignoreInputEvents) | 1895 if (m_ignoreInputEvents) |
(...skipping 2268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4154 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); | 4164 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); |
4155 | 4165 |
4156 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4166 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
4157 return false; | 4167 return false; |
4158 | 4168 |
4159 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4169 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
4160 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4170 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
4161 } | 4171 } |
4162 | 4172 |
4163 } // namespace blink | 4173 } // namespace blink |
OLD | NEW |