| 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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 for (const auto& eventTarget : *targets) { | 293 for (const auto& eventTarget : *targets) { |
| 294 if (Node* node = eventTarget.key->toNode()) { | 294 if (Node* node = eventTarget.key->toNode()) { |
| 295 for (Document* doc = &node->document(); doc; | 295 for (Document* doc = &node->document(); doc; |
| 296 doc = doc->localOwner() ? &doc->localOwner()->document() : 0) { | 296 doc = doc->localOwner() ? &doc->localOwner()->document() : 0) { |
| 297 if (doc == &document) { | 297 if (doc == &document) { |
| 298 targetsToRemove.append(eventTarget.key); | 298 targetsToRemove.append(eventTarget.key); |
| 299 break; | 299 break; |
| 300 } | 300 } |
| 301 } | 301 } |
| 302 } else if (eventTarget.key->toLocalDOMWindow()) { | 302 } else if (eventTarget.key->toLocalDOMWindow()) { |
| 303 // DOMWindows may outlive their documents, so we shouldn't remove their
handlers | 303 // DOMWindows may outlive their documents, so we shouldn't remove their |
| 304 // here. | 304 // handlers here. |
| 305 } else { | 305 } else { |
| 306 ASSERT_NOT_REACHED(); | 306 ASSERT_NOT_REACHED(); |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 for (size_t i = 0; i < targetsToRemove.size(); ++i) | 309 for (size_t i = 0; i < targetsToRemove.size(); ++i) |
| 310 updateEventHandlerInternal(RemoveAll, handlerClass, targetsToRemove[i]); | 310 updateEventHandlerInternal(RemoveAll, handlerClass, targetsToRemove[i]); |
| 311 } | 311 } |
| 312 } | 312 } |
| 313 | 313 |
| 314 void EventHandlerRegistry::checkConsistency() const { | 314 void EventHandlerRegistry::checkConsistency() const { |
| 315 #if ENABLE(ASSERT) | 315 #if ENABLE(ASSERT) |
| 316 for (size_t i = 0; i < EventHandlerClassCount; ++i) { | 316 for (size_t i = 0; i < EventHandlerClassCount; ++i) { |
| 317 EventHandlerClass handlerClass = static_cast<EventHandlerClass>(i); | 317 EventHandlerClass handlerClass = static_cast<EventHandlerClass>(i); |
| 318 const EventTargetSet* targets = &m_targets[handlerClass]; | 318 const EventTargetSet* targets = &m_targets[handlerClass]; |
| 319 for (const auto& eventTarget : *targets) { | 319 for (const auto& eventTarget : *targets) { |
| 320 if (Node* node = eventTarget.key->toNode()) { | 320 if (Node* node = eventTarget.key->toNode()) { |
| 321 // See the comment for |documentDetached| if either of these assertions
fails. | 321 // See the comment for |documentDetached| if either of these assertions |
| 322 // fails. |
| 322 ASSERT(node->document().frameHost()); | 323 ASSERT(node->document().frameHost()); |
| 323 ASSERT(node->document().frameHost() == m_frameHost); | 324 ASSERT(node->document().frameHost() == m_frameHost); |
| 324 } else if (LocalDOMWindow* window = eventTarget.key->toLocalDOMWindow()) { | 325 } else if (LocalDOMWindow* window = eventTarget.key->toLocalDOMWindow()) { |
| 325 // If any of these assertions fail, LocalDOMWindow failed to unregister
its handlers | 326 // If any of these assertions fail, LocalDOMWindow failed to unregister |
| 326 // properly. | 327 // its handlers properly. |
| 327 ASSERT(window->frame()); | 328 ASSERT(window->frame()); |
| 328 ASSERT(window->frame()->host()); | 329 ASSERT(window->frame()->host()); |
| 329 ASSERT(window->frame()->host() == m_frameHost); | 330 ASSERT(window->frame()->host() == m_frameHost); |
| 330 } | 331 } |
| 331 } | 332 } |
| 332 } | 333 } |
| 333 #endif // ENABLE(ASSERT) | 334 #endif // ENABLE(ASSERT) |
| 334 } | 335 } |
| 335 | 336 |
| 336 } // namespace blink | 337 } // namespace blink |
| OLD | NEW |