| 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 3442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3453 | 3453 |
| 3454 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() | 3454 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() |
| 3455 : m_disabler(&gDisablePaintInvalidationStateAsserts, true) | 3455 : m_disabler(&gDisablePaintInvalidationStateAsserts, true) |
| 3456 { | 3456 { |
| 3457 } | 3457 } |
| 3458 | 3458 |
| 3459 namespace { | 3459 namespace { |
| 3460 | 3460 |
| 3461 // TODO(trchen): Use std::function<void, LayoutObject&> when available. | 3461 // TODO(trchen): Use std::function<void, LayoutObject&> when available. |
| 3462 template <typename LayoutObjectTraversalFunctor> | 3462 template <typename LayoutObjectTraversalFunctor> |
| 3463 void traverseNonCompositingDescendants(LayoutObject&, const LayoutObjectTraversa
lFunctor&); | 3463 void traverseNonCompositingDescendantsInPaintOrder(LayoutObject&, const LayoutOb
jectTraversalFunctor&); |
| 3464 | 3464 |
| 3465 template <typename LayoutObjectTraversalFunctor> | 3465 template <typename LayoutObjectTraversalFunctor> |
| 3466 void findNonCompositedDescendantLayerToTraverse(LayoutObject& object, const Layo
utObjectTraversalFunctor& functor) | 3466 void traverseNonCompositingDescendantsBelongingToAncestorPaintInvalidationContai
ner(LayoutObject& object, const LayoutObjectTraversalFunctor& functor) |
| 3467 { | 3467 { |
| 3468 // |object| is a paint invalidation container but is not a stacking context,
so the paint |
| 3469 // invalidation container of stacked descendants don't belong to |object| bu
t belong to |
| 3470 // an ancestor. This function traverses all such descendants. |
| 3471 DCHECK(object.isPaintInvalidationContainer() && !object.styleRef().isStackin
gContext()); |
| 3472 |
| 3468 LayoutObject* descendant = object.nextInPreOrder(&object); | 3473 LayoutObject* descendant = object.nextInPreOrder(&object); |
| 3469 while (descendant) { | 3474 while (descendant) { |
| 3470 // Case 1: If the descendant has no layer, keep searching until we find
a layer. | 3475 if (!descendant->hasLayer() || !descendant->styleRef().isStacked()) { |
| 3471 if (!descendant->hasLayer()) { | 3476 // Case 1: The descendant is not stacked (or is stacked but has not
been |
| 3477 // allocated a layer yet during style change), so either it's a pain
t invalidation |
| 3478 // container in the same situation as |object|, or its paint invalid
ation |
| 3479 // container is in such situation. Keep searching until a stacked la
yer is found. |
| 3472 descendant = descendant->nextInPreOrder(&object); | 3480 descendant = descendant->nextInPreOrder(&object); |
| 3473 continue; | 3481 } else if (!descendant->isPaintInvalidationContainer()) { |
| 3482 // Case 2: The descendant is stacked and is not composited. |
| 3483 // The invalidation container of its subtree is our ancestor, |
| 3484 // thus recur into the subtree. |
| 3485 traverseNonCompositingDescendantsInPaintOrder(*descendant, functor); |
| 3486 descendant = descendant->nextInPreOrderAfterChildren(&object); |
| 3487 } else if (descendant->styleRef().isStackingContext()) { |
| 3488 // Case 3: The descendant is an invalidation container and is a stac
king context. |
| 3489 // No objects in the subtree can have invalidation container outside
of it, |
| 3490 // thus skip the whole subtree. |
| 3491 descendant = descendant->nextInPreOrderAfterChildren(&object); |
| 3492 } else { |
| 3493 // Case 4: The descendant is an invalidation container but not a sta
cking context. |
| 3494 // This is the same situation as |object|, thus keep searching. |
| 3495 descendant = descendant->nextInPreOrder(&object); |
| 3474 } | 3496 } |
| 3475 // Case 2: The descendant has a layer and is not composited. | |
| 3476 // The invalidation container of its subtree is our parent, | |
| 3477 // thus recur into the subtree. | |
| 3478 if (!descendant->isPaintInvalidationContainer()) { | |
| 3479 traverseNonCompositingDescendants(*descendant, functor); | |
| 3480 descendant = descendant->nextInPreOrderAfterChildren(&object); | |
| 3481 continue; | |
| 3482 } | |
| 3483 // Case 3: The descendant is an invalidation container and is a stacking
context. | |
| 3484 // No objects in the subtree can have invalidation container outside of
it, | |
| 3485 // thus skip the whole subtree. | |
| 3486 if (descendant->styleRef().isStackingContext()) { | |
| 3487 descendant = descendant->nextInPreOrderAfterChildren(&object); | |
| 3488 continue; | |
| 3489 } | |
| 3490 // Case 4: The descendant is an invalidation container but not a stackin
g context. | |
| 3491 // This is the same situation as the root, thus keep searching. | |
| 3492 descendant = descendant->nextInPreOrder(&object); | |
| 3493 } | 3497 } |
| 3494 } | 3498 } |
| 3495 | 3499 |
| 3496 template <typename LayoutObjectTraversalFunctor> | 3500 template <typename LayoutObjectTraversalFunctor> |
| 3497 void traverseNonCompositingDescendants(LayoutObject& object, const LayoutObjectT
raversalFunctor& functor) | 3501 void traverseNonCompositingDescendantsInPaintOrder(LayoutObject& object, const L
ayoutObjectTraversalFunctor& functor) |
| 3498 { | 3502 { |
| 3499 functor(object); | 3503 functor(object); |
| 3500 LayoutObject* descendant = object.nextInPreOrder(&object); | 3504 LayoutObject* descendant = object.nextInPreOrder(&object); |
| 3501 while (descendant) { | 3505 while (descendant) { |
| 3502 if (!descendant->isPaintInvalidationContainer()) { | 3506 if (!descendant->isPaintInvalidationContainer()) { |
| 3503 functor(*descendant); | 3507 functor(*descendant); |
| 3504 descendant = descendant->nextInPreOrder(&object); | 3508 descendant = descendant->nextInPreOrder(&object); |
| 3505 continue; | 3509 } else if (descendant->styleRef().isStackingContext()) { |
| 3510 // The descendant is an invalidation container and is a stacking con
text. |
| 3511 // No objects in the subtree can have invalidation container outside
of it, |
| 3512 // thus skip the whole subtree. |
| 3513 descendant = descendant->nextInPreOrderAfterChildren(&object); |
| 3514 } else { |
| 3515 // If a paint invalidation container is not a stacking context, |
| 3516 // some of its descendants may belong to the parent container. |
| 3517 traverseNonCompositingDescendantsBelongingToAncestorPaintInvalidatio
nContainer(*descendant, functor); |
| 3518 descendant = descendant->nextInPreOrderAfterChildren(&object); |
| 3506 } | 3519 } |
| 3507 if (descendant->styleRef().isStackingContext()) { | |
| 3508 descendant = descendant->nextInPreOrderAfterChildren(&object); | |
| 3509 continue; | |
| 3510 } | |
| 3511 | |
| 3512 // If a paint invalidation container is not a stacking context, | |
| 3513 // some of its descendants may belong to the parent container. | |
| 3514 findNonCompositedDescendantLayerToTraverse(*descendant, functor); | |
| 3515 descendant = descendant->nextInPreOrderAfterChildren(&object); | |
| 3516 } | 3520 } |
| 3517 } | 3521 } |
| 3518 | 3522 |
| 3519 } // unnamed namespace | 3523 } // unnamed namespace |
| 3520 | 3524 |
| 3521 void LayoutObject::invalidateDisplayItemClientsIncludingNonCompositingDescendant
s(PaintInvalidationReason reason) const | 3525 void LayoutObject::invalidateDisplayItemClientsIncludingNonCompositingDescendant
s(PaintInvalidationReason reason) const |
| 3522 { | 3526 { |
| 3523 // This is valid because we want to invalidate the client in the display ite
m list of the current backing. | 3527 // This is valid because we want to invalidate the client in the display ite
m list of the current backing. |
| 3524 DisableCompositingQueryAsserts disabler; | 3528 DisableCompositingQueryAsserts disabler; |
| 3525 | 3529 |
| 3526 slowSetPaintingLayerNeedsRepaint(); | 3530 slowSetPaintingLayerNeedsRepaint(); |
| 3527 traverseNonCompositingDescendants(const_cast<LayoutObject&>(*this), [reason]
(LayoutObject& object) { | 3531 traverseNonCompositingDescendantsInPaintOrder(const_cast<LayoutObject&>(*thi
s), [reason](LayoutObject& object) { |
| 3528 if (object.hasLayer() && toLayoutBoxModelObject(object).hasSelfPaintingL
ayer()) | 3532 if (object.hasLayer() && toLayoutBoxModelObject(object).hasSelfPaintingL
ayer()) |
| 3529 toLayoutBoxModelObject(object).layer()->setNeedsRepaint(); | 3533 toLayoutBoxModelObject(object).layer()->setNeedsRepaint(); |
| 3530 object.invalidateDisplayItemClients(reason); | 3534 object.invalidateDisplayItemClients(reason); |
| 3531 }); | 3535 }); |
| 3532 } | 3536 } |
| 3533 | 3537 |
| 3534 void LayoutObject::invalidatePaintOfPreviousPaintInvalidationRect(const LayoutBo
xModelObject& paintInvalidationContainer, PaintInvalidationReason reason) | 3538 void LayoutObject::invalidatePaintOfPreviousPaintInvalidationRect(const LayoutBo
xModelObject& paintInvalidationContainer, PaintInvalidationReason reason) |
| 3535 { | 3539 { |
| 3536 // It's caller's responsibility to ensure enclosingSelfPaintingLayer's needs
Repaint is set. | 3540 // It's caller's responsibility to ensure enclosingSelfPaintingLayer's needs
Repaint is set. |
| 3537 // Don't set the flag here because getting enclosingSelfPaintLayer has cost
and the caller can use | 3541 // Don't set the flag here because getting enclosingSelfPaintLayer has cost
and the caller can use |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3550 // Clear previous paint invalidation rect on the original paint invalidation
container to avoid | 3554 // Clear previous paint invalidation rect on the original paint invalidation
container to avoid |
| 3551 // under-invalidation if the new paint invalidation rect on the new paint in
validation container | 3555 // under-invalidation if the new paint invalidation rect on the new paint in
validation container |
| 3552 // happens to be the same as the old one. | 3556 // happens to be the same as the old one. |
| 3553 clearPreviousPaintInvalidationRects(); | 3557 clearPreviousPaintInvalidationRects(); |
| 3554 } | 3558 } |
| 3555 | 3559 |
| 3556 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants() | 3560 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants() |
| 3557 { | 3561 { |
| 3558 // Since we're only painting non-composited layers, we know that they all sh
are the same paintInvalidationContainer. | 3562 // Since we're only painting non-composited layers, we know that they all sh
are the same paintInvalidationContainer. |
| 3559 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn
validation(); | 3563 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn
validation(); |
| 3560 traverseNonCompositingDescendants(*this, [&paintInvalidationContainer](Layou
tObject& object) { | 3564 traverseNonCompositingDescendantsInPaintOrder(*this, [&paintInvalidationCont
ainer](LayoutObject& object) { |
| 3561 if (object.hasLayer()) | 3565 if (object.hasLayer()) |
| 3562 toLayoutBoxModelObject(object).layer()->setNeedsRepaint(); | 3566 toLayoutBoxModelObject(object).layer()->setNeedsRepaint(); |
| 3563 object.invalidatePaintOfPreviousPaintInvalidationRect(paintInvalidationC
ontainer, PaintInvalidationSubtree); | 3567 object.invalidatePaintOfPreviousPaintInvalidationRect(paintInvalidationC
ontainer, PaintInvalidationSubtree); |
| 3564 }); | 3568 }); |
| 3565 } | 3569 } |
| 3566 | 3570 |
| 3567 void LayoutObject::setShouldDoFullPaintInvalidationIncludingNonCompositingDescen
dants() | 3571 void LayoutObject::setShouldDoFullPaintInvalidationIncludingNonCompositingDescen
dants() |
| 3568 { | 3572 { |
| 3569 // Clear first because PaintInvalidationSubtree overrides other full paint i
nvalidation reasons. | 3573 // Clear first because PaintInvalidationSubtree overrides other full paint i
nvalidation reasons. |
| 3570 clearShouldDoFullPaintInvalidation(); | 3574 clearShouldDoFullPaintInvalidation(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3645 const blink::LayoutObject* root = object1; | 3649 const blink::LayoutObject* root = object1; |
| 3646 while (root->parent()) | 3650 while (root->parent()) |
| 3647 root = root->parent(); | 3651 root = root->parent(); |
| 3648 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); | 3652 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); |
| 3649 } else { | 3653 } else { |
| 3650 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); | 3654 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); |
| 3651 } | 3655 } |
| 3652 } | 3656 } |
| 3653 | 3657 |
| 3654 #endif | 3658 #endif |
| OLD | NEW |