Commit 2cb81412 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[FragmentItem] Fix PaintControllerPaintTest.InlineRelayout

This patch fixes |PaintControllerPaintTest.InlineRelayout|
when FragmentItem is enabled.

FragmentItem uses fragment id for inline fragments. This
patch changes the test to support fragment id to support
FragmentItem.

Bug: 982194
Change-Id: I6a554f6c951bdde7707b868319515f5ec366ee5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2237567
Commit-Queue: Koji Ishii <kojii@chromium.org>
Auto-Submit: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776636}
parent 3ed4bc6a
......@@ -462,6 +462,13 @@ const DisplayItemClient* NGInlineCursorPosition::GetDisplayItemClient() const {
return nullptr;
}
wtf_size_t NGInlineCursorPosition::FragmentId() const {
if (paint_fragment_)
return 0;
DCHECK(item_);
return item_->FragmentId();
}
const NGInlineBreakToken* NGInlineCursorPosition::InlineBreakToken() const {
DCHECK(IsLineBox());
if (paint_fragment_) {
......
......@@ -110,6 +110,7 @@ class CORE_EXPORT NGInlineCursorPosition {
LayoutObject* GetMutableLayoutObject() const;
const Node* GetNode() const;
const DisplayItemClient* GetDisplayItemClient() const;
wtf_size_t FragmentId() const;
// True if fragment at the current position can have children.
bool CanHaveChildren() const;
......
......@@ -60,16 +60,19 @@ TEST_P(PaintControllerPaintTest, InlineRelayout) {
*To<LayoutBlock>(GetDocument().body()->firstChild()->GetLayoutObject());
LayoutText& text = *ToLayoutText(div_block.FirstChild());
const DisplayItemClient* first_text_box = text.FirstTextBox();
wtf_size_t first_text_box_fragment_id = 0;
if (text.IsInLayoutNGInlineFormattingContext()) {
NGInlineCursor cursor;
cursor.MoveTo(text);
first_text_box = cursor.Current().GetDisplayItemClient();
first_text_box_fragment_id = cursor.Current().FragmentId();
}
EXPECT_THAT(RootPaintController().GetDisplayItemList(),
ElementsAre(IsSameId(&ViewScrollingBackgroundClient(),
kDocumentBackgroundType),
IsSameId(first_text_box, kForegroundType)));
IsSameId(first_text_box, kForegroundType,
first_text_box_fragment_id)));
div.setAttribute(html_names::kStyleAttr, "width: 10px; height: 200px");
UpdateAllLifecyclePhasesForTest();
......@@ -77,6 +80,7 @@ TEST_P(PaintControllerPaintTest, InlineRelayout) {
LayoutText& new_text = *ToLayoutText(div_block.FirstChild());
const DisplayItemClient* new_first_text_box = text.FirstTextBox();
const DisplayItemClient* second_text_box = nullptr;
wtf_size_t second_text_box_fragment_id = 0;
if (!text.IsInLayoutNGInlineFormattingContext()) {
second_text_box = new_text.FirstTextBox()->NextForSameLayoutObject();
} else {
......@@ -85,13 +89,16 @@ TEST_P(PaintControllerPaintTest, InlineRelayout) {
new_first_text_box = cursor.Current().GetDisplayItemClient();
cursor.MoveToNextForSameLayoutObject();
second_text_box = cursor.Current().GetDisplayItemClient();
second_text_box_fragment_id = cursor.Current().FragmentId();
}
EXPECT_THAT(RootPaintController().GetDisplayItemList(),
ElementsAre(IsSameId(&ViewScrollingBackgroundClient(),
kDocumentBackgroundType),
IsSameId(new_first_text_box, kForegroundType),
IsSameId(second_text_box, kForegroundType)));
IsSameId(new_first_text_box, kForegroundType,
first_text_box_fragment_id),
IsSameId(second_text_box, kForegroundType,
second_text_box_fragment_id)));
}
TEST_P(PaintControllerPaintTest, ChunkIdClientCacheFlag) {
......
......@@ -111,6 +111,9 @@ MATCHER_P(IsSameId, id, "") {
MATCHER_P2(IsSameId, client, type, "") {
return arg.GetId() == DisplayItem::Id(*client, type);
}
MATCHER_P3(IsSameId, client, type, fragment, "") {
return arg.GetId() == DisplayItem::Id(*client, type, fragment);
}
// Matcher for checking paint chunks. Sample usage:
// EXPACT_THAT(paint_controller.PaintChunks(),
......
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