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

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

Issue 2737863005: Revert of Make EventHandlerRegistry store Page instead of FrameHost (Closed)
Patch Set: Created 3 years, 9 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" 8 #include "core/CoreExport.h"
9 #include "core/frame/FrameHost.h" // TODO(sashab): Remove this. 9 #include "core/frame/FrameHost.h"
10 #include "core/page/Page.h"
11 #include "wtf/HashCountedSet.h" 10 #include "wtf/HashCountedSet.h"
12 11
13 namespace blink { 12 namespace blink {
14 13
15 class AddEventListenerOptions; 14 class AddEventListenerOptions;
16 class Document; 15 class Document;
17 class EventTarget; 16 class EventTarget;
18 class LocalFrame; 17 class LocalFrame;
19 18
20 typedef HashCountedSet<UntracedMember<EventTarget>> EventTargetSet; 19 typedef HashCountedSet<UntracedMember<EventTarget>> EventTargetSet;
21 20
22 // Registry for keeping track of event handlers. Note that only handlers on 21 // Registry for keeping track of event handlers. Note that only handlers on
23 // documents that can be rendered or can receive input (i.e., are attached to a 22 // documents that can be rendered or can receive input (i.e., are attached to a
24 // Page) are registered here. 23 // FrameHost) are registered here.
25 class CORE_EXPORT EventHandlerRegistry final 24 class CORE_EXPORT EventHandlerRegistry final
26 : public GarbageCollectedFinalized<EventHandlerRegistry> { 25 : public GarbageCollectedFinalized<EventHandlerRegistry> {
27 public: 26 public:
28 explicit EventHandlerRegistry(Page&); 27 explicit EventHandlerRegistry(FrameHost&);
29 virtual ~EventHandlerRegistry(); 28 virtual ~EventHandlerRegistry();
30 29
31 // Supported event handler classes. Note that each one may correspond to 30 // Supported event handler classes. Note that each one may correspond to
32 // multiple event types. 31 // multiple event types.
33 enum EventHandlerClass { 32 enum EventHandlerClass {
34 ScrollEvent, 33 ScrollEvent,
35 WheelEventBlocking, 34 WheelEventBlocking,
36 WheelEventPassive, 35 WheelEventPassive,
37 TouchStartOrMoveEventBlocking, 36 TouchStartOrMoveEventBlocking,
38 TouchStartOrMoveEventPassive, 37 TouchStartOrMoveEventPassive,
39 TouchEndOrCancelEventBlocking, 38 TouchEndOrCancelEventBlocking,
40 TouchEndOrCancelEventPassive, 39 TouchEndOrCancelEventPassive,
41 #if DCHECK_IS_ON() 40 #if DCHECK_IS_ON()
42 // Additional event categories for verifying handler tracking logic. 41 // Additional event categories for verifying handler tracking logic.
43 EventsForTesting, 42 EventsForTesting,
44 #endif 43 #endif
45 EventHandlerClassCount, // Must be the last entry. 44 EventHandlerClassCount, // Must be the last entry.
46 }; 45 };
47 46
48 // Returns true if the Page has event handlers of the specified class. 47 // Returns true if the FrameHost has event handlers of the specified class.
49 bool hasEventHandlers(EventHandlerClass) const; 48 bool hasEventHandlers(EventHandlerClass) const;
50 49
51 // Returns a set of EventTargets which have registered handlers of the given 50 // Returns a set of EventTargets which have registered handlers of the given
52 // class. 51 // class.
53 const EventTargetSet* eventHandlerTargets(EventHandlerClass) const; 52 const EventTargetSet* eventHandlerTargets(EventHandlerClass) const;
54 53
55 // Registration and management of event handlers attached to EventTargets. 54 // Registration and management of event handlers attached to EventTargets.
56 void didAddEventHandler(EventTarget&, 55 void didAddEventHandler(EventTarget&,
57 const AtomicString& eventType, 56 const AtomicString& eventType,
58 const AddEventListenerOptions&); 57 const AddEventListenerOptions&);
59 void didAddEventHandler(EventTarget&, EventHandlerClass); 58 void didAddEventHandler(EventTarget&, EventHandlerClass);
60 void didRemoveEventHandler(EventTarget&, 59 void didRemoveEventHandler(EventTarget&,
61 const AtomicString& eventType, 60 const AtomicString& eventType,
62 const AddEventListenerOptions&); 61 const AddEventListenerOptions&);
63 void didRemoveEventHandler(EventTarget&, EventHandlerClass); 62 void didRemoveEventHandler(EventTarget&, EventHandlerClass);
64 void didRemoveAllEventHandlers(EventTarget&); 63 void didRemoveAllEventHandlers(EventTarget&);
65 64
66 void didMoveIntoPage(EventTarget&); 65 void didMoveIntoFrameHost(EventTarget&);
67 void didMoveOutOfPage(EventTarget&); 66 void didMoveOutOfFrameHost(EventTarget&);
68 67
69 // Either |documentDetached| or |didMove{Into,OutOf,Between}Pages| must 68 // Either |documentDetached| or |didMove{Into,OutOf,Between}FrameHosts| must
70 // be called whenever the Page that is associated with a registered event 69 // be called whenever the FrameHost that is associated with a registered event
71 // target changes. This ensures the registry does not end up with stale 70 // target changes. This ensures the registry does not end up with stale
72 // references to handlers that are no longer related to it. 71 // references to handlers that are no longer related to it.
73 void documentDetached(Document&); 72 void documentDetached(Document&);
74 73
75 DECLARE_TRACE(); 74 DECLARE_TRACE();
76 void clearWeakMembers(Visitor*); 75 void clearWeakMembers(Visitor*);
77 76
78 private: 77 private:
79 enum ChangeOperation { 78 enum ChangeOperation {
80 Add, // Add a new event handler. 79 Add, // Add a new event handler.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 EventTarget*); 113 EventTarget*);
115 114
116 void updateEventHandlerInternal(ChangeOperation, 115 void updateEventHandlerInternal(ChangeOperation,
117 EventHandlerClass, 116 EventHandlerClass,
118 EventTarget*); 117 EventTarget*);
119 118
120 void updateAllEventHandlers(ChangeOperation, EventTarget&); 119 void updateAllEventHandlers(ChangeOperation, EventTarget&);
121 120
122 void checkConsistency(EventHandlerClass) const; 121 void checkConsistency(EventHandlerClass) const;
123 122
124 Member<Page> m_page; 123 Member<FrameHost> m_frameHost;
125 EventTargetSet m_targets[EventHandlerClassCount]; 124 EventTargetSet m_targets[EventHandlerClassCount];
126 }; 125 };
127 126
128 } // namespace blink 127 } // namespace blink
129 128
130 #endif // EventHandlerRegistry_h 129 #endif // EventHandlerRegistry_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.cpp ('k') | third_party/WebKit/Source/core/frame/EventHandlerRegistry.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698