Bug 1319424 - Ensure to setup line breaker before using it. r=jfkthame

MozReview-Commit-ID: EOuPLXTIBcZ

--HG--
extra : rebase_source : 166719397abf9ba8ca4e5bf9d187f2c7783981b3
This commit is contained in:
Xidorn Quan 2016-11-25 16:19:32 +11:00
Родитель 6d8fc9f0d5
Коммит c3010f1b3e
4 изменённых файлов: 57 добавлений и 13 удалений

Просмотреть файл

@ -2064,19 +2064,6 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
(mLineContainer->StyleText()->mTextAlign == NS_STYLE_TEXT_ALIGN_JUSTIFY ||
mLineContainer->StyleText()->mTextAlignLast == NS_STYLE_TEXT_ALIGN_JUSTIFY);
// for word-break style
switch (mLineContainer->StyleText()->mWordBreak) {
case NS_STYLE_WORDBREAK_BREAK_ALL:
mLineBreaker.SetWordBreak(nsILineBreaker::kWordBreak_BreakAll);
break;
case NS_STYLE_WORDBREAK_KEEP_ALL:
mLineBreaker.SetWordBreak(nsILineBreaker::kWordBreak_KeepAll);
break;
default:
mLineBreaker.SetWordBreak(nsILineBreaker::kWordBreak_Normal);
break;
}
const nsStyleText* textStyle = nullptr;
const nsStyleFont* fontStyle = nullptr;
nsStyleContext* lastStyleContext = nullptr;
@ -2555,6 +2542,19 @@ void
BuildTextRunsScanner::SetupBreakSinksForTextRun(gfxTextRun* aTextRun,
const void* aTextPtr)
{
// for word-break style
switch (mLineContainer->StyleText()->mWordBreak) {
case NS_STYLE_WORDBREAK_BREAK_ALL:
mLineBreaker.SetWordBreak(nsILineBreaker::kWordBreak_BreakAll);
break;
case NS_STYLE_WORDBREAK_KEEP_ALL:
mLineBreaker.SetWordBreak(nsILineBreaker::kWordBreak_KeepAll);
break;
default:
mLineBreaker.SetWordBreak(nsILineBreaker::kWordBreak_Normal);
break;
}
// textruns have uniform language
const nsStyleFont *styleFont = mMappedFlows[0].mStartFrame->StyleFont();
// We should only use a language for hyphenation if it was specified

Просмотреть файл

@ -122,6 +122,7 @@ HTTP(..) == wordbreak-7a.html wordbreak-7a-ref.html
fails HTTP(..) == wordbreak-7b.html wordbreak-7b-ref.html # bug 479829
== wordbreak-8.html wordbreak-8-ref.html
pref(gfx.font_rendering.graphite.enabled,true) HTTP(..) == wordbreak-9.html wordbreak-9-ref.html
== wordbreak-dynamic-1.html wordbreak-dynamic-1-ref.html
== wordwrap-01.html wordwrap-01-ref.html
HTTP(..) == wordwrap-02.html wordwrap-02-ref.html
fuzzy-if(gtkWidget,1,177) fuzzy-if(skiaContent,1,50) HTTP(..) == wordwrap-03.html wordwrap-03-ref.html # Fuzzy on Linux because the native textbox gradient is painted in a slightly different position depending on the invalid area.

Просмотреть файл

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Reference - word-break: break-all with dynamic change</title>
<style>
div {
font-family: monospace;
width: 3ch;
background: pink;
word-break: break-all;
}
</style>
</head>
<body>
<div>a bcdef</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<meta charset="UTF-8">
<title>Test - word-break: break-all with dynamic change</title>
<style>
div {
font-family: monospace;
width: 3ch;
background: pink;
word-break: break-all;
}
</style>
</head>
<body>
<div>a bcdef<div></div></div>
<script>
document.addEventListener("DOMContentLoaded", function() {
document.body.offsetHeight;
document.querySelector('div > div').style.display = 'none';
document.documentElement.classList.remove('reftest-wait');
});
</script>
</body>
</html>