Commit f7dbd402 authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Use NGPaintFragment::InlineFragmentsFor() in LayoutText::DetachAbstractInlineTextBoxesIfNeeded()

This patch changes |LayoutText::DetachAbstractInlineTextBoxesIfNeeded()| to
use |NGPaintFragment::InlineFragmentsFor()| instead of |NGInlineCursor|, because
|DetachAbstractInlineTextBoxesIfNeeded()| is called after containg block flow
of |LayoutText| changed, e.g. removing, moving, spliting, etc.

Note: This is experimatal patch because we don't know exact reproduce case.

Note: |NGInlineCursor::MoveTo(LayoutObject)| requires root paint fragment
computed from specified layout object.

Bug: 1040938
Change-Id: I7624a19e66f449182309a29ab0fc4748839d69b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2006837
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732769}
parent 162b5be7
...@@ -283,10 +283,17 @@ void LayoutText::DetachAbstractInlineTextBoxesIfNeeded() { ...@@ -283,10 +283,17 @@ void LayoutText::DetachAbstractInlineTextBoxesIfNeeded() {
// NGAbstractInlineTextBox for them. // NGAbstractInlineTextBox for them.
if (!has_abstract_inline_text_box_) if (!has_abstract_inline_text_box_)
return; return;
has_abstract_inline_text_box_ = false;
if (!RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) {
for (NGPaintFragment* fragment : NGPaintFragment::InlineFragmentsFor(this))
NGAbstractInlineTextBox::WillDestroy(fragment);
return;
}
// TODO(yosin): Make sure we call this function within valid containg block
// of |this|.
NGInlineCursor cursor; NGInlineCursor cursor;
for (cursor.MoveTo(*this); cursor; cursor.MoveToNextForSameLayoutObject()) for (cursor.MoveTo(*this); cursor; cursor.MoveToNextForSameLayoutObject())
NGAbstractInlineTextBox::WillDestroy(cursor); NGAbstractInlineTextBox::WillDestroy(cursor);
has_abstract_inline_text_box_ = false;
} }
void LayoutText::SetFirstInlineFragment(NGPaintFragment* first_fragment) { void LayoutText::SetFirstInlineFragment(NGPaintFragment* first_fragment) {
......
...@@ -101,6 +101,10 @@ void NGAbstractInlineTextBox::WillDestroy(const NGInlineCursor& cursor) { ...@@ -101,6 +101,10 @@ void NGAbstractInlineTextBox::WillDestroy(const NGInlineCursor& cursor) {
NOTREACHED(); NOTREACHED();
} }
void NGAbstractInlineTextBox::WillDestroy(const NGPaintFragment* fragment) {
NGAbstractInlineTextBoxCache<NGPaintFragment>::WillDestroy(fragment);
}
NGAbstractInlineTextBox::NGAbstractInlineTextBox( NGAbstractInlineTextBox::NGAbstractInlineTextBox(
LineLayoutText line_layout_item, LineLayoutText line_layout_item,
const NGPaintFragment& fragment) const NGPaintFragment& fragment)
......
...@@ -22,6 +22,7 @@ class CORE_EXPORT NGAbstractInlineTextBox final : public AbstractInlineTextBox { ...@@ -22,6 +22,7 @@ class CORE_EXPORT NGAbstractInlineTextBox final : public AbstractInlineTextBox {
static scoped_refptr<AbstractInlineTextBox> GetOrCreate( static scoped_refptr<AbstractInlineTextBox> GetOrCreate(
const NGInlineCursor& cursor); const NGInlineCursor& cursor);
static void WillDestroy(const NGInlineCursor& cursor); static void WillDestroy(const NGInlineCursor& cursor);
static void WillDestroy(const NGPaintFragment* fragment);
friend class LayoutText; friend class LayoutText;
......
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