Back out bug 384836 to diagnose Tp/Tp2 regression bug 385957.
authordbaron@dbaron.org
Tue, 26 Jun 2007 15:16:34 -0700
changeset 2808 59ed7b01ceacc71533bf6f748871cb5cfb963004
parent 2807 cfa34bbb26375ab084505699fdd65ccd7cbe0130
child 2809 b0f9efcfc95d72f706459e0ee64f0bd32882336e
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs384836, 385957
milestone1.9a6pre
Back out bug 384836 to diagnose Tp/Tp2 regression bug 385957.
gfx/thebes/public/gfxFont.h
gfx/thebes/src/gfxFont.cpp
layout/generic/nsTextFrameThebes.cpp
layout/generic/nsTextRunTransformations.cpp
layout/generic/nsTextRunTransformations.h
--- a/gfx/thebes/public/gfxFont.h
+++ b/gfx/thebes/public/gfxFont.h
@@ -584,18 +584,17 @@ public:
      * This can change glyphs and/or geometry! Some textruns' shapes
      * depend on potential line breaks (e.g., title-case-converting textruns).
      * This function is virtual so that those textruns can reshape themselves.
      * 
      * @return true if this changed the linebreaks, false if the new line
      * breaks are the same as the old
      */
     virtual PRBool SetPotentialLineBreaks(PRUint32 aStart, PRUint32 aLength,
-                                          PRPackedBool *aBreakBefore,
-                                          gfxContext *aRefContext);
+                                          PRPackedBool *aBreakBefore);
 
     /**
      * Layout provides PropertyProvider objects. These allow detection of
      * potential line break points and computation of spacing. We pass the data
      * this way to allow lazy data acquisition; for example BreakAndMeasureText
      * will want to only ask for properties of text it's actually looking at.
      * 
      * NOTE that requested spacing may not actually be applied, if the textrun
@@ -715,18 +714,17 @@ public:
      * function is virtual so that gfxTextRun subclasses can reshape
      * properly.
      * 
      * @param aAdvanceWidthDelta if non-null, returns the change in advance
      * width of the given range.
      */
     virtual PRBool SetLineBreaks(PRUint32 aStart, PRUint32 aLength,
                                  PRBool aLineBreakBefore, PRBool aLineBreakAfter,
-                                 gfxFloat *aAdvanceWidthDelta,
-                                 gfxContext *aRefContext);
+                                 gfxFloat *aAdvanceWidthDelta);
 
     /**
      * Finds the longest substring that will fit into the given width.
      * Uses GetHyphenationBreaks and GetSpacing from aBreakProvider.
      * Guarantees the following:
      * -- 0 <= result <= aMaxLength
      * -- result is the maximal value of N such that either
      *       N < aMaxLength && line break at N && GetAdvanceWidth(aStart, N) <= aWidth
--- a/gfx/thebes/src/gfxFont.cpp
+++ b/gfx/thebes/src/gfxFont.cpp
@@ -681,18 +681,17 @@ gfxTextRun::Clone(const gfxTextRunFactor
         return nsnull;
 
     textRun->CopyGlyphDataFrom(this, 0, mCharacterCount, 0, PR_FALSE);
     return textRun.forget();
 }
 
 PRBool
 gfxTextRun::SetPotentialLineBreaks(PRUint32 aStart, PRUint32 aLength,
-                                   PRPackedBool *aBreakBefore,
-                                   gfxContext *aRefContext)
+                                   PRPackedBool *aBreakBefore)
 {
     NS_ASSERTION(aStart + aLength <= mCharacterCount, "Overflow");
 
     if (!mCharacterGlyphs)
         return PR_TRUE;
     PRUint32 changed = 0;
     PRUint32 i;
     for (i = 0; i < aLength; ++i) {
@@ -1412,18 +1411,17 @@ gfxTextRun::GetAdvanceWidth(PRUint32 aSt
     }
 
     return result;
 }
 
 PRBool
 gfxTextRun::SetLineBreaks(PRUint32 aStart, PRUint32 aLength,
                           PRBool aLineBreakBefore, PRBool aLineBreakAfter,
-                          gfxFloat *aAdvanceWidthDelta,
-                          gfxContext *aRefContext)
+                          gfxFloat *aAdvanceWidthDelta)
 {
     // Do nothing because our shaping does not currently take linebreaks into
     // account. There is no change in advance width.
     if (aAdvanceWidthDelta) {
         *aAdvanceWidthDelta = 0;
     }
     return PR_FALSE;
 }
--- a/layout/generic/nsTextFrameThebes.cpp
+++ b/layout/generic/nsTextFrameThebes.cpp
@@ -905,32 +905,30 @@ public:
     nsIFrame*    mAncestorControllingInitialBreak;
     PRInt32      mContentOffset;
     PRInt32      mContentEndOffset;
     PRUint32     mTransformedTextOffset; // Only used inside BuildTextRunForFrames
   };
 
   class BreakSink : public nsILineBreakSink {
   public:
-    BreakSink(gfxTextRun* aTextRun, gfxContext* aContext, PRUint32 aOffsetIntoTextRun,
+    BreakSink(gfxTextRun* aTextRun, PRUint32 aOffsetIntoTextRun,
               PRBool aExistingTextRun) :
-                mTextRun(aTextRun), mContext(aContext),
-                mOffsetIntoTextRun(aOffsetIntoTextRun),
-                mChangedBreaks(PR_FALSE), mExistingTextRun(aExistingTextRun) {}
+                  mTextRun(aTextRun), mOffsetIntoTextRun(aOffsetIntoTextRun),
+                  mChangedBreaks(PR_FALSE), mExistingTextRun(aExistingTextRun) {}
 
     virtual void SetBreaks(PRUint32 aOffset, PRUint32 aLength,
                            PRPackedBool* aBreakBefore) {
       if (mTextRun->SetPotentialLineBreaks(aOffset + mOffsetIntoTextRun, aLength,
-                                           aBreakBefore, mContext)) {
+                                           aBreakBefore)) {
         mChangedBreaks = PR_TRUE;
       }
     }
 
     gfxTextRun*  mTextRun;
-    gfxContext*  mContext;
     PRUint32     mOffsetIntoTextRun;
     PRPackedBool mChangedBreaks;
     PRPackedBool mExistingTextRun;
   };
 
 private:
   nsAutoTArray<MappedFlow,10>   mMappedFlows;
   nsAutoTArray<nsTextFrame*,50> mLineBreakBeforeFrames;
@@ -1803,33 +1801,32 @@ HasCompressedLeadingWhitespace(nsTextFra
     }
     ++frameContentOffset;
   }
   aIterator->SetOriginalOffset(savedOffset);
   return result;
 }
 
 void
-BuildTextRunsScanner::SetupBreakSinksForTextRun(gfxTextRun* aTextRun,
+BuildTextRunsScanner::SetupBreakSinksForTextRun(gfxTextRun* aTextRun, 
                                                 PRBool aIsExistingTextRun,
                                                 PRBool aSuppressSink)
 {
   // textruns have uniform language
   nsIAtom* lang = mMappedFlows[0].mStartFrame->GetStyleVisibility()->mLangGroup;
   // We keep this pointed at the skip-chars data for the current mappedFlow.
   // This lets us cheaply check whether the flow has compressed initial
   // whitespace...
   gfxSkipCharsIterator iter(aTextRun->GetSkipChars());
 
   PRUint32 i;
   for (i = 0; i < mMappedFlows.Length(); ++i) {
     MappedFlow* mappedFlow = &mMappedFlows[i];
     nsAutoPtr<BreakSink>* breakSink = mBreakSinks.AppendElement(
-      new BreakSink(aTextRun, mContext,
-                    mappedFlow->mTransformedTextOffset, aIsExistingTextRun));
+      new BreakSink(aTextRun, mappedFlow->mTransformedTextOffset, aIsExistingTextRun));
     if (!breakSink || !*breakSink)
       return;
     PRUint32 offset = mappedFlow->mTransformedTextOffset;
 
     PRUint32 length =
       (i == mMappedFlows.Length() - 1 ? aTextRun->GetLength()
        : mMappedFlows[i + 1].mTransformedTextOffset)
       - offset;
@@ -5564,22 +5561,20 @@ nsTextFrame::TrimTrailingWhiteSpace(nsPr
     PRInt32 i;
     for (i = justificationEnd.GetOriginalOffset(); i < trimmed.mStart + trimmed.mLength; ++i) {
       if (IsJustifiableCharacter(frag, i, isCJK)) {
         aLastCharIsJustifiable = PR_TRUE;
       }
     }
   }
 
-  gfxContext* ctx = NS_STATIC_CAST(gfxContext*,
-    aRC.GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT));
   gfxFloat advanceDelta;
   mTextRun->SetLineBreaks(trimmedStart, trimmedEnd - trimmedStart,
                           (GetStateBits() & TEXT_START_OF_LINE) != 0, PR_TRUE,
-                          &advanceDelta, ctx);
+                          &advanceDelta);
 
   // aDeltaWidth is *subtracted* from our width.
   // If advanceDelta is positive then setting the line break made us longer,
   // so aDeltaWidth could go negative.
   aDeltaWidth = NSToCoordFloor(delta - advanceDelta);
   // XXX if aDeltaWidth goes negative, that means this frame might not actually fit
   // anymore!!! We need higher level line layout to recover somehow. This can
   // really only happen when we have glyphs with special shapes at the end of
--- a/layout/generic/nsTextRunTransformations.cpp
+++ b/layout/generic/nsTextRunTransformations.cpp
@@ -56,17 +56,18 @@ class nsTransformedTextRun : public gfxT
 public:
   nsTransformedTextRun(const gfxTextRunFactory::Parameters* aParams,
                        nsTransformingTextRunFactory* aFactory,
                        gfxFontGroup* aFontGroup,
                        const PRUnichar* aString, PRUint32 aLength,
                        const PRUint32 aFlags, nsStyleContext** aStyles,
                        PRBool aOwnsFactory)
     : gfxTextRun(aParams, aString, aLength, aFontGroup, aFlags),
-      mFactory(aFactory), mOwnsFactory(aOwnsFactory)
+      mFactory(aFactory), mRefContext(aParams->mContext),
+      mOwnsFactory(aOwnsFactory)
   {
     PRUint32 i;
     for (i = 0; i < aLength; ++i) {
       mStyles.AppendElement(aStyles[i]);
     }
     for (i = 0; i < aParams->mInitialBreakCount; ++i) {
       mLineBreaks.AppendElement(aParams->mInitialBreaks[i]);
     }
@@ -74,40 +75,37 @@ public:
   
   ~nsTransformedTextRun() {
     if (mOwnsFactory) {
       delete mFactory;
     }
   }
 
   virtual PRBool SetPotentialLineBreaks(PRUint32 aStart, PRUint32 aLength,
-                                        PRPackedBool* aBreakBefore,
-                                        gfxContext* aRefContext)
+                                        PRPackedBool* aBreakBefore)
   {
-    PRBool changed = gfxTextRun::SetPotentialLineBreaks(aStart, aLength,
-        aBreakBefore, aRefContext);
-    mFactory->RebuildTextRun(this, aRefContext);
+    PRBool changed = gfxTextRun::SetPotentialLineBreaks(aStart, aLength, aBreakBefore);
+    mFactory->RebuildTextRun(this);
     return changed;
   }
   virtual PRBool SetLineBreaks(PRUint32 aStart, PRUint32 aLength,
                                PRBool aLineBreakBefore, PRBool aLineBreakAfter,
-                               gfxFloat* aAdvanceWidthDelta,
-                               gfxContext* aRefContext);
+                               gfxFloat* aAdvanceWidthDelta);
 
   nsTransformingTextRunFactory       *mFactory;
+  nsRefPtr<gfxContext>                mRefContext;
   nsTArray<PRUint32>                  mLineBreaks;
   nsTArray<nsRefPtr<nsStyleContext> > mStyles;
   PRPackedBool                        mOwnsFactory;
 };
 
 PRBool
 nsTransformedTextRun::SetLineBreaks(PRUint32 aStart, PRUint32 aLength,
                                     PRBool aLineBreakBefore, PRBool aLineBreakAfter,
-                                    gfxFloat* aAdvanceWidthDelta,
-                                    gfxContext* aRefContext)
+                                    gfxFloat* aAdvanceWidthDelta)
 {
   nsTArray<PRUint32> newBreaks;
   PRUint32 i;
   PRBool changed = PR_FALSE;
   for (i = 0; i < mLineBreaks.Length(); ++i) {
     PRUint32 pos = mLineBreaks[i];
     if (pos >= aStart)
       break;
@@ -138,17 +136,17 @@ nsTransformedTextRun::SetLineBreaks(PRUi
     }
     return PR_FALSE;
   }
 
   newBreaks.AppendElements(mLineBreaks.Elements() + i, mLineBreaks.Length() - i);
   mLineBreaks.SwapElements(newBreaks);
 
   gfxFloat currentAdvance = GetAdvanceWidth(aStart, aLength, nsnull);
-  mFactory->RebuildTextRun(this, aRefContext);
+  mFactory->RebuildTextRun(this);
   if (aAdvanceWidthDelta) {
     *aAdvanceWidthDelta = GetAdvanceWidth(aStart, aLength, nsnull) - currentAdvance;
   }
   return PR_TRUE;
 }
 
 gfxTextRun*
 nsTransformingTextRunFactory::MakeTextRun(const PRUnichar* aString, PRUint32 aLength,
@@ -157,17 +155,17 @@ nsTransformingTextRunFactory::MakeTextRu
                                           nsStyleContext** aStyles, PRBool aOwnsFactory)
 {
   nsTransformedTextRun* textRun =
     new nsTransformedTextRun(aParams, this, aFontGroup,
                              aString, aLength, aFlags, aStyles, aOwnsFactory);
   if (!textRun)
     return nsnull;
 
-  RebuildTextRun(textRun, aParams->mContext);
+  RebuildTextRun(textRun);
   return textRun;
 }
 
 gfxTextRun*
 nsTransformingTextRunFactory::MakeTextRun(const PRUint8* aString, PRUint32 aLength,
                                           const gfxTextRunFactory::Parameters* aParams,
                                           gfxFontGroup* aFontGroup, PRUint32 aFlags,
                                           nsStyleContext** aStyles, PRBool aOwnsFactory)
@@ -307,45 +305,42 @@ MergeCharactersInTextRun(gfxTextRun* aDe
       }
       ++offset;
     }
   }
   NS_ASSERTION(offset == aDest->GetLength(), "Bad offset calculations");
 }
 
 static gfxTextRunFactory::Parameters
-GetParametersForInner(nsTransformedTextRun* aTextRun, PRUint32* aFlags,
-    gfxContext* aRefContext)
+GetParametersForInner(nsTransformedTextRun* aTextRun, PRUint32* aFlags)
 {
   gfxTextRunFactory::Parameters params =
-    { aRefContext, nsnull, nsnull,
+    { aTextRun->mRefContext, nsnull, nsnull,
       nsnull, nsnull, PRUint32(aTextRun->GetAppUnitsPerDevUnit())
     };
   *aFlags = aTextRun->GetFlags() & ~gfxFontGroup::TEXT_IS_PERSISTENT;
   return params;
 }
 
 void
-nsFontVariantTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
-    gfxContext* aRefContext)
+nsFontVariantTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun)
 {
   nsICaseConversion* converter = nsTextTransformer::GetCaseConv();
   if (!converter)
     return;
 
   gfxFontGroup* fontGroup = aTextRun->GetFontGroup();
   gfxFontStyle fontStyle = *fontGroup->GetStyle();
   fontStyle.size *= 0.8;
   nsRefPtr<gfxFontGroup> smallFont = fontGroup->Copy(&fontStyle);
   if (!smallFont)
     return;
 
   PRUint32 flags;
-  gfxTextRunFactory::Parameters innerParams =
-      GetParametersForInner(aTextRun, &flags, aRefContext);
+  gfxTextRunFactory::Parameters innerParams = GetParametersForInner(aTextRun, &flags);
   // The text outlives the child and inner textruns
   flags |= gfxFontGroup::TEXT_IS_PERSISTENT;
 
   PRUint32 length = aTextRun->GetLength();
   const PRUnichar* str = aTextRun->GetTextUnicode();
   nsRefPtr<nsStyleContext>* styles = aTextRun->mStyles.Elements();
   // Create a textrun so we can check cluster-start properties
   nsAutoPtr<gfxTextRun> inner;
@@ -404,18 +399,17 @@ nsFontVariantTextRunFactory::RebuildText
             MakeTextRun(str + runStart, i - runStart, &innerParams, flags);
       }
       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);
+      child->SetPotentialLineBreaks(0, canBreakBeforeArray.Length(), canBreakBeforeArray.Elements());
       AppendTextRun(aTextRun, child, runStart);
 
       runStart = i;
       styleArray.Clear();
       canBreakBeforeArray.Clear();
       lineBreakBeforeArray.Clear();
       if (nextLineBreak > 0 && aTextRun->mLineBreaks[nextLineBreak - 1] == i) {
         lineBreakBeforeArray.AppendElement(0);
@@ -428,18 +422,17 @@ nsFontVariantTextRunFactory::RebuildText
       canBreakBeforeArray.AppendElement(aTextRun->CanBreakLineBefore(i));
     }
   }
   NS_ASSERTION(nextLineBreak == aTextRun->mLineBreaks.Length(),
                "lost track of line breaks somehow");
 }
 
 void
-nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
-    gfxContext* aRefContext)
+nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun)
 {
   nsICaseConversion* converter = nsTextTransformer::GetCaseConv();
   if (!converter)
     return;
 
   PRUint32 length = aTextRun->GetLength();
   const PRUnichar* str = aTextRun->GetTextUnicode();
   nsRefPtr<nsStyleContext>* styles = aTextRun->mStyles.Elements();
@@ -509,18 +502,17 @@ nsCaseTransformTextRunFactory::RebuildTe
       aTextRun->mLineBreaks[nextLineBreak] == length) {
     lineBreakBeforeArray.AppendElement(length + extraCharsCount);
     ++nextLineBreak;
   }
   NS_ASSERTION(nextLineBreak == aTextRun->mLineBreaks.Length(),
                "lost track of line breaks somehow");
 
   PRUint32 flags;
-  gfxTextRunFactory::Parameters innerParams =
-      GetParametersForInner(aTextRun, &flags, aRefContext);
+  gfxTextRunFactory::Parameters innerParams = GetParametersForInner(aTextRun, &flags);
   gfxFontGroup* fontGroup = aTextRun->GetFontGroup();
 
   nsAutoPtr<gfxTextRun> child;
   // Setup actual line break data for child (which may affect shaping)
   innerParams.mInitialBreaks = lineBreakBeforeArray.Elements();
   innerParams.mInitialBreakCount = lineBreakBeforeArray.Length();
   // The text outlives 'child'
   flags |= gfxFontGroup::TEXT_IS_PERSISTENT;
@@ -534,13 +526,12 @@ nsCaseTransformTextRunFactory::RebuildTe
         flags);
   }
   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);
+  child->SetPotentialLineBreaks(0, canBreakBeforeArray.Length(), canBreakBeforeArray.Elements());
   // Now merge multiple characters into one multi-glyph character as required
   MergeCharactersInTextRun(aTextRun, child, charsToMergeArray.Elements());
 }
--- a/layout/generic/nsTextRunTransformations.h
+++ b/layout/generic/nsTextRunTransformations.h
@@ -52,26 +52,26 @@ public:
                           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);
 
-  virtual void RebuildTextRun(nsTransformedTextRun* aTextRun, gfxContext* aRefContext) = 0;
+  virtual void RebuildTextRun(nsTransformedTextRun* aTextRun) = 0;
 };
 
 /**
  * Builds textruns that render their text using a font-variant (i.e.,
  * smallcaps).
  */
 class nsFontVariantTextRunFactory : public nsTransformingTextRunFactory {
 public:
-  virtual void RebuildTextRun(nsTransformedTextRun* aTextRun, gfxContext* aRefContext);
+  virtual void RebuildTextRun(nsTransformedTextRun* aTextRun);
 };
 
 /**
  * Builds textruns that transform the text in some way (e.g., capitalize)
  * and then render the text using some other textrun implementation.
  */
 class nsCaseTransformTextRunFactory : public nsTransformingTextRunFactory {
 public:
@@ -82,16 +82,16 @@ public:
   // via the fontgroup.
   
   // Takes ownership of aInnerTransformTextRunFactory
   nsCaseTransformTextRunFactory(nsTransformingTextRunFactory* aInnerTransformingTextRunFactory,
                                 PRBool aAllUppercase = PR_FALSE)
     : mInnerTransformingTextRunFactory(aInnerTransformingTextRunFactory),
       mAllUppercase(aAllUppercase) {}
 
-  virtual void RebuildTextRun(nsTransformedTextRun* aTextRun, gfxContext* aRefContext);
+  virtual void RebuildTextRun(nsTransformedTextRun* aTextRun);
 
 protected:
   nsAutoPtr<nsTransformingTextRunFactory> mInnerTransformingTextRunFactory;
   PRPackedBool                            mAllUppercase;
 };
 
 #endif /*NSTEXTRUNTRANSFORMATIONS_H_*/