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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 , m_baseBackgroundColor(Color::white) | 123 , m_baseBackgroundColor(Color::white) |
| 124 , m_mediaType(MediaTypeNames::screen) | 124 , m_mediaType(MediaTypeNames::screen) |
| 125 , m_safeToPropagateScrollToParent(true) | 125 , m_safeToPropagateScrollToParent(true) |
| 126 , m_isTrackingPaintInvalidations(false) | 126 , m_isTrackingPaintInvalidations(false) |
| 127 , m_scrollCorner(nullptr) | 127 , m_scrollCorner(nullptr) |
| 128 , m_inputEventsScaleFactorForEmulation(1) | 128 , m_inputEventsScaleFactorForEmulation(1) |
| 129 , m_layoutSizeFixedToFrameSize(true) | 129 , m_layoutSizeFixedToFrameSize(true) |
| 130 , m_didScrollTimer(this, &FrameView::didScrollTimerFired) | 130 , m_didScrollTimer(this, &FrameView::didScrollTimerFired) |
| 131 , m_topControlsViewportAdjustment(0) | 131 , m_topControlsViewportAdjustment(0) |
| 132 , m_needsUpdateWidgetPositions(false) | 132 , m_needsUpdateWidgetPositions(false) |
| 133 , m_needsUpdateViewportVisibility(true) | |
| 133 #if ENABLE(ASSERT) | 134 #if ENABLE(ASSERT) |
| 134 , m_hasBeenDisposed(false) | 135 , m_hasBeenDisposed(false) |
| 135 #endif | 136 #endif |
| 136 , m_horizontalScrollbarMode(ScrollbarAuto) | 137 , m_horizontalScrollbarMode(ScrollbarAuto) |
| 137 , m_verticalScrollbarMode(ScrollbarAuto) | 138 , m_verticalScrollbarMode(ScrollbarAuto) |
| 138 , m_horizontalScrollbarLock(false) | 139 , m_horizontalScrollbarLock(false) |
| 139 , m_verticalScrollbarLock(false) | 140 , m_verticalScrollbarLock(false) |
| 140 , m_scrollbarsAvoidingResizer(0) | 141 , m_scrollbarsAvoidingResizer(0) |
| 141 , m_scrollbarsSuppressed(false) | 142 , m_scrollbarsSuppressed(false) |
| 142 , m_inUpdateScrollbars(false) | 143 , m_inUpdateScrollbars(false) |
| 143 , m_clipsRepaints(true) | 144 , m_clipsRepaints(true) |
| 144 , m_frameTimingRequestsDirty(true) | 145 , m_frameTimingRequestsDirty(true) |
| 145 | 146 , m_viewportVisibility(ViewportVisibility::Visible) |
| 147 , m_securityOriginStatusForThrottling(SecurityOriginStatus::IsSameOrigin) | |
| 146 { | 148 { |
| 147 ASSERT(m_frame); | 149 ASSERT(m_frame); |
| 148 init(); | 150 init(); |
| 149 } | 151 } |
| 150 | 152 |
| 151 PassRefPtrWillBeRawPtr<FrameView> FrameView::create(LocalFrame* frame) | 153 PassRefPtrWillBeRawPtr<FrameView> FrameView::create(LocalFrame* frame) |
| 152 { | 154 { |
| 153 RefPtrWillBeRawPtr<FrameView> view = adoptRefWillBeNoop(new FrameView(frame) ); | 155 RefPtrWillBeRawPtr<FrameView> view = adoptRefWillBeNoop(new FrameView(frame) ); |
| 154 view->show(); | 156 view->show(); |
| 155 return view.release(); | 157 return view.release(); |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1077 | 1079 |
| 1078 frame().document()->layoutUpdated(); | 1080 frame().document()->layoutUpdated(); |
| 1079 } | 1081 } |
| 1080 | 1082 |
| 1081 // The plan is to move to compositor-queried paint invalidation, in which case t his | 1083 // The plan is to move to compositor-queried paint invalidation, in which case t his |
| 1082 // method would setNeedsRedraw on the GraphicsLayers with invalidations and | 1084 // method would setNeedsRedraw on the GraphicsLayers with invalidations and |
| 1083 // let the compositor pick which to actually draw. | 1085 // let the compositor pick which to actually draw. |
| 1084 // See http://crbug.com/306706 | 1086 // See http://crbug.com/306706 |
| 1085 void FrameView::invalidateTreeIfNeeded(PaintInvalidationState& paintInvalidation State) | 1087 void FrameView::invalidateTreeIfNeeded(PaintInvalidationState& paintInvalidation State) |
| 1086 { | 1088 { |
| 1089 if (shouldThrottleRenderingPipeline()) | |
| 1090 return; | |
| 1091 | |
| 1087 lifecycle().advanceTo(DocumentLifecycle::InPaintInvalidation); | 1092 lifecycle().advanceTo(DocumentLifecycle::InPaintInvalidation); |
| 1088 | 1093 |
| 1089 ASSERT(layoutView()); | 1094 ASSERT(layoutView()); |
| 1090 LayoutView& rootForPaintInvalidation = *layoutView(); | 1095 LayoutView& rootForPaintInvalidation = *layoutView(); |
| 1091 ASSERT(!rootForPaintInvalidation.needsLayout()); | 1096 ASSERT(!rootForPaintInvalidation.needsLayout()); |
| 1092 | 1097 |
| 1093 TRACE_EVENT1("blink", "FrameView::invalidateTree", "root", rootForPaintInval idation.debugName().ascii()); | 1098 TRACE_EVENT1("blink", "FrameView::invalidateTree", "root", rootForPaintInval idation.debugName().ascii()); |
| 1094 | 1099 |
| 1095 rootForPaintInvalidation.invalidateTreeIfNeeded(paintInvalidationState); | 1100 rootForPaintInvalidation.invalidateTreeIfNeeded(paintInvalidationState); |
| 1096 | 1101 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1286 } | 1291 } |
| 1287 | 1292 |
| 1288 bool FrameView::shouldSetCursor() const | 1293 bool FrameView::shouldSetCursor() const |
| 1289 { | 1294 { |
| 1290 Page* page = frame().page(); | 1295 Page* page = frame().page(); |
| 1291 return page && page->visibilityState() != PageVisibilityStateHidden && page- >focusController().isActive() && page->settings().deviceSupportsMouse(); | 1296 return page && page->visibilityState() != PageVisibilityStateHidden && page- >focusController().isActive() && page->settings().deviceSupportsMouse(); |
| 1292 } | 1297 } |
| 1293 | 1298 |
| 1294 void FrameView::scrollContentsIfNeededRecursive() | 1299 void FrameView::scrollContentsIfNeededRecursive() |
| 1295 { | 1300 { |
| 1301 if (shouldThrottleStyleLayoutAndCompositingUpdates()) | |
| 1302 return; | |
| 1296 scrollContentsIfNeeded(); | 1303 scrollContentsIfNeeded(); |
| 1297 | 1304 |
| 1298 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { | 1305 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { |
| 1299 if (!child->isLocalFrame()) | 1306 if (!child->isLocalFrame()) |
| 1300 continue; | 1307 continue; |
| 1301 if (FrameView* view = toLocalFrame(child)->view()) | 1308 if (FrameView* view = toLocalFrame(child)->view()) |
| 1302 view->scrollContentsIfNeededRecursive(); | 1309 view->scrollContentsIfNeededRecursive(); |
| 1303 } | 1310 } |
| 1304 } | 1311 } |
| 1305 | 1312 |
| 1313 void FrameView::setLifecycleThrottlingModeForSubtree(DocumentLifecycle::Throttli ngMode throttlingMode) | |
| 1314 { | |
| 1315 ASSERT(m_frame->isLocalRoot()); | |
| 1316 for (Frame* frame = m_frame.get(); frame; frame = frame->tree().traverseNext (m_frame.get())) { | |
| 1317 if (!frame->isLocalFrame()) | |
| 1318 continue; | |
| 1319 if (FrameView* view = toLocalFrame(frame)->view()) | |
| 1320 view->lifecycle().setThrottlingMode(throttlingMode); | |
| 1321 } | |
| 1322 } | |
| 1323 | |
| 1306 bool FrameView::invalidateViewportConstrainedObjects() | 1324 bool FrameView::invalidateViewportConstrainedObjects() |
| 1307 { | 1325 { |
| 1308 for (const auto& viewportConstrainedObject : *m_viewportConstrainedObjects) { | 1326 for (const auto& viewportConstrainedObject : *m_viewportConstrainedObjects) { |
| 1309 LayoutObject* layoutObject = viewportConstrainedObject; | 1327 LayoutObject* layoutObject = viewportConstrainedObject; |
| 1310 ASSERT(layoutObject->style()->hasViewportConstrainedPosition()); | 1328 ASSERT(layoutObject->style()->hasViewportConstrainedPosition()); |
| 1311 ASSERT(layoutObject->hasLayer()); | 1329 ASSERT(layoutObject->hasLayer()); |
| 1312 DeprecatedPaintLayer* layer = toLayoutBoxModelObject(layoutObject)->laye r(); | 1330 DeprecatedPaintLayer* layer = toLayoutBoxModelObject(layoutObject)->laye r(); |
| 1313 | 1331 |
| 1314 if (layer->isPaintInvalidationContainer()) | 1332 if (layer->isPaintInvalidationContainer()) |
| 1315 continue; | 1333 continue; |
| (...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2411 void FrameView::updateWidgetPositionsIfNeeded() | 2429 void FrameView::updateWidgetPositionsIfNeeded() |
| 2412 { | 2430 { |
| 2413 if (!m_needsUpdateWidgetPositions) | 2431 if (!m_needsUpdateWidgetPositions) |
| 2414 return; | 2432 return; |
| 2415 | 2433 |
| 2416 m_needsUpdateWidgetPositions = false; | 2434 m_needsUpdateWidgetPositions = false; |
| 2417 | 2435 |
| 2418 updateWidgetPositions(); | 2436 updateWidgetPositions(); |
| 2419 } | 2437 } |
| 2420 | 2438 |
| 2421 void FrameView::updateAllLifecyclePhases(const LayoutRect& interestRect) | 2439 void FrameView::updateAllLifecyclePhases(DocumentLifecycle::ThrottlingMode throt tlingMode, const LayoutRect& interestRect) |
| 2422 { | 2440 { |
| 2423 frame().localFrameRoot()->view()->updateLifecyclePhasesInternal(AllPhases, i nterestRect); | 2441 frame().localFrameRoot()->view()->updateLifecyclePhasesInternal(AllPhases, t hrottlingMode, interestRect); |
| 2424 } | 2442 } |
| 2425 | 2443 |
| 2426 // TODO(chrishtr): add a scrolling update lifecycle phase. | 2444 // TODO(chrishtr): add a scrolling update lifecycle phase. |
| 2427 void FrameView::updateLifecycleToCompositingCleanPlusScrolling() | 2445 void FrameView::updateLifecycleToCompositingCleanPlusScrolling(DocumentLifecycle ::ThrottlingMode throttlingMode) |
| 2428 { | 2446 { |
| 2429 frame().localFrameRoot()->view()->updateLifecyclePhasesInternal(OnlyUpToComp ositingCleanPlusScrolling); | 2447 frame().localFrameRoot()->view()->updateLifecyclePhasesInternal(OnlyUpToComp ositingCleanPlusScrolling, throttlingMode, LayoutRect::infiniteRect()); |
| 2430 } | 2448 } |
| 2431 | 2449 |
| 2432 void FrameView::updateLifecyclePhasesInternal(LifeCycleUpdateOption phases, cons t LayoutRect& interestRect) | 2450 void FrameView::updateLifecyclePhasesInternal(LifeCycleUpdateOption phases, Docu mentLifecycle::ThrottlingMode throttlingMode, const LayoutRect& interestRect) |
| 2433 { | 2451 { |
| 2434 // This must be called from the root frame, since it recurses down, not up. | 2452 // This must be called from the root frame, since it recurses down, not up. |
| 2435 // Otherwise the lifecycles of the frames might be out of sync. | 2453 // Otherwise the lifecycles of the frames might be out of sync. |
| 2436 ASSERT(m_frame->isLocalRoot()); | 2454 ASSERT(m_frame->isLocalRoot()); |
| 2437 | 2455 |
| 2438 // Updating layout can run script, which can tear down the FrameView. | 2456 // Updating layout can run script, which can tear down the FrameView. |
| 2439 RefPtrWillBeRawPtr<FrameView> protector(this); | 2457 RefPtrWillBeRawPtr<FrameView> protector(this); |
| 2440 | 2458 |
| 2459 setLifecycleThrottlingModeForSubtree(throttlingMode); | |
| 2441 updateStyleAndLayoutIfNeededRecursive(); | 2460 updateStyleAndLayoutIfNeededRecursive(); |
| 2442 | 2461 |
| 2443 if (LayoutView* view = layoutView()) { | 2462 if (LayoutView* view = layoutView()) { |
| 2444 TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", InspectorUp dateLayerTreeEvent::data(m_frame.get())); | 2463 TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", InspectorUp dateLayerTreeEvent::data(m_frame.get())); |
| 2445 | 2464 |
| 2446 // This was required for slimming paint v1 but is only temporarily | 2465 // This was required for slimming paint v1 but is only temporarily |
| 2447 // needed for slimming paint v2. | 2466 // needed for slimming paint v2. |
| 2448 view->compositor()->updateIfNeededRecursive(); | 2467 view->compositor()->updateIfNeededRecursive(); |
| 2449 scrollContentsIfNeededRecursive(); | 2468 scrollContentsIfNeededRecursive(); |
| 2450 | 2469 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2525 collectFrameTimingRequestsRecursive(graphicsLayerTimingRequests); | 2544 collectFrameTimingRequestsRecursive(graphicsLayerTimingRequests); |
| 2526 | 2545 |
| 2527 for (const auto& iter : graphicsLayerTimingRequests) { | 2546 for (const auto& iter : graphicsLayerTimingRequests) { |
| 2528 const GraphicsLayer* graphicsLayer = iter.key; | 2547 const GraphicsLayer* graphicsLayer = iter.key; |
| 2529 graphicsLayer->platformLayer()->setFrameTimingRequests(iter.value); | 2548 graphicsLayer->platformLayer()->setFrameTimingRequests(iter.value); |
| 2530 } | 2549 } |
| 2531 } | 2550 } |
| 2532 | 2551 |
| 2533 void FrameView::updateStyleAndLayoutIfNeededRecursive() | 2552 void FrameView::updateStyleAndLayoutIfNeededRecursive() |
| 2534 { | 2553 { |
| 2554 if (shouldThrottleStyleLayoutAndCompositingUpdates()) | |
| 2555 return; | |
| 2556 | |
| 2535 // We have to crawl our entire subtree looking for any FrameViews that need | 2557 // We have to crawl our entire subtree looking for any FrameViews that need |
| 2536 // layout and make sure they are up to date. | 2558 // layout and make sure they are up to date. |
| 2537 // Mac actually tests for intersection with the dirty region and tries not t o | 2559 // Mac actually tests for intersection with the dirty region and tries not t o |
| 2538 // update layout for frames that are outside the dirty region. Not only doe s this seem | 2560 // update layout for frames that are outside the dirty region. Not only doe s this seem |
| 2539 // pointless (since those frames will have set a zero timer to layout anyway ), but | 2561 // pointless (since those frames will have set a zero timer to layout anyway ), but |
| 2540 // it is also incorrect, since if two frames overlap, the first could be exc luded from the dirty | 2562 // it is also incorrect, since if two frames overlap, the first could be exc luded from the dirty |
| 2541 // region but then become included later by the second frame adding rects to the dirty region | 2563 // region but then become included later by the second frame adding rects to the dirty region |
| 2542 // when it lays out. | 2564 // when it lays out. |
| 2543 | 2565 |
| 2544 m_frame->document()->updateLayoutTreeIfNeeded(); | 2566 m_frame->document()->updateLayoutTreeIfNeeded(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2576 #if ENABLE(ASSERT) | 2598 #if ENABLE(ASSERT) |
| 2577 m_frame->document()->layoutView()->assertLaidOut(); | 2599 m_frame->document()->layoutView()->assertLaidOut(); |
| 2578 #endif | 2600 #endif |
| 2579 | 2601 |
| 2580 updateWidgetPositionsIfNeeded(); | 2602 updateWidgetPositionsIfNeeded(); |
| 2581 } | 2603 } |
| 2582 | 2604 |
| 2583 void FrameView::invalidateTreeIfNeededRecursive() | 2605 void FrameView::invalidateTreeIfNeededRecursive() |
| 2584 { | 2606 { |
| 2585 ASSERT(layoutView()); | 2607 ASSERT(layoutView()); |
| 2608 | |
| 2609 // We need to stop recursing here since a child frame view might not be thro ttled | |
| 2610 // even though we are (e.g., it didn't compute its visibility yet). | |
| 2611 if (shouldThrottleRenderingPipeline()) | |
| 2612 return; | |
| 2586 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root", layoutView()->debugName().ascii()); | 2613 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root", layoutView()->debugName().ascii()); |
| 2587 | 2614 |
| 2588 Vector<LayoutObject*> pendingDelayedPaintInvalidations; | 2615 Vector<LayoutObject*> pendingDelayedPaintInvalidations; |
| 2589 PaintInvalidationState rootPaintInvalidationState(*layoutView(), pendingDela yedPaintInvalidations); | 2616 PaintInvalidationState rootPaintInvalidationState(*layoutView(), pendingDela yedPaintInvalidations); |
| 2590 | 2617 |
| 2591 invalidateTreeIfNeeded(rootPaintInvalidationState); | 2618 invalidateTreeIfNeeded(rootPaintInvalidationState); |
| 2592 | 2619 |
| 2593 // Some frames may be not reached during the above invalidateTreeIfNeeded be cause | 2620 // Some frames may be not reached during the above invalidateTreeIfNeeded be cause |
| 2594 // - the frame is a detached frame; or | 2621 // - the frame is a detached frame; or |
| 2595 // - it didn't need paint invalidation. | 2622 // - it didn't need paint invalidation. |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2894 | 2921 |
| 2895 if (m_scrollbarsAvoidingResizer && parent()) | 2922 if (m_scrollbarsAvoidingResizer && parent()) |
| 2896 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(-m_scrollbar sAvoidingResizer); | 2923 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(-m_scrollbar sAvoidingResizer); |
| 2897 | 2924 |
| 2898 Widget::setParent(parentView); | 2925 Widget::setParent(parentView); |
| 2899 | 2926 |
| 2900 if (m_scrollbarsAvoidingResizer && parent()) | 2927 if (m_scrollbarsAvoidingResizer && parent()) |
| 2901 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(m_scrollbars AvoidingResizer); | 2928 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(m_scrollbars AvoidingResizer); |
| 2902 | 2929 |
| 2903 updateScrollableAreaSet(); | 2930 updateScrollableAreaSet(); |
| 2931 m_needsUpdateViewportVisibility = true; | |
| 2904 } | 2932 } |
| 2905 | 2933 |
| 2906 void FrameView::removeChild(Widget* child) | 2934 void FrameView::removeChild(Widget* child) |
| 2907 { | 2935 { |
| 2908 ASSERT(child->parent() == this); | 2936 ASSERT(child->parent() == this); |
| 2909 | 2937 |
| 2910 if (child->isFrameView()) | 2938 if (child->isFrameView()) |
| 2911 removeScrollableArea(toFrameView(child)); | 2939 removeScrollableArea(toFrameView(child)); |
| 2912 | 2940 |
| 2913 child->setParent(0); | 2941 child->setParent(0); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2951 return; | 2979 return; |
| 2952 page->chromeClient().setCursor(cursor); | 2980 page->chromeClient().setCursor(cursor); |
| 2953 } | 2981 } |
| 2954 | 2982 |
| 2955 void FrameView::frameRectsChanged() | 2983 void FrameView::frameRectsChanged() |
| 2956 { | 2984 { |
| 2957 TRACE_EVENT0("blink", "FrameView::frameRectsChanged"); | 2985 TRACE_EVENT0("blink", "FrameView::frameRectsChanged"); |
| 2958 if (layoutSizeFixedToFrameSize()) | 2986 if (layoutSizeFixedToFrameSize()) |
| 2959 setLayoutSizeInternal(frameRect().size()); | 2987 setLayoutSizeInternal(frameRect().size()); |
| 2960 | 2988 |
| 2989 m_needsUpdateViewportVisibility = true; | |
| 2961 for (const auto& child : m_children) | 2990 for (const auto& child : m_children) |
| 2962 child->frameRectsChanged(); | 2991 child->frameRectsChanged(); |
| 2963 } | 2992 } |
| 2964 | 2993 |
| 2965 void FrameView::setLayoutSizeInternal(const IntSize& size) | 2994 void FrameView::setLayoutSizeInternal(const IntSize& size) |
| 2966 { | 2995 { |
| 2967 if (m_layoutSize == size) | 2996 if (m_layoutSize == size) |
| 2968 return; | 2997 return; |
| 2969 | 2998 |
| 2970 m_layoutSize = size; | 2999 m_layoutSize = size; |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3732 return ScrollBehaviorInstant; | 3761 return ScrollBehaviorInstant; |
| 3733 } | 3762 } |
| 3734 | 3763 |
| 3735 void FrameView::paint(GraphicsContext* context, const IntRect& rect) | 3764 void FrameView::paint(GraphicsContext* context, const IntRect& rect) |
| 3736 { | 3765 { |
| 3737 paint(context, GlobalPaintNormalPhase, rect); | 3766 paint(context, GlobalPaintNormalPhase, rect); |
| 3738 } | 3767 } |
| 3739 | 3768 |
| 3740 void FrameView::paint(GraphicsContext* context, const GlobalPaintFlags globalPai ntFlags, const IntRect& rect) | 3769 void FrameView::paint(GraphicsContext* context, const GlobalPaintFlags globalPai ntFlags, const IntRect& rect) |
| 3741 { | 3770 { |
| 3771 // TODO(skyostil): Remove this early-out in favor of painting cached scrollb ars. | |
| 3772 if (shouldThrottleRenderingPipeline()) | |
| 3773 return; | |
| 3742 FramePainter(*this).paint(context, globalPaintFlags, rect); | 3774 FramePainter(*this).paint(context, globalPaintFlags, rect); |
| 3743 } | 3775 } |
| 3744 | 3776 |
| 3745 void FrameView::paintContents(GraphicsContext* context, const GlobalPaintFlags g lobalPaintFlags, const IntRect& damageRect) | 3777 void FrameView::paintContents(GraphicsContext* context, const GlobalPaintFlags g lobalPaintFlags, const IntRect& damageRect) |
| 3746 { | 3778 { |
| 3779 if (shouldThrottleRenderingPipeline()) | |
| 3780 return; | |
| 3747 FramePainter(*this).paintContents(context, globalPaintFlags, damageRect); | 3781 FramePainter(*this).paintContents(context, globalPaintFlags, damageRect); |
| 3748 } | 3782 } |
| 3749 | 3783 |
| 3750 bool FrameView::isPointInScrollbarCorner(const IntPoint& windowPoint) | 3784 bool FrameView::isPointInScrollbarCorner(const IntPoint& windowPoint) |
| 3751 { | 3785 { |
| 3752 if (!scrollbarCornerPresent()) | 3786 if (!scrollbarCornerPresent()) |
| 3753 return false; | 3787 return false; |
| 3754 | 3788 |
| 3755 IntPoint framePoint = convertFromContainingWindow(windowPoint); | 3789 IntPoint framePoint = convertFromContainingWindow(windowPoint); |
| 3756 | 3790 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3924 } | 3958 } |
| 3925 | 3959 |
| 3926 void FrameView::collectFrameTimingRequests(GraphicsLayerFrameTimingRequests& gra phicsLayerTimingRequests) | 3960 void FrameView::collectFrameTimingRequests(GraphicsLayerFrameTimingRequests& gra phicsLayerTimingRequests) |
| 3927 { | 3961 { |
| 3928 if (!m_frame->isLocalFrame()) | 3962 if (!m_frame->isLocalFrame()) |
| 3929 return; | 3963 return; |
| 3930 Frame* frame = m_frame.get(); | 3964 Frame* frame = m_frame.get(); |
| 3931 LocalFrame* localFrame = toLocalFrame(frame); | 3965 LocalFrame* localFrame = toLocalFrame(frame); |
| 3932 LayoutRect viewRect = localFrame->contentLayoutObject()->viewRect(); | 3966 LayoutRect viewRect = localFrame->contentLayoutObject()->viewRect(); |
| 3933 const LayoutBoxModelObject* paintInvalidationContainer = localFrame->content LayoutObject()->containerForPaintInvalidation(); | 3967 const LayoutBoxModelObject* paintInvalidationContainer = localFrame->content LayoutObject()->containerForPaintInvalidation(); |
| 3968 // If the frame is being throttled, its compositing state may not be up to d ate. | |
| 3969 if (!paintInvalidationContainer->enclosingLayer()->isAllowedToQueryCompositi ngState()) | |
| 3970 return; | |
| 3934 const GraphicsLayer* graphicsLayer = paintInvalidationContainer->enclosingLa yer()->graphicsLayerBacking(); | 3971 const GraphicsLayer* graphicsLayer = paintInvalidationContainer->enclosingLa yer()->graphicsLayerBacking(); |
| 3935 | 3972 |
| 3936 if (!graphicsLayer) | 3973 if (!graphicsLayer) |
| 3937 return; | 3974 return; |
| 3938 | 3975 |
| 3939 DeprecatedPaintLayer::mapRectToPaintInvalidationBacking(localFrame->contentL ayoutObject(), paintInvalidationContainer, viewRect); | 3976 DeprecatedPaintLayer::mapRectToPaintInvalidationBacking(localFrame->contentL ayoutObject(), paintInvalidationContainer, viewRect); |
| 3940 | 3977 |
| 3941 graphicsLayerTimingRequests.add(graphicsLayer, Vector<std::pair<int64_t, Web Rect>>()).storedValue->value.append(std::make_pair(m_frame->frameID(), enclosing IntRect(viewRect))); | 3978 graphicsLayerTimingRequests.add(graphicsLayer, Vector<std::pair<int64_t, Web Rect>>()).storedValue->value.append(std::make_pair(m_frame->frameID(), enclosing IntRect(viewRect))); |
| 3942 } | 3979 } |
| 3943 | 3980 |
| 3981 void FrameView::updateViewportVisibilityIfNeeded() | |
| 3982 { | |
| 3983 // TODO(skyostil): Replace this with an intersection observer. | |
| 3984 | |
| 3985 // Without slimming paint v2 we can sometimes end up back in LayoutClean | |
| 3986 // during painting (e.g., because of block selection gaps). | |
|
esprehn
2015/09/21 21:27:20
huh?
Sami
2015/09/23 18:31:07
Yeah :( I found out that block selections can inva
| |
| 3987 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 3988 ASSERT(shouldThrottleRenderingPipeline() || lifecycle().state() >= Docum entLifecycle::PaintInvalidationClean); | |
| 3989 else | |
| 3990 ASSERT(shouldThrottleRenderingPipeline() || lifecycle().state() >= Docum entLifecycle::LayoutClean); | |
| 3991 if (!m_needsUpdateViewportVisibility) | |
| 3992 return; | |
| 3993 | |
| 3994 // Our frame's bounds in our parent's content coordinates. | |
| 3995 m_clippedBounds = frameRect(); | |
| 3996 m_viewportVisibility = ViewportVisibility::Visible; | |
| 3997 m_needsUpdateViewportVisibility = false; | |
| 3998 | |
| 3999 FrameView* parent = parentFrameView(); | |
| 4000 if (!parent) | |
| 4001 return; | |
| 4002 ASSERT(!parent->m_needsUpdateViewportVisibility); | |
| 4003 | |
| 4004 // If our parent is hidden, then we are too. | |
| 4005 if (parent->m_viewportVisibility == ViewportVisibility::Hidden) { | |
| 4006 m_viewportVisibility = ViewportVisibility::Hidden; | |
| 4007 return; | |
| 4008 } | |
| 4009 | |
| 4010 // Transform our bounds into the root frame's content coordinate space. | |
| 4011 m_clippedBounds = parent->contentsToRootFrame(m_clippedBounds); | |
| 4012 | |
| 4013 // TODO(skyostil): Expand the viewport to make it less likely to see stale c ontent while scrolling. | |
| 4014 IntRect viewport = parent->m_clippedBounds; | |
| 4015 m_clippedBounds.intersect(viewport); | |
| 4016 | |
| 4017 // If our bounds got clipped away, we are invisible. | |
| 4018 if (m_clippedBounds.isEmpty()) | |
| 4019 m_viewportVisibility = ViewportVisibility::Hidden; | |
| 4020 } | |
| 4021 | |
| 4022 void FrameView::updateThrottling() | |
| 4023 { | |
| 4024 ASSERT(m_frame->isLocalRoot()); | |
| 4025 updateThrottlingRecursive(SecurityOriginStatus::IsSameOrigin); | |
| 4026 } | |
| 4027 | |
| 4028 void FrameView::updateThrottlingRecursive(SecurityOriginStatus securityOriginSta tus) | |
| 4029 { | |
| 4030 ASSERT(!isInPerformLayout()); | |
| 4031 // Without slimming paint v2 we can sometimes end up back in LayoutClean | |
| 4032 // during painting (e.g., because of block selection gaps). | |
| 4033 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 4034 ASSERT(shouldThrottleRenderingPipeline() || lifecycle().state() >= Docum entLifecycle::PaintInvalidationClean); | |
| 4035 else | |
| 4036 ASSERT(shouldThrottleRenderingPipeline() || lifecycle().state() >= Docum entLifecycle::LayoutClean); | |
| 4037 bool wasThrottled = shouldThrottleRenderingPipeline(); | |
| 4038 | |
| 4039 updateViewportVisibilityIfNeeded(); | |
| 4040 | |
| 4041 // We only throttle the rendering pipeline in cross-origin frames. This is | |
| 4042 // to avoid a situation where an ancestor frame directly depends on the | |
| 4043 // pipeline timing of a descendant and breaks as a result of throttling. | |
| 4044 // The rationale is that cross-origin frames must already communicate with | |
| 4045 // asynchronous messages, so they should be able to tolerate some delay in | |
| 4046 // receiving replies from a throttled peer. | |
| 4047 // | |
| 4048 // Check if we can access our parent's security origin. As an optimization | |
| 4049 // only do this if we are invisible. | |
| 4050 if (securityOriginStatus == SecurityOriginStatus::IsSameOrigin | |
| 4051 && parentFrameView() && m_viewportVisibility == ViewportVisibility::Hidd en) { | |
| 4052 const SecurityOrigin* origin = frame().securityContext()->securityOrigin (); | |
| 4053 const SecurityOrigin* parentOrigin = parentFrameView()->frame().security Context()->securityOrigin(); | |
| 4054 if (!origin->canAccess(parentOrigin)) | |
| 4055 securityOriginStatus = SecurityOriginStatus::IsCrossOrigin; | |
| 4056 } | |
| 4057 m_securityOriginStatusForThrottling = securityOriginStatus; | |
| 4058 | |
| 4059 bool becameUnthrottled = wasThrottled && !shouldThrottleRenderingPipeline(); | |
| 4060 if (becameUnthrottled) | |
| 4061 page()->animator().scheduleVisualUpdate(m_frame.get()); | |
| 4062 | |
| 4063 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { | |
| 4064 if (!child->isLocalFrame()) | |
| 4065 continue; | |
| 4066 if (FrameView* view = toLocalFrame(child)->view()) | |
| 4067 view->updateThrottlingRecursive(securityOriginStatus); | |
| 4068 } | |
| 4069 } | |
| 4070 | |
| 4071 bool FrameView::shouldThrottleStyleLayoutAndCompositingUpdates() const | |
| 4072 { | |
| 4073 return lifecycle().throttlingMode() == DocumentLifecycle::ThrottlingMode::Al low | |
| 4074 && shouldThrottleRenderingPipeline(); | |
| 4075 } | |
| 4076 | |
| 4077 bool FrameView::shouldThrottleRenderingPipeline() const | |
| 4078 { | |
| 4079 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) | |
| 4080 return false; | |
| 4081 return m_viewportVisibility == ViewportVisibility::Hidden | |
| 4082 && m_securityOriginStatusForThrottling == SecurityOriginStatus::IsCrossO rigin; | |
| 4083 } | |
| 4084 | |
| 3944 } // namespace blink | 4085 } // namespace blink |
| OLD | NEW |