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

Side by Side Diff: third_party/WebKit/Source/core/frame/EventHandlerRegistry.cpp

Issue 1895303007: Non passive touch end or touch cancel listeners should not block scroll. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 8 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/frame/EventHandlerRegistry.h" 5 #include "core/frame/EventHandlerRegistry.h"
6 6
7 #include "core/events/EventListenerOptions.h" 7 #include "core/events/EventListenerOptions.h"
8 #include "core/frame/LocalDOMWindow.h" 8 #include "core/frame/LocalDOMWindow.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/html/HTMLFrameOwnerElement.h" 10 #include "core/html/HTMLFrameOwnerElement.h"
11 #include "core/page/ChromeClient.h" 11 #include "core/page/ChromeClient.h"
12 #include "core/page/Page.h" 12 #include "core/page/Page.h"
13 #include "core/page/scrolling/ScrollingCoordinator.h" 13 #include "core/page/scrolling/ScrollingCoordinator.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 namespace { 17 namespace {
18 18
19 inline bool isTouchEventType(const AtomicString& eventType)
20 {
21 return eventType == EventTypeNames::touchstart
22 || eventType == EventTypeNames::touchmove
23 || eventType == EventTypeNames::touchend
24 || eventType == EventTypeNames::touchcancel;
25 }
26
27 inline bool isPointerEventType(const AtomicString& eventType) 19 inline bool isPointerEventType(const AtomicString& eventType)
28 { 20 {
29 return eventType == EventTypeNames::gotpointercapture 21 return eventType == EventTypeNames::gotpointercapture
30 || eventType == EventTypeNames::lostpointercapture 22 || eventType == EventTypeNames::lostpointercapture
31 || eventType == EventTypeNames::pointercancel 23 || eventType == EventTypeNames::pointercancel
32 || eventType == EventTypeNames::pointerdown 24 || eventType == EventTypeNames::pointerdown
33 || eventType == EventTypeNames::pointerenter 25 || eventType == EventTypeNames::pointerenter
34 || eventType == EventTypeNames::pointerleave 26 || eventType == EventTypeNames::pointerleave
35 || eventType == EventTypeNames::pointermove 27 || eventType == EventTypeNames::pointermove
36 || eventType == EventTypeNames::pointerout 28 || eventType == EventTypeNames::pointerout
(...skipping 23 matching lines...) Expand all
60 { 52 {
61 checkConsistency(); 53 checkConsistency();
62 } 54 }
63 55
64 bool EventHandlerRegistry::eventTypeToClass(const AtomicString& eventType, const EventListenerOptions& options, EventHandlerClass* result) 56 bool EventHandlerRegistry::eventTypeToClass(const AtomicString& eventType, const EventListenerOptions& options, EventHandlerClass* result)
65 { 57 {
66 if (eventType == EventTypeNames::scroll) { 58 if (eventType == EventTypeNames::scroll) {
67 *result = ScrollEvent; 59 *result = ScrollEvent;
68 } else if (eventType == EventTypeNames::wheel || eventType == EventTypeNames ::mousewheel) { 60 } else if (eventType == EventTypeNames::wheel || eventType == EventTypeNames ::mousewheel) {
69 *result = options.passive() ? WheelEventPassive : WheelEventBlocking; 61 *result = options.passive() ? WheelEventPassive : WheelEventBlocking;
70 } else if (isTouchEventType(eventType)) { 62 } else if (eventType == EventTypeNames::touchend || eventType == EventTypeNa mes::touchcancel) {
71 *result = options.passive() ? TouchEventPassive : TouchEventBlocking; 63 *result = options.passive() ? TouchEndOrCancelEventPassive : TouchEndOrC ancelEventBlocking;
64 } else if (eventType == EventTypeNames::touchstart || eventType == EventType Names::touchmove) {
65 *result = options.passive() ? TouchStartOrMoveEventPassive : TouchStartO rMoveEventBlocking;
72 } else if (isPointerEventType(eventType)) { 66 } else if (isPointerEventType(eventType)) {
73 // The EventHandlerClass is TouchEventPassive since the pointer events 67 // The EventHandlerClass is TouchStartOrMoveEventPassive since
74 // never block scrolling and the compositor only needs to know 68 // the pointer events never block scrolling and the compositor
75 // about the touch listeners. 69 // only needs to know about the touch listeners.
76 *result = TouchEventPassive; 70 *result = TouchStartOrMoveEventPassive;
77 #if ENABLE(ASSERT) 71 #if ENABLE(ASSERT)
78 } else if (eventType == EventTypeNames::load || eventType == EventTypeNames: :mousemove || eventType == EventTypeNames::touchstart) { 72 } else if (eventType == EventTypeNames::load || eventType == EventTypeNames: :mousemove || eventType == EventTypeNames::touchstart) {
79 *result = EventsForTesting; 73 *result = EventsForTesting;
80 #endif 74 #endif
81 } else { 75 } else {
82 return false; 76 return false;
83 } 77 }
84 return true; 78 return true;
85 } 79 }
86 80
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 for (size_t i = 0; i < EventHandlerClassCount; ++i) { 200 for (size_t i = 0; i < EventHandlerClassCount; ++i) {
207 EventHandlerClass handlerClass = static_cast<EventHandlerClass>(i); 201 EventHandlerClass handlerClass = static_cast<EventHandlerClass>(i);
208 updateEventHandlerInternal(RemoveAll, handlerClass, &target); 202 updateEventHandlerInternal(RemoveAll, handlerClass, &target);
209 } 203 }
210 } 204 }
211 205
212 void EventHandlerRegistry::notifyHasHandlersChanged(EventHandlerClass handlerCla ss, bool hasActiveHandlers) 206 void EventHandlerRegistry::notifyHasHandlersChanged(EventHandlerClass handlerCla ss, bool hasActiveHandlers)
213 { 207 {
214 switch (handlerClass) { 208 switch (handlerClass) {
215 case ScrollEvent: 209 case ScrollEvent:
216 m_frameHost->chromeClient().setHaveScrollEventHandlers(hasActiveHandlers ); 210 m_frameHost->chromeClient().setHasScrollEventHandlers(hasActiveHandlers) ;
217 break; 211 break;
218 case WheelEventBlocking: 212 case WheelEventBlocking:
219 case WheelEventPassive: 213 case WheelEventPassive:
220 m_frameHost->chromeClient().setEventListenerProperties(WebEventListenerC lass::MouseWheel, webEventListenerProperties(hasEventHandlers(WheelEventBlocking ), hasEventHandlers(WheelEventPassive))); 214 m_frameHost->chromeClient().setEventListenerProperties(WebEventListenerC lass::MouseWheel, webEventListenerProperties(hasEventHandlers(WheelEventBlocking ), hasEventHandlers(WheelEventPassive)));
221 break; 215 break;
222 case TouchEventBlocking: 216 case TouchStartOrMoveEventBlocking:
223 case TouchEventPassive: 217 case TouchStartOrMoveEventPassive:
224 m_frameHost->chromeClient().setEventListenerProperties(WebEventListenerC lass::Touch, webEventListenerProperties(hasEventHandlers(TouchEventBlocking), ha sEventHandlers(TouchEventPassive))); 218 m_frameHost->chromeClient().setEventListenerProperties(WebEventListenerC lass::TouchStartOrMove, webEventListenerProperties(hasEventHandlers(TouchStartOr MoveEventBlocking), hasEventHandlers(TouchStartOrMoveEventPassive)));
219 break;
220 case TouchEndOrCancelEventBlocking:
221 case TouchEndOrCancelEventPassive:
222 m_frameHost->chromeClient().setEventListenerProperties(WebEventListenerC lass::TouchEndOrCancel, webEventListenerProperties(hasEventHandlers(TouchEndOrCa ncelEventBlocking), hasEventHandlers(TouchEndOrCancelEventPassive)));
225 break; 223 break;
226 #if ENABLE(ASSERT) 224 #if ENABLE(ASSERT)
227 case EventsForTesting: 225 case EventsForTesting:
228 break; 226 break;
229 #endif 227 #endif
230 default: 228 default:
231 ASSERT_NOT_REACHED(); 229 ASSERT_NOT_REACHED();
232 break; 230 break;
233 } 231 }
234 } 232 }
235 233
236 void EventHandlerRegistry::notifyDidAddOrRemoveEventHandlerTarget(EventHandlerCl ass handlerClass) 234 void EventHandlerRegistry::notifyDidAddOrRemoveEventHandlerTarget(EventHandlerCl ass handlerClass)
237 { 235 {
238 ScrollingCoordinator* scrollingCoordinator = m_frameHost->page().scrollingCo ordinator(); 236 ScrollingCoordinator* scrollingCoordinator = m_frameHost->page().scrollingCo ordinator();
239 if (scrollingCoordinator && handlerClass == TouchEventBlocking) 237 if (scrollingCoordinator && handlerClass == TouchStartOrMoveEventBlocking)
240 scrollingCoordinator->touchEventTargetRectsDidChange(); 238 scrollingCoordinator->touchEventTargetRectsDidChange();
241 } 239 }
242 240
243 DEFINE_TRACE(EventHandlerRegistry) 241 DEFINE_TRACE(EventHandlerRegistry)
244 { 242 {
245 visitor->trace(m_frameHost); 243 visitor->trace(m_frameHost);
246 visitor->template registerWeakMembers<EventHandlerRegistry, &EventHandlerReg istry::clearWeakMembers>(this); 244 visitor->template registerWeakMembers<EventHandlerRegistry, &EventHandlerReg istry::clearWeakMembers>(this);
247 } 245 }
248 246
249 void EventHandlerRegistry::clearWeakMembers(Visitor* visitor) 247 void EventHandlerRegistry::clearWeakMembers(Visitor* visitor)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 ASSERT(window->frame()); 308 ASSERT(window->frame());
311 ASSERT(window->frame()->host()); 309 ASSERT(window->frame()->host());
312 ASSERT(window->frame()->host() == m_frameHost); 310 ASSERT(window->frame()->host() == m_frameHost);
313 } 311 }
314 } 312 }
315 } 313 }
316 #endif // ENABLE(ASSERT) 314 #endif // ENABLE(ASSERT)
317 } 315 }
318 316
319 } // namespace blink 317 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/EventHandlerRegistry.h ('k') | third_party/WebKit/Source/core/html/HTMLInputElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698