Bug 1283106 - Put empty skip chars in gfxPlatform singleton rather than static local variable. r?jfkthame draft
authorXidorn Quan <me@upsuper.org>
Tue, 05 Jul 2016 11:02:24 +1000
changeset 383797 5153a7e824151e95782a5b7fe862f6c4a4d466e4
parent 383780 fcd9b8fb2a5752cc6073a1d974ceeb78588fdba7
child 524550 b7f668a762a5a93414b0bb9bd69e4181d25d6c38
push id22099
push userxquan@mozilla.com
push dateTue, 05 Jul 2016 03:45:30 +0000
reviewersjfkthame
bugs1283106
milestone50.0a1
Bug 1283106 - Put empty skip chars in gfxPlatform singleton rather than static local variable. r?jfkthame MozReview-Commit-ID: 5SU6ewm5wbd
gfx/thebes/gfxPlatform.h
layout/generic/nsTextFrame.cpp
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -11,16 +11,17 @@
 #include "nsTArray.h"
 #include "nsString.h"
 #include "nsCOMPtr.h"
 #include "nsUnicodeScriptCodes.h"
 
 #include "gfxTypes.h"
 #include "gfxFontFamilyList.h"
 #include "gfxBlur.h"
+#include "gfxSkipChars.h"
 #include "nsRect.h"
 
 #include "qcms.h"
 
 #include "mozilla/RefPtr.h"
 #include "GfxInfoCollector.h"
 
 #include "mozilla/layers/CompositorTypes.h"
@@ -656,16 +657,18 @@ public:
 
     /**
      * Check the blocklist for a feature. Returns false if the feature is blocked
      * with an appropriate message and failure ID.
      * */
     static bool IsGfxInfoStatusOkay(int32_t aFeature, nsCString* aOutMessage,
                                     nsCString& aFailureId);
 
+    const gfxSkipChars& EmptySkipChars() const { return kEmptySkipChars; }
+
 protected:
     gfxPlatform();
     virtual ~gfxPlatform();
 
     virtual void InitAcceleration();
 
     /**
      * Initialized hardware vsync based on each platform.
@@ -807,11 +810,15 @@ private:
     // created yet.
     mozilla::layers::LayersBackend mCompositorBackend;
 
     int32_t mScreenDepth;
     mozilla::gfx::IntSize mScreenSize;
 
     // Generation number for devices that ClientLayerManagers might depend on.
     uint64_t mDeviceCounter;
+
+    // An instance of gfxSkipChars which is empty. It is used as the
+    // basis for error-case iterators.
+    const gfxSkipChars kEmptySkipChars;
 };
 
 #endif /* GFX_PLATFORM_H */
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -2649,18 +2649,18 @@ nsTextFrame::EnsureTextRun(TextRunType a
     }
     if (refDT) {
       BuildTextRuns(refDT, this, aLineContainer, aLine, aWhichTextRun);
     }
     textRun = GetTextRun(aWhichTextRun);
     if (!textRun) {
       // A text run was not constructed for this frame. This is bad. The caller
       // will check mTextRun.
-      static const gfxSkipChars emptySkipChars;
-      return gfxSkipCharsIterator(emptySkipChars, 0);
+      return gfxSkipCharsIterator(gfxPlatform::
+                                  GetPlatform()->EmptySkipChars(), 0);
     }
     TabWidthStore* tabWidths = Properties().Get(TabWidthProperty());
     if (tabWidths && tabWidths->mValidForContentOffset != GetContentOffset()) {
       Properties().Delete(TabWidthProperty());
     }
   }
 
   if (textRun->GetFlags() & nsTextFrameUtils::TEXT_IS_SIMPLE_FLOW) {
@@ -2687,18 +2687,17 @@ nsTextFrame::EnsureTextRun(TextRunType a
       } else {
         *aFlowEndInTextRun = textRun->GetLength();
       }
     }
     return iter;
   }
 
   NS_ERROR("Can't find flow containing this frame???");
-  static const gfxSkipChars emptySkipChars;
-  return gfxSkipCharsIterator(emptySkipChars, 0);
+  return gfxSkipCharsIterator(gfxPlatform::GetPlatform()->EmptySkipChars(), 0);
 }
 
 static uint32_t
 GetEndOfTrimmedText(const nsTextFragment* aFrag, const nsStyleText* aStyleText,
                     uint32_t aStart, uint32_t aEnd,
                     gfxSkipCharsIterator* aIterator)
 {
   aIterator->SetSkippedOffset(aEnd);