OLD | NEW |
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/ScrollAnchor.h" | 34 #include "core/layout/ScrollAnchor.h" |
34 #include "core/layout/api/LayoutViewItem.h" | 35 #include "core/layout/api/LayoutViewItem.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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 | 585 |
585 LayoutAnalyzer* layoutAnalyzer() { return m_analyzer.get(); } | 586 LayoutAnalyzer* layoutAnalyzer() { return m_analyzer.get(); } |
586 | 587 |
587 // Returns true if this frame should not render or schedule visual updates. | 588 // Returns true if this frame should not render or schedule visual updates. |
588 bool shouldThrottleRendering() const; | 589 bool shouldThrottleRendering() const; |
589 | 590 |
590 // Returns true if this frame could potentially skip rendering and avoid | 591 // Returns true if this frame could potentially skip rendering and avoid |
591 // scheduling visual updates. | 592 // scheduling visual updates. |
592 bool canThrottleRendering() const; | 593 bool canThrottleRendering() const; |
593 bool isHiddenForThrottling() const { return m_hiddenForThrottling; } | 594 bool isHiddenForThrottling() const { return m_hiddenForThrottling; } |
| 595 void setupRenderThrottling(); |
594 | 596 |
595 // For testing, run pending intersection observer notifications for this fra
me. | 597 // For testing, run pending intersection observer notifications for this fra
me. |
596 void notifyRenderThrottlingObserversForTesting(); | 598 void updateRenderThrottlingStatusForTesting(); |
597 | 599 |
598 // Paint properties for SPv2 Only. | 600 // Paint properties for SPv2 Only. |
599 void setPreTranslation(PassRefPtr<TransformPaintPropertyNode> preTranslation
) { m_preTranslation = preTranslation; } | 601 void setPreTranslation(PassRefPtr<TransformPaintPropertyNode> preTranslation
) { m_preTranslation = preTranslation; } |
600 TransformPaintPropertyNode* preTranslation() const { return m_preTranslation
.get(); } | 602 TransformPaintPropertyNode* preTranslation() const { return m_preTranslation
.get(); } |
601 | 603 |
602 void setScrollTranslation(PassRefPtr<TransformPaintPropertyNode> scrollTrans
lation) { m_scrollTranslation = scrollTranslation; } | 604 void setScrollTranslation(PassRefPtr<TransformPaintPropertyNode> scrollTrans
lation) { m_scrollTranslation = scrollTranslation; } |
603 TransformPaintPropertyNode* scrollTranslation() const { return m_scrollTrans
lation.get(); } | 605 TransformPaintPropertyNode* scrollTranslation() const { return m_scrollTrans
lation.get(); } |
604 | 606 |
605 void setContentClip(PassRefPtr<ClipPaintPropertyNode> contentClip) { m_conte
ntClip = contentClip; } | 607 void setContentClip(PassRefPtr<ClipPaintPropertyNode> contentClip) { m_conte
ntClip = contentClip; } |
606 ClipPaintPropertyNode* contentClip() const { return m_contentClip.get(); } | 608 ClipPaintPropertyNode* contentClip() const { return m_contentClip.get(); } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 : m_scope(&view->m_inUpdateScrollbars, true) | 663 : m_scope(&view->m_inUpdateScrollbars, true) |
662 { } | 664 { } |
663 private: | 665 private: |
664 AutoReset<bool> m_scope; | 666 AutoReset<bool> m_scope; |
665 }; | 667 }; |
666 | 668 |
667 // Only for LayoutPart to traverse into sub frames during paint invalidation
. | 669 // Only for LayoutPart to traverse into sub frames during paint invalidation
. |
668 void invalidateTreeIfNeeded(const PaintInvalidationState&); | 670 void invalidateTreeIfNeeded(const PaintInvalidationState&); |
669 | 671 |
670 private: | 672 private: |
| 673 class IntersectionObserverCallback : public blink::IntersectionObserverCallb
ack { |
| 674 public: |
| 675 IntersectionObserverCallback(FrameView*, ExecutionContext*); |
| 676 |
| 677 // IntersectionObserverCallback implementation: |
| 678 void handleEvent(const HeapVector<Member<IntersectionObserverEntry>>&, I
ntersectionObserver&) override; |
| 679 ExecutionContext* getExecutionContext() const override; |
| 680 |
| 681 DECLARE_TRACE(); |
| 682 |
| 683 private: |
| 684 WeakMember<FrameView> m_frameView; |
| 685 WeakMember<ExecutionContext> m_context; |
| 686 }; |
| 687 |
671 explicit FrameView(LocalFrame*); | 688 explicit FrameView(LocalFrame*); |
672 | 689 |
673 void setScrollOffset(const DoublePoint&, ScrollType) override; | 690 void setScrollOffset(const DoublePoint&, ScrollType) override; |
674 | 691 |
675 void updateLifecyclePhasesInternal(DocumentLifecycle::LifecycleState targetS
tate); | 692 void updateLifecyclePhasesInternal(DocumentLifecycle::LifecycleState targetS
tate); |
676 | 693 |
677 void invalidateTreeIfNeededRecursive(); | 694 void invalidateTreeIfNeededRecursive(); |
678 void scrollContentsIfNeededRecursive(); | 695 void scrollContentsIfNeededRecursive(); |
679 void updateStyleAndLayoutIfNeededRecursive(); | 696 void updateStyleAndLayoutIfNeededRecursive(); |
680 void updatePaintProperties(); | 697 void updatePaintProperties(); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 | 788 |
772 // LayoutObject for the viewport-defining element (see Document::viewportDef
iningElement). | 789 // LayoutObject for the viewport-defining element (see Document::viewportDef
iningElement). |
773 LayoutObject* viewportLayoutObject() const; | 790 LayoutObject* viewportLayoutObject() const; |
774 | 791 |
775 void collectAnnotatedRegions(LayoutObject&, Vector<AnnotatedRegionValue>&) c
onst; | 792 void collectAnnotatedRegions(LayoutObject&, Vector<AnnotatedRegionValue>&) c
onst; |
776 | 793 |
777 template <typename Function> void forAllNonThrottledFrameViews(const Functio
n&); | 794 template <typename Function> void forAllNonThrottledFrameViews(const Functio
n&); |
778 | 795 |
779 void setNeedsUpdateViewportIntersection(); | 796 void setNeedsUpdateViewportIntersection(); |
780 void updateViewportIntersectionsForSubtree(DocumentLifecycle::LifecycleState
targetState); | 797 void updateViewportIntersectionsForSubtree(DocumentLifecycle::LifecycleState
targetState); |
781 void updateViewportIntersectionIfNeeded(); | 798 void updateRenderThrottlingStatus(bool hidden, bool subtreeThrottled); |
782 void notifyRenderThrottlingObservers(); | |
783 void updateThrottlingStatus(); | |
784 void notifyResizeObservers(); | 799 void notifyResizeObservers(); |
785 | 800 |
786 // PaintInvalidationCapableScrollableArea | 801 // PaintInvalidationCapableScrollableArea |
787 LayoutScrollbarPart* resizer() const override { return nullptr; } | 802 LayoutScrollbarPart* resizer() const override { return nullptr; } |
788 | 803 |
789 bool checkLayoutInvalidationIsAllowed() const; | 804 bool checkLayoutInvalidationIsAllowed() const; |
790 | 805 |
791 LayoutSize m_size; | 806 LayoutSize m_size; |
792 | 807 |
793 typedef HashSet<RefPtr<LayoutEmbeddedObject>> EmbeddedObjectSet; | 808 typedef HashSet<RefPtr<LayoutEmbeddedObject>> EmbeddedObjectSet; |
(...skipping 18 matching lines...) Expand all Loading... |
812 bool m_hasPendingLayout; | 827 bool m_hasPendingLayout; |
813 LayoutSubtreeRootList m_layoutSubtreeRootList; | 828 LayoutSubtreeRootList m_layoutSubtreeRootList; |
814 DepthOrderedLayoutObjectList m_orthogonalWritingModeRootList; | 829 DepthOrderedLayoutObjectList m_orthogonalWritingModeRootList; |
815 | 830 |
816 bool m_layoutSchedulingEnabled; | 831 bool m_layoutSchedulingEnabled; |
817 bool m_inSynchronousPostLayout; | 832 bool m_inSynchronousPostLayout; |
818 int m_layoutCount; | 833 int m_layoutCount; |
819 unsigned m_nestedLayoutCount; | 834 unsigned m_nestedLayoutCount; |
820 Timer<FrameView> m_postLayoutTasksTimer; | 835 Timer<FrameView> m_postLayoutTasksTimer; |
821 Timer<FrameView> m_updateWidgetsTimer; | 836 Timer<FrameView> m_updateWidgetsTimer; |
822 std::unique_ptr<CancellableTaskFactory> m_renderThrottlingObserverNotificati
onFactory; | |
823 | 837 |
824 bool m_firstLayout; | 838 bool m_firstLayout; |
825 bool m_isTransparent; | 839 bool m_isTransparent; |
826 Color m_baseBackgroundColor; | 840 Color m_baseBackgroundColor; |
827 IntSize m_lastViewportSize; | 841 IntSize m_lastViewportSize; |
828 float m_lastZoomFactor; | 842 float m_lastZoomFactor; |
829 | 843 |
830 AtomicString m_mediaType; | 844 AtomicString m_mediaType; |
831 AtomicString m_mediaTypeWhenNotPrinting; | 845 AtomicString m_mediaTypeWhenNotPrinting; |
832 | 846 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 | 908 |
895 // Mark if something has changed in the mapping from Frame to GraphicsLayer | 909 // Mark if something has changed in the mapping from Frame to GraphicsLayer |
896 // and the Frame Timing regions should be recalculated. | 910 // and the Frame Timing regions should be recalculated. |
897 bool m_frameTimingRequestsDirty; | 911 bool m_frameTimingRequestsDirty; |
898 | 912 |
899 // Exists only on root frame. | 913 // Exists only on root frame. |
900 // TODO(bokan): crbug.com/484188. We should specialize FrameView for the | 914 // TODO(bokan): crbug.com/484188. We should specialize FrameView for the |
901 // main frame. | 915 // main frame. |
902 Member<RootFrameViewport> m_viewportScrollableArea; | 916 Member<RootFrameViewport> m_viewportScrollableArea; |
903 | 917 |
904 // This frame's bounds in the root frame's content coordinates, clipped | |
905 // recursively through every ancestor view. | |
906 IntRect m_viewportIntersection; | |
907 bool m_viewportIntersectionValid; | |
908 | |
909 // The following members control rendering pipeline throttling for this | 918 // The following members control rendering pipeline throttling for this |
910 // frame. They are only updated in response to intersection observer | 919 // frame. They are only updated in response to intersection observer |
911 // notifications, i.e., not in the middle of the lifecycle. | 920 // notifications, i.e., not in the middle of the lifecycle. |
912 bool m_hiddenForThrottling; | 921 bool m_hiddenForThrottling; |
913 bool m_crossOriginForThrottling; | |
914 bool m_subtreeThrottled; | 922 bool m_subtreeThrottled; |
915 | 923 |
916 // Paint properties for SPv2 Only. | 924 // Paint properties for SPv2 Only. |
917 // The hierarchy of transform subtree created by a FrameView. | 925 // The hierarchy of transform subtree created by a FrameView. |
918 // [ preTranslation ] The offset from Widget::frameRect. Estab
lishes viewport. | 926 // [ preTranslation ] The offset from Widget::frameRect. Estab
lishes viewport. |
919 // +---[ scrollTranslation ] Frame scrolling. | 927 // +---[ scrollTranslation ] Frame scrolling. |
920 // TODO(trchen): These will not be needed once settings->rootLayerScrolls()
is enabled. | 928 // TODO(trchen): These will not be needed once settings->rootLayerScrolls()
is enabled. |
921 RefPtr<TransformPaintPropertyNode> m_preTranslation; | 929 RefPtr<TransformPaintPropertyNode> m_preTranslation; |
922 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; | 930 RefPtr<TransformPaintPropertyNode> m_scrollTranslation; |
923 // The content clip clips the document (= LayoutView) but not the scrollbars
. | 931 // The content clip clips the document (= LayoutView) but not the scrollbars
. |
924 // TODO(trchen): This will not be needed once settings->rootLayerScrolls() i
s enabled. | 932 // TODO(trchen): This will not be needed once settings->rootLayerScrolls() i
s enabled. |
925 RefPtr<ClipPaintPropertyNode> m_contentClip; | 933 RefPtr<ClipPaintPropertyNode> m_contentClip; |
926 | 934 |
927 // These nodes represent the root nodes of each property tree. | 935 // These nodes represent the root nodes of each property tree. |
928 // Only the root frame should create them and they will be no-op. | 936 // Only the root frame should create them and they will be no-op. |
929 RefPtr<TransformPaintPropertyNode> m_rootTransform; | 937 RefPtr<TransformPaintPropertyNode> m_rootTransform; |
930 RefPtr<ClipPaintPropertyNode> m_rootClip; | 938 RefPtr<ClipPaintPropertyNode> m_rootClip; |
931 RefPtr<EffectPaintPropertyNode> m_rootEffect; | 939 RefPtr<EffectPaintPropertyNode> m_rootEffect; |
932 | 940 |
933 // This is set on the local root frame view only. | 941 // This is set on the local root frame view only. |
934 DocumentLifecycle::LifecycleState m_currentUpdateLifecyclePhasesTargetState; | 942 DocumentLifecycle::LifecycleState m_currentUpdateLifecyclePhasesTargetState; |
935 | 943 |
936 ScrollAnchor m_scrollAnchor; | 944 ScrollAnchor m_scrollAnchor; |
937 | 945 |
938 bool m_needsScrollbarsUpdate; | 946 bool m_needsScrollbarsUpdate; |
939 bool m_suppressAdjustViewSize; | 947 bool m_suppressAdjustViewSize; |
940 bool m_allowsLayoutInvalidationAfterLayoutClean; | 948 bool m_allowsLayoutInvalidationAfterLayoutClean; |
941 | 949 |
| 950 Member<IntersectionObserver> m_intersectionObserver; |
| 951 |
942 // For testing. | 952 // For testing. |
943 struct ObjectPaintInvalidation { | 953 struct ObjectPaintInvalidation { |
944 String name; | 954 String name; |
945 PaintInvalidationReason reason; | 955 PaintInvalidationReason reason; |
946 }; | 956 }; |
947 std::unique_ptr<Vector<ObjectPaintInvalidation>> m_trackedObjectPaintInvalid
ations; | 957 std::unique_ptr<Vector<ObjectPaintInvalidation>> m_trackedObjectPaintInvalid
ations; |
948 }; | 958 }; |
949 | 959 |
950 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) | 960 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) |
951 { | 961 { |
(...skipping 17 matching lines...) Expand all Loading... |
969 if (m_visuallyNonEmptyPixelCount > visualPixelThreshold) | 979 if (m_visuallyNonEmptyPixelCount > visualPixelThreshold) |
970 setIsVisuallyNonEmpty(); | 980 setIsVisuallyNonEmpty(); |
971 } | 981 } |
972 | 982 |
973 DEFINE_TYPE_CASTS(FrameView, Widget, widget, widget->isFrameView(), widget.isFra
meView()); | 983 DEFINE_TYPE_CASTS(FrameView, Widget, widget, widget->isFrameView(), widget.isFra
meView()); |
974 DEFINE_TYPE_CASTS(FrameView, ScrollableArea, scrollableArea, scrollableArea->isF
rameView(), scrollableArea.isFrameView()); | 984 DEFINE_TYPE_CASTS(FrameView, ScrollableArea, scrollableArea, scrollableArea->isF
rameView(), scrollableArea.isFrameView()); |
975 | 985 |
976 } // namespace blink | 986 } // namespace blink |
977 | 987 |
978 #endif // FrameView_h | 988 #endif // FrameView_h |
OLD | NEW |