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

Side by Side Diff: third_party/WebKit/Source/core/frame/EventHandlerRegistry.cpp

Issue 2585283002: Migrate WTF::Vector::append() to ::push_back() [part 6 of N] (Closed)
Patch Set: Created 3 years, 12 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
OLDNEW
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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 265
266 void EventHandlerRegistry::clearWeakMembers(Visitor* visitor) { 266 void EventHandlerRegistry::clearWeakMembers(Visitor* visitor) {
267 Vector<UntracedMember<EventTarget>> deadTargets; 267 Vector<UntracedMember<EventTarget>> deadTargets;
268 for (size_t i = 0; i < EventHandlerClassCount; ++i) { 268 for (size_t i = 0; i < EventHandlerClassCount; ++i) {
269 EventHandlerClass handlerClass = static_cast<EventHandlerClass>(i); 269 EventHandlerClass handlerClass = static_cast<EventHandlerClass>(i);
270 const EventTargetSet* targets = &m_targets[handlerClass]; 270 const EventTargetSet* targets = &m_targets[handlerClass];
271 for (const auto& eventTarget : *targets) { 271 for (const auto& eventTarget : *targets) {
272 Node* node = eventTarget.key->toNode(); 272 Node* node = eventTarget.key->toNode();
273 LocalDOMWindow* window = eventTarget.key->toLocalDOMWindow(); 273 LocalDOMWindow* window = eventTarget.key->toLocalDOMWindow();
274 if (node && !ThreadHeap::isHeapObjectAlive(node)) { 274 if (node && !ThreadHeap::isHeapObjectAlive(node)) {
275 deadTargets.append(node); 275 deadTargets.push_back(node);
276 } else if (window && !ThreadHeap::isHeapObjectAlive(window)) { 276 } else if (window && !ThreadHeap::isHeapObjectAlive(window)) {
277 deadTargets.append(window); 277 deadTargets.push_back(window);
278 } 278 }
279 } 279 }
280 } 280 }
281 for (size_t i = 0; i < deadTargets.size(); ++i) 281 for (size_t i = 0; i < deadTargets.size(); ++i)
282 didRemoveAllEventHandlers(*deadTargets[i]); 282 didRemoveAllEventHandlers(*deadTargets[i]);
283 } 283 }
284 284
285 void EventHandlerRegistry::documentDetached(Document& document) { 285 void EventHandlerRegistry::documentDetached(Document& document) {
286 // Remove all event targets under the detached document. 286 // Remove all event targets under the detached document.
287 for (size_t handlerClassIndex = 0; handlerClassIndex < EventHandlerClassCount; 287 for (size_t handlerClassIndex = 0; handlerClassIndex < EventHandlerClassCount;
288 ++handlerClassIndex) { 288 ++handlerClassIndex) {
289 EventHandlerClass handlerClass = 289 EventHandlerClass handlerClass =
290 static_cast<EventHandlerClass>(handlerClassIndex); 290 static_cast<EventHandlerClass>(handlerClassIndex);
291 Vector<UntracedMember<EventTarget>> targetsToRemove; 291 Vector<UntracedMember<EventTarget>> targetsToRemove;
292 const EventTargetSet* targets = &m_targets[handlerClass]; 292 const EventTargetSet* targets = &m_targets[handlerClass];
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.push_back(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 303 // DOMWindows may outlive their documents, so we shouldn't remove their
304 // handlers here. 304 // handlers here.
305 } else { 305 } else {
306 ASSERT_NOT_REACHED(); 306 ASSERT_NOT_REACHED();
307 } 307 }
308 } 308 }
(...skipping 19 matching lines...) Expand all
328 ASSERT(window->frame()); 328 ASSERT(window->frame());
329 ASSERT(window->frame()->host()); 329 ASSERT(window->frame()->host());
330 ASSERT(window->frame()->host() == m_frameHost); 330 ASSERT(window->frame()->host() == m_frameHost);
331 } 331 }
332 } 332 }
333 } 333 }
334 #endif // ENABLE(ASSERT) 334 #endif // ENABLE(ASSERT)
335 } 335 }
336 336
337 } // namespace blink 337 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fileapi/FileReaderLoader.cpp ('k') | third_party/WebKit/Source/core/frame/Frame.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698