Chromium Code Reviews| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2544 collectFrameTimingRequestsRecursive(graphicsLayerTimingRequests); | 2563 collectFrameTimingRequestsRecursive(graphicsLayerTimingRequests); |
| 2545 | 2564 |
| 2546 for (const auto& iter : graphicsLayerTimingRequests) { | 2565 for (const auto& iter : graphicsLayerTimingRequests) { |
| 2547 const GraphicsLayer* graphicsLayer = iter.key; | 2566 const GraphicsLayer* graphicsLayer = iter.key; |
| 2548 graphicsLayer->platformLayer()->setFrameTimingRequests(iter.value); | 2567 graphicsLayer->platformLayer()->setFrameTimingRequests(iter.value); |
| 2549 } | 2568 } |
| 2550 } | 2569 } |
| 2551 | 2570 |
| 2552 void FrameView::updateStyleAndLayoutIfNeededRecursive() | 2571 void FrameView::updateStyleAndLayoutIfNeededRecursive() |
| 2553 { | 2572 { |
| 2573 if (shouldThrottleStyleLayoutAndCompositingUpdates()) | |
| 2574 return; | |
| 2575 | |
| 2554 // We have to crawl our entire subtree looking for any FrameViews that need | 2576 // We have to crawl our entire subtree looking for any FrameViews that need |
| 2555 // layout and make sure they are up to date. | 2577 // layout and make sure they are up to date. |
| 2556 // Mac actually tests for intersection with the dirty region and tries not t o | 2578 // 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 | 2579 // 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 | 2580 // 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 | 2581 // 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 | 2582 // region but then become included later by the second frame adding rects to the dirty region |
| 2561 // when it lays out. | 2583 // when it lays out. |
| 2562 | 2584 |
| 2563 m_frame->document()->updateLayoutTreeIfNeeded(); | 2585 m_frame->document()->updateLayoutTreeIfNeeded(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2595 #if ENABLE(ASSERT) | 2617 #if ENABLE(ASSERT) |
| 2596 m_frame->document()->layoutView()->assertLaidOut(); | 2618 m_frame->document()->layoutView()->assertLaidOut(); |
| 2597 #endif | 2619 #endif |
| 2598 | 2620 |
| 2599 updateWidgetPositionsIfNeeded(); | 2621 updateWidgetPositionsIfNeeded(); |
| 2600 } | 2622 } |
| 2601 | 2623 |
| 2602 void FrameView::invalidateTreeIfNeededRecursive() | 2624 void FrameView::invalidateTreeIfNeededRecursive() |
| 2603 { | 2625 { |
| 2604 ASSERT(layoutView()); | 2626 ASSERT(layoutView()); |
| 2627 | |
| 2628 // We need to stop recursing here since a child frame view might not be thro ttled | |
| 2629 // even though we are (e.g., it didn't compute its visibility yet). | |
| 2630 if (shouldThrottleRenderingPipeline()) | |
| 2631 return; | |
| 2605 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root", layoutView()->debugName().ascii()); | 2632 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root", layoutView()->debugName().ascii()); |
| 2606 | 2633 |
| 2607 Vector<LayoutObject*> pendingDelayedPaintInvalidations; | 2634 Vector<LayoutObject*> pendingDelayedPaintInvalidations; |
| 2608 PaintInvalidationState rootPaintInvalidationState(*layoutView(), pendingDela yedPaintInvalidations); | 2635 PaintInvalidationState rootPaintInvalidationState(*layoutView(), pendingDela yedPaintInvalidations); |
| 2609 | 2636 |
| 2610 invalidateTreeIfNeeded(rootPaintInvalidationState); | 2637 invalidateTreeIfNeeded(rootPaintInvalidationState); |
| 2611 | 2638 |
| 2612 // Some frames may be not reached during the above invalidateTreeIfNeeded be cause | 2639 // Some frames may be not reached during the above invalidateTreeIfNeeded be cause |
| 2613 // - the frame is a detached frame; or | 2640 // - the frame is a detached frame; or |
| 2614 // - it didn't need paint invalidation. | 2641 // - it didn't need paint invalidation. |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2921 | 2948 |
| 2922 if (m_scrollbarsAvoidingResizer && parent()) | 2949 if (m_scrollbarsAvoidingResizer && parent()) |
| 2923 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(-m_scrollbar sAvoidingResizer); | 2950 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(-m_scrollbar sAvoidingResizer); |
| 2924 | 2951 |
| 2925 Widget::setParent(parentView); | 2952 Widget::setParent(parentView); |
| 2926 | 2953 |
| 2927 if (m_scrollbarsAvoidingResizer && parent()) | 2954 if (m_scrollbarsAvoidingResizer && parent()) |
| 2928 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(m_scrollbars AvoidingResizer); | 2955 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(m_scrollbars AvoidingResizer); |
| 2929 | 2956 |
| 2930 updateScrollableAreaSet(); | 2957 updateScrollableAreaSet(); |
| 2958 m_needsUpdateViewportVisibility = true; | |
| 2931 } | 2959 } |
| 2932 | 2960 |
| 2933 void FrameView::removeChild(Widget* child) | 2961 void FrameView::removeChild(Widget* child) |
| 2934 { | 2962 { |
| 2935 ASSERT(child->parent() == this); | 2963 ASSERT(child->parent() == this); |
| 2936 | 2964 |
| 2937 if (child->isFrameView()) | 2965 if (child->isFrameView()) |
| 2938 removeScrollableArea(toFrameView(child)); | 2966 removeScrollableArea(toFrameView(child)); |
| 2939 | 2967 |
| 2940 child->setParent(0); | 2968 child->setParent(0); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2978 return; | 3006 return; |
| 2979 page->chromeClient().setCursor(cursor); | 3007 page->chromeClient().setCursor(cursor); |
| 2980 } | 3008 } |
| 2981 | 3009 |
| 2982 void FrameView::frameRectsChanged() | 3010 void FrameView::frameRectsChanged() |
| 2983 { | 3011 { |
| 2984 TRACE_EVENT0("blink", "FrameView::frameRectsChanged"); | 3012 TRACE_EVENT0("blink", "FrameView::frameRectsChanged"); |
| 2985 if (layoutSizeFixedToFrameSize()) | 3013 if (layoutSizeFixedToFrameSize()) |
| 2986 setLayoutSizeInternal(frameRect().size()); | 3014 setLayoutSizeInternal(frameRect().size()); |
| 2987 | 3015 |
| 3016 m_needsUpdateViewportVisibility = true; | |
| 2988 for (const auto& child : m_children) | 3017 for (const auto& child : m_children) |
| 2989 child->frameRectsChanged(); | 3018 child->frameRectsChanged(); |
| 2990 } | 3019 } |
| 2991 | 3020 |
| 2992 void FrameView::setLayoutSizeInternal(const IntSize& size) | 3021 void FrameView::setLayoutSizeInternal(const IntSize& size) |
| 2993 { | 3022 { |
| 2994 if (m_layoutSize == size) | 3023 if (m_layoutSize == size) |
| 2995 return; | 3024 return; |
| 2996 | 3025 |
| 2997 m_layoutSize = size; | 3026 m_layoutSize = size; |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3768 return ScrollBehaviorInstant; | 3797 return ScrollBehaviorInstant; |
| 3769 } | 3798 } |
| 3770 | 3799 |
| 3771 void FrameView::paint(GraphicsContext* context, const IntRect& rect) | 3800 void FrameView::paint(GraphicsContext* context, const IntRect& rect) |
| 3772 { | 3801 { |
| 3773 paint(context, GlobalPaintNormalPhase, rect); | 3802 paint(context, GlobalPaintNormalPhase, rect); |
| 3774 } | 3803 } |
| 3775 | 3804 |
| 3776 void FrameView::paint(GraphicsContext* context, const GlobalPaintFlags globalPai ntFlags, const IntRect& rect) | 3805 void FrameView::paint(GraphicsContext* context, const GlobalPaintFlags globalPai ntFlags, const IntRect& rect) |
| 3777 { | 3806 { |
| 3807 if (shouldThrottleRenderingPipeline()) | |
|
chrishtr
2015/09/03 18:03:58
This is not the right place. Instead you should pu
| |
| 3808 return; | |
| 3778 FramePainter(*this).paint(context, globalPaintFlags, rect); | 3809 FramePainter(*this).paint(context, globalPaintFlags, rect); |
| 3779 } | 3810 } |
| 3780 | 3811 |
| 3781 void FrameView::paintContents(GraphicsContext* context, const GlobalPaintFlags g lobalPaintFlags, const IntRect& damageRect) | 3812 void FrameView::paintContents(GraphicsContext* context, const GlobalPaintFlags g lobalPaintFlags, const IntRect& damageRect) |
| 3782 { | 3813 { |
| 3814 if (shouldThrottleRenderingPipeline()) | |
| 3815 return; | |
| 3783 FramePainter(*this).paintContents(context, globalPaintFlags, damageRect); | 3816 FramePainter(*this).paintContents(context, globalPaintFlags, damageRect); |
| 3784 } | 3817 } |
| 3785 | 3818 |
| 3786 bool FrameView::isPointInScrollbarCorner(const IntPoint& windowPoint) | 3819 bool FrameView::isPointInScrollbarCorner(const IntPoint& windowPoint) |
| 3787 { | 3820 { |
| 3788 if (!scrollbarCornerPresent()) | 3821 if (!scrollbarCornerPresent()) |
| 3789 return false; | 3822 return false; |
| 3790 | 3823 |
| 3791 IntPoint framePoint = convertFromContainingWindow(windowPoint); | 3824 IntPoint framePoint = convertFromContainingWindow(windowPoint); |
| 3792 | 3825 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3960 } | 3993 } |
| 3961 | 3994 |
| 3962 void FrameView::collectFrameTimingRequests(GraphicsLayerFrameTimingRequests& gra phicsLayerTimingRequests) | 3995 void FrameView::collectFrameTimingRequests(GraphicsLayerFrameTimingRequests& gra phicsLayerTimingRequests) |
| 3963 { | 3996 { |
| 3964 if (!m_frame->isLocalFrame()) | 3997 if (!m_frame->isLocalFrame()) |
| 3965 return; | 3998 return; |
| 3966 Frame* frame = m_frame.get(); | 3999 Frame* frame = m_frame.get(); |
| 3967 LocalFrame* localFrame = toLocalFrame(frame); | 4000 LocalFrame* localFrame = toLocalFrame(frame); |
| 3968 LayoutRect viewRect = localFrame->contentLayoutObject()->viewRect(); | 4001 LayoutRect viewRect = localFrame->contentLayoutObject()->viewRect(); |
| 3969 const LayoutBoxModelObject* paintInvalidationContainer = localFrame->content LayoutObject()->containerForPaintInvalidation(); | 4002 const LayoutBoxModelObject* paintInvalidationContainer = localFrame->content LayoutObject()->containerForPaintInvalidation(); |
| 4003 // If the frame is being throttled, its compositing state may not be up to d ate. | |
| 4004 if (!paintInvalidationContainer->enclosingLayer()->isAllowedToQueryCompositi ngState()) | |
| 4005 return; | |
| 3970 const GraphicsLayer* graphicsLayer = paintInvalidationContainer->enclosingLa yer()->graphicsLayerBacking(); | 4006 const GraphicsLayer* graphicsLayer = paintInvalidationContainer->enclosingLa yer()->graphicsLayerBacking(); |
| 3971 | 4007 |
| 3972 if (!graphicsLayer) | 4008 if (!graphicsLayer) |
| 3973 return; | 4009 return; |
| 3974 | 4010 |
| 3975 DeprecatedPaintLayer::mapRectToPaintInvalidationBacking(localFrame->contentL ayoutObject(), paintInvalidationContainer, viewRect); | 4011 DeprecatedPaintLayer::mapRectToPaintInvalidationBacking(localFrame->contentL ayoutObject(), paintInvalidationContainer, viewRect); |
| 3976 | 4012 |
| 3977 graphicsLayerTimingRequests.add(graphicsLayer, Vector<std::pair<int64_t, Web Rect>>()).storedValue->value.append(std::make_pair(m_frame->frameID(), enclosing IntRect(viewRect))); | 4013 graphicsLayerTimingRequests.add(graphicsLayer, Vector<std::pair<int64_t, Web Rect>>()).storedValue->value.append(std::make_pair(m_frame->frameID(), enclosing IntRect(viewRect))); |
| 3978 } | 4014 } |
| 3979 | 4015 |
| 4016 void FrameView::updateViewportVisibilityIfNeeded() | |
| 4017 { | |
| 4018 // TODO(skyostil): Replace this with an intersection observer. | |
| 4019 ASSERT(shouldThrottleRenderingPipeline() || lifecycle().state() >= DocumentL ifecycle::PaintInvalidationClean); | |
| 4020 if (!m_needsUpdateViewportVisibility) | |
| 4021 return; | |
| 4022 | |
| 4023 // Our frame's bounds in our parent's content coordinates. | |
| 4024 m_clippedBounds = frameRect(); | |
| 4025 m_viewportVisibility = ViewportVisibility::Visible; | |
| 4026 m_needsUpdateViewportVisibility = false; | |
| 4027 | |
| 4028 FrameView* parent = parentFrameView(); | |
| 4029 if (!parent) | |
| 4030 return; | |
| 4031 ASSERT(!parent->m_needsUpdateViewportVisibility); | |
| 4032 | |
| 4033 // If our parent is hidden, then we are too. | |
| 4034 if (parent->m_viewportVisibility == ViewportVisibility::Hidden) { | |
| 4035 m_viewportVisibility = ViewportVisibility::Hidden; | |
| 4036 return; | |
| 4037 } | |
| 4038 | |
| 4039 // Transform our bounds into the root frame's content coordinate space. | |
| 4040 m_clippedBounds = parent->contentsToRootFrame(m_clippedBounds); | |
| 4041 | |
| 4042 // TODO(skyostil): Expand the viewport to make it less likely to see stale c ontent while scrolling. | |
| 4043 IntRect viewport = parent->m_clippedBounds; | |
| 4044 m_clippedBounds.intersect(viewport); | |
| 4045 | |
| 4046 // If our bounds got clipped away, we are invisible. | |
| 4047 if (m_clippedBounds.isEmpty()) | |
| 4048 m_viewportVisibility = ViewportVisibility::Hidden; | |
| 4049 } | |
| 4050 | |
| 4051 void FrameView::updateThrottling() | |
| 4052 { | |
| 4053 ASSERT(m_frame->isLocalRoot()); | |
| 4054 updateThrottlingRecursive(SecurityOriginStatus::IsSameOrigin); | |
| 4055 } | |
| 4056 | |
| 4057 void FrameView::updateThrottlingRecursive(SecurityOriginStatus securityOriginSta tus) | |
| 4058 { | |
| 4059 ASSERT(!isInPerformLayout()); | |
| 4060 ASSERT(shouldThrottleRenderingPipeline() || lifecycle().state() >= DocumentL ifecycle::PaintInvalidationClean); | |
| 4061 bool wasThrottled = shouldThrottleRenderingPipeline(); | |
| 4062 | |
| 4063 updateViewportVisibilityIfNeeded(); | |
| 4064 | |
| 4065 // We only throttle the rendering pipeline in cross-origin frames. This is | |
| 4066 // to avoid a situation where an ancestor frame directly depends on the | |
| 4067 // pipeline timing of a descendant and breaks as a result of throttling. | |
| 4068 // The rationale is that cross-origin frames must already communicate with | |
| 4069 // asynchronous messages, they should be able to tolerate some delay in | |
| 4070 // receiving replies from a throttled peer. | |
| 4071 // | |
| 4072 // Check if we can access our parent's security origin. As an optimization | |
| 4073 // only do this if we are invisible. | |
| 4074 if (securityOriginStatus == SecurityOriginStatus::IsSameOrigin | |
| 4075 && parentFrameView() && m_viewportVisibility == ViewportVisibility::Hidd en) { | |
| 4076 const SecurityOrigin* origin = frame().securityContext()->securityOrigin (); | |
| 4077 const SecurityOrigin* parentOrigin = parentFrameView()->frame().security Context()->securityOrigin(); | |
| 4078 if (!origin->canAccess(parentOrigin)) | |
| 4079 securityOriginStatus = SecurityOriginStatus::IsCrossOrigin; | |
| 4080 } | |
| 4081 // FIXME: Always throttle for testing. | |
| 4082 securityOriginStatus = SecurityOriginStatus::IsCrossOrigin; | |
| 4083 m_securityOriginStatusForThrottling = securityOriginStatus; | |
| 4084 | |
| 4085 bool becameUnthrottled = wasThrottled && !shouldThrottleRenderingPipeline(); | |
| 4086 if (becameUnthrottled) | |
| 4087 page()->animator().scheduleVisualUpdate(m_frame.get()); | |
| 4088 | |
| 4089 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { | |
| 4090 if (!child->isLocalFrame()) | |
| 4091 continue; | |
| 4092 if (FrameView* view = toLocalFrame(child)->view()) | |
| 4093 view->updateThrottlingRecursive(securityOriginStatus); | |
| 4094 } | |
| 4095 } | |
| 4096 | |
| 4097 bool FrameView::shouldThrottleStyleLayoutAndCompositingUpdates() const | |
| 4098 { | |
| 4099 return lifecycle().throttlingMode() == DocumentLifecycle::ThrottlingMode::Al low | |
| 4100 && shouldThrottleRenderingPipeline(); | |
| 4101 } | |
| 4102 | |
| 4103 bool FrameView::shouldThrottleRenderingPipeline() const | |
| 4104 { | |
| 4105 // FIXME: Ignore for layout testing | |
| 4106 //if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) | |
| 4107 //return false; | |
| 4108 return m_viewportVisibility == ViewportVisibility::Hidden | |
| 4109 && m_securityOriginStatusForThrottling == SecurityOriginStatus::IsCrossO rigin; | |
| 4110 } | |
| 4111 | |
| 3980 } // namespace blink | 4112 } // namespace blink |
| OLD | NEW |