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 will be 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 // LayoutObject for the viewport-defining element (see Document::viewportDef
iningElement). | 721 // LayoutObject for the viewport-defining element (see Document::viewportDef
iningElement). |
710 LayoutObject* viewportLayoutObject(); | 722 LayoutObject* viewportLayoutObject(); |
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 |
| 731 void setNeedsUpdateViewportIntersection(); |
| 732 void updateViewportIntersectionsForSubtree(); |
| 733 void updateViewportIntersectionIfNeeded(); |
| 734 void notifyIntersectionObservers(); |
| 735 |
719 LayoutSize m_size; | 736 LayoutSize m_size; |
720 | 737 |
721 typedef HashSet<RefPtr<LayoutEmbeddedObject>> EmbeddedObjectSet; | 738 typedef HashSet<RefPtr<LayoutEmbeddedObject>> EmbeddedObjectSet; |
722 EmbeddedObjectSet m_partUpdateSet; | 739 EmbeddedObjectSet m_partUpdateSet; |
723 | 740 |
724 // FIXME: These are just "children" of the FrameView and should be RefPtrWil
lBeMember<Widget> instead. | 741 // FIXME: These are just "children" of the FrameView and should be RefPtrWil
lBeMember<Widget> instead. |
725 HashSet<RefPtr<LayoutPart>> m_parts; | 742 HashSet<RefPtr<LayoutPart>> m_parts; |
726 | 743 |
727 // The RefPtr cycle between LocalFrame and FrameView is broken | 744 // The RefPtr cycle between LocalFrame and FrameView is broken |
728 // when a LocalFrame is detached by LocalFrame::detach(). | 745 // when a LocalFrame is detached by LocalFrame::detach(). |
(...skipping 14 matching lines...) Expand all Loading... |
743 bool m_hasPendingLayout; | 760 bool m_hasPendingLayout; |
744 LayoutSubtreeRootList m_layoutSubtreeRootList; | 761 LayoutSubtreeRootList m_layoutSubtreeRootList; |
745 | 762 |
746 bool m_layoutSchedulingEnabled; | 763 bool m_layoutSchedulingEnabled; |
747 bool m_inPerformLayout; | 764 bool m_inPerformLayout; |
748 bool m_inSynchronousPostLayout; | 765 bool m_inSynchronousPostLayout; |
749 int m_layoutCount; | 766 int m_layoutCount; |
750 unsigned m_nestedLayoutCount; | 767 unsigned m_nestedLayoutCount; |
751 Timer<FrameView> m_postLayoutTasksTimer; | 768 Timer<FrameView> m_postLayoutTasksTimer; |
752 Timer<FrameView> m_updateWidgetsTimer; | 769 Timer<FrameView> m_updateWidgetsTimer; |
| 770 OwnPtr<CancellableTaskFactory> m_intersectionObserverNotificationFactory; |
753 | 771 |
754 bool m_firstLayout; | 772 bool m_firstLayout; |
755 bool m_isTransparent; | 773 bool m_isTransparent; |
756 Color m_baseBackgroundColor; | 774 Color m_baseBackgroundColor; |
757 IntSize m_lastViewportSize; | 775 IntSize m_lastViewportSize; |
758 float m_lastZoomFactor; | 776 float m_lastZoomFactor; |
759 | 777 |
760 AtomicString m_mediaType; | 778 AtomicString m_mediaType; |
761 AtomicString m_mediaTypeWhenNotPrinting; | 779 AtomicString m_mediaTypeWhenNotPrinting; |
762 | 780 |
(...skipping 27 matching lines...) Expand all Loading... |
790 IntSize m_layoutSize; | 808 IntSize m_layoutSize; |
791 bool m_layoutSizeFixedToFrameSize; | 809 bool m_layoutSizeFixedToFrameSize; |
792 | 810 |
793 Timer<FrameView> m_didScrollTimer; | 811 Timer<FrameView> m_didScrollTimer; |
794 | 812 |
795 Vector<IntRect> m_tickmarks; | 813 Vector<IntRect> m_tickmarks; |
796 | 814 |
797 float m_topControlsViewportAdjustment; | 815 float m_topControlsViewportAdjustment; |
798 | 816 |
799 bool m_needsUpdateWidgetPositions; | 817 bool m_needsUpdateWidgetPositions; |
| 818 bool m_needsUpdateViewportIntersection; |
| 819 bool m_needsUpdateViewportIntersectionInSubtree; |
800 | 820 |
801 #if ENABLE(ASSERT) | 821 #if ENABLE(ASSERT) |
802 // Verified when finalizing. | 822 // Verified when finalizing. |
803 bool m_hasBeenDisposed; | 823 bool m_hasBeenDisposed; |
804 #endif | 824 #endif |
805 | 825 |
806 RefPtrWillBeMember<Scrollbar> m_horizontalScrollbar; | 826 RefPtrWillBeMember<Scrollbar> m_horizontalScrollbar; |
807 RefPtrWillBeMember<Scrollbar> m_verticalScrollbar; | 827 RefPtrWillBeMember<Scrollbar> m_verticalScrollbar; |
808 ScrollbarMode m_horizontalScrollbarMode; | 828 ScrollbarMode m_horizontalScrollbarMode; |
809 ScrollbarMode m_verticalScrollbarMode; | 829 ScrollbarMode m_verticalScrollbarMode; |
(...skipping 15 matching lines...) Expand all Loading... |
825 OwnPtr<LayoutAnalyzer> m_analyzer; | 845 OwnPtr<LayoutAnalyzer> m_analyzer; |
826 | 846 |
827 // Mark if something has changed in the mapping from Frame to GraphicsLayer | 847 // Mark if something has changed in the mapping from Frame to GraphicsLayer |
828 // and the Frame Timing regions should be recalculated. | 848 // and the Frame Timing regions should be recalculated. |
829 bool m_frameTimingRequestsDirty; | 849 bool m_frameTimingRequestsDirty; |
830 | 850 |
831 // Exists only on root frame. | 851 // Exists only on root frame. |
832 // TODO(bokan): crbug.com/484188. We should specialize FrameView for the | 852 // TODO(bokan): crbug.com/484188. We should specialize FrameView for the |
833 // main frame. | 853 // main frame. |
834 OwnPtrWillBeMember<ScrollableArea> m_viewportScrollableArea; | 854 OwnPtrWillBeMember<ScrollableArea> m_viewportScrollableArea; |
| 855 |
| 856 // This frame's bounds in the root frame's content coordinates, clipped |
| 857 // recursively through every ancestor view. |
| 858 IntRect m_viewportIntersection; |
| 859 bool m_viewportIntersectionValid; |
| 860 |
| 861 // The following members control rendering pipeline throttling for this |
| 862 // frame. They are only updated in response to intersection observer |
| 863 // notifications, i.e., not in the middle of the lifecycle. |
| 864 bool m_hiddenForThrottling; |
| 865 bool m_crossOriginForThrottling; |
835 }; | 866 }; |
836 | 867 |
837 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) | 868 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) |
838 { | 869 { |
839 if (m_isVisuallyNonEmpty) | 870 if (m_isVisuallyNonEmpty) |
840 return; | 871 return; |
841 m_visuallyNonEmptyCharacterCount += count; | 872 m_visuallyNonEmptyCharacterCount += count; |
842 // Use a threshold value to prevent very small amounts of visible content fr
om triggering didMeaningfulLayout. | 873 // Use a threshold value to prevent very small amounts of visible content fr
om triggering didMeaningfulLayout. |
843 // The first few hundred characters rarely contain the interesting content o
f the page. | 874 // The first few hundred characters rarely contain the interesting content o
f the page. |
844 static const unsigned visualCharacterThreshold = 200; | 875 static const unsigned visualCharacterThreshold = 200; |
(...skipping 10 matching lines...) Expand all Loading... |
855 static const unsigned visualPixelThreshold = 32 * 32; | 886 static const unsigned visualPixelThreshold = 32 * 32; |
856 if (m_visuallyNonEmptyPixelCount > visualPixelThreshold) | 887 if (m_visuallyNonEmptyPixelCount > visualPixelThreshold) |
857 setIsVisuallyNonEmpty(); | 888 setIsVisuallyNonEmpty(); |
858 } | 889 } |
859 | 890 |
860 DEFINE_TYPE_CASTS(FrameView, Widget, widget, widget->isFrameView(), widget.isFra
meView()); | 891 DEFINE_TYPE_CASTS(FrameView, Widget, widget, widget->isFrameView(), widget.isFra
meView()); |
861 | 892 |
862 } // namespace blink | 893 } // namespace blink |
863 | 894 |
864 #endif // FrameView_h | 895 #endif // FrameView_h |
OLD | NEW |