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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 1449623002: IntersectionObserver: second cut. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Add missing break, rebaseline, no config.h Created 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 14 matching lines...) Expand all
25 */ 25 */
26 26
27 #include "core/frame/FrameView.h" 27 #include "core/frame/FrameView.h"
28 28
29 #include "core/HTMLNames.h" 29 #include "core/HTMLNames.h"
30 #include "core/MediaTypeNames.h" 30 #include "core/MediaTypeNames.h"
31 #include "core/css/FontFaceSet.h" 31 #include "core/css/FontFaceSet.h"
32 #include "core/css/resolver/StyleResolver.h" 32 #include "core/css/resolver/StyleResolver.h"
33 #include "core/dom/AXObjectCache.h" 33 #include "core/dom/AXObjectCache.h"
34 #include "core/dom/Fullscreen.h" 34 #include "core/dom/Fullscreen.h"
35 #include "core/dom/IntersectionObserverController.h"
35 #include "core/editing/EditingUtilities.h" 36 #include "core/editing/EditingUtilities.h"
36 #include "core/editing/FrameSelection.h" 37 #include "core/editing/FrameSelection.h"
37 #include "core/editing/RenderedPosition.h" 38 #include "core/editing/RenderedPosition.h"
38 #include "core/editing/markers/DocumentMarkerController.h" 39 #include "core/editing/markers/DocumentMarkerController.h"
39 #include "core/fetch/ResourceFetcher.h" 40 #include "core/fetch/ResourceFetcher.h"
40 #include "core/frame/FrameHost.h" 41 #include "core/frame/FrameHost.h"
41 #include "core/frame/LocalFrame.h" 42 #include "core/frame/LocalFrame.h"
42 #include "core/frame/Settings.h" 43 #include "core/frame/Settings.h"
43 #include "core/html/HTMLFrameElement.h" 44 #include "core/html/HTMLFrameElement.h"
44 #include "core/html/HTMLPlugInElement.h" 45 #include "core/html/HTMLPlugInElement.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 static bool s_initialTrackAllPaintInvalidations = false; 114 static bool s_initialTrackAllPaintInvalidations = false;
114 115
115 FrameView::FrameView(LocalFrame* frame) 116 FrameView::FrameView(LocalFrame* frame)
116 : m_frame(frame) 117 : m_frame(frame)
117 , m_displayMode(WebDisplayModeBrowser) 118 , m_displayMode(WebDisplayModeBrowser)
118 , m_canHaveScrollbars(true) 119 , m_canHaveScrollbars(true)
119 , m_hasPendingLayout(false) 120 , m_hasPendingLayout(false)
120 , m_inSynchronousPostLayout(false) 121 , m_inSynchronousPostLayout(false)
121 , m_postLayoutTasksTimer(this, &FrameView::postLayoutTimerFired) 122 , m_postLayoutTasksTimer(this, &FrameView::postLayoutTimerFired)
122 , m_updateWidgetsTimer(this, &FrameView::updateWidgetsTimerFired) 123 , m_updateWidgetsTimer(this, &FrameView::updateWidgetsTimerFired)
123 , m_intersectionObserverNotificationFactory(CancellableTaskFactory::create(t his, &FrameView::notifyIntersectionObservers)) 124 , m_renderThrottlingObserverNotificationFactory(CancellableTaskFactory::crea te(this, &FrameView::notifyRenderThrottlingObservers))
124 , m_isTransparent(false) 125 , m_isTransparent(false)
125 , m_baseBackgroundColor(Color::white) 126 , m_baseBackgroundColor(Color::white)
126 , m_mediaType(MediaTypeNames::screen) 127 , m_mediaType(MediaTypeNames::screen)
127 , m_safeToPropagateScrollToParent(true) 128 , m_safeToPropagateScrollToParent(true)
128 , m_isTrackingPaintInvalidations(false) 129 , m_isTrackingPaintInvalidations(false)
129 , m_scrollCorner(nullptr) 130 , m_scrollCorner(nullptr)
130 , m_inputEventsScaleFactorForEmulation(1) 131 , m_inputEventsScaleFactorForEmulation(1)
131 , m_layoutSizeFixedToFrameSize(true) 132 , m_layoutSizeFixedToFrameSize(true)
132 , m_didScrollTimer(this, &FrameView::didScrollTimerFired) 133 , m_didScrollTimer(this, &FrameView::didScrollTimerFired)
133 , m_topControlsViewportAdjustment(0) 134 , m_topControlsViewportAdjustment(0)
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 279
279 // Destroy |m_autoSizeInfo| as early as possible, to avoid dereferencing 280 // Destroy |m_autoSizeInfo| as early as possible, to avoid dereferencing
280 // partially destroyed |this| via |m_autoSizeInfo->m_frameView|. 281 // partially destroyed |this| via |m_autoSizeInfo->m_frameView|.
281 m_autoSizeInfo.clear(); 282 m_autoSizeInfo.clear();
282 283
283 if (m_postLayoutTasksTimer.isActive()) 284 if (m_postLayoutTasksTimer.isActive())
284 m_postLayoutTasksTimer.stop(); 285 m_postLayoutTasksTimer.stop();
285 286
286 if (m_didScrollTimer.isActive()) 287 if (m_didScrollTimer.isActive())
287 m_didScrollTimer.stop(); 288 m_didScrollTimer.stop();
288 m_intersectionObserverNotificationFactory->cancel(); 289 m_renderThrottlingObserverNotificationFactory->cancel();
289 290
290 // FIXME: Do we need to do something here for OOPI? 291 // FIXME: Do we need to do something here for OOPI?
291 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); 292 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner();
292 // TODO(dcheng): It seems buggy that we can have an owner element that 293 // TODO(dcheng): It seems buggy that we can have an owner element that
293 // points to another Widget. 294 // points to another Widget.
294 if (ownerElement && ownerElement->ownedWidget() == this) 295 if (ownerElement && ownerElement->ownedWidget() == this)
295 ownerElement->setWidget(nullptr); 296 ownerElement->setWidget(nullptr);
296 297
297 #if ENABLE(ASSERT) 298 #if ENABLE(ASSERT)
298 m_hasBeenDisposed = true; 299 m_hasBeenDisposed = true;
(...skipping 2063 matching lines...) Expand 10 before | Expand all | Expand 10 after
2362 // Otherwise the lifecycles of the frames might be out of sync. 2363 // Otherwise the lifecycles of the frames might be out of sync.
2363 ASSERT(m_frame->isLocalRoot()); 2364 ASSERT(m_frame->isLocalRoot());
2364 2365
2365 // Updating layout can run script, which can tear down the FrameView. 2366 // Updating layout can run script, which can tear down the FrameView.
2366 RefPtrWillBeRawPtr<FrameView> protector(this); 2367 RefPtrWillBeRawPtr<FrameView> protector(this);
2367 2368
2368 updateStyleAndLayoutIfNeededRecursive(); 2369 updateStyleAndLayoutIfNeededRecursive();
2369 ASSERT(lifecycle().state() >= DocumentLifecycle::LayoutClean); 2370 ASSERT(lifecycle().state() >= DocumentLifecycle::LayoutClean);
2370 2371
2371 if (phases == OnlyUpToLayoutClean) { 2372 if (phases == OnlyUpToLayoutClean) {
2372 updateViewportIntersectionsForSubtree(); 2373 updateViewportIntersectionsForSubtree(phases);
2373 return; 2374 return;
2374 } 2375 }
2375 2376
2376 if (LayoutView* view = layoutView()) { 2377 if (LayoutView* view = layoutView()) {
2377 { 2378 {
2378 TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", Inspect orUpdateLayerTreeEvent::data(m_frame.get())); 2379 TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", Inspect orUpdateLayerTreeEvent::data(m_frame.get()));
2379 2380
2380 // This was required for slimming paint v1 but is only temporarily 2381 // This was required for slimming paint v1 but is only temporarily
2381 // needed for slimming paint v2. 2382 // needed for slimming paint v2.
2382 view->compositor()->updateIfNeededRecursive(); 2383 view->compositor()->updateIfNeededRecursive();
(...skipping 23 matching lines...) Expand all
2406 2407
2407 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 2408 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
2408 pushPaintArtifactToCompositor(); 2409 pushPaintArtifactToCompositor();
2409 2410
2410 ASSERT(!view->hasPendingSelection()); 2411 ASSERT(!view->hasPendingSelection());
2411 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationCl ean 2412 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationCl ean
2412 || (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEna bled() && lifecycle().state() == DocumentLifecycle::PaintClean)); 2413 || (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEna bled() && lifecycle().state() == DocumentLifecycle::PaintClean));
2413 } 2414 }
2414 } 2415 }
2415 2416
2416 updateViewportIntersectionsForSubtree(); 2417 updateViewportIntersectionsForSubtree(phases);
2417 } 2418 }
2418 2419
2419 void FrameView::updatePaintProperties() 2420 void FrameView::updatePaintProperties()
2420 { 2421 {
2421 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); 2422 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
2422 2423
2423 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::InUpdatePaintProperties); }); 2424 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::InUpdatePaintProperties); });
2424 PaintPropertyTreeBuilder().buildPropertyTrees(*this); 2425 PaintPropertyTreeBuilder().buildPropertyTrees(*this);
2425 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::UpdatePaintPropertiesClean); }); 2426 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::UpdatePaintPropertiesClean); });
2426 } 2427 }
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after
3903 3904
3904 void FrameView::setNeedsUpdateViewportIntersection() 3905 void FrameView::setNeedsUpdateViewportIntersection()
3905 { 3906 {
3906 m_needsUpdateViewportIntersection = true; 3907 m_needsUpdateViewportIntersection = true;
3907 for (FrameView* parent = parentFrameView(); parent; parent = parent->parentF rameView()) 3908 for (FrameView* parent = parentFrameView(); parent; parent = parent->parentF rameView())
3908 parent->m_needsUpdateViewportIntersectionInSubtree = true; 3909 parent->m_needsUpdateViewportIntersectionInSubtree = true;
3909 } 3910 }
3910 3911
3911 void FrameView::updateViewportIntersectionIfNeeded() 3912 void FrameView::updateViewportIntersectionIfNeeded()
3912 { 3913 {
3913 // TODO(skyostil): Replace this with a real intersection observer.
3914 if (!m_needsUpdateViewportIntersection) 3914 if (!m_needsUpdateViewportIntersection)
3915 return; 3915 return;
3916 m_needsUpdateViewportIntersection = false; 3916 m_needsUpdateViewportIntersection = false;
3917 m_viewportIntersectionValid = true; 3917 m_viewportIntersectionValid = true;
3918
3919 FrameView* parent = parentFrameView(); 3918 FrameView* parent = parentFrameView();
3920 if (!parent) { 3919 if (!parent) {
3921 m_viewportIntersection = frameRect(); 3920 m_viewportIntersection = frameRect();
3922 return; 3921 return;
3923 } 3922 }
3924 ASSERT(!parent->m_needsUpdateViewportIntersection); 3923 ASSERT(!parent->m_needsUpdateViewportIntersection);
3925 3924
3926 // If our parent is hidden, then we are too. 3925 // If our parent is hidden, then we are too.
3927 if (parent->m_viewportIntersection.isEmpty()) { 3926 if (parent->m_viewportIntersection.isEmpty()) {
3928 m_viewportIntersection = parent->m_viewportIntersection; 3927 m_viewportIntersection = parent->m_viewportIntersection;
3929 return; 3928 return;
3930 } 3929 }
3931 3930
3932 // Transform our bounds into the root frame's content coordinate space, 3931 // Transform our bounds into the root frame's content coordinate space,
3933 // making sure we have valid layout data in our parent document. If our 3932 // making sure we have valid layout data in our parent document. If our
3934 // parent is throttled, we'll use possible stale layout information and 3933 // parent is throttled, we'll use possible stale layout information and
3935 // rely on the fact that another lifecycle update will be scheduled once 3934 // rely on the fact that another lifecycle update will be scheduled once
3936 // our parent becomes unthrottled. 3935 // our parent becomes unthrottled.
3937 ASSERT(parent->lifecycle().state() >= DocumentLifecycle::LayoutClean || pare nt->shouldThrottleRendering()); 3936 ASSERT(parent->lifecycle().state() >= DocumentLifecycle::LayoutClean || pare nt->shouldThrottleRendering());
3938 m_viewportIntersection = parent->contentsToRootFrame(frameRect()); 3937 m_viewportIntersection = parent->contentsToRootFrame(frameRect());
3939 3938
3940 // TODO(skyostil): Expand the viewport to make it less likely to see stale c ontent while scrolling. 3939 // TODO(skyostil): Expand the viewport to make it less likely to see stale c ontent while scrolling.
3941 IntRect viewport = parent->m_viewportIntersection; 3940 IntRect viewport = parent->m_viewportIntersection;
3942 m_viewportIntersection.intersect(viewport); 3941 m_viewportIntersection.intersect(viewport);
3943 } 3942 }
3944 3943
3945 void FrameView::updateViewportIntersectionsForSubtree() 3944 void FrameView::updateViewportIntersectionsForSubtree(LifeCycleUpdateOption phas es)
3946 { 3945 {
3947 bool hadValidIntersection = m_viewportIntersectionValid; 3946 bool hadValidIntersection = m_viewportIntersectionValid;
3948 bool hadEmptyIntersection = m_viewportIntersection.isEmpty(); 3947 bool hadEmptyIntersection = m_viewportIntersection.isEmpty();
3949 updateViewportIntersectionIfNeeded(); 3948 updateViewportIntersectionIfNeeded();
3949
3950 // Notify javascript IntersectionObservers
3951 if (phases == AllPhases)
3952 frame().document()->intersectionObserverController().computeTrackedInter sectionObservations();
3953
3954 // Adjust render throttling for iframes based on visibility
3950 bool shouldNotify = !hadValidIntersection || hadEmptyIntersection != m_viewp ortIntersection.isEmpty(); 3955 bool shouldNotify = !hadValidIntersection || hadEmptyIntersection != m_viewp ortIntersection.isEmpty();
3951 if (shouldNotify && !m_intersectionObserverNotificationFactory->isPending()) 3956 if (shouldNotify && !m_renderThrottlingObserverNotificationFactory->isPendin g())
3952 m_frame->frameScheduler()->timerTaskRunner()->postTask(BLINK_FROM_HERE, m_intersectionObserverNotificationFactory->cancelAndCreate()); 3957 m_frame->frameScheduler()->timerTaskRunner()->postTask(BLINK_FROM_HERE, m_renderThrottlingObserverNotificationFactory->cancelAndCreate());
3953 3958
3954 if (!m_needsUpdateViewportIntersectionInSubtree) 3959 if (!m_needsUpdateViewportIntersectionInSubtree)
3955 return; 3960 return;
3956 m_needsUpdateViewportIntersectionInSubtree = false; 3961 m_needsUpdateViewportIntersectionInSubtree = false;
3957 3962
3958 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { 3963 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) {
3959 if (!child->isLocalFrame()) 3964 if (!child->isLocalFrame())
3960 continue; 3965 continue;
3961 if (FrameView* view = toLocalFrame(child)->view()) 3966 if (FrameView* view = toLocalFrame(child)->view())
3962 view->updateViewportIntersectionsForSubtree(); 3967 view->updateViewportIntersectionsForSubtree(phases);
3963 } 3968 }
3964 } 3969 }
3965 3970
3966 void FrameView::notifyIntersectionObservers() 3971 void FrameView::notifyRenderThrottlingObservers()
3967 { 3972 {
3968 TRACE_EVENT0("blink", "FrameView::notifyIntersectionObservers"); 3973 TRACE_EVENT0("blink", "FrameView::notifyRenderThrottlingObservers");
3969 ASSERT(!isInPerformLayout()); 3974 ASSERT(!isInPerformLayout());
3970 ASSERT(!m_frame->document()->inStyleRecalc()); 3975 ASSERT(!m_frame->document()->inStyleRecalc());
3971 bool wasThrottled = canThrottleRendering(); 3976 bool wasThrottled = canThrottleRendering();
3972 3977
3973 // Only offscreen frames can be throttled. 3978 // Only offscreen frames can be throttled.
3974 m_hiddenForThrottling = m_viewportIntersectionValid && m_viewportIntersectio n.isEmpty(); 3979 m_hiddenForThrottling = m_viewportIntersectionValid && m_viewportIntersectio n.isEmpty();
3975 3980
3976 // We only throttle the rendering pipeline in cross-origin frames. This is 3981 // We only throttle the rendering pipeline in cross-origin frames. This is
3977 // to avoid a situation where an ancestor frame directly depends on the 3982 // to avoid a situation where an ancestor frame directly depends on the
3978 // pipeline timing of a descendant and breaks as a result of throttling. 3983 // pipeline timing of a descendant and breaks as a result of throttling.
(...skipping 29 matching lines...) Expand all
4008 return m_hiddenForThrottling && m_crossOriginForThrottling; 4013 return m_hiddenForThrottling && m_crossOriginForThrottling;
4009 } 4014 }
4010 4015
4011 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const 4016 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const
4012 { 4017 {
4013 ASSERT(layoutView()); 4018 ASSERT(layoutView());
4014 return *layoutView(); 4019 return *layoutView();
4015 } 4020 }
4016 4021
4017 } // namespace blink 4022 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698