Commit 1de7c2b8 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[FragmentItem] Fix reusing lines of `::first-line`

When `::first-line` state was changed, some lines may be
still reusable, but reusing may put the fragment tree in a
strange state where the block container doesn't think
different text/styles are needed for `::first-line`, but
|NGFragmentItem| may require the style/text for
`::first-line`.

This patch disallows reusing lines from `::first-line` if
new block container does not have different `::first-line`
text/style.

Bug: 1104533
Change-Id: Ieb8745726ea8664480c248bca2ec991813027f11
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2291181
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#787610}
parent 88a86df5
......@@ -36,6 +36,9 @@ class CORE_EXPORT NGFragmentItems {
return items_[0];
}
// Text content for `::first-line`. Available only if `::first-line` has
// different style than non-first-line style.
const String& FirstLineText() const { return first_line_text_content_; }
const String& Text(bool first_line) const {
return UNLIKELY(first_line) ? first_line_text_content_ : text_content_;
}
......
......@@ -156,6 +156,13 @@ NGFragmentItemsBuilder::AddPreviousItems(
DCHECK(node_);
DCHECK(container_builder);
DCHECK(text_content_);
if (UNLIKELY(items.FirstLineText() && !first_line_text_content_)) {
// Don't reuse previous items if they have different `::first-line` style
// but |this| doesn't. Reaching here means that computed style doesn't
// change, but |NGFragmentItem| has wrong |NGStyleVariant|.
return AddPreviousItemsResult();
}
} else {
DCHECK(!container_builder);
DCHECK(!text_content_);
......
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