| Index: third_party/WebKit/Source/core/frame/FrameView.cpp
|
| diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp
|
| index 29096603d9b63a9755fa09492108724c80373533..6cb14a4180770bb1d114beabd115b2d566d876b5 100644
|
| --- a/third_party/WebKit/Source/core/frame/FrameView.cpp
|
| +++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
|
| @@ -33,6 +33,7 @@
|
| #include "core/css/resolver/StyleResolver.h"
|
| #include "core/dom/AXObjectCache.h"
|
| #include "core/dom/Fullscreen.h"
|
| +#include "core/dom/IntersectionObservationRegistry.h"
|
| #include "core/editing/EditingUtilities.h"
|
| #include "core/editing/FrameSelection.h"
|
| #include "core/editing/RenderedPosition.h"
|
| @@ -121,7 +122,7 @@ FrameView::FrameView(LocalFrame* frame)
|
| , m_inSynchronousPostLayout(false)
|
| , m_postLayoutTasksTimer(this, &FrameView::postLayoutTimerFired)
|
| , m_updateWidgetsTimer(this, &FrameView::updateWidgetsTimerFired)
|
| - , m_intersectionObserverNotificationFactory(CancellableTaskFactory::create(this, &FrameView::notifyIntersectionObservers))
|
| + , m_renderThrottlingObserverNotificationFactory(CancellableTaskFactory::create(this, &FrameView::notifyRenderThrottlingObservers))
|
| , m_isTransparent(false)
|
| , m_baseBackgroundColor(Color::white)
|
| , m_mediaType(MediaTypeNames::screen)
|
| @@ -285,7 +286,7 @@ void FrameView::dispose()
|
|
|
| if (m_didScrollTimer.isActive())
|
| m_didScrollTimer.stop();
|
| - m_intersectionObserverNotificationFactory->cancel();
|
| + m_renderThrottlingObserverNotificationFactory->cancel();
|
|
|
| // FIXME: Do we need to do something here for OOPI?
|
| HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner();
|
| @@ -2395,10 +2396,8 @@ void FrameView::updateLifecyclePhasesInternal(LifeCycleUpdateOption phases)
|
| updateStyleAndLayoutIfNeededRecursive();
|
| ASSERT(lifecycle().state() >= DocumentLifecycle::LayoutClean);
|
|
|
| - if (phases == OnlyUpToLayoutClean) {
|
| - updateViewportIntersectionsForSubtree();
|
| + if (phases == OnlyUpToLayoutClean)
|
| return;
|
| - }
|
|
|
| if (LayoutView* view = layoutView()) {
|
| TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", InspectorUpdateLayerTreeEvent::data(m_frame.get()));
|
| @@ -3949,36 +3948,34 @@ void FrameView::setNeedsUpdateViewportIntersection()
|
|
|
| void FrameView::updateViewportIntersectionIfNeeded()
|
| {
|
| - // TODO(skyostil): Replace this with a real intersection observer.
|
| - if (!m_needsUpdateViewportIntersection)
|
| - return;
|
| - m_needsUpdateViewportIntersection = false;
|
| - m_viewportIntersectionValid = true;
|
| + if (m_needsUpdateViewportIntersection) {
|
| + FrameView* parent = parentFrameView();
|
| + if (parent) {
|
| + ASSERT(!parent->m_needsUpdateViewportIntersection);
|
|
|
| - FrameView* parent = parentFrameView();
|
| - if (!parent) {
|
| - m_viewportIntersection = frameRect();
|
| - return;
|
| - }
|
| - ASSERT(!parent->m_needsUpdateViewportIntersection);
|
| -
|
| - // If our parent is hidden, then we are too.
|
| - if (parent->m_viewportIntersection.isEmpty()) {
|
| - m_viewportIntersection = parent->m_viewportIntersection;
|
| - return;
|
| + // If our parent is hidden, then we are too.
|
| + if (parent->m_viewportIntersection.isEmpty()) {
|
| + m_viewportIntersection = parent->m_viewportIntersection;
|
| + } else {
|
| + // Transform our bounds into the root frame's content coordinate space,
|
| + // making sure we have valid layout data in our parent document. If our
|
| + // parent is throttled, we'll use possible stale layout information and
|
| + // rely on the fact that another lifecycle update will be scheduled once
|
| + // our parent becomes unthrottled.
|
| + ASSERT(parent->lifecycle().state() >= DocumentLifecycle::LayoutClean || parent->shouldThrottleRendering());
|
| + m_viewportIntersection = parent->contentsToRootFrame(frameRect());
|
| +
|
| + // TODO(skyostil): Expand the viewport to make it less likely to see stale content while scrolling.
|
| + IntRect viewport = parent->m_viewportIntersection;
|
| + m_viewportIntersection.intersect(viewport);
|
| + }
|
| + } else {
|
| + m_viewportIntersection = frameRect();
|
| + }
|
| }
|
|
|
| - // Transform our bounds into the root frame's content coordinate space,
|
| - // making sure we have valid layout data in our parent document. If our
|
| - // parent is throttled, we'll use possible stale layout information and
|
| - // rely on the fact that another lifecycle update will be scheduled once
|
| - // our parent becomes unthrottled.
|
| - ASSERT(parent->lifecycle().state() >= DocumentLifecycle::LayoutClean || parent->shouldThrottleRendering());
|
| - m_viewportIntersection = parent->contentsToRootFrame(frameRect());
|
| -
|
| - // TODO(skyostil): Expand the viewport to make it less likely to see stale content while scrolling.
|
| - IntRect viewport = parent->m_viewportIntersection;
|
| - m_viewportIntersection.intersect(viewport);
|
| + m_needsUpdateViewportIntersection = false;
|
| + m_viewportIntersectionValid = true;
|
| }
|
|
|
| void FrameView::updateViewportIntersectionsForSubtree()
|
| @@ -3986,9 +3983,14 @@ void FrameView::updateViewportIntersectionsForSubtree()
|
| bool hadValidIntersection = m_viewportIntersectionValid;
|
| bool hadEmptyIntersection = m_viewportIntersection.isEmpty();
|
| updateViewportIntersectionIfNeeded();
|
| +
|
| + // Notify javascript IntersectionObservers
|
| + frame().document()->intersectionObservationRegistry()->computeIntersectionObservations();
|
| +
|
| + // Adjust render throttling for iframes based on visibility
|
| bool shouldNotify = !hadValidIntersection || hadEmptyIntersection != m_viewportIntersection.isEmpty();
|
| - if (shouldNotify && !m_intersectionObserverNotificationFactory->isPending())
|
| - m_frame->frameScheduler()->timerTaskRunner()->postTask(BLINK_FROM_HERE, m_intersectionObserverNotificationFactory->cancelAndCreate());
|
| + if (shouldNotify && !m_renderThrottlingObserverNotificationFactory->isPending())
|
| + m_frame->frameScheduler()->timerTaskRunner()->postTask(BLINK_FROM_HERE, m_renderThrottlingObserverNotificationFactory->cancelAndCreate());
|
|
|
| if (!m_needsUpdateViewportIntersectionInSubtree)
|
| return;
|
| @@ -4002,9 +4004,9 @@ void FrameView::updateViewportIntersectionsForSubtree()
|
| }
|
| }
|
|
|
| -void FrameView::notifyIntersectionObservers()
|
| +void FrameView::notifyRenderThrottlingObservers()
|
| {
|
| - TRACE_EVENT0("blink", "FrameView::notifyIntersectionObservers");
|
| + TRACE_EVENT0("blink", "FrameView::notifyRenderThrottlingObservers");
|
| ASSERT(!isInPerformLayout());
|
| ASSERT(!m_frame->document()->inStyleRecalc());
|
| bool wasThrottled = canThrottleRendering();
|
|
|