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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 Copyright (C) 1997 Martin Jones (mjones@kde.org) 2 Copyright (C) 1997 Martin Jones (mjones@kde.org)
3 (C) 1998 Waldo Bastian (bastian@kde.org) 3 (C) 1998 Waldo Bastian (bastian@kde.org)
4 (C) 1998, 1999 Torben Weis (weis@kde.org) 4 (C) 1998, 1999 Torben Weis (weis@kde.org)
5 (C) 1999 Lars Knoll (knoll@kde.org) 5 (C) 1999 Lars Knoll (knoll@kde.org)
6 (C) 1999 Antti Koivisto (koivisto@kde.org) 6 (C) 1999 Antti Koivisto (koivisto@kde.org)
7 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights 7 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
8 reserved. 8 reserved.
9 9
10 This library is free software; you can redistribute it and/or 10 This library is free software; you can redistribute it and/or
(...skipping 10 matching lines...) Expand all
21 along with this library; see the file COPYING.LIB. If not, write to 21 along with this library; see the file COPYING.LIB. If not, write to
22 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 22 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 Boston, MA 02110-1301, USA. 23 Boston, MA 02110-1301, USA.
24 */ 24 */
25 25
26 #ifndef FrameView_h 26 #ifndef FrameView_h
27 #define FrameView_h 27 #define FrameView_h
28 28
29 #include "core/CoreExport.h" 29 #include "core/CoreExport.h"
30 #include "core/dom/DocumentLifecycle.h" 30 #include "core/dom/DocumentLifecycle.h"
31 #include "core/dom/IntersectionObserverCallback.h"
31 #include "core/frame/FrameViewAutoSizeInfo.h" 32 #include "core/frame/FrameViewAutoSizeInfo.h"
32 #include "core/frame/LayoutSubtreeRootList.h" 33 #include "core/frame/LayoutSubtreeRootList.h"
33 #include "core/frame/RootFrameViewport.h" 34 #include "core/frame/RootFrameViewport.h"
34 #include "core/layout/ScrollAnchor.h" 35 #include "core/layout/ScrollAnchor.h"
35 #include "core/paint/FirstMeaningfulPaintDetector.h" 36 #include "core/paint/FirstMeaningfulPaintDetector.h"
36 #include "core/paint/ObjectPaintProperties.h" 37 #include "core/paint/ObjectPaintProperties.h"
37 #include "core/paint/PaintInvalidationCapableScrollableArea.h" 38 #include "core/paint/PaintInvalidationCapableScrollableArea.h"
38 #include "core/paint/PaintPhase.h" 39 #include "core/paint/PaintPhase.h"
39 #include "platform/RuntimeEnabledFeatures.h" 40 #include "platform/RuntimeEnabledFeatures.h"
40 #include "platform/Widget.h" 41 #include "platform/Widget.h"
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 664
664 LayoutAnalyzer* layoutAnalyzer() { return m_analyzer.get(); } 665 LayoutAnalyzer* layoutAnalyzer() { return m_analyzer.get(); }
665 666
666 // Returns true if this frame should not render or schedule visual updates. 667 // Returns true if this frame should not render or schedule visual updates.
667 bool shouldThrottleRendering() const; 668 bool shouldThrottleRendering() const;
668 669
669 // Returns true if this frame could potentially skip rendering and avoid 670 // Returns true if this frame could potentially skip rendering and avoid
670 // scheduling visual updates. 671 // scheduling visual updates.
671 bool canThrottleRendering() const; 672 bool canThrottleRendering() const;
672 bool isHiddenForThrottling() const { return m_hiddenForThrottling; } 673 bool isHiddenForThrottling() const { return m_hiddenForThrottling; }
674 void setupRenderThrottling();
673 675
674 // For testing, run pending intersection observer notifications for this 676 // For testing, run pending intersection observer notifications for this
675 // frame. 677 // frame.
676 void notifyRenderThrottlingObserversForTesting(); 678 void updateRenderThrottlingStatusForTesting();
677 679
678 // Paint properties for SPv2 Only. 680 // Paint properties for SPv2 Only.
679 void setPreTranslation( 681 void setPreTranslation(
680 PassRefPtr<TransformPaintPropertyNode> preTranslation) { 682 PassRefPtr<TransformPaintPropertyNode> preTranslation) {
681 m_preTranslation = preTranslation; 683 m_preTranslation = preTranslation;
682 } 684 }
683 TransformPaintPropertyNode* preTranslation() const { 685 TransformPaintPropertyNode* preTranslation() const {
684 return m_preTranslation.get(); 686 return m_preTranslation.get();
685 } 687 }
686 688
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 : m_scope(&view->m_inUpdateScrollbars, true) {} 768 : m_scope(&view->m_inUpdateScrollbars, true) {}
767 769
768 private: 770 private:
769 AutoReset<bool> m_scope; 771 AutoReset<bool> m_scope;
770 }; 772 };
771 773
772 // Only for LayoutPart to traverse into sub frames during paint invalidation. 774 // Only for LayoutPart to traverse into sub frames during paint invalidation.
773 void invalidateTreeIfNeeded(const PaintInvalidationState&); 775 void invalidateTreeIfNeeded(const PaintInvalidationState&);
774 776
775 private: 777 private:
778 class IntersectionObserverCallback
779 : public blink::IntersectionObserverCallback {
780 public:
781 IntersectionObserverCallback(FrameView*, ExecutionContext*);
782
783 // IntersectionObserverCallback implementation:
784 void handleEvent(const HeapVector<Member<IntersectionObserverEntry>>&,
785 IntersectionObserver&) override;
786 ExecutionContext* getExecutionContext() const override;
787
788 DECLARE_TRACE();
789
790 private:
791 WeakMember<FrameView> m_frameView;
792 WeakMember<ExecutionContext> m_context;
793 };
794
776 explicit FrameView(LocalFrame*); 795 explicit FrameView(LocalFrame*);
777 796
778 void updateScrollOffset(const ScrollOffset&, ScrollType) override; 797 void updateScrollOffset(const ScrollOffset&, ScrollType) override;
779 798
780 void updateLifecyclePhasesInternal( 799 void updateLifecyclePhasesInternal(
781 DocumentLifecycle::LifecycleState targetState); 800 DocumentLifecycle::LifecycleState targetState);
782 801
783 void invalidateTreeIfNeededRecursive(); 802 void invalidateTreeIfNeededRecursive();
784 void scrollContentsIfNeededRecursive(); 803 void scrollContentsIfNeededRecursive();
785 void updateStyleAndLayoutIfNeededRecursive(); 804 void updateStyleAndLayoutIfNeededRecursive();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 909
891 void collectAnnotatedRegions(LayoutObject&, 910 void collectAnnotatedRegions(LayoutObject&,
892 Vector<AnnotatedRegionValue>&) const; 911 Vector<AnnotatedRegionValue>&) const;
893 912
894 template <typename Function> 913 template <typename Function>
895 void forAllNonThrottledFrameViews(const Function&); 914 void forAllNonThrottledFrameViews(const Function&);
896 915
897 void setNeedsUpdateViewportIntersection(); 916 void setNeedsUpdateViewportIntersection();
898 void updateViewportIntersectionsForSubtree( 917 void updateViewportIntersectionsForSubtree(
899 DocumentLifecycle::LifecycleState targetState); 918 DocumentLifecycle::LifecycleState targetState);
900 void updateViewportIntersectionIfNeeded(); 919 void updateRenderThrottlingStatus(bool hidden, bool subtreeThrottled);
901 void notifyRenderThrottlingObservers();
902 void updateThrottlingStatus();
903 void notifyResizeObservers(); 920 void notifyResizeObservers();
904 921
905 // PaintInvalidationCapableScrollableArea 922 // PaintInvalidationCapableScrollableArea
906 LayoutScrollbarPart* resizer() const override { return nullptr; } 923 LayoutScrollbarPart* resizer() const override { return nullptr; }
907 924
908 bool checkLayoutInvalidationIsAllowed() const; 925 bool checkLayoutInvalidationIsAllowed() const;
909 926
910 PaintController* paintController() { return m_paintController.get(); } 927 PaintController* paintController() { return m_paintController.get(); }
911 928
912 LayoutSize m_size; 929 LayoutSize m_size;
(...skipping 21 matching lines...) Expand all
934 bool m_hasPendingLayout; 951 bool m_hasPendingLayout;
935 LayoutSubtreeRootList m_layoutSubtreeRootList; 952 LayoutSubtreeRootList m_layoutSubtreeRootList;
936 DepthOrderedLayoutObjectList m_orthogonalWritingModeRootList; 953 DepthOrderedLayoutObjectList m_orthogonalWritingModeRootList;
937 954
938 bool m_layoutSchedulingEnabled; 955 bool m_layoutSchedulingEnabled;
939 bool m_inSynchronousPostLayout; 956 bool m_inSynchronousPostLayout;
940 int m_layoutCount; 957 int m_layoutCount;
941 unsigned m_nestedLayoutCount; 958 unsigned m_nestedLayoutCount;
942 Timer<FrameView> m_postLayoutTasksTimer; 959 Timer<FrameView> m_postLayoutTasksTimer;
943 Timer<FrameView> m_updateWidgetsTimer; 960 Timer<FrameView> m_updateWidgetsTimer;
944 std::unique_ptr<CancellableTaskFactory>
945 m_renderThrottlingObserverNotificationFactory;
946 961
947 bool m_firstLayout; 962 bool m_firstLayout;
948 bool m_isTransparent; 963 bool m_isTransparent;
949 Color m_baseBackgroundColor; 964 Color m_baseBackgroundColor;
950 IntSize m_lastViewportSize; 965 IntSize m_lastViewportSize;
951 float m_lastZoomFactor; 966 float m_lastZoomFactor;
952 967
953 AtomicString m_mediaType; 968 AtomicString m_mediaType;
954 AtomicString m_mediaTypeWhenNotPrinting; 969 AtomicString m_mediaTypeWhenNotPrinting;
955 970
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 1031
1017 // Mark if something has changed in the mapping from Frame to GraphicsLayer 1032 // Mark if something has changed in the mapping from Frame to GraphicsLayer
1018 // and the Frame Timing regions should be recalculated. 1033 // and the Frame Timing regions should be recalculated.
1019 bool m_frameTimingRequestsDirty; 1034 bool m_frameTimingRequestsDirty;
1020 1035
1021 // Exists only on root frame. 1036 // Exists only on root frame.
1022 // TODO(bokan): crbug.com/484188. We should specialize FrameView for the 1037 // TODO(bokan): crbug.com/484188. We should specialize FrameView for the
1023 // main frame. 1038 // main frame.
1024 Member<RootFrameViewport> m_viewportScrollableArea; 1039 Member<RootFrameViewport> m_viewportScrollableArea;
1025 1040
1026 // This frame's bounds in the root frame's content coordinates, clipped
1027 // recursively through every ancestor view.
1028 IntRect m_viewportIntersection;
1029 bool m_viewportIntersectionValid;
1030
1031 // The following members control rendering pipeline throttling for this 1041 // The following members control rendering pipeline throttling for this
1032 // frame. They are only updated in response to intersection observer 1042 // frame. They are only updated in response to intersection observer
1033 // notifications, i.e., not in the middle of the lifecycle. 1043 // notifications, i.e., not in the middle of the lifecycle.
1034 bool m_hiddenForThrottling; 1044 bool m_hiddenForThrottling;
1035 bool m_crossOriginForThrottling;
1036 bool m_subtreeThrottled; 1045 bool m_subtreeThrottled;
1037 1046
1038 // Paint properties for SPv2 Only. 1047 // Paint properties for SPv2 Only.
1039 // The hierarchy of transform subtree created by a FrameView. 1048 // The hierarchy of transform subtree created by a FrameView.
1040 // [ preTranslation ] The offset from Widget::frameRect. 1049 // [ preTranslation ] The offset from Widget::frameRect.
1041 // | Establishes viewport. 1050 // | Establishes viewport.
1042 // +---[ scrollTranslation ] Frame scrolling. 1051 // +---[ scrollTranslation ] Frame scrolling.
1043 // TODO(trchen): These will not be needed once settings->rootLayerScrolls() is 1052 // TODO(trchen): These will not be needed once settings->rootLayerScrolls() is
1044 // enabled. 1053 // enabled.
1045 RefPtr<TransformPaintPropertyNode> m_preTranslation; 1054 RefPtr<TransformPaintPropertyNode> m_preTranslation;
(...skipping 10 matching lines...) Expand all
1056 1065
1057 // This is set on the local root frame view only. 1066 // This is set on the local root frame view only.
1058 DocumentLifecycle::LifecycleState m_currentUpdateLifecyclePhasesTargetState; 1067 DocumentLifecycle::LifecycleState m_currentUpdateLifecyclePhasesTargetState;
1059 1068
1060 ScrollAnchor m_scrollAnchor; 1069 ScrollAnchor m_scrollAnchor;
1061 1070
1062 bool m_needsScrollbarsUpdate; 1071 bool m_needsScrollbarsUpdate;
1063 bool m_suppressAdjustViewSize; 1072 bool m_suppressAdjustViewSize;
1064 bool m_allowsLayoutInvalidationAfterLayoutClean; 1073 bool m_allowsLayoutInvalidationAfterLayoutClean;
1065 1074
1075 Member<IntersectionObserver> m_intersectionObserver;
1076
1066 // For testing. 1077 // For testing.
1067 struct ObjectPaintInvalidation { 1078 struct ObjectPaintInvalidation {
1068 String name; 1079 String name;
1069 PaintInvalidationReason reason; 1080 PaintInvalidationReason reason;
1070 }; 1081 };
1071 std::unique_ptr<Vector<ObjectPaintInvalidation>> 1082 std::unique_ptr<Vector<ObjectPaintInvalidation>>
1072 m_trackedObjectPaintInvalidations; 1083 m_trackedObjectPaintInvalidations;
1073 1084
1074 // For Slimming Paint v2 only. 1085 // For Slimming Paint v2 only.
1075 std::unique_ptr<PaintController> m_paintController; 1086 std::unique_ptr<PaintController> m_paintController;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 widget.isFrameView()); 1118 widget.isFrameView());
1108 DEFINE_TYPE_CASTS(FrameView, 1119 DEFINE_TYPE_CASTS(FrameView,
1109 ScrollableArea, 1120 ScrollableArea,
1110 scrollableArea, 1121 scrollableArea,
1111 scrollableArea->isFrameView(), 1122 scrollableArea->isFrameView(),
1112 scrollableArea.isFrameView()); 1123 scrollableArea.isFrameView());
1113 1124
1114 } // namespace blink 1125 } // namespace blink
1115 1126
1116 #endif // FrameView_h 1127 #endif // FrameView_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698