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

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

Issue 1603773002: Use registerWeakMembers to manage observer root. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: nit scratched Created 4 years, 11 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/IntersectionObservation.h" 5 #include "core/dom/IntersectionObservation.h"
6 6
7 #include "core/dom/ElementRareData.h" 7 #include "core/dom/ElementRareData.h"
8 #include "core/dom/IntersectionObserver.h" 8 #include "core/dom/IntersectionObserver.h"
9 #include "core/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
10 #include "core/layout/LayoutBox.h" 10 #include "core/layout/LayoutBox.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 pixelSnappedIntRect(geometry.rootRect), 154 pixelSnappedIntRect(geometry.rootRect),
155 pixelSnappedIntRect(geometry.intersectionRect), 155 pixelSnappedIntRect(geometry.intersectionRect),
156 targetElement); 156 targetElement);
157 observer().enqueueIntersectionObserverEntry(*newEntry); 157 observer().enqueueIntersectionObserverEntry(*newEntry);
158 } 158 }
159 setLastThresholdIndex(newThresholdIndex); 159 setLastThresholdIndex(newThresholdIndex);
160 } 160 }
161 161
162 void IntersectionObservation::disconnect() 162 void IntersectionObservation::disconnect()
163 { 163 {
164 IntersectionObserver* observer = m_observer;
165 clearRootAndRemoveFromTarget();
166 observer->removeObservation(*this);
167 }
168
169 void IntersectionObservation::clearRootAndRemoveFromTarget()
170 {
164 if (m_target) 171 if (m_target)
165 target()->ensureIntersectionObserverData().removeObservation(this->obser ver()); 172 target()->ensureIntersectionObserverData().removeObservation(observer()) ;
166 m_observer->removeObservation(*this);
167 m_observer.clear(); 173 m_observer.clear();
168 } 174 }
169 175
170 DEFINE_TRACE(IntersectionObservation) 176 DEFINE_TRACE(IntersectionObservation)
171 { 177 {
172 visitor->trace(m_observer); 178 visitor->trace(m_observer);
173 visitor->trace(m_target); 179 visitor->trace(m_target);
174 } 180 }
175 181
176 } // namespace blink 182 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698