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

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

Issue 2541073004: ABANDONED CL: Revert of Move EventHandler timers to per-frame task queues. (Closed)
Patch Set: Created 4 years 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 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
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"
39 #include "core/dom/TouchList.h" 38 #include "core/dom/TouchList.h"
40 #include "core/dom/shadow/FlatTreeTraversal.h" 39 #include "core/dom/shadow/FlatTreeTraversal.h"
41 #include "core/dom/shadow/ShadowRoot.h" 40 #include "core/dom/shadow/ShadowRoot.h"
42 #include "core/editing/EditingUtilities.h" 41 #include "core/editing/EditingUtilities.h"
43 #include "core/editing/Editor.h" 42 #include "core/editing/Editor.h"
44 #include "core/editing/FrameSelection.h" 43 #include "core/editing/FrameSelection.h"
45 #include "core/editing/SelectionController.h" 44 #include "core/editing/SelectionController.h"
46 #include "core/events/EventPath.h" 45 #include "core/events/EventPath.h"
47 #include "core/events/GestureEvent.h" 46 #include "core/events/GestureEvent.h"
48 #include "core/events/KeyboardEvent.h" 47 #include "core/events/KeyboardEvent.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 const Cursor& cursor() const { 153 const Cursor& cursor() const {
155 ASSERT(m_isCursorChange); 154 ASSERT(m_isCursorChange);
156 return m_cursor; 155 return m_cursor;
157 } 156 }
158 157
159 private: 158 private:
160 bool m_isCursorChange; 159 bool m_isCursorChange;
161 Cursor m_cursor; 160 Cursor m_cursor;
162 }; 161 };
163 162
164 EventHandler::EventHandler(LocalFrame& frame) 163 EventHandler::EventHandler(LocalFrame* frame)
165 : m_frame(frame), 164 : m_frame(frame),
166 m_selectionController(SelectionController::create(frame)), 165 m_selectionController(SelectionController::create(*frame)),
167 m_hoverTimer(TaskRunnerHelper::get(TaskType::UserInteraction, &frame), 166 m_hoverTimer(this, &EventHandler::hoverTimerFired),
168 this, 167 m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired),
169 &EventHandler::hoverTimerFired),
170 m_cursorUpdateTimer(TaskRunnerHelper::get(TaskType::Internal, &frame),
171 this,
172 &EventHandler::cursorUpdateTimerFired),
173 m_eventHandlerWillResetCapturingMouseEventsNode(0), 168 m_eventHandlerWillResetCapturingMouseEventsNode(0),
174 m_shouldOnlyFireDragOverEvent(false), 169 m_shouldOnlyFireDragOverEvent(false),
175 m_scrollManager(new ScrollManager(frame)), 170 m_scrollManager(new ScrollManager(frame)),
176 m_mouseEventManager(new MouseEventManager(frame, *m_scrollManager)), 171 m_mouseEventManager(new MouseEventManager(frame, m_scrollManager)),
177 m_keyboardEventManager(new KeyboardEventManager(frame, *m_scrollManager)), 172 m_keyboardEventManager(new KeyboardEventManager(frame, m_scrollManager)),
178 m_pointerEventManager( 173 m_pointerEventManager(
179 new PointerEventManager(frame, *m_mouseEventManager)), 174 new PointerEventManager(frame, m_mouseEventManager)),
180 m_gestureManager(new GestureManager(frame, 175 m_gestureManager(new GestureManager(frame,
181 *m_scrollManager, 176 m_scrollManager,
182 *m_mouseEventManager, 177 m_mouseEventManager,
183 *m_pointerEventManager, 178 m_pointerEventManager,
184 *m_selectionController)), 179 m_selectionController)),
185 m_activeIntervalTimer( 180 m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) {}
186 TaskRunnerHelper::get(TaskType::UserInteraction, &frame),
187 this,
188 &EventHandler::activeIntervalTimerFired) {}
189 181
190 DEFINE_TRACE(EventHandler) { 182 DEFINE_TRACE(EventHandler) {
191 visitor->trace(m_frame); 183 visitor->trace(m_frame);
192 visitor->trace(m_selectionController); 184 visitor->trace(m_selectionController);
193 visitor->trace(m_capturingMouseEventsNode); 185 visitor->trace(m_capturingMouseEventsNode);
194 visitor->trace(m_lastMouseMoveEventSubframe); 186 visitor->trace(m_lastMouseMoveEventSubframe);
195 visitor->trace(m_lastScrollbarUnderMouse); 187 visitor->trace(m_lastScrollbarUnderMouse);
196 visitor->trace(m_dragTarget); 188 visitor->trace(m_dragTarget);
197 visitor->trace(m_frameSetBeingResized); 189 visitor->trace(m_frameSetBeingResized);
198 visitor->trace(m_scrollManager); 190 visitor->trace(m_scrollManager);
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1669 hitTestResultForGestureEvent(gestureEvent, hitType); 1661 hitTestResultForGestureEvent(gestureEvent, hitType);
1670 // Now apply hover/active state to the final target. 1662 // Now apply hover/active state to the final target.
1671 HitTestRequest request(hitType | HitTestRequest::AllowChildFrameContent); 1663 HitTestRequest request(hitType | HitTestRequest::AllowChildFrameContent);
1672 if (!request.readOnly()) 1664 if (!request.readOnly())
1673 updateGestureHoverActiveState( 1665 updateGestureHoverActiveState(
1674 request, eventWithHitTestResults.hitTestResult().innerElement()); 1666 request, eventWithHitTestResults.hitTestResult().innerElement());
1675 1667
1676 if (shouldKeepActiveForMinInterval) { 1668 if (shouldKeepActiveForMinInterval) {
1677 m_lastDeferredTapElement = 1669 m_lastDeferredTapElement =
1678 eventWithHitTestResults.hitTestResult().innerElement(); 1670 eventWithHitTestResults.hitTestResult().innerElement();
1679 // TODO(https://crbug.com/668758): Use a normal BeginFrame update for this.
1680 m_activeIntervalTimer.startOneShot(minimumActiveInterval - activeInterval, 1671 m_activeIntervalTimer.startOneShot(minimumActiveInterval - activeInterval,
1681 BLINK_FROM_HERE); 1672 BLINK_FROM_HERE);
1682 } 1673 }
1683 1674
1684 return eventWithHitTestResults; 1675 return eventWithHitTestResults;
1685 } 1676 }
1686 1677
1687 GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent( 1678 GestureEventWithHitTestResults EventHandler::hitTestResultForGestureEvent(
1688 const PlatformGestureEvent& gestureEvent, 1679 const PlatformGestureEvent& gestureEvent,
1689 HitTestRequest::HitTestRequestType hitType) { 1680 HitTestRequest::HitTestRequestType hitType) {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1880 locationInRootFrame, globalPosition, 1871 locationInRootFrame, globalPosition,
1881 WebPointerProperties::Button::NoButton, eventType, /* clickCount */ 0, 1872 WebPointerProperties::Button::NoButton, eventType, /* clickCount */ 0,
1882 PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable, 1873 PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable,
1883 WTF::monotonicallyIncreasingTime(), 1874 WTF::monotonicallyIncreasingTime(),
1884 WebPointerProperties::PointerType::Mouse); 1875 WebPointerProperties::PointerType::Mouse);
1885 1876
1886 return sendContextMenuEvent(mouseEvent, overrideTargetElement); 1877 return sendContextMenuEvent(mouseEvent, overrideTargetElement);
1887 } 1878 }
1888 1879
1889 void EventHandler::scheduleHoverStateUpdate() { 1880 void EventHandler::scheduleHoverStateUpdate() {
1890 // TODO(https://crbug.com/668758): Use a normal BeginFrame update for this.
1891 if (!m_hoverTimer.isActive()) 1881 if (!m_hoverTimer.isActive())
1892 m_hoverTimer.startOneShot(0, BLINK_FROM_HERE); 1882 m_hoverTimer.startOneShot(0, BLINK_FROM_HERE);
1893 } 1883 }
1894 1884
1895 void EventHandler::scheduleCursorUpdate() { 1885 void EventHandler::scheduleCursorUpdate() {
1896 // We only want one timer for the page, rather than each frame having it's own 1886 // We only want one timer for the page, rather than each frame having it's own
1897 // timer competing which eachother (since there's only one mouse cursor). 1887 // timer competing which eachother (since there's only one mouse cursor).
1898 ASSERT(m_frame == m_frame->localFrameRoot()); 1888 ASSERT(m_frame == m_frame->localFrameRoot());
1899 1889
1900 // TODO(https://crbug.com/668758): Use a normal BeginFrame update for this.
1901 if (!m_cursorUpdateTimer.isActive()) 1890 if (!m_cursorUpdateTimer.isActive())
1902 m_cursorUpdateTimer.startOneShot(cursorUpdateInterval, BLINK_FROM_HERE); 1891 m_cursorUpdateTimer.startOneShot(cursorUpdateInterval, BLINK_FROM_HERE);
1903 } 1892 }
1904 1893
1905 bool EventHandler::cursorUpdatePending() { 1894 bool EventHandler::cursorUpdatePending() {
1906 return m_cursorUpdateTimer.isActive(); 1895 return m_cursorUpdateTimer.isActive();
1907 } 1896 }
1908 1897
1909 void EventHandler::dispatchFakeMouseMoveEventSoon() { 1898 void EventHandler::dispatchFakeMouseMoveEventSoon() {
1910 m_mouseEventManager->dispatchFakeMouseMoveEventSoon(); 1899 m_mouseEventManager->dispatchFakeMouseMoveEventSoon();
1911 } 1900 }
1912 1901
1913 void EventHandler::dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad& quad) { 1902 void EventHandler::dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad& quad) {
1914 m_mouseEventManager->dispatchFakeMouseMoveEventSoonInQuad(quad); 1903 m_mouseEventManager->dispatchFakeMouseMoveEventSoonInQuad(quad);
1915 } 1904 }
1916 1905
1917 void EventHandler::setResizingFrameSet(HTMLFrameSetElement* frameSet) { 1906 void EventHandler::setResizingFrameSet(HTMLFrameSetElement* frameSet) {
1918 m_frameSetBeingResized = frameSet; 1907 m_frameSetBeingResized = frameSet;
1919 } 1908 }
1920 1909
1921 void EventHandler::resizeScrollableAreaDestroyed() { 1910 void EventHandler::resizeScrollableAreaDestroyed() {
1922 m_scrollManager->clearResizeScrollableArea(true); 1911 m_scrollManager->clearResizeScrollableArea(true);
1923 } 1912 }
1924 1913
1925 void EventHandler::hoverTimerFired(TimerBase*) { 1914 void EventHandler::hoverTimerFired(TimerBase*) {
1926 TRACE_EVENT0("input", "EventHandler::hoverTimerFired"); 1915 TRACE_EVENT0("input", "EventHandler::hoverTimerFired");
1916 m_hoverTimer.stop();
1927 1917
1928 ASSERT(m_frame); 1918 ASSERT(m_frame);
1929 ASSERT(m_frame->document()); 1919 ASSERT(m_frame->document());
1930 1920
1931 if (LayoutViewItem layoutItem = m_frame->contentLayoutItem()) { 1921 if (LayoutViewItem layoutItem = m_frame->contentLayoutItem()) {
1932 if (FrameView* view = m_frame->view()) { 1922 if (FrameView* view = m_frame->view()) {
1933 HitTestRequest request(HitTestRequest::Move); 1923 HitTestRequest request(HitTestRequest::Move);
1934 HitTestResult result(request, 1924 HitTestResult result(request,
1935 view->rootFrameToContents( 1925 view->rootFrameToContents(
1936 m_mouseEventManager->lastKnownMousePosition())); 1926 m_mouseEventManager->lastKnownMousePosition()));
1937 layoutItem.hitTest(result); 1927 layoutItem.hitTest(result);
1938 m_frame->document()->updateHoverActiveState( 1928 m_frame->document()->updateHoverActiveState(
1939 request, result.innerElement(), result.scrollbar()); 1929 request, result.innerElement(), result.scrollbar());
1940 } 1930 }
1941 } 1931 }
1942 } 1932 }
1943 1933
1944 void EventHandler::activeIntervalTimerFired(TimerBase*) { 1934 void EventHandler::activeIntervalTimerFired(TimerBase*) {
1945 TRACE_EVENT0("input", "EventHandler::activeIntervalTimerFired"); 1935 TRACE_EVENT0("input", "EventHandler::activeIntervalTimerFired");
1936 m_activeIntervalTimer.stop();
1946 1937
1947 if (m_frame && m_frame->document() && m_lastDeferredTapElement) { 1938 if (m_frame && m_frame->document() && m_lastDeferredTapElement) {
1948 // FIXME: Enable condition when http://crbug.com/226842 lands 1939 // FIXME: Enable condition when http://crbug.com/226842 lands
1949 // m_lastDeferredTapElement.get() == m_frame->document()->activeElement() 1940 // m_lastDeferredTapElement.get() == m_frame->document()->activeElement()
1950 HitTestRequest request(HitTestRequest::TouchEvent | 1941 HitTestRequest request(HitTestRequest::TouchEvent |
1951 HitTestRequest::Release); 1942 HitTestRequest::Release);
1952 m_frame->document()->updateHoverActiveState( 1943 m_frame->document()->updateHoverActiveState(
1953 request, m_lastDeferredTapElement.get(), nullptr); 1944 request, m_lastDeferredTapElement.get(), nullptr);
1954 } 1945 }
1955 m_lastDeferredTapElement = nullptr; 1946 m_lastDeferredTapElement = nullptr;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2111 } 2102 }
2112 2103
2113 FrameHost* EventHandler::frameHost() const { 2104 FrameHost* EventHandler::frameHost() const {
2114 if (!m_frame->page()) 2105 if (!m_frame->page())
2115 return nullptr; 2106 return nullptr;
2116 2107
2117 return &m_frame->page()->frameHost(); 2108 return &m_frame->page()->frameHost();
2118 } 2109 }
2119 2110
2120 } // namespace blink 2111 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/EventHandler.h ('k') | third_party/WebKit/Source/core/input/GestureManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698