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

Side by Side Diff: third_party/WebKit/Source/core/events/RegisteredEventListener.h

Issue 2245723002: Support "once" event listener option (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added forcing 'once' to be always defined." Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/Source/core/events/EventTarget.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Apple Inc. All rights reserv ed.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 18 matching lines...) Expand all
29 #include "wtf/RefPtr.h" 29 #include "wtf/RefPtr.h"
30 30
31 namespace blink { 31 namespace blink {
32 32
33 class RegisteredEventListener { 33 class RegisteredEventListener {
34 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 34 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
35 public: 35 public:
36 RegisteredEventListener() 36 RegisteredEventListener()
37 : m_useCapture(false) 37 : m_useCapture(false)
38 , m_passive(false) 38 , m_passive(false)
39 , m_once(false)
39 , m_blockedEventWarningEmitted(false) 40 , m_blockedEventWarningEmitted(false)
40 , m_passiveForcedForDocumentTarget(false) 41 , m_passiveForcedForDocumentTarget(false)
41 { 42 {
42 } 43 }
43 44
44 RegisteredEventListener(EventListener* listener, const AddEventListenerOptio nsResolved& options) 45 RegisteredEventListener(EventListener* listener, const AddEventListenerOptio nsResolved& options)
45 : m_listener(listener) 46 : m_listener(listener)
46 , m_useCapture(options.capture()) 47 , m_useCapture(options.capture())
47 , m_passive(options.passive()) 48 , m_passive(options.passive())
49 , m_once(options.once())
48 , m_blockedEventWarningEmitted(false) 50 , m_blockedEventWarningEmitted(false)
49 , m_passiveForcedForDocumentTarget(options.passiveForcedForDocumentTarge t()) 51 , m_passiveForcedForDocumentTarget(options.passiveForcedForDocumentTarge t())
50 { 52 {
51 } 53 }
52 54
53 DEFINE_INLINE_TRACE() 55 DEFINE_INLINE_TRACE()
54 { 56 {
55 visitor->trace(m_listener); 57 visitor->trace(m_listener);
56 } 58 }
57 59
58 AddEventListenerOptionsResolved options() const 60 AddEventListenerOptionsResolved options() const
59 { 61 {
60 AddEventListenerOptionsResolved result; 62 AddEventListenerOptionsResolved result;
61 result.setCapture(m_useCapture); 63 result.setCapture(m_useCapture);
62 result.setPassive(m_passive); 64 result.setPassive(m_passive);
63 result.setPassiveForcedForDocumentTarget(m_passiveForcedForDocumentTarge t); 65 result.setPassiveForcedForDocumentTarget(m_passiveForcedForDocumentTarge t);
66 result.setOnce(m_once);
64 return result; 67 return result;
65 } 68 }
66 69
67 const EventListener* listener() const 70 const EventListener* listener() const
68 { 71 {
69 return m_listener; 72 return m_listener;
70 } 73 }
71 74
72 EventListener* listener() 75 EventListener* listener()
73 { 76 {
74 return m_listener; 77 return m_listener;
75 } 78 }
76 79
77 bool passive() const 80 bool passive() const
78 { 81 {
79 return m_passive; 82 return m_passive;
80 } 83 }
81 84
85 bool once() const
86 {
87 return m_once;
88 }
89
82 bool capture() const 90 bool capture() const
83 { 91 {
84 return m_useCapture; 92 return m_useCapture;
85 } 93 }
86 94
87 bool blockedEventWarningEmitted() const 95 bool blockedEventWarningEmitted() const
88 { 96 {
89 return m_blockedEventWarningEmitted; 97 return m_blockedEventWarningEmitted;
90 } 98 }
91 99
(...skipping 20 matching lines...) Expand all
112 // Equality is soley based on the listener and useCapture flags. 120 // Equality is soley based on the listener and useCapture flags.
113 DCHECK(m_listener); 121 DCHECK(m_listener);
114 DCHECK(other.m_listener); 122 DCHECK(other.m_listener);
115 return *m_listener == *other.m_listener && m_useCapture == other.m_useCa pture; 123 return *m_listener == *other.m_listener && m_useCapture == other.m_useCa pture;
116 } 124 }
117 125
118 private: 126 private:
119 Member<EventListener> m_listener; 127 Member<EventListener> m_listener;
120 unsigned m_useCapture : 1; 128 unsigned m_useCapture : 1;
121 unsigned m_passive : 1; 129 unsigned m_passive : 1;
130 unsigned m_once : 1;
122 unsigned m_blockedEventWarningEmitted : 1; 131 unsigned m_blockedEventWarningEmitted : 1;
123 unsigned m_passiveForcedForDocumentTarget : 1; 132 unsigned m_passiveForcedForDocumentTarget : 1;
124 }; 133 };
125 134
126 } // namespace blink 135 } // namespace blink
127 136
128 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::RegisteredEventListener); 137 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::RegisteredEventListener);
129 138
130 #endif // RegisteredEventListener_h 139 #endif // RegisteredEventListener_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/EventTarget.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698