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