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

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

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