OLD | NEW |
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 15 matching lines...) Expand all Loading... |
26 | 26 |
27 #include "config.h" | 27 #include "config.h" |
28 #include "core/frame/FrameView.h" | 28 #include "core/frame/FrameView.h" |
29 | 29 |
30 #include "core/HTMLNames.h" | 30 #include "core/HTMLNames.h" |
31 #include "core/MediaTypeNames.h" | 31 #include "core/MediaTypeNames.h" |
32 #include "core/css/FontFaceSet.h" | 32 #include "core/css/FontFaceSet.h" |
33 #include "core/css/resolver/StyleResolver.h" | 33 #include "core/css/resolver/StyleResolver.h" |
34 #include "core/dom/AXObjectCache.h" | 34 #include "core/dom/AXObjectCache.h" |
35 #include "core/dom/Fullscreen.h" | 35 #include "core/dom/Fullscreen.h" |
| 36 #include "core/dom/IntersectionObserverController.h" |
36 #include "core/editing/EditingUtilities.h" | 37 #include "core/editing/EditingUtilities.h" |
37 #include "core/editing/FrameSelection.h" | 38 #include "core/editing/FrameSelection.h" |
38 #include "core/editing/RenderedPosition.h" | 39 #include "core/editing/RenderedPosition.h" |
39 #include "core/editing/markers/DocumentMarkerController.h" | 40 #include "core/editing/markers/DocumentMarkerController.h" |
40 #include "core/fetch/ResourceFetcher.h" | 41 #include "core/fetch/ResourceFetcher.h" |
41 #include "core/frame/FrameHost.h" | 42 #include "core/frame/FrameHost.h" |
42 #include "core/frame/LocalFrame.h" | 43 #include "core/frame/LocalFrame.h" |
43 #include "core/frame/Settings.h" | 44 #include "core/frame/Settings.h" |
44 #include "core/html/HTMLFrameElement.h" | 45 #include "core/html/HTMLFrameElement.h" |
45 #include "core/html/HTMLPlugInElement.h" | 46 #include "core/html/HTMLPlugInElement.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 static bool s_initialTrackAllPaintInvalidations = false; | 115 static bool s_initialTrackAllPaintInvalidations = false; |
115 | 116 |
116 FrameView::FrameView(LocalFrame* frame) | 117 FrameView::FrameView(LocalFrame* frame) |
117 : m_frame(frame) | 118 : m_frame(frame) |
118 , m_displayMode(WebDisplayModeBrowser) | 119 , m_displayMode(WebDisplayModeBrowser) |
119 , m_canHaveScrollbars(true) | 120 , m_canHaveScrollbars(true) |
120 , m_hasPendingLayout(false) | 121 , m_hasPendingLayout(false) |
121 , m_inSynchronousPostLayout(false) | 122 , m_inSynchronousPostLayout(false) |
122 , m_postLayoutTasksTimer(this, &FrameView::postLayoutTimerFired) | 123 , m_postLayoutTasksTimer(this, &FrameView::postLayoutTimerFired) |
123 , m_updateWidgetsTimer(this, &FrameView::updateWidgetsTimerFired) | 124 , m_updateWidgetsTimer(this, &FrameView::updateWidgetsTimerFired) |
124 , m_intersectionObserverNotificationFactory(CancellableTaskFactory::create(t
his, &FrameView::notifyIntersectionObservers)) | 125 , m_renderThrottlingObserverNotificationFactory(CancellableTaskFactory::crea
te(this, &FrameView::notifyRenderThrottlingObservers)) |
125 , m_isTransparent(false) | 126 , m_isTransparent(false) |
126 , m_baseBackgroundColor(Color::white) | 127 , m_baseBackgroundColor(Color::white) |
127 , m_mediaType(MediaTypeNames::screen) | 128 , m_mediaType(MediaTypeNames::screen) |
128 , m_safeToPropagateScrollToParent(true) | 129 , m_safeToPropagateScrollToParent(true) |
129 , m_isTrackingPaintInvalidations(false) | 130 , m_isTrackingPaintInvalidations(false) |
130 , m_scrollCorner(nullptr) | 131 , m_scrollCorner(nullptr) |
131 , m_inputEventsScaleFactorForEmulation(1) | 132 , m_inputEventsScaleFactorForEmulation(1) |
132 , m_layoutSizeFixedToFrameSize(true) | 133 , m_layoutSizeFixedToFrameSize(true) |
133 , m_didScrollTimer(this, &FrameView::didScrollTimerFired) | 134 , m_didScrollTimer(this, &FrameView::didScrollTimerFired) |
134 , m_topControlsViewportAdjustment(0) | 135 , m_topControlsViewportAdjustment(0) |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 2070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2369 // Otherwise the lifecycles of the frames might be out of sync. | 2370 // Otherwise the lifecycles of the frames might be out of sync. |
2370 ASSERT(m_frame->isLocalRoot()); | 2371 ASSERT(m_frame->isLocalRoot()); |
2371 | 2372 |
2372 // Updating layout can run script, which can tear down the FrameView. | 2373 // Updating layout can run script, which can tear down the FrameView. |
2373 RefPtrWillBeRawPtr<FrameView> protector(this); | 2374 RefPtrWillBeRawPtr<FrameView> protector(this); |
2374 | 2375 |
2375 updateStyleAndLayoutIfNeededRecursive(); | 2376 updateStyleAndLayoutIfNeededRecursive(); |
2376 ASSERT(lifecycle().state() >= DocumentLifecycle::LayoutClean); | 2377 ASSERT(lifecycle().state() >= DocumentLifecycle::LayoutClean); |
2377 | 2378 |
2378 if (phases == OnlyUpToLayoutClean) { | 2379 if (phases == OnlyUpToLayoutClean) { |
2379 updateViewportIntersectionsForSubtree(); | 2380 updateViewportIntersectionsForSubtree(phases); |
2380 return; | 2381 return; |
2381 } | 2382 } |
2382 | 2383 |
2383 if (LayoutView* view = layoutView()) { | 2384 if (LayoutView* view = layoutView()) { |
2384 { | 2385 { |
2385 TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", Inspect
orUpdateLayerTreeEvent::data(m_frame.get())); | 2386 TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", Inspect
orUpdateLayerTreeEvent::data(m_frame.get())); |
2386 | 2387 |
2387 // This was required for slimming paint v1 but is only temporarily | 2388 // This was required for slimming paint v1 but is only temporarily |
2388 // needed for slimming paint v2. | 2389 // needed for slimming paint v2. |
2389 view->compositor()->updateIfNeededRecursive(); | 2390 view->compositor()->updateIfNeededRecursive(); |
(...skipping 23 matching lines...) Expand all Loading... |
2413 | 2414 |
2414 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 2415 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
2415 pushPaintArtifactToCompositor(); | 2416 pushPaintArtifactToCompositor(); |
2416 | 2417 |
2417 ASSERT(!view->hasPendingSelection()); | 2418 ASSERT(!view->hasPendingSelection()); |
2418 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationCl
ean | 2419 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationCl
ean |
2419 || (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEna
bled() && lifecycle().state() == DocumentLifecycle::PaintClean)); | 2420 || (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEna
bled() && lifecycle().state() == DocumentLifecycle::PaintClean)); |
2420 } | 2421 } |
2421 } | 2422 } |
2422 | 2423 |
2423 updateViewportIntersectionsForSubtree(); | 2424 updateViewportIntersectionsForSubtree(phases); |
2424 } | 2425 } |
2425 | 2426 |
2426 void FrameView::updatePaintProperties() | 2427 void FrameView::updatePaintProperties() |
2427 { | 2428 { |
2428 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 2429 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
2429 | 2430 |
2430 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle(
).advanceTo(DocumentLifecycle::InUpdatePaintProperties); }); | 2431 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle(
).advanceTo(DocumentLifecycle::InUpdatePaintProperties); }); |
2431 PaintPropertyTreeBuilder().buildPropertyTrees(*this); | 2432 PaintPropertyTreeBuilder().buildPropertyTrees(*this); |
2432 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle(
).advanceTo(DocumentLifecycle::UpdatePaintPropertiesClean); }); | 2433 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle(
).advanceTo(DocumentLifecycle::UpdatePaintPropertiesClean); }); |
2433 } | 2434 } |
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3904 | 3905 |
3905 void FrameView::setNeedsUpdateViewportIntersection() | 3906 void FrameView::setNeedsUpdateViewportIntersection() |
3906 { | 3907 { |
3907 m_needsUpdateViewportIntersection = true; | 3908 m_needsUpdateViewportIntersection = true; |
3908 for (FrameView* parent = parentFrameView(); parent; parent = parent->parentF
rameView()) | 3909 for (FrameView* parent = parentFrameView(); parent; parent = parent->parentF
rameView()) |
3909 parent->m_needsUpdateViewportIntersectionInSubtree = true; | 3910 parent->m_needsUpdateViewportIntersectionInSubtree = true; |
3910 } | 3911 } |
3911 | 3912 |
3912 void FrameView::updateViewportIntersectionIfNeeded() | 3913 void FrameView::updateViewportIntersectionIfNeeded() |
3913 { | 3914 { |
3914 // TODO(skyostil): Replace this with a real intersection observer. | |
3915 if (!m_needsUpdateViewportIntersection) | 3915 if (!m_needsUpdateViewportIntersection) |
3916 return; | 3916 return; |
3917 m_needsUpdateViewportIntersection = false; | 3917 m_needsUpdateViewportIntersection = false; |
3918 m_viewportIntersectionValid = true; | 3918 m_viewportIntersectionValid = true; |
3919 | |
3920 FrameView* parent = parentFrameView(); | 3919 FrameView* parent = parentFrameView(); |
3921 if (!parent) { | 3920 if (!parent) { |
3922 m_viewportIntersection = frameRect(); | 3921 m_viewportIntersection = frameRect(); |
3923 return; | 3922 return; |
3924 } | 3923 } |
3925 ASSERT(!parent->m_needsUpdateViewportIntersection); | 3924 ASSERT(!parent->m_needsUpdateViewportIntersection); |
3926 | 3925 |
3927 // If our parent is hidden, then we are too. | 3926 // If our parent is hidden, then we are too. |
3928 if (parent->m_viewportIntersection.isEmpty()) { | 3927 if (parent->m_viewportIntersection.isEmpty()) { |
3929 m_viewportIntersection = parent->m_viewportIntersection; | 3928 m_viewportIntersection = parent->m_viewportIntersection; |
3930 return; | 3929 return; |
3931 } | 3930 } |
3932 | 3931 |
3933 // Transform our bounds into the root frame's content coordinate space, | 3932 // Transform our bounds into the root frame's content coordinate space, |
3934 // making sure we have valid layout data in our parent document. If our | 3933 // making sure we have valid layout data in our parent document. If our |
3935 // parent is throttled, we'll use possible stale layout information and | 3934 // parent is throttled, we'll use possible stale layout information and |
3936 // rely on the fact that another lifecycle update will be scheduled once | 3935 // rely on the fact that another lifecycle update will be scheduled once |
3937 // our parent becomes unthrottled. | 3936 // our parent becomes unthrottled. |
3938 ASSERT(parent->lifecycle().state() >= DocumentLifecycle::LayoutClean || pare
nt->shouldThrottleRendering()); | 3937 ASSERT(parent->lifecycle().state() >= DocumentLifecycle::LayoutClean || pare
nt->shouldThrottleRendering()); |
3939 m_viewportIntersection = parent->contentsToRootFrame(frameRect()); | 3938 m_viewportIntersection = parent->contentsToRootFrame(frameRect()); |
3940 | 3939 |
3941 // TODO(skyostil): Expand the viewport to make it less likely to see stale c
ontent while scrolling. | 3940 // TODO(skyostil): Expand the viewport to make it less likely to see stale c
ontent while scrolling. |
3942 IntRect viewport = parent->m_viewportIntersection; | 3941 IntRect viewport = parent->m_viewportIntersection; |
3943 m_viewportIntersection.intersect(viewport); | 3942 m_viewportIntersection.intersect(viewport); |
3944 } | 3943 } |
3945 | 3944 |
3946 void FrameView::updateViewportIntersectionsForSubtree() | 3945 void FrameView::updateViewportIntersectionsForSubtree(LifeCycleUpdateOption phas
es) |
3947 { | 3946 { |
3948 bool hadValidIntersection = m_viewportIntersectionValid; | 3947 bool hadValidIntersection = m_viewportIntersectionValid; |
3949 bool hadEmptyIntersection = m_viewportIntersection.isEmpty(); | 3948 bool hadEmptyIntersection = m_viewportIntersection.isEmpty(); |
3950 updateViewportIntersectionIfNeeded(); | 3949 updateViewportIntersectionIfNeeded(); |
| 3950 |
| 3951 // Notify javascript IntersectionObservers |
| 3952 if (phases == AllPhases) |
| 3953 frame().document()->intersectionObserverController()->computeTrackedInte
rsectionObservations(); |
| 3954 |
| 3955 // Adjust render throttling for iframes based on visibility |
3951 bool shouldNotify = !hadValidIntersection || hadEmptyIntersection != m_viewp
ortIntersection.isEmpty(); | 3956 bool shouldNotify = !hadValidIntersection || hadEmptyIntersection != m_viewp
ortIntersection.isEmpty(); |
3952 if (shouldNotify && !m_intersectionObserverNotificationFactory->isPending()) | 3957 if (shouldNotify && !m_renderThrottlingObserverNotificationFactory->isPendin
g()) |
3953 m_frame->frameScheduler()->timerTaskRunner()->postTask(BLINK_FROM_HERE,
m_intersectionObserverNotificationFactory->cancelAndCreate()); | 3958 m_frame->frameScheduler()->timerTaskRunner()->postTask(BLINK_FROM_HERE,
m_renderThrottlingObserverNotificationFactory->cancelAndCreate()); |
3954 | 3959 |
3955 if (!m_needsUpdateViewportIntersectionInSubtree) | 3960 if (!m_needsUpdateViewportIntersectionInSubtree) |
3956 return; | 3961 return; |
3957 m_needsUpdateViewportIntersectionInSubtree = false; | 3962 m_needsUpdateViewportIntersectionInSubtree = false; |
3958 | 3963 |
3959 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree
().nextSibling()) { | 3964 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree
().nextSibling()) { |
3960 if (!child->isLocalFrame()) | 3965 if (!child->isLocalFrame()) |
3961 continue; | 3966 continue; |
3962 if (FrameView* view = toLocalFrame(child)->view()) | 3967 if (FrameView* view = toLocalFrame(child)->view()) |
3963 view->updateViewportIntersectionsForSubtree(); | 3968 view->updateViewportIntersectionsForSubtree(phases); |
3964 } | 3969 } |
3965 } | 3970 } |
3966 | 3971 |
3967 void FrameView::notifyIntersectionObservers() | 3972 void FrameView::notifyRenderThrottlingObservers() |
3968 { | 3973 { |
3969 TRACE_EVENT0("blink", "FrameView::notifyIntersectionObservers"); | 3974 TRACE_EVENT0("blink", "FrameView::notifyRenderThrottlingObservers"); |
3970 ASSERT(!isInPerformLayout()); | 3975 ASSERT(!isInPerformLayout()); |
3971 ASSERT(!m_frame->document()->inStyleRecalc()); | 3976 ASSERT(!m_frame->document()->inStyleRecalc()); |
3972 bool wasThrottled = canThrottleRendering(); | 3977 bool wasThrottled = canThrottleRendering(); |
3973 | 3978 |
3974 // Only offscreen frames can be throttled. | 3979 // Only offscreen frames can be throttled. |
3975 m_hiddenForThrottling = m_viewportIntersectionValid && m_viewportIntersectio
n.isEmpty(); | 3980 m_hiddenForThrottling = m_viewportIntersectionValid && m_viewportIntersectio
n.isEmpty(); |
3976 | 3981 |
3977 // We only throttle the rendering pipeline in cross-origin frames. This is | 3982 // We only throttle the rendering pipeline in cross-origin frames. This is |
3978 // to avoid a situation where an ancestor frame directly depends on the | 3983 // to avoid a situation where an ancestor frame directly depends on the |
3979 // pipeline timing of a descendant and breaks as a result of throttling. | 3984 // pipeline timing of a descendant and breaks as a result of throttling. |
(...skipping 29 matching lines...) Expand all Loading... |
4009 return m_hiddenForThrottling && m_crossOriginForThrottling; | 4014 return m_hiddenForThrottling && m_crossOriginForThrottling; |
4010 } | 4015 } |
4011 | 4016 |
4012 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const | 4017 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const |
4013 { | 4018 { |
4014 ASSERT(layoutView()); | 4019 ASSERT(layoutView()); |
4015 return *layoutView(); | 4020 return *layoutView(); |
4016 } | 4021 } |
4017 | 4022 |
4018 } // namespace blink | 4023 } // namespace blink |
OLD | NEW |