OLD | NEW |
---|---|
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 #endif | 133 #endif |
134 , m_horizontalScrollbarMode(ScrollbarAuto) | 134 , m_horizontalScrollbarMode(ScrollbarAuto) |
135 , m_verticalScrollbarMode(ScrollbarAuto) | 135 , m_verticalScrollbarMode(ScrollbarAuto) |
136 , m_horizontalScrollbarLock(false) | 136 , m_horizontalScrollbarLock(false) |
137 , m_verticalScrollbarLock(false) | 137 , m_verticalScrollbarLock(false) |
138 , m_scrollbarsAvoidingResizer(0) | 138 , m_scrollbarsAvoidingResizer(0) |
139 , m_scrollbarsSuppressed(false) | 139 , m_scrollbarsSuppressed(false) |
140 , m_inUpdateScrollbars(false) | 140 , m_inUpdateScrollbars(false) |
141 , m_clipsRepaints(true) | 141 , m_clipsRepaints(true) |
142 , m_frameTimingRequestsDirty(true) | 142 , m_frameTimingRequestsDirty(true) |
143 | 143 , m_lifecycleThrottlingMode(LifecycleThrottlingMode::Disallow) |
144 , m_viewportVisibility(ViewportVisibility::Unknown) | |
145 , m_viewportVisibilityForThrottling(ViewportVisibility::Unknown) | |
146 , m_isCrossOriginForThrottling(false) | |
144 { | 147 { |
145 ASSERT(m_frame); | 148 ASSERT(m_frame); |
146 init(); | 149 init(); |
147 } | 150 } |
148 | 151 |
149 PassRefPtrWillBeRawPtr<FrameView> FrameView::create(LocalFrame* frame) | 152 PassRefPtrWillBeRawPtr<FrameView> FrameView::create(LocalFrame* frame) |
150 { | 153 { |
151 RefPtrWillBeRawPtr<FrameView> view = adoptRefWillBeNoop(new FrameView(frame) ); | 154 RefPtrWillBeRawPtr<FrameView> view = adoptRefWillBeNoop(new FrameView(frame) ); |
152 view->show(); | 155 view->show(); |
153 return view.release(); | 156 return view.release(); |
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1083 | 1086 |
1084 frame().document()->layoutUpdated(); | 1087 frame().document()->layoutUpdated(); |
1085 } | 1088 } |
1086 | 1089 |
1087 // The plan is to move to compositor-queried paint invalidation, in which case t his | 1090 // 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 | 1091 // method would setNeedsRedraw on the GraphicsLayers with invalidations and |
1089 // let the compositor pick which to actually draw. | 1092 // let the compositor pick which to actually draw. |
1090 // See http://crbug.com/306706 | 1093 // See http://crbug.com/306706 |
1091 void FrameView::invalidateTreeIfNeeded(PaintInvalidationState& paintInvalidation State) | 1094 void FrameView::invalidateTreeIfNeeded(PaintInvalidationState& paintInvalidation State) |
1092 { | 1095 { |
1096 if (shouldThrottleRenderingPipeline()) | |
1097 return; | |
1098 | |
1093 lifecycle().advanceTo(DocumentLifecycle::InPaintInvalidation); | 1099 lifecycle().advanceTo(DocumentLifecycle::InPaintInvalidation); |
1094 | 1100 |
1095 ASSERT(layoutView()); | 1101 ASSERT(layoutView()); |
1096 LayoutView& rootForPaintInvalidation = *layoutView(); | 1102 LayoutView& rootForPaintInvalidation = *layoutView(); |
1097 ASSERT(!rootForPaintInvalidation.needsLayout()); | 1103 ASSERT(!rootForPaintInvalidation.needsLayout()); |
1098 | 1104 |
1099 TRACE_EVENT1("blink", "FrameView::invalidateTree", "root", rootForPaintInval idation.debugName().ascii()); | 1105 TRACE_EVENT1("blink", "FrameView::invalidateTree", "root", rootForPaintInval idation.debugName().ascii()); |
1100 | 1106 |
1101 // In slimming paint mode we do per-object invalidation. | 1107 // In slimming paint mode we do per-object invalidation. |
1102 if (m_doFullPaintInvalidation && !RuntimeEnabledFeatures::slimmingPaintEnabl ed()) | 1108 if (m_doFullPaintInvalidation && !RuntimeEnabledFeatures::slimmingPaintEnabl ed()) |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1296 } | 1302 } |
1297 | 1303 |
1298 bool FrameView::shouldSetCursor() const | 1304 bool FrameView::shouldSetCursor() const |
1299 { | 1305 { |
1300 Page* page = frame().page(); | 1306 Page* page = frame().page(); |
1301 return page && page->visibilityState() != PageVisibilityStateHidden && page- >focusController().isActive() && page->settings().deviceSupportsMouse(); | 1307 return page && page->visibilityState() != PageVisibilityStateHidden && page- >focusController().isActive() && page->settings().deviceSupportsMouse(); |
1302 } | 1308 } |
1303 | 1309 |
1304 void FrameView::scrollContentsIfNeededRecursive() | 1310 void FrameView::scrollContentsIfNeededRecursive() |
1305 { | 1311 { |
1312 if (shouldThrottleStyleLayoutAndCompositingUpdates()) | |
1313 return; | |
1306 scrollContentsIfNeeded(); | 1314 scrollContentsIfNeeded(); |
1307 | 1315 |
1308 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { | 1316 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { |
1309 if (!child->isLocalFrame()) | 1317 if (!child->isLocalFrame()) |
1310 continue; | 1318 continue; |
1311 if (FrameView* view = toLocalFrame(child)->view()) | 1319 if (FrameView* view = toLocalFrame(child)->view()) |
1312 view->scrollContentsIfNeededRecursive(); | 1320 view->scrollContentsIfNeededRecursive(); |
1313 } | 1321 } |
1314 } | 1322 } |
1315 | 1323 |
1324 void FrameView::setLifecycleThrottlingModeRecursive(LifecycleThrottlingMode life cycleThrottlingMode) | |
esprehn
2015/09/02 21:10:37
This actually doesn't need to be recursive, you ca
Sami
2015/09/03 17:23:20
Neat, thanks!
| |
1325 { | |
1326 m_lifecycleThrottlingMode = lifecycleThrottlingMode; | |
1327 | |
1328 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { | |
1329 if (!child->isLocalFrame()) | |
1330 continue; | |
1331 if (FrameView* view = toLocalFrame(child)->view()) | |
1332 view->setLifecycleThrottlingModeRecursive(lifecycleThrottlingMode); | |
1333 } | |
1334 } | |
1335 | |
1316 bool FrameView::invalidateViewportConstrainedObjects() | 1336 bool FrameView::invalidateViewportConstrainedObjects() |
1317 { | 1337 { |
1318 for (const auto& viewportConstrainedObject : *m_viewportConstrainedObjects) { | 1338 for (const auto& viewportConstrainedObject : *m_viewportConstrainedObjects) { |
1319 LayoutObject* layoutObject = viewportConstrainedObject; | 1339 LayoutObject* layoutObject = viewportConstrainedObject; |
1320 ASSERT(layoutObject->style()->hasViewportConstrainedPosition()); | 1340 ASSERT(layoutObject->style()->hasViewportConstrainedPosition()); |
1321 ASSERT(layoutObject->hasLayer()); | 1341 ASSERT(layoutObject->hasLayer()); |
1322 DeprecatedPaintLayer* layer = toLayoutBoxModelObject(layoutObject)->laye r(); | 1342 DeprecatedPaintLayer* layer = toLayoutBoxModelObject(layoutObject)->laye r(); |
1323 | 1343 |
1324 if (layer->isPaintInvalidationContainer()) | 1344 if (layer->isPaintInvalidationContainer()) |
1325 continue; | 1345 continue; |
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2420 void FrameView::updateWidgetPositionsIfNeeded() | 2440 void FrameView::updateWidgetPositionsIfNeeded() |
2421 { | 2441 { |
2422 if (!m_needsUpdateWidgetPositions) | 2442 if (!m_needsUpdateWidgetPositions) |
2423 return; | 2443 return; |
2424 | 2444 |
2425 m_needsUpdateWidgetPositions = false; | 2445 m_needsUpdateWidgetPositions = false; |
2426 | 2446 |
2427 updateWidgetPositions(); | 2447 updateWidgetPositions(); |
2428 } | 2448 } |
2429 | 2449 |
2430 void FrameView::updateAllLifecyclePhases() | 2450 void FrameView::updateAllLifecyclePhases(LifecycleThrottlingMode lifecycleThrott lingMode) |
2431 { | 2451 { |
2432 frame().localFrameRoot()->view()->updateLifecyclePhasesInternal(AllPhases); | 2452 frame().localFrameRoot()->view()->updateLifecyclePhasesInternal(AllPhases, l ifecycleThrottlingMode); |
2433 } | 2453 } |
2434 | 2454 |
2435 // TODO(chrishtr): add a scrolling update lifecycle phase. | 2455 // TODO(chrishtr): add a scrolling update lifecycle phase. |
2436 void FrameView::updateLifecycleToCompositingCleanPlusScrolling() | 2456 void FrameView::updateLifecycleToCompositingCleanPlusScrolling(LifecycleThrottli ngMode lifecycleThrottlingMode) |
2437 { | 2457 { |
2438 frame().localFrameRoot()->view()->updateLifecyclePhasesInternal(OnlyUpToComp ositingCleanPlusScrolling); | 2458 frame().localFrameRoot()->view()->updateLifecyclePhasesInternal(OnlyUpToComp ositingCleanPlusScrolling, lifecycleThrottlingMode); |
2439 } | 2459 } |
2440 | 2460 |
2441 void FrameView::updateLifecyclePhasesInternal(LifeCycleUpdateOption phases) | 2461 void FrameView::updateLifecyclePhasesInternal(LifeCycleUpdateOption phases, Life cycleThrottlingMode lifecycleThrottlingMode) |
2442 { | 2462 { |
2443 // This must be called from the root frame, since it recurses down, not up. | 2463 // 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. | 2464 // Otherwise the lifecycles of the frames might be out of sync. |
2445 ASSERT(m_frame->isLocalRoot()); | 2465 ASSERT(m_frame->isLocalRoot()); |
2446 | 2466 |
2447 // Updating layout can run script, which can tear down the FrameView. | 2467 // Updating layout can run script, which can tear down the FrameView. |
2448 RefPtrWillBeRawPtr<FrameView> protector(this); | 2468 RefPtrWillBeRawPtr<FrameView> protector(this); |
2449 | 2469 |
2470 setLifecycleThrottlingModeRecursive(lifecycleThrottlingMode); | |
2450 updateStyleAndLayoutIfNeededRecursive(); | 2471 updateStyleAndLayoutIfNeededRecursive(); |
2451 | 2472 |
2452 if (LayoutView* view = layoutView()) { | 2473 if (LayoutView* view = layoutView()) { |
2453 TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", InspectorUp dateLayerTreeEvent::data(m_frame.get())); | 2474 TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", InspectorUp dateLayerTreeEvent::data(m_frame.get())); |
2454 | 2475 |
2455 // This was required for slimming paint v1 but is only temporarily | 2476 // This was required for slimming paint v1 but is only temporarily |
2456 // needed for slimming paint v2. | 2477 // needed for slimming paint v2. |
2457 view->compositor()->updateIfNeededRecursive(); | 2478 view->compositor()->updateIfNeededRecursive(); |
2458 scrollContentsIfNeededRecursive(); | 2479 scrollContentsIfNeededRecursive(); |
2459 | 2480 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2544 collectFrameTimingRequestsRecursive(graphicsLayerTimingRequests); | 2565 collectFrameTimingRequestsRecursive(graphicsLayerTimingRequests); |
2545 | 2566 |
2546 for (const auto& iter : graphicsLayerTimingRequests) { | 2567 for (const auto& iter : graphicsLayerTimingRequests) { |
2547 const GraphicsLayer* graphicsLayer = iter.key; | 2568 const GraphicsLayer* graphicsLayer = iter.key; |
2548 graphicsLayer->platformLayer()->setFrameTimingRequests(iter.value); | 2569 graphicsLayer->platformLayer()->setFrameTimingRequests(iter.value); |
2549 } | 2570 } |
2550 } | 2571 } |
2551 | 2572 |
2552 void FrameView::updateStyleAndLayoutIfNeededRecursive() | 2573 void FrameView::updateStyleAndLayoutIfNeededRecursive() |
2553 { | 2574 { |
2575 if (shouldThrottleStyleLayoutAndCompositingUpdates()) | |
2576 return; | |
2577 | |
2554 // We have to crawl our entire subtree looking for any FrameViews that need | 2578 // We have to crawl our entire subtree looking for any FrameViews that need |
2555 // layout and make sure they are up to date. | 2579 // layout and make sure they are up to date. |
2556 // Mac actually tests for intersection with the dirty region and tries not t o | 2580 // Mac actually tests for intersection with the dirty region and tries not t o |
2557 // update layout for frames that are outside the dirty region. Not only doe s this seem | 2581 // update layout for frames that are outside the dirty region. Not only doe s this seem |
2558 // pointless (since those frames will have set a zero timer to layout anyway ), but | 2582 // pointless (since those frames will have set a zero timer to layout anyway ), but |
2559 // it is also incorrect, since if two frames overlap, the first could be exc luded from the dirty | 2583 // it is also incorrect, since if two frames overlap, the first could be exc luded from the dirty |
2560 // region but then become included later by the second frame adding rects to the dirty region | 2584 // region but then become included later by the second frame adding rects to the dirty region |
2561 // when it lays out. | 2585 // when it lays out. |
2562 | 2586 |
2563 m_frame->document()->updateLayoutTreeIfNeeded(); | 2587 m_frame->document()->updateLayoutTreeIfNeeded(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2595 #if ENABLE(ASSERT) | 2619 #if ENABLE(ASSERT) |
2596 m_frame->document()->layoutView()->assertLaidOut(); | 2620 m_frame->document()->layoutView()->assertLaidOut(); |
2597 #endif | 2621 #endif |
2598 | 2622 |
2599 updateWidgetPositionsIfNeeded(); | 2623 updateWidgetPositionsIfNeeded(); |
2600 } | 2624 } |
2601 | 2625 |
2602 void FrameView::invalidateTreeIfNeededRecursive() | 2626 void FrameView::invalidateTreeIfNeededRecursive() |
2603 { | 2627 { |
2604 ASSERT(layoutView()); | 2628 ASSERT(layoutView()); |
2629 | |
2630 // We need to stop recursing here since a child frame view might not be thro ttled | |
2631 // even though we are (e.g., it didn't compute its visibility yet). | |
2632 if (shouldThrottleRenderingPipeline()) | |
2633 return; | |
2605 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root", layoutView()->debugName().ascii()); | 2634 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root", layoutView()->debugName().ascii()); |
2606 | 2635 |
2607 Vector<LayoutObject*> pendingDelayedPaintInvalidations; | 2636 Vector<LayoutObject*> pendingDelayedPaintInvalidations; |
2608 PaintInvalidationState rootPaintInvalidationState(*layoutView(), pendingDela yedPaintInvalidations); | 2637 PaintInvalidationState rootPaintInvalidationState(*layoutView(), pendingDela yedPaintInvalidations); |
2609 | 2638 |
2610 invalidateTreeIfNeeded(rootPaintInvalidationState); | 2639 invalidateTreeIfNeeded(rootPaintInvalidationState); |
2611 | 2640 |
2612 // Some frames may be not reached during the above invalidateTreeIfNeeded be cause | 2641 // Some frames may be not reached during the above invalidateTreeIfNeeded be cause |
2613 // - the frame is a detached frame; or | 2642 // - the frame is a detached frame; or |
2614 // - it didn't need paint invalidation. | 2643 // - it didn't need paint invalidation. |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2921 | 2950 |
2922 if (m_scrollbarsAvoidingResizer && parent()) | 2951 if (m_scrollbarsAvoidingResizer && parent()) |
2923 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(-m_scrollbar sAvoidingResizer); | 2952 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(-m_scrollbar sAvoidingResizer); |
2924 | 2953 |
2925 Widget::setParent(parentView); | 2954 Widget::setParent(parentView); |
2926 | 2955 |
2927 if (m_scrollbarsAvoidingResizer && parent()) | 2956 if (m_scrollbarsAvoidingResizer && parent()) |
2928 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(m_scrollbars AvoidingResizer); | 2957 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(m_scrollbars AvoidingResizer); |
2929 | 2958 |
2930 updateScrollableAreaSet(); | 2959 updateScrollableAreaSet(); |
2960 computeViewportVisibility(); | |
2931 } | 2961 } |
2932 | 2962 |
2933 void FrameView::removeChild(Widget* child) | 2963 void FrameView::removeChild(Widget* child) |
2934 { | 2964 { |
2935 ASSERT(child->parent() == this); | 2965 ASSERT(child->parent() == this); |
2936 | 2966 |
2937 if (child->isFrameView()) | 2967 if (child->isFrameView()) |
2938 removeScrollableArea(toFrameView(child)); | 2968 removeScrollableArea(toFrameView(child)); |
2939 | 2969 |
2940 child->setParent(0); | 2970 child->setParent(0); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2978 return; | 3008 return; |
2979 page->chromeClient().setCursor(cursor); | 3009 page->chromeClient().setCursor(cursor); |
2980 } | 3010 } |
2981 | 3011 |
2982 void FrameView::frameRectsChanged() | 3012 void FrameView::frameRectsChanged() |
2983 { | 3013 { |
2984 TRACE_EVENT0("blink", "FrameView::frameRectsChanged"); | 3014 TRACE_EVENT0("blink", "FrameView::frameRectsChanged"); |
2985 if (layoutSizeFixedToFrameSize()) | 3015 if (layoutSizeFixedToFrameSize()) |
2986 setLayoutSizeInternal(frameRect().size()); | 3016 setLayoutSizeInternal(frameRect().size()); |
2987 | 3017 |
3018 computeViewportVisibility(); | |
2988 for (const auto& child : m_children) | 3019 for (const auto& child : m_children) |
2989 child->frameRectsChanged(); | 3020 child->frameRectsChanged(); |
2990 } | 3021 } |
2991 | 3022 |
2992 void FrameView::setLayoutSizeInternal(const IntSize& size) | 3023 void FrameView::setLayoutSizeInternal(const IntSize& size) |
2993 { | 3024 { |
2994 if (m_layoutSize == size) | 3025 if (m_layoutSize == size) |
2995 return; | 3026 return; |
2996 | 3027 |
2997 m_layoutSize = size; | 3028 m_layoutSize = size; |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3768 return ScrollBehaviorInstant; | 3799 return ScrollBehaviorInstant; |
3769 } | 3800 } |
3770 | 3801 |
3771 void FrameView::paint(GraphicsContext* context, const IntRect& rect) | 3802 void FrameView::paint(GraphicsContext* context, const IntRect& rect) |
3772 { | 3803 { |
3773 paint(context, GlobalPaintNormalPhase, rect); | 3804 paint(context, GlobalPaintNormalPhase, rect); |
3774 } | 3805 } |
3775 | 3806 |
3776 void FrameView::paint(GraphicsContext* context, const GlobalPaintFlags globalPai ntFlags, const IntRect& rect) | 3807 void FrameView::paint(GraphicsContext* context, const GlobalPaintFlags globalPai ntFlags, const IntRect& rect) |
3777 { | 3808 { |
3809 if (shouldThrottleRenderingPipeline()) | |
3810 return; | |
3778 FramePainter(*this).paint(context, globalPaintFlags, rect); | 3811 FramePainter(*this).paint(context, globalPaintFlags, rect); |
3779 } | 3812 } |
3780 | 3813 |
3781 void FrameView::paintContents(GraphicsContext* context, const GlobalPaintFlags g lobalPaintFlags, const IntRect& damageRect) | 3814 void FrameView::paintContents(GraphicsContext* context, const GlobalPaintFlags g lobalPaintFlags, const IntRect& damageRect) |
3782 { | 3815 { |
3816 if (shouldThrottleRenderingPipeline()) | |
3817 return; | |
3783 FramePainter(*this).paintContents(context, globalPaintFlags, damageRect); | 3818 FramePainter(*this).paintContents(context, globalPaintFlags, damageRect); |
3784 } | 3819 } |
3785 | 3820 |
3786 bool FrameView::isPointInScrollbarCorner(const IntPoint& windowPoint) | 3821 bool FrameView::isPointInScrollbarCorner(const IntPoint& windowPoint) |
3787 { | 3822 { |
3788 if (!scrollbarCornerPresent()) | 3823 if (!scrollbarCornerPresent()) |
3789 return false; | 3824 return false; |
3790 | 3825 |
3791 IntPoint framePoint = convertFromContainingWindow(windowPoint); | 3826 IntPoint framePoint = convertFromContainingWindow(windowPoint); |
3792 | 3827 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3960 } | 3995 } |
3961 | 3996 |
3962 void FrameView::collectFrameTimingRequests(GraphicsLayerFrameTimingRequests& gra phicsLayerTimingRequests) | 3997 void FrameView::collectFrameTimingRequests(GraphicsLayerFrameTimingRequests& gra phicsLayerTimingRequests) |
3963 { | 3998 { |
3964 if (!m_frame->isLocalFrame()) | 3999 if (!m_frame->isLocalFrame()) |
3965 return; | 4000 return; |
3966 Frame* frame = m_frame.get(); | 4001 Frame* frame = m_frame.get(); |
3967 LocalFrame* localFrame = toLocalFrame(frame); | 4002 LocalFrame* localFrame = toLocalFrame(frame); |
3968 LayoutRect viewRect = localFrame->contentLayoutObject()->viewRect(); | 4003 LayoutRect viewRect = localFrame->contentLayoutObject()->viewRect(); |
3969 const LayoutBoxModelObject* paintInvalidationContainer = localFrame->content LayoutObject()->containerForPaintInvalidation(); | 4004 const LayoutBoxModelObject* paintInvalidationContainer = localFrame->content LayoutObject()->containerForPaintInvalidation(); |
4005 // If the frame is being throttled, its compositing state may not be up to d ate. | |
4006 if (!paintInvalidationContainer->enclosingLayer()->isAllowedToQueryCompositi ngState()) | |
4007 return; | |
3970 const GraphicsLayer* graphicsLayer = paintInvalidationContainer->enclosingLa yer()->graphicsLayerBacking(); | 4008 const GraphicsLayer* graphicsLayer = paintInvalidationContainer->enclosingLa yer()->graphicsLayerBacking(); |
3971 | 4009 |
3972 if (!graphicsLayer) | 4010 if (!graphicsLayer) |
3973 return; | 4011 return; |
3974 | 4012 |
3975 DeprecatedPaintLayer::mapRectToPaintInvalidationBacking(localFrame->contentL ayoutObject(), paintInvalidationContainer, viewRect); | 4013 DeprecatedPaintLayer::mapRectToPaintInvalidationBacking(localFrame->contentL ayoutObject(), paintInvalidationContainer, viewRect); |
3976 | 4014 |
3977 graphicsLayerTimingRequests.add(graphicsLayer, Vector<std::pair<int64_t, Web Rect>>()).storedValue->value.append(std::make_pair(m_frame->frameID(), enclosing IntRect(viewRect))); | 4015 graphicsLayerTimingRequests.add(graphicsLayer, Vector<std::pair<int64_t, Web Rect>>()).storedValue->value.append(std::make_pair(m_frame->frameID(), enclosing IntRect(viewRect))); |
3978 } | 4016 } |
3979 | 4017 |
4018 void FrameView::computeViewportVisibility() | |
4019 { | |
4020 // TODO(skyostil): Replace this with a position observer. | |
esprehn
2015/09/02 21:10:37
This needs lifecycle asserts, what phases is this
Sami
2015/09/03 17:23:20
Yeah, agreed. Since frameRectsChanged() is called
| |
4021 | |
4022 // Our frame's bounds in our parent's content coordinates. | |
4023 m_clippedBounds = frameRect(); | |
4024 m_viewportVisibility = ViewportVisibility::Visible; | |
4025 | |
4026 FrameView* parent = parentFrameView(); | |
4027 if (!parent) | |
4028 return; | |
4029 | |
4030 // If our parent has indeterminate visibility, then so do we. | |
4031 if (parent->m_viewportVisibility == ViewportVisibility::Unknown) { | |
4032 m_viewportVisibility = ViewportVisibility::Unknown; | |
4033 return; | |
4034 } | |
4035 | |
4036 // If our parent is hidden, then we are too. | |
4037 if (parent->m_viewportVisibility == ViewportVisibility::Hidden) { | |
4038 m_viewportVisibility = ViewportVisibility::Hidden; | |
4039 return; | |
4040 } | |
4041 | |
4042 // Transform our bounds into the root frame's content coordinate space. | |
4043 m_clippedBounds = parent->contentsToRootFrame(m_clippedBounds); | |
4044 | |
4045 // TODO(skyostil): Expand the viewport to make it less likely to see stale c ontent while scrolling. | |
4046 IntRect viewport = parent->m_clippedBounds; | |
4047 m_clippedBounds.intersect(viewport); | |
4048 | |
4049 // If our bounds got clipped away, we are invisible. | |
4050 if (m_clippedBounds.isEmpty()) | |
4051 m_viewportVisibility = ViewportVisibility::Hidden; | |
4052 } | |
4053 | |
4054 void FrameView::updateThrottling() | |
4055 { | |
4056 ASSERT(m_frame->isLocalRoot()); | |
4057 updateThrottlingRecursive(false); | |
esprehn
2015/09/02 21:10:37
This boolean is not clear.
Sami
2015/09/03 17:23:20
Replaced with an enum.
| |
4058 } | |
4059 | |
4060 void FrameView::updateThrottlingRecursive(bool hasCrossedSecurityOrigin) | |
4061 { | |
4062 ASSERT(!isInPerformLayout()); | |
4063 bool wasThrottled = shouldThrottleRenderingPipeline(); | |
4064 | |
4065 // Visibility should never go back to an unknown state. | |
4066 ASSERT(m_viewportVisibility != ViewportVisibility::Unknown | |
4067 || m_viewportVisibilityForThrottling == ViewportVisibility::Unknown); | |
esprehn
2015/09/02 21:10:37
Lets remove the Unknown state, you're either visib
Sami
2015/09/03 17:23:20
Ok, let's default to visible.
| |
4068 m_viewportVisibilityForThrottling = m_viewportVisibility; | |
4069 | |
4070 // Check if we can access our parent's security origin. As an optimization o nly do this if we are invisible. | |
4071 if (!hasCrossedSecurityOrigin && parentFrameView() && m_viewportVisibilityFo rThrottling == ViewportVisibility::Hidden) { | |
esprehn
2015/09/02 21:10:37
What's the reason for this?
Sami
2015/09/03 17:23:20
Added a big comment, but the tl;dr is that we want
| |
4072 const SecurityOrigin* origin = frame().securityContext()->securityOrigin (); | |
4073 const SecurityOrigin* parentOrigin = parentFrameView()->frame().security Context()->securityOrigin(); | |
4074 hasCrossedSecurityOrigin = !origin->canAccess(parentOrigin); | |
Mike West
2015/09/02 11:30:08
This looks pretty reasonable.
That said:
1. Do w
Sami
2015/09/03 14:07:56
Great, thanks for checking.
| |
4075 } | |
4076 // FIXME: Always throttle for testing. | |
4077 hasCrossedSecurityOrigin = true; | |
4078 m_isCrossOriginForThrottling = hasCrossedSecurityOrigin; | |
4079 | |
4080 bool becameUnthrottled = wasThrottled && !shouldThrottleRenderingPipeline(); | |
4081 if (becameUnthrottled) | |
4082 page()->animator().scheduleVisualUpdate(m_frame.get()); | |
4083 | |
4084 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { | |
4085 if (!child->isLocalFrame()) | |
4086 continue; | |
4087 if (FrameView* view = toLocalFrame(child)->view()) | |
4088 view->updateThrottlingRecursive(hasCrossedSecurityOrigin); | |
4089 } | |
4090 } | |
4091 | |
4092 bool FrameView::shouldThrottleStyleLayoutAndCompositingUpdates() const | |
4093 { | |
4094 return m_lifecycleThrottlingMode == LifecycleThrottlingMode::Allow | |
esprehn
2015/09/02 21:10:37
This bit seems like it should be in the DocumentLi
Sami
2015/09/03 17:23:20
Good idea, done.
| |
4095 && shouldThrottleRenderingPipeline(); | |
4096 } | |
4097 | |
4098 bool FrameView::shouldThrottleRenderingPipeline() const | |
4099 { | |
4100 // FIXME: Ignore for layout testing | |
4101 //if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) | |
4102 //return false; | |
4103 return parent() | |
esprehn
2015/09/02 21:10:37
This parent check shouldn't be needed.
Sami
2015/09/03 17:23:20
Done.
| |
4104 && m_viewportVisibilityForThrottling == ViewportVisibility::Hidden | |
4105 && m_isCrossOriginForThrottling; | |
4106 } | |
4107 | |
3980 } // namespace blink | 4108 } // namespace blink |
OLD | NEW |