Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: Source/core/frame/FrameView.h

Issue 1246173002: Throttle rendering pipeline for invisible iframes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Clean up logic. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/frame/FrameView.cpp » ('j') | Source/core/frame/FrameView.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 void setIsPainting(bool val) { m_isPainting = val; } 219 void setIsPainting(bool val) { m_isPainting = val; }
220 bool isPainting() const; 220 bool isPainting() const;
221 void setLastPaintTime(double val) { m_lastPaintTime = val; } 221 void setLastPaintTime(double val) { m_lastPaintTime = val; }
222 bool hasEverPainted() const { return m_lastPaintTime; } 222 bool hasEverPainted() const { return m_lastPaintTime; }
223 void setNodeToDraw(Node*); 223 void setNodeToDraw(Node*);
224 Node* nodeToDraw() { return m_nodeToDraw.get(); } 224 Node* nodeToDraw() { return m_nodeToDraw.get(); }
225 225
226 Color documentBackgroundColor() const; 226 Color documentBackgroundColor() const;
227 227
228 // Run all needed lifecycle stages. After calling this method, all frames wi ll be in the lifecycle state PaintInvalidationClean. 228 // Run all needed lifecycle stages. After calling this method, all frames wi ll be in the lifecycle state PaintInvalidationClean.
229 void updateAllLifecyclePhases(); 229 // If lifecycle throttling is allowed, some frames may skip the lifecycle up date (e.g., based on visibility) and will not end
230 // up being PaintInvalidationClean.
231 enum class LifecycleThrottlingMode { Disallow, Allow };
232 void updateAllLifecyclePhases(LifecycleThrottlingMode = LifecycleThrottlingM ode::Disallow);
230 233
231 // Computes the style, layout and compositing lifecycle stages if needed. Af ter calling this method, all frames wil lbe in a lifecycle 234 // 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. 235 // state >= CompositingClean, and scrolling has been updated.
233 void updateLifecycleToCompositingCleanPlusScrolling(); 236 void updateLifecycleToCompositingCleanPlusScrolling(LifecycleThrottlingMode = LifecycleThrottlingMode::Disallow);
234 237
235 bool invalidateViewportConstrainedObjects(); 238 bool invalidateViewportConstrainedObjects();
236 239
237 void incrementVisuallyNonEmptyCharacterCount(unsigned); 240 void incrementVisuallyNonEmptyCharacterCount(unsigned);
238 void incrementVisuallyNonEmptyPixelCount(const IntSize&); 241 void incrementVisuallyNonEmptyPixelCount(const IntSize&);
239 bool isVisuallyNonEmpty() const { return m_isVisuallyNonEmpty; } 242 bool isVisuallyNonEmpty() const { return m_isVisuallyNonEmpty; }
240 void setIsVisuallyNonEmpty() { m_isVisuallyNonEmpty = true; } 243 void setIsVisuallyNonEmpty() { m_isVisuallyNonEmpty = true; }
241 void enableAutoSizeMode(const IntSize& minSize, const IntSize& maxSize); 244 void enableAutoSizeMode(const IntSize& minSize, const IntSize& maxSize);
242 void disableAutoSizeMode(); 245 void disableAutoSizeMode();
243 246
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 // Returns true if the default scrolling direction is vertical. i.e. writing mode 555 // Returns true if the default scrolling direction is vertical. i.e. writing mode
553 // is horiziontal. In a vertical document, a spacebar scrolls down. 556 // is horiziontal. In a vertical document, a spacebar scrolls down.
554 bool isVerticalDocument() const; 557 bool isVerticalDocument() const;
555 558
556 // Returns true if the document's writing mode is right-to-left or bottom-to -top. 559 // Returns true if the document's writing mode is right-to-left or bottom-to -top.
557 bool isFlippedDocument() const; 560 bool isFlippedDocument() const;
558 561
559 void setFrameTimingRequestsDirty(bool isDirty) { m_frameTimingRequestsDirty = isDirty; } 562 void setFrameTimingRequestsDirty(bool isDirty) { m_frameTimingRequestsDirty = isDirty; }
560 bool frameTimingRequestsDirty() { return m_frameTimingRequestsDirty; } 563 bool frameTimingRequestsDirty() { return m_frameTimingRequestsDirty; }
561 564
565 // Returns true if this frame should skip rendering pipeline processing duri ng the
566 // current BeginMainFrame.
567 bool shouldThrottleRenderingPipeline() const;
568
569 // Returns true if this frame should skip style computation, layout and
570 // compositing updates for the current BeginMainFrame.
571 bool shouldThrottleStyleLayoutAndCompositingUpdates() const;
572
573 // Updates the throttling status of all frames in the hierarchy and
574 // schedules new animations or lifecycle updates as necessary. Must be
575 // called after the layer update phase of the current BeginMainFrame.
576 void updateThrottling();
577
562 protected: 578 protected:
563 // Scroll the content via the compositor. 579 // Scroll the content via the compositor.
564 bool scrollContentsFastPath(const IntSize& scrollDelta); 580 bool scrollContentsFastPath(const IntSize& scrollDelta);
565 581
566 // Scroll the content by invalidating everything. 582 // Scroll the content by invalidating everything.
567 void scrollContentsSlowPath(const IntRect& updateRect); 583 void scrollContentsSlowPath(const IntRect& updateRect);
568 584
569 // These functions are used to create/destroy scrollbars. 585 // These functions are used to create/destroy scrollbars.
570 void setHasHorizontalScrollbar(bool); 586 void setHasHorizontalScrollbar(bool);
571 void setHasVerticalScrollbar(bool); 587 void setHasVerticalScrollbar(bool);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 explicit FrameView(LocalFrame*); 621 explicit FrameView(LocalFrame*);
606 622
607 void setScrollOffset(const IntPoint&, ScrollType) override; 623 void setScrollOffset(const IntPoint&, ScrollType) override;
608 void setScrollOffset(const DoublePoint&, ScrollType) override; 624 void setScrollOffset(const DoublePoint&, ScrollType) override;
609 625
610 enum LifeCycleUpdateOption { 626 enum LifeCycleUpdateOption {
611 AllPhases, 627 AllPhases,
612 OnlyUpToCompositingCleanPlusScrolling, 628 OnlyUpToCompositingCleanPlusScrolling,
613 }; 629 };
614 630
615 void updateLifecyclePhasesInternal(LifeCycleUpdateOption); 631 void updateLifecyclePhasesInternal(LifeCycleUpdateOption, LifecycleThrottlin gMode);
616 void invalidateTreeIfNeededRecursive(); 632 void invalidateTreeIfNeededRecursive();
617 void scrollContentsIfNeededRecursive(); 633 void scrollContentsIfNeededRecursive();
618 void updateStyleAndLayoutIfNeededRecursive(); 634 void updateStyleAndLayoutIfNeededRecursive();
619 void paintForSlimmingPaintV2(); 635 void paintForSlimmingPaintV2();
620 void compositeForSlimmingPaintV2(); 636 void compositeForSlimmingPaintV2();
621 637
622 void reset(); 638 void reset();
623 void init(); 639 void init();
624 640
625 void clearLayoutSubtreeRootsAndMarkContainingBlocks(); 641 void clearLayoutSubtreeRootsAndMarkContainingBlocks();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 // LayoutObject for the viewport-defining element (see Document::viewportDef iningElement). 726 // LayoutObject for the viewport-defining element (see Document::viewportDef iningElement).
711 LayoutObject* viewportLayoutObject(); 727 LayoutObject* viewportLayoutObject();
712 728
713 void collectAnnotatedRegions(LayoutObject&, Vector<AnnotatedRegionValue>&); 729 void collectAnnotatedRegions(LayoutObject&, Vector<AnnotatedRegionValue>&);
714 730
715 typedef WTF::HashMap <const GraphicsLayer*, Vector<std::pair<int64_t, WebRec t>>> GraphicsLayerFrameTimingRequests; 731 typedef WTF::HashMap <const GraphicsLayer*, Vector<std::pair<int64_t, WebRec t>>> GraphicsLayerFrameTimingRequests;
716 void updateFrameTimingRequestsIfNeeded(); 732 void updateFrameTimingRequestsIfNeeded();
717 void collectFrameTimingRequests(GraphicsLayerFrameTimingRequests&); 733 void collectFrameTimingRequests(GraphicsLayerFrameTimingRequests&);
718 void collectFrameTimingRequestsRecursive(GraphicsLayerFrameTimingRequests&); 734 void collectFrameTimingRequestsRecursive(GraphicsLayerFrameTimingRequests&);
719 735
736 void computeViewportVisibility();
737 void setLifecycleThrottlingModeRecursive(LifecycleThrottlingMode);
738 void updateThrottlingRecursive(bool hasCrossedSecurityOrigin);
739
720 LayoutSize m_size; 740 LayoutSize m_size;
721 741
722 typedef HashSet<RefPtr<LayoutEmbeddedObject>> EmbeddedObjectSet; 742 typedef HashSet<RefPtr<LayoutEmbeddedObject>> EmbeddedObjectSet;
723 EmbeddedObjectSet m_partUpdateSet; 743 EmbeddedObjectSet m_partUpdateSet;
724 744
725 // FIXME: These are just "children" of the FrameView and should be RefPtrWil lBeMember<Widget> instead. 745 // FIXME: These are just "children" of the FrameView and should be RefPtrWil lBeMember<Widget> instead.
726 HashSet<RefPtr<LayoutPart>> m_parts; 746 HashSet<RefPtr<LayoutPart>> m_parts;
727 747
728 // The RefPtr cycle between LocalFrame and FrameView is broken 748 // The RefPtr cycle between LocalFrame and FrameView is broken
729 // when a LocalFrame is detached by LocalFrame::detach(). 749 // when a LocalFrame is detached by LocalFrame::detach().
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 OwnPtr<LayoutAnalyzer> m_analyzer; 852 OwnPtr<LayoutAnalyzer> m_analyzer;
833 853
834 // Mark if something has changed in the mapping from Frame to GraphicsLayer 854 // Mark if something has changed in the mapping from Frame to GraphicsLayer
835 // and the Frame Timing regions should be recalculated. 855 // and the Frame Timing regions should be recalculated.
836 bool m_frameTimingRequestsDirty; 856 bool m_frameTimingRequestsDirty;
837 857
838 // Exists only on root frame. 858 // Exists only on root frame.
839 // TODO(bokan): crbug.com/484188. We should specialize FrameView for the 859 // TODO(bokan): crbug.com/484188. We should specialize FrameView for the
840 // main frame. 860 // main frame.
841 OwnPtrWillBeMember<ScrollableArea> m_viewportScrollableArea; 861 OwnPtrWillBeMember<ScrollableArea> m_viewportScrollableArea;
862
863 LifecycleThrottlingMode m_lifecycleThrottlingMode;
864 // This frame's bounds in the root frame's content coordinates, clipped recu rsively through every ancestor view.
865 IntRect m_clippedBounds;
866
867 enum class ViewportVisibility { Hidden, Visible, Unknown };
868 ViewportVisibility m_viewportVisibility;
869 ViewportVisibility m_viewportVisibilityForThrottling;
ojan 2015/09/01 19:56:48 This member deserves a comment explaining why we n
Sami 2015/09/02 10:46:02 Definitely agreed. Added a comment.
870 bool m_isCrossOriginForThrottling;
842 }; 871 };
843 872
844 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count) 873 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count)
845 { 874 {
846 if (m_isVisuallyNonEmpty) 875 if (m_isVisuallyNonEmpty)
847 return; 876 return;
848 m_visuallyNonEmptyCharacterCount += count; 877 m_visuallyNonEmptyCharacterCount += count;
849 // Use a threshold value to prevent very small amounts of visible content fr om triggering didFirstVisuallyNonEmptyLayout. 878 // Use a threshold value to prevent very small amounts of visible content fr om triggering didFirstVisuallyNonEmptyLayout.
850 // The first few hundred characters rarely contain the interesting content o f the page. 879 // The first few hundred characters rarely contain the interesting content o f the page.
851 static const unsigned visualCharacterThreshold = 200; 880 static const unsigned visualCharacterThreshold = 200;
(...skipping 10 matching lines...) Expand all
862 static const unsigned visualPixelThreshold = 32 * 32; 891 static const unsigned visualPixelThreshold = 32 * 32;
863 if (m_visuallyNonEmptyPixelCount > visualPixelThreshold) 892 if (m_visuallyNonEmptyPixelCount > visualPixelThreshold)
864 setIsVisuallyNonEmpty(); 893 setIsVisuallyNonEmpty();
865 } 894 }
866 895
867 DEFINE_TYPE_CASTS(FrameView, Widget, widget, widget->isFrameView(), widget.isFra meView()); 896 DEFINE_TYPE_CASTS(FrameView, Widget, widget, widget->isFrameView(), widget.isFra meView());
868 897
869 } // namespace blink 898 } // namespace blink
870 899
871 #endif // FrameView_h 900 #endif // FrameView_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/frame/FrameView.cpp » ('j') | Source/core/frame/FrameView.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698