Index: third_party/WebKit/Source/core/frame/FrameView.h |
diff --git a/third_party/WebKit/Source/core/frame/FrameView.h b/third_party/WebKit/Source/core/frame/FrameView.h |
index ac44e9d85fa60eae8ca0b69b1dec3560e3e891eb..8b5a87be6d6434327ba9edcf794910f91095cb2f 100644 |
--- a/third_party/WebKit/Source/core/frame/FrameView.h |
+++ b/third_party/WebKit/Source/core/frame/FrameView.h |
@@ -26,6 +26,7 @@ |
#define FrameView_h |
#include "core/CoreExport.h" |
+#include "core/dom/DocumentLifecycle.h" |
#include "core/frame/FrameViewAutoSizeInfo.h" |
#include "core/frame/LayoutSubtreeRootList.h" |
#include "core/frame/RootFrameViewport.h" |
@@ -52,6 +53,7 @@ |
namespace blink { |
class AXObjectCache; |
+class CancellableTaskFactory; |
class ComputedStyle; |
class DocumentLifecycle; |
class Cursor; |
@@ -82,6 +84,7 @@ class CORE_EXPORT FrameView final : public Widget, public ScrollableArea { |
friend class PaintControllerPaintTestForSlimmingPaintV2; |
friend class Internals; |
friend class LayoutPart; // for invalidateTreeIfNeeded |
+ friend class FrameThrottlingTest; |
public: |
static PassRefPtrWillBeRawPtr<FrameView> create(LocalFrame*); |
@@ -225,16 +228,18 @@ public: |
Color documentBackgroundColor() const; |
// Run all needed lifecycle stages. After calling this method, all frames will be in the lifecycle state PaintInvalidationClean. |
+ // If lifecycle throttling is allowed, some frames may skip the lifecycle update (e.g., based on visibility) and will not end |
+ // up being PaintInvalidationClean. |
// TODO(pdr): Update callers to pass in the interest rect. |
- void updateAllLifecyclePhases(const LayoutRect* interestRect = nullptr); |
+ void updateAllLifecyclePhases(DocumentLifecycle::ThrottlingMode = DocumentLifecycle::ThrottlingMode::Disallow, const LayoutRect* interestRect = nullptr); |
esprehn
2015/10/14 22:09:46
We shouldn't need to pass this as an argument, jus
Sami
2015/10/16 16:48:08
Yeah, that's much cleaner. Thanks for the idea.
|
// Computes the style, layout and compositing lifecycle stages if needed. After calling this method, all frames wil lbe in a lifecycle |
// state >= CompositingClean, and scrolling has been updated. |
- void updateLifecycleToCompositingCleanPlusScrolling(); |
+ void updateLifecycleToCompositingCleanPlusScrolling(DocumentLifecycle::ThrottlingMode = DocumentLifecycle::ThrottlingMode::Disallow); |
// Computes only the style and layout lifecycle stages. |
// After calling this method, all frames will be in a lifecycle state >= LayoutClean. |
- void updateLifecycleToLayoutClean(); |
+ void updateLifecycleToLayoutClean(DocumentLifecycle::ThrottlingMode = DocumentLifecycle::ThrottlingMode::Disallow); |
bool invalidateViewportConstrainedObjects(); |
@@ -556,6 +561,14 @@ public: |
void setFrameTimingRequestsDirty(bool isDirty) { m_frameTimingRequestsDirty = isDirty; } |
bool frameTimingRequestsDirty() { return m_frameTimingRequestsDirty; } |
+ // Returns true if this frame should skip rendering and avoid scheduling |
+ // new visual updates. |
+ bool shouldThrottleRendering() const; |
+ |
+ // Returns true if this frame should skip rendering and this has not been |
+ // disallowed, e.g., because of a synchronous layout. |
+ bool shouldThrottleRenderingIfAllowed() const; |
+ |
protected: |
// Scroll the content via the compositor. |
bool scrollContentsFastPath(const IntSize& scrollDelta); |
@@ -610,7 +623,7 @@ private: |
AllPhases, |
}; |
- void updateLifecyclePhasesInternal(LifeCycleUpdateOption, const LayoutRect* interestRect); |
+ void updateLifecyclePhasesInternal(LifeCycleUpdateOption, DocumentLifecycle::ThrottlingMode, const LayoutRect* interestRect); |
void invalidateTreeIfNeededRecursive(); |
void scrollContentsIfNeededRecursive(); |
void updateStyleAndLayoutIfNeededRecursive(); |
@@ -716,6 +729,12 @@ private: |
void collectFrameTimingRequests(GraphicsLayerFrameTimingRequests&); |
void collectFrameTimingRequestsRecursive(GraphicsLayerFrameTimingRequests&); |
+ void setLifecycleThrottlingMode(DocumentLifecycle::ThrottlingMode); |
+ void setNeedsUpdateViewportIntersection(); |
+ void updateViewportIntersectionsForSubtree(); |
+ void updateViewportIntersectionIfNeeded(); |
+ void notifyIntersectionObservers(); |
+ |
LayoutSize m_size; |
typedef HashSet<RefPtr<LayoutEmbeddedObject>> EmbeddedObjectSet; |
@@ -750,6 +769,7 @@ private: |
unsigned m_nestedLayoutCount; |
Timer<FrameView> m_postLayoutTasksTimer; |
Timer<FrameView> m_updateWidgetsTimer; |
+ OwnPtr<CancellableTaskFactory> m_intersectionObserverNotificationFactory; |
bool m_firstLayout; |
bool m_isTransparent; |
@@ -797,6 +817,8 @@ private: |
float m_topControlsViewportAdjustment; |
bool m_needsUpdateWidgetPositions; |
+ bool m_needsUpdateViewportIntersection; |
+ bool m_needsUpdateViewportIntersectionInSubtree; |
#if ENABLE(ASSERT) |
// Verified when finalizing. |
@@ -832,6 +854,21 @@ private: |
// TODO(bokan): crbug.com/484188. We should specialize FrameView for the |
// main frame. |
OwnPtrWillBeMember<ScrollableArea> m_viewportScrollableArea; |
+ |
+ // This frame's bounds in the root frame's content coordinates, clipped |
+ // recursively through every ancestor view. |
+ IntRect m_viewportIntersection; |
+ bool m_viewportIntersectionValid; |
+ |
+ enum class ViewportVisibility { Hidden, Visible }; |
+ enum class SecurityOriginStatus { IsSameOrigin, IsCrossOrigin }; |
esprehn
2015/10/14 22:09:46
ditto, this can just be a boolean
Sami
2015/10/16 16:48:08
Done.
|
+ |
+ // The following members control rendering pipeline throttling for this |
+ // frame. They are only updated at the end of the pipeline (after painting) |
+ // to avoid running further pipeline stages for a frame without having gone |
+ // through the previous ones. |
+ ViewportVisibility m_viewportVisibilityForThrottling; |
esprehn
2015/10/14 22:09:46
this should just be a boolean
Sami
2015/10/16 16:48:08
Done.
|
+ SecurityOriginStatus m_securityOriginStatusForThrottling; |
}; |
inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) |