Commit 3351035f authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[LayoutNG] Fix crash in LayoutNGListMarker::TextAlternative

This patch fixes LayoutNGListMarker::TextAlternative to not
to rely on it has LayoutText child. This can happen if the
list marker is an image marker (for bullet lists) or the
function was called before layout completes.

LayoutListMarker always computes from its list item. LayoutNG
took a shortcut because we store the result in its LayoutText
child, but cases where we don't store was missed.

AXLayoutObject::TextAlternative() calls this function.

Bug: 894691
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I6c13c6f00920702e17188858d15c674d38698dfb
Reviewed-on: https://chromium-review.googlesource.com/c/1277132
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Reviewed-by: default avatarcathie chen <cathiechen@tencent.com>
Cr-Commit-Position: refs/heads/master@{#599327}
parent 262ece47
...@@ -247,6 +247,12 @@ LayoutNGListItem::MarkerType LayoutNGListItem::MarkerText( ...@@ -247,6 +247,12 @@ LayoutNGListItem::MarkerType LayoutNGListItem::MarkerText(
return kStatic; return kStatic;
} }
String LayoutNGListItem::MarkerTextWithSuffix() const {
StringBuilder text;
MarkerText(&text, kWithSuffix);
return text.ToString();
}
String LayoutNGListItem::MarkerTextWithoutSuffix() const { String LayoutNGListItem::MarkerTextWithoutSuffix() const {
StringBuilder text; StringBuilder text;
MarkerText(&text, kWithoutSuffix); MarkerText(&text, kWithoutSuffix);
......
...@@ -19,6 +19,7 @@ class CORE_EXPORT LayoutNGListItem final : public LayoutNGBlockFlow { ...@@ -19,6 +19,7 @@ class CORE_EXPORT LayoutNGListItem final : public LayoutNGBlockFlow {
ListItemOrdinal& Ordinal() { return ordinal_; } ListItemOrdinal& Ordinal() { return ordinal_; }
int Value() const; int Value() const;
String MarkerTextWithSuffix() const;
String MarkerTextWithoutSuffix() const; String MarkerTextWithoutSuffix() const;
LayoutObject* Marker() const { return marker_; } LayoutObject* Marker() const { return marker_; }
......
...@@ -66,7 +66,11 @@ LayoutObject* LayoutNGListMarker::SymbolMarkerLayoutText() const { ...@@ -66,7 +66,11 @@ LayoutObject* LayoutNGListMarker::SymbolMarkerLayoutText() const {
} }
String LayoutNGListMarker::TextAlternative() const { String LayoutNGListMarker::TextAlternative() const {
return ToLayoutText(FirstChild())->GetText(); // Compute from the list item, in the logical order even in RTL, reflecting
// speech order.
if (LayoutNGListItem* list_item = ListItem())
return list_item->MarkerTextWithSuffix();
return g_empty_string;
} }
bool LayoutNGListMarker::NeedsOccupyWholeLine() const { bool LayoutNGListMarker::NeedsOccupyWholeLine() const {
......
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