| 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 traverseNonCompositingDescendantsInPaintOrder(LayoutObject&, const LayoutOb
jectTraversalFunctor&); | 3492 void traverseNonCompositingDescendants(LayoutObject&, const LayoutObjectTraversa
lFunctor&); |
| 3493 | 3493 |
| 3494 template <typename LayoutObjectTraversalFunctor> | 3494 template <typename LayoutObjectTraversalFunctor> |
| 3495 void traverseNonCompositingDescendantsBelongingToAncestorPaintInvalidationContai
ner(LayoutObject& object, const LayoutObjectTraversalFunctor& functor) | 3495 void findNonCompositedDescendantLayerToTraverse(LayoutObject& object, const Layo
utObjectTraversalFunctor& 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 | |
| 3502 LayoutObject* descendant = object.nextInPreOrder(&object); | 3497 LayoutObject* descendant = object.nextInPreOrder(&object); |
| 3503 while (descendant) { | 3498 while (descendant) { |
| 3504 if (!descendant->hasLayer() || !descendant->styleRef().isStacked()) { | 3499 // Case 1: If the descendant has no layer, keep searching until we find
a layer. |
| 3505 // Case 1: The descendant is not stacked (or is stacked but has not
been | 3500 if (!descendant->hasLayer()) { |
| 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. | |
| 3509 descendant = descendant->nextInPreOrder(&object); | 3501 descendant = descendant->nextInPreOrder(&object); |
| 3510 } else if (!descendant->isPaintInvalidationContainer()) { | 3502 continue; |
| 3511 // Case 2: The descendant is stacked and is not composited. | 3503 } |
| 3512 // The invalidation container of its subtree is our ancestor, | 3504 // Case 2: The descendant has a layer and is not composited. |
| 3513 // thus recur into the subtree. | 3505 // The invalidation container of its subtree is our parent, |
| 3514 traverseNonCompositingDescendantsInPaintOrder(*descendant, functor); | 3506 // thus recur into the subtree. |
| 3507 if (!descendant->isPaintInvalidationContainer()) { |
| 3508 traverseNonCompositingDescendants(*descendant, functor); |
| 3515 descendant = descendant->nextInPreOrderAfterChildren(&object); | 3509 descendant = descendant->nextInPreOrderAfterChildren(&object); |
| 3516 } else if (descendant->styleRef().isStackingContext()) { | 3510 continue; |
| 3517 // Case 3: The descendant is an invalidation container and is a stac
king context. | 3511 } |
| 3518 // No objects in the subtree can have invalidation container outside
of it, | 3512 // Case 3: The descendant is an invalidation container and is a stacking
context. |
| 3519 // thus skip the whole subtree. | 3513 // No objects in the subtree can have invalidation container outside of
it, |
| 3514 // thus skip the whole subtree. |
| 3515 if (descendant->styleRef().isStackingContext()) { |
| 3520 descendant = descendant->nextInPreOrderAfterChildren(&object); | 3516 descendant = descendant->nextInPreOrderAfterChildren(&object); |
| 3521 } else { | 3517 continue; |
| 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); | |
| 3525 } | 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); |
| 3526 } | 3522 } |
| 3527 } | 3523 } |
| 3528 | 3524 |
| 3529 template <typename LayoutObjectTraversalFunctor> | 3525 template <typename LayoutObjectTraversalFunctor> |
| 3530 void traverseNonCompositingDescendantsInPaintOrder(LayoutObject& object, const L
ayoutObjectTraversalFunctor& functor) | 3526 void traverseNonCompositingDescendants(LayoutObject& object, const LayoutObjectT
raversalFunctor& functor) |
| 3531 { | 3527 { |
| 3532 functor(object); | 3528 functor(object); |
| 3533 LayoutObject* descendant = object.nextInPreOrder(&object); | 3529 LayoutObject* descendant = object.nextInPreOrder(&object); |
| 3534 while (descendant) { | 3530 while (descendant) { |
| 3535 if (!descendant->isPaintInvalidationContainer()) { | 3531 if (!descendant->isPaintInvalidationContainer()) { |
| 3536 functor(*descendant); | 3532 functor(*descendant); |
| 3537 descendant = descendant->nextInPreOrder(&object); | 3533 descendant = descendant->nextInPreOrder(&object); |
| 3538 } else if (descendant->styleRef().isStackingContext()) { | 3534 continue; |
| 3539 // The descendant is an invalidation container and is a stacking con
text. | 3535 } |
| 3540 // No objects in the subtree can have invalidation container outside
of it, | 3536 if (descendant->styleRef().isStackingContext()) { |
| 3541 // thus skip the whole subtree. | |
| 3542 descendant = descendant->nextInPreOrderAfterChildren(&object); | 3537 descendant = descendant->nextInPreOrderAfterChildren(&object); |
| 3543 } else { | 3538 continue; |
| 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); | |
| 3548 } | 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); |
| 3549 } | 3545 } |
| 3550 } | 3546 } |
| 3551 | 3547 |
| 3552 } // unnamed namespace | 3548 } // unnamed namespace |
| 3553 | 3549 |
| 3554 void LayoutObject::invalidateDisplayItemClientsIncludingNonCompositingDescendant
s(PaintInvalidationReason reason) const | 3550 void LayoutObject::invalidateDisplayItemClientsIncludingNonCompositingDescendant
s(PaintInvalidationReason reason) const |
| 3555 { | 3551 { |
| 3556 // This is valid because we want to invalidate the client in the display ite
m list of the current backing. | 3552 // This is valid because we want to invalidate the client in the display ite
m list of the current backing. |
| 3557 DisableCompositingQueryAsserts disabler; | 3553 DisableCompositingQueryAsserts disabler; |
| 3558 | 3554 |
| 3559 slowSetPaintingLayerNeedsRepaint(); | 3555 slowSetPaintingLayerNeedsRepaint(); |
| 3560 traverseNonCompositingDescendantsInPaintOrder(const_cast<LayoutObject&>(*thi
s), [reason](LayoutObject& object) { | 3556 traverseNonCompositingDescendants(const_cast<LayoutObject&>(*this), [reason]
(LayoutObject& object) { |
| 3561 if (object.hasLayer() && toLayoutBoxModelObject(object).hasSelfPaintingL
ayer()) | 3557 if (object.hasLayer() && toLayoutBoxModelObject(object).hasSelfPaintingL
ayer()) |
| 3562 toLayoutBoxModelObject(object).layer()->setNeedsRepaint(); | 3558 toLayoutBoxModelObject(object).layer()->setNeedsRepaint(); |
| 3563 object.invalidateDisplayItemClients(reason); | 3559 object.invalidateDisplayItemClients(reason); |
| 3564 }); | 3560 }); |
| 3565 } | 3561 } |
| 3566 | 3562 |
| 3567 void LayoutObject::invalidatePaintOfPreviousPaintInvalidationRect(const LayoutBo
xModelObject& paintInvalidationContainer, PaintInvalidationReason reason) | 3563 void LayoutObject::invalidatePaintOfPreviousPaintInvalidationRect(const LayoutBo
xModelObject& paintInvalidationContainer, PaintInvalidationReason reason) |
| 3568 { | 3564 { |
| 3569 // It's caller's responsibility to ensure enclosingSelfPaintingLayer's needs
Repaint is set. | 3565 // It's caller's responsibility to ensure enclosingSelfPaintingLayer's needs
Repaint is set. |
| 3570 // Don't set the flag here because getting enclosingSelfPaintLayer has cost
and the caller can use | 3566 // Don't set the flag here because getting enclosingSelfPaintLayer has cost
and the caller can use |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3583 // Clear previous paint invalidation rect on the original paint invalidation
container to avoid | 3579 // Clear previous paint invalidation rect on the original paint invalidation
container to avoid |
| 3584 // under-invalidation if the new paint invalidation rect on the new paint in
validation container | 3580 // under-invalidation if the new paint invalidation rect on the new paint in
validation container |
| 3585 // happens to be the same as the old one. | 3581 // happens to be the same as the old one. |
| 3586 clearPreviousPaintInvalidationRects(); | 3582 clearPreviousPaintInvalidationRects(); |
| 3587 } | 3583 } |
| 3588 | 3584 |
| 3589 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants() | 3585 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants() |
| 3590 { | 3586 { |
| 3591 // Since we're only painting non-composited layers, we know that they all sh
are the same paintInvalidationContainer. | 3587 // Since we're only painting non-composited layers, we know that they all sh
are the same paintInvalidationContainer. |
| 3592 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn
validation(); | 3588 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn
validation(); |
| 3593 traverseNonCompositingDescendantsInPaintOrder(*this, [&paintInvalidationCont
ainer](LayoutObject& object) { | 3589 traverseNonCompositingDescendants(*this, [&paintInvalidationContainer](Layou
tObject& object) { |
| 3594 if (object.hasLayer()) | 3590 if (object.hasLayer()) |
| 3595 toLayoutBoxModelObject(object).layer()->setNeedsRepaint(); | 3591 toLayoutBoxModelObject(object).layer()->setNeedsRepaint(); |
| 3596 object.invalidatePaintOfPreviousPaintInvalidationRect(paintInvalidationC
ontainer, PaintInvalidationSubtree); | 3592 object.invalidatePaintOfPreviousPaintInvalidationRect(paintInvalidationC
ontainer, PaintInvalidationSubtree); |
| 3597 }); | 3593 }); |
| 3598 } | 3594 } |
| 3599 | 3595 |
| 3600 void LayoutObject::setShouldDoFullPaintInvalidationIncludingNonCompositingDescen
dants() | 3596 void LayoutObject::setShouldDoFullPaintInvalidationIncludingNonCompositingDescen
dants() |
| 3601 { | 3597 { |
| 3602 // Clear first because PaintInvalidationSubtree overrides other full paint i
nvalidation reasons. | 3598 // Clear first because PaintInvalidationSubtree overrides other full paint i
nvalidation reasons. |
| 3603 clearShouldDoFullPaintInvalidation(); | 3599 clearShouldDoFullPaintInvalidation(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3678 const blink::LayoutObject* root = object1; | 3674 const blink::LayoutObject* root = object1; |
| 3679 while (root->parent()) | 3675 while (root->parent()) |
| 3680 root = root->parent(); | 3676 root = root->parent(); |
| 3681 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); | 3677 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); |
| 3682 } else { | 3678 } else { |
| 3683 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); | 3679 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); |
| 3684 } | 3680 } |
| 3685 } | 3681 } |
| 3686 | 3682 |
| 3687 #endif | 3683 #endif |
| OLD | NEW |