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

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

Issue 1415143005: Preparation for enabling slimming paint synchronized painting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix webkit_unit_tests Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 m_isPainting = false; 217 m_isPainting = false;
218 m_visuallyNonEmptyCharacterCount = 0; 218 m_visuallyNonEmptyCharacterCount = 0;
219 m_visuallyNonEmptyPixelCount = 0; 219 m_visuallyNonEmptyPixelCount = 0;
220 m_isVisuallyNonEmpty = false; 220 m_isVisuallyNonEmpty = false;
221 clearScrollAnchor(); 221 clearScrollAnchor();
222 m_viewportConstrainedObjects.clear(); 222 m_viewportConstrainedObjects.clear();
223 m_layoutSubtreeRootList.clear(); 223 m_layoutSubtreeRootList.clear();
224 } 224 }
225 225
226 template <typename Function> 226 template <typename Function>
227 void FrameView::forAllFrameViews(Function function) 227 void FrameView::forAllNonThrottlingFrameViews(Function function)
pdr. 2015/10/29 04:06:10 supernit: forAllNonThrottledFrameViews
Xianzhu 2015/10/29 04:22:01 Done.
228 { 228 {
229 for (Frame* frame = m_frame.get(); frame; frame = frame->tree().traverseNext (m_frame.get())) { 229 if (shouldThrottleRendering())
230 if (!frame->isLocalFrame()) 230 return;
231
232 function(*this);
233
234 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) {
235 if (!child->isLocalFrame())
231 continue; 236 continue;
232 if (FrameView* view = toLocalFrame(frame)->view()) 237 if (FrameView* childView = toLocalFrame(child)->view())
233 function(*view); 238 childView->forAllNonThrottlingFrameViews(function);
234 } 239 }
235 } 240 }
236 241
237 void FrameView::removeFromAXObjectCache() 242 void FrameView::removeFromAXObjectCache()
238 { 243 {
239 if (AXObjectCache* cache = axObjectCache()) { 244 if (AXObjectCache* cache = axObjectCache()) {
240 cache->remove(this); 245 cache->remove(this);
241 cache->childrenChanged(m_frame->pagePopupOwner()); 246 cache->childrenChanged(m_frame->pagePopupOwner());
242 } 247 }
243 } 248 }
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 } 1289 }
1285 1290
1286 bool FrameView::shouldSetCursor() const 1291 bool FrameView::shouldSetCursor() const
1287 { 1292 {
1288 Page* page = frame().page(); 1293 Page* page = frame().page();
1289 return page && page->visibilityState() != PageVisibilityStateHidden && page- >focusController().isActive() && page->settings().deviceSupportsMouse(); 1294 return page && page->visibilityState() != PageVisibilityStateHidden && page- >focusController().isActive() && page->settings().deviceSupportsMouse();
1290 } 1295 }
1291 1296
1292 void FrameView::scrollContentsIfNeededRecursive() 1297 void FrameView::scrollContentsIfNeededRecursive()
1293 { 1298 {
1294 forAllFrameViews([](FrameView& frameView) { 1299 forAllNonThrottlingFrameViews([](FrameView& frameView) {
1295 if (frameView.shouldThrottleRendering())
1296 return;
1297 frameView.scrollContentsIfNeeded(); 1300 frameView.scrollContentsIfNeeded();
1298 }); 1301 });
1299 } 1302 }
1300 1303
1301 void FrameView::invalidateBackgroundAttachmentFixedObjects() 1304 void FrameView::invalidateBackgroundAttachmentFixedObjects()
1302 { 1305 {
1303 for (const auto& layoutObject : m_backgroundAttachmentFixedObjects) 1306 for (const auto& layoutObject : m_backgroundAttachmentFixedObjects)
1304 layoutObject->setShouldDoFullPaintInvalidation(); 1307 layoutObject->setShouldDoFullPaintInvalidation();
1305 } 1308 }
1306 1309
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 CompositedLayerMapping* compositedLayerMapping = layoutView()->layer()-> compositedLayerMapping(); 1819 CompositedLayerMapping* compositedLayerMapping = layoutView()->layer()-> compositedLayerMapping();
1817 compositedLayerMapping->updateContentsOpaque(); 1820 compositedLayerMapping->updateContentsOpaque();
1818 if (compositedLayerMapping->mainGraphicsLayer()) 1821 if (compositedLayerMapping->mainGraphicsLayer())
1819 compositedLayerMapping->mainGraphicsLayer()->setNeedsDisplay(); 1822 compositedLayerMapping->mainGraphicsLayer()->setNeedsDisplay();
1820 } 1823 }
1821 recalculateScrollbarOverlayStyle(); 1824 recalculateScrollbarOverlayStyle();
1822 } 1825 }
1823 1826
1824 void FrameView::updateBackgroundRecursively(const Color& backgroundColor, bool t ransparent) 1827 void FrameView::updateBackgroundRecursively(const Color& backgroundColor, bool t ransparent)
1825 { 1828 {
1826 forAllFrameViews([backgroundColor, transparent](FrameView& frameView) { 1829 forAllNonThrottlingFrameViews([backgroundColor, transparent](FrameView& fram eView) {
1827 frameView.setTransparent(transparent); 1830 frameView.setTransparent(transparent);
1828 frameView.setBaseBackgroundColor(backgroundColor); 1831 frameView.setBaseBackgroundColor(backgroundColor);
1829 }); 1832 });
1830 } 1833 }
1831 1834
1832 void FrameView::scrollToAnchor() 1835 void FrameView::scrollToAnchor()
1833 { 1836 {
1834 RefPtrWillBeRawPtr<Node> anchorNode = m_scrollAnchor; 1837 RefPtrWillBeRawPtr<Node> anchorNode = m_scrollAnchor;
1835 if (!anchorNode) 1838 if (!anchorNode)
1836 return; 1839 return;
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
2449 invalidateTreeIfNeededRecursive(); 2452 invalidateTreeIfNeededRecursive();
2450 2453
2451 if (view->compositor()->inCompositingMode()) 2454 if (view->compositor()->inCompositingMode())
2452 scrollingCoordinator()->updateAfterCompositingChangeIfNeeded(); 2455 scrollingCoordinator()->updateAfterCompositingChangeIfNeeded();
2453 2456
2454 updateCompositedSelectionIfNeeded(); 2457 updateCompositedSelectionIfNeeded();
2455 2458
2456 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 2459 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
2457 updatePaintProperties(); 2460 updatePaintProperties();
2458 2461
2459 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled ()) { 2462 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled () && !m_frame->document()->printing()) {
2460 synchronizedPaint(interestRect); 2463 synchronizedPaint(interestRect);
2461 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 2464 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
2462 compositeForSlimmingPaintV2(); 2465 compositeForSlimmingPaintV2();
2463 } 2466 }
2464 2467
2465 if (RuntimeEnabledFeatures::frameTimingSupportEnabled()) 2468 if (RuntimeEnabledFeatures::frameTimingSupportEnabled())
2466 updateFrameTimingRequestsIfNeeded(); 2469 updateFrameTimingRequestsIfNeeded();
2467 2470
2468 ASSERT(!view->hasPendingSelection()); 2471 ASSERT(!view->hasPendingSelection());
2469 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationCl ean 2472 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationCl ean
2470 || (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && lifecycl e().state() == DocumentLifecycle::CompositingForSlimmingPaintV2Clean) 2473 || (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && lifecycl e().state() == DocumentLifecycle::CompositingForSlimmingPaintV2Clean)
2471 || (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEna bled() && lifecycle().state() == DocumentLifecycle::PaintClean)); 2474 || (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEna bled() && lifecycle().state() == DocumentLifecycle::PaintClean));
2472 } 2475 }
2473 } 2476 }
2474 2477
2475 updateViewportIntersectionsForSubtree(); 2478 updateViewportIntersectionsForSubtree();
2476 } 2479 }
2477 2480
2478 void FrameView::updatePaintProperties() 2481 void FrameView::updatePaintProperties()
2479 { 2482 {
2480 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); 2483 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
2481 2484
2482 forAllFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo( DocumentLifecycle::InUpdatePaintProperties); }); 2485 forAllNonThrottlingFrameViews([](FrameView& frameView) { frameView.lifecycle ().advanceTo(DocumentLifecycle::InUpdatePaintProperties); });
2483 PaintPropertyTreeBuilder().buildPropertyTrees(*this); 2486 PaintPropertyTreeBuilder().buildPropertyTrees(*this);
2484 forAllFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo( DocumentLifecycle::UpdatePaintPropertiesClean); }); 2487 forAllNonThrottlingFrameViews([](FrameView& frameView) { frameView.lifecycle ().advanceTo(DocumentLifecycle::UpdatePaintPropertiesClean); });
2485 } 2488 }
2486 2489
2487 void FrameView::synchronizedPaint(const LayoutRect* interestRect) 2490 void FrameView::synchronizedPaint(const LayoutRect* interestRect)
2488 { 2491 {
2489 ASSERT(RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()); 2492 ASSERT(RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled());
2490 ASSERT(frame() == page()->mainFrame() || (!frame().tree().parent()->isLocalF rame())); 2493 ASSERT(frame() == page()->mainFrame() || (!frame().tree().parent()->isLocalF rame()));
2491 2494
2492 LayoutView* view = layoutView(); 2495 LayoutView* view = layoutView();
2493 ASSERT(view); 2496 ASSERT(view);
2494 // TODO(chrishtr): figure out if there can be any GraphicsLayer above this o ne that draws content. 2497 forAllNonThrottlingFrameViews([](FrameView& frameView) { frameView.lifecycle ().advanceTo(DocumentLifecycle::InPaint); });
2495 GraphicsLayer* rootGraphicsLayer = view->layer()->graphicsLayerBacking();
2496 forAllFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo( DocumentLifecycle::InPaint); });
2497 2498
2498 // A null graphics layer can occur for painting of SVG images that are not p arented into the main frame tree. 2499 // A null graphics layer can occur for painting of SVG images that are not p arented into the main frame tree.
2499 if (rootGraphicsLayer) { 2500 if (GraphicsLayer* rootGraphicsLayer = view->compositor()->rootGraphicsLayer ()) {
2501 while (GraphicsLayer* parent = rootGraphicsLayer->parent())
2502 rootGraphicsLayer = parent;
2500 synchronizedPaintRecursively(rootGraphicsLayer, interestRect); 2503 synchronizedPaintRecursively(rootGraphicsLayer, interestRect);
2501 } 2504 }
2502 2505
2503 forAllFrameViews([](FrameView& frameView) { 2506 forAllNonThrottlingFrameViews([](FrameView& frameView) {
2504 frameView.lifecycle().advanceTo(DocumentLifecycle::PaintClean); 2507 frameView.lifecycle().advanceTo(DocumentLifecycle::PaintClean);
2505 frameView.layoutView()->layer()->clearNeedsRepaintRecursively(); 2508 frameView.layoutView()->layer()->clearNeedsRepaintRecursively();
2506 }); 2509 });
2507 } 2510 }
2508 2511
2509 void FrameView::synchronizedPaintRecursively(GraphicsLayer* graphicsLayer, const LayoutRect* interestRect) 2512 void FrameView::synchronizedPaintRecursively(GraphicsLayer* graphicsLayer, const LayoutRect* interestRect)
2510 { 2513 {
2511 ASSERT(graphicsLayer->paintController()); 2514 ASSERT(graphicsLayer->paintController());
2512 GraphicsContext context(*graphicsLayer->paintController()); 2515 GraphicsContext context(*graphicsLayer->paintController());
2513 2516
2517 if (GraphicsLayer* maskLayer = graphicsLayer->maskLayer())
2518 synchronizedPaintRecursively(maskLayer, interestRect);
2519 if (GraphicsLayer* contentsClippingMaskLayer = graphicsLayer->contentsClippi ngMaskLayer())
2520 synchronizedPaintRecursively(contentsClippingMaskLayer, interestRect);
2521 if (GraphicsLayer* replicaLayer = graphicsLayer->replicaLayer())
2522 synchronizedPaintRecursively(replicaLayer, interestRect);
2523
2514 // TODO(chrishtr): fix unit tests to not inject one-off interest rects. 2524 // TODO(chrishtr): fix unit tests to not inject one-off interest rects.
2515 if (interestRect) 2525 if (interestRect)
2516 graphicsLayer->paint(context, roundedIntRect(*interestRect)); 2526 graphicsLayer->paint(context, roundedIntRect(*interestRect));
2517 else 2527 else
2518 graphicsLayer->paintIfNeeded(context); 2528 graphicsLayer->paintIfNeeded(context);
2519 2529
2520 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 2530 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled())
2521 graphicsLayer->paintController()->commitNewDisplayItems(); 2531 graphicsLayer->paintController()->commitNewDisplayItems();
2522 2532
2523 for (auto& child : graphicsLayer->children()) 2533 for (auto& child : graphicsLayer->children())
2524 synchronizedPaintRecursively(child, interestRect); 2534 synchronizedPaintRecursively(child, interestRect);
2525 } 2535 }
2526 2536
2527 void FrameView::compositeForSlimmingPaintV2() 2537 void FrameView::compositeForSlimmingPaintV2()
2528 { 2538 {
2529 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); 2539 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
2530 ASSERT(frame() == page()->mainFrame() || (!frame().tree().parent()->isLocalF rame())); 2540 ASSERT(frame() == page()->mainFrame() || (!frame().tree().parent()->isLocalF rame()));
2531 2541
2532 forAllFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo( DocumentLifecycle::InCompositingForSlimmingPaintV2); }); 2542 forAllNonThrottlingFrameViews([](FrameView& frameView) { frameView.lifecycle ().advanceTo(DocumentLifecycle::InCompositingForSlimmingPaintV2); });
2533 2543
2534 // Detached frames can have no root graphics layer. 2544 // Detached frames can have no root graphics layer.
2535 if (GraphicsLayer* rootGraphicsLayer = layoutView()->layer()->graphicsLayerB acking()) 2545 if (GraphicsLayer* rootGraphicsLayer = layoutView()->layer()->graphicsLayerB acking())
2536 rootGraphicsLayer->paintController()->commitNewDisplayItems(); 2546 rootGraphicsLayer->paintController()->commitNewDisplayItems();
2537 2547
2538 forAllFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo( DocumentLifecycle::CompositingForSlimmingPaintV2Clean); }); 2548 forAllNonThrottlingFrameViews([](FrameView& frameView) { frameView.lifecycle ().advanceTo(DocumentLifecycle::CompositingForSlimmingPaintV2Clean); });
2539 } 2549 }
2540 2550
2541 void FrameView::updateFrameTimingRequestsIfNeeded() 2551 void FrameView::updateFrameTimingRequestsIfNeeded()
2542 { 2552 {
2543 GraphicsLayerFrameTimingRequests graphicsLayerTimingRequests; 2553 GraphicsLayerFrameTimingRequests graphicsLayerTimingRequests;
2544 // TODO(mpb) use a 'dirty' bit to not call this every time. 2554 // TODO(mpb) use a 'dirty' bit to not call this every time.
2545 collectFrameTimingRequestsRecursive(graphicsLayerTimingRequests); 2555 collectFrameTimingRequestsRecursive(graphicsLayerTimingRequests);
2546 2556
2547 for (const auto& iter : graphicsLayerTimingRequests) { 2557 for (const auto& iter : graphicsLayerTimingRequests) {
2548 const GraphicsLayer* graphicsLayer = iter.key; 2558 const GraphicsLayer* graphicsLayer = iter.key;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2612 2622
2613 // We need to stop recursing here since a child frame view might not be thro ttled 2623 // We need to stop recursing here since a child frame view might not be thro ttled
2614 // even though we are (e.g., it didn't compute its visibility yet). 2624 // even though we are (e.g., it didn't compute its visibility yet).
2615 if (shouldThrottleRendering()) 2625 if (shouldThrottleRendering())
2616 return; 2626 return;
2617 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root", layoutView()->debugName().ascii()); 2627 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root", layoutView()->debugName().ascii());
2618 2628
2619 Vector<LayoutObject*> pendingDelayedPaintInvalidations; 2629 Vector<LayoutObject*> pendingDelayedPaintInvalidations;
2620 PaintInvalidationState rootPaintInvalidationState(*layoutView(), pendingDela yedPaintInvalidations); 2630 PaintInvalidationState rootPaintInvalidationState(*layoutView(), pendingDela yedPaintInvalidations);
2621 2631
2622 invalidateTreeIfNeeded(rootPaintInvalidationState); 2632 if (lifecycle().state() < DocumentLifecycle::PaintInvalidationClean)
chrishtr 2015/10/28 21:12:58 Why this change?
chrishtr 2015/10/29 20:22:45 Is this the same reason as the comment thread belo
2633 invalidateTreeIfNeeded(rootPaintInvalidationState);
2623 2634
2624 // Some frames may be not reached during the above invalidateTreeIfNeeded be cause 2635 // Some frames may be not reached during the above invalidateTreeIfNeeded be cause
2625 // - the frame is a detached frame; or 2636 // - the frame is a detached frame; or
2626 // - it didn't need paint invalidation. 2637 // - it didn't need paint invalidation.
2627 // We need to call invalidateTreeIfNeededRecursive() for such frames to fini sh required 2638 // We need to call invalidateTreeIfNeededRecursive() for such frames to fini sh required
2628 // paint invalidation and advance their life cycle state. 2639 // paint invalidation and advance their life cycle state.
2629 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { 2640 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) {
2630 if (!child->isLocalFrame()) 2641 if (child->isLocalFrame())
2631 continue; 2642 toLocalFrame(child)->view()->invalidateTreeIfNeededRecursive();
2632 FrameView* childFrameView = toLocalFrame(child)->view();
2633 if (childFrameView->lifecycle().state() < DocumentLifecycle::PaintInvali dationClean)
chrishtr 2015/10/28 21:12:58 Why these changes? What was wrong?
Xianzhu 2015/10/29 04:22:01 This check is moved out, so that we also check it
chrishtr 2015/10/29 20:22:45 Not sure what you mean..
Xianzhu 2015/10/30 00:03:57 The above line is moved to new line 2632. Previous
2634 childFrameView->invalidateTreeIfNeededRecursive();
2635 } 2643 }
2636 2644
2637 // Process objects needing paint invalidation on the next frame. See the def inition of PaintInvalidationDelayedFull for more details. 2645 // Process objects needing paint invalidation on the next frame. See the def inition of PaintInvalidationDelayedFull for more details.
2638 for (auto& target : pendingDelayedPaintInvalidations) 2646 for (auto& target : pendingDelayedPaintInvalidations)
2639 target->setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull); 2647 target->setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull);
2640 } 2648 }
2641 2649
2642 void FrameView::enableAutoSizeMode(const IntSize& minSize, const IntSize& maxSiz e) 2650 void FrameView::enableAutoSizeMode(const IntSize& minSize, const IntSize& maxSiz e)
2643 { 2651 {
2644 if (!m_autoSizeInfo) 2652 if (!m_autoSizeInfo)
(...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after
4078 } 4086 }
4079 4087
4080 bool FrameView::canThrottleRendering() const 4088 bool FrameView::canThrottleRendering() const
4081 { 4089 {
4082 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) 4090 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled())
4083 return false; 4091 return false;
4084 return m_hiddenForThrottling && m_crossOriginForThrottling; 4092 return m_hiddenForThrottling && m_crossOriginForThrottling;
4085 } 4093 }
4086 4094
4087 } // namespace blink 4095 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698