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

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: Rebased Created 4 years, 3 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 reserv ed. 7 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
8 8
9 This library is free software; you can redistribute it and/or 9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public 10 modify it under the terms of the GNU Library General Public
11 License as published by the Free Software Foundation; either 11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version. 12 version 2 of the License, or (at your option) any later version.
13 13
14 This library is distributed in the hope that it will be useful, 14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details. 17 Library General Public License for more details.
18 18
19 You should have received a copy of the GNU Library General Public License 19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to 20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA. 22 Boston, MA 02110-1301, USA.
23 */ 23 */
24 24
25 #ifndef FrameView_h 25 #ifndef FrameView_h
26 #define FrameView_h 26 #define FrameView_h
27 27
28 #include "core/CoreExport.h" 28 #include "core/CoreExport.h"
29 #include "core/dom/DocumentLifecycle.h" 29 #include "core/dom/DocumentLifecycle.h"
30 #include "core/dom/IntersectionObserverCallback.h"
30 #include "core/frame/FrameViewAutoSizeInfo.h" 31 #include "core/frame/FrameViewAutoSizeInfo.h"
31 #include "core/frame/LayoutSubtreeRootList.h" 32 #include "core/frame/LayoutSubtreeRootList.h"
32 #include "core/frame/RootFrameViewport.h" 33 #include "core/frame/RootFrameViewport.h"
33 #include "core/layout/LayoutObject.h" 34 #include "core/layout/LayoutObject.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/PaintInvalidationCapableScrollableArea.h" 37 #include "core/paint/PaintInvalidationCapableScrollableArea.h"
37 #include "core/paint/PaintPhase.h" 38 #include "core/paint/PaintPhase.h"
38 #include "platform/RuntimeEnabledFeatures.h" 39 #include "platform/RuntimeEnabledFeatures.h"
39 #include "platform/Widget.h" 40 #include "platform/Widget.h"
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 583
583 LayoutAnalyzer* layoutAnalyzer() { return m_analyzer.get(); } 584 LayoutAnalyzer* layoutAnalyzer() { return m_analyzer.get(); }
584 585
585 // Returns true if this frame should not render or schedule visual updates. 586 // Returns true if this frame should not render or schedule visual updates.
586 bool shouldThrottleRendering() const; 587 bool shouldThrottleRendering() const;
587 588
588 // Returns true if this frame could potentially skip rendering and avoid 589 // Returns true if this frame could potentially skip rendering and avoid
589 // scheduling visual updates. 590 // scheduling visual updates.
590 bool canThrottleRendering() const; 591 bool canThrottleRendering() const;
591 bool isHiddenForThrottling() const { return m_hiddenForThrottling; } 592 bool isHiddenForThrottling() const { return m_hiddenForThrottling; }
593 void setupRenderThrottling();
592 594
593 // For testing, run pending intersection observer notifications for this fra me. 595 // For testing, run pending intersection observer notifications for this fra me.
594 void notifyRenderThrottlingObserversForTesting(); 596 void updateRenderThrottlingStatusForTesting();
595 597
596 // Paint properties for SPv2 Only. 598 // Paint properties for SPv2 Only.
597 void setPreTranslation(PassRefPtr<TransformPaintPropertyNode> preTranslation ) { m_preTranslation = preTranslation; } 599 void setPreTranslation(PassRefPtr<TransformPaintPropertyNode> preTranslation ) { m_preTranslation = preTranslation; }
598 TransformPaintPropertyNode* preTranslation() const { return m_preTranslation .get(); } 600 TransformPaintPropertyNode* preTranslation() const { return m_preTranslation .get(); }
599 601
600 void setScrollTranslation(PassRefPtr<TransformPaintPropertyNode> scrollTrans lation) { m_scrollTranslation = scrollTranslation; } 602 void setScrollTranslation(PassRefPtr<TransformPaintPropertyNode> scrollTrans lation) { m_scrollTranslation = scrollTranslation; }
601 TransformPaintPropertyNode* scrollTranslation() const { return m_scrollTrans lation.get(); } 603 TransformPaintPropertyNode* scrollTranslation() const { return m_scrollTrans lation.get(); }
602 604
603 void setContentClip(PassRefPtr<ClipPaintPropertyNode> contentClip) { m_conte ntClip = contentClip; } 605 void setContentClip(PassRefPtr<ClipPaintPropertyNode> contentClip) { m_conte ntClip = contentClip; }
604 ClipPaintPropertyNode* contentClip() const { return m_contentClip.get(); } 606 ClipPaintPropertyNode* contentClip() const { return m_contentClip.get(); }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 : m_scope(&view->m_inUpdateScrollbars, true) 661 : m_scope(&view->m_inUpdateScrollbars, true)
660 { } 662 { }
661 private: 663 private:
662 AutoReset<bool> m_scope; 664 AutoReset<bool> m_scope;
663 }; 665 };
664 666
665 // Only for LayoutPart to traverse into sub frames during paint invalidation . 667 // Only for LayoutPart to traverse into sub frames during paint invalidation .
666 void invalidateTreeIfNeeded(const PaintInvalidationState&); 668 void invalidateTreeIfNeeded(const PaintInvalidationState&);
667 669
668 private: 670 private:
671 class IntersectionObserverCallback : public blink::IntersectionObserverCallb ack {
672 public:
673 IntersectionObserverCallback(FrameView*, ExecutionContext*);
674
675 // IntersectionObserverCallback implementation:
676 void handleEvent(const HeapVector<Member<IntersectionObserverEntry>>&, I ntersectionObserver&) override;
677 ExecutionContext* getExecutionContext() const override;
678
679 DECLARE_TRACE();
680
681 private:
682 WeakMember<FrameView> m_frameView;
683 WeakMember<ExecutionContext> m_context;
684 };
685
669 explicit FrameView(LocalFrame*); 686 explicit FrameView(LocalFrame*);
670 687
671 void setScrollOffset(const DoublePoint&, ScrollType) override; 688 void setScrollOffset(const DoublePoint&, ScrollType) override;
672 689
673 void updateLifecyclePhasesInternal(DocumentLifecycle::LifecycleState targetS tate); 690 void updateLifecyclePhasesInternal(DocumentLifecycle::LifecycleState targetS tate);
674 691
675 void invalidateTreeIfNeededRecursive(); 692 void invalidateTreeIfNeededRecursive();
676 void scrollContentsIfNeededRecursive(); 693 void scrollContentsIfNeededRecursive();
677 void updateStyleAndLayoutIfNeededRecursive(); 694 void updateStyleAndLayoutIfNeededRecursive();
678 void updatePaintProperties(); 695 void updatePaintProperties();
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 786
770 // LayoutObject for the viewport-defining element (see Document::viewportDef iningElement). 787 // LayoutObject for the viewport-defining element (see Document::viewportDef iningElement).
771 LayoutObject* viewportLayoutObject() const; 788 LayoutObject* viewportLayoutObject() const;
772 789
773 void collectAnnotatedRegions(LayoutObject&, Vector<AnnotatedRegionValue>&) c onst; 790 void collectAnnotatedRegions(LayoutObject&, Vector<AnnotatedRegionValue>&) c onst;
774 791
775 template <typename Function> void forAllNonThrottledFrameViews(const Functio n&); 792 template <typename Function> void forAllNonThrottledFrameViews(const Functio n&);
776 793
777 void setNeedsUpdateViewportIntersection(); 794 void setNeedsUpdateViewportIntersection();
778 void updateViewportIntersectionsForSubtree(DocumentLifecycle::LifecycleState targetState); 795 void updateViewportIntersectionsForSubtree(DocumentLifecycle::LifecycleState targetState);
779 void updateViewportIntersectionIfNeeded(); 796 void updateRenderThrottlingStatus(bool hidden, bool subtreeThrottled);
780 void notifyRenderThrottlingObservers();
781 void updateThrottlingStatus();
782 void notifyResizeObservers(); 797 void notifyResizeObservers();
783 798
784 // PaintInvalidationCapableScrollableArea 799 // PaintInvalidationCapableScrollableArea
785 LayoutScrollbarPart* resizer() const override { return nullptr; } 800 LayoutScrollbarPart* resizer() const override { return nullptr; }
786 801
787 bool checkLayoutInvalidationIsAllowed() const; 802 bool checkLayoutInvalidationIsAllowed() const;
788 803
789 LayoutSize m_size; 804 LayoutSize m_size;
790 805
791 typedef HashSet<RefPtr<LayoutEmbeddedObject>> EmbeddedObjectSet; 806 typedef HashSet<RefPtr<LayoutEmbeddedObject>> EmbeddedObjectSet;
(...skipping 18 matching lines...) Expand all
810 bool m_hasPendingLayout; 825 bool m_hasPendingLayout;
811 LayoutSubtreeRootList m_layoutSubtreeRootList; 826 LayoutSubtreeRootList m_layoutSubtreeRootList;
812 DepthOrderedLayoutObjectList m_orthogonalWritingModeRootList; 827 DepthOrderedLayoutObjectList m_orthogonalWritingModeRootList;
813 828
814 bool m_layoutSchedulingEnabled; 829 bool m_layoutSchedulingEnabled;
815 bool m_inSynchronousPostLayout; 830 bool m_inSynchronousPostLayout;
816 int m_layoutCount; 831 int m_layoutCount;
817 unsigned m_nestedLayoutCount; 832 unsigned m_nestedLayoutCount;
818 Timer<FrameView> m_postLayoutTasksTimer; 833 Timer<FrameView> m_postLayoutTasksTimer;
819 Timer<FrameView> m_updateWidgetsTimer; 834 Timer<FrameView> m_updateWidgetsTimer;
820 std::unique_ptr<CancellableTaskFactory> m_renderThrottlingObserverNotificati onFactory;
821 835
822 bool m_firstLayout; 836 bool m_firstLayout;
823 bool m_isTransparent; 837 bool m_isTransparent;
824 Color m_baseBackgroundColor; 838 Color m_baseBackgroundColor;
825 IntSize m_lastViewportSize; 839 IntSize m_lastViewportSize;
826 float m_lastZoomFactor; 840 float m_lastZoomFactor;
827 841
828 AtomicString m_mediaType; 842 AtomicString m_mediaType;
829 AtomicString m_mediaTypeWhenNotPrinting; 843 AtomicString m_mediaTypeWhenNotPrinting;
830 844
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 906
893 // Mark if something has changed in the mapping from Frame to GraphicsLayer 907 // Mark if something has changed in the mapping from Frame to GraphicsLayer
894 // and the Frame Timing regions should be recalculated. 908 // and the Frame Timing regions should be recalculated.
895 bool m_frameTimingRequestsDirty; 909 bool m_frameTimingRequestsDirty;
896 910
897 // Exists only on root frame. 911 // Exists only on root frame.
898 // TODO(bokan): crbug.com/484188. We should specialize FrameView for the 912 // TODO(bokan): crbug.com/484188. We should specialize FrameView for the
899 // main frame. 913 // main frame.
900 Member<RootFrameViewport> m_viewportScrollableArea; 914 Member<RootFrameViewport> m_viewportScrollableArea;
901 915
902 // This frame's bounds in the root frame's content coordinates, clipped
903 // recursively through every ancestor view.
904 IntRect m_viewportIntersection;
905 bool m_viewportIntersectionValid;
906
907 // The following members control rendering pipeline throttling for this 916 // The following members control rendering pipeline throttling for this
908 // frame. They are only updated in response to intersection observer 917 // frame. They are only updated in response to intersection observer
909 // notifications, i.e., not in the middle of the lifecycle. 918 // notifications, i.e., not in the middle of the lifecycle.
910 bool m_hiddenForThrottling; 919 bool m_hiddenForThrottling;
911 bool m_crossOriginForThrottling;
912 bool m_subtreeThrottled; 920 bool m_subtreeThrottled;
913 921
914 // Paint properties for SPv2 Only. 922 // Paint properties for SPv2 Only.
915 // The hierarchy of transform subtree created by a FrameView. 923 // The hierarchy of transform subtree created by a FrameView.
916 // [ preTranslation ] The offset from Widget::frameRect. Estab lishes viewport. 924 // [ preTranslation ] The offset from Widget::frameRect. Estab lishes viewport.
917 // +---[ scrollTranslation ] Frame scrolling. 925 // +---[ scrollTranslation ] Frame scrolling.
918 // TODO(trchen): These will not be needed once settings->rootLayerScrolls() is enabled. 926 // TODO(trchen): These will not be needed once settings->rootLayerScrolls() is enabled.
919 RefPtr<TransformPaintPropertyNode> m_preTranslation; 927 RefPtr<TransformPaintPropertyNode> m_preTranslation;
920 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; 928 RefPtr<TransformPaintPropertyNode> m_scrollTranslation;
921 // The content clip clips the document (= LayoutView) but not the scrollbars . 929 // The content clip clips the document (= LayoutView) but not the scrollbars .
922 // TODO(trchen): This will not be needed once settings->rootLayerScrolls() i s enabled. 930 // TODO(trchen): This will not be needed once settings->rootLayerScrolls() i s enabled.
923 RefPtr<ClipPaintPropertyNode> m_contentClip; 931 RefPtr<ClipPaintPropertyNode> m_contentClip;
924 932
925 // These nodes represent the root nodes of each property tree. 933 // These nodes represent the root nodes of each property tree.
926 // Only the root frame should create them and they will be no-op. 934 // Only the root frame should create them and they will be no-op.
927 RefPtr<TransformPaintPropertyNode> m_rootTransform; 935 RefPtr<TransformPaintPropertyNode> m_rootTransform;
928 RefPtr<ClipPaintPropertyNode> m_rootClip; 936 RefPtr<ClipPaintPropertyNode> m_rootClip;
929 RefPtr<EffectPaintPropertyNode> m_rootEffect; 937 RefPtr<EffectPaintPropertyNode> m_rootEffect;
930 938
931 // This is set on the local root frame view only. 939 // This is set on the local root frame view only.
932 DocumentLifecycle::LifecycleState m_currentUpdateLifecyclePhasesTargetState; 940 DocumentLifecycle::LifecycleState m_currentUpdateLifecyclePhasesTargetState;
933 941
934 ScrollAnchor m_scrollAnchor; 942 ScrollAnchor m_scrollAnchor;
935 943
936 bool m_needsScrollbarsUpdate; 944 bool m_needsScrollbarsUpdate;
937 bool m_suppressAdjustViewSize; 945 bool m_suppressAdjustViewSize;
938 bool m_allowsLayoutInvalidationAfterLayoutClean; 946 bool m_allowsLayoutInvalidationAfterLayoutClean;
939 947
948 Member<IntersectionObserver> m_intersectionObserver;
949
940 // For testing. 950 // For testing.
941 struct ObjectPaintInvalidation { 951 struct ObjectPaintInvalidation {
942 String name; 952 String name;
943 PaintInvalidationReason reason; 953 PaintInvalidationReason reason;
944 }; 954 };
945 std::unique_ptr<Vector<ObjectPaintInvalidation>> m_trackedObjectPaintInvalid ations; 955 std::unique_ptr<Vector<ObjectPaintInvalidation>> m_trackedObjectPaintInvalid ations;
946 }; 956 };
947 957
948 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) 958 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count)
949 { 959 {
(...skipping 17 matching lines...) Expand all
967 if (m_visuallyNonEmptyPixelCount > visualPixelThreshold) 977 if (m_visuallyNonEmptyPixelCount > visualPixelThreshold)
968 setIsVisuallyNonEmpty(); 978 setIsVisuallyNonEmpty();
969 } 979 }
970 980
971 DEFINE_TYPE_CASTS(FrameView, Widget, widget, widget->isFrameView(), widget.isFra meView()); 981 DEFINE_TYPE_CASTS(FrameView, Widget, widget, widget->isFrameView(), widget.isFra meView());
972 DEFINE_TYPE_CASTS(FrameView, ScrollableArea, scrollableArea, scrollableArea->isF rameView(), scrollableArea.isFrameView()); 982 DEFINE_TYPE_CASTS(FrameView, ScrollableArea, scrollableArea, scrollableArea->isF rameView(), scrollableArea.isFrameView());
973 983
974 } // namespace blink 984 } // namespace blink
975 985
976 #endif // FrameView_h 986 #endif // FrameView_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698