| 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/frame/LocalDOMWindow.h" | 8 #include "core/frame/LocalDOMWindow.h" |
| 9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 10 #include "core/html/HTMLFrameOwnerElement.h" | 10 #include "core/html/HTMLFrameOwnerElement.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 | 266 |
| 267 void EventHandlerRegistry::documentDetached(Document& document) | 267 void EventHandlerRegistry::documentDetached(Document& document) |
| 268 { | 268 { |
| 269 // Remove all event targets under the detached document. | 269 // Remove all event targets under the detached document. |
| 270 for (size_t handlerClassIndex = 0; handlerClassIndex < EventHandlerClassCoun
t; ++handlerClassIndex) { | 270 for (size_t handlerClassIndex = 0; handlerClassIndex < EventHandlerClassCoun
t; ++handlerClassIndex) { |
| 271 EventHandlerClass handlerClass = static_cast<EventHandlerClass>(handlerC
lassIndex); | 271 EventHandlerClass handlerClass = static_cast<EventHandlerClass>(handlerC
lassIndex); |
| 272 Vector<UntracedMember<EventTarget>> targetsToRemove; | 272 Vector<UntracedMember<EventTarget>> targetsToRemove; |
| 273 const EventTargetSet* targets = &m_targets[handlerClass]; | 273 const EventTargetSet* targets = &m_targets[handlerClass]; |
| 274 for (const auto& eventTarget : *targets) { | 274 for (const auto& eventTarget : *targets) { |
| 275 if (Node* node = eventTarget.key->toNode()) { | 275 if (Node* node = eventTarget.key->toNode()) { |
| 276 for (Document* doc = &node->document(); doc; doc = doc->ownerEle
ment() ? &doc->ownerElement()->document() : 0) { | 276 for (Document* doc = &node->document(); doc; doc = doc->localOwn
er() ? &doc->localOwner()->document() : 0) { |
| 277 if (doc == &document) { | 277 if (doc == &document) { |
| 278 targetsToRemove.append(eventTarget.key); | 278 targetsToRemove.append(eventTarget.key); |
| 279 break; | 279 break; |
| 280 } | 280 } |
| 281 } | 281 } |
| 282 } else if (eventTarget.key->toLocalDOMWindow()) { | 282 } else if (eventTarget.key->toLocalDOMWindow()) { |
| 283 // DOMWindows may outlive their documents, so we shouldn't remov
e their handlers | 283 // DOMWindows may outlive their documents, so we shouldn't remov
e their handlers |
| 284 // here. | 284 // here. |
| 285 } else { | 285 } else { |
| 286 ASSERT_NOT_REACHED(); | 286 ASSERT_NOT_REACHED(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 308 ASSERT(window->frame()); | 308 ASSERT(window->frame()); |
| 309 ASSERT(window->frame()->host()); | 309 ASSERT(window->frame()->host()); |
| 310 ASSERT(window->frame()->host() == m_frameHost); | 310 ASSERT(window->frame()->host() == m_frameHost); |
| 311 } | 311 } |
| 312 } | 312 } |
| 313 } | 313 } |
| 314 #endif // ENABLE(ASSERT) | 314 #endif // ENABLE(ASSERT) |
| 315 } | 315 } |
| 316 | 316 |
| 317 } // namespace blink | 317 } // namespace blink |
| OLD | NEW |