Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: third_party/WebKit/Source/core/input/EventHandler.cpp

Issue 1989623002: Suppressed MEs for gestures from cancelled PEs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed a text selection regression. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 , m_eventHandlerWillResetCapturingMouseEventsNode(0) 208 , m_eventHandlerWillResetCapturingMouseEventsNode(0)
209 , m_clickCount(0) 209 , m_clickCount(0)
210 , m_shouldOnlyFireDragOverEvent(false) 210 , m_shouldOnlyFireDragOverEvent(false)
211 , m_mousePositionIsUnknown(true) 211 , m_mousePositionIsUnknown(true)
212 , m_mouseDownTimestamp(0) 212 , m_mouseDownTimestamp(0)
213 , m_pointerEventManager(frame) 213 , m_pointerEventManager(frame)
214 , m_scrollManager(frame) 214 , m_scrollManager(frame)
215 , m_longTapShouldInvokeContextMenu(false) 215 , m_longTapShouldInvokeContextMenu(false)
216 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) 216 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired)
217 , m_lastShowPressTimestamp(0) 217 , m_lastShowPressTimestamp(0)
218 , m_suppressMouseEventsFromGestures(false)
218 { 219 {
219 } 220 }
220 221
221 EventHandler::~EventHandler() 222 EventHandler::~EventHandler()
222 { 223 {
223 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); 224 ASSERT(!m_fakeMouseMoveEventTimer.isActive());
224 } 225 }
225 226
226 DEFINE_TRACE(EventHandler) 227 DEFINE_TRACE(EventHandler)
227 { 228 {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 m_lastShowPressTimestamp = 0; 275 m_lastShowPressTimestamp = 0;
275 m_lastDeferredTapElement = nullptr; 276 m_lastDeferredTapElement = nullptr;
276 m_eventHandlerWillResetCapturingMouseEventsNode = false; 277 m_eventHandlerWillResetCapturingMouseEventsNode = false;
277 m_mouseDownMayStartAutoscroll = false; 278 m_mouseDownMayStartAutoscroll = false;
278 m_svgPan = false; 279 m_svgPan = false;
279 m_mouseDownPos = IntPoint(); 280 m_mouseDownPos = IntPoint();
280 m_mouseDownTimestamp = 0; 281 m_mouseDownTimestamp = 0;
281 m_longTapShouldInvokeContextMenu = false; 282 m_longTapShouldInvokeContextMenu = false;
282 m_dragStartPos = LayoutPoint(); 283 m_dragStartPos = LayoutPoint();
283 m_mouseDown = PlatformMouseEvent(); 284 m_mouseDown = PlatformMouseEvent();
285 m_suppressMouseEventsFromGestures = false;
284 } 286 }
285 287
286 WebInputEventResult EventHandler::mergeEventResult( 288 WebInputEventResult EventHandler::mergeEventResult(
287 WebInputEventResult resultA, WebInputEventResult resultB) 289 WebInputEventResult resultA, WebInputEventResult resultB)
288 { 290 {
289 // The ordering of the enumeration is specific. There are times that 291 // The ordering of the enumeration is specific. There are times that
290 // multiple events fire and we need to combine them into a single 292 // multiple events fire and we need to combine them into a single
291 // result code. The enumeration is based on the level of consumption that 293 // result code. The enumeration is based on the level of consumption that
292 // is most significant. The enumeration is ordered with smaller specified 294 // is most significant. The enumeration is ordered with smaller specified
293 // numbers first. Examples of merged results are: 295 // numbers first. Examples of merged results are:
(...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1802 if (gestureDomEvent) { 1804 if (gestureDomEvent) {
1803 DispatchEventResult gestureDomEventResult = eventTarget->dispatchEve nt(gestureDomEvent); 1805 DispatchEventResult gestureDomEventResult = eventTarget->dispatchEve nt(gestureDomEvent);
1804 if (gestureDomEventResult != DispatchEventResult::NotCanceled) { 1806 if (gestureDomEventResult != DispatchEventResult::NotCanceled) {
1805 ASSERT(gestureDomEventResult != DispatchEventResult::CanceledByE ventHandler); 1807 ASSERT(gestureDomEventResult != DispatchEventResult::CanceledByE ventHandler);
1806 return toWebInputEventResult(gestureDomEventResult); 1808 return toWebInputEventResult(gestureDomEventResult);
1807 } 1809 }
1808 } 1810 }
1809 } 1811 }
1810 1812
1811 switch (gestureEvent.type()) { 1813 switch (gestureEvent.type()) {
1814 case PlatformEvent::GestureTapDown:
1815 return handleGestureTapDown(targetedEvent);
1812 case PlatformEvent::GestureTap: 1816 case PlatformEvent::GestureTap:
1813 return handleGestureTap(targetedEvent); 1817 return handleGestureTap(targetedEvent);
1814 case PlatformEvent::GestureShowPress: 1818 case PlatformEvent::GestureShowPress:
1815 return handleGestureShowPress(); 1819 return handleGestureShowPress();
1816 case PlatformEvent::GestureLongPress: 1820 case PlatformEvent::GestureLongPress:
1817 return handleGestureLongPress(targetedEvent); 1821 return handleGestureLongPress(targetedEvent);
1818 case PlatformEvent::GestureLongTap: 1822 case PlatformEvent::GestureLongTap:
1819 return handleGestureLongTap(targetedEvent); 1823 return handleGestureLongTap(targetedEvent);
1820 case PlatformEvent::GestureTwoFingerTap: 1824 case PlatformEvent::GestureTwoFingerTap:
1821 return sendContextMenuEventForGesture(targetedEvent); 1825 return sendContextMenuEventForGesture(targetedEvent);
1822 case PlatformEvent::GestureTapDown:
1823 case PlatformEvent::GesturePinchBegin: 1826 case PlatformEvent::GesturePinchBegin:
1824 case PlatformEvent::GesturePinchEnd: 1827 case PlatformEvent::GesturePinchEnd:
1825 case PlatformEvent::GesturePinchUpdate: 1828 case PlatformEvent::GesturePinchUpdate:
1826 case PlatformEvent::GestureTapDownCancel: 1829 case PlatformEvent::GestureTapDownCancel:
1827 case PlatformEvent::GestureTapUnconfirmed: 1830 case PlatformEvent::GestureTapUnconfirmed:
1828 break; 1831 break;
1829 default: 1832 default:
1830 ASSERT_NOT_REACHED(); 1833 ASSERT_NOT_REACHED();
1831 } 1834 }
1832 1835
1833 return WebInputEventResult::NotHandled; 1836 return WebInputEventResult::NotHandled;
1834 } 1837 }
1835 1838
1836 WebInputEventResult EventHandler::handleGestureScrollEvent(const PlatformGesture Event& gestureEvent) 1839 WebInputEventResult EventHandler::handleGestureScrollEvent(const PlatformGesture Event& gestureEvent)
1837 { 1840 {
1838 TRACE_EVENT0("input", "EventHandler::handleGestureScrollEvent"); 1841 TRACE_EVENT0("input", "EventHandler::handleGestureScrollEvent");
1839 1842
1840 return m_scrollManager.handleGestureScrollEvent(gestureEvent); 1843 return m_scrollManager.handleGestureScrollEvent(gestureEvent);
1841 } 1844 }
1842 1845
1846 WebInputEventResult EventHandler::handleGestureTapDown(const GestureEventWithHit TestResults& targetedEvent)
1847 {
1848 m_suppressMouseEventsFromGestures =
1849 m_pointerEventManager.primaryPointerdownCanceled(targetedEvent.event().u niqueTouchEventId());
1850 return WebInputEventResult::NotHandled;
1851 }
1852
1843 WebInputEventResult EventHandler::handleGestureTap(const GestureEventWithHitTest Results& targetedEvent) 1853 WebInputEventResult EventHandler::handleGestureTap(const GestureEventWithHitTest Results& targetedEvent)
1844 { 1854 {
1845 FrameView* frameView(m_frame->view()); 1855 FrameView* frameView(m_frame->view());
1846 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); 1856 const PlatformGestureEvent& gestureEvent = targetedEvent.event();
1847 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type()); 1857 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type());
1848 uint64_t preDispatchDomTreeVersion = m_frame->document()->domTreeVersion(); 1858 uint64_t preDispatchDomTreeVersion = m_frame->document()->domTreeVersion();
1849 uint64_t preDispatchStyleVersion = m_frame->document()->styleVersion(); 1859 uint64_t preDispatchStyleVersion = m_frame->document()->styleVersion();
1850 1860
1851 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); 1861 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
1852 1862
1853 HitTestResult currentHitTest = targetedEvent.hitTestResult(); 1863 HitTestResult currentHitTest = targetedEvent.hitTestResult();
1854 1864
1855 // We use the adjusted position so the application isn't surprised to see a event with 1865 // We use the adjusted position so the application isn't surprised to see a event with
1856 // co-ordinates outside the target's bounds. 1866 // co-ordinates outside the target's bounds.
1857 IntPoint adjustedPoint = frameView->rootFrameToContents(gestureEvent.positio n()); 1867 IntPoint adjustedPoint = frameView->rootFrameToContents(gestureEvent.positio n());
1858 1868
1859 unsigned modifiers = gestureEvent.getModifiers(); 1869 const unsigned modifiers = gestureEvent.getModifiers();
1860 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globa lPosition(), 1870
1861 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, 1871 if (!m_suppressMouseEventsFromGestures) {
1862 static_cast<PlatformEvent::Modifiers>(modifiers), 1872 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.g lobalPosition(),
1863 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerPrope rties::PointerType::Mouse); 1873 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0,
1864 dispatchMouseEvent(EventTypeNames::mousemove, currentHitTest.innerNode(), 0, fakeMouseMove); 1874 static_cast<PlatformEvent::Modifiers>(modifiers),
1875 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerP roperties::PointerType::Mouse);
1876 dispatchMouseEvent(EventTypeNames::mousemove, currentHitTest.innerNode() , 0, fakeMouseMove);
1877 }
1865 1878
1866 // Do a new hit-test in case the mousemove event changed the DOM. 1879 // Do a new hit-test in case the mousemove event changed the DOM.
1867 // Note that if the original hit test wasn't over an element (eg. was over a scrollbar) we 1880 // Note that if the original hit test wasn't over an element (eg. was over a scrollbar) we
1868 // don't want to re-hit-test because it may be in the wrong frame (and there 's no way the page 1881 // don't want to re-hit-test because it may be in the wrong frame (and there 's no way the page
1869 // could have seen the event anyway). 1882 // could have seen the event anyway).
1870 // Also note that the position of the frame may have changed, so we need to recompute the content 1883 // Also note that the position of the frame may have changed, so we need to recompute the content
1871 // co-ordinates (updating layout/style as hitTestResultAtPoint normally woul d). 1884 // co-ordinates (updating layout/style as hitTestResultAtPoint normally woul d).
1872 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug. com/398920 1885 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug. com/398920
1873 if (currentHitTest.innerNode()) { 1886 if (currentHitTest.innerNode()) {
1874 LocalFrame* mainFrame = m_frame->localFrameRoot(); 1887 LocalFrame* mainFrame = m_frame->localFrameRoot();
1875 if (mainFrame && mainFrame->view()) 1888 if (mainFrame && mainFrame->view())
1876 mainFrame->view()->updateLifecycleToCompositingCleanPlusScrolling(); 1889 mainFrame->view()->updateLifecycleToCompositingCleanPlusScrolling();
1877 adjustedPoint = frameView->rootFrameToContents(gestureEvent.position()); 1890 adjustedPoint = frameView->rootFrameToContents(gestureEvent.position());
1878 currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, hitType); 1891 currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, hitType);
1879 } 1892 }
1880 m_clickNode = currentHitTest.innerNode(); 1893 m_clickNode = currentHitTest.innerNode();
1881 1894
1882 // Capture data for showUnhandledTapUIIfNeeded. 1895 // Capture data for showUnhandledTapUIIfNeeded.
1883 Node* tappedNode = m_clickNode; 1896 Node* tappedNode = m_clickNode;
1884 IntPoint tappedPosition = gestureEvent.position(); 1897 IntPoint tappedPosition = gestureEvent.position();
1885 1898
1886 if (m_clickNode && m_clickNode->isTextNode()) 1899 if (m_clickNode && m_clickNode->isTextNode())
1887 m_clickNode = FlatTreeTraversal::parent(*m_clickNode); 1900 m_clickNode = FlatTreeTraversal::parent(*m_clickNode);
1888 1901
1889 PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globa lPosition(), 1902 PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globa lPosition(),
1890 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(), 1903 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(),
1891 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut tonDown), 1904 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut tonDown),
1892 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerProp erties::PointerType::Mouse); 1905 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerPrope rties::PointerType::Mouse);
1893 WebInputEventResult mouseDownEventResult = dispatchMouseEvent(EventTypeNames ::mousedown, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown) ; 1906
1894 selectionController().initializeSelectionState(); 1907 // TODO(mustaq): We suppress MEs plus all it's side effects. What would that
1895 if (mouseDownEventResult == WebInputEventResult::NotHandled) 1908 // mean for for TEs? What's the right balance here? crbug.com/617255
1896 mouseDownEventResult = handleMouseFocus(MouseEventWithHitTestResults(fak eMouseDown, currentHitTest), InputDeviceCapabilities::firesTouchEventsSourceCapa bilities()); 1909 WebInputEventResult mouseDownEventResult = WebInputEventResult::NotHandled;
Rick Byers 2016/06/09 16:07:33 nit: this local isn't used outside the below scope
mustaq 2016/06/09 16:41:03 The mergeEventResult calls at the end combine all
Rick Byers 2016/06/09 17:01:33 Oh sorry, my search missed it (due to wrapping in
mustaq 2016/06/09 17:17:27 Acknowledged.
1897 if (mouseDownEventResult == WebInputEventResult::NotHandled) 1910 if (!m_suppressMouseEventsFromGestures) {
1898 mouseDownEventResult = handleMousePressEvent(MouseEventWithHitTestResult s(fakeMouseDown, currentHitTest)); 1911 mouseDownEventResult = dispatchMouseEvent(EventTypeNames::mousedown, cur rentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown);
1912 selectionController().initializeSelectionState();
1913 if (mouseDownEventResult == WebInputEventResult::NotHandled)
1914 mouseDownEventResult = handleMouseFocus(MouseEventWithHitTestResults (fakeMouseDown, currentHitTest), InputDeviceCapabilities::firesTouchEventsSource Capabilities());
1915 if (mouseDownEventResult == WebInputEventResult::NotHandled)
1916 mouseDownEventResult = handleMousePressEvent(MouseEventWithHitTestRe sults(fakeMouseDown, currentHitTest));
1917 }
1899 1918
1900 if (currentHitTest.innerNode()) { 1919 if (currentHitTest.innerNode()) {
1901 ASSERT(gestureEvent.type() == PlatformEvent::GestureTap); 1920 ASSERT(gestureEvent.type() == PlatformEvent::GestureTap);
1902 HitTestResult result = currentHitTest; 1921 HitTestResult result = currentHitTest;
1903 result.setToShadowHostIfInUserAgentShadowRoot(); 1922 result.setToShadowHostIfInUserAgentShadowRoot();
1904 m_frame->chromeClient().onMouseDown(result.innerNode()); 1923 m_frame->chromeClient().onMouseDown(result.innerNode());
1905 } 1924 }
1906 1925
1907 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug. com/398920 1926 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug. com/398920
1908 if (currentHitTest.innerNode()) { 1927 if (currentHitTest.innerNode()) {
1909 LocalFrame* mainFrame = m_frame->localFrameRoot(); 1928 LocalFrame* mainFrame = m_frame->localFrameRoot();
1910 if (mainFrame && mainFrame->view()) 1929 if (mainFrame && mainFrame->view())
1911 mainFrame->view()->updateAllLifecyclePhases(); 1930 mainFrame->view()->updateAllLifecyclePhases();
1912 adjustedPoint = frameView->rootFrameToContents(gestureEvent.position()); 1931 adjustedPoint = frameView->rootFrameToContents(gestureEvent.position());
1913 currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, hitType); 1932 currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, hitType);
1914 } 1933 }
1934
1915 PlatformMouseEvent fakeMouseUp(gestureEvent.position(), gestureEvent.globalP osition(), 1935 PlatformMouseEvent fakeMouseUp(gestureEvent.position(), gestureEvent.globalP osition(),
1916 LeftButton, PlatformEvent::MouseReleased, gestureEvent.tapCount(), 1936 LeftButton, PlatformEvent::MouseReleased, gestureEvent.tapCount(),
1917 static_cast<PlatformEvent::Modifiers>(modifiers), 1937 static_cast<PlatformEvent::Modifiers>(modifiers),
1918 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerProp erties::PointerType::Mouse); 1938 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerPrope rties::PointerType::Mouse);
1919 WebInputEventResult mouseUpEventResult = dispatchMouseEvent(EventTypeNames:: mouseup, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseUp); 1939 WebInputEventResult mouseUpEventResult = WebInputEventResult::NotHandled;
1940 if (!m_suppressMouseEventsFromGestures)
1941 mouseUpEventResult = dispatchMouseEvent(EventTypeNames::mouseup, current HitTest.innerNode(), gestureEvent.tapCount(), fakeMouseUp);
1920 1942
1921 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled; 1943 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled;
1922 if (m_clickNode) { 1944 if (m_clickNode) {
1923 if (currentHitTest.innerNode()) { 1945 if (currentHitTest.innerNode()) {
1924 // Updates distribution because a mouseup (or mousedown) event liste ner can make the 1946 // Updates distribution because a mouseup (or mousedown) event liste ner can make the
1925 // tree dirty at dispatchMouseEvent() invocation above. 1947 // tree dirty at dispatchMouseEvent() invocation above.
1926 // Unless distribution is updated, commonAncestor would hit ASSERT. 1948 // Unless distribution is updated, commonAncestor would hit ASSERT.
1927 // Both m_clickNode and currentHitTest.innerNode()) don't need to be updated 1949 // Both m_clickNode and currentHitTest.innerNode()) don't need to be updated
1928 // because commonAncestor() will exit early if their documents are d ifferent. 1950 // because commonAncestor() will exit early if their documents are d ifferent.
1929 m_clickNode->updateDistribution(); 1951 m_clickNode->updateDistribution();
1930 Node* clickTargetNode = currentHitTest.innerNode()->commonAncestor(* m_clickNode, parentForClickEvent); 1952 Node* clickTargetNode = currentHitTest.innerNode()->commonAncestor(* m_clickNode, parentForClickEvent);
1931 clickEventResult = dispatchMouseEvent(EventTypeNames::click, clickTa rgetNode, gestureEvent.tapCount(), fakeMouseUp); 1953 clickEventResult = dispatchMouseEvent(EventTypeNames::click, clickTa rgetNode, gestureEvent.tapCount(), fakeMouseUp);
1932 } 1954 }
1933 m_clickNode = nullptr; 1955 m_clickNode = nullptr;
1934 } 1956 }
1935 1957
1936 if (mouseUpEventResult == WebInputEventResult::NotHandled) 1958 if (!m_suppressMouseEventsFromGestures && mouseUpEventResult == WebInputEven tResult::NotHandled)
Rick Byers 2016/06/09 16:07:33 nit: you can simplify this slightly and have the e
mustaq 2016/06/09 16:41:03 Done. Dave, are you okay with this? This only aff
dtapuska 2016/06/09 16:55:02 That is alright. Like I said we could interpret it
1937 mouseUpEventResult = handleMouseReleaseEvent(MouseEventWithHitTestResult s(fakeMouseUp, currentHitTest)); 1959 mouseUpEventResult = handleMouseReleaseEvent(MouseEventWithHitTestResult s(fakeMouseUp, currentHitTest));
1938 1960
1939 WebInputEventResult eventResult = mergeEventResult(mergeEventResult(mouseDow nEventResult, mouseUpEventResult), clickEventResult); 1961 WebInputEventResult eventResult = mergeEventResult(mergeEventResult(mouseDow nEventResult, mouseUpEventResult), clickEventResult);
1940 if (eventResult == WebInputEventResult::NotHandled && tappedNode && m_frame- >page()) { 1962 if (eventResult == WebInputEventResult::NotHandled && tappedNode && m_frame- >page()) {
1941 bool domTreeChanged = preDispatchDomTreeVersion != m_frame->document()-> domTreeVersion(); 1963 bool domTreeChanged = preDispatchDomTreeVersion != m_frame->document()-> domTreeVersion();
1942 bool styleChanged = preDispatchStyleVersion != m_frame->document()->styl eVersion(); 1964 bool styleChanged = preDispatchStyleVersion != m_frame->document()->styl eVersion();
1943 1965
1944 IntPoint tappedPositionInViewport = frameHost()->visualViewport().rootFr ameToViewport(tappedPosition); 1966 IntPoint tappedPositionInViewport = frameHost()->visualViewport().rootFr ameToViewport(tappedPosition);
1945 m_frame->chromeClient().showUnhandledTapUIIfNeeded(tappedPositionInViewp ort, tappedNode, domTreeChanged || styleChanged); 1967 m_frame->chromeClient().showUnhandledTapUIIfNeeded(tappedPositionInViewp ort, tappedNode, domTreeChanged || styleChanged);
1946 } 1968 }
1947 return eventResult; 1969 return eventResult;
1948 } 1970 }
1949 1971
1950 WebInputEventResult EventHandler::handleGestureLongPress(const GestureEventWithH itTestResults& targetedEvent) 1972 WebInputEventResult EventHandler::handleGestureLongPress(const GestureEventWithH itTestResults& targetedEvent)
1951 { 1973 {
1952 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); 1974 const PlatformGestureEvent& gestureEvent = targetedEvent.event();
1953 IntPoint adjustedPoint = gestureEvent.position(); 1975 IntPoint adjustedPoint = gestureEvent.position();
1954 1976
1955 unsigned modifiers = gestureEvent.getModifiers(); 1977 unsigned modifiers = gestureEvent.getModifiers();
1956 1978
1957 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests here (re-using the 1979 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests here (re-using the
1958 // supplied HitTestResult), but that will require some overhaul of the touch drag-and-drop code 1980 // supplied HitTestResult), but that will require some overhaul of the touch drag-and-drop code
1959 // and LongPress is such a special scenario that it's unlikely to matter muc h in practice. 1981 // and LongPress is such a special scenario that it's unlikely to matter muc h in practice.
1960 1982
1961 m_longTapShouldInvokeContextMenu = false; 1983 m_longTapShouldInvokeContextMenu = false;
1962 if (m_frame->settings() && m_frame->settings()->touchDragDropEnabled() && m_ frame->view()) { 1984 if (m_frame->settings() && m_frame->settings()->touchDragDropEnabled() && m_ frame->view()) {
1985 // TODO(mustaq): Suppressing long-tap MouseEvents could break
1986 // drag-drop. Will do separately because of the risk. crbug.com/606938.
1963 PlatformMouseEvent mouseDownEvent(adjustedPoint, gestureEvent.globalPosi tion(), LeftButton, PlatformEvent::MousePressed, 1, 1987 PlatformMouseEvent mouseDownEvent(adjustedPoint, gestureEvent.globalPosi tion(), LeftButton, PlatformEvent::MousePressed, 1,
1964 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::Lef tButtonDown), 1988 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::Lef tButtonDown),
1965 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime(), W ebPointerProperties::PointerType::Mouse); 1989 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime(), W ebPointerProperties::PointerType::Mouse);
1966 m_mouseDown = mouseDownEvent; 1990 m_mouseDown = mouseDownEvent;
1967 1991
1968 PlatformMouseEvent mouseDragEvent(adjustedPoint, gestureEvent.globalPosi tion(), LeftButton, PlatformEvent::MouseMoved, 1, 1992 PlatformMouseEvent mouseDragEvent(adjustedPoint, gestureEvent.globalPosi tion(), LeftButton, PlatformEvent::MouseMoved, 1,
1969 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::Lef tButtonDown), 1993 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::Lef tButtonDown),
1970 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime(), W ebPointerProperties::PointerType::Mouse); 1994 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime(), W ebPointerProperties::PointerType::Mouse);
1971 HitTestRequest request(HitTestRequest::ReadOnly); 1995 HitTestRequest request(HitTestRequest::ReadOnly);
1972 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDragE vent); 1996 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDragE vent);
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
3082 if (!rect.contains(roundedIntPoint(point))) 3106 if (!rect.contains(roundedIntPoint(point)))
3083 return result; 3107 return result;
3084 } 3108 }
3085 frame->contentLayoutItem().hitTest(result); 3109 frame->contentLayoutItem().hitTest(result);
3086 return result; 3110 return result;
3087 } 3111 }
3088 3112
3089 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt) 3113 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt)
3090 { 3114 {
3091 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); 3115 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent");
3092
3093 return m_pointerEventManager.handleTouchEvents(event); 3116 return m_pointerEventManager.handleTouchEvents(event);
3094 } 3117 }
3095 3118
3096 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) 3119 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event)
3097 { 3120 {
3098 m_mousePositionIsUnknown = false; 3121 m_mousePositionIsUnknown = false;
3099 m_lastKnownMousePosition = event.position(); 3122 m_lastKnownMousePosition = event.position();
3100 m_lastKnownMouseGlobalPosition = event.globalPosition(); 3123 m_lastKnownMouseGlobalPosition = event.globalPosition();
3101 } 3124 }
3102 3125
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3151 3174
3152 FrameHost* EventHandler::frameHost() const 3175 FrameHost* EventHandler::frameHost() const
3153 { 3176 {
3154 if (!m_frame->page()) 3177 if (!m_frame->page())
3155 return nullptr; 3178 return nullptr;
3156 3179
3157 return &m_frame->page()->frameHost(); 3180 return &m_frame->page()->frameHost();
3158 } 3181 }
3159 3182
3160 } // namespace blink 3183 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698