Bug 1308502 - Allow line-break even within a cluster if the preceding character (i.e. base of cluster) is a space. r=m_kato
authorJonathan Kew <jkew@mozilla.com>
Tue, 11 Oct 2016 13:47:11 +0100
changeset 360379 f1b5a733bc5467719caf44bdc18a9318b25c80b3
parent 360378 c99f2fb3dc50e2aae4710aa93674e170ff2a6be7
child 360380 ffcf738fc20023b939afec0ced3be7b209573155
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-beta@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1308502
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1308502 - Allow line-break even within a cluster if the preceding character (i.e. base of cluster) is a space. r=m_kato
gfx/thebes/gfxTextRun.cpp
layout/reftests/line-breaking/reftest.list
--- a/gfx/thebes/gfxTextRun.cpp
+++ b/gfx/thebes/gfxTextRun.cpp
@@ -212,26 +212,31 @@ gfxTextRun::ReleaseFontGroup()
 }
 
 bool
 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;
 }
 
 gfxTextRun::LigatureData
 gfxTextRun::ComputeLigatureData(Range aPartRange,
                                 PropertyProvider *aProvider) const
 {
--- a/layout/reftests/line-breaking/reftest.list
+++ b/layout/reftests/line-breaking/reftest.list
@@ -25,15 +25,15 @@ random-if(cocoaWidget) == ja-3.html ja-3
 == punctuation-open-3.html punctuation-open-3-ref.html
 == punctuation-open-4.html punctuation-open-4-ref.html
 == quotationmarks-1.html quotationmarks-1-ref.html
 # The following is currently disabled on Linux because of a rendering issue with missing-glyph
 # representations on the test boxes. See bug #450088 for discussion.
 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
 == winpath-1.html winpath-1-ref.html
 == zwnbsp-1.html zwnbsp-1-ref.html