Chromium Code Reviews| 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 Frame* mainFrame = m_frameHost->page().mainFrame(); |
| 124 LocalFrame* frame = | |
| 125 mainFrame->isLocalFrame() ? toLocalFrame(mainFrame) : nullptr; | |
| 126 if (Node* node = target->toNode()) | |
| 127 frame = node->document().frame(); | |
|
dcheng
2016/11/10 07:46:11
My reading of this is we'll need to handle the Loc
wjmaclean
2016/11/10 15:57:15
Done. (DCHECK'd as ASSERT is deprecated.)
wjmaclean
2016/11/11 15:40:51
Hmmm, that didn't work. It seems we must have more
dcheng
2016/11/11 22:32:11
Does the debugger know what type of EventTarget is
| |
| 128 | |
| 129 notifyHasHandlersChanged(frame, handlerClass, hasHandlers); | |
| 130 } | |
| 124 | 131 |
| 125 if (targetSetChanged) | 132 if (targetSetChanged) |
| 126 notifyDidAddOrRemoveEventHandlerTarget(handlerClass); | 133 notifyDidAddOrRemoveEventHandlerTarget(handlerClass); |
| 127 } | 134 } |
| 128 | 135 |
| 129 void EventHandlerRegistry::updateEventHandlerOfType( | 136 void EventHandlerRegistry::updateEventHandlerOfType( |
| 130 ChangeOperation op, | 137 ChangeOperation op, |
| 131 const AtomicString& eventType, | 138 const AtomicString& eventType, |
| 132 const AddEventListenerOptions& options, | 139 const AddEventListenerOptions& options, |
| 133 EventTarget* target) { | 140 EventTarget* target) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 } | 210 } |
| 204 | 211 |
| 205 void EventHandlerRegistry::didRemoveAllEventHandlers(EventTarget& target) { | 212 void EventHandlerRegistry::didRemoveAllEventHandlers(EventTarget& target) { |
| 206 for (size_t i = 0; i < EventHandlerClassCount; ++i) { | 213 for (size_t i = 0; i < EventHandlerClassCount; ++i) { |
| 207 EventHandlerClass handlerClass = static_cast<EventHandlerClass>(i); | 214 EventHandlerClass handlerClass = static_cast<EventHandlerClass>(i); |
| 208 updateEventHandlerInternal(RemoveAll, handlerClass, &target); | 215 updateEventHandlerInternal(RemoveAll, handlerClass, &target); |
| 209 } | 216 } |
| 210 } | 217 } |
| 211 | 218 |
| 212 void EventHandlerRegistry::notifyHasHandlersChanged( | 219 void EventHandlerRegistry::notifyHasHandlersChanged( |
| 220 LocalFrame* frame, | |
| 213 EventHandlerClass handlerClass, | 221 EventHandlerClass handlerClass, |
| 214 bool hasActiveHandlers) { | 222 bool hasActiveHandlers) { |
| 215 switch (handlerClass) { | 223 switch (handlerClass) { |
| 216 case ScrollEvent: | 224 case ScrollEvent: |
| 217 m_frameHost->chromeClient().setHasScrollEventHandlers(hasActiveHandlers); | 225 m_frameHost->chromeClient().setHasScrollEventHandlers(hasActiveHandlers); |
| 218 break; | 226 break; |
| 219 case WheelEventBlocking: | 227 case WheelEventBlocking: |
| 220 case WheelEventPassive: | 228 case WheelEventPassive: |
| 221 m_frameHost->chromeClient().setEventListenerProperties( | 229 m_frameHost->chromeClient().setEventListenerProperties( |
| 222 WebEventListenerClass::MouseWheel, | 230 frame, WebEventListenerClass::MouseWheel, |
| 223 webEventListenerProperties(hasEventHandlers(WheelEventBlocking), | 231 webEventListenerProperties(hasEventHandlers(WheelEventBlocking), |
| 224 hasEventHandlers(WheelEventPassive))); | 232 hasEventHandlers(WheelEventPassive))); |
| 225 break; | 233 break; |
| 226 case TouchStartOrMoveEventBlocking: | 234 case TouchStartOrMoveEventBlocking: |
| 227 case TouchStartOrMoveEventPassive: | 235 case TouchStartOrMoveEventPassive: |
| 228 m_frameHost->chromeClient().setEventListenerProperties( | 236 m_frameHost->chromeClient().setEventListenerProperties( |
| 229 WebEventListenerClass::TouchStartOrMove, | 237 frame, WebEventListenerClass::TouchStartOrMove, |
| 230 webEventListenerProperties( | 238 webEventListenerProperties( |
| 231 hasEventHandlers(TouchStartOrMoveEventBlocking), | 239 hasEventHandlers(TouchStartOrMoveEventBlocking), |
| 232 hasEventHandlers(TouchStartOrMoveEventPassive))); | 240 hasEventHandlers(TouchStartOrMoveEventPassive))); |
| 233 break; | 241 break; |
| 234 case TouchEndOrCancelEventBlocking: | 242 case TouchEndOrCancelEventBlocking: |
| 235 case TouchEndOrCancelEventPassive: | 243 case TouchEndOrCancelEventPassive: |
| 236 m_frameHost->chromeClient().setEventListenerProperties( | 244 m_frameHost->chromeClient().setEventListenerProperties( |
| 237 WebEventListenerClass::TouchEndOrCancel, | 245 frame, WebEventListenerClass::TouchEndOrCancel, |
| 238 webEventListenerProperties( | 246 webEventListenerProperties( |
| 239 hasEventHandlers(TouchEndOrCancelEventBlocking), | 247 hasEventHandlers(TouchEndOrCancelEventBlocking), |
| 240 hasEventHandlers(TouchEndOrCancelEventPassive))); | 248 hasEventHandlers(TouchEndOrCancelEventPassive))); |
| 241 break; | 249 break; |
| 242 #if ENABLE(ASSERT) | 250 #if ENABLE(ASSERT) |
| 243 case EventsForTesting: | 251 case EventsForTesting: |
| 244 break; | 252 break; |
| 245 #endif | 253 #endif |
| 246 default: | 254 default: |
| 247 ASSERT_NOT_REACHED(); | 255 ASSERT_NOT_REACHED(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 ASSERT(window->frame()); | 336 ASSERT(window->frame()); |
| 329 ASSERT(window->frame()->host()); | 337 ASSERT(window->frame()->host()); |
| 330 ASSERT(window->frame()->host() == m_frameHost); | 338 ASSERT(window->frame()->host() == m_frameHost); |
| 331 } | 339 } |
| 332 } | 340 } |
| 333 } | 341 } |
| 334 #endif // ENABLE(ASSERT) | 342 #endif // ENABLE(ASSERT) |
| 335 } | 343 } |
| 336 | 344 |
| 337 } // namespace blink | 345 } // namespace blink |
| OLD | NEW |