mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
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:
parent
882f519fe4
commit
d4c933c660
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
10
layout/reftests/text/wordwrap-07-ref.html
Normal file
10
layout/reftests/text/wordwrap-07-ref.html
Normal 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>
|
13
layout/reftests/text/wordwrap-07.html
Normal file
13
layout/reftests/text/wordwrap-07.html
Normal 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>
|
7
layout/style/crashtests/447776-1.html
Normal file
7
layout/style/crashtests/447776-1.html
Normal 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>
|
8
layout/style/crashtests/447783-1.html
Normal file
8
layout/style/crashtests/447783-1.html
Normal 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>
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user