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 62792a190a8244ae33808c6e0af7a90aee1459b5..452e66473f00e343e59cb25d6abb96da121b399e 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/IntersectionObserverRegistry.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(); |
@@ -2375,10 +2376,8 @@ void FrameView::updateLifecyclePhasesInternal(LifeCycleUpdateOption phases) |
updateStyleAndLayoutIfNeededRecursive(); |
ASSERT(lifecycle().state() >= DocumentLifecycle::LayoutClean); |
- if (phases == OnlyUpToLayoutClean) { |
- 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.
|
+ if (phases == OnlyUpToLayoutClean) |
return; |
- } |
if (LayoutView* view = layoutView()) { |
{ |
@@ -3911,36 +3910,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) { |
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
|
+ FrameView* parent = parentFrameView(); |
+ 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
|
+ 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() |
@@ -3948,9 +3945,14 @@ void FrameView::updateViewportIntersectionsForSubtree() |
bool hadValidIntersection = m_viewportIntersectionValid; |
bool hadEmptyIntersection = m_viewportIntersection.isEmpty(); |
updateViewportIntersectionIfNeeded(); |
+ |
+ // Notify javascript IntersectionObservers |
+ frame().document()->intersectionObserverRegistry()->computeTrackedIntersectionObservations(); |
+ |
+ // 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; |
@@ -3964,9 +3966,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(); |