Commit 038c592e authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Fix invalid DCHECK in LayoutBox::GetCachedLayoutResult

Sometimes we may need to retrieve |NGLayoutResult| after its
|WillBeDestroyed| is called.
1. |LayoutBox::WillBeDestroyed| marks its cached
   |NGLayoutResult| as |WillBeDestroyed|.
2. |LayoutObject::WillBeDestroyed| clears its children by
   |DestroyLeftoverChildren|.
3. One of its descendant calls |SetNeedsLayout|.
4. In determining the container chain to mark dirty,
   |GetCachedLayoutResult| is needed to know if
   |ObjectIsRelayoutBoundary|.

There will be rooms to improve, such as:
* |DestroyLeftoverChildren| after |WillBeDestroyed| of its
  subclasses look dangerous. |LayoutBlockFlow| calls
  |DestroyLeftoverChildren| probably to prevent this.
* We can probalby stop marking objects that are
  |BeingDestroyed|, though knowing exactly where may not be
  easy.
but these changes are likely risky. This patch simply allows
retrieving |GetCachedLayoutResult| if |BeingDestroyed|.

Bug: 1091188
Change-Id: I966e1c6e7844fed795eadeb775b520bbd239e56a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2230562
Auto-Submit: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775181}
parent 7ab0e899
......@@ -2655,7 +2655,7 @@ const NGLayoutResult* LayoutBox::GetCachedLayoutResult() const {
const NGLayoutResult* result = layout_results_[0].get();
if (result->IsSingleUse())
return nullptr;
DCHECK(result->PhysicalFragment().IsAlive());
DCHECK(result->PhysicalFragment().IsAlive() || BeingDestroyed());
DCHECK_EQ(layout_results_.size(), 1u);
return result;
}
......
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