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

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

Issue 1988633002: Schedule a frame from IntersectionObserver::observe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: test fixes Created 4 years, 7 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/IntersectionObserver.h" 5 #include "core/dom/IntersectionObserver.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "core/css/parser/CSSParserTokenRange.h" 8 #include "core/css/parser/CSSParserTokenRange.h"
9 #include "core/css/parser/CSSTokenizer.h" 9 #include "core/css/parser/CSSTokenizer.h"
10 #include "core/dom/Element.h" 10 #include "core/dom/Element.h"
11 #include "core/dom/ExceptionCode.h" 11 #include "core/dom/ExceptionCode.h"
12 #include "core/dom/ExecutionContext.h" 12 #include "core/dom/ExecutionContext.h"
13 #include "core/dom/IntersectionObserverCallback.h" 13 #include "core/dom/IntersectionObserverCallback.h"
14 #include "core/dom/IntersectionObserverController.h" 14 #include "core/dom/IntersectionObserverController.h"
15 #include "core/dom/IntersectionObserverEntry.h" 15 #include "core/dom/IntersectionObserverEntry.h"
16 #include "core/dom/IntersectionObserverInit.h" 16 #include "core/dom/IntersectionObserverInit.h"
17 #include "core/dom/NodeIntersectionObserverData.h" 17 #include "core/dom/NodeIntersectionObserverData.h"
18 #include "core/frame/FrameView.h"
18 #include "core/html/HTMLFrameOwnerElement.h" 19 #include "core/html/HTMLFrameOwnerElement.h"
19 #include "core/layout/LayoutView.h" 20 #include "core/layout/LayoutView.h"
20 #include "core/timing/DOMWindowPerformance.h" 21 #include "core/timing/DOMWindowPerformance.h"
21 #include "core/timing/Performance.h" 22 #include "core/timing/Performance.h"
22 #include "platform/Timer.h" 23 #include "platform/Timer.h"
23 #include <algorithm> 24 #include <algorithm>
24 25
25 namespace blink { 26 namespace blink {
26 27
27 static void parseRootMargin(String rootMarginParameter, Vector<Length>& rootMarg in, ExceptionState& exceptionState) 28 static void parseRootMargin(String rootMarginParameter, Vector<Length>& rootMarg in, ExceptionState& exceptionState)
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 return; 177 return;
177 178
178 bool shouldReportRootBounds = false; 179 bool shouldReportRootBounds = false;
179 LocalFrame* targetFrame = target->document().frame(); 180 LocalFrame* targetFrame = target->document().frame();
180 LocalFrame* rootFrame = rootNode()->document().frame(); 181 LocalFrame* rootFrame = rootNode()->document().frame();
181 if (targetFrame && rootFrame) 182 if (targetFrame && rootFrame)
182 shouldReportRootBounds = targetFrame->securityContext()->getSecurityOrig in()->canAccess(rootFrame->securityContext()->getSecurityOrigin()); 183 shouldReportRootBounds = targetFrame->securityContext()->getSecurityOrig in()->canAccess(rootFrame->securityContext()->getSecurityOrigin());
183 IntersectionObservation* observation = new IntersectionObservation(*this, *t arget, shouldReportRootBounds); 184 IntersectionObservation* observation = new IntersectionObservation(*this, *t arget, shouldReportRootBounds);
184 target->ensureIntersectionObserverData().addObservation(*observation); 185 target->ensureIntersectionObserverData().addObservation(*observation);
185 m_observations.add(observation); 186 m_observations.add(observation);
187 if (!rootFrame)
188 return;
189 if (FrameView* rootFrameView = rootFrame->view())
190 rootFrameView->scheduleAnimation();
esprehn 2016/05/20 22:40:52 I think this is probably broken for OOPIF, we need
szager1 2016/05/20 22:42:12 Oh yes, undoubtedly, IO is completely broken for O
186 } 191 }
187 192
188 void IntersectionObserver::unobserve(Element* target) 193 void IntersectionObserver::unobserve(Element* target)
189 { 194 {
190 if (!target || !target->intersectionObserverData()) 195 if (!target || !target->intersectionObserverData())
191 return; 196 return;
192 // TODO(szager): unobserve callback 197 // TODO(szager): unobserve callback
193 if (IntersectionObservation* observation = target->intersectionObserverData( )->getObservationFor(*this)) 198 if (IntersectionObservation* observation = target->intersectionObserverData( )->getObservationFor(*this))
194 observation->disconnect(); 199 observation->disconnect();
195 } 200 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 311
307 DEFINE_TRACE(IntersectionObserver) 312 DEFINE_TRACE(IntersectionObserver)
308 { 313 {
309 visitor->template registerWeakMembers<IntersectionObserver, &IntersectionObs erver::clearWeakMembers>(this); 314 visitor->template registerWeakMembers<IntersectionObserver, &IntersectionObs erver::clearWeakMembers>(this);
310 visitor->trace(m_callback); 315 visitor->trace(m_callback);
311 visitor->trace(m_observations); 316 visitor->trace(m_observations);
312 visitor->trace(m_entries); 317 visitor->trace(m_entries);
313 } 318 }
314 319
315 } // namespace blink 320 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698