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

Side by Side Diff: third_party/WebKit/Source/core/dom/IntersectionObserverController.cpp

Issue 2657443005: Migrate WTF::HashSet::add() to ::insert() [part 1 of N] (Closed)
Patch Set: Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/dom/IntersectionObserverController.h" 5 #include "core/dom/IntersectionObserverController.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/Element.h" 8 #include "core/dom/Element.h"
9 #include "core/dom/TaskRunnerHelper.h" 9 #include "core/dom/TaskRunnerHelper.h"
10 #include "platform/instrumentation/tracing/TraceEvent.h" 10 #include "platform/instrumentation/tracing/TraceEvent.h"
(...skipping 24 matching lines...) Expand all
35 TaskRunnerHelper::get(TaskType::Unthrottled, getExecutionContext()) 35 TaskRunnerHelper::get(TaskType::Unthrottled, getExecutionContext())
36 ->postTask(BLINK_FROM_HERE, 36 ->postTask(BLINK_FROM_HERE,
37 WTF::bind(&IntersectionObserverController:: 37 WTF::bind(&IntersectionObserverController::
38 deliverIntersectionObservations, 38 deliverIntersectionObservations,
39 m_weakPtrFactory.createWeakPtr())); 39 m_weakPtrFactory.createWeakPtr()));
40 } 40 }
41 } 41 }
42 42
43 void IntersectionObserverController::scheduleIntersectionObserverForDelivery( 43 void IntersectionObserverController::scheduleIntersectionObserverForDelivery(
44 IntersectionObserver& observer) { 44 IntersectionObserver& observer) {
45 m_pendingIntersectionObservers.add(&observer); 45 m_pendingIntersectionObservers.insert(&observer);
46 postTaskToDeliverObservations(); 46 postTaskToDeliverObservations();
47 } 47 }
48 48
49 void IntersectionObserverController::resume() { 49 void IntersectionObserverController::resume() {
50 // If the callback fired while DOM objects were suspended, notifications might 50 // If the callback fired while DOM objects were suspended, notifications might
51 // be late, so deliver them right away (rather than waiting to fire again). 51 // be late, so deliver them right away (rather than waiting to fire again).
52 if (m_callbackFiredWhileSuspended) { 52 if (m_callbackFiredWhileSuspended) {
53 m_callbackFiredWhileSuspended = false; 53 m_callbackFiredWhileSuspended = false;
54 postTaskToDeliverObservations(); 54 postTaskToDeliverObservations();
55 } 55 }
(...skipping 21 matching lines...) Expand all
77 "IntersectionObserverController::computeTrackedIntersectionObservations"); 77 "IntersectionObserverController::computeTrackedIntersectionObservations");
78 for (auto& observer : m_trackedIntersectionObservers) { 78 for (auto& observer : m_trackedIntersectionObservers) {
79 observer->computeIntersectionObservations(); 79 observer->computeIntersectionObservations();
80 if (observer->hasEntries()) 80 if (observer->hasEntries())
81 scheduleIntersectionObserverForDelivery(*observer); 81 scheduleIntersectionObserverForDelivery(*observer);
82 } 82 }
83 } 83 }
84 84
85 void IntersectionObserverController::addTrackedObserver( 85 void IntersectionObserverController::addTrackedObserver(
86 IntersectionObserver& observer) { 86 IntersectionObserver& observer) {
87 m_trackedIntersectionObservers.add(&observer); 87 m_trackedIntersectionObservers.insert(&observer);
88 } 88 }
89 89
90 void IntersectionObserverController::removeTrackedObserversForRoot( 90 void IntersectionObserverController::removeTrackedObserversForRoot(
91 const Node& root) { 91 const Node& root) {
92 HeapVector<Member<IntersectionObserver>> toRemove; 92 HeapVector<Member<IntersectionObserver>> toRemove;
93 for (auto& observer : m_trackedIntersectionObservers) { 93 for (auto& observer : m_trackedIntersectionObservers) {
94 if (observer->root() == &root) 94 if (observer->root() == &root)
95 toRemove.push_back(observer); 95 toRemove.push_back(observer);
96 } 96 }
97 m_trackedIntersectionObservers.removeAll(toRemove); 97 m_trackedIntersectionObservers.removeAll(toRemove);
98 } 98 }
99 99
100 DEFINE_TRACE(IntersectionObserverController) { 100 DEFINE_TRACE(IntersectionObserverController) {
101 visitor->trace(m_trackedIntersectionObservers); 101 visitor->trace(m_trackedIntersectionObservers);
102 visitor->trace(m_pendingIntersectionObservers); 102 visitor->trace(m_pendingIntersectionObservers);
103 SuspendableObject::trace(visitor); 103 SuspendableObject::trace(visitor);
104 } 104 }
105 105
106 } // namespace blink 106 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/IdTargetObserverRegistry.cpp ('k') | third_party/WebKit/Source/core/dom/MessagePort.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698