Bug 1283106 - Put empty skip chars in gfxPlatform singleton rather than static local variable. r?jfkthame
MozReview-Commit-ID: 5SU6ewm5wbd
--- 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);