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: sky/engine/core/frame/EventHandlerRegistry.h

Issue 713073003: remove updateTouchEventTargetRectsIfNeeded (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: moar Created 6 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef EventHandlerRegistry_h
6 #define EventHandlerRegistry_h
7
8 #include "core/frame/FrameHost.h"
9 #include "wtf/HashCountedSet.h"
10 #include "wtf/text/AtomicString.h"
11
12 namespace blink {
13
14 class Document;
15 class EventTarget;
16
17 typedef HashCountedSet<EventTarget*> EventTargetSet;
18
19 // Registry for keeping track of event handlers. Note that only handlers on
20 // documents that can be rendered or can receive input (i.e., are attached to a
21 // FrameHost) are registered here.
22 class EventHandlerRegistry final {
23 public:
24 explicit EventHandlerRegistry(FrameHost&);
25 virtual ~EventHandlerRegistry();
26
27 // Supported event handler classes. Note that each one may correspond to
28 // multiple event types.
29 enum EventHandlerClass {
30 ScrollEvent,
31 WheelEvent,
32 TouchEvent,
33 #if ENABLE(ASSERT)
34 // Additional event categories for verifying handler tracking logic.
35 EventsForTesting,
36 #endif
37 EventHandlerClassCount, // Must be the last entry.
38 };
39
40 // Returns true if the FrameHost has event handlers of the specified class.
41 bool hasEventHandlers(EventHandlerClass) const;
42
43 // Returns a set of EventTargets which have registered handlers of the given class.
44 const EventTargetSet* eventHandlerTargets(EventHandlerClass) const;
45
46 // Registration and management of event handlers attached to EventTargets.
47 void didAddEventHandler(EventTarget&, const AtomicString& eventType);
48 void didAddEventHandler(EventTarget&, EventHandlerClass);
49 void didRemoveEventHandler(EventTarget&, const AtomicString& eventType);
50 void didRemoveEventHandler(EventTarget&, EventHandlerClass);
51 void didRemoveAllEventHandlers(EventTarget&);
52
53 void didMoveIntoFrameHost(EventTarget&);
54 void didMoveOutOfFrameHost(EventTarget&);
55 static void didMoveBetweenFrameHosts(EventTarget&, FrameHost* oldFrameHost, FrameHost* newFrameHost);
56
57 // Either |documentDetached| or |didMove{Into,OutOf,Between}FrameHosts| must
58 // be called whenever the FrameHost that is associated with a registered eve nt
59 // target changes. This ensures the registry does not end up with stale
60 // references to handlers that are no longer related to it.
61 void documentDetached(Document&);
62
63 private:
64 enum ChangeOperation {
65 Add, // Add a new event handler.
66 Remove, // Remove an existing event handler.
67 RemoveAll // Remove any and all existing event handlers for a given targ et.
68 };
69
70 // Returns true if |eventType| belongs to a class this registry tracks.
71 static bool eventTypeToClass(const AtomicString& eventType, EventHandlerClas s* result);
72
73 // Returns true if the operation actually added a new target or completely
74 // removed an existing one.
75 bool updateEventHandlerTargets(ChangeOperation, EventHandlerClass, EventTarg et*);
76
77 // Called on the EventHandlerRegistry of the root Document to notify
78 // clients when we have added the first handler or removed the last one for
79 // a given event class. |hasActiveHandlers| can be used to distinguish
80 // between the two cases.
81 void notifyHasHandlersChanged(EventHandlerClass, bool hasActiveHandlers);
82
83 // Called to notify clients whenever a single event handler target is
84 // registered or unregistered. If several handlers are registered for the
85 // same target, only the first registration will trigger this notification.
86 void notifyDidAddOrRemoveEventHandlerTarget(EventHandlerClass);
87
88 // Record a change operation to a given event handler class and notify any
89 // parent registry and other clients accordingly.
90 void updateEventHandlerOfType(ChangeOperation, const AtomicString& eventType , EventTarget*);
91
92 void updateEventHandlerInternal(ChangeOperation, EventHandlerClass, EventTar get*);
93
94 void updateAllEventHandlers(ChangeOperation, EventTarget&);
95
96 void checkConsistency() const;
97
98 FrameHost& m_frameHost;
99 EventTargetSet m_targets[EventHandlerClassCount];
100 };
101
102 } // namespace blink
103
104 #endif // EventHandlerRegistry_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698