Commit cabebfee authored by wangxianzhu's avatar wangxianzhu Committed by Commit bot

Add 'WithoutGeometryChange' variants of paint invalidation flag setters

Add a flag needsPaintOffsetAndVisualRectUpdate() to indicate that the
object needs paint offset and visual rect update during
PrePaintTreeWalk.

The original paint invalidation flag setters setMayNeedPaintInvalidation,
setShouldDoFullPaintInvalidaiton and setters calling the two will set
the new flag besides the original flags.

Add 'WithoutGeometryChange' variants of the two setters to allow
PrePaintTreeWalk to skip paint offset and visual rect update (to be
implemented in later CLs).

BUG=697081,685179

Review-Url: https://codereview.chromium.org/2751383003
Cr-Commit-Position: refs/heads/master@{#457809}
parent 79fc7765
......@@ -1646,12 +1646,12 @@ void LayoutBox::imageChanged(WrappedImagePtr image, const IntRect*) {
styleRef().maskBoxImage().image()->data() == image) ||
(styleRef().boxReflect() && styleRef().boxReflect()->mask().image() &&
styleRef().boxReflect()->mask().image()->data() == image)) {
setShouldDoFullPaintInvalidation();
setShouldDoFullPaintInvalidationWithoutGeometryChange();
} else {
for (const FillLayer* layer = &styleRef().maskLayers(); layer;
layer = layer->next()) {
if (layer->image() && image == layer->image()->data()) {
setShouldDoFullPaintInvalidation();
setShouldDoFullPaintInvalidationWithoutGeometryChange();
break;
}
}
......@@ -1669,7 +1669,7 @@ void LayoutBox::imageChanged(WrappedImagePtr image, const IntRect*) {
if (maybeAnimated) {
setMayNeedPaintInvalidationAnimatedBackgroundImage();
} else {
setShouldDoFullPaintInvalidation();
setShouldDoFullPaintInvalidationWithoutGeometryChange();
setBackgroundChangedSinceLastPaintInvalidation();
}
break;
......@@ -1750,8 +1750,10 @@ void LayoutBox::ensureIsReadyForPaintInvalidation() {
LayoutBoxModelObject::ensureIsReadyForPaintInvalidation();
if (mayNeedPaintInvalidationAnimatedBackgroundImage() &&
!backgroundIsKnownToBeObscured())
setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull);
!backgroundIsKnownToBeObscured()) {
setShouldDoFullPaintInvalidationWithoutGeometryChange(
PaintInvalidationDelayedFull);
}
if (fullPaintInvalidationReason() != PaintInvalidationDelayedFull ||
!intersectsVisibleViewport())
......@@ -1763,7 +1765,8 @@ void LayoutBox::ensureIsReadyForPaintInvalidation() {
// Conservatively assume the delayed paint invalidation was caused by
// background image change.
setBackgroundChangedSinceLastPaintInvalidation();
setShouldDoFullPaintInvalidation(PaintInvalidationFull);
setShouldDoFullPaintInvalidationWithoutGeometryChange(
PaintInvalidationFull);
}
}
......
......@@ -1624,6 +1624,7 @@ void LayoutObject::markAncestorsForOverflowRecalcIfNeeded() {
void LayoutObject::setNeedsOverflowRecalcAfterStyleChange() {
bool neededRecalc = needsOverflowRecalcAfterStyleChange();
setSelfNeedsOverflowRecalcAfterStyleChange();
setNeedsPaintOffsetAndVisualRectUpdate();
if (!neededRecalc)
markAncestorsForOverflowRecalcIfNeeded();
}
......@@ -1723,11 +1724,17 @@ void LayoutObject::setStyle(PassRefPtr<ComputedStyle> style) {
}
if (diff.needsPaintInvalidationSubtree() ||
updatedDiff.needsPaintInvalidationSubtree())
updatedDiff.needsPaintInvalidationSubtree()) {
setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants();
else if (diff.needsPaintInvalidationObject() ||
updatedDiff.needsPaintInvalidationObject())
} 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();
}
// Text nodes share style with their parents but the paint properties don't
// apply to them, hence the !isText() check.
......@@ -3409,14 +3416,24 @@ inline void LayoutObject::markAncestorsForPaintInvalidation() {
for (LayoutObject* parent = this->paintInvalidationParent();
parent && !parent->shouldCheckForPaintInvalidation();
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();
}
......@@ -3428,8 +3445,14 @@ bool LayoutObject::shouldCheckForPaintInvalidationWithPaintInvalidationState(
void LayoutObject::setShouldDoFullPaintInvalidation(
PaintInvalidationReason reason) {
setNeedsPaintOffsetAndVisualRectUpdate();
setShouldDoFullPaintInvalidationWithoutGeometryChange(reason);
}
void LayoutObject::setShouldDoFullPaintInvalidationWithoutGeometryChange(
PaintInvalidationReason reason) {
// Only full invalidation reasons are allowed.
ASSERT(isFullPaintInvalidationReason(reason));
DCHECK(isFullPaintInvalidationReason(reason));
bool isUpgradingDelayedFullToFull =
m_bitfields.fullPaintInvalidationReason() ==
......@@ -3450,6 +3473,11 @@ void LayoutObject::setShouldDoFullPaintInvalidation(
}
void LayoutObject::setMayNeedPaintInvalidation() {
setNeedsPaintOffsetAndVisualRectUpdate();
setMayNeedPaintInvalidationWithoutGeometryChange();
}
void LayoutObject::setMayNeedPaintInvalidationWithoutGeometryChange() {
if (mayNeedPaintInvalidation())
return;
m_bitfields.setMayNeedPaintInvalidation(true);
......@@ -3468,7 +3496,7 @@ void LayoutObject::setMayNeedPaintInvalidationAnimatedBackgroundImage() {
if (mayNeedPaintInvalidationAnimatedBackgroundImage())
return;
m_bitfields.setMayNeedPaintInvalidationAnimatedBackgroundImage(true);
setMayNeedPaintInvalidation();
setMayNeedPaintInvalidationWithoutGeometryChange();
}
void LayoutObject::clearPaintInvalidationFlags() {
......@@ -3478,10 +3506,10 @@ void LayoutObject::clearPaintInvalidationFlags() {
DCHECK(!shouldCheckForPaintInvalidation() || 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);
}
......
......@@ -1645,6 +1645,8 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
}
void setShouldDoFullPaintInvalidation(
PaintInvalidationReason = PaintInvalidationFull);
void setShouldDoFullPaintInvalidationWithoutGeometryChange(
PaintInvalidationReason = PaintInvalidationFull);
void clearShouldDoFullPaintInvalidation() {
m_bitfields.setFullPaintInvalidationReason(PaintInvalidationNone);
}
......@@ -1655,12 +1657,17 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
return m_bitfields.mayNeedPaintInvalidation();
}
void setMayNeedPaintInvalidation();
void setMayNeedPaintInvalidationWithoutGeometryChange();
bool mayNeedPaintInvalidationSubtree() const {
return m_bitfields.mayNeedPaintInvalidationSubtree();
}
void setMayNeedPaintInvalidationSubtree();
bool needsPaintOffsetAndVisualRectUpdate() const {
return m_bitfields.needsPaintOffsetAndVisualRectUpdate();
}
bool mayNeedPaintInvalidationAnimatedBackgroundImage() const {
return m_bitfields.mayNeedPaintInvalidationAnimatedBackgroundImage();
}
......@@ -1675,9 +1682,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
const PaintInvalidationState&) const;
bool shouldCheckForPaintInvalidation() const {
return mayNeedPaintInvalidation() || shouldDoFullPaintInvalidation() ||
shouldInvalidateSelection() ||
m_bitfields.childShouldCheckForPaintInvalidation();
return mayNeedPaintInvalidation() || shouldDoFullPaintInvalidation();
}
virtual LayoutRect viewRect() const;
......@@ -2014,7 +2019,8 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
#if DCHECK_IS_ON()
virtual bool paintInvalidationStateIsDirty() const {
return backgroundChangedSinceLastPaintInvalidation() ||
shouldCheckForPaintInvalidation();
shouldCheckForPaintInvalidation() || shouldInvalidateSelection() ||
needsPaintOffsetAndVisualRectUpdate();
}
#endif
......@@ -2099,6 +2105,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
inline void markAncestorsForOverflowRecalcIfNeeded();
inline void markAncestorsForPaintInvalidation();
inline void setNeedsPaintOffsetAndVisualRectUpdate();
inline void invalidateContainerPreferredLogicalWidths();
......@@ -2195,10 +2202,10 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
m_selfNeedsOverflowRecalcAfterStyleChange(false),
m_childNeedsOverflowRecalcAfterStyleChange(false),
m_preferredLogicalWidthsDirty(false),
m_childShouldCheckForPaintInvalidation(false),
m_mayNeedPaintInvalidation(false),
m_mayNeedPaintInvalidationSubtree(false),
m_mayNeedPaintInvalidationAnimatedBackgroundImage(false),
m_needsPaintOffsetAndVisualRectUpdate(false),
m_shouldInvalidateSelection(false),
m_floating(false),
m_isAnonymous(!node),
......@@ -2297,13 +2304,13 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
ADD_BOOLEAN_BITFIELD(preferredLogicalWidthsDirty,
PreferredLogicalWidthsDirty);
ADD_BOOLEAN_BITFIELD(childShouldCheckForPaintInvalidation,
ChildShouldCheckForPaintInvalidation);
ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidation, MayNeedPaintInvalidation);
ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidationSubtree,
MayNeedPaintInvalidationSubtree);
ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidationAnimatedBackgroundImage,
MayNeedPaintInvalidationAnimatedBackgroundImage);
ADD_BOOLEAN_BITFIELD(needsPaintOffsetAndVisualRectUpdate,
NeedsPaintOffsetAndVisualRectUpdate);
ADD_BOOLEAN_BITFIELD(shouldInvalidateSelection, ShouldInvalidateSelection);
// This boolean is the cached value of 'float'
......
......@@ -182,8 +182,7 @@ TEST_F(LayoutObjectTest, MutableForPaintingClearPaintFlags) {
LayoutObject* object = document().body()->layoutObject();
object->setShouldDoFullPaintInvalidation();
EXPECT_TRUE(object->shouldDoFullPaintInvalidation());
object->m_bitfields.setChildShouldCheckForPaintInvalidation(true);
EXPECT_TRUE(object->m_bitfields.childShouldCheckForPaintInvalidation());
EXPECT_TRUE(object->needsPaintOffsetAndVisualRectUpdate());
object->setMayNeedPaintInvalidation();
EXPECT_TRUE(object->mayNeedPaintInvalidation());
object->setMayNeedPaintInvalidationSubtree();
......@@ -204,7 +203,6 @@ TEST_F(LayoutObjectTest, MutableForPaintingClearPaintFlags) {
object->getMutableForPainting().clearPaintFlags();
EXPECT_FALSE(object->shouldDoFullPaintInvalidation());
EXPECT_FALSE(object->m_bitfields.childShouldCheckForPaintInvalidation());
EXPECT_FALSE(object->mayNeedPaintInvalidation());
EXPECT_FALSE(object->mayNeedPaintInvalidationSubtree());
EXPECT_FALSE(object->mayNeedPaintInvalidationAnimatedBackgroundImage());
......@@ -214,4 +212,63 @@ TEST_F(LayoutObjectTest, MutableForPaintingClearPaintFlags) {
EXPECT_FALSE(object->descendantNeedsPaintPropertyUpdate());
}
TEST_F(LayoutObjectTest, NeedsPaintOffsetAndVisualRectUpdate) {
LayoutObject* object = document().body()->layoutObject();
LayoutObject* parent = object->parent();
object->setShouldDoFullPaintInvalidation();
EXPECT_TRUE(object->shouldDoFullPaintInvalidation());
EXPECT_TRUE(object->needsPaintOffsetAndVisualRectUpdate());
EXPECT_TRUE(parent->mayNeedPaintInvalidation());
EXPECT_TRUE(parent->needsPaintOffsetAndVisualRectUpdate());
object->clearPaintInvalidationFlags();
EXPECT_FALSE(object->shouldDoFullPaintInvalidation());
EXPECT_FALSE(object->needsPaintOffsetAndVisualRectUpdate());
parent->clearPaintInvalidationFlags();
EXPECT_FALSE(parent->mayNeedPaintInvalidation());
EXPECT_FALSE(parent->needsPaintOffsetAndVisualRectUpdate());
object->setMayNeedPaintInvalidation();
EXPECT_TRUE(object->mayNeedPaintInvalidation());
EXPECT_TRUE(object->needsPaintOffsetAndVisualRectUpdate());
EXPECT_TRUE(parent->mayNeedPaintInvalidation());
EXPECT_TRUE(parent->needsPaintOffsetAndVisualRectUpdate());
object->clearPaintInvalidationFlags();
EXPECT_FALSE(object->mayNeedPaintInvalidation());
EXPECT_FALSE(object->needsPaintOffsetAndVisualRectUpdate());
parent->clearPaintInvalidationFlags();
EXPECT_FALSE(parent->mayNeedPaintInvalidation());
EXPECT_FALSE(parent->needsPaintOffsetAndVisualRectUpdate());
object->setShouldDoFullPaintInvalidationWithoutGeometryChange();
EXPECT_TRUE(object->shouldDoFullPaintInvalidation());
EXPECT_FALSE(object->needsPaintOffsetAndVisualRectUpdate());
EXPECT_TRUE(parent->mayNeedPaintInvalidation());
EXPECT_FALSE(parent->needsPaintOffsetAndVisualRectUpdate());
object->setMayNeedPaintInvalidation();
EXPECT_TRUE(object->needsPaintOffsetAndVisualRectUpdate());
EXPECT_TRUE(parent->needsPaintOffsetAndVisualRectUpdate());
object->clearPaintInvalidationFlags();
EXPECT_FALSE(object->mayNeedPaintInvalidation());
EXPECT_FALSE(object->needsPaintOffsetAndVisualRectUpdate());
parent->clearPaintInvalidationFlags();
EXPECT_FALSE(parent->mayNeedPaintInvalidation());
EXPECT_FALSE(parent->needsPaintOffsetAndVisualRectUpdate());
object->setMayNeedPaintInvalidationWithoutGeometryChange();
EXPECT_TRUE(object->mayNeedPaintInvalidation());
EXPECT_FALSE(object->needsPaintOffsetAndVisualRectUpdate());
EXPECT_TRUE(parent->mayNeedPaintInvalidation());
EXPECT_FALSE(parent->needsPaintOffsetAndVisualRectUpdate());
object->setMayNeedPaintInvalidation();
EXPECT_TRUE(object->needsPaintOffsetAndVisualRectUpdate());
EXPECT_TRUE(parent->needsPaintOffsetAndVisualRectUpdate());
object->clearPaintInvalidationFlags();
EXPECT_FALSE(object->mayNeedPaintInvalidation());
EXPECT_FALSE(object->needsPaintOffsetAndVisualRectUpdate());
parent->clearPaintInvalidationFlags();
EXPECT_FALSE(parent->mayNeedPaintInvalidation());
EXPECT_FALSE(parent->needsPaintOffsetAndVisualRectUpdate());
}
} // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment