Bug 472909. Need to call FinishSettingProperties on nsTranformedTextRuns that we create as parts of other transformed textruns. r=smontagu
authorRobert O'Callahan <robert@ocallahan.org>
Fri, 16 Jan 2009 21:17:46 +1300
changeset 23857 55e7016fb7b2035fef419cbdd55b6659b9c7fb85
parent 23856 f25cd7ccf8c42a62eac82503e6f20e62dfa69dd0
child 23858 79e8e0d200194783a884c72b5e3d868d0604cc8b
push id4759
push userrocallahan@mozilla.com
push dateSat, 17 Jan 2009 09:14:36 +0000
treeherdermozilla-central@7e0d34e958e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmontagu
bugs472909
milestone1.9.2a1pre
Bug 472909. Need to call FinishSettingProperties on nsTranformedTextRuns that we create as parts of other transformed textruns. r=smontagu
layout/generic/nsTextRunTransformations.cpp
layout/generic/nsTextRunTransformations.h
layout/reftests/text-transform/reftest.list
layout/reftests/text-transform/small-caps-1-ref.html
layout/reftests/text-transform/small-caps-1.html
--- a/layout/generic/nsTextRunTransformations.cpp
+++ b/layout/generic/nsTextRunTransformations.cpp
@@ -83,27 +83,27 @@ nsTransformedTextRun::SetPotentialLineBr
   PRBool changed = gfxTextRun::SetPotentialLineBreaks(aStart, aLength,
       aBreakBefore, aRefContext);
   if (changed) {
     mNeedsRebuild = PR_TRUE;
   }
   return changed;
 }
 
-gfxTextRun*
+nsTransformedTextRun*
 nsTransformingTextRunFactory::MakeTextRun(const PRUnichar* aString, PRUint32 aLength,
                                           const gfxTextRunFactory::Parameters* aParams,
                                           gfxFontGroup* aFontGroup, PRUint32 aFlags,
                                           nsStyleContext** aStyles, PRBool aOwnsFactory)
 {
   return nsTransformedTextRun::Create(aParams, this, aFontGroup,
                                       aString, aLength, aFlags, aStyles, aOwnsFactory);
 }
 
-gfxTextRun*
+nsTransformedTextRun*
 nsTransformingTextRunFactory::MakeTextRun(const PRUint8* aString, PRUint32 aLength,
                                           const gfxTextRunFactory::Parameters* aParams,
                                           gfxFontGroup* aFontGroup, PRUint32 aFlags,
                                           nsStyleContext** aStyles, PRBool aOwnsFactory)
 {
   // We'll only have a Unicode code path to minimize the amount of code needed
   // for these rarely used features
   NS_ConvertASCIItoUTF16 unicodeString(reinterpret_cast<const char*>(aString), aLength);
@@ -274,17 +274,17 @@ nsFontVariantTextRunFactory::RebuildText
           isLowercase = ch != ch2 || ch == SZLIG;
         } else {
           // Don't transform the character! I.e., pretend that it's not lowercase
         }
       }
     }
 
     if ((i == length || runIsLowercase != isLowercase) && runStart < i) {
-      nsAutoPtr<gfxTextRun> transformedChild;
+      nsAutoPtr<nsTransformedTextRun> transformedChild;
       gfxTextRunCache::AutoTextRun cachedChild;
       gfxTextRun* child;
 
       if (runIsLowercase) {
         transformedChild = uppercaseFactory.MakeTextRun(str + runStart, i - runStart,
             &innerParams, smallFont, flags, styleArray.Elements(), PR_FALSE);
         child = transformedChild;
       } else {
@@ -296,16 +296,19 @@ nsFontVariantTextRunFactory::RebuildText
       if (!child)
         return;
       // Copy potential linebreaks into child so they're preserved
       // (and also child will be shaped appropriately)
       NS_ASSERTION(canBreakBeforeArray.Length() == i - runStart,
                    "lost some break-before values?");
       child->SetPotentialLineBreaks(0, canBreakBeforeArray.Length(),
           canBreakBeforeArray.Elements(), aRefContext);
+      if (transformedChild) {
+        transformedChild->FinishSettingProperties(aRefContext);
+      }
       aTextRun->CopyGlyphDataFrom(child, 0, child->GetLength(), runStart, PR_FALSE);
 
       runStart = i;
       styleArray.Clear();
       canBreakBeforeArray.Clear();
     }
 
     if (i < length) {
@@ -383,17 +386,17 @@ nsCaseTransformTextRunFactory::RebuildTe
     }
   }
 
   PRUint32 flags;
   gfxTextRunFactory::Parameters innerParams =
       GetParametersForInner(aTextRun, &flags, aRefContext);
   gfxFontGroup* fontGroup = aTextRun->GetFontGroup();
 
