Bug 849606 r=jwatt
authorRobert Longson <longsonr@gmail.com>
Fri, 22 Mar 2013 10:25:58 +0000
changeset 125917 3550c269a5652b0b0081a9f9afbf8621fec30fc8
parent 125916 3825fdbcec62e4a6d420ff260945a70eee942744
child 125918 55f53541cd6cf2235e7a036496d251a88a7871f8
push id25166
push userlongsonr@gmail.com
push dateFri, 22 Mar 2013 10:26:44 +0000
treeherdermozilla-inbound@3550c269a565 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs849606
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 849606 r=jwatt
layout/svg/nsSVGTextFrame2.cpp
--- a/layout/svg/nsSVGTextFrame2.cpp
+++ b/layout/svg/nsSVGTextFrame2.cpp
@@ -1869,22 +1869,16 @@ TextRenderedRunIterator::Next()
   for (;;) {
     if (mFrameIterator.IsAfterSubtree()) {
       mCurrent = TextRenderedRun();
       return mCurrent;
     }
 
     frame = mFrameIterator.Current();
 
-    // Get the character index for the start of this rendered run, by skipping
-    // any undisplayed characters.
-    if (frame != mCurrent.mFrame) {
-      mFrameStartTextElementCharIndex += mFrameIterator.UndisplayedCharacters();
-      mTextElementCharIndex += mFrameIterator.UndisplayedCharacters();
-    }
     charIndex = mTextElementCharIndex;
 
     // Get the position and rotation of the character that begins this
     // rendered run.
     pt = Root()->mPositions[mTextElementCharIndex].mPosition;
     rotate = Root()->mPositions[mTextElementCharIndex].mAngle;
 
     // Find the end of the rendered run, by looking through the
@@ -1938,16 +1932,17 @@ TextRenderedRunIterator::Next()
     // Update our global character index to move past the characters
     // corresponding to this rendered run.
     mTextElementCharIndex += untrimmedLength;
 
     // If we have moved past the end of the current frame's content, we need to
     // advance to the next frame.
     if (offset + untrimmedLength >= contentEnd) {
       mFrameIterator.Next();
+      mTextElementCharIndex += mFrameIterator.UndisplayedCharacters();
       mFrameStartTextElementCharIndex = mTextElementCharIndex;
     }
 
     if (!mFrameIterator.Current()) {
       if (skip) {
         // That was the last frame, and we skipped this rendered run.  So we
         // have no rendered run to return.
         mCurrent = TextRenderedRun();
@@ -1970,16 +1965,21 @@ TextRenderedRunIterator::Next()
 
 TextRenderedRun
 TextRenderedRunIterator::First()
 {
   if (Root()->mPositions.IsEmpty()) {
     mFrameIterator.Close();
     return TextRenderedRun();
   }
+  // Get the character index for the start of this rendered run, by skipping
+  // any undisplayed characters.
+  mTextElementCharIndex = mFrameIterator.UndisplayedCharacters();
+  mFrameStartTextElementCharIndex = mTextElementCharIndex;
+
   return Next();
 }
 
 // -----------------------------------------------------------------------------
 // CharIterator
 
 /**
  * Iterator for characters within an nsSVGTextFrame2.
@@ -2208,16 +2208,24 @@ private:
   bool NextCharacter();
 
   /**
    * Returns whether the current character matches the filter.
    */
   bool MatchesFilter() const;
 
   /**
+   * If this is the start of a glyph, record it.
+   */
+  void UpdateGlyphStartTextElementCharIndex() {
+    if (!IsOriginalCharSkipped() && IsClusterAndLigatureGroupStart()) {
+      mGlyphStartTextElementCharIndex = mTextElementCharIndex;
+    }
+  }
+  /**
    * The filter to use.
    */
   CharacterFilter mFilter;
 
   /**
    * The iterator for text frames.
    */
   TextFrameIterator mFrameIterator;
@@ -2260,16 +2268,17 @@ CharIterator::CharIterator(nsSVGTextFram
     mTrimmedLength(0),
     mTextElementCharIndex(0),
     mGlyphStartTextElementCharIndex(0)
 {
   if (!AtEnd()) {
     mSkipCharsIterator = TextFrame()->EnsureTextRun(nsTextFrame::eInflated);
     mTextRun = TextFrame()->GetTextRun(nsTextFrame::eInflated);
     mTextElementCharIndex = mFrameIterator.UndisplayedCharacters();
+    UpdateGlyphStartTextElementCharIndex();
     if (!MatchesFilter()) {
       Next();
     }
   }
 }
 
 bool
 CharIterator::Next()
@@ -2472,40 +2481,34 @@ bool
 CharIterator::NextCharacter()
 {
   mTextElementCharIndex++;
 
   // Advance within the current text run.
   mSkipCharsIterator.AdvanceOriginal(1);
   if (mSkipCharsIterator.GetOriginalOffset() < TextFrame()->GetContentEnd()) {
     // We're still within the part of the text run for the current text frame.
-    if (!IsOriginalCharSkipped() && IsClusterAndLigatureGroupStart()) {
-      // If this is the start of a glyph, record it.
-      mGlyphStartTextElementCharIndex = mTextElementCharIndex;
-    }
+    UpdateGlyphStartTextElementCharIndex();
     return true;
   }
 
   // Advance to the next frame.
   mFrameIterator.Next();
 
   // Skip any undisplayed characters.
   mTextElementCharIndex += mFrameIterator.UndisplayedCharacters();
   if (!TextFrame()) {
     // We're at the end.
     mSkipCharsIterator = gfxSkipCharsIterator();
     return false;
   }
 
   mSkipCharsIterator = TextFrame()->EnsureTextRun(nsTextFrame::eInflated);
   mTextRun = TextFrame()->GetTextRun(nsTextFrame::eInflated);
-  if (!IsOriginalCharSkipped() && IsClusterAndLigatureGroupStart()) {
-    // If this is the start of a glyph, record it.
-    mGlyphStartTextElementCharIndex = mTextElementCharIndex;
-  }
+  UpdateGlyphStartTextElementCharIndex();
   return true;
 }
 
 bool
 CharIterator::MatchesFilter() const
 {
   if (mFilter == eOriginal) {
     return true;