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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayer.cpp

Issue 2521033003: Reland: Don't early out recursion into PaintLayerChildren when computing composited bounds. (Closed)
Patch Set: none Created 4 years 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) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
6 * 6 *
7 * Other contributors: 7 * Other contributors:
8 * Robert O'Callahan <roc+@cs.cmu.edu> 8 * Robert O'Callahan <roc+@cs.cmu.edu>
9 * David Baron <dbaron@fas.harvard.edu> 9 * David Baron <dbaron@fas.harvard.edu>
10 * Christian Biesinger <cbiesinger@web.de> 10 * Christian Biesinger <cbiesinger@web.de>
(...skipping 2457 matching lines...) Expand 10 before | Expand all | Expand 10 after
2468 } 2468 }
2469 2469
2470 LayoutRect PaintLayer::boundingBoxForCompositingOverlapTest() const { 2470 LayoutRect PaintLayer::boundingBoxForCompositingOverlapTest() const {
2471 // Apply NeverIncludeTransformForAncestorLayer, because the geometry map in 2471 // Apply NeverIncludeTransformForAncestorLayer, because the geometry map in
2472 // CompositingInputsUpdater will take care of applying the transform of |this| 2472 // CompositingInputsUpdater will take care of applying the transform of |this|
2473 // (== the ancestorLayer argument to boundingBoxForCompositing). 2473 // (== the ancestorLayer argument to boundingBoxForCompositing).
2474 // TODO(trchen): Layer fragmentation is inhibited across compositing boundary. 2474 // TODO(trchen): Layer fragmentation is inhibited across compositing boundary.
2475 // Should we return the unfragmented bounds for overlap testing? Or perhaps 2475 // Should we return the unfragmented bounds for overlap testing? Or perhaps
2476 // assume fragmented layers always overlap? 2476 // assume fragmented layers always overlap?
2477 return overlapBoundsIncludeChildren() 2477 return overlapBoundsIncludeChildren()
2478 ? boundingBoxForCompositing(this, 2478 ? boundingBoxForCompositingInternal(
2479 NeverIncludeTransformForAncestorLayer) 2479 this, nullptr, NeverIncludeTransformForAncestorLayer)
2480 : fragmentsBoundingBox(this); 2480 : fragmentsBoundingBox(this);
2481 } 2481 }
2482 2482
2483 bool PaintLayer::overlapBoundsIncludeChildren() const { 2483 bool PaintLayer::overlapBoundsIncludeChildren() const {
2484 return hasFilterThatMovesPixels(); 2484 return hasFilterThatMovesPixels();
2485 } 2485 }
2486 2486
2487 static void expandRectForStackingChildren( 2487 void PaintLayer::expandRectForStackingChildren(
2488 const PaintLayer* ancestorLayer, 2488 const PaintLayer* compositedLayer,
2489 LayoutRect& result, 2489 LayoutRect& result,
2490 PaintLayer::CalculateBoundsOptions options) { 2490 PaintLayer::CalculateBoundsOptions options) const {
2491 DCHECK(ancestorLayer->stackingNode()->isStackingContext() || 2491 DCHECK(stackingNode()->isStackingContext() ||
2492 !ancestorLayer->stackingNode()->hasPositiveZOrderList()); 2492 !stackingNode()->hasPositiveZOrderList());
2493 2493
2494 #if DCHECK_IS_ON() 2494 #if DCHECK_IS_ON()
2495 LayerListMutationDetector mutationChecker( 2495 LayerListMutationDetector mutationChecker(
2496 const_cast<PaintLayer*>(ancestorLayer)->stackingNode()); 2496 const_cast<PaintLayer*>(this)->stackingNode());
2497 #endif 2497 #endif
2498 2498
2499 PaintLayerStackingNodeIterator iterator(*ancestorLayer->stackingNode(), 2499 PaintLayerStackingNodeIterator iterator(*this->stackingNode(), AllChildren);
2500 AllChildren);
2501 while (PaintLayerStackingNode* node = iterator.next()) { 2500 while (PaintLayerStackingNode* node = iterator.next()) {
2502 // Here we exclude both directly composited layers and squashing layers 2501 // Here we exclude both directly composited layers and squashing layers
2503 // because those Layers don't paint into the graphics layer 2502 // because those Layers don't paint into the graphics layer
2504 // for this Layer. For example, the bounds of squashed Layers 2503 // for this Layer. For example, the bounds of squashed Layers
2505 // will be included in the computation of the appropriate squashing 2504 // will be included in the computation of the appropriate squashing
2506 // GraphicsLayer. 2505 // GraphicsLayer.
2507 if (options != PaintLayer::CalculateBoundsOptions:: 2506 if (options != PaintLayer::CalculateBoundsOptions::
2508 IncludeTransformsAndCompositedChildLayers && 2507 IncludeTransformsAndCompositedChildLayers &&
2509 node->layer()->compositingState() != NotComposited) 2508 node->layer()->compositingState() != NotComposited)
2510 continue; 2509 continue;
2511 result.unite( 2510 result.unite(node->layer()->boundingBoxForCompositingInternal(
2512 node->layer()->boundingBoxForCompositing(ancestorLayer, options)); 2511 compositedLayer, this, options));
2513 } 2512 }
2514 } 2513 }
2515 2514
2516 LayoutRect PaintLayer::physicalBoundingBoxIncludingStackingChildren( 2515 LayoutRect PaintLayer::physicalBoundingBoxIncludingStackingChildren(
2517 const LayoutPoint& offsetFromRoot, 2516 const LayoutPoint& offsetFromRoot,
2518 CalculateBoundsOptions options) const { 2517 CalculateBoundsOptions options) const {
2519 LayoutRect result = physicalBoundingBox(LayoutPoint()); 2518 LayoutRect result = physicalBoundingBox(LayoutPoint());
2520 2519
2521 const_cast<PaintLayer*>(this)->stackingNode()->updateLayerListsIfNeeded(); 2520 const_cast<PaintLayer*>(this)->stackingNode()->updateLayerListsIfNeeded();
2522 2521
2523 expandRectForStackingChildren(this, result, options); 2522 expandRectForStackingChildren(this, result, options);
2524 2523
2525 result.moveBy(offsetFromRoot); 2524 result.moveBy(offsetFromRoot);
2526 return result; 2525 return result;
2527 } 2526 }
2528 2527
2529 LayoutRect PaintLayer::boundingBoxForCompositing( 2528 LayoutRect PaintLayer::boundingBoxForCompositing() const {
2530 const PaintLayer* ancestorLayer, 2529 return boundingBoxForCompositingInternal(
2530 this, nullptr, MaybeIncludeTransformForAncestorLayer);
2531 }
2532
2533 LayoutRect PaintLayer::boundingBoxForCompositingInternal(
2534 const PaintLayer* compositedLayer,
2535 const PaintLayer* stackingParent,
2531 CalculateBoundsOptions options) const { 2536 CalculateBoundsOptions options) const {
2532 if (!isSelfPaintingLayer()) 2537 if (!isSelfPaintingLayer())
2533 return LayoutRect(); 2538 return LayoutRect();
2534 2539
2535 if (!ancestorLayer)
2536 ancestorLayer = this;
2537
2538 // FIXME: This could be improved to do a check like 2540 // FIXME: This could be improved to do a check like
2539 // hasVisibleNonCompositingDescendantLayers() (bug 92580). 2541 // hasVisibleNonCompositingDescendantLayers() (bug 92580).
2540 if (this != ancestorLayer && !hasVisibleContent() && !hasVisibleDescendant()) 2542 if (this != compositedLayer && !hasVisibleContent() &&
2543 !hasVisibleDescendant())
2541 return LayoutRect(); 2544 return LayoutRect();
2542 2545
2543 // Without composited scrolling, the root layer is the size of the document. 2546 // Without composited scrolling, the root layer is the size of the document.
2544 if (isRootLayer() && !needsCompositedScrolling()) 2547 if (isRootLayer() && !needsCompositedScrolling())
2545 return LayoutRect(m_layoutObject->view()->documentRect()); 2548 return LayoutRect(m_layoutObject->view()->documentRect());
2546 2549
2547 // The layer created for the LayoutFlowThread is just a helper for painting 2550 // The layer created for the LayoutFlowThread is just a helper for painting
2548 // and hit-testing, and should not contribute to the bounding box. The 2551 // and hit-testing, and should not contribute to the bounding box. The
2549 // LayoutMultiColumnSets will contribute the correct size for the layout 2552 // LayoutMultiColumnSets will contribute the correct size for the layout
2550 // content of the multicol container. 2553 // content of the multicol container.
2551 if (layoutObject()->isLayoutFlowThread()) 2554 if (layoutObject()->isLayoutFlowThread())
2552 return LayoutRect(); 2555 return LayoutRect();
2553 2556
2557 const_cast<PaintLayer*>(this)->stackingNode()->updateLayerListsIfNeeded();
2558
2554 // If there is a clip applied by an ancestor to this PaintLayer but below or 2559 // If there is a clip applied by an ancestor to this PaintLayer but below or
2555 // equal to |ancestorLayer|, use that clip as the bounds rather than the 2560 // equal to |ancestorLayer|, use that clip as the bounds rather than the
2556 // recursive bounding boxes, since the latter may be larger than the actual 2561 // recursive bounding boxes, since the latter may be larger than the actual
2557 // size. See https://bugs.webkit.org/show_bug.cgi?id=80372 for examples. 2562 // size. See https://bugs.webkit.org/show_bug.cgi?id=80372 for examples.
2558 LayoutRect result = clipper().localClipRect(ancestorLayer); 2563 LayoutRect result = clipper().localClipRect(compositedLayer);
2559 // TODO(chrishtr): avoid converting to IntRect and back. 2564 // TODO(chrishtr): avoid converting to IntRect and back.
2560 if (result == LayoutRect(LayoutRect::infiniteIntRect())) { 2565 if (result == LayoutRect(LayoutRect::infiniteIntRect()))
2561 result = physicalBoundingBox(LayoutPoint()); 2566 result = physicalBoundingBox(LayoutPoint());
2562 2567
2563 const_cast<PaintLayer*>(this)->stackingNode()->updateLayerListsIfNeeded(); 2568 expandRectForStackingChildren(compositedLayer, result, options);
2564 2569
2565 expandRectForStackingChildren(this, result, options); 2570 // Only enlarge by the filter outsets if we know the filter is going to be
2566 2571 // rendered in software. Accelerated filters will handle their own outsets.
2567 // Only enlarge by the filter outsets if we know the filter is going to be 2572 if (paintsWithFilters())
2568 // rendered in software. Accelerated filters will handle their own outsets. 2573 result = mapLayoutRectForFilter(result);
2569 if (paintsWithFilters())
2570 result = mapLayoutRectForFilter(result);
2571 }
2572 2574
2573 if (transform() && (options == IncludeTransformsAndCompositedChildLayers || 2575 if (transform() && (options == IncludeTransformsAndCompositedChildLayers ||
2574 ((paintsWithTransform(GlobalPaintNormalPhase) && 2576 ((paintsWithTransform(GlobalPaintNormalPhase) &&
2575 (this != ancestorLayer || 2577 (this != compositedLayer ||
2576 options == MaybeIncludeTransformForAncestorLayer))))) 2578 options == MaybeIncludeTransformForAncestorLayer)))))
2577 result = transform()->mapRect(result); 2579 result = transform()->mapRect(result);
2578 2580
2579 if (shouldFragmentCompositedBounds(ancestorLayer)) { 2581 if (shouldFragmentCompositedBounds(compositedLayer)) {
2580 convertFromFlowThreadToVisualBoundingBoxInAncestor(ancestorLayer, result); 2582 convertFromFlowThreadToVisualBoundingBoxInAncestor(compositedLayer, result);
2581 return result; 2583 return result;
2582 } 2584 }
2583 LayoutPoint delta; 2585
2584 convertToLayerCoords(ancestorLayer, delta); 2586 if (stackingParent) {
2585 result.moveBy(delta); 2587 LayoutPoint delta;
2588 convertToLayerCoords(stackingParent, delta);
2589 result.moveBy(delta);
2590 }
2586 return result; 2591 return result;
2587 } 2592 }
2588 2593
2589 CompositingState PaintLayer::compositingState() const { 2594 CompositingState PaintLayer::compositingState() const {
2590 DCHECK(isAllowedToQueryCompositingState()); 2595 DCHECK(isAllowedToQueryCompositingState());
2591 2596
2592 // This is computed procedurally so there is no redundant state variable that 2597 // This is computed procedurally so there is no redundant state variable that
2593 // can get out of sync from the real actual compositing state. 2598 // can get out of sync from the real actual compositing state.
2594 2599
2595 if (groupedMapping()) { 2600 if (groupedMapping()) {
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
3250 } 3255 }
3251 3256
3252 void showLayerTree(const blink::LayoutObject* layoutObject) { 3257 void showLayerTree(const blink::LayoutObject* layoutObject) {
3253 if (!layoutObject) { 3258 if (!layoutObject) {
3254 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; 3259 LOG(INFO) << "Cannot showLayerTree. Root is (nil)";
3255 return; 3260 return;
3256 } 3261 }
3257 showLayerTree(layoutObject->enclosingLayer()); 3262 showLayerTree(layoutObject->enclosingLayer());
3258 } 3263 }
3259 #endif 3264 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.h ('k') | third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698