Bug 1684497 - Hoist ResetGlyphRuns out of the conditional statement. r=heycam
authorJonathan Kew <jkew@mozilla.com>
Tue, 05 Jan 2021 21:53:40 +0000
changeset 562186 e202f996ca42da4e343446bbb7e5b8dbbf7f3ac7
parent 562185 7151cfdc78ba55efee78d43852093d1d5b587249
child 562187 958d142c083c70c4eb74eb833d01aeaea4159bbe
push id38083
push usercsabou@mozilla.com
push dateThu, 07 Jan 2021 04:07:15 +0000
treeherdermozilla-central@958d142c083c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1684497
milestone86.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 1684497 - Hoist ResetGlyphRuns out of the conditional statement. r=heycam This matches how it's done at the other callsite. (Also add an assertion that would've caught the omission sooner.) Differential Revision: https://phabricator.services.mozilla.com/D100779
layout/generic/MathMLTextRunFactory.cpp
layout/generic/nsTextRunTransformations.cpp
--- a/layout/generic/MathMLTextRunFactory.cpp
+++ b/layout/generic/MathMLTextRunFactory.cpp
@@ -673,24 +673,24 @@ void MathMLTextRunFactory::RebuildTextRu
   NS_ASSERTION(convertedString.Length() == canBreakBeforeArray.Length(),
                "Dropped characters or break-before values somewhere!");
   Range range(0, uint32_t(canBreakBeforeArray.Length()));
   child->SetPotentialLineBreaks(range, canBreakBeforeArray.Elements());
   if (transformedChild) {
     transformedChild->FinishSettingProperties(aRefDrawTarget, aMFR);
   }
 
+  aTextRun->ResetGlyphRuns();
   if (mergeNeeded) {
     // Now merge multiple characters into one multi-glyph character as required
     NS_ASSERTION(charsToMergeArray.Length() == child->GetLength(),
                  "source length mismatch");
     NS_ASSERTION(deletedCharsArray.Length() == aTextRun->GetLength(),
                  "destination length mismatch");
     MergeCharactersInTextRun(aTextRun, child, charsToMergeArray.Elements(),
                              deletedCharsArray.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.
-    aTextRun->ResetGlyphRuns();
     aTextRun->CopyGlyphDataFrom(child, Range(child), 0);
   }
 }
--- a/layout/generic/nsTextRunTransformations.cpp
+++ b/layout/generic/nsTextRunTransformations.cpp
@@ -118,16 +118,17 @@ nsTransformingTextRunFactory::MakeTextRu
   return MakeTextRun(unicodeString.get(), aLength, aParams, aFontGroup,
                      aFlags & ~gfx::ShapedTextFlags::TEXT_IS_8BIT, aFlags2,
                      std::move(aStyles), aOwnsFactory);
 }
 
 void MergeCharactersInTextRun(gfxTextRun* aDest, gfxTextRun* aSrc,
                               const bool* aCharsToMerge,
                               const bool* aDeletedChars) {
+  MOZ_ASSERT(!aDest->TrailingGlyphRun(), "unexpected glyphRuns in aDest!");
   gfxTextRun::GlyphRunIterator iter(aSrc, gfxTextRun::Range(aSrc));
   uint32_t offset = 0;
   AutoTArray<gfxTextRun::DetailedGlyph, 2> glyphs;
   const gfxTextRun::CompressedGlyph continuationGlyph =
       gfxTextRun::CompressedGlyph::MakeComplex(false, false);
   const gfxTextRun::CompressedGlyph* srcGlyphs = aSrc->GetCharacterGlyphs();
   gfxTextRun::CompressedGlyph* destGlyphs = aDest->GetCharacterGlyphs();
   while (iter.NextRun()) {