Commit 7b16dac8 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Fix a crash with <ruby> followed by a TAB

The only callsite of CommitPendingEndOverhang() is
NGLineBreaker::HandleText(), and it is called for NGInlineItem::kControl
for a TAB character as well as NGInlineItem::kText. So,
CommitPendingEndOverhang() should take care of NGInlineItem::kControl.

This CL updates CommitPendingEndOverhang() so that a ruby annotation
text doesn't hang over a TAB character.

This CL also adds a stream printer for blink::NGLineInfo.

Bug: 1138943
Change-Id: I478e93086f449b8e4cda4c8828d34f4111d80ea6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2483739
Auto-Submit: Kent Tamura <tkent@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818369}
parent 41cc9680
......@@ -256,4 +256,14 @@ float NGLineInfo::ComputeWidthInFloat() const {
}
#endif
std::ostream& operator<<(std::ostream& ostream, const NGLineInfo& line_info) {
// Feel free to add more NGLneInfo members.
ostream << "NGLineInfo available_width_=" << line_info.AvailableWidth()
<< " width_=" << line_info.Width() << " Results=[\n";
for (const auto& result : line_info.Results()) {
ostream << "\t" << result.item->ToString() << "\n";
}
return ostream << "]";
}
} // namespace blink
......@@ -298,6 +298,8 @@ class CORE_EXPORT NGLineInfo {
bool is_ruby_text_ = false;
};
std::ostream& operator<<(std::ostream& ostream, const NGLineInfo& line_info);
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_INLINE_NG_INLINE_ITEM_RESULT_H_
......@@ -194,7 +194,9 @@ LayoutUnit CommitPendingEndOverhang(NGLineInfo* line_info) {
if (items->size() < 2U)
return LayoutUnit();
const NGInlineItemResult& text_item = items->back();
DCHECK_EQ(text_item.item->Type(), NGInlineItem::kText);
if (text_item.item->Type() == NGInlineItem::kControl)
return LayoutUnit();
DCHECK(text_item.item->Type() == NGInlineItem::kText);
wtf_size_t i = items->size() - 2;
while ((*items)[i].item->Type() != NGInlineItem::kAtomicInline) {
const auto type = (*items)[i].item->Type();
......
<!DOCTYPE html>
<html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<style>
#container {
width: 10em;
white-space: pre-wrap;
}
</style>
<body>
<div id=container></div>
<script>
test(() => {
const div = document.querySelector('#container');
div.innerHTML = '<ruby>xx<rt>foo bar foo bar foo bar foo bar foo bar</rt></ruby><span>&#9;</span>';
// Force layout.
div.clientHeight;
// Success if CommitPendingEndOverhang() didn't crash in |div.clientHeight|.
}, 'Overhanging ruby followed by a TAB should not crash');
</script>
</body>
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