| 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 FrameViewTest; |
| 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 // Returns true if the default scrolling direction is vertical. i.e. writing
mode | 557 // Returns true if the default scrolling direction is vertical. i.e. writing
mode |
| 554 // is horiziontal. In a vertical document, a spacebar scrolls down. | 558 // is horiziontal. In a vertical document, a spacebar scrolls down. |
| 555 bool isVerticalDocument() const; | 559 bool isVerticalDocument() const; |
| 556 | 560 |
| 557 // Returns true if the document's writing mode is right-to-left or bottom-to
-top. | 561 // Returns true if the document's writing mode is right-to-left or bottom-to
-top. |
| 558 bool isFlippedDocument() const; | 562 bool isFlippedDocument() const; |
| 559 | 563 |
| 560 void setFrameTimingRequestsDirty(bool isDirty) { m_frameTimingRequestsDirty
= isDirty; } | 564 void setFrameTimingRequestsDirty(bool isDirty) { m_frameTimingRequestsDirty
= isDirty; } |
| 561 bool frameTimingRequestsDirty() { return m_frameTimingRequestsDirty; } | 565 bool frameTimingRequestsDirty() { return m_frameTimingRequestsDirty; } |
| 562 | 566 |
| 567 // Returns true if this frame should skip rendering pipeline processing duri
ng the |
| 568 // current BeginMainFrame. |
| 569 bool shouldThrottleRenderingPipeline() const; |
| 570 |
| 571 // Returns true if this frame should skip style computation, layout and |
| 572 // compositing updates for the current BeginMainFrame. |
| 573 bool shouldThrottleStyleLayoutAndCompositingUpdates() const; |
| 574 |
| 575 // Updates the throttling status of all frames in the hierarchy and |
| 576 // schedules new animations or lifecycle updates as necessary. Must be |
| 577 // called after the layer update phase of the current BeginMainFrame. |
| 578 void updateThrottling(); |
| 579 |
| 563 protected: | 580 protected: |
| 564 // Scroll the content via the compositor. | 581 // Scroll the content via the compositor. |
| 565 bool scrollContentsFastPath(const IntSize& scrollDelta); | 582 bool scrollContentsFastPath(const IntSize& scrollDelta); |
| 566 | 583 |
| 567 // Scroll the content by invalidating everything. | 584 // Scroll the content by invalidating everything. |
| 568 void scrollContentsSlowPath(const IntRect& updateRect); | 585 void scrollContentsSlowPath(const IntRect& updateRect); |
| 569 | 586 |
| 570 // These functions are used to create/destroy scrollbars. | 587 // These functions are used to create/destroy scrollbars. |
| 571 void setHasHorizontalScrollbar(bool); | 588 void setHasHorizontalScrollbar(bool); |
| 572 void setHasVerticalScrollbar(bool); | 589 void setHasVerticalScrollbar(bool); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 explicit FrameView(LocalFrame*); | 623 explicit FrameView(LocalFrame*); |
| 607 | 624 |
| 608 void setScrollOffset(const IntPoint&, ScrollType) override; | 625 void setScrollOffset(const IntPoint&, ScrollType) override; |
| 609 void setScrollOffset(const DoublePoint&, ScrollType) override; | 626 void setScrollOffset(const DoublePoint&, ScrollType) override; |
| 610 | 627 |
| 611 enum LifeCycleUpdateOption { | 628 enum LifeCycleUpdateOption { |
| 612 AllPhases, | 629 AllPhases, |
| 613 OnlyUpToCompositingCleanPlusScrolling, | 630 OnlyUpToCompositingCleanPlusScrolling, |
| 614 }; | 631 }; |
| 615 | 632 |
| 616 void updateLifecyclePhasesInternal(LifeCycleUpdateOption, const LayoutRect&
interestRect = LayoutRect::infiniteRect()); | 633 void updateLifecyclePhasesInternal(LifeCycleUpdateOption, DocumentLifecycle:
:ThrottlingMode, const LayoutRect& interestRect = LayoutRect::infiniteRect()); |
| 617 void invalidateTreeIfNeededRecursive(); | 634 void invalidateTreeIfNeededRecursive(); |
| 618 void scrollContentsIfNeededRecursive(); | 635 void scrollContentsIfNeededRecursive(); |
| 619 void updateStyleAndLayoutIfNeededRecursive(); | 636 void updateStyleAndLayoutIfNeededRecursive(); |
| 620 void paintForSlimmingPaintV2(const LayoutRect& interestRect); | 637 void paintForSlimmingPaintV2(const LayoutRect& interestRect); |
| 621 void compositeForSlimmingPaintV2(); | 638 void compositeForSlimmingPaintV2(); |
| 622 | 639 |
| 623 void reset(); | 640 void reset(); |
| 624 void init(); | 641 void init(); |
| 625 | 642 |
| 626 void clearLayoutSubtreeRootsAndMarkContainingBlocks(); | 643 void clearLayoutSubtreeRootsAndMarkContainingBlocks(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 // LayoutObject for the viewport-defining element (see Document::viewportDef
iningElement). | 728 // LayoutObject for the viewport-defining element (see Document::viewportDef
iningElement). |
| 712 LayoutObject* viewportLayoutObject(); | 729 LayoutObject* viewportLayoutObject(); |
| 713 | 730 |
| 714 void collectAnnotatedRegions(LayoutObject&, Vector<AnnotatedRegionValue>&); | 731 void collectAnnotatedRegions(LayoutObject&, Vector<AnnotatedRegionValue>&); |
| 715 | 732 |
| 716 typedef WTF::HashMap <const GraphicsLayer*, Vector<std::pair<int64_t, WebRec
t>>> GraphicsLayerFrameTimingRequests; | 733 typedef WTF::HashMap <const GraphicsLayer*, Vector<std::pair<int64_t, WebRec
t>>> GraphicsLayerFrameTimingRequests; |
| 717 void updateFrameTimingRequestsIfNeeded(); | 734 void updateFrameTimingRequestsIfNeeded(); |
| 718 void collectFrameTimingRequests(GraphicsLayerFrameTimingRequests&); | 735 void collectFrameTimingRequests(GraphicsLayerFrameTimingRequests&); |
| 719 void collectFrameTimingRequestsRecursive(GraphicsLayerFrameTimingRequests&); | 736 void collectFrameTimingRequestsRecursive(GraphicsLayerFrameTimingRequests&); |
| 720 | 737 |
| 738 void updateViewportVisibilityIfNeeded(); |
| 739 void setLifecycleThrottlingModeForSubtree(DocumentLifecycle::ThrottlingMode)
; |
| 740 |
| 741 enum class SecurityOriginStatus { IsSameOrigin, IsCrossOrigin }; |
| 742 void updateThrottlingRecursive(SecurityOriginStatus); |
| 743 |
| 721 LayoutSize m_size; | 744 LayoutSize m_size; |
| 722 | 745 |
| 723 typedef HashSet<RefPtr<LayoutEmbeddedObject>> EmbeddedObjectSet; | 746 typedef HashSet<RefPtr<LayoutEmbeddedObject>> EmbeddedObjectSet; |
| 724 EmbeddedObjectSet m_partUpdateSet; | 747 EmbeddedObjectSet m_partUpdateSet; |
| 725 | 748 |
| 726 // FIXME: These are just "children" of the FrameView and should be RefPtrWil
lBeMember<Widget> instead. | 749 // FIXME: These are just "children" of the FrameView and should be RefPtrWil
lBeMember<Widget> instead. |
| 727 HashSet<RefPtr<LayoutPart>> m_parts; | 750 HashSet<RefPtr<LayoutPart>> m_parts; |
| 728 | 751 |
| 729 // The RefPtr cycle between LocalFrame and FrameView is broken | 752 // The RefPtr cycle between LocalFrame and FrameView is broken |
| 730 // when a LocalFrame is detached by LocalFrame::detach(). | 753 // when a LocalFrame is detached by LocalFrame::detach(). |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 IntSize m_layoutSize; | 815 IntSize m_layoutSize; |
| 793 bool m_layoutSizeFixedToFrameSize; | 816 bool m_layoutSizeFixedToFrameSize; |
| 794 | 817 |
| 795 Timer<FrameView> m_didScrollTimer; | 818 Timer<FrameView> m_didScrollTimer; |
| 796 | 819 |
| 797 Vector<IntRect> m_tickmarks; | 820 Vector<IntRect> m_tickmarks; |
| 798 | 821 |
| 799 float m_topControlsViewportAdjustment; | 822 float m_topControlsViewportAdjustment; |
| 800 | 823 |
| 801 bool m_needsUpdateWidgetPositions; | 824 bool m_needsUpdateWidgetPositions; |
| 825 bool m_needsUpdateViewportVisibility; |
| 802 | 826 |
| 803 #if ENABLE(ASSERT) | 827 #if ENABLE(ASSERT) |
| 804 // Verified when finalizing. | 828 // Verified when finalizing. |
| 805 bool m_hasBeenDisposed; | 829 bool m_hasBeenDisposed; |
| 806 #endif | 830 #endif |
| 807 | 831 |
| 808 RefPtrWillBeMember<Scrollbar> m_horizontalScrollbar; | 832 RefPtrWillBeMember<Scrollbar> m_horizontalScrollbar; |
| 809 RefPtrWillBeMember<Scrollbar> m_verticalScrollbar; | 833 RefPtrWillBeMember<Scrollbar> m_verticalScrollbar; |
| 810 ScrollbarMode m_horizontalScrollbarMode; | 834 ScrollbarMode m_horizontalScrollbarMode; |
| 811 ScrollbarMode m_verticalScrollbarMode; | 835 ScrollbarMode m_verticalScrollbarMode; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 830 OwnPtr<LayoutAnalyzer> m_analyzer; | 854 OwnPtr<LayoutAnalyzer> m_analyzer; |
| 831 | 855 |
| 832 // Mark if something has changed in the mapping from Frame to GraphicsLayer | 856 // Mark if something has changed in the mapping from Frame to GraphicsLayer |
| 833 // and the Frame Timing regions should be recalculated. | 857 // and the Frame Timing regions should be recalculated. |
| 834 bool m_frameTimingRequestsDirty; | 858 bool m_frameTimingRequestsDirty; |
| 835 | 859 |
| 836 // Exists only on root frame. | 860 // Exists only on root frame. |
| 837 // TODO(bokan): crbug.com/484188. We should specialize FrameView for the | 861 // TODO(bokan): crbug.com/484188. We should specialize FrameView for the |
| 838 // main frame. | 862 // main frame. |
| 839 OwnPtrWillBeMember<ScrollableArea> m_viewportScrollableArea; | 863 OwnPtrWillBeMember<ScrollableArea> m_viewportScrollableArea; |
| 864 |
| 865 // This frame's bounds in the root frame's content coordinates, clipped |
| 866 // recursively through every ancestor view. |
| 867 IntRect m_clippedBounds; |
| 868 |
| 869 enum class ViewportVisibility { Hidden, Visible }; |
| 870 |
| 871 // The following members control rendering pipeline throttling for this |
| 872 // frame. They are only updated at the end of the pipeline (after painting) |
| 873 // to avoid running further pipeline stages for a frame without having gone |
| 874 // through the previous ones. |
| 875 ViewportVisibility m_viewportVisibility; |
| 876 SecurityOriginStatus m_securityOriginStatusForThrottling; |
| 840 }; | 877 }; |
| 841 | 878 |
| 842 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) | 879 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) |
| 843 { | 880 { |
| 844 if (m_isVisuallyNonEmpty) | 881 if (m_isVisuallyNonEmpty) |
| 845 return; | 882 return; |
| 846 m_visuallyNonEmptyCharacterCount += count; | 883 m_visuallyNonEmptyCharacterCount += count; |
| 847 // Use a threshold value to prevent very small amounts of visible content fr
om triggering didFirstVisuallyNonEmptyLayout. | 884 // Use a threshold value to prevent very small amounts of visible content fr
om triggering didFirstVisuallyNonEmptyLayout. |
| 848 // The first few hundred characters rarely contain the interesting content o
f the page. | 885 // The first few hundred characters rarely contain the interesting content o
f the page. |
| 849 static const unsigned visualCharacterThreshold = 200; | 886 static const unsigned visualCharacterThreshold = 200; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 860 static const unsigned visualPixelThreshold = 32 * 32; | 897 static const unsigned visualPixelThreshold = 32 * 32; |
| 861 if (m_visuallyNonEmptyPixelCount > visualPixelThreshold) | 898 if (m_visuallyNonEmptyPixelCount > visualPixelThreshold) |
| 862 setIsVisuallyNonEmpty(); | 899 setIsVisuallyNonEmpty(); |
| 863 } | 900 } |
| 864 | 901 |
| 865 DEFINE_TYPE_CASTS(FrameView, Widget, widget, widget->isFrameView(), widget.isFra
meView()); | 902 DEFINE_TYPE_CASTS(FrameView, Widget, widget, widget->isFrameView(), widget.isFra
meView()); |
| 866 | 903 |
| 867 } // namespace blink | 904 } // namespace blink |
| 868 | 905 |
| 869 #endif // FrameView_h | 906 #endif // FrameView_h |
| OLD | NEW |