| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 #include "core/input/EventHandler.h" | 29 #include "core/input/EventHandler.h" |
| 30 | 30 |
| 31 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 31 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 32 #include "core/HTMLNames.h" | 32 #include "core/HTMLNames.h" |
| 33 #include "core/InputTypeNames.h" | 33 #include "core/InputTypeNames.h" |
| 34 #include "core/clipboard/DataTransfer.h" | 34 #include "core/clipboard/DataTransfer.h" |
| 35 #include "core/dom/DOMNodeIds.h" | 35 #include "core/dom/DOMNodeIds.h" |
| 36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
| 37 #include "core/dom/DocumentUserGestureToken.h" | 37 #include "core/dom/DocumentUserGestureToken.h" |
| 38 #include "core/dom/TaskRunnerHelper.h" |
| 38 #include "core/dom/TouchList.h" | 39 #include "core/dom/TouchList.h" |
| 39 #include "core/dom/shadow/FlatTreeTraversal.h" | 40 #include "core/dom/shadow/FlatTreeTraversal.h" |
| 40 #include "core/dom/shadow/ShadowRoot.h" | 41 #include "core/dom/shadow/ShadowRoot.h" |
| 41 #include "core/editing/EditingUtilities.h" | 42 #include "core/editing/EditingUtilities.h" |
| 42 #include "core/editing/Editor.h" | 43 #include "core/editing/Editor.h" |
| 43 #include "core/editing/FrameSelection.h" | 44 #include "core/editing/FrameSelection.h" |
| 44 #include "core/editing/SelectionController.h" | 45 #include "core/editing/SelectionController.h" |
| 45 #include "core/events/EventPath.h" | 46 #include "core/events/EventPath.h" |
| 46 #include "core/events/GestureEvent.h" | 47 #include "core/events/GestureEvent.h" |
| 47 #include "core/events/KeyboardEvent.h" | 48 #include "core/events/KeyboardEvent.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 const Cursor& cursor() const { | 154 const Cursor& cursor() const { |
| 154 ASSERT(m_isCursorChange); | 155 ASSERT(m_isCursorChange); |
| 155 return m_cursor; | 156 return m_cursor; |
| 156 } | 157 } |
| 157 | 158 |
| 158 private: | 159 private: |
| 159 bool m_isCursorChange; | 160 bool m_isCursorChange; |
| 160 Cursor m_cursor; | 161 Cursor m_cursor; |
| 161 }; | 162 }; |
| 162 | 163 |
| 163 EventHandler::EventHandler(LocalFrame* frame) | 164 EventHandler::EventHandler(LocalFrame& frame) |
| 164 : m_frame(frame), | 165 : m_frame(frame), |
| 165 m_selectionController(SelectionController::create(*frame)), | 166 m_selectionController(SelectionController::create(frame)), |
| 166 m_hoverTimer(this, &EventHandler::hoverTimerFired), | 167 m_hoverTimer(TaskRunnerHelper::get(TaskType::UserInteraction, &frame), |
| 167 m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired), | 168 this, |
| 169 &EventHandler::hoverTimerFired), |
| 170 m_cursorUpdateTimer(TaskRunnerHelper::get(TaskType::Internal, &frame), |
| 171 this, |
| 172 &EventHandler::cursorUpdateTimerFired), |
| 168 m_eventHandlerWillResetCapturingMouseEventsNode(0), | 173 m_eventHandlerWillResetCapturingMouseEventsNode(0), |
| 169 m_shouldOnlyFireDragOverEvent(false), | 174 m_shouldOnlyFireDragOverEvent(false), |
| 170 m_scrollManager(new ScrollManager(frame)), | 175 m_scrollManager(new ScrollManager(frame)), |
| 171 m_mouseEventManager(new MouseEventManager(frame, m_scrollManager)), | 176 m_mouseEventManager(new MouseEventManager(frame, *m_scrollManager)), |
| 172 m_keyboardEventManager(new KeyboardEventManager(frame, m_scrollManager)), | 177 m_keyboardEventManager(new KeyboardEventManager(frame, *m_scrollManager)), |
| 173 m_pointerEventManager( | 178 m_pointerEventManager( |
| 174 new PointerEventManager(frame, m_mouseEventManager)), | 179 new PointerEventManager(frame, *m_mouseEventManager)), |
| 175 m_gestureManager(new GestureManager(frame, | 180 m_gestureManager(new GestureManager(frame, |
| 176 m_scrollManager, | 181 *m_scrollManager, |
| 177 m_mouseEventManager, | 182 *m_mouseEventManager, |
| 178 m_pointerEventManager, | 183 *m_pointerEventManager, |
| 179 m_selectionController)), | 184 *m_selectionController)), |
| 180 m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) {} | 185 m_activeIntervalTimer( |
| 186 TaskRunnerHelper::get(TaskType::UserInteraction, &frame), |
| 187 this, |
| 188 &EventHandler::activeIntervalTimerFired) {} |
| 181 | 189 |
| 182 DEFINE_TRACE(EventHandler) { | 190 DEFINE_TRACE(EventHandler) { |
| 183 visitor->trace(m_frame); | 191 visitor->trace(m_frame); |
| 184 visitor->trace(m_selectionController); | 192 visitor->trace(m_selectionController); |
| 185 visitor->trace(m_capturingMouseEventsNode); | 193 visitor->trace(m_capturingMouseEventsNode); |
| 186 visitor->trace(m_lastMouseMoveEventSubframe); | 194 visitor->trace(m_lastMouseMoveEventSubframe); |
| 187 visitor->trace(m_lastScrollbarUnderMouse); | 195 visitor->trace(m_lastScrollbarUnderMouse); |
| 188 visitor->trace(m_dragTarget); | 196 visitor->trace(m_dragTarget); |
| 189 visitor->trace(m_frameSetBeingResized); | 197 visitor->trace(m_frameSetBeingResized); |
| 190 visitor->trace(m_scrollManager); | 198 visitor->trace(m_scrollManager); |
| (...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1661 hitTestResultForGestureEvent(gestureEvent, hitType); | 1669 hitTestResultForGestureEvent(gestureEvent, hitType); |
| 1662 // Now apply hover/active state to the final target. | 1670 // Now apply hover/active state to the final target. |
| 1663 HitTestRequest request(hitType | HitTestRequest::AllowChildFrameContent); | 1671 HitTestRequest request(hitType | HitTestRequest::AllowChildFrameContent); |
| 1664 if (!request.readOnly()) | 1672 if (!request.readOnly()) |
| 1665 updateGestureHoverActiveState( | 1673 updateGestureHoverActiveState( |
| 1666 request, eventWithHitTestResults.hitTestResult().innerElement()); | 1674 request, eventWithHitTestResults.hitTestResult().innerElement()); |
| 1667 | 1675 |
| 1668 if (shouldKeepActiveForMinInterval) { | 1676 if (shouldKeepActiveForMinInterval) { |
| 1669 m_lastDeferredTapElement = | 1677 m_lastDeferredTapElement = |
| 1670 eventWithHitTestResults.hitTestResult().innerElement(); | 1678 eventWithHitTestResults.hitTestResult().innerElement(); |
| 1679 // TODO(https://crbug.com/668758): Use a normal BeginFrame update for this. |
| 1671 m_activeIntervalTimer.startOneShot(minimumActiveInterval - activeInterval, | 1680 m_activeIntervalTimer.startOneShot(minimumActiveInterval - activeInterval, |
| 1672 BLINK_FROM_HERE); | 1681 BLINK_FROM_HERE); |
| 1673 } | 1682 } |
| 1674 | 1683 |
| 1675 return eventWithHitTestResults; | 1684 return eventWithHitTestResults; |
| 1676 } | 1685 } |
| 1677 | 1686 |
| 1678 GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent( | 1687 GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent( |
| 1679 const PlatformGestureEvent& gestureEvent, | 1688 const PlatformGestureEvent& gestureEvent, |
| 1680 HitTestRequest::HitTestRequestType hitType) { | 1689 HitTestRequest::HitTestRequestType hitType) { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1871 locationInRootFrame, globalPosition, | 1880 locationInRootFrame, globalPosition, |
| 1872 WebPointerProperties::Button::NoButton, eventType, /* clickCount */ 0, | 1881 WebPointerProperties::Button::NoButton, eventType, /* clickCount */ 0, |
| 1873 PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable, | 1882 PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable, |
| 1874 WTF::monotonicallyIncreasingTime(), | 1883 WTF::monotonicallyIncreasingTime(), |
| 1875 WebPointerProperties::PointerType::Mouse); | 1884 WebPointerProperties::PointerType::Mouse); |
| 1876 | 1885 |
| 1877 return sendContextMenuEvent(mouseEvent, overrideTargetElement); | 1886 return sendContextMenuEvent(mouseEvent, overrideTargetElement); |
| 1878 } | 1887 } |
| 1879 | 1888 |
| 1880 void EventHandler::scheduleHoverStateUpdate() { | 1889 void EventHandler::scheduleHoverStateUpdate() { |
| 1890 // TODO(https://crbug.com/668758): Use a normal BeginFrame update for this. |
| 1881 if (!m_hoverTimer.isActive()) | 1891 if (!m_hoverTimer.isActive()) |
| 1882 m_hoverTimer.startOneShot(0, BLINK_FROM_HERE); | 1892 m_hoverTimer.startOneShot(0, BLINK_FROM_HERE); |
| 1883 } | 1893 } |
| 1884 | 1894 |
| 1885 void EventHandler::scheduleCursorUpdate() { | 1895 void EventHandler::scheduleCursorUpdate() { |
| 1886 // We only want one timer for the page, rather than each frame having it's own | 1896 // We only want one timer for the page, rather than each frame having it's own |
| 1887 // timer competing which eachother (since there's only one mouse cursor). | 1897 // timer competing which eachother (since there's only one mouse cursor). |
| 1888 ASSERT(m_frame == m_frame->localFrameRoot()); | 1898 ASSERT(m_frame == m_frame->localFrameRoot()); |
| 1889 | 1899 |
| 1900 // TODO(https://crbug.com/668758): Use a normal BeginFrame update for this. |
| 1890 if (!m_cursorUpdateTimer.isActive()) | 1901 if (!m_cursorUpdateTimer.isActive()) |
| 1891 m_cursorUpdateTimer.startOneShot(cursorUpdateInterval, BLINK_FROM_HERE); | 1902 m_cursorUpdateTimer.startOneShot(cursorUpdateInterval, BLINK_FROM_HERE); |
| 1892 } | 1903 } |
| 1893 | 1904 |
| 1894 bool EventHandler::cursorUpdatePending() { | 1905 bool EventHandler::cursorUpdatePending() { |
| 1895 return m_cursorUpdateTimer.isActive(); | 1906 return m_cursorUpdateTimer.isActive(); |
| 1896 } | 1907 } |
| 1897 | 1908 |
| 1898 void EventHandler::dispatchFakeMouseMoveEventSoon() { | 1909 void EventHandler::dispatchFakeMouseMoveEventSoon() { |
| 1899 m_mouseEventManager->dispatchFakeMouseMoveEventSoon(); | 1910 m_mouseEventManager->dispatchFakeMouseMoveEventSoon(); |
| 1900 } | 1911 } |
| 1901 | 1912 |
| 1902 void EventHandler::dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad& quad) { | 1913 void EventHandler::dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad& quad) { |
| 1903 m_mouseEventManager->dispatchFakeMouseMoveEventSoonInQuad(quad); | 1914 m_mouseEventManager->dispatchFakeMouseMoveEventSoonInQuad(quad); |
| 1904 } | 1915 } |
| 1905 | 1916 |
| 1906 void EventHandler::setResizingFrameSet(HTMLFrameSetElement* frameSet) { | 1917 void EventHandler::setResizingFrameSet(HTMLFrameSetElement* frameSet) { |
| 1907 m_frameSetBeingResized = frameSet; | 1918 m_frameSetBeingResized = frameSet; |
| 1908 } | 1919 } |
| 1909 | 1920 |
| 1910 void EventHandler::resizeScrollableAreaDestroyed() { | 1921 void EventHandler::resizeScrollableAreaDestroyed() { |
| 1911 m_scrollManager->clearResizeScrollableArea(true); | 1922 m_scrollManager->clearResizeScrollableArea(true); |
| 1912 } | 1923 } |
| 1913 | 1924 |
| 1914 void EventHandler::hoverTimerFired(TimerBase*) { | 1925 void EventHandler::hoverTimerFired(TimerBase*) { |
| 1915 TRACE_EVENT0("input", "EventHandler::hoverTimerFired"); | 1926 TRACE_EVENT0("input", "EventHandler::hoverTimerFired"); |
| 1916 m_hoverTimer.stop(); | |
| 1917 | 1927 |
| 1918 ASSERT(m_frame); | 1928 ASSERT(m_frame); |
| 1919 ASSERT(m_frame->document()); | 1929 ASSERT(m_frame->document()); |
| 1920 | 1930 |
| 1921 if (LayoutViewItem layoutItem = m_frame->contentLayoutItem()) { | 1931 if (LayoutViewItem layoutItem = m_frame->contentLayoutItem()) { |
| 1922 if (FrameView* view = m_frame->view()) { | 1932 if (FrameView* view = m_frame->view()) { |
| 1923 HitTestRequest request(HitTestRequest::Move); | 1933 HitTestRequest request(HitTestRequest::Move); |
| 1924 HitTestResult result(request, | 1934 HitTestResult result(request, |
| 1925 view->rootFrameToContents( | 1935 view->rootFrameToContents( |
| 1926 m_mouseEventManager->lastKnownMousePosition())); | 1936 m_mouseEventManager->lastKnownMousePosition())); |
| 1927 layoutItem.hitTest(result); | 1937 layoutItem.hitTest(result); |
| 1928 m_frame->document()->updateHoverActiveState( | 1938 m_frame->document()->updateHoverActiveState( |
| 1929 request, result.innerElement(), result.scrollbar()); | 1939 request, result.innerElement(), result.scrollbar()); |
| 1930 } | 1940 } |
| 1931 } | 1941 } |
| 1932 } | 1942 } |
| 1933 | 1943 |
| 1934 void EventHandler::activeIntervalTimerFired(TimerBase*) { | 1944 void EventHandler::activeIntervalTimerFired(TimerBase*) { |
| 1935 TRACE_EVENT0("input", "EventHandler::activeIntervalTimerFired"); | 1945 TRACE_EVENT0("input", "EventHandler::activeIntervalTimerFired"); |
| 1936 m_activeIntervalTimer.stop(); | |
| 1937 | 1946 |
| 1938 if (m_frame && m_frame->document() && m_lastDeferredTapElement) { | 1947 if (m_frame && m_frame->document() && m_lastDeferredTapElement) { |
| 1939 // FIXME: Enable condition when http://crbug.com/226842 lands | 1948 // FIXME: Enable condition when http://crbug.com/226842 lands |
| 1940 // m_lastDeferredTapElement.get() == m_frame->document()->activeElement() | 1949 // m_lastDeferredTapElement.get() == m_frame->document()->activeElement() |
| 1941 HitTestRequest request(HitTestRequest::TouchEvent | | 1950 HitTestRequest request(HitTestRequest::TouchEvent | |
| 1942 HitTestRequest::Release); | 1951 HitTestRequest::Release); |
| 1943 m_frame->document()->updateHoverActiveState( | 1952 m_frame->document()->updateHoverActiveState( |
| 1944 request, m_lastDeferredTapElement.get(), nullptr); | 1953 request, m_lastDeferredTapElement.get(), nullptr); |
| 1945 } | 1954 } |
| 1946 m_lastDeferredTapElement = nullptr; | 1955 m_lastDeferredTapElement = nullptr; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2102 } | 2111 } |
| 2103 | 2112 |
| 2104 FrameHost* EventHandler::frameHost() const { | 2113 FrameHost* EventHandler::frameHost() const { |
| 2105 if (!m_frame->page()) | 2114 if (!m_frame->page()) |
| 2106 return nullptr; | 2115 return nullptr; |
| 2107 | 2116 |
| 2108 return &m_frame->page()->frameHost(); | 2117 return &m_frame->page()->frameHost(); |
| 2109 } | 2118 } |
| 2110 | 2119 |
| 2111 } // namespace blink | 2120 } // namespace blink |
| OLD | NEW |