Bug 1308502 - Allow line-break even within a cluster if the preceding character (i.e. base of cluster) is a space. r=m_kato

This commit is contained in:
Jonathan Kew 2016-10-11 13:47:11 +01:00
parent 0844b5ebc4
commit 175dc497d0
2 changed files with 16 additions and 11 deletions

View File

@ -217,16 +217,21 @@ gfxTextRun::SetPotentialLineBreaks(Range aRange, uint8_t *aBreakBefore)
NS_ASSERTION(aRange.end <= GetLength(), "Overflow");
uint32_t changed = 0;
uint32_t i;
CompressedGlyph *charGlyphs = mCharacterGlyphs + aRange.start;
for (i = 0; i < aRange.Length(); ++i) {
uint8_t canBreak = aBreakBefore[i];
if (canBreak && !charGlyphs[i].IsClusterStart()) {
// This can happen ... there is no guarantee that our linebreaking rules
// align with the platform's idea of what constitutes a cluster.
canBreak = CompressedGlyph::FLAG_BREAK_TYPE_NONE;
CompressedGlyph* cg = mCharacterGlyphs + aRange.start;
const CompressedGlyph* const end = cg + aRange.Length();
while (cg < end) {
uint8_t canBreak = *aBreakBefore++;
if (canBreak && !cg->IsClusterStart()) {
// XXX If we replace the line-breaker with one based more closely
// on UAX#14 (e.g. using ICU), this may not be needed any more.
// Avoid possible breaks inside a cluster, EXCEPT when the previous
// character was a space (compare UAX#14 rules LB9, LB10).
if (cg == mCharacterGlyphs || !(cg - 1)->CharIsSpace()) {
canBreak = CompressedGlyph::FLAG_BREAK_TYPE_NONE;
}
}
changed |= charGlyphs[i].SetCanBreakBefore(canBreak);
changed |= cg->SetCanBreakBefore(canBreak);
++cg;
}
return changed != 0;
}

View File

@ -30,8 +30,8 @@ random-if(cocoaWidget) == ja-3.html ja-3-ref.html
skip-if(gtkWidget) == quotationmarks-cjk-1.html quotationmarks-cjk-1-ref.html
== smileys-1.html smileys-1-ref.html
== smileys-2.html smileys-2-ref.html
fails == space-cluster-1.html space-cluster-1-ref.html # bug 1308502
fails == space-cluster-2.html space-cluster-2-ref.html # bug 1308502
== space-cluster-1.html space-cluster-1-ref.html
== space-cluster-2.html space-cluster-2-ref.html
== url-1.html url-1-ref.html
== url-2.html url-2-ref.html
== url-3.html url-3-ref.html