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

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

Issue 2916893003: Bookkeep the pointer event listeners added to page (Closed)
Patch Set: fix rebase error Created 3 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 // 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 #ifndef EventHandlerRegistry_h 5 #ifndef EventHandlerRegistry_h
6 #define EventHandlerRegistry_h 6 #define EventHandlerRegistry_h
7 7
8 #include "core/CoreExport.h" // TODO(sashab): Remove this. 8 #include "core/CoreExport.h" // TODO(sashab): Remove this.
9 #include "core/page/Page.h" 9 #include "core/page/Page.h"
10 #include "platform/wtf/HashCountedSet.h" 10 #include "platform/wtf/HashCountedSet.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 class AddEventListenerOptions; 14 class AddEventListenerOptions;
15 class Document; 15 class Document;
16 class EventTarget; 16 class EventTarget;
17 class LocalFrame;
18 17
19 typedef HashCountedSet<UntracedMember<EventTarget>> EventTargetSet; 18 typedef HashCountedSet<UntracedMember<EventTarget>> EventTargetSet;
20 19
21 // Registry for keeping track of event handlers. Note that only handlers on 20 // Registry for keeping track of event handlers. Note that only handlers on
22 // documents that can be rendered or can receive input (i.e., are attached to a 21 // documents that can be rendered or can receive input (i.e., are attached to a
23 // Page) are registered here. 22 // Page) are registered here.
24 class CORE_EXPORT EventHandlerRegistry final 23 class CORE_EXPORT EventHandlerRegistry final
25 : public GarbageCollectedFinalized<EventHandlerRegistry> { 24 : public GarbageCollectedFinalized<EventHandlerRegistry> {
26 public: 25 public:
27 explicit EventHandlerRegistry(Page&); 26 explicit EventHandlerRegistry(Page&);
28 virtual ~EventHandlerRegistry(); 27 virtual ~EventHandlerRegistry();
29 28
30 // Supported event handler classes. Note that each one may correspond to 29 // Supported event handler classes. Note that each one may correspond to
31 // multiple event types. 30 // multiple event types.
32 enum EventHandlerClass { 31 enum EventHandlerClass {
33 kScrollEvent, 32 kScrollEvent,
34 kWheelEventBlocking, 33 kWheelEventBlocking,
35 kWheelEventPassive, 34 kWheelEventPassive,
36 kTouchStartOrMoveEventBlocking, 35 kTouchStartOrMoveEventBlocking,
37 kTouchStartOrMoveEventPassive, 36 kTouchStartOrMoveEventPassive,
38 kTouchEndOrCancelEventBlocking, 37 kTouchEndOrCancelEventBlocking,
39 kTouchEndOrCancelEventPassive, 38 kTouchEndOrCancelEventPassive,
39 kPointerEvent,
40 #if DCHECK_IS_ON() 40 #if DCHECK_IS_ON()
41 // Additional event categories for verifying handler tracking logic. 41 // Additional event categories for verifying handler tracking logic.
42 kEventsForTesting, 42 kEventsForTesting,
43 #endif 43 #endif
44 kEventHandlerClassCount, // Must be the last entry. 44 kEventHandlerClassCount, // Must be the last entry.
45 }; 45 };
46 46
47 // Returns true if the Page has event handlers of the specified class. 47 // Returns true if the Page has event handlers of the specified class.
48 bool HasEventHandlers(EventHandlerClass) const; 48 bool HasEventHandlers(EventHandlerClass) const;
49 49
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // Returns true if the operation actually added a new target or completely 90 // Returns true if the operation actually added a new target or completely
91 // removed an existing one. 91 // removed an existing one.
92 bool UpdateEventHandlerTargets(ChangeOperation, 92 bool UpdateEventHandlerTargets(ChangeOperation,
93 EventHandlerClass, 93 EventHandlerClass,
94 EventTarget*); 94 EventTarget*);
95 95
96 // Called on the EventHandlerRegistry of the root Document to notify 96 // Called on the EventHandlerRegistry of the root Document to notify
97 // clients when we have added the first handler or removed the last one for 97 // clients when we have added the first handler or removed the last one for
98 // a given event class. |hasActiveHandlers| can be used to distinguish 98 // a given event class. |hasActiveHandlers| can be used to distinguish
99 // between the two cases. 99 // between the two cases.
100 void NotifyHasHandlersChanged(LocalFrame*, 100 void NotifyHasHandlersChanged(EventTarget*,
101 EventHandlerClass, 101 EventHandlerClass,
102 bool has_active_handlers); 102 bool has_active_handlers);
103 103
104 // Called to notify clients whenever a single event handler target is 104 // Called to notify clients whenever a single event handler target is
105 // registered or unregistered. If several handlers are registered for the 105 // registered or unregistered. If several handlers are registered for the
106 // same target, only the first registration will trigger this notification. 106 // same target, only the first registration will trigger this notification.
107 void NotifyDidAddOrRemoveEventHandlerTarget(EventHandlerClass); 107 void NotifyDidAddOrRemoveEventHandlerTarget(EventHandlerClass);
108 108
109 // Record a change operation to a given event handler class and notify any 109 // Record a change operation to a given event handler class and notify any
110 // parent registry and other clients accordingly. 110 // parent registry and other clients accordingly.
111 void UpdateEventHandlerOfType(ChangeOperation, 111 void UpdateEventHandlerOfType(ChangeOperation,
112 const AtomicString& event_type, 112 const AtomicString& event_type,
113 const AddEventListenerOptions&, 113 const AddEventListenerOptions&,
114 EventTarget*); 114 EventTarget*);
115 115
116 void UpdateEventHandlerInternal(ChangeOperation, 116 bool UpdateEventHandlerInternal(ChangeOperation,
117 EventHandlerClass, 117 EventHandlerClass,
118 EventTarget*); 118 EventTarget*);
119 119
120 void UpdateAllEventHandlers(ChangeOperation, EventTarget&); 120 void UpdateAllEventHandlers(ChangeOperation, EventTarget&);
121 121
122 void CheckConsistency(EventHandlerClass) const; 122 void CheckConsistency(EventHandlerClass) const;
123 123
124 Member<Page> page_; 124 Member<Page> page_;
125 EventTargetSet targets_[kEventHandlerClassCount]; 125 EventTargetSet targets_[kEventHandlerClassCount];
126 }; 126 };
127 127
128 } // namespace blink 128 } // namespace blink
129 129
130 #endif // EventHandlerRegistry_h 130 #endif // EventHandlerRegistry_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698