bf7b1b1
diff -pruN -x '.moz*' -x .deps -x 'thunderbird*' -x '*.mk' -x 'config*' -x dist -x build -x toolkit -x '*o' -x '*a' -x '*html' -x 'firefox*' mozilla.orig/layout/generic/nsTextFrame.cpp mozilla/layout/generic/nsTextFrame.cpp
bf7b1b1
--- mozilla.orig/layout/generic/nsTextFrame.cpp	2006-12-20 12:15:38.000000000 +0900
bf7b1b1
+++ mozilla/layout/generic/nsTextFrame.cpp	2006-12-20 21:29:39.000000000 +0900
bf7b1b1
@@ -2973,15 +2973,16 @@ nsTextFrame::RenderString(nsIRenderingCo
bf7b1b1
 
bf7b1b1
   nsIFontMetrics* lastFont = aTextStyle.mLastFont;
bf7b1b1
   PRInt32 pendingCount;
bf7b1b1
-  PRUnichar* runStart = bp;
bf7b1b1
+  PRUnichar* runStart = bp, *top = aBuffer;
bf7b1b1
   nscoord charWidth, width = 0;
bf7b1b1
   PRInt32 countSoFar = 0;
bf7b1b1
+  PRUint32 offset;
bf7b1b1
   // Save the color we want to use for the text, since calls to
bf7b1b1
   // PaintTextDecorations in this method will call SetColor() on the rendering
bf7b1b1
   // context.
bf7b1b1
   nscolor textColor;
bf7b1b1
   aRenderingContext.GetColor(textColor);
bf7b1b1
-  for (; --aLength >= 0; aBuffer++) {
bf7b1b1
+  for (offset = 0; offset < aLength; aBuffer++, offset++) {
bf7b1b1
     nsIFontMetrics* nextFont;
bf7b1b1
     nscoord glyphWidth = 0;
bf7b1b1
     PRUnichar ch = *aBuffer;
bf7b1b1
@@ -3038,7 +3039,7 @@ nsTextFrame::RenderString(nsIRenderingCo
bf7b1b1
     else if (ch == ' ') {
bf7b1b1
       glyphWidth += aTextStyle.mSpaceWidth + aTextStyle.mWordSpacing + aTextStyle.mLetterSpacing;
bf7b1b1
     }
bf7b1b1
-    else if (IS_HIGH_SURROGATE(ch) && aLength > 0 &&
bf7b1b1
+    else if (IS_HIGH_SURROGATE(ch) && (offset + 1) < aLength &&
bf7b1b1
            IS_LOW_SURROGATE(*(aBuffer+1))) {
bf7b1b1
       
bf7b1b1
       // special handling for surrogate pair
bf7b1b1
@@ -3046,7 +3047,7 @@ nsTextFrame::RenderString(nsIRenderingCo
bf7b1b1
       glyphWidth += charWidth + aTextStyle.mLetterSpacing;
bf7b1b1
       // copy the surrogate low
bf7b1b1
       *bp++ = ch;
bf7b1b1
-      --aLength;
bf7b1b1
+      offset++;
bf7b1b1
       aBuffer++;
bf7b1b1
       ch = *aBuffer;
bf7b1b1
       // put the width into the space buffer
bf7b1b1
@@ -3058,10 +3059,10 @@ nsTextFrame::RenderString(nsIRenderingCo
bf7b1b1
       glyphWidth = 0;
bf7b1b1
     }
bf7b1b1
     else {
bf7b1b1
-      aRenderingContext.GetWidth(ch, charWidth);
bf7b1b1
+      aRenderingContext.GetRangeWidth(top, aLength, offset, offset + 1, (PRUint32&)charWidth);
bf7b1b1
       glyphWidth += charWidth + aTextStyle.mLetterSpacing;
bf7b1b1
     }
bf7b1b1
-    if (justifying && (!isEndOfLine || aLength > 0)
bf7b1b1
+    if (justifying && (!isEndOfLine || (offset + 1) < aLength)
bf7b1b1
         && IsJustifiableCharacter(ch, isCJ)) {
bf7b1b1
       glyphWidth += aTextStyle.mExtraSpacePerJustifiableCharacter;
bf7b1b1
       if ((PRUint32)--aTextStyle.mNumJustifiableCharacterToRender