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

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

Issue 2553343004: IntersectionObserver: use nullptr for implicit root. (Closed)
Patch Set: rebase Created 4 years 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/NodeIntersectionObserverData.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "core/dom/NodeIntersectionObserverData.h"
6
7 #include "core/dom/Document.h"
8 #include "core/dom/IntersectionObservation.h"
9 #include "core/dom/IntersectionObserver.h"
10 #include "core/dom/IntersectionObserverController.h"
11
12 namespace blink {
13
14 NodeIntersectionObserverData::NodeIntersectionObserverData() {}
15
16 IntersectionObservation* NodeIntersectionObserverData::getObservationFor(
17 IntersectionObserver& observer) {
18 auto i = m_intersectionObservations.find(&observer);
19 if (i == m_intersectionObservations.end())
20 return nullptr;
21 return i->value;
22 }
23
24 void NodeIntersectionObserverData::addObservation(
25 IntersectionObservation& observation) {
26 m_intersectionObservations.add(
27 TraceWrapperMember<IntersectionObserver>(this, &observation.observer()),
28 &observation);
29 }
30
31 void NodeIntersectionObserverData::removeObservation(
32 IntersectionObserver& observer) {
33 m_intersectionObservations.remove(&observer);
34 }
35
36 void NodeIntersectionObserverData::activateValidIntersectionObservers(
37 Node& node) {
38 IntersectionObserverController& controller =
39 node.document().ensureIntersectionObserverController();
40 for (auto& observer : m_intersectionObservers)
41 controller.addTrackedObserver(*observer);
42 }
43
44 void NodeIntersectionObserverData::deactivateAllIntersectionObservers(
45 Node& node) {
46 node.document()
47 .ensureIntersectionObserverController()
48 .removeTrackedObserversForRoot(node);
49 }
50
51 DEFINE_TRACE(NodeIntersectionObserverData) {
52 visitor->trace(m_intersectionObservers);
53 visitor->trace(m_intersectionObservations);
54 }
55
56 DEFINE_TRACE_WRAPPERS(NodeIntersectionObserverData) {
57 for (auto& entry : m_intersectionObservations) {
58 visitor->traceWrappers(entry.key);
59 }
60 }
61
62 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/NodeIntersectionObserverData.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698