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/IntersectionObserverRegistry.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 2067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2366 // This must be called from the root frame, since it recurses down, not up. | 2367 // This must be called from the root frame, since it recurses down, not up. |
2367 // Otherwise the lifecycles of the frames might be out of sync. | 2368 // Otherwise the lifecycles of the frames might be out of sync. |
2368 ASSERT(m_frame->isLocalRoot()); | 2369 ASSERT(m_frame->isLocalRoot()); |
2369 | 2370 |
2370 // Updating layout can run script, which can tear down the FrameView. | 2371 // Updating layout can run script, which can tear down the FrameView. |
2371 RefPtrWillBeRawPtr<FrameView> protector(this); | 2372 RefPtrWillBeRawPtr<FrameView> protector(this); |
2372 | 2373 |
2373 updateStyleAndLayoutIfNeededRecursive(); | 2374 updateStyleAndLayoutIfNeededRecursive(); |
2374 ASSERT(lifecycle().state() >= DocumentLifecycle::LayoutClean); | 2375 ASSERT(lifecycle().state() >= DocumentLifecycle::LayoutClean); |
2375 | 2376 |
2376 if (phases == OnlyUpToLayoutClean) { | 2377 if (phases == OnlyUpToLayoutClean) |
2377 updateViewportIntersectionsForSubtree(); | |
2378 return; | 2378 return; |
2379 } | |
2380 | 2379 |
2381 if (LayoutView* view = layoutView()) { | 2380 if (LayoutView* view = layoutView()) { |
2382 { | 2381 { |
2383 TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", Inspect
orUpdateLayerTreeEvent::data(m_frame.get())); | 2382 TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", Inspect
orUpdateLayerTreeEvent::data(m_frame.get())); |
2384 | 2383 |
2385 // This was required for slimming paint v1 but is only temporarily | 2384 // This was required for slimming paint v1 but is only temporarily |
2386 // needed for slimming paint v2. | 2385 // needed for slimming paint v2. |
2387 view->compositor()->updateIfNeededRecursive(); | 2386 view->compositor()->updateIfNeededRecursive(); |
2388 scrollContentsIfNeededRecursive(); | 2387 scrollContentsIfNeededRecursive(); |
2389 | 2388 |
(...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3878 | 3877 |
3879 void FrameView::setNeedsUpdateViewportIntersection() | 3878 void FrameView::setNeedsUpdateViewportIntersection() |
3880 { | 3879 { |
3881 m_needsUpdateViewportIntersection = true; | 3880 m_needsUpdateViewportIntersection = true; |
3882 for (FrameView* parent = parentFrameView(); parent; parent = parent->parentF
rameView()) | 3881 for (FrameView* parent = parentFrameView(); parent; parent = parent->parentF
rameView()) |
3883 parent->m_needsUpdateViewportIntersectionInSubtree = true; | 3882 parent->m_needsUpdateViewportIntersectionInSubtree = true; |
3884 } | 3883 } |
3885 | 3884 |
3886 void FrameView::updateViewportIntersectionIfNeeded() | 3885 void FrameView::updateViewportIntersectionIfNeeded() |
3887 { | 3886 { |
3888 // TODO(skyostil): Replace this with a real intersection observer. | 3887 if (m_needsUpdateViewportIntersection) { |
3889 if (!m_needsUpdateViewportIntersection) | 3888 FrameView* parent = parentFrameView(); |
3890 return; | 3889 if (parent) { |
| 3890 ASSERT(!parent->m_needsUpdateViewportIntersection); |
| 3891 |
| 3892 // If our parent is hidden, then we are too. |
| 3893 if (parent->m_viewportIntersection.isEmpty()) { |
| 3894 m_viewportIntersection = parent->m_viewportIntersection; |
| 3895 } else { |
| 3896 // Transform our bounds into the root frame's content coordinate
space, |
| 3897 // making sure we have valid layout data in our parent document.
If our |
| 3898 // parent is throttled, we'll use possible stale layout informat
ion and |
| 3899 // rely on the fact that another lifecycle update will be schedu
led once |
| 3900 // our parent becomes unthrottled. |
| 3901 ASSERT(parent->lifecycle().state() >= DocumentLifecycle::LayoutC
lean || parent->shouldThrottleRendering()); |
| 3902 m_viewportIntersection = parent->contentsToRootFrame(frameRect()
); |
| 3903 |
| 3904 // TODO(skyostil): Expand the viewport to make it less likely to
see stale content while scrolling. |
| 3905 IntRect viewport = parent->m_viewportIntersection; |
| 3906 m_viewportIntersection.intersect(viewport); |
| 3907 } |
| 3908 } else { |
| 3909 m_viewportIntersection = frameRect(); |
| 3910 } |
| 3911 } |
| 3912 |
3891 m_needsUpdateViewportIntersection = false; | 3913 m_needsUpdateViewportIntersection = false; |
3892 m_viewportIntersectionValid = true; | 3914 m_viewportIntersectionValid = true; |
3893 | |
3894 FrameView* parent = parentFrameView(); | |
3895 if (!parent) { | |
3896 m_viewportIntersection = frameRect(); | |
3897 return; | |
3898 } | |
3899 ASSERT(!parent->m_needsUpdateViewportIntersection); | |
3900 | |
3901 // If our parent is hidden, then we are too. | |
3902 if (parent->m_viewportIntersection.isEmpty()) { | |
3903 m_viewportIntersection = parent->m_viewportIntersection; | |
3904 return; | |
3905 } | |
3906 | |
3907 // Transform our bounds into the root frame's content coordinate space, | |
3908 // making sure we have valid layout data in our parent document. If our | |
3909 // parent is throttled, we'll use possible stale layout information and | |
3910 // rely on the fact that another lifecycle update will be scheduled once | |
3911 // our parent becomes unthrottled. | |
3912 ASSERT(parent->lifecycle().state() >= DocumentLifecycle::LayoutClean || pare
nt->shouldThrottleRendering()); | |
3913 m_viewportIntersection = parent->contentsToRootFrame(frameRect()); | |
3914 | |
3915 // TODO(skyostil): Expand the viewport to make it less likely to see stale c
ontent while scrolling. | |
3916 IntRect viewport = parent->m_viewportIntersection; | |
3917 m_viewportIntersection.intersect(viewport); | |
3918 } | 3915 } |
3919 | 3916 |
3920 void FrameView::updateViewportIntersectionsForSubtree() | 3917 void FrameView::updateViewportIntersectionsForSubtree() |
3921 { | 3918 { |
3922 bool hadValidIntersection = m_viewportIntersectionValid; | 3919 bool hadValidIntersection = m_viewportIntersectionValid; |
3923 bool hadEmptyIntersection = m_viewportIntersection.isEmpty(); | 3920 bool hadEmptyIntersection = m_viewportIntersection.isEmpty(); |
3924 updateViewportIntersectionIfNeeded(); | 3921 updateViewportIntersectionIfNeeded(); |
| 3922 |
| 3923 // Notify javascript IntersectionObservers |
| 3924 frame().document()->intersectionObserverRegistry()->computeTrackedIntersecti
onObservations(); |
| 3925 |
| 3926 // Adjust render throttling for iframes based on visibility |
3925 bool shouldNotify = !hadValidIntersection || hadEmptyIntersection != m_viewp
ortIntersection.isEmpty(); | 3927 bool shouldNotify = !hadValidIntersection || hadEmptyIntersection != m_viewp
ortIntersection.isEmpty(); |
3926 if (shouldNotify && !m_intersectionObserverNotificationFactory->isPending()) | 3928 if (shouldNotify && !m_renderThrottlingObserverNotificationFactory->isPendin
g()) |
3927 m_frame->frameScheduler()->timerTaskRunner()->postTask(BLINK_FROM_HERE,
m_intersectionObserverNotificationFactory->cancelAndCreate()); | 3929 m_frame->frameScheduler()->timerTaskRunner()->postTask(BLINK_FROM_HERE,
m_renderThrottlingObserverNotificationFactory->cancelAndCreate()); |
3928 | 3930 |
3929 if (!m_needsUpdateViewportIntersectionInSubtree) | 3931 if (!m_needsUpdateViewportIntersectionInSubtree) |
3930 return; | 3932 return; |
3931 m_needsUpdateViewportIntersectionInSubtree = false; | 3933 m_needsUpdateViewportIntersectionInSubtree = false; |
3932 | 3934 |
3933 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree
().nextSibling()) { | 3935 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree
().nextSibling()) { |
3934 if (!child->isLocalFrame()) | 3936 if (!child->isLocalFrame()) |
3935 continue; | 3937 continue; |
3936 if (FrameView* view = toLocalFrame(child)->view()) | 3938 if (FrameView* view = toLocalFrame(child)->view()) |
3937 view->updateViewportIntersectionsForSubtree(); | 3939 view->updateViewportIntersectionsForSubtree(); |
3938 } | 3940 } |
3939 } | 3941 } |
3940 | 3942 |
3941 void FrameView::notifyIntersectionObservers() | 3943 void FrameView::notifyRenderThrottlingObservers() |
3942 { | 3944 { |
3943 TRACE_EVENT0("blink", "FrameView::notifyIntersectionObservers"); | 3945 TRACE_EVENT0("blink", "FrameView::notifyRenderThrottlingObservers"); |
3944 ASSERT(!isInPerformLayout()); | 3946 ASSERT(!isInPerformLayout()); |
3945 ASSERT(!m_frame->document()->inStyleRecalc()); | 3947 ASSERT(!m_frame->document()->inStyleRecalc()); |
3946 bool wasThrottled = canThrottleRendering(); | 3948 bool wasThrottled = canThrottleRendering(); |
3947 | 3949 |
3948 // Only offscreen frames can be throttled. | 3950 // Only offscreen frames can be throttled. |
3949 m_hiddenForThrottling = m_viewportIntersectionValid && m_viewportIntersectio
n.isEmpty(); | 3951 m_hiddenForThrottling = m_viewportIntersectionValid && m_viewportIntersectio
n.isEmpty(); |
3950 | 3952 |
3951 // We only throttle the rendering pipeline in cross-origin frames. This is | 3953 // We only throttle the rendering pipeline in cross-origin frames. This is |
3952 // to avoid a situation where an ancestor frame directly depends on the | 3954 // to avoid a situation where an ancestor frame directly depends on the |
3953 // pipeline timing of a descendant and breaks as a result of throttling. | 3955 // pipeline timing of a descendant and breaks as a result of throttling. |
(...skipping 29 matching lines...) Expand all Loading... |
3983 return m_hiddenForThrottling && m_crossOriginForThrottling; | 3985 return m_hiddenForThrottling && m_crossOriginForThrottling; |
3984 } | 3986 } |
3985 | 3987 |
3986 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const | 3988 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const |
3987 { | 3989 { |
3988 ASSERT(layoutView()); | 3990 ASSERT(layoutView()); |
3989 return *layoutView(); | 3991 return *layoutView(); |
3990 } | 3992 } |
3991 | 3993 |
3992 } // namespace blink | 3994 } // namespace blink |
OLD | NEW |