Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // Case 1: If the descendant has no layer, keep searching until we find a layer. |
| 3500 if (!descendant->hasLayer()) { | 3505 if (!descendant->hasLayer()) { |
|
trchen
2016/08/04 23:34:55
How about this:
// Case 1: If the descendant is n
Xianzhu
2016/08/05 00:27:07
Done.
| |
| 3501 descendant = descendant->nextInPreOrder(&object); | 3506 descendant = descendant->nextInPreOrder(&object); |
| 3502 continue; | 3507 continue; |
| 3503 } | 3508 } |
| 3504 // Case 2: The descendant has a layer and is not composited. | 3509 // 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()) { | 3510 if (!descendant->isPaintInvalidationContainer()) { |
|
trchen
2016/08/04 23:34:55
// Case 2: The descendant is stacked but not compo
Xianzhu
2016/08/05 00:27:07
Done.
| |
| 3508 traverseNonCompositingDescendants(*descendant, functor); | 3511 // Case 2a: The descendant is stacked. The invalidation container of |
| 3509 descendant = descendant->nextInPreOrderAfterChildren(&object); | 3512 // its subtree is our ancestor, thus recur into the subtree. |
| 3513 if (descendant->styleRef().isStacked()) { | |
| 3514 traverseNonCompositingDescendantsInPaintOrder(*descendant, funct or); | |
| 3515 descendant = descendant->nextInPreOrderAfterChildren(&object); | |
| 3516 continue; | |
| 3517 } | |
| 3518 // Case 2b: The descendant is not stacked so its paint invalidation container | |
| 3519 // is still |object|. Keep searching. | |
| 3520 descendant = descendant->nextInPreOrder(&object); | |
| 3510 continue; | 3521 continue; |
| 3511 } | 3522 } |
| 3512 // Case 3: The descendant is an invalidation container and is a stacking context. | 3523 // 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, | 3524 // No objects in the subtree can have invalidation container outside of it, |
| 3514 // thus skip the whole subtree. | 3525 // thus skip the whole subtree. |
| 3515 if (descendant->styleRef().isStackingContext()) { | 3526 if (descendant->styleRef().isStackingContext()) { |
| 3516 descendant = descendant->nextInPreOrderAfterChildren(&object); | 3527 descendant = descendant->nextInPreOrderAfterChildren(&object); |
| 3517 continue; | 3528 continue; |
| 3518 } | 3529 } |
| 3519 // Case 4: The descendant is an invalidation container but not a stackin g context. | 3530 // 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. | 3531 // This is the same situation as the root, thus keep searching. |
| 3521 descendant = descendant->nextInPreOrder(&object); | 3532 descendant = descendant->nextInPreOrder(&object); |
| 3522 } | 3533 } |
| 3523 } | 3534 } |
| 3524 | 3535 |
| 3525 template <typename LayoutObjectTraversalFunctor> | 3536 template <typename LayoutObjectTraversalFunctor> |
| 3526 void traverseNonCompositingDescendants(LayoutObject& object, const LayoutObjectT raversalFunctor& functor) | 3537 void traverseNonCompositingDescendantsInPaintOrder(LayoutObject& object, const L ayoutObjectTraversalFunctor& functor) |
| 3527 { | 3538 { |
| 3528 functor(object); | 3539 functor(object); |
| 3529 LayoutObject* descendant = object.nextInPreOrder(&object); | 3540 LayoutObject* descendant = object.nextInPreOrder(&object); |
| 3530 while (descendant) { | 3541 while (descendant) { |
| 3531 if (!descendant->isPaintInvalidationContainer()) { | 3542 if (!descendant->isPaintInvalidationContainer()) { |
| 3532 functor(*descendant); | 3543 functor(*descendant); |
| 3533 descendant = descendant->nextInPreOrder(&object); | 3544 descendant = descendant->nextInPreOrder(&object); |
| 3534 continue; | 3545 continue; |
| 3535 } | 3546 } |
| 3536 if (descendant->styleRef().isStackingContext()) { | 3547 if (descendant->styleRef().isStackingContext()) { |
| 3537 descendant = descendant->nextInPreOrderAfterChildren(&object); | 3548 descendant = descendant->nextInPreOrderAfterChildren(&object); |
| 3538 continue; | 3549 continue; |
| 3539 } | 3550 } |
| 3540 | 3551 |
| 3541 // If a paint invalidation container is not a stacking context, | 3552 // If a paint invalidation container is not a stacking context, |
| 3542 // some of its descendants may belong to the parent container. | 3553 // some of its descendants may belong to the parent container. |
| 3543 findNonCompositedDescendantLayerToTraverse(*descendant, functor); | 3554 traverseNonCompositingDescendantsBelongingToAncestorPaintInvalidationCon tainer(*descendant, functor); |
| 3544 descendant = descendant->nextInPreOrderAfterChildren(&object); | 3555 descendant = descendant->nextInPreOrderAfterChildren(&object); |
| 3545 } | 3556 } |
| 3546 } | 3557 } |
| 3547 | 3558 |
| 3548 } // unnamed namespace | 3559 } // unnamed namespace |
| 3549 | 3560 |
| 3550 void LayoutObject::invalidateDisplayItemClientsIncludingNonCompositingDescendant s(PaintInvalidationReason reason) const | 3561 void LayoutObject::invalidateDisplayItemClientsIncludingNonCompositingDescendant s(PaintInvalidationReason reason) const |
| 3551 { | 3562 { |
| 3552 // This is valid because we want to invalidate the client in the display ite m list of the current backing. | 3563 // This is valid because we want to invalidate the client in the display ite m list of the current backing. |
| 3553 DisableCompositingQueryAsserts disabler; | 3564 DisableCompositingQueryAsserts disabler; |
| 3554 | 3565 |
| 3555 slowSetPaintingLayerNeedsRepaint(); | 3566 slowSetPaintingLayerNeedsRepaint(); |
| 3556 traverseNonCompositingDescendants(const_cast<LayoutObject&>(*this), [reason] (LayoutObject& object) { | 3567 traverseNonCompositingDescendantsInPaintOrder(const_cast<LayoutObject&>(*thi s), [reason](LayoutObject& object) { |
| 3557 if (object.hasLayer() && toLayoutBoxModelObject(object).hasSelfPaintingL ayer()) | 3568 if (object.hasLayer() && toLayoutBoxModelObject(object).hasSelfPaintingL ayer()) |
| 3558 toLayoutBoxModelObject(object).layer()->setNeedsRepaint(); | 3569 toLayoutBoxModelObject(object).layer()->setNeedsRepaint(); |
| 3559 object.invalidateDisplayItemClients(reason); | 3570 object.invalidateDisplayItemClients(reason); |
| 3560 }); | 3571 }); |
| 3561 } | 3572 } |
| 3562 | 3573 |
| 3563 void LayoutObject::invalidatePaintOfPreviousPaintInvalidationRect(const LayoutBo xModelObject& paintInvalidationContainer, PaintInvalidationReason reason) | 3574 void LayoutObject::invalidatePaintOfPreviousPaintInvalidationRect(const LayoutBo xModelObject& paintInvalidationContainer, PaintInvalidationReason reason) |
| 3564 { | 3575 { |
| 3565 // It's caller's responsibility to ensure enclosingSelfPaintingLayer's needs Repaint is set. | 3576 // 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 | 3577 // Don't set the flag here because getting enclosingSelfPaintLayer has cost and the caller can use |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 3579 // Clear previous paint invalidation rect on the original paint invalidation container to avoid | 3590 // 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 | 3591 // 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. | 3592 // happens to be the same as the old one. |
| 3582 clearPreviousPaintInvalidationRects(); | 3593 clearPreviousPaintInvalidationRects(); |
| 3583 } | 3594 } |
| 3584 | 3595 |
| 3585 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants() | 3596 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants() |
| 3586 { | 3597 { |
| 3587 // Since we're only painting non-composited layers, we know that they all sh are the same paintInvalidationContainer. | 3598 // Since we're only painting non-composited layers, we know that they all sh are the same paintInvalidationContainer. |
| 3588 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn validation(); | 3599 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn validation(); |
| 3589 traverseNonCompositingDescendants(*this, [&paintInvalidationContainer](Layou tObject& object) { | 3600 traverseNonCompositingDescendantsInPaintOrder(*this, [&paintInvalidationCont ainer](LayoutObject& object) { |
| 3590 if (object.hasLayer()) | 3601 if (object.hasLayer()) |
| 3591 toLayoutBoxModelObject(object).layer()->setNeedsRepaint(); | 3602 toLayoutBoxModelObject(object).layer()->setNeedsRepaint(); |
| 3592 object.invalidatePaintOfPreviousPaintInvalidationRect(paintInvalidationC ontainer, PaintInvalidationSubtree); | 3603 object.invalidatePaintOfPreviousPaintInvalidationRect(paintInvalidationC ontainer, PaintInvalidationSubtree); |
| 3593 }); | 3604 }); |
| 3594 } | 3605 } |
| 3595 | 3606 |
| 3596 void LayoutObject::setShouldDoFullPaintInvalidationIncludingNonCompositingDescen dants() | 3607 void LayoutObject::setShouldDoFullPaintInvalidationIncludingNonCompositingDescen dants() |
| 3597 { | 3608 { |
| 3598 // Clear first because PaintInvalidationSubtree overrides other full paint i nvalidation reasons. | 3609 // Clear first because PaintInvalidationSubtree overrides other full paint i nvalidation reasons. |
| 3599 clearShouldDoFullPaintInvalidation(); | 3610 clearShouldDoFullPaintInvalidation(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3674 const blink::LayoutObject* root = object1; | 3685 const blink::LayoutObject* root = object1; |
| 3675 while (root->parent()) | 3686 while (root->parent()) |
| 3676 root = root->parent(); | 3687 root = root->parent(); |
| 3677 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); | 3688 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); |
| 3678 } else { | 3689 } else { |
| 3679 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); | 3690 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); |
| 3680 } | 3691 } |
| 3681 } | 3692 } |
| 3682 | 3693 |
| 3683 #endif | 3694 #endif |
| OLD | NEW |