Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(917)

Unified Diff: third_party/WebKit/Source/core/frame/FrameView.h

Issue 2272773002: Use intersection observer to control frame throttling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix rebase typo Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 d8f183533b304cbc72c827789d3e7ae11255013c..0c8655aec0ed8c874c07a03dd98096892d075d74 100644
--- a/third_party/WebKit/Source/core/frame/FrameView.h
+++ b/third_party/WebKit/Source/core/frame/FrameView.h
@@ -28,6 +28,7 @@
#include "core/CoreExport.h"
#include "core/dom/DocumentLifecycle.h"
+#include "core/dom/IntersectionObserverCallback.h"
#include "core/frame/FrameViewAutoSizeInfo.h"
#include "core/frame/LayoutSubtreeRootList.h"
#include "core/frame/RootFrameViewport.h"
@@ -670,10 +671,11 @@ class CORE_EXPORT FrameView final
// scheduling visual updates.
bool canThrottleRendering() const;
bool isHiddenForThrottling() const { return m_hiddenForThrottling; }
+ void setupRenderThrottling();
// For testing, run pending intersection observer notifications for this
// frame.
- void notifyRenderThrottlingObserversForTesting();
+ void updateRenderThrottlingStatusForTesting();
// Paint properties for SPv2 Only.
void setPreTranslation(
@@ -773,6 +775,23 @@ class CORE_EXPORT FrameView final
void invalidateTreeIfNeeded(const PaintInvalidationState&);
private:
+ class IntersectionObserverCallback
+ : public blink::IntersectionObserverCallback {
+ public:
+ IntersectionObserverCallback(FrameView*, ExecutionContext*);
+
+ // IntersectionObserverCallback implementation:
+ void handleEvent(const HeapVector<Member<IntersectionObserverEntry>>&,
+ IntersectionObserver&) override;
+ ExecutionContext* getExecutionContext() const override;
+
+ DECLARE_TRACE();
+
+ private:
+ WeakMember<FrameView> m_frameView;
+ WeakMember<ExecutionContext> m_context;
+ };
+
explicit FrameView(LocalFrame*);
void updateScrollOffset(const ScrollOffset&, ScrollType) override;
@@ -897,9 +916,7 @@ class CORE_EXPORT FrameView final
void setNeedsUpdateViewportIntersection();
void updateViewportIntersectionsForSubtree(
DocumentLifecycle::LifecycleState targetState);
- void updateViewportIntersectionIfNeeded();
- void notifyRenderThrottlingObservers();
- void updateThrottlingStatus();
+ void updateRenderThrottlingStatus(bool hidden, bool subtreeThrottled);
void notifyResizeObservers();
// PaintInvalidationCapableScrollableArea
@@ -941,8 +958,6 @@ class CORE_EXPORT FrameView final
unsigned m_nestedLayoutCount;
Timer<FrameView> m_postLayoutTasksTimer;
Timer<FrameView> m_updateWidgetsTimer;
- std::unique_ptr<CancellableTaskFactory>
- m_renderThrottlingObserverNotificationFactory;
bool m_firstLayout;
bool m_isTransparent;
@@ -1023,16 +1038,10 @@ class CORE_EXPORT FrameView final
// main frame.
Member<RootFrameViewport> 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;
-
// The following members control rendering pipeline throttling for this
// frame. They are only updated in response to intersection observer
// notifications, i.e., not in the middle of the lifecycle.
bool m_hiddenForThrottling;
- bool m_crossOriginForThrottling;
bool m_subtreeThrottled;
// Paint properties for SPv2 Only.
@@ -1063,6 +1072,8 @@ class CORE_EXPORT FrameView final
bool m_suppressAdjustViewSize;
bool m_allowsLayoutInvalidationAfterLayoutClean;
+ Member<IntersectionObserver> m_intersectionObserver;
+
// For testing.
struct ObjectPaintInvalidation {
String name;

Powered by Google App Engine
This is Rietveld 408576698