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. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. |
| 7 * All rights reserved. | 7 * All rights reserved. |
| 8 * Copyright (C) 2009 Google Inc. All rights reserved. | 8 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. | 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. |
| 10 * (http://www.torchmobile.com/) | 10 * (http://www.torchmobile.com/) |
| (...skipping 1611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1622 ? object->parent() | 1622 ? object->parent() |
| 1623 : object->containingBlock(); | 1623 : object->containingBlock(); |
| 1624 if (object) | 1624 if (object) |
| 1625 object->setChildNeedsOverflowRecalcAfterStyleChange(); | 1625 object->setChildNeedsOverflowRecalcAfterStyleChange(); |
| 1626 } while (object); | 1626 } while (object); |
| 1627 } | 1627 } |
| 1628 | 1628 |
| 1629 void LayoutObject::setNeedsOverflowRecalcAfterStyleChange() { | 1629 void LayoutObject::setNeedsOverflowRecalcAfterStyleChange() { |
| 1630 bool neededRecalc = needsOverflowRecalcAfterStyleChange(); | 1630 bool neededRecalc = needsOverflowRecalcAfterStyleChange(); |
| 1631 setSelfNeedsOverflowRecalcAfterStyleChange(); | 1631 setSelfNeedsOverflowRecalcAfterStyleChange(); |
| 1632 setNeedsPaintOffsetAndVisualRectUpdate(); | |
| 1632 if (!neededRecalc) | 1633 if (!neededRecalc) |
| 1633 markAncestorsForOverflowRecalcIfNeeded(); | 1634 markAncestorsForOverflowRecalcIfNeeded(); |
| 1634 } | 1635 } |
| 1635 | 1636 |
| 1636 DISABLE_CFI_PERF | 1637 DISABLE_CFI_PERF |
| 1637 void LayoutObject::setStyle(PassRefPtr<ComputedStyle> style) { | 1638 void LayoutObject::setStyle(PassRefPtr<ComputedStyle> style) { |
| 1638 ASSERT(style); | 1639 ASSERT(style); |
| 1639 | 1640 |
| 1640 if (m_style == style) { | 1641 if (m_style == style) { |
| 1641 // We need to run through adjustStyleDifference() for iframes, plugins, and | 1642 // We need to run through adjustStyleDifference() for iframes, plugins, and |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1721 | 1722 |
| 1722 if (diff.needsRecomputeOverflow() && !needsLayout()) { | 1723 if (diff.needsRecomputeOverflow() && !needsLayout()) { |
| 1723 // TODO(rhogan): Make inlines capable of recomputing overflow too. | 1724 // TODO(rhogan): Make inlines capable of recomputing overflow too. |
| 1724 if (isLayoutBlock()) | 1725 if (isLayoutBlock()) |
| 1725 setNeedsOverflowRecalcAfterStyleChange(); | 1726 setNeedsOverflowRecalcAfterStyleChange(); |
| 1726 else | 1727 else |
| 1727 setNeedsLayoutAndPrefWidthsRecalc(LayoutInvalidationReason::StyleChange); | 1728 setNeedsLayoutAndPrefWidthsRecalc(LayoutInvalidationReason::StyleChange); |
| 1728 } | 1729 } |
| 1729 | 1730 |
| 1730 if (diff.needsPaintInvalidationSubtree() || | 1731 if (diff.needsPaintInvalidationSubtree() || |
| 1731 updatedDiff.needsPaintInvalidationSubtree()) | 1732 updatedDiff.needsPaintInvalidationSubtree()) { |
| 1732 setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); | 1733 setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); |
| 1733 else if (diff.needsPaintInvalidationObject() || | 1734 } else if (diff.needsPaintInvalidationObject() || |
| 1734 updatedDiff.needsPaintInvalidationObject()) | 1735 updatedDiff.needsPaintInvalidationObject()) { |
| 1735 setShouldDoFullPaintInvalidation(); | 1736 // TODO(wangxianzhu): For now LayoutSVGRoot::localVisualRect() depends on |
| 1737 // several styles. Refactor to avoid this special case. | |
| 1738 if (isSVGRoot()) | |
| 1739 setShouldDoFullPaintInvalidation(); | |
| 1740 else | |
| 1741 setShouldDoFullPaintInvalidationWithoutGeometryChange(); | |
| 1742 } | |
| 1743 | |
| 1744 // Visibility affects visual rect. | |
| 1745 if (oldStyle && oldStyle->visibility() != m_style->visibility()) | |
| 1746 setNeedsPaintOffsetAndVisualRectUpdate(); | |
| 1736 | 1747 |
| 1737 // Text nodes share style with their parents but the paint properties don't | 1748 // Text nodes share style with their parents but the paint properties don't |
| 1738 // apply to them, hence the !isText() check. | 1749 // apply to them, hence the !isText() check. |
| 1739 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && !isText() && | 1750 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && !isText() && |
| 1740 (diff.transformChanged() || diff.opacityChanged() || | 1751 (diff.transformChanged() || diff.opacityChanged() || |
| 1741 diff.zIndexChanged() || diff.filterChanged() || | 1752 diff.zIndexChanged() || diff.filterChanged() || |
| 1742 diff.backdropFilterChanged() || diff.cssClipChanged())) { | 1753 diff.backdropFilterChanged() || diff.cssClipChanged())) { |
| 1743 setNeedsPaintPropertyUpdate(); | 1754 setNeedsPaintPropertyUpdate(); |
| 1744 | 1755 |
| 1745 // We don't need to invalidate paint of objects on SPv2 when only paint | 1756 // We don't need to invalidate paint of objects on SPv2 when only paint |
| (...skipping 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3406 } | 3417 } |
| 3407 } | 3418 } |
| 3408 | 3419 |
| 3409 inline void LayoutObject::markAncestorsForPaintInvalidation() { | 3420 inline void LayoutObject::markAncestorsForPaintInvalidation() { |
| 3410 for ( | 3421 for ( |
| 3411 LayoutObject* parent = this->paintInvalidationParent(); | 3422 LayoutObject* parent = this->paintInvalidationParent(); |
| 3412 parent && | 3423 parent && |
| 3413 !parent | 3424 !parent |
| 3414 ->shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() ; | 3425 ->shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() ; |
| 3415 parent = parent->paintInvalidationParent()) | 3426 parent = parent->paintInvalidationParent()) |
| 3416 parent->m_bitfields.setChildShouldCheckForPaintInvalidation(true); | 3427 parent->m_bitfields.setMayNeedPaintInvalidation(true); |
| 3428 } | |
| 3429 | |
| 3430 inline void LayoutObject::setNeedsPaintOffsetAndVisualRectUpdate() { | |
| 3431 if (needsPaintOffsetAndVisualRectUpdate()) | |
| 3432 return; | |
| 3433 m_bitfields.setNeedsPaintOffsetAndVisualRectUpdate(true); | |
| 3434 for (LayoutObject* parent = paintInvalidationParent(); | |
| 3435 parent && !parent->needsPaintOffsetAndVisualRectUpdate(); | |
| 3436 parent = parent->paintInvalidationParent()) | |
| 3437 parent->m_bitfields.setNeedsPaintOffsetAndVisualRectUpdate(true); | |
| 3417 } | 3438 } |
| 3418 | 3439 |
| 3419 void LayoutObject::setShouldInvalidateSelection() { | 3440 void LayoutObject::setShouldInvalidateSelection() { |
| 3420 if (!canUpdateSelectionOnRootLineBoxes()) | 3441 if (!canUpdateSelectionOnRootLineBoxes()) |
| 3421 return; | 3442 return; |
| 3422 m_bitfields.setShouldInvalidateSelection(true); | 3443 m_bitfields.setShouldInvalidateSelection(true); |
| 3423 markAncestorsForPaintInvalidation(); | 3444 setMayNeedPaintInvalidation(); |
| 3424 frameView()->scheduleVisualUpdateForPaintInvalidationIfNeeded(); | 3445 frameView()->scheduleVisualUpdateForPaintInvalidationIfNeeded(); |
| 3425 } | 3446 } |
| 3426 | 3447 |
| 3427 void LayoutObject::setShouldDoFullPaintInvalidation( | 3448 void LayoutObject::setShouldDoFullPaintInvalidation( |
| 3428 PaintInvalidationReason reason) { | 3449 PaintInvalidationReason reason) { |
| 3450 setNeedsPaintOffsetAndVisualRectUpdate(); | |
|
pdr.
2017/03/10 06:21:39
Can this be called during paint invalidation? I th
Xianzhu
2017/03/10 17:43:05
This can be called during paint invalidation (e.g.
| |
| 3451 setShouldDoFullPaintInvalidationWithoutGeometryChange(reason); | |
| 3452 } | |
| 3453 | |
| 3454 void LayoutObject::setShouldDoFullPaintInvalidationWithoutGeometryChange( | |
| 3455 PaintInvalidationReason reason) { | |
| 3429 // Only full invalidation reasons are allowed. | 3456 // Only full invalidation reasons are allowed. |
| 3430 ASSERT(isFullPaintInvalidationReason(reason)); | 3457 DCHECK(isFullPaintInvalidationReason(reason)); |
| 3431 | 3458 |
| 3432 bool isUpgradingDelayedFullToFull = | 3459 bool isUpgradingDelayedFullToFull = |
| 3433 m_bitfields.fullPaintInvalidationReason() == | 3460 m_bitfields.fullPaintInvalidationReason() == |
| 3434 PaintInvalidationDelayedFull && | 3461 PaintInvalidationDelayedFull && |
| 3435 reason != PaintInvalidationDelayedFull; | 3462 reason != PaintInvalidationDelayedFull; |
| 3436 | 3463 |
| 3437 if (m_bitfields.fullPaintInvalidationReason() == PaintInvalidationNone || | 3464 if (m_bitfields.fullPaintInvalidationReason() == PaintInvalidationNone || |
| 3438 isUpgradingDelayedFullToFull) { | 3465 isUpgradingDelayedFullToFull) { |
| 3439 if (reason == PaintInvalidationFull) | 3466 if (reason == PaintInvalidationFull) |
| 3440 reason = | 3467 reason = |
| 3441 documentLifecycleBasedPaintInvalidationReason(document().lifecycle()); | 3468 documentLifecycleBasedPaintInvalidationReason(document().lifecycle()); |
| 3442 m_bitfields.setFullPaintInvalidationReason(reason); | 3469 m_bitfields.setFullPaintInvalidationReason(reason); |
| 3443 if (!isUpgradingDelayedFullToFull) | 3470 if (!isUpgradingDelayedFullToFull) |
| 3444 markAncestorsForPaintInvalidation(); | 3471 markAncestorsForPaintInvalidation(); |
| 3445 } | 3472 } |
| 3446 | 3473 |
| 3447 frameView()->scheduleVisualUpdateForPaintInvalidationIfNeeded(); | 3474 frameView()->scheduleVisualUpdateForPaintInvalidationIfNeeded(); |
| 3448 } | 3475 } |
| 3449 | 3476 |
| 3450 void LayoutObject::setMayNeedPaintInvalidation() { | 3477 void LayoutObject::setMayNeedPaintInvalidation() { |
| 3478 setNeedsPaintOffsetAndVisualRectUpdate(); | |
| 3479 setMayNeedPaintInvalidationWithoutGeometryChange(); | |
| 3480 } | |
| 3481 | |
| 3482 void LayoutObject::setMayNeedPaintInvalidationWithoutGeometryChange() { | |
| 3451 if (mayNeedPaintInvalidation()) | 3483 if (mayNeedPaintInvalidation()) |
| 3452 return; | 3484 return; |
| 3453 m_bitfields.setMayNeedPaintInvalidation(true); | 3485 m_bitfields.setMayNeedPaintInvalidation(true); |
| 3454 markAncestorsForPaintInvalidation(); | 3486 markAncestorsForPaintInvalidation(); |
| 3455 frameView()->scheduleVisualUpdateForPaintInvalidationIfNeeded(); | 3487 frameView()->scheduleVisualUpdateForPaintInvalidationIfNeeded(); |
| 3456 } | 3488 } |
| 3457 | 3489 |
| 3458 void LayoutObject::setMayNeedPaintInvalidationSubtree() { | 3490 void LayoutObject::setMayNeedPaintInvalidationSubtree() { |
| 3459 if (mayNeedPaintInvalidationSubtree()) | 3491 if (mayNeedPaintInvalidationSubtree()) |
| 3460 return; | 3492 return; |
| 3461 m_bitfields.setMayNeedPaintInvalidationSubtree(true); | 3493 m_bitfields.setMayNeedPaintInvalidationSubtree(true); |
| 3462 setMayNeedPaintInvalidation(); | 3494 setMayNeedPaintInvalidation(); |
| 3463 } | 3495 } |
| 3464 | 3496 |
| 3465 void LayoutObject::setMayNeedPaintInvalidationAnimatedBackgroundImage() { | 3497 void LayoutObject::setMayNeedPaintInvalidationAnimatedBackgroundImage() { |
| 3466 if (mayNeedPaintInvalidationAnimatedBackgroundImage()) | 3498 if (mayNeedPaintInvalidationAnimatedBackgroundImage()) |
| 3467 return; | 3499 return; |
| 3468 m_bitfields.setMayNeedPaintInvalidationAnimatedBackgroundImage(true); | 3500 m_bitfields.setMayNeedPaintInvalidationAnimatedBackgroundImage(true); |
| 3469 setMayNeedPaintInvalidation(); | 3501 setMayNeedPaintInvalidationWithoutGeometryChange(); |
| 3470 } | 3502 } |
| 3471 | 3503 |
| 3472 void LayoutObject::clearPaintInvalidationFlags() { | 3504 void LayoutObject::clearPaintInvalidationFlags() { |
| 3473 // paintInvalidationStateIsDirty should be kept in sync with the | 3505 // paintInvalidationStateIsDirty should be kept in sync with the |
| 3474 // booleans that are cleared below. | 3506 // booleans that are cleared below. |
| 3475 #if DCHECK_IS_ON() | 3507 #if DCHECK_IS_ON() |
| 3476 DCHECK(!shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() || | 3508 DCHECK(!shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() || |
| 3477 paintInvalidationStateIsDirty()); | 3509 paintInvalidationStateIsDirty()); |
| 3478 #endif | 3510 #endif |
| 3479 clearShouldDoFullPaintInvalidation(); | 3511 clearShouldDoFullPaintInvalidation(); |
| 3480 m_bitfields.setChildShouldCheckForPaintInvalidation(false); | |
| 3481 m_bitfields.setMayNeedPaintInvalidation(false); | 3512 m_bitfields.setMayNeedPaintInvalidation(false); |
| 3482 m_bitfields.setMayNeedPaintInvalidationSubtree(false); | 3513 m_bitfields.setMayNeedPaintInvalidationSubtree(false); |
| 3483 m_bitfields.setMayNeedPaintInvalidationAnimatedBackgroundImage(false); | 3514 m_bitfields.setMayNeedPaintInvalidationAnimatedBackgroundImage(false); |
| 3515 m_bitfields.setNeedsPaintOffsetAndVisualRectUpdate(false); | |
| 3484 m_bitfields.setShouldInvalidateSelection(false); | 3516 m_bitfields.setShouldInvalidateSelection(false); |
| 3485 m_bitfields.setBackgroundChangedSinceLastPaintInvalidation(false); | 3517 m_bitfields.setBackgroundChangedSinceLastPaintInvalidation(false); |
| 3486 } | 3518 } |
| 3487 | 3519 |
| 3488 bool LayoutObject::isAllowedToModifyLayoutTreeStructure(Document& document) { | 3520 bool LayoutObject::isAllowedToModifyLayoutTreeStructure(Document& document) { |
| 3489 return DeprecatedDisableModifyLayoutTreeStructureAsserts:: | 3521 return DeprecatedDisableModifyLayoutTreeStructureAsserts:: |
| 3490 canModifyLayoutTreeStateInAnyState() || | 3522 canModifyLayoutTreeStateInAnyState() || |
| 3491 document.lifecycle().stateAllowsLayoutTreeMutations(); | 3523 document.lifecycle().stateAllowsLayoutTreeMutations(); |
| 3492 } | 3524 } |
| 3493 | 3525 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3596 const blink::LayoutObject* root = object1; | 3628 const blink::LayoutObject* root = object1; |
| 3597 while (root->parent()) | 3629 while (root->parent()) |
| 3598 root = root->parent(); | 3630 root = root->parent(); |
| 3599 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); | 3631 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); |
| 3600 } else { | 3632 } else { |
| 3601 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); | 3633 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); |
| 3602 } | 3634 } |
| 3603 } | 3635 } |
| 3604 | 3636 |
| 3605 #endif | 3637 #endif |
| OLD | NEW |