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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutObject.cpp

Issue 2214253002: Don't traverse non-stacked layer under composited child in traverseNonCompositingDescendants (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: !hasLayer || !isStacked Created 4 years, 4 months 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 3471 matching lines...) Expand 10 before | Expand all | Expand 10 after
3482 3482
3483 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() 3483 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts()
3484 : m_disabler(&gDisablePaintInvalidationStateAsserts, true) 3484 : m_disabler(&gDisablePaintInvalidationStateAsserts, true)
3485 { 3485 {
3486 } 3486 }
3487 3487
3488 namespace { 3488 namespace {
3489 3489
3490 // TODO(trchen): Use std::function<void, LayoutObject&> when available. 3490 // TODO(trchen): Use std::function<void, LayoutObject&> when available.
3491 template <typename LayoutObjectTraversalFunctor> 3491 template <typename LayoutObjectTraversalFunctor>
3492 void traverseNonCompositingDescendants(LayoutObject&, const LayoutObjectTraversa lFunctor&); 3492 void traverseNonCompositingDescendantsInPaintOrder(LayoutObject&, const LayoutOb jectTraversalFunctor&);
3493 3493
3494 template <typename LayoutObjectTraversalFunctor> 3494 template <typename LayoutObjectTraversalFunctor>
3495 void findNonCompositedDescendantLayerToTraverse(LayoutObject& object, const Layo utObjectTraversalFunctor& functor) 3495 void traverseNonCompositingDescendantsBelongingToAncestorPaintInvalidationContai ner(LayoutObject& object, const LayoutObjectTraversalFunctor& functor)
3496 { 3496 {
3497 // |object| is a paint invalidation container but is not a stacking context, so the paint
3498 // invalidation container of stacked descendants don't belong to |object| bu t belong to
3499 // an ancestor. This function traverses all such descendants.
3500 DCHECK(object.isPaintInvalidationContainer() && !object.styleRef().isStackin gContext());
3501
3497 LayoutObject* descendant = object.nextInPreOrder(&object); 3502 LayoutObject* descendant = object.nextInPreOrder(&object);
3498 while (descendant) { 3503 while (descendant) {
3499 // Case 1: If the descendant has no layer, keep searching until we find a layer. 3504 if (!descendant->hasLayer() || !descendant->styleRef().isStacked()) {
3500 if (!descendant->hasLayer()) { 3505 // Case 1: The descendant is not stacked (or is stacked but has not been
3506 // allocated a layer yet during style change), so either it's a pain t invalidation
3507 // container in the same situation as |object|, or its paint invalid ation
3508 // container is in such situation. Keep searching until a stacked la yer is found.
3501 descendant = descendant->nextInPreOrder(&object); 3509 descendant = descendant->nextInPreOrder(&object);
3502 continue; 3510 } else if (!descendant->isPaintInvalidationContainer()) {
3511 // Case 2: The descendant is stacked and is not composited.
3512 // The invalidation container of its subtree is our ancestor,
3513 // thus recur into the subtree.
3514 traverseNonCompositingDescendantsInPaintOrder(*descendant, functor);
3515 descendant = descendant->nextInPreOrderAfterChildren(&object);
3516 } else if (descendant->styleRef().isStackingContext()) {
3517 // Case 3: The descendant is an invalidation container and is a stac king context.
3518 // No objects in the subtree can have invalidation container outside of it,
3519 // thus skip the whole subtree.
3520 descendant = descendant->nextInPreOrderAfterChildren(&object);
3521 } else {
3522 // Case 4: The descendant is an invalidation container but not a sta cking context.
3523 // This is the same situation as |object|, thus keep searching.
3524 descendant = descendant->nextInPreOrder(&object);
3503 } 3525 }
3504 // Case 2: The descendant has a layer and is not composited.
3505 // The invalidation container of its subtree is our parent,
3506 // thus recur into the subtree.
3507 if (!descendant->isPaintInvalidationContainer()) {
3508 traverseNonCompositingDescendants(*descendant, functor);
3509 descendant = descendant->nextInPreOrderAfterChildren(&object);
3510 continue;
3511 }
3512 // Case 3: The descendant is an invalidation container and is a stacking context.
3513 // No objects in the subtree can have invalidation container outside of it,
3514 // thus skip the whole subtree.
3515 if (descendant->styleRef().isStackingContext()) {
3516 descendant = descendant->nextInPreOrderAfterChildren(&object);
3517 continue;
3518 }
3519 // Case 4: The descendant is an invalidation container but not a stackin g context.
3520 // This is the same situation as the root, thus keep searching.
3521 descendant = descendant->nextInPreOrder(&object);
3522 } 3526 }
3523 } 3527 }
3524 3528
3525 template <typename LayoutObjectTraversalFunctor> 3529 template <typename LayoutObjectTraversalFunctor>
3526 void traverseNonCompositingDescendants(LayoutObject& object, const LayoutObjectT raversalFunctor& functor) 3530 void traverseNonCompositingDescendantsInPaintOrder(LayoutObject& object, const L ayoutObjectTraversalFunctor& functor)
3527 { 3531 {
3528 functor(object); 3532 functor(object);
3529 LayoutObject* descendant = object.nextInPreOrder(&object); 3533 LayoutObject* descendant = object.nextInPreOrder(&object);
3530 while (descendant) { 3534 while (descendant) {
3531 if (!descendant->isPaintInvalidationContainer()) { 3535 if (!descendant->isPaintInvalidationContainer()) {
3532 functor(*descendant); 3536 functor(*descendant);
3533 descendant = descendant->nextInPreOrder(&object); 3537 descendant = descendant->nextInPreOrder(&object);
3534 continue; 3538 } else if (descendant->styleRef().isStackingContext()) {
3539 // The descendant is an invalidation container and is a stacking con text.
3540 // No objects in the subtree can have invalidation container outside of it,
3541 // thus skip the whole subtree.
3542 descendant = descendant->nextInPreOrderAfterChildren(&object);
3543 } else {
3544 // If a paint invalidation container is not a stacking context,
3545 // some of its descendants may belong to the parent container.
3546 traverseNonCompositingDescendantsBelongingToAncestorPaintInvalidatio nContainer(*descendant, functor);
3547 descendant = descendant->nextInPreOrderAfterChildren(&object);
3535 } 3548 }
3536 if (descendant->styleRef().isStackingContext()) {
3537 descendant = descendant->nextInPreOrderAfterChildren(&object);
3538 continue;
3539 }
3540
3541 // If a paint invalidation container is not a stacking context,
3542 // some of its descendants may belong to the parent container.
3543 findNonCompositedDescendantLayerToTraverse(*descendant, functor);
3544 descendant = descendant->nextInPreOrderAfterChildren(&object);
3545 } 3549 }
3546 } 3550 }
3547 3551
3548 } // unnamed namespace 3552 } // unnamed namespace
3549 3553
3550 void LayoutObject::invalidateDisplayItemClientsIncludingNonCompositingDescendant s(PaintInvalidationReason reason) const 3554 void LayoutObject::invalidateDisplayItemClientsIncludingNonCompositingDescendant s(PaintInvalidationReason reason) const
3551 { 3555 {
3552 // This is valid because we want to invalidate the client in the display ite m list of the current backing. 3556 // This is valid because we want to invalidate the client in the display ite m list of the current backing.
3553 DisableCompositingQueryAsserts disabler; 3557 DisableCompositingQueryAsserts disabler;
3554 3558
3555 slowSetPaintingLayerNeedsRepaint(); 3559 slowSetPaintingLayerNeedsRepaint();
3556 traverseNonCompositingDescendants(const_cast<LayoutObject&>(*this), [reason] (LayoutObject& object) { 3560 traverseNonCompositingDescendantsInPaintOrder(const_cast<LayoutObject&>(*thi s), [reason](LayoutObject& object) {
3557 if (object.hasLayer() && toLayoutBoxModelObject(object).hasSelfPaintingL ayer()) 3561 if (object.hasLayer() && toLayoutBoxModelObject(object).hasSelfPaintingL ayer())
3558 toLayoutBoxModelObject(object).layer()->setNeedsRepaint(); 3562 toLayoutBoxModelObject(object).layer()->setNeedsRepaint();
3559 object.invalidateDisplayItemClients(reason); 3563 object.invalidateDisplayItemClients(reason);
3560 }); 3564 });
3561 } 3565 }
3562 3566
3563 void LayoutObject::invalidatePaintOfPreviousPaintInvalidationRect(const LayoutBo xModelObject& paintInvalidationContainer, PaintInvalidationReason reason) 3567 void LayoutObject::invalidatePaintOfPreviousPaintInvalidationRect(const LayoutBo xModelObject& paintInvalidationContainer, PaintInvalidationReason reason)
3564 { 3568 {
3565 // It's caller's responsibility to ensure enclosingSelfPaintingLayer's needs Repaint is set. 3569 // It's caller's responsibility to ensure enclosingSelfPaintingLayer's needs Repaint is set.
3566 // Don't set the flag here because getting enclosingSelfPaintLayer has cost and the caller can use 3570 // Don't set the flag here because getting enclosingSelfPaintLayer has cost and the caller can use
(...skipping 12 matching lines...) Expand all
3579 // Clear previous paint invalidation rect on the original paint invalidation container to avoid 3583 // Clear previous paint invalidation rect on the original paint invalidation container to avoid
3580 // under-invalidation if the new paint invalidation rect on the new paint in validation container 3584 // under-invalidation if the new paint invalidation rect on the new paint in validation container
3581 // happens to be the same as the old one. 3585 // happens to be the same as the old one.
3582 clearPreviousPaintInvalidationRects(); 3586 clearPreviousPaintInvalidationRects();
3583 } 3587 }
3584 3588
3585 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants() 3589 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants()
3586 { 3590 {
3587 // Since we're only painting non-composited layers, we know that they all sh are the same paintInvalidationContainer. 3591 // Since we're only painting non-composited layers, we know that they all sh are the same paintInvalidationContainer.
3588 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn validation(); 3592 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn validation();
3589 traverseNonCompositingDescendants(*this, [&paintInvalidationContainer](Layou tObject& object) { 3593 traverseNonCompositingDescendantsInPaintOrder(*this, [&paintInvalidationCont ainer](LayoutObject& object) {
3590 if (object.hasLayer()) 3594 if (object.hasLayer())
3591 toLayoutBoxModelObject(object).layer()->setNeedsRepaint(); 3595 toLayoutBoxModelObject(object).layer()->setNeedsRepaint();
3592 object.invalidatePaintOfPreviousPaintInvalidationRect(paintInvalidationC ontainer, PaintInvalidationSubtree); 3596 object.invalidatePaintOfPreviousPaintInvalidationRect(paintInvalidationC ontainer, PaintInvalidationSubtree);
3593 }); 3597 });
3594 } 3598 }
3595 3599
3596 void LayoutObject::setShouldDoFullPaintInvalidationIncludingNonCompositingDescen dants() 3600 void LayoutObject::setShouldDoFullPaintInvalidationIncludingNonCompositingDescen dants()
3597 { 3601 {
3598 // Clear first because PaintInvalidationSubtree overrides other full paint i nvalidation reasons. 3602 // Clear first because PaintInvalidationSubtree overrides other full paint i nvalidation reasons.
3599 clearShouldDoFullPaintInvalidation(); 3603 clearShouldDoFullPaintInvalidation();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
3674 const blink::LayoutObject* root = object1; 3678 const blink::LayoutObject* root = object1;
3675 while (root->parent()) 3679 while (root->parent())
3676 root = root->parent(); 3680 root = root->parent();
3677 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); 3681 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0);
3678 } else { 3682 } else {
3679 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); 3683 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)");
3680 } 3684 }
3681 } 3685 }
3682 3686
3683 #endif 3687 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698