| 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 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1617 ? object->parent() | 1617 ? object->parent() |
| 1618 : object->containingBlock(); | 1618 : object->containingBlock(); |
| 1619 if (object) | 1619 if (object) |
| 1620 object->setChildNeedsOverflowRecalcAfterStyleChange(); | 1620 object->setChildNeedsOverflowRecalcAfterStyleChange(); |
| 1621 } while (object); | 1621 } while (object); |
| 1622 } | 1622 } |
| 1623 | 1623 |
| 1624 void LayoutObject::setNeedsOverflowRecalcAfterStyleChange() { | 1624 void LayoutObject::setNeedsOverflowRecalcAfterStyleChange() { |
| 1625 bool neededRecalc = needsOverflowRecalcAfterStyleChange(); | 1625 bool neededRecalc = needsOverflowRecalcAfterStyleChange(); |
| 1626 setSelfNeedsOverflowRecalcAfterStyleChange(); | 1626 setSelfNeedsOverflowRecalcAfterStyleChange(); |
| 1627 setMayNeedPaintInvalidation(); |
| 1627 if (!neededRecalc) | 1628 if (!neededRecalc) |
| 1628 markAncestorsForOverflowRecalcIfNeeded(); | 1629 markAncestorsForOverflowRecalcIfNeeded(); |
| 1629 } | 1630 } |
| 1630 | 1631 |
| 1631 DISABLE_CFI_PERF | 1632 DISABLE_CFI_PERF |
| 1632 void LayoutObject::setStyle(PassRefPtr<ComputedStyle> style) { | 1633 void LayoutObject::setStyle(PassRefPtr<ComputedStyle> style) { |
| 1633 ASSERT(style); | 1634 ASSERT(style); |
| 1634 | 1635 |
| 1635 if (m_style == style) { | 1636 if (m_style == style) { |
| 1636 // We need to run through adjustStyleDifference() for iframes, plugins, and | 1637 // We need to run through adjustStyleDifference() for iframes, plugins, and |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1716 | 1717 |
| 1717 if (diff.needsRecomputeOverflow() && !needsLayout()) { | 1718 if (diff.needsRecomputeOverflow() && !needsLayout()) { |
| 1718 // TODO(rhogan): Make inlines capable of recomputing overflow too. | 1719 // TODO(rhogan): Make inlines capable of recomputing overflow too. |
| 1719 if (isLayoutBlock()) | 1720 if (isLayoutBlock()) |
| 1720 setNeedsOverflowRecalcAfterStyleChange(); | 1721 setNeedsOverflowRecalcAfterStyleChange(); |
| 1721 else | 1722 else |
| 1722 setNeedsLayoutAndPrefWidthsRecalc(LayoutInvalidationReason::StyleChange); | 1723 setNeedsLayoutAndPrefWidthsRecalc(LayoutInvalidationReason::StyleChange); |
| 1723 } | 1724 } |
| 1724 | 1725 |
| 1725 if (diff.needsPaintInvalidationSubtree() || | 1726 if (diff.needsPaintInvalidationSubtree() || |
| 1726 updatedDiff.needsPaintInvalidationSubtree()) | 1727 updatedDiff.needsPaintInvalidationSubtree()) { |
| 1727 setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); | 1728 setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); |
| 1728 else if (diff.needsPaintInvalidationObject() || | 1729 } else if (diff.needsPaintInvalidationObject() || |
| 1729 updatedDiff.needsPaintInvalidationObject()) | 1730 updatedDiff.needsPaintInvalidationObject()) { |
| 1730 setShouldDoFullPaintInvalidation(); | 1731 // TODO(wangxianzhu): For now LayoutSVGRoot::localVisualRect() depends on |
| 1732 // several styles. Refactor to avoid this special case. |
| 1733 if (isSVGRoot()) |
| 1734 setShouldDoFullPaintInvalidation(); |
| 1735 else |
| 1736 setShouldDoFullPaintInvalidationWithoutGeometryChange(); |
| 1737 } |
| 1731 | 1738 |
| 1732 // Text nodes share style with their parents but the paint properties don't | 1739 // Text nodes share style with their parents but the paint properties don't |
| 1733 // apply to them, hence the !isText() check. | 1740 // apply to them, hence the !isText() check. |
| 1734 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && !isText() && | 1741 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && !isText() && |
| 1735 (diff.transformChanged() || diff.opacityChanged() || | 1742 (diff.transformChanged() || diff.opacityChanged() || |
| 1736 diff.zIndexChanged() || diff.filterChanged() || | 1743 diff.zIndexChanged() || diff.filterChanged() || |
| 1737 diff.backdropFilterChanged() || diff.cssClipChanged())) { | 1744 diff.backdropFilterChanged() || diff.cssClipChanged())) { |
| 1738 setNeedsPaintPropertyUpdate(); | 1745 setNeedsPaintPropertyUpdate(); |
| 1739 | 1746 |
| 1740 // We don't need to invalidate paint of objects on SPv2 when only paint | 1747 // We don't need to invalidate paint of objects on SPv2 when only paint |
| (...skipping 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3402 return PaintInvalidationCompositingUpdate; | 3409 return PaintInvalidationCompositingUpdate; |
| 3403 default: | 3410 default: |
| 3404 return PaintInvalidationFull; | 3411 return PaintInvalidationFull; |
| 3405 } | 3412 } |
| 3406 } | 3413 } |
| 3407 | 3414 |
| 3408 inline void LayoutObject::markAncestorsForPaintInvalidation() { | 3415 inline void LayoutObject::markAncestorsForPaintInvalidation() { |
| 3409 for (LayoutObject* parent = this->paintInvalidationParent(); | 3416 for (LayoutObject* parent = this->paintInvalidationParent(); |
| 3410 parent && !parent->shouldCheckForPaintInvalidation(); | 3417 parent && !parent->shouldCheckForPaintInvalidation(); |
| 3411 parent = parent->paintInvalidationParent()) | 3418 parent = parent->paintInvalidationParent()) |
| 3412 parent->m_bitfields.setChildShouldCheckForPaintInvalidation(true); | 3419 parent->m_bitfields.setMayNeedPaintInvalidation(true); |
| 3420 } |
| 3421 |
| 3422 inline void LayoutObject::setNeedsPaintOffsetAndVisualRectUpdate() { |
| 3423 if (needsPaintOffsetAndVisualRectUpdate()) |
| 3424 return; |
| 3425 m_bitfields.setNeedsPaintOffsetAndVisualRectUpdate(true); |
| 3426 for (LayoutObject* parent = paintInvalidationParent(); |
| 3427 parent && !parent->needsPaintOffsetAndVisualRectUpdate(); |
| 3428 parent = parent->paintInvalidationParent()) |
| 3429 parent->m_bitfields.setNeedsPaintOffsetAndVisualRectUpdate(true); |
| 3413 } | 3430 } |
| 3414 | 3431 |
| 3415 void LayoutObject::setShouldInvalidateSelection() { | 3432 void LayoutObject::setShouldInvalidateSelection() { |
| 3416 if (!canUpdateSelectionOnRootLineBoxes()) | 3433 if (!canUpdateSelectionOnRootLineBoxes()) |
| 3417 return; | 3434 return; |
| 3418 m_bitfields.setShouldInvalidateSelection(true); | 3435 m_bitfields.setShouldInvalidateSelection(true); |
| 3419 markAncestorsForPaintInvalidation(); | 3436 setMayNeedPaintInvalidation(); |
| 3420 frameView()->scheduleVisualUpdateForPaintInvalidationIfNeeded(); | 3437 frameView()->scheduleVisualUpdateForPaintInvalidationIfNeeded(); |
| 3421 } | 3438 } |
| 3422 | 3439 |
| 3423 bool LayoutObject::shouldCheckForPaintInvalidationWithPaintInvalidationState( | 3440 bool LayoutObject::shouldCheckForPaintInvalidationWithPaintInvalidationState( |
| 3424 const PaintInvalidationState& paintInvalidationState) const { | 3441 const PaintInvalidationState& paintInvalidationState) const { |
| 3425 return paintInvalidationState.hasForcedSubtreeInvalidationFlags() || | 3442 return paintInvalidationState.hasForcedSubtreeInvalidationFlags() || |
| 3426 shouldCheckForPaintInvalidation(); | 3443 shouldCheckForPaintInvalidation(); |
| 3427 } | 3444 } |
| 3428 | 3445 |
| 3429 void LayoutObject::setShouldDoFullPaintInvalidation( | 3446 void LayoutObject::setShouldDoFullPaintInvalidation( |
| 3430 PaintInvalidationReason reason) { | 3447 PaintInvalidationReason reason) { |
| 3448 setNeedsPaintOffsetAndVisualRectUpdate(); |
| 3449 setShouldDoFullPaintInvalidationWithoutGeometryChange(reason); |
| 3450 } |
| 3451 |
| 3452 void LayoutObject::setShouldDoFullPaintInvalidationWithoutGeometryChange( |
| 3453 PaintInvalidationReason reason) { |
| 3431 // Only full invalidation reasons are allowed. | 3454 // Only full invalidation reasons are allowed. |
| 3432 ASSERT(isFullPaintInvalidationReason(reason)); | 3455 DCHECK(isFullPaintInvalidationReason(reason)); |
| 3433 | 3456 |
| 3434 bool isUpgradingDelayedFullToFull = | 3457 bool isUpgradingDelayedFullToFull = |
| 3435 m_bitfields.fullPaintInvalidationReason() == | 3458 m_bitfields.fullPaintInvalidationReason() == |
| 3436 PaintInvalidationDelayedFull && | 3459 PaintInvalidationDelayedFull && |
| 3437 reason != PaintInvalidationDelayedFull; | 3460 reason != PaintInvalidationDelayedFull; |
| 3438 | 3461 |
| 3439 if (m_bitfields.fullPaintInvalidationReason() == PaintInvalidationNone || | 3462 if (m_bitfields.fullPaintInvalidationReason() == PaintInvalidationNone || |
| 3440 isUpgradingDelayedFullToFull) { | 3463 isUpgradingDelayedFullToFull) { |
| 3441 if (reason == PaintInvalidationFull) | 3464 if (reason == PaintInvalidationFull) |
| 3442 reason = | 3465 reason = |
| 3443 documentLifecycleBasedPaintInvalidationReason(document().lifecycle()); | 3466 documentLifecycleBasedPaintInvalidationReason(document().lifecycle()); |
| 3444 m_bitfields.setFullPaintInvalidationReason(reason); | 3467 m_bitfields.setFullPaintInvalidationReason(reason); |
| 3445 if (!isUpgradingDelayedFullToFull) | 3468 if (!isUpgradingDelayedFullToFull) |
| 3446 markAncestorsForPaintInvalidation(); | 3469 markAncestorsForPaintInvalidation(); |
| 3447 } | 3470 } |
| 3448 | 3471 |
| 3449 frameView()->scheduleVisualUpdateForPaintInvalidationIfNeeded(); | 3472 frameView()->scheduleVisualUpdateForPaintInvalidationIfNeeded(); |
| 3450 } | 3473 } |
| 3451 | 3474 |
| 3452 void LayoutObject::setMayNeedPaintInvalidation() { | 3475 void LayoutObject::setMayNeedPaintInvalidation() { |
| 3476 setNeedsPaintOffsetAndVisualRectUpdate(); |
| 3477 setMayNeedPaintInvalidationWithoutGeometryChange(); |
| 3478 } |
| 3479 |
| 3480 void LayoutObject::setMayNeedPaintInvalidationWithoutGeometryChange() { |
| 3453 if (mayNeedPaintInvalidation()) | 3481 if (mayNeedPaintInvalidation()) |
| 3454 return; | 3482 return; |
| 3455 m_bitfields.setMayNeedPaintInvalidation(true); | 3483 m_bitfields.setMayNeedPaintInvalidation(true); |
| 3456 markAncestorsForPaintInvalidation(); | 3484 markAncestorsForPaintInvalidation(); |
| 3457 frameView()->scheduleVisualUpdateForPaintInvalidationIfNeeded(); | 3485 frameView()->scheduleVisualUpdateForPaintInvalidationIfNeeded(); |
| 3458 } | 3486 } |
| 3459 | 3487 |
| 3460 void LayoutObject::setMayNeedPaintInvalidationSubtree() { | 3488 void LayoutObject::setMayNeedPaintInvalidationSubtree() { |
| 3461 if (mayNeedPaintInvalidationSubtree()) | 3489 if (mayNeedPaintInvalidationSubtree()) |
| 3462 return; | 3490 return; |
| 3463 m_bitfields.setMayNeedPaintInvalidationSubtree(true); | 3491 m_bitfields.setMayNeedPaintInvalidationSubtree(true); |
| 3464 setMayNeedPaintInvalidation(); | 3492 setMayNeedPaintInvalidation(); |
| 3465 } | 3493 } |
| 3466 | 3494 |
| 3467 void LayoutObject::setMayNeedPaintInvalidationAnimatedBackgroundImage() { | 3495 void LayoutObject::setMayNeedPaintInvalidationAnimatedBackgroundImage() { |
| 3468 if (mayNeedPaintInvalidationAnimatedBackgroundImage()) | 3496 if (mayNeedPaintInvalidationAnimatedBackgroundImage()) |
| 3469 return; | 3497 return; |
| 3470 m_bitfields.setMayNeedPaintInvalidationAnimatedBackgroundImage(true); | 3498 m_bitfields.setMayNeedPaintInvalidationAnimatedBackgroundImage(true); |
| 3471 setMayNeedPaintInvalidation(); | 3499 setMayNeedPaintInvalidationWithoutGeometryChange(); |
| 3472 } | 3500 } |
| 3473 | 3501 |
| 3474 void LayoutObject::clearPaintInvalidationFlags() { | 3502 void LayoutObject::clearPaintInvalidationFlags() { |
| 3475 // paintInvalidationStateIsDirty should be kept in sync with the | 3503 // paintInvalidationStateIsDirty should be kept in sync with the |
| 3476 // booleans that are cleared below. | 3504 // booleans that are cleared below. |
| 3477 #if DCHECK_IS_ON() | 3505 #if DCHECK_IS_ON() |
| 3478 DCHECK(!shouldCheckForPaintInvalidation() || paintInvalidationStateIsDirty()); | 3506 DCHECK(!shouldCheckForPaintInvalidation() || paintInvalidationStateIsDirty()); |
| 3479 #endif | 3507 #endif |
| 3480 clearShouldDoFullPaintInvalidation(); | 3508 clearShouldDoFullPaintInvalidation(); |
| 3481 m_bitfields.setChildShouldCheckForPaintInvalidation(false); | |
| 3482 m_bitfields.setMayNeedPaintInvalidation(false); | 3509 m_bitfields.setMayNeedPaintInvalidation(false); |
| 3483 m_bitfields.setMayNeedPaintInvalidationSubtree(false); | 3510 m_bitfields.setMayNeedPaintInvalidationSubtree(false); |
| 3484 m_bitfields.setMayNeedPaintInvalidationAnimatedBackgroundImage(false); | 3511 m_bitfields.setMayNeedPaintInvalidationAnimatedBackgroundImage(false); |
| 3512 m_bitfields.setNeedsPaintOffsetAndVisualRectUpdate(false); |
| 3485 m_bitfields.setShouldInvalidateSelection(false); | 3513 m_bitfields.setShouldInvalidateSelection(false); |
| 3486 m_bitfields.setBackgroundChangedSinceLastPaintInvalidation(false); | 3514 m_bitfields.setBackgroundChangedSinceLastPaintInvalidation(false); |
| 3487 } | 3515 } |
| 3488 | 3516 |
| 3489 bool LayoutObject::isAllowedToModifyLayoutTreeStructure(Document& document) { | 3517 bool LayoutObject::isAllowedToModifyLayoutTreeStructure(Document& document) { |
| 3490 return DeprecatedDisableModifyLayoutTreeStructureAsserts:: | 3518 return DeprecatedDisableModifyLayoutTreeStructureAsserts:: |
| 3491 canModifyLayoutTreeStateInAnyState() || | 3519 canModifyLayoutTreeStateInAnyState() || |
| 3492 document.lifecycle().stateAllowsLayoutTreeMutations(); | 3520 document.lifecycle().stateAllowsLayoutTreeMutations(); |
| 3493 } | 3521 } |
| 3494 | 3522 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3597 const blink::LayoutObject* root = object1; | 3625 const blink::LayoutObject* root = object1; |
| 3598 while (root->parent()) | 3626 while (root->parent()) |
| 3599 root = root->parent(); | 3627 root = root->parent(); |
| 3600 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); | 3628 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); |
| 3601 } else { | 3629 } else { |
| 3602 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); | 3630 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); |
| 3603 } | 3631 } |
| 3604 } | 3632 } |
| 3605 | 3633 |
| 3606 #endif | 3634 #endif |
| OLD | NEW |