| 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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1721 if (!m_frame->document()->shouldScheduleLayout()) | 1739 if (!m_frame->document()->shouldScheduleLayout()) |
| 1722 return; | 1740 return; |
| 1723 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Invali
dateLayout", TRACE_EVENT_SCOPE_THREAD, "data", InspectorInvalidateLayoutEvent::d
ata(m_frame.get())); | 1741 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Invali
dateLayout", TRACE_EVENT_SCOPE_THREAD, "data", InspectorInvalidateLayoutEvent::d
ata(m_frame.get())); |
| 1724 | 1742 |
| 1725 clearLayoutSubtreeRootsAndMarkContainingBlocks(); | 1743 clearLayoutSubtreeRootsAndMarkContainingBlocks(); |
| 1726 | 1744 |
| 1727 if (m_hasPendingLayout) | 1745 if (m_hasPendingLayout) |
| 1728 return; | 1746 return; |
| 1729 m_hasPendingLayout = true; | 1747 m_hasPendingLayout = true; |
| 1730 | 1748 |
| 1731 page()->animator().scheduleVisualUpdate(m_frame.get()); | 1749 if (!shouldThrottleRenderingPipeline()) |
| 1750 page()->animator().scheduleVisualUpdate(m_frame.get()); |
| 1732 lifecycle().ensureStateAtMost(DocumentLifecycle::StyleClean); | 1751 lifecycle().ensureStateAtMost(DocumentLifecycle::StyleClean); |
| 1733 } | 1752 } |
| 1734 | 1753 |
| 1735 void FrameView::scheduleRelayoutOfSubtree(LayoutObject* relayoutRoot) | 1754 void FrameView::scheduleRelayoutOfSubtree(LayoutObject* relayoutRoot) |
| 1736 { | 1755 { |
| 1737 ASSERT(m_frame->view() == this); | 1756 ASSERT(m_frame->view() == this); |
| 1738 | 1757 |
| 1739 // FIXME: Should this call shouldScheduleLayout instead? | 1758 // FIXME: Should this call shouldScheduleLayout instead? |
| 1740 if (!m_frame->document()->isActive()) | 1759 if (!m_frame->document()->isActive()) |
| 1741 return; | 1760 return; |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2411 void FrameView::updateWidgetPositionsIfNeeded() | 2430 void FrameView::updateWidgetPositionsIfNeeded() |
| 2412 { | 2431 { |
| 2413 if (!m_needsUpdateWidgetPositions) | 2432 if (!m_needsUpdateWidgetPositions) |
| 2414 return; | 2433 return; |
| 2415 | 2434 |
| 2416 m_needsUpdateWidgetPositions = false; | 2435 m_needsUpdateWidgetPositions = false; |
| 2417 | 2436 |
| 2418 updateWidgetPositions(); | 2437 updateWidgetPositions(); |
| 2419 } | 2438 } |
| 2420 | 2439 |
| 2421 void FrameView::updateAllLifecyclePhases(const LayoutRect& interestRect) | 2440 void FrameView::updateAllLifecyclePhases(DocumentLifecycle::ThrottlingMode throt
tlingMode, const LayoutRect& interestRect) |
| 2422 { | 2441 { |
| 2423 frame().localFrameRoot()->view()->updateLifecyclePhasesInternal(AllPhases, i
nterestRect); | 2442 frame().localFrameRoot()->view()->updateLifecyclePhasesInternal(AllPhases, t
hrottlingMode, interestRect); |
| 2424 } | 2443 } |
| 2425 | 2444 |
| 2426 // TODO(chrishtr): add a scrolling update lifecycle phase. | 2445 // TODO(chrishtr): add a scrolling update lifecycle phase. |
| 2427 void FrameView::updateLifecycleToCompositingCleanPlusScrolling() | 2446 void FrameView::updateLifecycleToCompositingCleanPlusScrolling(DocumentLifecycle
::ThrottlingMode throttlingMode) |
| 2428 { | 2447 { |
| 2429 frame().localFrameRoot()->view()->updateLifecyclePhasesInternal(OnlyUpToComp
ositingCleanPlusScrolling); | 2448 frame().localFrameRoot()->view()->updateLifecyclePhasesInternal(OnlyUpToComp
ositingCleanPlusScrolling, throttlingMode, LayoutRect::infiniteRect()); |
| 2430 } | 2449 } |
| 2431 | 2450 |
| 2432 void FrameView::updateLifecyclePhasesInternal(LifeCycleUpdateOption phases, cons
t LayoutRect& interestRect) | 2451 void FrameView::updateLifecyclePhasesInternal(LifeCycleUpdateOption phases, Docu
mentLifecycle::ThrottlingMode throttlingMode, const LayoutRect& interestRect) |
| 2433 { | 2452 { |
| 2434 // This must be called from the root frame, since it recurses down, not up. | 2453 // 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. | 2454 // Otherwise the lifecycles of the frames might be out of sync. |
| 2436 ASSERT(m_frame->isLocalRoot()); | 2455 ASSERT(m_frame->isLocalRoot()); |
| 2437 | 2456 |
| 2438 // Updating layout can run script, which can tear down the FrameView. | 2457 // Updating layout can run script, which can tear down the FrameView. |
| 2439 RefPtrWillBeRawPtr<FrameView> protector(this); | 2458 RefPtrWillBeRawPtr<FrameView> protector(this); |
| 2440 | 2459 |
| 2460 setLifecycleThrottlingModeForSubtree(throttlingMode); |
| 2441 updateStyleAndLayoutIfNeededRecursive(); | 2461 updateStyleAndLayoutIfNeededRecursive(); |
| 2442 | 2462 |
| 2443 if (LayoutView* view = layoutView()) { | 2463 if (LayoutView* view = layoutView()) { |
| 2444 TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", InspectorUp
dateLayerTreeEvent::data(m_frame.get())); | 2464 TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", InspectorUp
dateLayerTreeEvent::data(m_frame.get())); |
| 2445 | 2465 |
| 2446 // This was required for slimming paint v1 but is only temporarily | 2466 // This was required for slimming paint v1 but is only temporarily |
| 2447 // needed for slimming paint v2. | 2467 // needed for slimming paint v2. |
| 2448 view->compositor()->updateIfNeededRecursive(); | 2468 view->compositor()->updateIfNeededRecursive(); |
| 2449 scrollContentsIfNeededRecursive(); | 2469 scrollContentsIfNeededRecursive(); |
| 2450 | 2470 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2525 collectFrameTimingRequestsRecursive(graphicsLayerTimingRequests); | 2545 collectFrameTimingRequestsRecursive(graphicsLayerTimingRequests); |
| 2526 | 2546 |
| 2527 for (const auto& iter : graphicsLayerTimingRequests) { | 2547 for (const auto& iter : graphicsLayerTimingRequests) { |
| 2528 const GraphicsLayer* graphicsLayer = iter.key; | 2548 const GraphicsLayer* graphicsLayer = iter.key; |
| 2529 graphicsLayer->platformLayer()->setFrameTimingRequests(iter.value); | 2549 graphicsLayer->platformLayer()->setFrameTimingRequests(iter.value); |
| 2530 } | 2550 } |
| 2531 } | 2551 } |
| 2532 | 2552 |
| 2533 void FrameView::updateStyleAndLayoutIfNeededRecursive() | 2553 void FrameView::updateStyleAndLayoutIfNeededRecursive() |
| 2534 { | 2554 { |
| 2555 if (shouldThrottleStyleLayoutAndCompositingUpdates()) |
| 2556 return; |
| 2557 |
| 2535 // We have to crawl our entire subtree looking for any FrameViews that need | 2558 // We have to crawl our entire subtree looking for any FrameViews that need |
| 2536 // layout and make sure they are up to date. | 2559 // layout and make sure they are up to date. |
| 2537 // Mac actually tests for intersection with the dirty region and tries not t
o | 2560 // 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 | 2561 // 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 | 2562 // 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 | 2563 // 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 | 2564 // region but then become included later by the second frame adding rects to
the dirty region |
| 2542 // when it lays out. | 2565 // when it lays out. |
| 2543 | 2566 |
| 2544 m_frame->document()->updateLayoutTreeIfNeeded(); | 2567 m_frame->document()->updateLayoutTreeIfNeeded(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2576 #if ENABLE(ASSERT) | 2599 #if ENABLE(ASSERT) |
| 2577 m_frame->document()->layoutView()->assertLaidOut(); | 2600 m_frame->document()->layoutView()->assertLaidOut(); |
| 2578 #endif | 2601 #endif |
| 2579 | 2602 |
| 2580 updateWidgetPositionsIfNeeded(); | 2603 updateWidgetPositionsIfNeeded(); |
| 2581 } | 2604 } |
| 2582 | 2605 |
| 2583 void FrameView::invalidateTreeIfNeededRecursive() | 2606 void FrameView::invalidateTreeIfNeededRecursive() |
| 2584 { | 2607 { |
| 2585 ASSERT(layoutView()); | 2608 ASSERT(layoutView()); |
| 2609 |
| 2610 // We need to stop recursing here since a child frame view might not be thro
ttled |
| 2611 // even though we are (e.g., it didn't compute its visibility yet). |
| 2612 if (shouldThrottleRenderingPipeline()) |
| 2613 return; |
| 2586 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root",
layoutView()->debugName().ascii()); | 2614 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root",
layoutView()->debugName().ascii()); |
| 2587 | 2615 |
| 2588 Vector<LayoutObject*> pendingDelayedPaintInvalidations; | 2616 Vector<LayoutObject*> pendingDelayedPaintInvalidations; |
| 2589 PaintInvalidationState rootPaintInvalidationState(*layoutView(), pendingDela
yedPaintInvalidations); | 2617 PaintInvalidationState rootPaintInvalidationState(*layoutView(), pendingDela
yedPaintInvalidations); |
| 2590 | 2618 |
| 2591 invalidateTreeIfNeeded(rootPaintInvalidationState); | 2619 invalidateTreeIfNeeded(rootPaintInvalidationState); |
| 2592 | 2620 |
| 2593 // Some frames may be not reached during the above invalidateTreeIfNeeded be
cause | 2621 // Some frames may be not reached during the above invalidateTreeIfNeeded be
cause |
| 2594 // - the frame is a detached frame; or | 2622 // - the frame is a detached frame; or |
| 2595 // - it didn't need paint invalidation. | 2623 // - it didn't need paint invalidation. |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2894 | 2922 |
| 2895 if (m_scrollbarsAvoidingResizer && parent()) | 2923 if (m_scrollbarsAvoidingResizer && parent()) |
| 2896 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(-m_scrollbar
sAvoidingResizer); | 2924 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(-m_scrollbar
sAvoidingResizer); |
| 2897 | 2925 |
| 2898 Widget::setParent(parentView); | 2926 Widget::setParent(parentView); |
| 2899 | 2927 |
| 2900 if (m_scrollbarsAvoidingResizer && parent()) | 2928 if (m_scrollbarsAvoidingResizer && parent()) |
| 2901 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(m_scrollbars
AvoidingResizer); | 2929 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(m_scrollbars
AvoidingResizer); |
| 2902 | 2930 |
| 2903 updateScrollableAreaSet(); | 2931 updateScrollableAreaSet(); |
| 2932 m_needsUpdateViewportVisibility = true; |
| 2904 } | 2933 } |
| 2905 | 2934 |
| 2906 void FrameView::removeChild(Widget* child) | 2935 void FrameView::removeChild(Widget* child) |
| 2907 { | 2936 { |
| 2908 ASSERT(child->parent() == this); | 2937 ASSERT(child->parent() == this); |
| 2909 | 2938 |
| 2910 if (child->isFrameView()) | 2939 if (child->isFrameView()) |
| 2911 removeScrollableArea(toFrameView(child)); | 2940 removeScrollableArea(toFrameView(child)); |
| 2912 | 2941 |
| 2913 child->setParent(0); | 2942 child->setParent(0); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2951 return; | 2980 return; |
| 2952 page->chromeClient().setCursor(cursor); | 2981 page->chromeClient().setCursor(cursor); |
| 2953 } | 2982 } |
| 2954 | 2983 |
| 2955 void FrameView::frameRectsChanged() | 2984 void FrameView::frameRectsChanged() |
| 2956 { | 2985 { |
| 2957 TRACE_EVENT0("blink", "FrameView::frameRectsChanged"); | 2986 TRACE_EVENT0("blink", "FrameView::frameRectsChanged"); |
| 2958 if (layoutSizeFixedToFrameSize()) | 2987 if (layoutSizeFixedToFrameSize()) |
| 2959 setLayoutSizeInternal(frameRect().size()); | 2988 setLayoutSizeInternal(frameRect().size()); |
| 2960 | 2989 |
| 2990 m_needsUpdateViewportVisibility = true; |
| 2961 for (const auto& child : m_children) | 2991 for (const auto& child : m_children) |
| 2962 child->frameRectsChanged(); | 2992 child->frameRectsChanged(); |
| 2963 } | 2993 } |
| 2964 | 2994 |
| 2965 void FrameView::setLayoutSizeInternal(const IntSize& size) | 2995 void FrameView::setLayoutSizeInternal(const IntSize& size) |
| 2966 { | 2996 { |
| 2967 if (m_layoutSize == size) | 2997 if (m_layoutSize == size) |
| 2968 return; | 2998 return; |
| 2969 | 2999 |
| 2970 m_layoutSize = size; | 3000 m_layoutSize = size; |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3732 return ScrollBehaviorInstant; | 3762 return ScrollBehaviorInstant; |
| 3733 } | 3763 } |
| 3734 | 3764 |
| 3735 void FrameView::paint(GraphicsContext* context, const IntRect& rect) | 3765 void FrameView::paint(GraphicsContext* context, const IntRect& rect) |
| 3736 { | 3766 { |
| 3737 paint(context, GlobalPaintNormalPhase, rect); | 3767 paint(context, GlobalPaintNormalPhase, rect); |
| 3738 } | 3768 } |
| 3739 | 3769 |
| 3740 void FrameView::paint(GraphicsContext* context, const GlobalPaintFlags globalPai
ntFlags, const IntRect& rect) | 3770 void FrameView::paint(GraphicsContext* context, const GlobalPaintFlags globalPai
ntFlags, const IntRect& rect) |
| 3741 { | 3771 { |
| 3772 // TODO(skyostil): Remove this early-out in favor of painting cached scrollb
ars. |
| 3773 if (shouldThrottleRenderingPipeline()) |
| 3774 return; |
| 3742 FramePainter(*this).paint(context, globalPaintFlags, rect); | 3775 FramePainter(*this).paint(context, globalPaintFlags, rect); |
| 3743 } | 3776 } |
| 3744 | 3777 |
| 3745 void FrameView::paintContents(GraphicsContext* context, const GlobalPaintFlags g
lobalPaintFlags, const IntRect& damageRect) | 3778 void FrameView::paintContents(GraphicsContext* context, const GlobalPaintFlags g
lobalPaintFlags, const IntRect& damageRect) |
| 3746 { | 3779 { |
| 3780 if (shouldThrottleRenderingPipeline()) |
| 3781 return; |
| 3747 FramePainter(*this).paintContents(context, globalPaintFlags, damageRect); | 3782 FramePainter(*this).paintContents(context, globalPaintFlags, damageRect); |
| 3748 } | 3783 } |
| 3749 | 3784 |
| 3750 bool FrameView::isPointInScrollbarCorner(const IntPoint& windowPoint) | 3785 bool FrameView::isPointInScrollbarCorner(const IntPoint& windowPoint) |
| 3751 { | 3786 { |
| 3752 if (!scrollbarCornerPresent()) | 3787 if (!scrollbarCornerPresent()) |
| 3753 return false; | 3788 return false; |
| 3754 | 3789 |
| 3755 IntPoint framePoint = convertFromContainingWindow(windowPoint); | 3790 IntPoint framePoint = convertFromContainingWindow(windowPoint); |
| 3756 | 3791 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3924 } | 3959 } |
| 3925 | 3960 |
| 3926 void FrameView::collectFrameTimingRequests(GraphicsLayerFrameTimingRequests& gra
phicsLayerTimingRequests) | 3961 void FrameView::collectFrameTimingRequests(GraphicsLayerFrameTimingRequests& gra
phicsLayerTimingRequests) |
| 3927 { | 3962 { |
| 3928 if (!m_frame->isLocalFrame()) | 3963 if (!m_frame->isLocalFrame()) |
| 3929 return; | 3964 return; |
| 3930 Frame* frame = m_frame.get(); | 3965 Frame* frame = m_frame.get(); |
| 3931 LocalFrame* localFrame = toLocalFrame(frame); | 3966 LocalFrame* localFrame = toLocalFrame(frame); |
| 3932 LayoutRect viewRect = localFrame->contentLayoutObject()->viewRect(); | 3967 LayoutRect viewRect = localFrame->contentLayoutObject()->viewRect(); |
| 3933 const LayoutBoxModelObject* paintInvalidationContainer = localFrame->content
LayoutObject()->containerForPaintInvalidation(); | 3968 const LayoutBoxModelObject* paintInvalidationContainer = localFrame->content
LayoutObject()->containerForPaintInvalidation(); |
| 3969 // If the frame is being throttled, its compositing state may not be up to d
ate. |
| 3970 if (!paintInvalidationContainer->enclosingLayer()->isAllowedToQueryCompositi
ngState()) |
| 3971 return; |
| 3934 const GraphicsLayer* graphicsLayer = paintInvalidationContainer->enclosingLa
yer()->graphicsLayerBacking(); | 3972 const GraphicsLayer* graphicsLayer = paintInvalidationContainer->enclosingLa
yer()->graphicsLayerBacking(); |
| 3935 | 3973 |
| 3936 if (!graphicsLayer) | 3974 if (!graphicsLayer) |
| 3937 return; | 3975 return; |
| 3938 | 3976 |
| 3939 DeprecatedPaintLayer::mapRectToPaintInvalidationBacking(localFrame->contentL
ayoutObject(), paintInvalidationContainer, viewRect); | 3977 DeprecatedPaintLayer::mapRectToPaintInvalidationBacking(localFrame->contentL
ayoutObject(), paintInvalidationContainer, viewRect); |
| 3940 | 3978 |
| 3941 graphicsLayerTimingRequests.add(graphicsLayer, Vector<std::pair<int64_t, Web
Rect>>()).storedValue->value.append(std::make_pair(m_frame->frameID(), enclosing
IntRect(viewRect))); | 3979 graphicsLayerTimingRequests.add(graphicsLayer, Vector<std::pair<int64_t, Web
Rect>>()).storedValue->value.append(std::make_pair(m_frame->frameID(), enclosing
IntRect(viewRect))); |
| 3942 } | 3980 } |
| 3943 | 3981 |
| 3982 void FrameView::updateViewportVisibilityIfNeeded() |
| 3983 { |
| 3984 // TODO(skyostil): Replace this with an intersection observer. |
| 3985 |
| 3986 // Without slimming paint v2 we can sometimes end up back in LayoutClean |
| 3987 // during painting (e.g., because of block selection gaps). |
| 3988 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 3989 ASSERT(shouldThrottleRenderingPipeline() || lifecycle().state() >= Docum
entLifecycle::PaintInvalidationClean); |
| 3990 else |
| 3991 ASSERT(shouldThrottleRenderingPipeline() || lifecycle().state() >= Docum
entLifecycle::LayoutClean); |
| 3992 if (!m_needsUpdateViewportVisibility) |
| 3993 return; |
| 3994 |
| 3995 // Our frame's bounds in our parent's content coordinates. |
| 3996 m_clippedBounds = frameRect(); |
| 3997 m_viewportVisibility = ViewportVisibility::Visible; |
| 3998 m_needsUpdateViewportVisibility = false; |
| 3999 |
| 4000 FrameView* parent = parentFrameView(); |
| 4001 if (!parent) |
| 4002 return; |
| 4003 ASSERT(!parent->m_needsUpdateViewportVisibility); |
| 4004 |
| 4005 // If our parent is hidden, then we are too. |
| 4006 if (parent->m_viewportVisibility == ViewportVisibility::Hidden) { |
| 4007 m_viewportVisibility = ViewportVisibility::Hidden; |
| 4008 return; |
| 4009 } |
| 4010 |
| 4011 // Transform our bounds into the root frame's content coordinate space. |
| 4012 m_clippedBounds = parent->contentsToRootFrame(m_clippedBounds); |
| 4013 |
| 4014 // TODO(skyostil): Expand the viewport to make it less likely to see stale c
ontent while scrolling. |
| 4015 IntRect viewport = parent->m_clippedBounds; |
| 4016 m_clippedBounds.intersect(viewport); |
| 4017 |
| 4018 // If our bounds got clipped away, we are invisible. |
| 4019 if (m_clippedBounds.isEmpty()) |
| 4020 m_viewportVisibility = ViewportVisibility::Hidden; |
| 4021 } |
| 4022 |
| 4023 void FrameView::finalizeLifecycleUpdate() |
| 4024 { |
| 4025 ASSERT(m_frame->isLocalRoot()); |
| 4026 updateThrottlingRecursive(SecurityOriginStatus::IsSameOrigin); |
| 4027 } |
| 4028 |
| 4029 void FrameView::updateThrottlingRecursive(SecurityOriginStatus securityOriginSta
tus) |
| 4030 { |
| 4031 ASSERT(!isInPerformLayout()); |
| 4032 // Without slimming paint v2 we can sometimes end up back in LayoutClean |
| 4033 // during painting (e.g., because of block selection gaps -- see |
| 4034 // BlockFlowPainter::paintSelection). |
| 4035 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 4036 ASSERT(shouldThrottleRenderingPipeline() || lifecycle().state() >= Docum
entLifecycle::PaintInvalidationClean); |
| 4037 else |
| 4038 ASSERT(shouldThrottleRenderingPipeline() || lifecycle().state() >= Docum
entLifecycle::LayoutClean); |
| 4039 bool wasThrottled = shouldThrottleRenderingPipeline(); |
| 4040 |
| 4041 updateViewportVisibilityIfNeeded(); |
| 4042 |
| 4043 // We only throttle the rendering pipeline in cross-origin frames. This is |
| 4044 // to avoid a situation where an ancestor frame directly depends on the |
| 4045 // pipeline timing of a descendant and breaks as a result of throttling. |
| 4046 // The rationale is that cross-origin frames must already communicate with |
| 4047 // asynchronous messages, so they should be able to tolerate some delay in |
| 4048 // receiving replies from a throttled peer. |
| 4049 // |
| 4050 // Check if we can access our parent's security origin. |
| 4051 if (securityOriginStatus == SecurityOriginStatus::IsSameOrigin && parentFram
eView()) { |
| 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 |