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