Commit d1e2bc0e authored by hyunjune's avatar hyunjune Committed by Commit Bot

Fix up a crash relied on LineBreaker

This patch fixes up a crash relied on line break with 'white-space'.
Because After HandleOverflow is called, the current style is changed
into |HandleOverflow|. So When |TextBreak|'s result is Overflow,
this patch restores the current style as the old current style.

Bug: 999863
Change-Id: I787d80abac66599671fd6cb19cb19eebb2110852
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1806616Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Hyunjune Kim <hyunjune.kim@samsung.com>
Cr-Commit-Position: refs/heads/master@{#700090}
parent 5c01ffe8
...@@ -1642,6 +1642,7 @@ void NGLineBreaker::HandleOverflow(NGLineInfo* line_info) { ...@@ -1642,6 +1642,7 @@ void NGLineBreaker::HandleOverflow(NGLineInfo* line_info) {
// must not be at the end. // must not be at the end.
LayoutUnit item_available_width = LayoutUnit item_available_width =
std::min(-width_to_rewind, item_result->inline_size - 1); std::min(-width_to_rewind, item_result->inline_size - 1);
auto was_current_style = current_style_;
SetCurrentStyle(*item.Style()); SetCurrentStyle(*item.Style());
BreakResult break_result = BreakResult break_result =
BreakText(item_result, item, *item.TextShapeResult(), BreakText(item_result, item, *item.TextShapeResult(),
...@@ -1672,6 +1673,8 @@ void NGLineBreaker::HandleOverflow(NGLineInfo* line_info) { ...@@ -1672,6 +1673,8 @@ void NGLineBreaker::HandleOverflow(NGLineInfo* line_info) {
} }
state_ = LineBreakState::kTrailing; state_ = LineBreakState::kTrailing;
return; return;
} else {
SetCurrentStyle(*was_current_style);
} }
position_maybe_changed = true; position_maybe_changed = true;
} }
......
<!doctype html>
<html>
<head>
<title>pre(white-space's one of values) crash if there is no available width</title>
<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=999863">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>test(()=>{})</script>
</head>
<body>
abc<b style="margin-left: 100%; white-space: pre;">def</b>
<div>
<li>
<a href="dummy">success if does not crash</a>
</li>
</div>
</body>
</html>
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