Commit 9b1b174a authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Make NGBoxFragmentPainter::PaintInlineItems() to support kGeneratedText

This patch makes |NGBoxFragmentPainter::PaintInlineItems()| to support
|kGeneratedText|, e.g. ellispsis, soft hyphen, for preperation of migration
of |NGFragmentItem|.

This patch is follow-up of the patch[1] which constructs |kGeneratedText| type
fragment. Before the patch[1], we construct |kText| fragment item even if it
is generated text type in |NGPhysicalTextFragment|.


[1] http://crrev.com/c/1905045 Make ComputeNGCaretPosition() not to get Bidi
level for layout generated text

Bug: 982194
Change-Id: I4e3eaedc7f22756923a4b9763e8c727a2dc531cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1910987
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715073}
parent 6b4ea4f3
......@@ -186,6 +186,10 @@ NGTextFragmentPaintInfo NGFragmentItem::TextPaintInfo(
return {items.Text(UsesFirstLineStyle()), text_.start_offset,
text_.end_offset, text_.shape_result.get()};
}
if (Type() == kGeneratedText) {
return {generated_text_.text, 0, generated_text_.text.length(),
generated_text_.shape_result.get()};
}
NOTREACHED();
return {};
}
......
......@@ -244,8 +244,12 @@ class CORE_EXPORT NGFragmentItem : public DisplayItemClient {
// Functions for |TextItem| and |GeneratedTextItem|
using NGTextType = NGPhysicalTextFragment::NGTextType;
NGTextType TextType() const {
DCHECK_EQ(Type(), kText);
return static_cast<NGTextType>(sub_type_);
if (Type() == kText)
return static_cast<NGTextType>(sub_type_);
if (Type() == kGeneratedText)
return NGTextType::kGeneratedText;
NOTREACHED() << this;
return NGTextType::kNormalText;
}
// True if this is a forced line break.
......
......@@ -1039,10 +1039,8 @@ void NGBoxFragmentPainter::PaintInlineItems(
DCHECK(item);
switch (item->Type()) {
case NGFragmentItem::kText:
PaintTextItem(cursor, paint_info, paint_offset);
break;
case NGFragmentItem::kGeneratedText:
// TODO(kojii): Implement.
PaintTextItem(cursor, paint_info, paint_offset);
break;
case NGFragmentItem::kLine:
if (PaintLineBoxItem(*item, paint_info, paint_offset) ==
......@@ -1272,7 +1270,7 @@ void NGBoxFragmentPainter::PaintTextItem(const NGInlineCursor& cursor,
const PhysicalOffset& paint_offset) {
DCHECK(cursor.CurrentItem());
const NGFragmentItem& item = *cursor.CurrentItem();
DCHECK_EQ(item.Type(), NGFragmentItem::kText);
DCHECK(cursor.IsText()) << item;
DCHECK(items_);
// Only paint during the foreground/selection phases.
......
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