Commit afbc3514 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Fix ObjectPaintInvalidatorTest for LayoutNG

LayoutNG allows an inline to contain floating objects, so the original
logic for floating objects escaping inline containers doesn't apply.

Bug: 922645
Change-Id: Id736d7051a6356325be92cb7fa25949a21304c1f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1913027Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715184}
parent 57ee9cf0
...@@ -22,18 +22,24 @@ template <typename Functor> ...@@ -22,18 +22,24 @@ template <typename Functor>
static void TraverseNonCompositingDescendantsInPaintOrder(const LayoutObject&, static void TraverseNonCompositingDescendantsInPaintOrder(const LayoutObject&,
const Functor&); const Functor&);
static bool MayBeSkippedContainerForFloating(const LayoutObject& object) {
return !object.IsInLayoutNGInlineFormattingContext() &&
!object.IsLayoutBlock();
}
template <typename Functor> template <typename Functor>
static void static void
TraverseNonCompositingDescendantsBelongingToAncestorPaintInvalidationContainer( TraverseNonCompositingDescendantsBelongingToAncestorPaintInvalidationContainer(
const LayoutObject& object, const LayoutObject& object,
const Functor& functor) { const Functor& functor) {
// |object| is a paint invalidation container, but is not a stacking context // |object| is a paint invalidation container, but is not a stacking context
// or is a non-block, so the paint invalidation container of stacked // (legacy layout only: or is a non-block), so the paint invalidation
// descendants may not belong to |object| but belong to an ancestor. This // container of stacked descendants may not belong to |object| but belong to
// function traverses all such descendants. See Case 1a and Case 2 below for // an ancestor. This function traverses all such descendants. See (legacy
// details. // layout only: Case 1a and) Case 2 below for details.
DCHECK(object.IsPaintInvalidationContainer() && DCHECK(object.IsPaintInvalidationContainer() &&
(!object.StyleRef().IsStackingContext() || !object.IsLayoutBlock())); (!object.StyleRef().IsStackingContext() ||
MayBeSkippedContainerForFloating(object)));
LayoutObject* descendant = object.NextInPreOrder(&object); LayoutObject* descendant = object.NextInPreOrder(&object);
while (descendant) { while (descendant) {
...@@ -43,7 +49,10 @@ TraverseNonCompositingDescendantsBelongingToAncestorPaintInvalidationContainer( ...@@ -43,7 +49,10 @@ TraverseNonCompositingDescendantsBelongingToAncestorPaintInvalidationContainer(
// invalidation container in the same situation as |object|, or its paint // invalidation container in the same situation as |object|, or its paint
// invalidation container is in such situation. Keep searching until a // invalidation container is in such situation. Keep searching until a
// stacked layer is found. // stacked layer is found.
if (!object.IsLayoutBlock() && descendant->IsFloating()) { if (MayBeSkippedContainerForFloating(object) &&
descendant->IsFloating()) {
// The following is for legacy layout only because LayoutNG allows an
// inline to contain floats.
// Case 1a (rare): However, if the descendant is a floating object below // Case 1a (rare): However, if the descendant is a floating object below
// a composited non-block object, the subtree may belong to an ancestor // a composited non-block object, the subtree may belong to an ancestor
// in paint order, thus recur into the subtree. Note that for // in paint order, thus recur into the subtree. Note that for
...@@ -65,12 +74,13 @@ TraverseNonCompositingDescendantsBelongingToAncestorPaintInvalidationContainer( ...@@ -65,12 +74,13 @@ TraverseNonCompositingDescendantsBelongingToAncestorPaintInvalidationContainer(
TraverseNonCompositingDescendantsInPaintOrder(*descendant, functor); TraverseNonCompositingDescendantsInPaintOrder(*descendant, functor);
descendant = descendant->NextInPreOrderAfterChildren(&object); descendant = descendant->NextInPreOrderAfterChildren(&object);
} else if (descendant->StyleRef().IsStackingContext() && } else if (descendant->StyleRef().IsStackingContext() &&
descendant->IsLayoutBlock()) { !MayBeSkippedContainerForFloating(*descendant)) {
// Case 3: The descendant is an invalidation container and is a stacking // Case 3: The descendant is an invalidation container and is a stacking
// context. No objects in the subtree can have invalidation container // context. No objects in the subtree can have invalidation container
// outside of it, thus skip the whole subtree. // outside of it, thus skip the whole subtree.
// This excludes non-block because there might be floating objects under // Legacy layout only: This excludes non-block because there might be
// the descendant belonging to some ancestor in paint order (Case 1a). // floating objects under the descendant belonging to some ancestor in
// paint order (Case 1a).
descendant = descendant->NextInPreOrderAfterChildren(&object); descendant = descendant->NextInPreOrderAfterChildren(&object);
} else { } else {
// Case 4: The descendant is an invalidation container but not a stacking // Case 4: The descendant is an invalidation container but not a stacking
...@@ -92,12 +102,13 @@ static void TraverseNonCompositingDescendantsInPaintOrder( ...@@ -92,12 +102,13 @@ static void TraverseNonCompositingDescendantsInPaintOrder(
functor(*descendant); functor(*descendant);
descendant = descendant->NextInPreOrder(&object); descendant = descendant->NextInPreOrder(&object);
} else if (descendant->StyleRef().IsStackingContext() && } else if (descendant->StyleRef().IsStackingContext() &&
descendant->IsLayoutBlock()) { !MayBeSkippedContainerForFloating(*descendant)) {
// The descendant is an invalidation container and is a stacking context. // The descendant is an invalidation container and is a stacking context.
// No objects in the subtree can have invalidation container outside of // No objects in the subtree can have invalidation container outside of
// it, thus skip the whole subtree. // it, thus skip the whole subtree.
// This excludes non-blocks because there might be floating objects under // Legacy layout only: This excludes non-blocks because there might be
// the descendant belonging to some ancestor in paint order (Case 1a). // floating objects under the descendant belonging to some ancestor in
// paint order (Case 1a).
descendant = descendant->NextInPreOrderAfterChildren(&object); descendant = descendant->NextInPreOrderAfterChildren(&object);
} else { } else {
// If a paint invalidation container is not a stacking context, or the // If a paint invalidation container is not a stacking context, or the
...@@ -116,7 +127,9 @@ static void SetPaintingLayerNeedsRepaintDuringTraverse( ...@@ -116,7 +127,9 @@ static void SetPaintingLayerNeedsRepaintDuringTraverse(
ToLayoutBoxModelObject(object).HasSelfPaintingLayer()) { ToLayoutBoxModelObject(object).HasSelfPaintingLayer()) {
ToLayoutBoxModelObject(object).Layer()->SetNeedsRepaint(); ToLayoutBoxModelObject(object).Layer()->SetNeedsRepaint();
} else if (object.IsFloating() && object.Parent() && } else if (object.IsFloating() && object.Parent() &&
!object.Parent()->IsLayoutBlock()) { MayBeSkippedContainerForFloating(*object.Parent())) {
// The following is for legacy layout only because LayoutNG allows an
// inline to contain floats.
object.PaintingLayer()->SetNeedsRepaint(); object.PaintingLayer()->SetNeedsRepaint();
} }
} }
......
...@@ -123,6 +123,7 @@ class PLATFORM_EXPORT DisplayItemClient { ...@@ -123,6 +123,7 @@ class PLATFORM_EXPORT DisplayItemClient {
private: private:
friend class FakeDisplayItemClient; friend class FakeDisplayItemClient;
friend class ObjectPaintInvalidatorTest;
friend class PaintController; friend class PaintController;
void Validate() const { void Validate() const {
......
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