Index: third_party/WebKit/Source/core/dom/ElementIntersectionObserverData.cpp |
diff --git a/third_party/WebKit/Source/core/dom/NodeIntersectionObserverData.cpp b/third_party/WebKit/Source/core/dom/ElementIntersectionObserverData.cpp |
similarity index 49% |
rename from third_party/WebKit/Source/core/dom/NodeIntersectionObserverData.cpp |
rename to third_party/WebKit/Source/core/dom/ElementIntersectionObserverData.cpp |
index 7a3fc71fca48bf3a31def3ec6c7a15d1e32d3011..ff76561d108f5432782ddc8e31edde18daa8eee8 100644 |
--- a/third_party/WebKit/Source/core/dom/NodeIntersectionObserverData.cpp |
+++ b/third_party/WebKit/Source/core/dom/ElementIntersectionObserverData.cpp |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "core/dom/NodeIntersectionObserverData.h" |
+#include "core/dom/ElementIntersectionObserverData.h" |
#include "core/dom/Document.h" |
#include "core/dom/IntersectionObservation.h" |
@@ -11,9 +11,9 @@ |
namespace blink { |
-NodeIntersectionObserverData::NodeIntersectionObserverData() {} |
+ElementIntersectionObserverData::ElementIntersectionObserverData() {} |
-IntersectionObservation* NodeIntersectionObserverData::getObservationFor( |
+IntersectionObservation* ElementIntersectionObserverData::getObservationFor( |
IntersectionObserver& observer) { |
auto i = m_intersectionObservations.find(&observer); |
if (i == m_intersectionObservations.end()) |
@@ -21,39 +21,55 @@ IntersectionObservation* NodeIntersectionObserverData::getObservationFor( |
return i->value; |
} |
-void NodeIntersectionObserverData::addObservation( |
+void ElementIntersectionObserverData::addObserver( |
+ IntersectionObserver& observer) { |
+ m_intersectionObservers.add(&observer); |
+} |
+ |
+void ElementIntersectionObserverData::removeObserver( |
+ IntersectionObserver& observer) { |
+ m_intersectionObservers.remove(&observer); |
+} |
+ |
+void ElementIntersectionObserverData::addObservation( |
IntersectionObservation& observation) { |
m_intersectionObservations.add( |
TraceWrapperMember<IntersectionObserver>(this, &observation.observer()), |
&observation); |
} |
-void NodeIntersectionObserverData::removeObservation( |
+void ElementIntersectionObserverData::removeObservation( |
IntersectionObserver& observer) { |
m_intersectionObservations.remove(&observer); |
} |
-void NodeIntersectionObserverData::activateValidIntersectionObservers( |
+void ElementIntersectionObserverData::activateValidIntersectionObservers( |
Node& node) { |
- IntersectionObserverController& controller = |
- node.document().ensureIntersectionObserverController(); |
- for (auto& observer : m_intersectionObservers) |
- controller.addTrackedObserver(*observer); |
+ for (auto& observer : m_intersectionObservers) { |
+ observer->trackingDocument() |
+ .ensureIntersectionObserverController() |
+ .addTrackedObserver(*observer); |
+ } |
} |
-void NodeIntersectionObserverData::deactivateAllIntersectionObservers( |
+void ElementIntersectionObserverData::deactivateAllIntersectionObservers( |
Node& node) { |
+ for (auto& observer : m_intersectionObservers) { |
+ observer->trackingDocument() |
+ .ensureIntersectionObserverController() |
+ .addTrackedObserver(*observer); |
+ } |
node.document() |
.ensureIntersectionObserverController() |
.removeTrackedObserversForRoot(node); |
} |
-DEFINE_TRACE(NodeIntersectionObserverData) { |
+DEFINE_TRACE(ElementIntersectionObserverData) { |
visitor->trace(m_intersectionObservers); |
visitor->trace(m_intersectionObservations); |
} |
-DEFINE_TRACE_WRAPPERS(NodeIntersectionObserverData) { |
+DEFINE_TRACE_WRAPPERS(ElementIntersectionObserverData) { |
for (auto& entry : m_intersectionObservations) { |
visitor->traceWrappers(entry.key); |
} |