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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2706193003: FrameView: Remove redundant tree walk when unthrottling display:none frames (Closed)
Patch Set: Enums ftw Created 3 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 4722 matching lines...) Expand 10 before | Expand all | Expand 10 after
4733 if (targetState == DocumentLifecycle::PaintClean && 4733 if (targetState == DocumentLifecycle::PaintClean &&
4734 frame().document()->intersectionObserverController()) 4734 frame().document()->intersectionObserverController())
4735 frame() 4735 frame()
4736 .document() 4736 .document()
4737 ->intersectionObserverController() 4737 ->intersectionObserverController()
4738 ->computeTrackedIntersectionObservations(); 4738 ->computeTrackedIntersectionObservations();
4739 4739
4740 // Don't throttle display:none frames (see updateRenderThrottlingStatus). 4740 // Don't throttle display:none frames (see updateRenderThrottlingStatus).
4741 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); 4741 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner();
4742 if (m_hiddenForThrottling && ownerElement && !ownerElement->layoutObject()) { 4742 if (m_hiddenForThrottling && ownerElement && !ownerElement->layoutObject()) {
4743 updateRenderThrottlingStatus(m_hiddenForThrottling, m_subtreeThrottled); 4743 // No need to notify children because descendants of display:none frames
4744 // should remain throttled.
4745 updateRenderThrottlingStatus(m_hiddenForThrottling, m_subtreeThrottled,
4746 DontForceThrottlingInvalidation,
4747 DontNotifyChildren);
4744 DCHECK(!canThrottleRendering()); 4748 DCHECK(!canThrottleRendering());
4745 } 4749 }
4746 4750
4747 for (Frame* child = m_frame->tree().firstChild(); child; 4751 for (Frame* child = m_frame->tree().firstChild(); child;
4748 child = child->tree().nextSibling()) { 4752 child = child->tree().nextSibling()) {
4749 if (!child->isLocalFrame()) 4753 if (!child->isLocalFrame())
4750 continue; 4754 continue;
4751 if (FrameView* view = toLocalFrame(child)->view()) 4755 if (FrameView* view = toLocalFrame(child)->view())
4752 view->updateViewportIntersectionsForSubtree(targetState); 4756 view->updateViewportIntersectionsForSubtree(targetState);
4753 } 4757 }
4754 } 4758 }
4755 4759
4756 void FrameView::updateRenderThrottlingStatusForTesting() { 4760 void FrameView::updateRenderThrottlingStatusForTesting() {
4757 m_visibilityObserver->deliverObservationsForTesting(); 4761 m_visibilityObserver->deliverObservationsForTesting();
4758 } 4762 }
4759 4763
4760 void FrameView::crossOriginStatusChanged() { 4764 void FrameView::crossOriginStatusChanged() {
4761 // Cross-domain status is not stored as a dirty bit within FrameView, 4765 // Cross-domain status is not stored as a dirty bit within FrameView,
4762 // so force-invalidate throttling status when it changes regardless of 4766 // so force-invalidate throttling status when it changes regardless of
4763 // previous or new value. 4767 // previous or new value.
4764 updateRenderThrottlingStatus(m_hiddenForThrottling, m_subtreeThrottled, true); 4768 updateRenderThrottlingStatus(m_hiddenForThrottling, m_subtreeThrottled,
4769 ForceThrottlingInvalidation);
4765 } 4770 }
4766 4771
4767 void FrameView::updateRenderThrottlingStatus(bool hidden, 4772 void FrameView::updateRenderThrottlingStatus(
4768 bool subtreeThrottled, 4773 bool hidden,
4769 bool forceThrottlingInvalidation) { 4774 bool subtreeThrottled,
4775 ForceThrottlingInvalidationBehavior forceThrottlingInvalidationBehavior,
4776 NotifyChildrenBehavior notifyChildrenBehavior) {
4770 TRACE_EVENT0("blink", "FrameView::updateRenderThrottlingStatus"); 4777 TRACE_EVENT0("blink", "FrameView::updateRenderThrottlingStatus");
4771 DCHECK(!isInPerformLayout()); 4778 DCHECK(!isInPerformLayout());
4772 DCHECK(!m_frame->document() || !m_frame->document()->inStyleRecalc()); 4779 DCHECK(!m_frame->document() || !m_frame->document()->inStyleRecalc());
4773 bool wasThrottled = canThrottleRendering(); 4780 bool wasThrottled = canThrottleRendering();
4774 4781
4775 // Note that we disallow throttling of 0x0 and display:none frames because 4782 // Note that we disallow throttling of 0x0 and display:none frames because
4776 // some sites use them to drive UI logic. 4783 // some sites use them to drive UI logic.
4777 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); 4784 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner();
4778 m_hiddenForThrottling = hidden && !frameRect().isEmpty() && 4785 m_hiddenForThrottling = hidden && !frameRect().isEmpty() &&
4779 (ownerElement && ownerElement->layoutObject()); 4786 (ownerElement && ownerElement->layoutObject());
4780 m_subtreeThrottled = subtreeThrottled; 4787 m_subtreeThrottled = subtreeThrottled;
4781 4788
4782 bool isThrottled = canThrottleRendering(); 4789 bool isThrottled = canThrottleRendering();
4783 bool becameUnthrottled = wasThrottled && !isThrottled; 4790 bool becameUnthrottled = wasThrottled && !isThrottled;
4784 4791
4785 // If this FrameView became unthrottled or throttled, we must make sure all 4792 // If this FrameView became unthrottled or throttled, we must make sure all
4786 // its children are notified synchronously. Otherwise we 1) might attempt to 4793 // its children are notified synchronously. Otherwise we 1) might attempt to
4787 // paint one of the children with an out-of-date layout before 4794 // paint one of the children with an out-of-date layout before
4788 // |updateRenderThrottlingStatus| has made it throttled or 2) fail to 4795 // |updateRenderThrottlingStatus| has made it throttled or 2) fail to
4789 // unthrottle a child whose parent is unthrottled by a later notification. 4796 // unthrottle a child whose parent is unthrottled by a later notification.
4790 if (wasThrottled != isThrottled || forceThrottlingInvalidation) { 4797 if (notifyChildrenBehavior == NotifyChildren &&
4798 (wasThrottled != isThrottled ||
4799 forceThrottlingInvalidationBehavior == ForceThrottlingInvalidation)) {
4791 for (const Member<Widget>& child : *children()) { 4800 for (const Member<Widget>& child : *children()) {
4792 if (child->isFrameView()) { 4801 if (child->isFrameView()) {
4793 FrameView* childView = toFrameView(child); 4802 FrameView* childView = toFrameView(child);
4794 childView->updateRenderThrottlingStatus( 4803 childView->updateRenderThrottlingStatus(
4795 childView->m_hiddenForThrottling, isThrottled); 4804 childView->m_hiddenForThrottling, isThrottled);
4796 } 4805 }
4797 } 4806 }
4798 } 4807 }
4799 4808
4800 ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator(); 4809 ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator();
4801 if (becameUnthrottled || forceThrottlingInvalidation) { 4810 if (becameUnthrottled ||
4811 forceThrottlingInvalidationBehavior == ForceThrottlingInvalidation) {
4802 // ScrollingCoordinator needs to update according to the new throttling 4812 // ScrollingCoordinator needs to update according to the new throttling
4803 // status. 4813 // status.
4804 if (scrollingCoordinator) 4814 if (scrollingCoordinator)
4805 scrollingCoordinator->notifyGeometryChanged(); 4815 scrollingCoordinator->notifyGeometryChanged();
4806 // Start ticking animation frames again if necessary. 4816 // Start ticking animation frames again if necessary.
4807 if (page()) 4817 if (page())
4808 page()->animator().scheduleVisualUpdate(m_frame.get()); 4818 page()->animator().scheduleVisualUpdate(m_frame.get());
4809 // Force a full repaint of this frame to ensure we are not left with a 4819 // Force a full repaint of this frame to ensure we are not left with a
4810 // partially painted version of this frame's contents if we skipped 4820 // partially painted version of this frame's contents if we skipped
4811 // painting them while the frame was throttled. 4821 // painting them while the frame was throttled.
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
5185 void FrameView::setAnimationHost( 5195 void FrameView::setAnimationHost(
5186 std::unique_ptr<CompositorAnimationHost> host) { 5196 std::unique_ptr<CompositorAnimationHost> host) {
5187 m_animationHost = std::move(host); 5197 m_animationHost = std::move(host);
5188 } 5198 }
5189 5199
5190 LayoutUnit FrameView::caretWidth() const { 5200 LayoutUnit FrameView::caretWidth() const {
5191 return LayoutUnit(getHostWindow()->windowToViewportScalar(1)); 5201 return LayoutUnit(getHostWindow()->windowToViewportScalar(1));
5192 } 5202 }
5193 5203
5194 } // namespace blink 5204 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.h ('k') | third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698