-  nsAutoPtr<gfxTextRun> transformedChild;
+  nsAutoPtr<nsTransformedTextRun> transformedChild;
   gfxTextRunCache::AutoTextRun cachedChild;
   gfxTextRun* child;
 
   if (mInnerTransformingTextRunFactory) {
     transformedChild = mInnerTransformingTextRunFactory->MakeTextRun(
         convertedString.BeginReading(), convertedString.Length(),
         &innerParams, fontGroup, flags, styleArray.Elements(), PR_FALSE);
     child = transformedChild.get();
@@ -406,16 +409,19 @@ nsCaseTransformTextRunFactory::RebuildTe
   if (!child)
     return;
   // Copy potential linebreaks into child so they're preserved
   // (and also child will be shaped appropriately)
   NS_ASSERTION(convertedString.Length() == canBreakBeforeArray.Length(),
                "Dropped characters or break-before values somewhere!");
   child->SetPotentialLineBreaks(0, canBreakBeforeArray.Length(),
       canBreakBeforeArray.Elements(), aRefContext);
+  if (transformedChild) {
+    transformedChild->FinishSettingProperties(aRefContext);
+  }
 
   if (extraCharsCount > 0) {
     // Now merge multiple characters into one multi-glyph character as required
     MergeCharactersInTextRun(aTextRun, child, charsToMergeArray.Elements());
   } else {
     // No merging to do, so just copy; this produces a more optimized textrun.
     // We can't steal the data because the child may be cached and stealing
     // the data would break the cache.
--- a/layout/generic/nsTextRunTransformations.h
+++ b/layout/generic/nsTextRunTransformations.h
@@ -43,24 +43,24 @@
 class nsTransformedTextRun;
 class nsStyleContext;
 
 class nsTransformingTextRunFactory {
 public:
   virtual ~nsTransformingTextRunFactory() {}
 
   // Default 8-bit path just transforms to Unicode and takes that path
-  gfxTextRun* MakeTextRun(const PRUint8* aString, PRUint32 aLength,
-                          const gfxFontGroup::Parameters* aParams,
-                          gfxFontGroup* aFontGroup, PRUint32 aFlags,
-                          nsStyleContext** aStyles, PRBool aOwnsFactory = PR_TRUE);
-  gfxTextRun* MakeTextRun(const PRUnichar* aString, PRUint32 aLength,
-                          const gfxFontGroup::Parameters* aParams,
-                          gfxFontGroup* aFontGroup, PRUint32 aFlags,
-                          nsStyleContext** aStyles, PRBool aOwnsFactory = PR_TRUE);
+  nsTransformedTextRun* MakeTextRun(const PRUint8* aString, PRUint32 aLength,
+                                    const gfxFontGroup::Parameters* aParams,
+                                    gfxFontGroup* aFontGroup, PRUint32 aFlags,
+                                    nsStyleContext** aStyles, PRBool aOwnsFactory = PR_TRUE);
+  nsTransformedTextRun* MakeTextRun(const PRUnichar* aString, PRUint32 aLength,
+                                    const gfxFontGroup::Parameters* aParams,
+                                    gfxFontGroup* aFontGroup, PRUint32 aFlags,
+                                    nsStyleContext** aStyles, PRBool aOwnsFactory = PR_TRUE);
 
   virtual void RebuildTextRun(nsTransformedTextRun* aTextRun, gfxContext* aRefContext) = 0;
 };
 
 /**
  * Builds textruns that render their text using a font-variant (i.e.,
  * smallcaps).
  */
--- a/layout/reftests/text-transform/reftest.list
+++ b/layout/reftests/text-transform/reftest.list
@@ -1,6 +1,7 @@
 == capitalize-1.html capitalize-ref.html
 == capitalize-2.html capitalize-ref.html
 == capitalize-3.html capitalize-3-ref.html
 == lowercase-1.html lowercase-ref.html
+== small-caps-1.html small-caps-1-ref.html
 == uppercase-1.html uppercase-ref.html
 == uppercase-szlig-1.html uppercase-szlig-ref.html
new file mode 100644
--- /dev/null
+++ b/layout/reftests/text-transform/small-caps-1-ref.html
@@ -0,0 +1,4 @@
+<!DOCTYPE HTML>
+<html>
+<body style="font-size:100px;">A<span style="font-size:80%">A</span></body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/text-transform/small-caps-1.html
@@ -0,0 +1,4 @@
+<!DOCTYPE HTML>
+<html>
+<body style="font-variant:small-caps; font-size:100px;">Aa</body>
+</html>