Bug 447776 – Hang with word-wrap: break-word and width: 0px

with testcase and crashtests
p=smontagu r/sr=roc
This commit is contained in:
Ian Neal 2008-07-27 17:43:07 +01:00
parent 882f519fe4
commit d4c933c660
7 changed files with 72 additions and 25 deletions

View File

@ -1742,32 +1742,38 @@ gfxTextRun::BreakAndMeasureText(PRUint32 aStart, PRUint32 aMaxLength,
}
}
PRBool lineBreakHere = mCharacterGlyphs[i].CanBreakBefore() &&
(!aSuppressInitialBreak || i > aStart);
PRBool hyphenation = haveHyphenation && hyphenBuffer[i - bufferStart];
PRBool wordWrapping = aCanWordWrap && *aBreakPriority <= eWordWrapBreak;
if (lineBreakHere || hyphenation || wordWrapping) {
gfxFloat hyphenatedAdvance = advance;
if (!lineBreakHere && !wordWrapping) {
hyphenatedAdvance += aProvider->GetHyphenWidth();
}
if (lastBreak < 0 || width + hyphenatedAdvance - trimmableAdvance <= aWidth) {
// We can break here.
lastBreak = i;
lastBreakTrimmableChars = trimmableChars;
lastBreakTrimmableAdvance = trimmableAdvance;
lastBreakUsedHyphenation = !lineBreakHere && !wordWrapping;
*aBreakPriority = hyphenation || lineBreakHere ?
eNormalBreak : eWordWrapBreak;
}
// There can't be a word-wrap break opportunity at the beginning of the
// line: if the width is too small for even one character to fit, it
// could be the first and last break opportunity on the line, and that
// would trigger an infinite loop.
if (!aSuppressInitialBreak || i > aStart) {
PRBool lineBreakHere = mCharacterGlyphs[i].CanBreakBefore();
PRBool hyphenation = haveHyphenation && hyphenBuffer[i - bufferStart];
PRBool wordWrapping = aCanWordWrap && *aBreakPriority <= eWordWrapBreak;
width += advance;
advance = 0;
if (width - trimmableAdvance > aWidth) {
// No more text fits. Abort
aborted = PR_TRUE;
break;
if (lineBreakHere || hyphenation || wordWrapping) {
gfxFloat hyphenatedAdvance = advance;
if (!lineBreakHere && !wordWrapping) {
hyphenatedAdvance += aProvider->GetHyphenWidth();
}
if (lastBreak < 0 || width + hyphenatedAdvance - trimmableAdvance <= aWidth) {
// We can break here.
lastBreak = i;
lastBreakTrimmableChars = trimmableChars;
lastBreakTrimmableAdvance = trimmableAdvance;
lastBreakUsedHyphenation = !lineBreakHere && !wordWrapping;
*aBreakPriority = hyphenation || lineBreakHere ?
eNormalBreak : eWordWrapBreak;
}
width += advance;
advance = 0;
if (width - trimmableAdvance > aWidth) {
// No more text fits. Abort
aborted = PR_TRUE;
break;
}
}
}

View File

@ -11,6 +11,7 @@ random-if(MOZ_WIDGET_TOOLKIT=="gtk2") == wordwrap-03.html wordwrap-03-ref.html #
== wordwrap-04.html wordwrap-04-ref.html
== wordwrap-05.html wordwrap-05-ref.html
== wordwrap-06.html wordwrap-06-ref.html
== wordwrap-07.html wordwrap-07-ref.html
== zwnj-01.html zwnj-01-ref.html
== zwnj-02.html zwnj-02-ref.html
random-if(MOZ_WIDGET_TOOLKIT=="gtk2") != zwnj-01.html zwnj-02-ref.html # Bad fonts on the tinderbox -- works locally

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Test Wordwrap</title>
</head>
<body>
<div><em>H<br>e<br>l<br>l<br>o</em><br>K<br>i<br>t<br>t<br>y</div>
</body>
</html>

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
div { width: 0px; word-wrap: break-word; }
</style>
<title>Test Wordwrap</title>
</head>
<body>
<div><em>Hello</em>Kitty</div>
</body>
</html>

View File

@ -0,0 +1,7 @@
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Hang with zero width and word-wrap</title>
</head><body>
<div style="width: 0px; word-wrap: break-word;">abc</div>
</body></html>

View File

@ -0,0 +1,8 @@
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Hang with -moz-column-count and word-wrap</title>
</head><body>
<div style="border: 1px solid black; word-wrap: normal; -moz-column-count: 2; width: 110px;">
a<span style="word-wrap: break-word;">abcde</span>
</div>
</body></html>

View File

@ -16,3 +16,5 @@ load 437170-1.html
skip load 439184-1.html # skip until we figure out how to test this
load 444237-1.html
load 444848-1.html
load 447776-1.html
load 447783-1.html