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

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

Issue 1246173002: Throttle rendering pipeline for invisible iframes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Keep animation time consistent. 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
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 , m_baseBackgroundColor(Color::white) 121 , m_baseBackgroundColor(Color::white)
122 , m_mediaType(MediaTypeNames::screen) 122 , m_mediaType(MediaTypeNames::screen)
123 , m_safeToPropagateScrollToParent(true) 123 , m_safeToPropagateScrollToParent(true)
124 , m_isTrackingPaintInvalidations(false) 124 , m_isTrackingPaintInvalidations(false)
125 , m_scrollCorner(nullptr) 125 , m_scrollCorner(nullptr)
126 , m_inputEventsScaleFactorForEmulation(1) 126 , m_inputEventsScaleFactorForEmulation(1)
127 , m_layoutSizeFixedToFrameSize(true) 127 , m_layoutSizeFixedToFrameSize(true)
128 , m_didScrollTimer(this, &FrameView::didScrollTimerFired) 128 , m_didScrollTimer(this, &FrameView::didScrollTimerFired)
129 , m_topControlsViewportAdjustment(0) 129 , m_topControlsViewportAdjustment(0)
130 , m_needsUpdateWidgetPositions(false) 130 , m_needsUpdateWidgetPositions(false)
131 , m_needsUpdateViewportVisibility(true)
131 #if ENABLE(ASSERT) 132 #if ENABLE(ASSERT)
132 , m_hasBeenDisposed(false) 133 , m_hasBeenDisposed(false)
133 #endif 134 #endif
134 , m_horizontalScrollbarMode(ScrollbarAuto) 135 , m_horizontalScrollbarMode(ScrollbarAuto)
135 , m_verticalScrollbarMode(ScrollbarAuto) 136 , m_verticalScrollbarMode(ScrollbarAuto)
136 , m_horizontalScrollbarLock(false) 137 , m_horizontalScrollbarLock(false)
137 , m_verticalScrollbarLock(false) 138 , m_verticalScrollbarLock(false)
138 , m_scrollbarsAvoidingResizer(0) 139 , m_scrollbarsAvoidingResizer(0)
139 , m_scrollbarsSuppressed(false) 140 , m_scrollbarsSuppressed(false)
140 , m_inUpdateScrollbars(false) 141 , m_inUpdateScrollbars(false)
141 , m_clipsRepaints(true) 142 , m_clipsRepaints(true)
142 , m_frameTimingRequestsDirty(true) 143 , m_frameTimingRequestsDirty(true)
143 144 , m_viewportVisibility(ViewportVisibility::Visible)
145 , m_securityOriginStatusForThrottling(SecurityOriginStatus::IsSameOrigin)
144 { 146 {
145 ASSERT(m_frame); 147 ASSERT(m_frame);
146 init(); 148 init();
147 } 149 }
148 150
149 PassRefPtrWillBeRawPtr<FrameView> FrameView::create(LocalFrame* frame) 151 PassRefPtrWillBeRawPtr<FrameView> FrameView::create(LocalFrame* frame)
150 { 152 {
151 RefPtrWillBeRawPtr<FrameView> view = adoptRefWillBeNoop(new FrameView(frame) ); 153 RefPtrWillBeRawPtr<FrameView> view = adoptRefWillBeNoop(new FrameView(frame) );
152 view->show(); 154 view->show();
153 return view.release(); 155 return view.release();
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 1085
1084 frame().document()->layoutUpdated(); 1086 frame().document()->layoutUpdated();
1085 } 1087 }
1086 1088
1087 // The plan is to move to compositor-queried paint invalidation, in which case t his 1089 // The plan is to move to compositor-queried paint invalidation, in which case t his
1088 // method would setNeedsRedraw on the GraphicsLayers with invalidations and 1090 // method would setNeedsRedraw on the GraphicsLayers with invalidations and
1089 // let the compositor pick which to actually draw. 1091 // let the compositor pick which to actually draw.
1090 // See http://crbug.com/306706 1092 // See http://crbug.com/306706
1091 void FrameView::invalidateTreeIfNeeded(PaintInvalidationState& paintInvalidation State) 1093 void FrameView::invalidateTreeIfNeeded(PaintInvalidationState& paintInvalidation State)
1092 { 1094 {
1095 if (shouldThrottleRenderingPipeline())
1096 return;
1097
1093 lifecycle().advanceTo(DocumentLifecycle::InPaintInvalidation); 1098 lifecycle().advanceTo(DocumentLifecycle::InPaintInvalidation);
1094 1099
1095 ASSERT(layoutView()); 1100 ASSERT(layoutView());
1096 LayoutView& rootForPaintInvalidation = *layoutView(); 1101 LayoutView& rootForPaintInvalidation = *layoutView();
1097 ASSERT(!rootForPaintInvalidation.needsLayout()); 1102 ASSERT(!rootForPaintInvalidation.needsLayout());
1098 1103
1099 TRACE_EVENT1("blink", "FrameView::invalidateTree", "root", rootForPaintInval idation.debugName().ascii()); 1104 TRACE_EVENT1("blink", "FrameView::invalidateTree", "root", rootForPaintInval idation.debugName().ascii());
1100 1105
1101 // In slimming paint mode we do per-object invalidation. 1106 // In slimming paint mode we do per-object invalidation.
1102 if (m_doFullPaintInvalidation && !RuntimeEnabledFeatures::slimmingPaintEnabl ed()) 1107 if (m_doFullPaintInvalidation && !RuntimeEnabledFeatures::slimmingPaintEnabl ed())
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 } 1301 }
1297 1302
1298 bool FrameView::shouldSetCursor() const 1303 bool FrameView::shouldSetCursor() const
1299 { 1304 {
1300 Page* page = frame().page(); 1305 Page* page = frame().page();
1301 return page && page->visibilityState() != PageVisibilityStateHidden && page- >focusController().isActive() && page->settings().deviceSupportsMouse(); 1306 return page && page->visibilityState() != PageVisibilityStateHidden && page- >focusController().isActive() && page->settings().deviceSupportsMouse();
1302 } 1307 }
1303 1308
1304 void FrameView::scrollContentsIfNeededRecursive() 1309 void FrameView::scrollContentsIfNeededRecursive()
1305 { 1310 {
1311 if (shouldThrottleStyleLayoutAndCompositingUpdates())
1312 return;
1306 scrollContentsIfNeeded(); 1313 scrollContentsIfNeeded();
1307 1314
1308 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { 1315 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) {
1309 if (!child->isLocalFrame()) 1316 if (!child->isLocalFrame())
1310 continue; 1317 continue;
1311 if (FrameView* view = toLocalFrame(child)->view()) 1318 if (FrameView* view = toLocalFrame(child)->view())
1312 view->scrollContentsIfNeededRecursive(); 1319 view->scrollContentsIfNeededRecursive();
1313 } 1320 }
1314 } 1321 }
1315 1322
1323 void FrameView::setLifecycleThrottlingModeForSubtree(DocumentLifecycle::Throttli ngMode throttlingMode)
1324 {
1325 ASSERT(m_frame->isLocalRoot());
1326 for (Frame* frame = m_frame.get(); frame; frame = frame->tree().traverseNext (m_frame.get())) {
1327 if (!frame->isLocalFrame())
1328 continue;
1329 if (FrameView* view = toLocalFrame(frame)->view())
1330 view->lifecycle().setThrottlingMode(throttlingMode);
1331 }
1332 }
1333
1316 bool FrameView::invalidateViewportConstrainedObjects() 1334 bool FrameView::invalidateViewportConstrainedObjects()
1317 { 1335 {
1318 for (const auto& viewportConstrainedObject : *m_viewportConstrainedObjects) { 1336 for (const auto& viewportConstrainedObject : *m_viewportConstrainedObjects) {
1319 LayoutObject* layoutObject = viewportConstrainedObject; 1337 LayoutObject* layoutObject = viewportConstrainedObject;
1320 ASSERT(layoutObject->style()->hasViewportConstrainedPosition()); 1338 ASSERT(layoutObject->style()->hasViewportConstrainedPosition());
1321 ASSERT(layoutObject->hasLayer()); 1339 ASSERT(layoutObject->hasLayer());
1322 DeprecatedPaintLayer* layer = toLayoutBoxModelObject(layoutObject)->laye r(); 1340 DeprecatedPaintLayer* layer = toLayoutBoxModelObject(layoutObject)->laye r();
1323 1341
1324 if (layer->isPaintInvalidationContainer()) 1342 if (layer->isPaintInvalidationContainer())
1325 continue; 1343 continue;
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after
2420 void FrameView::updateWidgetPositionsIfNeeded() 2438 void FrameView::updateWidgetPositionsIfNeeded()
2421 { 2439 {
2422 if (!m_needsUpdateWidgetPositions) 2440 if (!m_needsUpdateWidgetPositions)
2423 return; 2441 return;
2424 2442
2425 m_needsUpdateWidgetPositions = false; 2443 m_needsUpdateWidgetPositions = false;
2426 2444
2427 updateWidgetPositions(); 2445 updateWidgetPositions();
2428 } 2446 }
2429 2447
2430 void FrameView::updateAllLifecyclePhases() 2448 void FrameView::updateAllLifecyclePhases(DocumentLifecycle::ThrottlingMode throt tlingMode)
2431 { 2449 {
2432 frame().localFrameRoot()->view()->updateLifecyclePhasesInternal(AllPhases); 2450 frame().localFrameRoot()->view()->updateLifecyclePhasesInternal(AllPhases, t hrottlingMode);
2433 } 2451 }
2434 2452
2435 // TODO(chrishtr): add a scrolling update lifecycle phase. 2453 // TODO(chrishtr): add a scrolling update lifecycle phase.
2436 void FrameView::updateLifecycleToCompositingCleanPlusScrolling() 2454 void FrameView::updateLifecycleToCompositingCleanPlusScrolling(DocumentLifecycle ::ThrottlingMode throttlingMode)
2437 { 2455 {
2438 frame().localFrameRoot()->view()->updateLifecyclePhasesInternal(OnlyUpToComp ositingCleanPlusScrolling); 2456 frame().localFrameRoot()->view()->updateLifecyclePhasesInternal(OnlyUpToComp ositingCleanPlusScrolling, throttlingMode);
2439 } 2457 }
2440 2458
2441 void FrameView::updateLifecyclePhasesInternal(LifeCycleUpdateOption phases) 2459 void FrameView::updateLifecyclePhasesInternal(LifeCycleUpdateOption phases, Docu mentLifecycle::ThrottlingMode throttlingMode)
2442 { 2460 {
2443 // This must be called from the root frame, since it recurses down, not up. 2461 // This must be called from the root frame, since it recurses down, not up.
2444 // Otherwise the lifecycles of the frames might be out of sync. 2462 // Otherwise the lifecycles of the frames might be out of sync.
2445 ASSERT(m_frame->isLocalRoot()); 2463 ASSERT(m_frame->isLocalRoot());
2446 2464
2447 // Updating layout can run script, which can tear down the FrameView. 2465 // Updating layout can run script, which can tear down the FrameView.
2448 RefPtrWillBeRawPtr<FrameView> protector(this); 2466 RefPtrWillBeRawPtr<FrameView> protector(this);
2449 2467
2468 setLifecycleThrottlingModeForSubtree(throttlingMode);
2450 updateStyleAndLayoutIfNeededRecursive(); 2469 updateStyleAndLayoutIfNeededRecursive();
2451 2470
2452 if (LayoutView* view = layoutView()) { 2471 if (LayoutView* view = layoutView()) {
2453 TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", InspectorUp dateLayerTreeEvent::data(m_frame.get())); 2472 TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", InspectorUp dateLayerTreeEvent::data(m_frame.get()));
2454 2473
2455 // This was required for slimming paint v1 but is only temporarily 2474 // This was required for slimming paint v1 but is only temporarily
2456 // needed for slimming paint v2. 2475 // needed for slimming paint v2.
2457 view->compositor()->updateIfNeededRecursive(); 2476 view->compositor()->updateIfNeededRecursive();
2458 scrollContentsIfNeededRecursive(); 2477 scrollContentsIfNeededRecursive();
2459 2478
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2536 collectFrameTimingRequestsRecursive(graphicsLayerTimingRequests); 2555 collectFrameTimingRequestsRecursive(graphicsLayerTimingRequests);
2537 2556
2538 for (const auto& iter : graphicsLayerTimingRequests) { 2557 for (const auto& iter : graphicsLayerTimingRequests) {
2539 const GraphicsLayer* graphicsLayer = iter.key; 2558 const GraphicsLayer* graphicsLayer = iter.key;
2540 graphicsLayer->platformLayer()->setFrameTimingRequests(iter.value); 2559 graphicsLayer->platformLayer()->setFrameTimingRequests(iter.value);
2541 } 2560 }
2542 } 2561 }
2543 2562
2544 void FrameView::updateStyleAndLayoutIfNeededRecursive() 2563 void FrameView::updateStyleAndLayoutIfNeededRecursive()
2545 { 2564 {
2565 if (shouldThrottleStyleLayoutAndCompositingUpdates())
2566 return;
2567
2546 // We have to crawl our entire subtree looking for any FrameViews that need 2568 // We have to crawl our entire subtree looking for any FrameViews that need
2547 // layout and make sure they are up to date. 2569 // layout and make sure they are up to date.
2548 // Mac actually tests for intersection with the dirty region and tries not t o 2570 // Mac actually tests for intersection with the dirty region and tries not t o
2549 // update layout for frames that are outside the dirty region. Not only doe s this seem 2571 // update layout for frames that are outside the dirty region. Not only doe s this seem
2550 // pointless (since those frames will have set a zero timer to layout anyway ), but 2572 // pointless (since those frames will have set a zero timer to layout anyway ), but
2551 // it is also incorrect, since if two frames overlap, the first could be exc luded from the dirty 2573 // it is also incorrect, since if two frames overlap, the first could be exc luded from the dirty
2552 // region but then become included later by the second frame adding rects to the dirty region 2574 // region but then become included later by the second frame adding rects to the dirty region
2553 // when it lays out. 2575 // when it lays out.
2554 2576
2555 m_frame->document()->updateLayoutTreeIfNeeded(); 2577 m_frame->document()->updateLayoutTreeIfNeeded();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2587 #if ENABLE(ASSERT) 2609 #if ENABLE(ASSERT)
2588 m_frame->document()->layoutView()->assertLaidOut(); 2610 m_frame->document()->layoutView()->assertLaidOut();
2589 #endif 2611 #endif
2590 2612
2591 updateWidgetPositionsIfNeeded(); 2613 updateWidgetPositionsIfNeeded();
2592 } 2614 }
2593 2615
2594 void FrameView::invalidateTreeIfNeededRecursive() 2616 void FrameView::invalidateTreeIfNeededRecursive()
2595 { 2617 {
2596 ASSERT(layoutView()); 2618 ASSERT(layoutView());
2619
2620 // We need to stop recursing here since a child frame view might not be thro ttled
2621 // even though we are (e.g., it didn't compute its visibility yet).
2622 if (shouldThrottleRenderingPipeline())
2623 return;
2597 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root", layoutView()->debugName().ascii()); 2624 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root", layoutView()->debugName().ascii());
2598 2625
2599 Vector<LayoutObject*> pendingDelayedPaintInvalidations; 2626 Vector<LayoutObject*> pendingDelayedPaintInvalidations;
2600 PaintInvalidationState rootPaintInvalidationState(*layoutView(), pendingDela yedPaintInvalidations); 2627 PaintInvalidationState rootPaintInvalidationState(*layoutView(), pendingDela yedPaintInvalidations);
2601 2628
2602 invalidateTreeIfNeeded(rootPaintInvalidationState); 2629 invalidateTreeIfNeeded(rootPaintInvalidationState);
2603 2630
2604 // Some frames may be not reached during the above invalidateTreeIfNeeded be cause 2631 // Some frames may be not reached during the above invalidateTreeIfNeeded be cause
2605 // - the frame is a detached frame; or 2632 // - the frame is a detached frame; or
2606 // - it didn't need paint invalidation. 2633 // - it didn't need paint invalidation.
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
2913 2940
2914 if (m_scrollbarsAvoidingResizer && parent()) 2941 if (m_scrollbarsAvoidingResizer && parent())
2915 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(-m_scrollbar sAvoidingResizer); 2942 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(-m_scrollbar sAvoidingResizer);
2916 2943
2917 Widget::setParent(parentView); 2944 Widget::setParent(parentView);
2918 2945
2919 if (m_scrollbarsAvoidingResizer && parent()) 2946 if (m_scrollbarsAvoidingResizer && parent())
2920 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(m_scrollbars AvoidingResizer); 2947 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(m_scrollbars AvoidingResizer);
2921 2948
2922 updateScrollableAreaSet(); 2949 updateScrollableAreaSet();
2950 m_needsUpdateViewportVisibility = true;
2923 } 2951 }
2924 2952
2925 void FrameView::removeChild(Widget* child) 2953 void FrameView::removeChild(Widget* child)
2926 { 2954 {
2927 ASSERT(child->parent() == this); 2955 ASSERT(child->parent() == this);
2928 2956
2929 if (child->isFrameView()) 2957 if (child->isFrameView())
2930 removeScrollableArea(toFrameView(child)); 2958 removeScrollableArea(toFrameView(child));
2931 2959
2932 child->setParent(0); 2960 child->setParent(0);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2970 return; 2998 return;
2971 page->chromeClient().setCursor(cursor); 2999 page->chromeClient().setCursor(cursor);
2972 } 3000 }
2973 3001
2974 void FrameView::frameRectsChanged() 3002 void FrameView::frameRectsChanged()
2975 { 3003 {
2976 TRACE_EVENT0("blink", "FrameView::frameRectsChanged"); 3004 TRACE_EVENT0("blink", "FrameView::frameRectsChanged");
2977 if (layoutSizeFixedToFrameSize()) 3005 if (layoutSizeFixedToFrameSize())
2978 setLayoutSizeInternal(frameRect().size()); 3006 setLayoutSizeInternal(frameRect().size());
2979 3007
3008 m_needsUpdateViewportVisibility = true;
2980 for (const auto& child : m_children) 3009 for (const auto& child : m_children)
2981 child->frameRectsChanged(); 3010 child->frameRectsChanged();
2982 } 3011 }
2983 3012
2984 void FrameView::setLayoutSizeInternal(const IntSize& size) 3013 void FrameView::setLayoutSizeInternal(const IntSize& size)
2985 { 3014 {
2986 if (m_layoutSize == size) 3015 if (m_layoutSize == size)
2987 return; 3016 return;
2988 3017
2989 m_layoutSize = size; 3018 m_layoutSize = size;
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
3760 return ScrollBehaviorInstant; 3789 return ScrollBehaviorInstant;
3761 } 3790 }
3762 3791
3763 void FrameView::paint(GraphicsContext* context, const IntRect& rect) 3792 void FrameView::paint(GraphicsContext* context, const IntRect& rect)
3764 { 3793 {
3765 paint(context, GlobalPaintNormalPhase, rect); 3794 paint(context, GlobalPaintNormalPhase, rect);
3766 } 3795 }
3767 3796
3768 void FrameView::paint(GraphicsContext* context, const GlobalPaintFlags globalPai ntFlags, const IntRect& rect) 3797 void FrameView::paint(GraphicsContext* context, const GlobalPaintFlags globalPai ntFlags, const IntRect& rect)
3769 { 3798 {
3799 if (shouldThrottleRenderingPipeline())
chrishtr 2015/09/04 17:32:04 Add a TODO to get rid of this in favor of painting
Sami 2015/09/07 17:27:16 Done.
3800 return;
3770 FramePainter(*this).paint(context, globalPaintFlags, rect); 3801 FramePainter(*this).paint(context, globalPaintFlags, rect);
3771 } 3802 }
3772 3803
3773 void FrameView::paintContents(GraphicsContext* context, const GlobalPaintFlags g lobalPaintFlags, const IntRect& damageRect) 3804 void FrameView::paintContents(GraphicsContext* context, const GlobalPaintFlags g lobalPaintFlags, const IntRect& damageRect)
3774 { 3805 {
3806 if (shouldThrottleRenderingPipeline())
3807 return;
3775 FramePainter(*this).paintContents(context, globalPaintFlags, damageRect); 3808 FramePainter(*this).paintContents(context, globalPaintFlags, damageRect);
3776 } 3809 }
3777 3810
3778 bool FrameView::isPointInScrollbarCorner(const IntPoint& windowPoint) 3811 bool FrameView::isPointInScrollbarCorner(const IntPoint& windowPoint)
3779 { 3812 {
3780 if (!scrollbarCornerPresent()) 3813 if (!scrollbarCornerPresent())
3781 return false; 3814 return false;
3782 3815
3783 IntPoint framePoint = convertFromContainingWindow(windowPoint); 3816 IntPoint framePoint = convertFromContainingWindow(windowPoint);
3784 3817
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
3952 } 3985 }
3953 3986
3954 void FrameView::collectFrameTimingRequests(GraphicsLayerFrameTimingRequests& gra phicsLayerTimingRequests) 3987 void FrameView::collectFrameTimingRequests(GraphicsLayerFrameTimingRequests& gra phicsLayerTimingRequests)
3955 { 3988 {
3956 if (!m_frame->isLocalFrame()) 3989 if (!m_frame->isLocalFrame())
3957 return; 3990 return;
3958 Frame* frame = m_frame.get(); 3991 Frame* frame = m_frame.get();
3959 LocalFrame* localFrame = toLocalFrame(frame); 3992 LocalFrame* localFrame = toLocalFrame(frame);
3960 LayoutRect viewRect = localFrame->contentLayoutObject()->viewRect(); 3993 LayoutRect viewRect = localFrame->contentLayoutObject()->viewRect();
3961 const LayoutBoxModelObject* paintInvalidationContainer = localFrame->content LayoutObject()->containerForPaintInvalidation(); 3994 const LayoutBoxModelObject* paintInvalidationContainer = localFrame->content LayoutObject()->containerForPaintInvalidation();
3995 // If the frame is being throttled, its compositing state may not be up to d ate.
3996 if (!paintInvalidationContainer->enclosingLayer()->isAllowedToQueryCompositi ngState())
3997 return;
3962 const GraphicsLayer* graphicsLayer = paintInvalidationContainer->enclosingLa yer()->graphicsLayerBacking(); 3998 const GraphicsLayer* graphicsLayer = paintInvalidationContainer->enclosingLa yer()->graphicsLayerBacking();
3963 3999
3964 if (!graphicsLayer) 4000 if (!graphicsLayer)
3965 return; 4001 return;
3966 4002
3967 DeprecatedPaintLayer::mapRectToPaintInvalidationBacking(localFrame->contentL ayoutObject(), paintInvalidationContainer, viewRect); 4003 DeprecatedPaintLayer::mapRectToPaintInvalidationBacking(localFrame->contentL ayoutObject(), paintInvalidationContainer, viewRect);
3968 4004
3969 graphicsLayerTimingRequests.add(graphicsLayer, Vector<std::pair<int64_t, Web Rect>>()).storedValue->value.append(std::make_pair(m_frame->frameID(), enclosing IntRect(viewRect))); 4005 graphicsLayerTimingRequests.add(graphicsLayer, Vector<std::pair<int64_t, Web Rect>>()).storedValue->value.append(std::make_pair(m_frame->frameID(), enclosing IntRect(viewRect)));
3970 } 4006 }
3971 4007
4008 void FrameView::updateViewportVisibilityIfNeeded()
4009 {
4010 // TODO(skyostil): Replace this with an intersection observer.
4011 ASSERT(shouldThrottleRenderingPipeline() || lifecycle().state() >= DocumentL ifecycle::PaintInvalidationClean);
4012 if (!m_needsUpdateViewportVisibility)
4013 return;
4014
4015 // Our frame's bounds in our parent's content coordinates.
4016 m_clippedBounds = frameRect();
4017 m_viewportVisibility = ViewportVisibility::Visible;
4018 m_needsUpdateViewportVisibility = false;
4019
4020 FrameView* parent = parentFrameView();
4021 if (!parent)
4022 return;
4023 ASSERT(!parent->m_needsUpdateViewportVisibility);
4024
4025 // If our parent is hidden, then we are too.
4026 if (parent->m_viewportVisibility == ViewportVisibility::Hidden) {
4027 m_viewportVisibility = ViewportVisibility::Hidden;
4028 return;
4029 }
4030
4031 // Transform our bounds into the root frame's content coordinate space.
4032 m_clippedBounds = parent->contentsToRootFrame(m_clippedBounds);
4033
4034 // TODO(skyostil): Expand the viewport to make it less likely to see stale c ontent while scrolling.
4035 IntRect viewport = parent->m_clippedBounds;
4036 m_clippedBounds.intersect(viewport);
4037
4038 // If our bounds got clipped away, we are invisible.
4039 if (m_clippedBounds.isEmpty())
4040 m_viewportVisibility = ViewportVisibility::Hidden;
4041 }
4042
4043 void FrameView::updateThrottling()
4044 {
4045 ASSERT(m_frame->isLocalRoot());
4046 updateThrottlingRecursive(SecurityOriginStatus::IsSameOrigin);
4047 }
4048
4049 void FrameView::updateThrottlingRecursive(SecurityOriginStatus securityOriginSta tus)
4050 {
4051 ASSERT(!isInPerformLayout());
4052 ASSERT(shouldThrottleRenderingPipeline() || lifecycle().state() >= DocumentL ifecycle::PaintInvalidationClean);
4053 bool wasThrottled = shouldThrottleRenderingPipeline();
4054
4055 updateViewportVisibilityIfNeeded();
4056
4057 // We only throttle the rendering pipeline in cross-origin frames. This is
4058 // to avoid a situation where an ancestor frame directly depends on the
4059 // pipeline timing of a descendant and breaks as a result of throttling.
4060 // The rationale is that cross-origin frames must already communicate with
4061 // asynchronous messages, they should be able to tolerate some delay in
4062 // receiving replies from a throttled peer.
4063 //
4064 // Check if we can access our parent's security origin. As an optimization
4065 // only do this if we are invisible.
4066 if (securityOriginStatus == SecurityOriginStatus::IsSameOrigin
4067 && parentFrameView() && m_viewportVisibility == ViewportVisibility::Hidd en) {
4068 const SecurityOrigin* origin = frame().securityContext()->securityOrigin ();
4069 const SecurityOrigin* parentOrigin = parentFrameView()->frame().security Context()->securityOrigin();
4070 if (!origin->canAccess(parentOrigin))
4071 securityOriginStatus = SecurityOriginStatus::IsCrossOrigin;
4072 }
4073 // FIXME: Always throttle for testing.
4074 securityOriginStatus = SecurityOriginStatus::IsCrossOrigin;
4075 m_securityOriginStatusForThrottling = securityOriginStatus;
4076
4077 bool becameUnthrottled = wasThrottled && !shouldThrottleRenderingPipeline();
4078 if (becameUnthrottled)
4079 page()->animator().scheduleVisualUpdate(m_frame.get());
4080
4081 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) {
4082 if (!child->isLocalFrame())
4083 continue;
4084 if (FrameView* view = toLocalFrame(child)->view())
4085 view->updateThrottlingRecursive(securityOriginStatus);
4086 }
4087 }
4088
4089 bool FrameView::shouldThrottleStyleLayoutAndCompositingUpdates() const
4090 {
4091 return lifecycle().throttlingMode() == DocumentLifecycle::ThrottlingMode::Al low
4092 && shouldThrottleRenderingPipeline();
4093 }
4094
4095 bool FrameView::shouldThrottleRenderingPipeline() const
4096 {
4097 // FIXME: Ignore for layout testing
4098 //if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled())
4099 //return false;
4100 return m_viewportVisibility == ViewportVisibility::Hidden
4101 && m_securityOriginStatusForThrottling == SecurityOriginStatus::IsCrossO rigin;
4102 }
4103
3972 } // namespace blink 4104 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698