Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| index d62eab76425595a0e172f6c538666b4162abbc8c..4c651507e174243f7c4134bb8d15669691b94533 100644 |
| --- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| +++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| @@ -1629,6 +1629,7 @@ void LayoutObject::markAncestorsForOverflowRecalcIfNeeded() { |
| void LayoutObject::setNeedsOverflowRecalcAfterStyleChange() { |
| bool neededRecalc = needsOverflowRecalcAfterStyleChange(); |
| setSelfNeedsOverflowRecalcAfterStyleChange(); |
| + setNeedsPaintOffsetAndVisualRectUpdate(); |
| if (!neededRecalc) |
| markAncestorsForOverflowRecalcIfNeeded(); |
| } |
| @@ -1728,11 +1729,21 @@ void LayoutObject::setStyle(PassRefPtr<ComputedStyle> style) { |
| } |
| if (diff.needsPaintInvalidationSubtree() || |
| - updatedDiff.needsPaintInvalidationSubtree()) |
| + updatedDiff.needsPaintInvalidationSubtree()) { |
| setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); |
| - else if (diff.needsPaintInvalidationObject() || |
| - updatedDiff.needsPaintInvalidationObject()) |
| - setShouldDoFullPaintInvalidation(); |
| + } else if (diff.needsPaintInvalidationObject() || |
| + updatedDiff.needsPaintInvalidationObject()) { |
| + // TODO(wangxianzhu): For now LayoutSVGRoot::localVisualRect() depends on |
| + // several styles. Refactor to avoid this special case. |
| + if (isSVGRoot()) |
| + setShouldDoFullPaintInvalidation(); |
| + else |
| + setShouldDoFullPaintInvalidationWithoutGeometryChange(); |
| + } |
| + |
| + // Visibility affects visual rect. |
| + if (oldStyle && oldStyle->visibility() != m_style->visibility()) |
| + setNeedsPaintOffsetAndVisualRectUpdate(); |
| // Text nodes share style with their parents but the paint properties don't |
| // apply to them, hence the !isText() check. |
| @@ -3413,21 +3424,37 @@ inline void LayoutObject::markAncestorsForPaintInvalidation() { |
| !parent |
| ->shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState(); |
| parent = parent->paintInvalidationParent()) |
| - parent->m_bitfields.setChildShouldCheckForPaintInvalidation(true); |
| + parent->m_bitfields.setMayNeedPaintInvalidation(true); |
| +} |
| + |
| +inline void LayoutObject::setNeedsPaintOffsetAndVisualRectUpdate() { |
| + if (needsPaintOffsetAndVisualRectUpdate()) |
| + return; |
| + m_bitfields.setNeedsPaintOffsetAndVisualRectUpdate(true); |
| + for (LayoutObject* parent = paintInvalidationParent(); |
| + parent && !parent->needsPaintOffsetAndVisualRectUpdate(); |
| + parent = parent->paintInvalidationParent()) |
| + parent->m_bitfields.setNeedsPaintOffsetAndVisualRectUpdate(true); |
| } |
| void LayoutObject::setShouldInvalidateSelection() { |
| if (!canUpdateSelectionOnRootLineBoxes()) |
| return; |
| m_bitfields.setShouldInvalidateSelection(true); |
| - markAncestorsForPaintInvalidation(); |
| + setMayNeedPaintInvalidation(); |
| frameView()->scheduleVisualUpdateForPaintInvalidationIfNeeded(); |
| } |
| void LayoutObject::setShouldDoFullPaintInvalidation( |
| PaintInvalidationReason reason) { |
| + 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.
|
| + setShouldDoFullPaintInvalidationWithoutGeometryChange(reason); |
| +} |
| + |
| +void LayoutObject::setShouldDoFullPaintInvalidationWithoutGeometryChange( |
| + PaintInvalidationReason reason) { |
| // Only full invalidation reasons are allowed. |
| - ASSERT(isFullPaintInvalidationReason(reason)); |
| + DCHECK(isFullPaintInvalidationReason(reason)); |
| bool isUpgradingDelayedFullToFull = |
| m_bitfields.fullPaintInvalidationReason() == |
| @@ -3448,6 +3475,11 @@ void LayoutObject::setShouldDoFullPaintInvalidation( |
| } |
| void LayoutObject::setMayNeedPaintInvalidation() { |
| + setNeedsPaintOffsetAndVisualRectUpdate(); |
| + setMayNeedPaintInvalidationWithoutGeometryChange(); |
| +} |
| + |
| +void LayoutObject::setMayNeedPaintInvalidationWithoutGeometryChange() { |
| if (mayNeedPaintInvalidation()) |
| return; |
| m_bitfields.setMayNeedPaintInvalidation(true); |
| @@ -3466,7 +3498,7 @@ void LayoutObject::setMayNeedPaintInvalidationAnimatedBackgroundImage() { |
| if (mayNeedPaintInvalidationAnimatedBackgroundImage()) |
| return; |
| m_bitfields.setMayNeedPaintInvalidationAnimatedBackgroundImage(true); |
| - setMayNeedPaintInvalidation(); |
| + setMayNeedPaintInvalidationWithoutGeometryChange(); |
| } |
| void LayoutObject::clearPaintInvalidationFlags() { |
| @@ -3477,10 +3509,10 @@ void LayoutObject::clearPaintInvalidationFlags() { |
| paintInvalidationStateIsDirty()); |
| #endif |
| clearShouldDoFullPaintInvalidation(); |
| - m_bitfields.setChildShouldCheckForPaintInvalidation(false); |
| m_bitfields.setMayNeedPaintInvalidation(false); |
| m_bitfields.setMayNeedPaintInvalidationSubtree(false); |
| m_bitfields.setMayNeedPaintInvalidationAnimatedBackgroundImage(false); |
| + m_bitfields.setNeedsPaintOffsetAndVisualRectUpdate(false); |
| m_bitfields.setShouldInvalidateSelection(false); |
| m_bitfields.setBackgroundChangedSinceLastPaintInvalidation(false); |
| } |