Skip to content

Commit

Permalink
[LayoutNG] Fix crash for very long line with break-word
Browse files Browse the repository at this point in the history
This patch fixes NGLineBreaker crash when handling a very
long line.

Because line breaker determines overflow by the position
being larger than the available width, it cannot stop if the
available width is |LayoutUnit::Max()|. This patch clamps the
available width by |LayoutUnit::NearlyMax()| to prevent that.

The `word-wrap: break-word` is not necessary to cause the
failure, but it makes things worse by setting |ShapeResult|
to |nullptr| when overflow occurs for the performance reason.

This patch also changes |BreakText| to return whether the
overflow occurred or not, rather than callers to determine it
from the position. Doing so helps clearer communication with
the callers.

Bug: 961987
Change-Id: I17eb758aca8b9b6d3e2f328e5b1b49acb83c0a5e
  • Loading branch information
kojiishi authored and chromium-wpt-export-bot committed May 17, 2019
1 parent fd251c5 commit 15184fd
Showing 1 changed file with 28 additions and 0 deletions.
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<title>CSS Text Test: very long line with `overflow-wrap: break-word` should not crash</title>
<link rel="help" href="https://crbug.com/961987">
<link rel="author" title="Koji Ishii" href="kojii@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
html, body {
margin: 0;
}
body {
overflow-wrap: break-word;
width: 2147483648px;
}
div {
/* Double the width in case CSS parser clamps the body width. */
width: 200%;
}
span {
border-left: 2147483648px solid;
}
</style>
<body>
<div><span>x</span></div>
<script>
test(() => { document.body.offsetTop; });
</script>
</body>

0 comments on commit 15184fd

Please sign in to comment.