Commit 336bac22 authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

[FlexNG] Merge anonymous flex-items when elements are removed.

This code is basically lifted from LayoutFlexibleBox::RemoveChild.

Bug: 845235
Change-Id: Icdda90143d896cb9678cab3cde1bfc4554471701
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1982619Reviewed-by: default avatarDavid Grogan <dgrogan@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728109}
parent a4787d09
......@@ -52,4 +52,31 @@ void LayoutNGFlexibleBox::UpdateBlockLayout(bool relayout_children) {
descendant.node.UseLegacyOutOfFlowPositioning();
}
namespace {
void MergeAnonymousFlexItems(LayoutObject* remove_child) {
// When we remove a flex item, and the previous and next siblings of the item
// are text nodes wrapped in anonymous flex items, the adjacent text nodes
// need to be merged into the same flex item.
LayoutObject* prev = remove_child->PreviousSibling();
if (!prev || !prev->IsAnonymousBlock())
return;
LayoutObject* next = remove_child->NextSibling();
if (!next || !next->IsAnonymousBlock())
return;
ToLayoutBoxModelObject(next)->MoveAllChildrenTo(ToLayoutBoxModelObject(prev));
To<LayoutBlockFlow>(next)->DeleteLineBoxTree();
next->Destroy();
}
} // namespace
void LayoutNGFlexibleBox::RemoveChild(LayoutObject* child) {
if (!DocumentBeingDestroyed() &&
!StyleRef().IsDeprecatedFlexboxUsingFlexLayout())
MergeAnonymousFlexItems(child);
LayoutBlock::RemoveChild(child);
}
} // namespace blink
......@@ -25,6 +25,8 @@ class CORE_EXPORT LayoutNGFlexibleBox : public LayoutNGMixin<LayoutBlock> {
const char* GetName() const override { return "LayoutNGFlexibleBox"; }
protected:
void RemoveChild(LayoutObject*) override;
bool IsOfType(LayoutObjectType type) const override {
return type == kLayoutObjectNGFlexibleBox ||
LayoutNGMixin<LayoutBlock>::IsOfType(type);
......
......@@ -1317,8 +1317,6 @@ crbug.com/591099 virtual/layout_ng_flex_box/css3/flexbox/relpos-with-percentage-
### virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/
crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/align-items-004.htm [ Failure ]
crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/align-items-baseline-overflow-non-visible.html [ Failure ]
crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/anonymous-flex-item-001.html [ Failure ]
crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/anonymous-flex-item-003.html [ Failure ]
crbug.com/807497 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/anonymous-flex-item-005.html [ Failure ]
crbug.com/591099 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/flex-basis-010.html [ Failure ]
crbug.com/249112 virtual/layout_ng_flex_box/external/wpt/css/css-flexbox/flex-minimum-height-flex-items-005.xht [ Failure ]
......
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