Bug 1386915 - Add nsLookAndFeel::NativeInit() virtual call for initializing native-side state; r=jfkthame

MozReview-Commit-ID: 8XKSC1AOI0N
This commit is contained in:
Manish Goregaokar 2017-08-03 13:16:31 -07:00
parent 89df80e7d0
commit b74c4d0f69
11 changed files with 34 additions and 0 deletions

View File

@ -9,6 +9,7 @@
#include "gfxPlatformFontList.h"
#include "mozilla/AutoRestyleTimelineMarker.h"
#include "mozilla/DocumentStyleRootIterator.h"
#include "mozilla/LookAndFeel.h"
#include "mozilla/ServoBindings.h"
#include "mozilla/ServoRestyleManager.h"
#include "mozilla/ServoStyleRuleMap.h"
@ -260,6 +261,8 @@ ServoStyleSet::PreTraverseSync()
nsCSSRuleProcessor::InitSystemMetrics();
LookAndFeel::NativeInit();
// This is lazily computed and pseudo matching needs to access
// it so force computation early.
mPresContext->Document()->GetDocumentState();

View File

@ -618,6 +618,16 @@ public:
*/
static void Refresh();
/**
* GTK's initialization code can't be run off main thread, call this
* if you plan on using LookAndFeel off main thread later.
*
* This initialized state may get reset due to theme changes, so it
* must be called prior to each potential off-main-thread LookAndFeel
* call, not just once.
*/
static void NativeInit();
/**
* If the implementation is caching values, these accessors allow the
* cache to be exported and imported.

View File

@ -15,6 +15,7 @@ public:
virtual ~nsLookAndFeel();
virtual nsresult NativeGetColor(ColorID aID, nscolor &aResult);
virtual void NativeInit() final {};
virtual nsresult GetIntImpl(IntID aID, int32_t &aResult);
virtual nsresult GetFloatImpl(FloatID aID, float &aResult);
virtual bool GetFontImpl(FontID aID, nsString& aName, gfxFontStyle& aStyle,

View File

@ -14,6 +14,7 @@ public:
virtual ~nsLookAndFeel();
virtual nsresult NativeGetColor(ColorID aID, nscolor &aResult);
virtual void NativeInit() final {};
virtual nsresult GetIntImpl(IntID aID, int32_t &aResult);
virtual nsresult GetFloatImpl(FloatID aID, float &aResult);
virtual bool GetFontImpl(FontID aID, nsString& aFontName,

View File

@ -54,6 +54,12 @@ nsLookAndFeel::nsLookAndFeel()
{
}
void
nsLookAndFeel::NativeInit()
{
EnsureInit();
}
nsLookAndFeel::~nsLookAndFeel()
{
#if (MOZ_WIDGET_GTK == 2)

View File

@ -21,6 +21,7 @@ public:
virtual ~nsLookAndFeel();
virtual nsresult NativeGetColor(ColorID aID, nscolor &aResult);
virtual void NativeInit() final;
virtual nsresult GetIntImpl(IntID aID, int32_t &aResult);
virtual nsresult GetFloatImpl(FloatID aID, float &aResult);
virtual bool GetFontImpl(FontID aID, nsString& aFontName,

View File

@ -24,6 +24,7 @@ public:
virtual ~HeadlessLookAndFeel();
virtual nsresult NativeGetColor(ColorID aID, nscolor &aResult);
virtual void NativeInit() final {};
virtual nsresult GetIntImpl(IntID aID, int32_t &aResult);
virtual nsresult GetFloatImpl(FloatID aID, float &aResult);
virtual bool GetFontImpl(FontID aID,

View File

@ -990,6 +990,13 @@ LookAndFeel::Refresh()
nsLookAndFeel::GetInstance()->RefreshImpl();
}
// static
void
LookAndFeel::NativeInit()
{
nsLookAndFeel::GetInstance()->NativeInit();
}
// static
nsTArray<LookAndFeelInt>
LookAndFeel::GetIntCache()

View File

@ -84,6 +84,8 @@ public:
virtual nsTArray<LookAndFeelInt> GetIntCacheImpl();
virtual void SetIntCacheImpl(const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) {}
virtual void NativeInit() = 0;
protected:
nsXPLookAndFeel();

View File

@ -15,6 +15,7 @@ public:
virtual ~nsLookAndFeel();
virtual nsresult NativeGetColor(const ColorID aID, nscolor &aResult);
virtual void NativeInit() final {};
virtual nsresult GetIntImpl(IntID aID, int32_t &aResult);
virtual nsresult GetFloatImpl(FloatID aID, float &aResult);
virtual bool GetFontImpl(FontID aID, nsString& aFontName,

View File

@ -43,6 +43,7 @@ public:
virtual ~nsLookAndFeel();
nsresult NativeGetColor(ColorID aID, nscolor &aResult) override;
void NativeInit() final {};
nsresult GetIntImpl(IntID aID, int32_t &aResult) override;
nsresult GetFloatImpl(FloatID aID, float &aResult) override;
bool GetFontImpl(FontID aID, nsString& aFontName,