OLD | NEW |
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 #include "core/frame/EventHandlerRegistry.h" | 5 #include "core/frame/EventHandlerRegistry.h" |
6 | 6 |
7 #include "core/events/EventListenerOptions.h" | 7 #include "core/events/EventListenerOptions.h" |
8 #include "core/events/EventUtil.h" | 8 #include "core/events/EventUtil.h" |
9 #include "core/frame/LocalDOMWindow.h" | 9 #include "core/frame/LocalDOMWindow.h" |
10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } | 112 } |
113 | 113 |
114 void EventHandlerRegistry::updateEventHandlerInternal( | 114 void EventHandlerRegistry::updateEventHandlerInternal( |
115 ChangeOperation op, | 115 ChangeOperation op, |
116 EventHandlerClass handlerClass, | 116 EventHandlerClass handlerClass, |
117 EventTarget* target) { | 117 EventTarget* target) { |
118 bool hadHandlers = m_targets[handlerClass].size(); | 118 bool hadHandlers = m_targets[handlerClass].size(); |
119 bool targetSetChanged = updateEventHandlerTargets(op, handlerClass, target); | 119 bool targetSetChanged = updateEventHandlerTargets(op, handlerClass, target); |
120 bool hasHandlers = m_targets[handlerClass].size(); | 120 bool hasHandlers = m_targets[handlerClass].size(); |
121 | 121 |
122 if (hadHandlers != hasHandlers) | 122 if (hadHandlers != hasHandlers) { |
123 notifyHasHandlersChanged(handlerClass, hasHandlers); | 123 LocalFrame* frame = nullptr; |
| 124 if (Node* node = target->toNode()) |
| 125 frame = node->document().frame(); |
| 126 notifyHasHandlersChanged(frame, handlerClass, hasHandlers); |
| 127 } |
124 | 128 |
125 if (targetSetChanged) | 129 if (targetSetChanged) |
126 notifyDidAddOrRemoveEventHandlerTarget(handlerClass); | 130 notifyDidAddOrRemoveEventHandlerTarget(handlerClass); |
127 } | 131 } |
128 | 132 |
129 void EventHandlerRegistry::updateEventHandlerOfType( | 133 void EventHandlerRegistry::updateEventHandlerOfType( |
130 ChangeOperation op, | 134 ChangeOperation op, |
131 const AtomicString& eventType, | 135 const AtomicString& eventType, |
132 const AddEventListenerOptions& options, | 136 const AddEventListenerOptions& options, |
133 EventTarget* target) { | 137 EventTarget* target) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 } | 207 } |
204 | 208 |
205 void EventHandlerRegistry::didRemoveAllEventHandlers(EventTarget& target) { | 209 void EventHandlerRegistry::didRemoveAllEventHandlers(EventTarget& target) { |
206 for (size_t i = 0; i < EventHandlerClassCount; ++i) { | 210 for (size_t i = 0; i < EventHandlerClassCount; ++i) { |
207 EventHandlerClass handlerClass = static_cast<EventHandlerClass>(i); | 211 EventHandlerClass handlerClass = static_cast<EventHandlerClass>(i); |
208 updateEventHandlerInternal(RemoveAll, handlerClass, &target); | 212 updateEventHandlerInternal(RemoveAll, handlerClass, &target); |
209 } | 213 } |
210 } | 214 } |
211 | 215 |
212 void EventHandlerRegistry::notifyHasHandlersChanged( | 216 void EventHandlerRegistry::notifyHasHandlersChanged( |
| 217 LocalFrame* frame, |
213 EventHandlerClass handlerClass, | 218 EventHandlerClass handlerClass, |
214 bool hasActiveHandlers) { | 219 bool hasActiveHandlers) { |
215 switch (handlerClass) { | 220 switch (handlerClass) { |
216 case ScrollEvent: | 221 case ScrollEvent: |
217 m_frameHost->chromeClient().setHasScrollEventHandlers(hasActiveHandlers); | 222 m_frameHost->chromeClient().setHasScrollEventHandlers(hasActiveHandlers); |
218 break; | 223 break; |
219 case WheelEventBlocking: | 224 case WheelEventBlocking: |
220 case WheelEventPassive: | 225 case WheelEventPassive: |
221 m_frameHost->chromeClient().setEventListenerProperties( | 226 m_frameHost->chromeClient().setEventListenerProperties( |
222 WebEventListenerClass::MouseWheel, | 227 frame, WebEventListenerClass::MouseWheel, |
223 webEventListenerProperties(hasEventHandlers(WheelEventBlocking), | 228 webEventListenerProperties(hasEventHandlers(WheelEventBlocking), |
224 hasEventHandlers(WheelEventPassive))); | 229 hasEventHandlers(WheelEventPassive))); |
225 break; | 230 break; |
226 case TouchStartOrMoveEventBlocking: | 231 case TouchStartOrMoveEventBlocking: |
227 case TouchStartOrMoveEventPassive: | 232 case TouchStartOrMoveEventPassive: |
228 m_frameHost->chromeClient().setEventListenerProperties( | 233 m_frameHost->chromeClient().setEventListenerProperties( |
229 WebEventListenerClass::TouchStartOrMove, | 234 frame, WebEventListenerClass::TouchStartOrMove, |
230 webEventListenerProperties( | 235 webEventListenerProperties( |
231 hasEventHandlers(TouchStartOrMoveEventBlocking), | 236 hasEventHandlers(TouchStartOrMoveEventBlocking), |
232 hasEventHandlers(TouchStartOrMoveEventPassive))); | 237 hasEventHandlers(TouchStartOrMoveEventPassive))); |
233 break; | 238 break; |
234 case TouchEndOrCancelEventBlocking: | 239 case TouchEndOrCancelEventBlocking: |
235 case TouchEndOrCancelEventPassive: | 240 case TouchEndOrCancelEventPassive: |
236 m_frameHost->chromeClient().setEventListenerProperties( | 241 m_frameHost->chromeClient().setEventListenerProperties( |
237 WebEventListenerClass::TouchEndOrCancel, | 242 frame, WebEventListenerClass::TouchEndOrCancel, |
238 webEventListenerProperties( | 243 webEventListenerProperties( |
239 hasEventHandlers(TouchEndOrCancelEventBlocking), | 244 hasEventHandlers(TouchEndOrCancelEventBlocking), |
240 hasEventHandlers(TouchEndOrCancelEventPassive))); | 245 hasEventHandlers(TouchEndOrCancelEventPassive))); |
241 break; | 246 break; |
242 #if ENABLE(ASSERT) | 247 #if ENABLE(ASSERT) |
243 case EventsForTesting: | 248 case EventsForTesting: |
244 break; | 249 break; |
245 #endif | 250 #endif |
246 default: | 251 default: |
247 ASSERT_NOT_REACHED(); | 252 ASSERT_NOT_REACHED(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 ASSERT(window->frame()); | 333 ASSERT(window->frame()); |
329 ASSERT(window->frame()->host()); | 334 ASSERT(window->frame()->host()); |
330 ASSERT(window->frame()->host() == m_frameHost); | 335 ASSERT(window->frame()->host() == m_frameHost); |
331 } | 336 } |
332 } | 337 } |
333 } | 338 } |
334 #endif // ENABLE(ASSERT) | 339 #endif // ENABLE(ASSERT) |
335 } | 340 } |
336 | 341 |
337 } // namespace blink | 342 } // namespace blink |
OLD | NEW |