Bug 333659. nsLineBreaker fixes. Not Part Of The Build, used by new-textframe only.
authorroc+@cs.cmu.edu
Thu, 22 Mar 2007 16:45:02 -0700
changeset 13 d3975ca2e484168209c34bf4d84db75f584fe72a
parent 12 39eb219415e499cd69691d5cf89d1a899a5e0eee
child 14 c440979aa01fcb48ded6b6c9d6df8586a15034c6
push idunknown
push userunknown
push dateunknown
bugs333659
milestone1.9a3pre
Bug 333659. nsLineBreaker fixes. Not Part Of The Build, used by new-textframe only.
content/base/src/nsLineBreaker.cpp
--- a/content/base/src/nsLineBreaker.cpp
+++ b/content/base/src/nsLineBreaker.cpp
@@ -80,17 +80,17 @@ nsresult
 nsLineBreaker::FlushCurrentWord()
 {
   nsAutoTArray<PRPackedBool,4000> breakState;
   if (!breakState.AppendElements(mCurrentWord.Length()))
     return NS_ERROR_OUT_OF_MEMORY;
 
   if (!mCurrentWordContainsCJK) {
     // Just set everything internal to "no break"!
-    memset(breakState.Elements(), 0, mCurrentWord.Length());
+    memset(breakState.Elements(), PR_FALSE, mCurrentWord.Length());
   } else {
     nsContentUtils::LineBreaker()->
       GetJISx4051Breaks(mCurrentWord.Elements(), mCurrentWord.Length(), breakState.Elements());
   }
 
   PRUint32 i;
   PRUint32 offset = 0;
   for (i = 0; i < mTextItems.Length(); ++i) {
@@ -100,17 +100,20 @@ nsLineBreaker::FlushCurrentWord()
     if (!(ti->mFlags & BREAK_NONWHITESPACE_BEFORE) && ti->mSinkOffset == 0) {
       breakState[offset] = PR_FALSE;
     }
     if (!(ti->mFlags & BREAK_NONWHITESPACE_INSIDE)) {
       PRUint32 exclude = ti->mSinkOffset == 0 ? 1 : 0;
       memset(breakState.Elements() + offset + exclude, PR_FALSE, ti->mLength - exclude);
     }
 
-    PRUint32 skipSet = i > 0 ? 1 : 0;
+    // Don't set the break state for the first character of the word, because
+    // it was already set correctly earlier and we don't know what the true
+    // value should be.
+    PRUint32 skipSet = i == 0 ? 1 : 0;
     ti->mSink->SetBreaks(ti->mSinkOffset + skipSet, ti->mLength - skipSet,
                          breakState.Elements() + offset + skipSet);
     offset += ti->mLength;
   }
 
   mCurrentWord.Clear();
   mTextItems.Clear();
   mCurrentWordContainsCJK = PR_FALSE;