Chromium Code Reviews| 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(); | |
|
ojan
2015/12/12 01:06:29
I think removing this is the right change, but sho
szager1
2015/12/16 19:15:37
Done.
| |
| 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 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3904 | 3903 |
| 3905 void FrameView::setNeedsUpdateViewportIntersection() | 3904 void FrameView::setNeedsUpdateViewportIntersection() |
| 3906 { | 3905 { |
| 3907 m_needsUpdateViewportIntersection = true; | 3906 m_needsUpdateViewportIntersection = true; |
| 3908 for (FrameView* parent = parentFrameView(); parent; parent = parent->parentF rameView()) | 3907 for (FrameView* parent = parentFrameView(); parent; parent = parent->parentF rameView()) |
| 3909 parent->m_needsUpdateViewportIntersectionInSubtree = true; | 3908 parent->m_needsUpdateViewportIntersectionInSubtree = true; |
| 3910 } | 3909 } |
| 3911 | 3910 |
| 3912 void FrameView::updateViewportIntersectionIfNeeded() | 3911 void FrameView::updateViewportIntersectionIfNeeded() |
| 3913 { | 3912 { |
| 3914 // TODO(skyostil): Replace this with a real intersection observer. | 3913 if (m_needsUpdateViewportIntersection) { |
|
ojan
2015/12/12 01:06:29
Why did you get rid of the early return?
szager1
2015/12/16 19:15:37
I can't remember why I did that, but it's not need
| |
| 3915 if (!m_needsUpdateViewportIntersection) | 3914 FrameView* parent = parentFrameView(); |
| 3916 return; | 3915 if (parent) { |
|
esprehn
2015/12/12 00:14:16
if (FrameView* parent = ...) {
szager1
2015/12/16 19:15:37
Since I reverted to the old code, the parent varia
| |
| 3916 ASSERT(!parent->m_needsUpdateViewportIntersection); | |
| 3917 | |
| 3918 // If our parent is hidden, then we are too. | |
| 3919 if (parent->m_viewportIntersection.isEmpty()) { | |
| 3920 m_viewportIntersection = parent->m_viewportIntersection; | |
| 3921 } else { | |
| 3922 // Transform our bounds into the root frame's content coordinate space, | |
| 3923 // making sure we have valid layout data in our parent document. If our | |
| 3924 // parent is throttled, we'll use possible stale layout informat ion and | |
| 3925 // rely on the fact that another lifecycle update will be schedu led once | |
| 3926 // our parent becomes unthrottled. | |
| 3927 ASSERT(parent->lifecycle().state() >= DocumentLifecycle::LayoutC lean || parent->shouldThrottleRendering()); | |
| 3928 m_viewportIntersection = parent->contentsToRootFrame(frameRect() ); | |
| 3929 | |
| 3930 // TODO(skyostil): Expand the viewport to make it less likely to see stale content while scrolling. | |
| 3931 IntRect viewport = parent->m_viewportIntersection; | |
| 3932 m_viewportIntersection.intersect(viewport); | |
| 3933 } | |
| 3934 } else { | |
| 3935 m_viewportIntersection = frameRect(); | |
| 3936 } | |
| 3937 } | |
| 3938 | |
| 3917 m_needsUpdateViewportIntersection = false; | 3939 m_needsUpdateViewportIntersection = false; |
| 3918 m_viewportIntersectionValid = true; | 3940 m_viewportIntersectionValid = true; |
| 3919 | |
| 3920 FrameView* parent = parentFrameView(); | |
| 3921 if (!parent) { | |
| 3922 m_viewportIntersection = frameRect(); | |
| 3923 return; | |
| 3924 } | |
| 3925 ASSERT(!parent->m_needsUpdateViewportIntersection); | |
| 3926 | |
| 3927 // If our parent is hidden, then we are too. | |
| 3928 if (parent->m_viewportIntersection.isEmpty()) { | |
| 3929 m_viewportIntersection = parent->m_viewportIntersection; | |
| 3930 return; | |
| 3931 } | |
| 3932 | |
| 3933 // 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 | |
| 3935 // parent is throttled, we'll use possible stale layout information and | |
| 3936 // rely on the fact that another lifecycle update will be scheduled once | |
| 3937 // our parent becomes unthrottled. | |
| 3938 ASSERT(parent->lifecycle().state() >= DocumentLifecycle::LayoutClean || pare nt->shouldThrottleRendering()); | |
| 3939 m_viewportIntersection = parent->contentsToRootFrame(frameRect()); | |
| 3940 | |
| 3941 // TODO(skyostil): Expand the viewport to make it less likely to see stale c ontent while scrolling. | |
| 3942 IntRect viewport = parent->m_viewportIntersection; | |
| 3943 m_viewportIntersection.intersect(viewport); | |
| 3944 } | 3941 } |
| 3945 | 3942 |
| 3946 void FrameView::updateViewportIntersectionsForSubtree() | 3943 void FrameView::updateViewportIntersectionsForSubtree() |
| 3947 { | 3944 { |
| 3948 bool hadValidIntersection = m_viewportIntersectionValid; | 3945 bool hadValidIntersection = m_viewportIntersectionValid; |
| 3949 bool hadEmptyIntersection = m_viewportIntersection.isEmpty(); | 3946 bool hadEmptyIntersection = m_viewportIntersection.isEmpty(); |
| 3950 updateViewportIntersectionIfNeeded(); | 3947 updateViewportIntersectionIfNeeded(); |
| 3948 | |
| 3949 // Notify javascript IntersectionObservers | |
| 3950 frame().document()->intersectionObserverRegistry()->computeTrackedIntersecti onObservations(); | |
| 3951 | |
| 3952 // Adjust render throttling for iframes based on visibility | |
| 3951 bool shouldNotify = !hadValidIntersection || hadEmptyIntersection != m_viewp ortIntersection.isEmpty(); | 3953 bool shouldNotify = !hadValidIntersection || hadEmptyIntersection != m_viewp ortIntersection.isEmpty(); |
| 3952 if (shouldNotify && !m_intersectionObserverNotificationFactory->isPending()) | 3954 if (shouldNotify && !m_renderThrottlingObserverNotificationFactory->isPendin g()) |
| 3953 m_frame->frameScheduler()->timerTaskRunner()->postTask(BLINK_FROM_HERE, m_intersectionObserverNotificationFactory->cancelAndCreate()); | 3955 m_frame->frameScheduler()->timerTaskRunner()->postTask(BLINK_FROM_HERE, m_renderThrottlingObserverNotificationFactory->cancelAndCreate()); |
| 3954 | 3956 |
| 3955 if (!m_needsUpdateViewportIntersectionInSubtree) | 3957 if (!m_needsUpdateViewportIntersectionInSubtree) |
| 3956 return; | 3958 return; |
| 3957 m_needsUpdateViewportIntersectionInSubtree = false; | 3959 m_needsUpdateViewportIntersectionInSubtree = false; |
| 3958 | 3960 |
| 3959 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { | 3961 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { |
| 3960 if (!child->isLocalFrame()) | 3962 if (!child->isLocalFrame()) |
| 3961 continue; | 3963 continue; |
| 3962 if (FrameView* view = toLocalFrame(child)->view()) | 3964 if (FrameView* view = toLocalFrame(child)->view()) |
| 3963 view->updateViewportIntersectionsForSubtree(); | 3965 view->updateViewportIntersectionsForSubtree(); |
| 3964 } | 3966 } |
| 3965 } | 3967 } |
| 3966 | 3968 |
| 3967 void FrameView::notifyIntersectionObservers() | 3969 void FrameView::notifyRenderThrottlingObservers() |
| 3968 { | 3970 { |
| 3969 TRACE_EVENT0("blink", "FrameView::notifyIntersectionObservers"); | 3971 TRACE_EVENT0("blink", "FrameView::notifyRenderThrottlingObservers"); |
| 3970 ASSERT(!isInPerformLayout()); | 3972 ASSERT(!isInPerformLayout()); |
| 3971 ASSERT(!m_frame->document()->inStyleRecalc()); | 3973 ASSERT(!m_frame->document()->inStyleRecalc()); |
| 3972 bool wasThrottled = canThrottleRendering(); | 3974 bool wasThrottled = canThrottleRendering(); |
| 3973 | 3975 |
| 3974 // Only offscreen frames can be throttled. | 3976 // Only offscreen frames can be throttled. |
| 3975 m_hiddenForThrottling = m_viewportIntersectionValid && m_viewportIntersectio n.isEmpty(); | 3977 m_hiddenForThrottling = m_viewportIntersectionValid && m_viewportIntersectio n.isEmpty(); |
| 3976 | 3978 |
| 3977 // We only throttle the rendering pipeline in cross-origin frames. This is | 3979 // 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 | 3980 // 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. | 3981 // 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; | 4011 return m_hiddenForThrottling && m_crossOriginForThrottling; |
| 4010 } | 4012 } |
| 4011 | 4013 |
| 4012 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const | 4014 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const |
| 4013 { | 4015 { |
| 4014 ASSERT(layoutView()); | 4016 ASSERT(layoutView()); |
| 4015 return *layoutView(); | 4017 return *layoutView(); |
| 4016 } | 4018 } |
| 4017 | 4019 |
| 4018 } // namespace blink | 4020 } // namespace blink |
| OLD | NEW |