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/frame/FrameViewAutoSizeInfo.h" | 30 #include "core/frame/FrameViewAutoSizeInfo.h" |
30 #include "core/frame/LayoutSubtreeRootList.h" | 31 #include "core/frame/LayoutSubtreeRootList.h" |
31 #include "core/frame/RootFrameViewport.h" | 32 #include "core/frame/RootFrameViewport.h" |
32 #include "core/layout/LayoutAnalyzer.h" | 33 #include "core/layout/LayoutAnalyzer.h" |
33 #include "core/paint/PaintPhase.h" | 34 #include "core/paint/PaintPhase.h" |
34 #include "platform/RuntimeEnabledFeatures.h" | 35 #include "platform/RuntimeEnabledFeatures.h" |
35 #include "platform/Widget.h" | 36 #include "platform/Widget.h" |
36 #include "platform/geometry/IntRect.h" | 37 #include "platform/geometry/IntRect.h" |
37 #include "platform/geometry/LayoutRect.h" | 38 #include "platform/geometry/LayoutRect.h" |
38 #include "platform/graphics/Color.h" | 39 #include "platform/graphics/Color.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 76 |
76 typedef unsigned long long DOMTimeStamp; | 77 typedef unsigned long long DOMTimeStamp; |
77 | 78 |
78 class CORE_EXPORT FrameView final : public Widget, public ScrollableArea { | 79 class CORE_EXPORT FrameView final : public Widget, public ScrollableArea { |
79 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(FrameView); | 80 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(FrameView); |
80 | 81 |
81 friend class DisplayItemListPaintTestForSlimmingPaintV2; | 82 friend class DisplayItemListPaintTestForSlimmingPaintV2; |
82 friend class Internals; | 83 friend class Internals; |
83 friend class LayoutPart; // for invalidateTreeIfNeeded | 84 friend class LayoutPart; // for invalidateTreeIfNeeded |
84 friend class LayoutView; // for contentRectangleForPaintInvalidation | 85 friend class LayoutView; // for contentRectangleForPaintInvalidation |
| 86 friend class FrameThrottlingTest; |
85 | 87 |
86 public: | 88 public: |
87 static PassRefPtrWillBeRawPtr<FrameView> create(LocalFrame*); | 89 static PassRefPtrWillBeRawPtr<FrameView> create(LocalFrame*); |
88 static PassRefPtrWillBeRawPtr<FrameView> create(LocalFrame*, const IntSize&
initialSize); | 90 static PassRefPtrWillBeRawPtr<FrameView> create(LocalFrame*, const IntSize&
initialSize); |
89 | 91 |
90 ~FrameView() override; | 92 ~FrameView() override; |
91 | 93 |
92 void invalidateRect(const IntRect&) override; | 94 void invalidateRect(const IntRect&) override; |
93 void setFrameRect(const IntRect&) override; | 95 void setFrameRect(const IntRect&) override; |
94 | 96 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 void setIsPainting(bool val) { m_isPainting = val; } | 221 void setIsPainting(bool val) { m_isPainting = val; } |
220 bool isPainting() const; | 222 bool isPainting() const; |
221 void setLastPaintTime(double val) { m_lastPaintTime = val; } | 223 void setLastPaintTime(double val) { m_lastPaintTime = val; } |
222 bool hasEverPainted() const { return m_lastPaintTime; } | 224 bool hasEverPainted() const { return m_lastPaintTime; } |
223 void setNodeToDraw(Node*); | 225 void setNodeToDraw(Node*); |
224 Node* nodeToDraw() { return m_nodeToDraw.get(); } | 226 Node* nodeToDraw() { return m_nodeToDraw.get(); } |
225 | 227 |
226 Color documentBackgroundColor() const; | 228 Color documentBackgroundColor() const; |
227 | 229 |
228 // Run all needed lifecycle stages. After calling this method, all frames wi
ll be in the lifecycle state PaintInvalidationClean. | 230 // Run all needed lifecycle stages. After calling this method, all frames wi
ll be in the lifecycle state PaintInvalidationClean. |
| 231 // If lifecycle throttling is allowed, some frames may skip the lifecycle up
date (e.g., based on visibility) and will not end |
| 232 // up being PaintInvalidationClean. |
229 // TODO(pdr): Update callers to pass in the interest rect. | 233 // TODO(pdr): Update callers to pass in the interest rect. |
230 void updateAllLifecyclePhases(const LayoutRect& interestRect = LayoutRect::i
nfiniteRect()); | 234 void updateAllLifecyclePhases(DocumentLifecycle::ThrottlingMode = DocumentLi
fecycle::ThrottlingMode::Disallow, const LayoutRect& interestRect = LayoutRect::
infiniteRect()); |
231 | 235 |
232 // Computes the style, layout and compositing lifecycle stages if needed. Af
ter calling this method, all frames wil lbe in a lifecycle | 236 // Computes the style, layout and compositing lifecycle stages if needed. Af
ter calling this method, all frames wil lbe in a lifecycle |
233 // state >= CompositingClean, and scrolling has been updated. | 237 // state >= CompositingClean, and scrolling has been updated. |
234 void updateLifecycleToCompositingCleanPlusScrolling(); | 238 void updateLifecycleToCompositingCleanPlusScrolling(DocumentLifecycle::Throt
tlingMode = DocumentLifecycle::ThrottlingMode::Disallow); |
235 | 239 |
236 bool invalidateViewportConstrainedObjects(); | 240 bool invalidateViewportConstrainedObjects(); |
237 | 241 |
238 void incrementVisuallyNonEmptyCharacterCount(unsigned); | 242 void incrementVisuallyNonEmptyCharacterCount(unsigned); |
239 void incrementVisuallyNonEmptyPixelCount(const IntSize&); | 243 void incrementVisuallyNonEmptyPixelCount(const IntSize&); |
240 bool isVisuallyNonEmpty() const { return m_isVisuallyNonEmpty; } | 244 bool isVisuallyNonEmpty() const { return m_isVisuallyNonEmpty; } |
241 void setIsVisuallyNonEmpty() { m_isVisuallyNonEmpty = true; } | 245 void setIsVisuallyNonEmpty() { m_isVisuallyNonEmpty = true; } |
242 void enableAutoSizeMode(const IntSize& minSize, const IntSize& maxSize); | 246 void enableAutoSizeMode(const IntSize& minSize, const IntSize& maxSize); |
243 void disableAutoSizeMode(); | 247 void disableAutoSizeMode(); |
244 | 248 |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 // Returns true if the default scrolling direction is vertical. i.e. writing
mode | 554 // Returns true if the default scrolling direction is vertical. i.e. writing
mode |
551 // is horiziontal. In a vertical document, a spacebar scrolls down. | 555 // is horiziontal. In a vertical document, a spacebar scrolls down. |
552 bool isVerticalDocument() const; | 556 bool isVerticalDocument() const; |
553 | 557 |
554 // Returns true if the document's writing mode is right-to-left or bottom-to
-top. | 558 // Returns true if the document's writing mode is right-to-left or bottom-to
-top. |
555 bool isFlippedDocument() const; | 559 bool isFlippedDocument() const; |
556 | 560 |
557 void setFrameTimingRequestsDirty(bool isDirty) { m_frameTimingRequestsDirty
= isDirty; } | 561 void setFrameTimingRequestsDirty(bool isDirty) { m_frameTimingRequestsDirty
= isDirty; } |
558 bool frameTimingRequestsDirty() { return m_frameTimingRequestsDirty; } | 562 bool frameTimingRequestsDirty() { return m_frameTimingRequestsDirty; } |
559 | 563 |
| 564 // Returns true if this frame should skip rendering pipeline processing duri
ng the |
| 565 // current BeginMainFrame. |
| 566 bool shouldThrottleRenderingPipeline() const; |
| 567 |
| 568 // Returns true if this frame should skip style computation, layout and |
| 569 // compositing updates for the current BeginMainFrame. |
| 570 bool shouldThrottleStyleLayoutAndCompositingUpdates() const; |
| 571 |
| 572 // Called to signal the end of a lifecycle update. Updates the throttling |
| 573 // status of all frames in the hierarchy and schedules new animations or |
| 574 // lifecycle updates as necessary. |
| 575 void finalizeLifecycleUpdate(); |
| 576 |
560 protected: | 577 protected: |
561 // Scroll the content via the compositor. | 578 // Scroll the content via the compositor. |
562 bool scrollContentsFastPath(const IntSize& scrollDelta); | 579 bool scrollContentsFastPath(const IntSize& scrollDelta); |
563 | 580 |
564 // Scroll the content by invalidating everything. | 581 // Scroll the content by invalidating everything. |
565 void scrollContentsSlowPath(const IntRect& updateRect); | 582 void scrollContentsSlowPath(const IntRect& updateRect); |
566 | 583 |
567 // These functions are used to create/destroy scrollbars. | 584 // These functions are used to create/destroy scrollbars. |
568 void setHasHorizontalScrollbar(bool); | 585 void setHasHorizontalScrollbar(bool); |
569 void setHasVerticalScrollbar(bool); | 586 void setHasVerticalScrollbar(bool); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 explicit FrameView(LocalFrame*); | 620 explicit FrameView(LocalFrame*); |
604 | 621 |
605 void setScrollOffset(const IntPoint&, ScrollType) override; | 622 void setScrollOffset(const IntPoint&, ScrollType) override; |
606 void setScrollOffset(const DoublePoint&, ScrollType) override; | 623 void setScrollOffset(const DoublePoint&, ScrollType) override; |
607 | 624 |
608 enum LifeCycleUpdateOption { | 625 enum LifeCycleUpdateOption { |
609 AllPhases, | 626 AllPhases, |
610 OnlyUpToCompositingCleanPlusScrolling, | 627 OnlyUpToCompositingCleanPlusScrolling, |
611 }; | 628 }; |
612 | 629 |
613 void updateLifecyclePhasesInternal(LifeCycleUpdateOption, const LayoutRect&
interestRect = LayoutRect::infiniteRect()); | 630 void updateLifecyclePhasesInternal(LifeCycleUpdateOption, DocumentLifecycle:
:ThrottlingMode, const LayoutRect& interestRect = LayoutRect::infiniteRect()); |
614 void invalidateTreeIfNeededRecursive(); | 631 void invalidateTreeIfNeededRecursive(); |
615 void scrollContentsIfNeededRecursive(); | 632 void scrollContentsIfNeededRecursive(); |
616 void updateStyleAndLayoutIfNeededRecursive(); | 633 void updateStyleAndLayoutIfNeededRecursive(); |
617 void paintForSlimmingPaintV2(const LayoutRect& interestRect); | 634 void paintForSlimmingPaintV2(const LayoutRect& interestRect); |
618 void compositeForSlimmingPaintV2(); | 635 void compositeForSlimmingPaintV2(); |
619 | 636 |
620 void reset(); | 637 void reset(); |
621 void init(); | 638 void init(); |
622 | 639 |
623 void clearLayoutSubtreeRootsAndMarkContainingBlocks(); | 640 void clearLayoutSubtreeRootsAndMarkContainingBlocks(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 // LayoutObject for the viewport-defining element (see Document::viewportDef
iningElement). | 725 // LayoutObject for the viewport-defining element (see Document::viewportDef
iningElement). |
709 LayoutObject* viewportLayoutObject(); | 726 LayoutObject* viewportLayoutObject(); |
710 | 727 |
711 void collectAnnotatedRegions(LayoutObject&, Vector<AnnotatedRegionValue>&); | 728 void collectAnnotatedRegions(LayoutObject&, Vector<AnnotatedRegionValue>&); |
712 | 729 |
713 typedef WTF::HashMap <const GraphicsLayer*, Vector<std::pair<int64_t, WebRec
t>>> GraphicsLayerFrameTimingRequests; | 730 typedef WTF::HashMap <const GraphicsLayer*, Vector<std::pair<int64_t, WebRec
t>>> GraphicsLayerFrameTimingRequests; |
714 void updateFrameTimingRequestsIfNeeded(); | 731 void updateFrameTimingRequestsIfNeeded(); |
715 void collectFrameTimingRequests(GraphicsLayerFrameTimingRequests&); | 732 void collectFrameTimingRequests(GraphicsLayerFrameTimingRequests&); |
716 void collectFrameTimingRequestsRecursive(GraphicsLayerFrameTimingRequests&); | 733 void collectFrameTimingRequestsRecursive(GraphicsLayerFrameTimingRequests&); |
717 | 734 |
| 735 void updateViewportVisibilityIfNeeded(); |
| 736 void setLifecycleThrottlingModeForSubtree(DocumentLifecycle::ThrottlingMode)
; |
| 737 |
| 738 enum class SecurityOriginStatus { IsSameOrigin, IsCrossOrigin }; |
| 739 void updateThrottlingRecursive(SecurityOriginStatus); |
| 740 |
718 LayoutSize m_size; | 741 LayoutSize m_size; |
719 | 742 |
720 typedef HashSet<RefPtr<LayoutEmbeddedObject>> EmbeddedObjectSet; | 743 typedef HashSet<RefPtr<LayoutEmbeddedObject>> EmbeddedObjectSet; |
721 EmbeddedObjectSet m_partUpdateSet; | 744 EmbeddedObjectSet m_partUpdateSet; |
722 | 745 |
723 // FIXME: These are just "children" of the FrameView and should be RefPtrWil
lBeMember<Widget> instead. | 746 // FIXME: These are just "children" of the FrameView and should be RefPtrWil
lBeMember<Widget> instead. |
724 HashSet<RefPtr<LayoutPart>> m_parts; | 747 HashSet<RefPtr<LayoutPart>> m_parts; |
725 | 748 |
726 // The RefPtr cycle between LocalFrame and FrameView is broken | 749 // The RefPtr cycle between LocalFrame and FrameView is broken |
727 // when a LocalFrame is detached by LocalFrame::detach(). | 750 // when a LocalFrame is detached by LocalFrame::detach(). |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 IntSize m_layoutSize; | 812 IntSize m_layoutSize; |
790 bool m_layoutSizeFixedToFrameSize; | 813 bool m_layoutSizeFixedToFrameSize; |
791 | 814 |
792 Timer<FrameView> m_didScrollTimer; | 815 Timer<FrameView> m_didScrollTimer; |
793 | 816 |
794 Vector<IntRect> m_tickmarks; | 817 Vector<IntRect> m_tickmarks; |
795 | 818 |
796 float m_topControlsViewportAdjustment; | 819 float m_topControlsViewportAdjustment; |
797 | 820 |
798 bool m_needsUpdateWidgetPositions; | 821 bool m_needsUpdateWidgetPositions; |
| 822 bool m_needsUpdateViewportVisibility; |
799 | 823 |
800 #if ENABLE(ASSERT) | 824 #if ENABLE(ASSERT) |
801 // Verified when finalizing. | 825 // Verified when finalizing. |
802 bool m_hasBeenDisposed; | 826 bool m_hasBeenDisposed; |
803 #endif | 827 #endif |
804 | 828 |
805 RefPtrWillBeMember<Scrollbar> m_horizontalScrollbar; | 829 RefPtrWillBeMember<Scrollbar> m_horizontalScrollbar; |
806 RefPtrWillBeMember<Scrollbar> m_verticalScrollbar; | 830 RefPtrWillBeMember<Scrollbar> m_verticalScrollbar; |
807 ScrollbarMode m_horizontalScrollbarMode; | 831 ScrollbarMode m_horizontalScrollbarMode; |
808 ScrollbarMode m_verticalScrollbarMode; | 832 ScrollbarMode m_verticalScrollbarMode; |
(...skipping 17 matching lines...) Expand all Loading... |
826 OwnPtr<LayoutAnalyzer> m_analyzer; | 850 OwnPtr<LayoutAnalyzer> m_analyzer; |
827 | 851 |
828 // Mark if something has changed in the mapping from Frame to GraphicsLayer | 852 // Mark if something has changed in the mapping from Frame to GraphicsLayer |
829 // and the Frame Timing regions should be recalculated. | 853 // and the Frame Timing regions should be recalculated. |
830 bool m_frameTimingRequestsDirty; | 854 bool m_frameTimingRequestsDirty; |
831 | 855 |
832 // Exists only on root frame. | 856 // Exists only on root frame. |
833 // TODO(bokan): crbug.com/484188. We should specialize FrameView for the | 857 // TODO(bokan): crbug.com/484188. We should specialize FrameView for the |
834 // main frame. | 858 // main frame. |
835 OwnPtrWillBeMember<ScrollableArea> m_viewportScrollableArea; | 859 OwnPtrWillBeMember<ScrollableArea> m_viewportScrollableArea; |
| 860 |
| 861 // This frame's bounds in the root frame's content coordinates, clipped |
| 862 // recursively through every ancestor view. |
| 863 IntRect m_clippedBounds; |
| 864 |
| 865 enum class ViewportVisibility { Hidden, Visible }; |
| 866 |
| 867 // The following members control rendering pipeline throttling for this |
| 868 // frame. They are only updated at the end of the pipeline (after painting) |
| 869 // to avoid running further pipeline stages for a frame without having gone |
| 870 // through the previous ones. |
| 871 ViewportVisibility m_viewportVisibility; |
| 872 SecurityOriginStatus m_securityOriginStatusForThrottling; |
836 }; | 873 }; |
837 | 874 |
838 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) | 875 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) |
839 { | 876 { |
840 if (m_isVisuallyNonEmpty) | 877 if (m_isVisuallyNonEmpty) |
841 return; | 878 return; |
842 m_visuallyNonEmptyCharacterCount += count; | 879 m_visuallyNonEmptyCharacterCount += count; |
843 // Use a threshold value to prevent very small amounts of visible content fr
om triggering didFirstVisuallyNonEmptyLayout. | 880 // Use a threshold value to prevent very small amounts of visible content fr
om triggering didFirstVisuallyNonEmptyLayout. |
844 // The first few hundred characters rarely contain the interesting content o
f the page. | 881 // The first few hundred characters rarely contain the interesting content o
f the page. |
845 static const unsigned visualCharacterThreshold = 200; | 882 static const unsigned visualCharacterThreshold = 200; |
(...skipping 10 matching lines...) Expand all Loading... |
856 static const unsigned visualPixelThreshold = 32 * 32; | 893 static const unsigned visualPixelThreshold = 32 * 32; |
857 if (m_visuallyNonEmptyPixelCount > visualPixelThreshold) | 894 if (m_visuallyNonEmptyPixelCount > visualPixelThreshold) |
858 setIsVisuallyNonEmpty(); | 895 setIsVisuallyNonEmpty(); |
859 } | 896 } |
860 | 897 |
861 DEFINE_TYPE_CASTS(FrameView, Widget, widget, widget->isFrameView(), widget.isFra
meView()); | 898 DEFINE_TYPE_CASTS(FrameView, Widget, widget, widget->isFrameView(), widget.isFra
meView()); |
862 | 899 |
863 } // namespace blink | 900 } // namespace blink |
864 | 901 |
865 #endif // FrameView_h | 902 #endif // FrameView_h |
OLD | NEW |