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" |
39 #include "platform/scroll/ScrollTypes.h" | 40 #include "platform/scroll/ScrollTypes.h" |
40 #include "platform/scroll/ScrollableArea.h" | 41 #include "platform/scroll/ScrollableArea.h" |
41 #include "platform/scroll/Scrollbar.h" | 42 #include "platform/scroll/Scrollbar.h" |
42 #include "public/platform/WebDisplayMode.h" | 43 #include "public/platform/WebDisplayMode.h" |
43 #include "public/platform/WebRect.h" | 44 #include "public/platform/WebRect.h" |
44 #include "wtf/Allocator.h" | 45 #include "wtf/Allocator.h" |
45 #include "wtf/Forward.h" | 46 #include "wtf/Forward.h" |
46 #include "wtf/HashSet.h" | 47 #include "wtf/HashSet.h" |
47 #include "wtf/ListHashSet.h" | 48 #include "wtf/ListHashSet.h" |
48 #include "wtf/OwnPtr.h" | 49 #include "wtf/OwnPtr.h" |
49 #include "wtf/TemporaryChange.h" | 50 #include "wtf/TemporaryChange.h" |
50 #include "wtf/text/WTFString.h" | 51 #include "wtf/text/WTFString.h" |
51 | 52 |
52 namespace blink { | 53 namespace blink { |
53 | 54 |
54 class AXObjectCache; | 55 class AXObjectCache; |
| 56 class CancellableTaskFactory; |
55 class ComputedStyle; | 57 class ComputedStyle; |
56 class DocumentLifecycle; | 58 class DocumentLifecycle; |
57 class Cursor; | 59 class Cursor; |
58 class Element; | 60 class Element; |
59 class FloatSize; | 61 class FloatSize; |
60 class HTMLFrameOwnerElement; | 62 class HTMLFrameOwnerElement; |
61 class LayoutPart; | 63 class LayoutPart; |
62 class LocalFrame; | 64 class LocalFrame; |
63 class KURL; | 65 class KURL; |
64 class Node; | 66 class Node; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 220 |
219 void setIsPainting(bool val) const { m_isPainting = val; } | 221 void setIsPainting(bool val) const { m_isPainting = val; } |
220 bool isPainting() const; | 222 bool isPainting() const; |
221 | 223 |
222 void setNodeToDraw(Node*); | 224 void setNodeToDraw(Node*); |
223 Node* nodeToDraw() const { return m_nodeToDraw.get(); } | 225 Node* nodeToDraw() const { return m_nodeToDraw.get(); } |
224 | 226 |
225 Color documentBackgroundColor() const; | 227 Color documentBackgroundColor() const; |
226 | 228 |
227 // Run all needed lifecycle stages. After calling this method, all frames wi
ll be in the lifecycle state PaintInvalidationClean. | 229 // Run all needed lifecycle stages. After calling this method, all frames wi
ll be in the lifecycle state PaintInvalidationClean. |
| 230 // If lifecycle throttling is allowed (see DocumentLifecycle::PreventThrottl
ingScope), some frames may skip the lifecycle update |
| 231 // (e.g., based on visibility) and will not end up being PaintInvalidationCl
ean. |
228 // TODO(pdr): Update callers to pass in the interest rect. | 232 // TODO(pdr): Update callers to pass in the interest rect. |
229 void updateAllLifecyclePhases(const LayoutRect* interestRect = nullptr); | 233 void updateAllLifecyclePhases(const LayoutRect* interestRect = nullptr); |
230 | 234 |
231 // Computes the style, layout and compositing lifecycle stages if needed. Af
ter calling this method, all frames wil lbe in a lifecycle | 235 // Computes the style, layout and compositing lifecycle stages if needed. Af
ter calling this method, all frames wil lbe in a lifecycle |
232 // state >= CompositingClean, and scrolling has been updated. | 236 // state >= CompositingClean, and scrolling has been updated (unless throttl
ing is allowed). |
233 void updateLifecycleToCompositingCleanPlusScrolling(); | 237 void updateLifecycleToCompositingCleanPlusScrolling(); |
234 | 238 |
235 // Computes only the style and layout lifecycle stages. | 239 // Computes only the style and layout lifecycle stages. |
236 // After calling this method, all frames will be in a lifecycle state >= Lay
outClean. | 240 // After calling this method, all frames will be in a lifecycle state >= Lay
outClean (unless throttling is allowed). |
237 void updateLifecycleToLayoutClean(); | 241 void updateLifecycleToLayoutClean(); |
238 | 242 |
239 bool invalidateViewportConstrainedObjects(); | 243 bool invalidateViewportConstrainedObjects(); |
240 | 244 |
241 void incrementVisuallyNonEmptyCharacterCount(unsigned); | 245 void incrementVisuallyNonEmptyCharacterCount(unsigned); |
242 void incrementVisuallyNonEmptyPixelCount(const IntSize&); | 246 void incrementVisuallyNonEmptyPixelCount(const IntSize&); |
243 bool isVisuallyNonEmpty() const { return m_isVisuallyNonEmpty; } | 247 bool isVisuallyNonEmpty() const { return m_isVisuallyNonEmpty; } |
244 void setIsVisuallyNonEmpty() { m_isVisuallyNonEmpty = true; } | 248 void setIsVisuallyNonEmpty() { m_isVisuallyNonEmpty = true; } |
245 void enableAutoSizeMode(const IntSize& minSize, const IntSize& maxSize); | 249 void enableAutoSizeMode(const IntSize& minSize, const IntSize& maxSize); |
246 void disableAutoSizeMode(); | 250 void disableAutoSizeMode(); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 // Returns true if the default scrolling direction is vertical. i.e. writing
mode | 553 // Returns true if the default scrolling direction is vertical. i.e. writing
mode |
550 // is horiziontal. In a vertical document, a spacebar scrolls down. | 554 // is horiziontal. In a vertical document, a spacebar scrolls down. |
551 bool isVerticalDocument() const; | 555 bool isVerticalDocument() const; |
552 | 556 |
553 // Returns true if the document's writing mode is right-to-left or bottom-to
-top. | 557 // Returns true if the document's writing mode is right-to-left or bottom-to
-top. |
554 bool isFlippedDocument() const; | 558 bool isFlippedDocument() const; |
555 | 559 |
556 void setFrameTimingRequestsDirty(bool isDirty) { m_frameTimingRequestsDirty
= isDirty; } | 560 void setFrameTimingRequestsDirty(bool isDirty) { m_frameTimingRequestsDirty
= isDirty; } |
557 bool frameTimingRequestsDirty() { return m_frameTimingRequestsDirty; } | 561 bool frameTimingRequestsDirty() { return m_frameTimingRequestsDirty; } |
558 | 562 |
| 563 // Returns true if this frame should not render or schedule visual updates. |
| 564 bool shouldThrottleRendering() const; |
| 565 |
| 566 // Returns true if this frame could potentially skip rendering and avoid |
| 567 // scheduling visual updates. |
| 568 bool canThrottleRendering() const; |
| 569 bool isHiddenForThrottling() const { return m_hiddenForThrottling; } |
| 570 |
559 protected: | 571 protected: |
560 // Scroll the content via the compositor. | 572 // Scroll the content via the compositor. |
561 bool scrollContentsFastPath(const IntSize& scrollDelta); | 573 bool scrollContentsFastPath(const IntSize& scrollDelta); |
562 | 574 |
563 // Scroll the content by invalidating everything. | 575 // Scroll the content by invalidating everything. |
564 void scrollContentsSlowPath(const IntRect& updateRect); | 576 void scrollContentsSlowPath(const IntRect& updateRect); |
565 | 577 |
566 // These functions are used to create/destroy scrollbars. | 578 // These functions are used to create/destroy scrollbars. |
567 void setHasHorizontalScrollbar(bool); | 579 void setHasHorizontalScrollbar(bool); |
568 void setHasVerticalScrollbar(bool); | 580 void setHasVerticalScrollbar(bool); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 | 723 |
712 void collectAnnotatedRegions(LayoutObject&, Vector<AnnotatedRegionValue>&) c
onst; | 724 void collectAnnotatedRegions(LayoutObject&, Vector<AnnotatedRegionValue>&) c
onst; |
713 | 725 |
714 typedef WTF::HashMap <const GraphicsLayer*, Vector<std::pair<int64_t, WebRec
t>>> GraphicsLayerFrameTimingRequests; | 726 typedef WTF::HashMap <const GraphicsLayer*, Vector<std::pair<int64_t, WebRec
t>>> GraphicsLayerFrameTimingRequests; |
715 void updateFrameTimingRequestsIfNeeded(); | 727 void updateFrameTimingRequestsIfNeeded(); |
716 void collectFrameTimingRequests(GraphicsLayerFrameTimingRequests&); | 728 void collectFrameTimingRequests(GraphicsLayerFrameTimingRequests&); |
717 void collectFrameTimingRequestsRecursive(GraphicsLayerFrameTimingRequests&); | 729 void collectFrameTimingRequestsRecursive(GraphicsLayerFrameTimingRequests&); |
718 | 730 |
719 template <typename Function> void forAllFrameViews(Function); | 731 template <typename Function> void forAllFrameViews(Function); |
720 | 732 |
| 733 void setNeedsUpdateViewportIntersection(); |
| 734 void updateViewportIntersectionsForSubtree(); |
| 735 void updateViewportIntersectionIfNeeded(); |
| 736 void notifyIntersectionObservers(); |
| 737 |
721 LayoutSize m_size; | 738 LayoutSize m_size; |
722 | 739 |
723 typedef HashSet<RefPtr<LayoutEmbeddedObject>> EmbeddedObjectSet; | 740 typedef HashSet<RefPtr<LayoutEmbeddedObject>> EmbeddedObjectSet; |
724 EmbeddedObjectSet m_partUpdateSet; | 741 EmbeddedObjectSet m_partUpdateSet; |
725 | 742 |
726 // FIXME: These are just "children" of the FrameView and should be RefPtrWil
lBeMember<Widget> instead. | 743 // FIXME: These are just "children" of the FrameView and should be RefPtrWil
lBeMember<Widget> instead. |
727 HashSet<RefPtr<LayoutPart>> m_parts; | 744 HashSet<RefPtr<LayoutPart>> m_parts; |
728 | 745 |
729 // The RefPtr cycle between LocalFrame and FrameView is broken | 746 // The RefPtr cycle between LocalFrame and FrameView is broken |
730 // when a LocalFrame is detached by LocalFrame::detach(). | 747 // when a LocalFrame is detached by LocalFrame::detach(). |
(...skipping 14 matching lines...) Expand all Loading... |
745 bool m_hasPendingLayout; | 762 bool m_hasPendingLayout; |
746 LayoutSubtreeRootList m_layoutSubtreeRootList; | 763 LayoutSubtreeRootList m_layoutSubtreeRootList; |
747 | 764 |
748 bool m_layoutSchedulingEnabled; | 765 bool m_layoutSchedulingEnabled; |
749 bool m_inPerformLayout; | 766 bool m_inPerformLayout; |
750 bool m_inSynchronousPostLayout; | 767 bool m_inSynchronousPostLayout; |
751 int m_layoutCount; | 768 int m_layoutCount; |
752 unsigned m_nestedLayoutCount; | 769 unsigned m_nestedLayoutCount; |
753 Timer<FrameView> m_postLayoutTasksTimer; | 770 Timer<FrameView> m_postLayoutTasksTimer; |
754 Timer<FrameView> m_updateWidgetsTimer; | 771 Timer<FrameView> m_updateWidgetsTimer; |
| 772 OwnPtr<CancellableTaskFactory> m_intersectionObserverNotificationFactory; |
755 | 773 |
756 bool m_firstLayout; | 774 bool m_firstLayout; |
757 bool m_isTransparent; | 775 bool m_isTransparent; |
758 Color m_baseBackgroundColor; | 776 Color m_baseBackgroundColor; |
759 IntSize m_lastViewportSize; | 777 IntSize m_lastViewportSize; |
760 float m_lastZoomFactor; | 778 float m_lastZoomFactor; |
761 | 779 |
762 AtomicString m_mediaType; | 780 AtomicString m_mediaType; |
763 AtomicString m_mediaTypeWhenNotPrinting; | 781 AtomicString m_mediaTypeWhenNotPrinting; |
764 | 782 |
(...skipping 27 matching lines...) Expand all Loading... |
792 IntSize m_layoutSize; | 810 IntSize m_layoutSize; |
793 bool m_layoutSizeFixedToFrameSize; | 811 bool m_layoutSizeFixedToFrameSize; |
794 | 812 |
795 Timer<FrameView> m_didScrollTimer; | 813 Timer<FrameView> m_didScrollTimer; |
796 | 814 |
797 Vector<IntRect> m_tickmarks; | 815 Vector<IntRect> m_tickmarks; |
798 | 816 |
799 float m_topControlsViewportAdjustment; | 817 float m_topControlsViewportAdjustment; |
800 | 818 |
801 bool m_needsUpdateWidgetPositions; | 819 bool m_needsUpdateWidgetPositions; |
| 820 bool m_needsUpdateViewportIntersection; |
| 821 bool m_needsUpdateViewportIntersectionInSubtree; |
802 | 822 |
803 #if ENABLE(ASSERT) | 823 #if ENABLE(ASSERT) |
804 // Verified when finalizing. | 824 // Verified when finalizing. |
805 bool m_hasBeenDisposed; | 825 bool m_hasBeenDisposed; |
806 #endif | 826 #endif |
807 | 827 |
808 RefPtrWillBeMember<Scrollbar> m_horizontalScrollbar; | 828 RefPtrWillBeMember<Scrollbar> m_horizontalScrollbar; |
809 RefPtrWillBeMember<Scrollbar> m_verticalScrollbar; | 829 RefPtrWillBeMember<Scrollbar> m_verticalScrollbar; |
810 ScrollbarMode m_horizontalScrollbarMode; | 830 ScrollbarMode m_horizontalScrollbarMode; |
811 ScrollbarMode m_verticalScrollbarMode; | 831 ScrollbarMode m_verticalScrollbarMode; |
(...skipping 15 matching lines...) Expand all Loading... |
827 OwnPtr<LayoutAnalyzer> m_analyzer; | 847 OwnPtr<LayoutAnalyzer> m_analyzer; |
828 | 848 |
829 // Mark if something has changed in the mapping from Frame to GraphicsLayer | 849 // Mark if something has changed in the mapping from Frame to GraphicsLayer |
830 // and the Frame Timing regions should be recalculated. | 850 // and the Frame Timing regions should be recalculated. |
831 bool m_frameTimingRequestsDirty; | 851 bool m_frameTimingRequestsDirty; |
832 | 852 |
833 // Exists only on root frame. | 853 // Exists only on root frame. |
834 // TODO(bokan): crbug.com/484188. We should specialize FrameView for the | 854 // TODO(bokan): crbug.com/484188. We should specialize FrameView for the |
835 // main frame. | 855 // main frame. |
836 OwnPtrWillBeMember<ScrollableArea> m_viewportScrollableArea; | 856 OwnPtrWillBeMember<ScrollableArea> m_viewportScrollableArea; |
| 857 |
| 858 // This frame's bounds in the root frame's content coordinates, clipped |
| 859 // recursively through every ancestor view. |
| 860 IntRect m_viewportIntersection; |
| 861 bool m_viewportIntersectionValid; |
| 862 |
| 863 // The following members control rendering pipeline throttling for this |
| 864 // frame. They are only updated in response to intersection observer |
| 865 // notifications, i.e., not in the middle of the lifecycle. |
| 866 bool m_hiddenForThrottling; |
| 867 bool m_crossOriginForThrottling; |
837 }; | 868 }; |
838 | 869 |
839 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) | 870 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) |
840 { | 871 { |
841 if (m_isVisuallyNonEmpty) | 872 if (m_isVisuallyNonEmpty) |
842 return; | 873 return; |
843 m_visuallyNonEmptyCharacterCount += count; | 874 m_visuallyNonEmptyCharacterCount += count; |
844 // Use a threshold value to prevent very small amounts of visible content fr
om triggering didMeaningfulLayout. | 875 // Use a threshold value to prevent very small amounts of visible content fr
om triggering didMeaningfulLayout. |
845 // The first few hundred characters rarely contain the interesting content o
f the page. | 876 // The first few hundred characters rarely contain the interesting content o
f the page. |
846 static const unsigned visualCharacterThreshold = 200; | 877 static const unsigned visualCharacterThreshold = 200; |
(...skipping 10 matching lines...) Expand all Loading... |
857 static const unsigned visualPixelThreshold = 32 * 32; | 888 static const unsigned visualPixelThreshold = 32 * 32; |
858 if (m_visuallyNonEmptyPixelCount > visualPixelThreshold) | 889 if (m_visuallyNonEmptyPixelCount > visualPixelThreshold) |
859 setIsVisuallyNonEmpty(); | 890 setIsVisuallyNonEmpty(); |
860 } | 891 } |
861 | 892 |
862 DEFINE_TYPE_CASTS(FrameView, Widget, widget, widget->isFrameView(), widget.isFra
meView()); | 893 DEFINE_TYPE_CASTS(FrameView, Widget, widget, widget->isFrameView(), widget.isFra
meView()); |
863 | 894 |
864 } // namespace blink | 895 } // namespace blink |
865 | 896 |
866 #endif // FrameView_h | 897 #endif // FrameView_h |
OLD | NEW |