зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1652561 - Remote Win32k calls in nsLookAndFeel::GetFontImpl() r=emilio,geckoview-reviewers,agi,froydnj
Content processes will now receive cached values for GetFontImpl() from the parent process during initialization and whenever the theme changes. This eliminates the use of several Win32k calls in content. Differential Revision: https://phabricator.services.mozilla.com/D83406
This commit is contained in:
Родитель
133b9692b1
Коммит
552aa91269
|
@ -605,7 +605,7 @@ NS_INTERFACE_MAP_END
|
|||
|
||||
mozilla::ipc::IPCResult ContentChild::RecvSetXPCOMProcessAttributes(
|
||||
XPCOMInitData&& aXPCOMInit, const StructuredCloneData& aInitialData,
|
||||
nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache,
|
||||
LookAndFeelCache&& aLookAndFeelCache,
|
||||
nsTArray<SystemFontListEntry>&& aFontList,
|
||||
const Maybe<SharedMemoryHandle>& aSharedUASheetHandle,
|
||||
const uintptr_t& aSharedUASheetAddress,
|
||||
|
@ -614,7 +614,7 @@ mozilla::ipc::IPCResult ContentChild::RecvSetXPCOMProcessAttributes(
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
mLookAndFeelCache = std::move(aLookAndFeelIntCache);
|
||||
mLookAndFeelCache = std::move(aLookAndFeelCache);
|
||||
mFontList = std::move(aFontList);
|
||||
mSharedFontListBlocks = std::move(aSharedFontListBlocks);
|
||||
#ifdef XP_WIN
|
||||
|
@ -2303,8 +2303,8 @@ mozilla::ipc::IPCResult ContentChild::RecvNotifyVisited(
|
|||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentChild::RecvThemeChanged(
|
||||
nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache) {
|
||||
LookAndFeel::SetIntCache(aLookAndFeelIntCache);
|
||||
LookAndFeelCache&& aLookAndFeelCache) {
|
||||
LookAndFeel::SetCache(aLookAndFeelCache);
|
||||
LookAndFeel::NotifyChangedAllWindows();
|
||||
return IPC_OK();
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "mozilla/dom/RemoteType.h"
|
||||
#include "mozilla/ipc/InputStreamUtils.h"
|
||||
#include "mozilla/ipc/ProtocolUtils.h"
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsClassHashtable.h"
|
||||
|
@ -35,7 +36,6 @@ struct SubstitutionMapping;
|
|||
struct OverrideMapping;
|
||||
class nsIDomainPolicy;
|
||||
class nsIURIClassifierCallback;
|
||||
struct LookAndFeelInt;
|
||||
class nsDocShellLoadState;
|
||||
class nsFrameLoader;
|
||||
class nsIOpenWindowInfo;
|
||||
|
@ -308,7 +308,8 @@ class ContentChild final : public PContentChild,
|
|||
const bool& haveBidiKeyboards);
|
||||
|
||||
mozilla::ipc::IPCResult RecvNotifyVisited(nsTArray<VisitedQueryResult>&&);
|
||||
mozilla::ipc::IPCResult RecvThemeChanged(nsTArray<LookAndFeelInt>&&);
|
||||
mozilla::ipc::IPCResult RecvThemeChanged(
|
||||
LookAndFeelCache&& aLookAndFeelCache);
|
||||
|
||||
mozilla::ipc::IPCResult RecvUpdateSystemParameters(
|
||||
nsTArray<SystemParameterKVPair>&& aUpdates);
|
||||
|
@ -542,7 +543,7 @@ class ContentChild final : public PContentChild,
|
|||
|
||||
mozilla::ipc::IPCResult RecvSetXPCOMProcessAttributes(
|
||||
XPCOMInitData&& aXPCOMInit, const StructuredCloneData& aInitialData,
|
||||
nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache,
|
||||
LookAndFeelCache&& aLookAndFeelCache,
|
||||
nsTArray<SystemFontListEntry>&& aFontList,
|
||||
const Maybe<base::SharedMemoryHandle>& aSharedUASheetHandle,
|
||||
const uintptr_t& aSharedUASheetAddress,
|
||||
|
@ -607,7 +608,7 @@ class ContentChild final : public PContentChild,
|
|||
bool DeallocPSessionStorageObserverChild(
|
||||
PSessionStorageObserverChild* aActor);
|
||||
|
||||
nsTArray<LookAndFeelInt>& LookAndFeelCache() { return mLookAndFeelCache; }
|
||||
LookAndFeelCache& BorrowLookAndFeelCache() { return mLookAndFeelCache; }
|
||||
|
||||
/**
|
||||
* Helper function for protocols that use the GPU process when available.
|
||||
|
@ -835,8 +836,8 @@ class ContentChild final : public PContentChild,
|
|||
// parent process and used to initialize gfx in the child. Currently used
|
||||
// only on MacOSX and Linux.
|
||||
nsTArray<mozilla::dom::SystemFontListEntry> mFontList;
|
||||
// Temporary storage for nsXPLookAndFeel flags.
|
||||
nsTArray<LookAndFeelInt> mLookAndFeelCache;
|
||||
// Temporary storage for nsXPLookAndFeel cache info.
|
||||
LookAndFeelCache mLookAndFeelCache;
|
||||
// Temporary storage for list of shared-fontlist memory blocks.
|
||||
nsTArray<base::SharedMemoryHandle> mSharedFontListBlocks;
|
||||
|
||||
|
|
|
@ -2643,7 +2643,8 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) {
|
|||
// at present.
|
||||
nsTArray<SystemFontListEntry> fontList;
|
||||
gfxPlatform::GetPlatform()->ReadSystemFontList(&fontList);
|
||||
nsTArray<LookAndFeelInt> lnfCache = LookAndFeel::GetIntCache();
|
||||
|
||||
LookAndFeelCache lnfCache = LookAndFeel::GetCache();
|
||||
|
||||
// If the shared fontlist is in use, collect its shmem block handles to pass
|
||||
// to the child.
|
||||
|
|
|
@ -85,7 +85,7 @@ using mozilla::gfx::IntSize from "mozilla/gfx/2D.h";
|
|||
using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
|
||||
using mozilla::dom::ContentParentId from "mozilla/dom/ipc/IdType.h";
|
||||
using mozilla::LayoutDeviceIntPoint from "Units.h";
|
||||
using struct LookAndFeelInt from "mozilla/widget/WidgetMessageUtils.h";
|
||||
using struct LookAndFeelCache from "mozilla/widget/WidgetMessageUtils.h";
|
||||
using class mozilla::dom::MessagePort from "mozilla/dom/MessagePort.h";
|
||||
using class mozilla::dom::ipc::StructuredCloneData from "mozilla/dom/ipc/StructuredCloneData.h";
|
||||
using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
|
||||
|
@ -560,7 +560,7 @@ child:
|
|||
* Tell the child that the system theme has changed, and that a repaint
|
||||
* is necessary.
|
||||
*/
|
||||
async ThemeChanged(LookAndFeelInt[] lookAndFeelIntCache);
|
||||
async ThemeChanged(LookAndFeelCache lookAndFeelCache);
|
||||
|
||||
async UpdateSystemParameters(SystemParameterKVPair[] aUpdates);
|
||||
|
||||
|
@ -666,7 +666,7 @@ child:
|
|||
|
||||
async SetXPCOMProcessAttributes(XPCOMInitData xpcomInit,
|
||||
StructuredCloneData initialData,
|
||||
LookAndFeelInt[] lookAndFeelIntCache,
|
||||
LookAndFeelCache lookAndFeelCache,
|
||||
/* used on MacOSX/Linux/Android only: */
|
||||
SystemFontListEntry[] systemFontList,
|
||||
SharedMemoryHandle? sharedUASheetHandle,
|
||||
|
|
|
@ -523,14 +523,14 @@ void nsPresContext::PreferenceChanged(const char* aPrefName) {
|
|||
if (prefName.EqualsLiteral("font.internaluseonly.changed")) {
|
||||
mChangeHintForPrefChange |= nsChangeHint_ReconstructFrame;
|
||||
} else if (StringBeginsWith(prefName, "font."_ns) ||
|
||||
// Changes to font family preferences don't change anything in the
|
||||
// computed style data, so the style system won't generate a reflow
|
||||
// hint for us. We need to do that manually.
|
||||
prefName.EqualsLiteral("intl.accept_languages") ||
|
||||
// Changes to bidi prefs need to trigger a reflow (see bug 443629)
|
||||
StringBeginsWith(prefName, "bidi."_ns) ||
|
||||
// Changes to font_rendering prefs need to trigger a reflow
|
||||
StringBeginsWith(prefName, "gfx.font_rendering."_ns)) {
|
||||
// Changes to font family preferences don't change anything in the
|
||||
// computed style data, so the style system won't generate a reflow
|
||||
// hint for us. We need to do that manually.
|
||||
prefName.EqualsLiteral("intl.accept_languages") ||
|
||||
// Changes to bidi prefs need to trigger a reflow (see bug 443629)
|
||||
StringBeginsWith(prefName, "bidi."_ns) ||
|
||||
// Changes to font_rendering prefs need to trigger a reflow
|
||||
StringBeginsWith(prefName, "gfx.font_rendering."_ns)) {
|
||||
mChangeHintForPrefChange |= NS_STYLE_HINT_REFLOW;
|
||||
}
|
||||
|
||||
|
@ -1345,9 +1345,9 @@ void nsPresContext::ThemeChangedInternal() {
|
|||
if (XRE_IsParentProcess()) {
|
||||
nsTArray<ContentParent*> cp;
|
||||
ContentParent::GetAll(cp);
|
||||
auto cache = LookAndFeel::GetIntCache();
|
||||
LookAndFeelCache lnfCache = LookAndFeel::GetCache();
|
||||
for (ContentParent* c : cp) {
|
||||
Unused << c->SendThemeChanged(cache);
|
||||
Unused << c->SendThemeChanged(lnfCache);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,9 @@ class RangedArray {
|
|||
ArrayType mArr;
|
||||
|
||||
public:
|
||||
static size_t length() { return Length; }
|
||||
static size_t minIndex() { return MinIndex; }
|
||||
|
||||
T& operator[](size_t aIndex) {
|
||||
MOZ_ASSERT(aIndex == MinIndex || aIndex > MinIndex);
|
||||
return mArr[aIndex - MinIndex];
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
|
||||
struct gfxFontStyle;
|
||||
|
||||
struct LookAndFeelInt;
|
||||
struct LookAndFeelFontInfo;
|
||||
struct LookAndFeelCache;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -546,8 +545,8 @@ class LookAndFeel {
|
|||
* If the implementation is caching values, these accessors allow the
|
||||
* cache to be exported and imported.
|
||||
*/
|
||||
static nsTArray<LookAndFeelInt> GetIntCache();
|
||||
static void SetIntCache(const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache);
|
||||
static LookAndFeelCache GetCache();
|
||||
static void SetCache(const LookAndFeelCache& aCache);
|
||||
static void NotifyChangedAllWindows();
|
||||
};
|
||||
|
||||
|
@ -558,7 +557,7 @@ struct LookAndFeelInt {
|
|||
int32_t value;
|
||||
};
|
||||
|
||||
struct LookAndFeelFontInfo {
|
||||
struct LookAndFeelFont {
|
||||
bool haveFont;
|
||||
nsString fontName;
|
||||
float pixelHeight;
|
||||
|
@ -566,6 +565,15 @@ struct LookAndFeelFontInfo {
|
|||
bool bold;
|
||||
};
|
||||
|
||||
struct LookAndFeelCache {
|
||||
void Clear() {
|
||||
mInts.Clear();
|
||||
mFonts.Clear();
|
||||
}
|
||||
nsTArray<LookAndFeelInt> mInts;
|
||||
nsTArray<LookAndFeelFont> mFonts;
|
||||
};
|
||||
|
||||
// On the Mac, GetColor(ColorID::TextSelectForeground, color) returns this
|
||||
// constant to specify that the foreground color should not be changed
|
||||
// (ie. a colored text keeps its colors when selected).
|
||||
|
|
|
@ -32,6 +32,44 @@ struct ParamTraits<LookAndFeelInt> {
|
|||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<LookAndFeelFont> {
|
||||
typedef LookAndFeelFont paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam) {
|
||||
WriteParam(aMsg, aParam.haveFont);
|
||||
WriteParam(aMsg, aParam.fontName);
|
||||
WriteParam(aMsg, aParam.pixelHeight);
|
||||
WriteParam(aMsg, aParam.italic);
|
||||
WriteParam(aMsg, aParam.bold);
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, PickleIterator* aIter,
|
||||
paramType* aResult) {
|
||||
return ReadParam(aMsg, aIter, &aResult->haveFont) &&
|
||||
ReadParam(aMsg, aIter, &aResult->fontName) &&
|
||||
ReadParam(aMsg, aIter, &aResult->pixelHeight) &&
|
||||
ReadParam(aMsg, aIter, &aResult->italic) &&
|
||||
ReadParam(aMsg, aIter, &aResult->bold);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<LookAndFeelCache> {
|
||||
typedef LookAndFeelCache paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam) {
|
||||
WriteParam(aMsg, aParam.mInts);
|
||||
WriteParam(aMsg, aParam.mFonts);
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, PickleIterator* aIter,
|
||||
paramType* aResult) {
|
||||
return ReadParam(aMsg, aIter, &aResult->mInts) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mFonts);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<nsTransparencyMode>
|
||||
: public ContiguousEnumSerializerInclusive<nsTransparencyMode,
|
||||
|
|
|
@ -481,24 +481,21 @@ void nsLookAndFeel::EnsureInitShowPassword() {
|
|||
}
|
||||
}
|
||||
|
||||
nsTArray<LookAndFeelInt> nsLookAndFeel::GetIntCacheImpl() {
|
||||
nsTArray<LookAndFeelInt> lookAndFeelIntCache =
|
||||
nsXPLookAndFeel::GetIntCacheImpl();
|
||||
LookAndFeelCache nsLookAndFeel::GetCacheImpl() {
|
||||
LookAndFeelCache cache = nsXPLookAndFeel::GetCacheImpl();
|
||||
|
||||
const IntID kIdsToCache[] = {IntID::PrefersReducedMotion,
|
||||
IntID::SystemUsesDarkTheme};
|
||||
|
||||
for (IntID id : kIdsToCache) {
|
||||
lookAndFeelIntCache.AppendElement(
|
||||
LookAndFeelInt{.id = id, .value = GetInt(id)});
|
||||
cache.mInts.AppendElement(LookAndFeelInt{.id = id, .value = GetInt(id)});
|
||||
}
|
||||
|
||||
return lookAndFeelIntCache;
|
||||
return cache;
|
||||
}
|
||||
|
||||
void nsLookAndFeel::SetIntCacheImpl(
|
||||
const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) {
|
||||
for (const auto& entry : aLookAndFeelIntCache) {
|
||||
void nsLookAndFeel::SetCacheImpl(const LookAndFeelCache& aCache) {
|
||||
for (const auto& entry : aCache.mInts) {
|
||||
switch (entry.id) {
|
||||
case IntID::PrefersReducedMotion:
|
||||
mPrefersReducedMotion = entry.value;
|
||||
|
|
|
@ -23,9 +23,8 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
|
|||
virtual bool GetEchoPasswordImpl() override;
|
||||
virtual uint32_t GetPasswordMaskDelayImpl() override;
|
||||
virtual char16_t GetPasswordCharacterImpl() override;
|
||||
virtual nsTArray<LookAndFeelInt> GetIntCacheImpl() override;
|
||||
virtual void SetIntCacheImpl(
|
||||
const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) override;
|
||||
LookAndFeelCache GetCacheImpl() override;
|
||||
void SetCacheImpl(const LookAndFeelCache& aCache) override;
|
||||
|
||||
protected:
|
||||
bool mInitializedSystemColors = false;
|
||||
|
|
|
@ -27,9 +27,8 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
|
|||
|
||||
static bool UseOverlayScrollbars();
|
||||
|
||||
virtual nsTArray<LookAndFeelInt> GetIntCacheImpl() override;
|
||||
virtual void SetIntCacheImpl(
|
||||
const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) override;
|
||||
LookAndFeelCache GetCacheImpl() override;
|
||||
void SetCacheImpl(const LookAndFeelCache& aCache) override;
|
||||
|
||||
protected:
|
||||
static bool SystemWantsOverlayScrollbars();
|
||||
|
|
|
@ -654,34 +654,34 @@ bool nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName, gfxFontStyle& a
|
|||
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false);
|
||||
}
|
||||
|
||||
nsTArray<LookAndFeelInt> nsLookAndFeel::GetIntCacheImpl() {
|
||||
nsTArray<LookAndFeelInt> lookAndFeelIntCache = nsXPLookAndFeel::GetIntCacheImpl();
|
||||
LookAndFeelCache nsLookAndFeel::GetCacheImpl() {
|
||||
LookAndFeelCache cache = nsXPLookAndFeel::GetCacheImpl();
|
||||
|
||||
LookAndFeelInt useOverlayScrollbars;
|
||||
useOverlayScrollbars.id = IntID::UseOverlayScrollbars;
|
||||
useOverlayScrollbars.value = GetInt(IntID::UseOverlayScrollbars);
|
||||
lookAndFeelIntCache.AppendElement(useOverlayScrollbars);
|
||||
cache.mInts.AppendElement(useOverlayScrollbars);
|
||||
|
||||
LookAndFeelInt allowOverlayScrollbarsOverlap;
|
||||
allowOverlayScrollbarsOverlap.id = IntID::AllowOverlayScrollbarsOverlap;
|
||||
allowOverlayScrollbarsOverlap.value = GetInt(IntID::AllowOverlayScrollbarsOverlap);
|
||||
lookAndFeelIntCache.AppendElement(allowOverlayScrollbarsOverlap);
|
||||
cache.mInts.AppendElement(allowOverlayScrollbarsOverlap);
|
||||
|
||||
LookAndFeelInt prefersReducedMotion;
|
||||
prefersReducedMotion.id = IntID::PrefersReducedMotion;
|
||||
prefersReducedMotion.value = GetInt(IntID::PrefersReducedMotion);
|
||||
lookAndFeelIntCache.AppendElement(prefersReducedMotion);
|
||||
cache.mInts.AppendElement(prefersReducedMotion);
|
||||
|
||||
LookAndFeelInt systemUsesDarkTheme;
|
||||
systemUsesDarkTheme.id = IntID::SystemUsesDarkTheme;
|
||||
systemUsesDarkTheme.value = GetInt(IntID::SystemUsesDarkTheme);
|
||||
lookAndFeelIntCache.AppendElement(systemUsesDarkTheme);
|
||||
cache.mInts.AppendElement(systemUsesDarkTheme);
|
||||
|
||||
return lookAndFeelIntCache;
|
||||
return cache;
|
||||
}
|
||||
|
||||
void nsLookAndFeel::SetIntCacheImpl(const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) {
|
||||
for (auto entry : aLookAndFeelIntCache) {
|
||||
void nsLookAndFeel::SetCacheImpl(const LookAndFeelCache& aCache) {
|
||||
for (auto entry : aCache.mInts) {
|
||||
switch (entry.id) {
|
||||
case IntID::UseOverlayScrollbars:
|
||||
mUseOverlayScrollbars = entry.value;
|
||||
|
|
|
@ -271,25 +271,22 @@ void nsLookAndFeel::RefreshImpl() {
|
|||
mInitialized = false;
|
||||
}
|
||||
|
||||
nsTArray<LookAndFeelInt> nsLookAndFeel::GetIntCacheImpl() {
|
||||
nsTArray<LookAndFeelInt> lookAndFeelIntCache =
|
||||
nsXPLookAndFeel::GetIntCacheImpl();
|
||||
LookAndFeelCache nsLookAndFeel::GetCacheImpl() {
|
||||
LookAndFeelCache cache = nsXPLookAndFeel::GetCacheImpl();
|
||||
|
||||
const IntID kIdsToCache[] = {IntID::SystemUsesDarkTheme,
|
||||
IntID::PrefersReducedMotion,
|
||||
IntID::UseAccessibilityTheme};
|
||||
|
||||
for (IntID id : kIdsToCache) {
|
||||
lookAndFeelIntCache.AppendElement(
|
||||
LookAndFeelInt{.id = id, .value = GetInt(id)});
|
||||
cache.mInts.AppendElement(LookAndFeelInt{.id = id, .value = GetInt(id)});
|
||||
}
|
||||
|
||||
return lookAndFeelIntCache;
|
||||
return cache;
|
||||
}
|
||||
|
||||
void nsLookAndFeel::SetIntCacheImpl(
|
||||
const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) {
|
||||
for (const auto& entry : aLookAndFeelIntCache) {
|
||||
void nsLookAndFeel::SetCacheImpl(const LookAndFeelCache& aCache) {
|
||||
for (const auto& entry : aCache.mInts) {
|
||||
switch (entry.id) {
|
||||
case IntID::SystemUsesDarkTheme:
|
||||
mSystemUsesDarkTheme = entry.value;
|
||||
|
|
|
@ -31,9 +31,8 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
|
|||
char16_t GetPasswordCharacterImpl() override;
|
||||
bool GetEchoPasswordImpl() override;
|
||||
|
||||
nsTArray<LookAndFeelInt> GetIntCacheImpl() override;
|
||||
void SetIntCacheImpl(
|
||||
const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) override;
|
||||
LookAndFeelCache GetCacheImpl() override;
|
||||
void SetCacheImpl(const LookAndFeelCache& aCache) override;
|
||||
|
||||
bool IsCSDAvailable() const { return mCSDAvailable; }
|
||||
|
||||
|
|
|
@ -455,10 +455,10 @@ void nsXPLookAndFeel::Init() {
|
|||
if (XRE_IsContentProcess()) {
|
||||
mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton();
|
||||
|
||||
LookAndFeel::SetIntCache(cc->LookAndFeelCache());
|
||||
LookAndFeel::SetCache(cc->BorrowLookAndFeelCache());
|
||||
// This is only ever used once during initialization, and can be cleared
|
||||
// now.
|
||||
cc->LookAndFeelCache().Clear();
|
||||
cc->BorrowLookAndFeelCache().Clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -999,9 +999,7 @@ void nsXPLookAndFeel::RefreshImpl() {
|
|||
}
|
||||
}
|
||||
|
||||
nsTArray<LookAndFeelInt> nsXPLookAndFeel::GetIntCacheImpl() {
|
||||
return nsTArray<LookAndFeelInt>();
|
||||
}
|
||||
LookAndFeelCache nsXPLookAndFeel::GetCacheImpl() { return LookAndFeelCache{}; }
|
||||
|
||||
static bool sRecordedLookAndFeelTelemetry = false;
|
||||
|
||||
|
@ -1082,14 +1080,13 @@ void LookAndFeel::Refresh() { nsLookAndFeel::GetInstance()->RefreshImpl(); }
|
|||
void LookAndFeel::NativeInit() { nsLookAndFeel::GetInstance()->NativeInit(); }
|
||||
|
||||
// static
|
||||
nsTArray<LookAndFeelInt> LookAndFeel::GetIntCache() {
|
||||
return nsLookAndFeel::GetInstance()->GetIntCacheImpl();
|
||||
LookAndFeelCache LookAndFeel::GetCache() {
|
||||
return nsLookAndFeel::GetInstance()->GetCacheImpl();
|
||||
}
|
||||
|
||||
// static
|
||||
void LookAndFeel::SetIntCache(
|
||||
const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) {
|
||||
return nsLookAndFeel::GetInstance()->SetIntCacheImpl(aLookAndFeelIntCache);
|
||||
void LookAndFeel::SetCache(const LookAndFeelCache& aCache) {
|
||||
nsLookAndFeel::GetInstance()->SetCacheImpl(aCache);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla
|
|
@ -72,9 +72,8 @@ class nsXPLookAndFeel : public mozilla::LookAndFeel {
|
|||
|
||||
virtual uint32_t GetPasswordMaskDelayImpl() { return 600; }
|
||||
|
||||
virtual nsTArray<LookAndFeelInt> GetIntCacheImpl();
|
||||
virtual void SetIntCacheImpl(
|
||||
const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) {}
|
||||
virtual LookAndFeelCache GetCacheImpl();
|
||||
virtual void SetCacheImpl(const LookAndFeelCache& aCache) {}
|
||||
|
||||
virtual void NativeInit() = 0;
|
||||
|
||||
|
|
|
@ -630,9 +630,9 @@ nsresult nsLookAndFeel::GetFloatImpl(FloatID aID, float& aResult) {
|
|||
return res;
|
||||
}
|
||||
|
||||
LookAndFeelFontInfo nsLookAndFeel::GetLookAndFeelFontInfoInternal(
|
||||
LookAndFeelFont nsLookAndFeel::GetLookAndFeelFontInternal(
|
||||
const LOGFONTW& aLogFont, bool aUseShellDlg) {
|
||||
LookAndFeelFontInfo result{};
|
||||
LookAndFeelFont result{};
|
||||
|
||||
result.haveFont = false;
|
||||
|
||||
|
@ -690,9 +690,12 @@ LookAndFeelFontInfo nsLookAndFeel::GetLookAndFeelFontInfoInternal(
|
|||
return result;
|
||||
}
|
||||
|
||||
LookAndFeelFontInfo nsLookAndFeel::GetLookAndFeelFontInfo(
|
||||
LookAndFeel::FontID anID) {
|
||||
LookAndFeelFontInfo result{};
|
||||
LookAndFeelFont nsLookAndFeel::GetLookAndFeelFont(LookAndFeel::FontID anID) {
|
||||
if (XRE_IsContentProcess()) {
|
||||
return mFontCache[size_t(anID)];
|
||||
}
|
||||
|
||||
LookAndFeelFont result{};
|
||||
|
||||
result.haveFont = false;
|
||||
|
||||
|
@ -701,7 +704,7 @@ LookAndFeelFontInfo nsLookAndFeel::GetLookAndFeelFontInfo(
|
|||
LOGFONTW logFont;
|
||||
if (::SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(logFont),
|
||||
(PVOID)&logFont, 0)) {
|
||||
result = GetLookAndFeelFontInfoInternal(logFont, false);
|
||||
result = GetLookAndFeelFontInternal(logFont, false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -716,17 +719,17 @@ LookAndFeelFontInfo nsLookAndFeel::GetLookAndFeelFontInfo(
|
|||
switch (anID) {
|
||||
case LookAndFeel::FontID::Menu:
|
||||
case LookAndFeel::FontID::PullDownMenu:
|
||||
result = GetLookAndFeelFontInfoInternal(ncm.lfMenuFont, false);
|
||||
result = GetLookAndFeelFontInternal(ncm.lfMenuFont, false);
|
||||
break;
|
||||
case LookAndFeel::FontID::Caption:
|
||||
result = GetLookAndFeelFontInfoInternal(ncm.lfCaptionFont, false);
|
||||
result = GetLookAndFeelFontInternal(ncm.lfCaptionFont, false);
|
||||
break;
|
||||
case LookAndFeel::FontID::SmallCaption:
|
||||
result = GetLookAndFeelFontInfoInternal(ncm.lfSmCaptionFont, false);
|
||||
result = GetLookAndFeelFontInternal(ncm.lfSmCaptionFont, false);
|
||||
break;
|
||||
case LookAndFeel::FontID::StatusBar:
|
||||
case LookAndFeel::FontID::Tooltips:
|
||||
result = GetLookAndFeelFontInfoInternal(ncm.lfStatusFont, false);
|
||||
result = GetLookAndFeelFontInternal(ncm.lfStatusFont, false);
|
||||
break;
|
||||
case LookAndFeel::FontID::Widget:
|
||||
case LookAndFeel::FontID::Dialog:
|
||||
|
@ -737,35 +740,34 @@ LookAndFeelFontInfo nsLookAndFeel::GetLookAndFeelFontInfo(
|
|||
// set of LookAndFeel values to map to the dialog font; we may
|
||||
// want to add or remove cases here after reviewing the visual
|
||||
// results under various Windows versions.
|
||||
result = GetLookAndFeelFontInfoInternal(ncm.lfMessageFont, true);
|
||||
result = GetLookAndFeelFontInternal(ncm.lfMessageFont, true);
|
||||
break;
|
||||
default:
|
||||
result = GetLookAndFeelFontInfoInternal(ncm.lfMessageFont, false);
|
||||
result = GetLookAndFeelFontInternal(ncm.lfMessageFont, false);
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool nsLookAndFeel::GetSysFontInfo(LookAndFeel::FontID anID,
|
||||
nsString& aFontName,
|
||||
gfxFontStyle& aFontStyle) {
|
||||
LookAndFeelFontInfo fontInfo = GetLookAndFeelFontInfo(anID);
|
||||
bool nsLookAndFeel::GetSysFont(LookAndFeel::FontID anID, nsString& aFontName,
|
||||
gfxFontStyle& aFontStyle) {
|
||||
LookAndFeelFont font = GetLookAndFeelFont(anID);
|
||||
|
||||
if (!fontInfo.haveFont) {
|
||||
if (!font.haveFont) {
|
||||
return false;
|
||||
}
|
||||
|
||||
aFontName = std::move(fontInfo.fontName);
|
||||
aFontName = std::move(font.fontName);
|
||||
|
||||
aFontStyle.size = fontInfo.pixelHeight;
|
||||
aFontStyle.size = font.pixelHeight;
|
||||
|
||||
// FIXME: What about oblique?
|
||||
aFontStyle.style =
|
||||
fontInfo.italic ? FontSlantStyle::Italic() : FontSlantStyle::Normal();
|
||||
font.italic ? FontSlantStyle::Italic() : FontSlantStyle::Normal();
|
||||
|
||||
// FIXME: Other weights?
|
||||
aFontStyle.weight = fontInfo.bold ? FontWeight::Bold() : FontWeight::Normal();
|
||||
aFontStyle.weight = font.bold ? FontWeight::Bold() : FontWeight::Normal();
|
||||
|
||||
// FIXME: Set aFontStyle->stretch correctly!
|
||||
aFontStyle.stretch = FontStretch::Normal();
|
||||
|
@ -787,7 +789,7 @@ bool nsLookAndFeel::GetFontImpl(FontID anID, nsString& aFontName,
|
|||
aFontStyle = cacheSlot.mFontStyle;
|
||||
}
|
||||
} else {
|
||||
status = GetSysFontInfo(anID, aFontName, aFontStyle);
|
||||
status = GetSysFont(anID, aFontName, aFontStyle);
|
||||
|
||||
cacheSlot.mCacheValid = true;
|
||||
cacheSlot.mHaveFont = status;
|
||||
|
@ -805,29 +807,37 @@ char16_t nsLookAndFeel::GetPasswordCharacterImpl() {
|
|||
return UNICODE_BLACK_CIRCLE_CHAR;
|
||||
}
|
||||
|
||||
nsTArray<LookAndFeelInt> nsLookAndFeel::GetIntCacheImpl() {
|
||||
nsTArray<LookAndFeelInt> lookAndFeelIntCache =
|
||||
nsXPLookAndFeel::GetIntCacheImpl();
|
||||
LookAndFeelCache nsLookAndFeel::GetCacheImpl() {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
LookAndFeelCache cache = nsXPLookAndFeel::GetCacheImpl();
|
||||
|
||||
LookAndFeelInt lafInt;
|
||||
lafInt.id = IntID::UseAccessibilityTheme;
|
||||
lafInt.value = GetInt(IntID::UseAccessibilityTheme);
|
||||
lookAndFeelIntCache.AppendElement(lafInt);
|
||||
cache.mInts.AppendElement(lafInt);
|
||||
|
||||
lafInt.id = IntID::WindowsDefaultTheme;
|
||||
lafInt.value = GetInt(IntID::WindowsDefaultTheme);
|
||||
lookAndFeelIntCache.AppendElement(lafInt);
|
||||
cache.mInts.AppendElement(lafInt);
|
||||
|
||||
lafInt.id = IntID::WindowsThemeIdentifier;
|
||||
lafInt.value = GetInt(IntID::WindowsThemeIdentifier);
|
||||
lookAndFeelIntCache.AppendElement(lafInt);
|
||||
cache.mInts.AppendElement(lafInt);
|
||||
|
||||
return lookAndFeelIntCache;
|
||||
for (size_t i = size_t(LookAndFeel::FontID::MINIMUM);
|
||||
i <= size_t(LookAndFeel::FontID::MAXIMUM); ++i) {
|
||||
cache.mFonts.AppendElement(GetLookAndFeelFont(LookAndFeel::FontID(i)));
|
||||
}
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
void nsLookAndFeel::SetIntCacheImpl(
|
||||
const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) {
|
||||
for (auto entry : aLookAndFeelIntCache) {
|
||||
void nsLookAndFeel::SetCacheImpl(const LookAndFeelCache& aCache) {
|
||||
MOZ_ASSERT(XRE_IsContentProcess());
|
||||
MOZ_RELEASE_ASSERT(aCache.mFonts.Length() == mFontCache.length());
|
||||
|
||||
for (auto entry : aCache.mInts) {
|
||||
switch (entry.id) {
|
||||
case IntID::UseAccessibilityTheme:
|
||||
mUseAccessibilityTheme = entry.value;
|
||||
|
@ -843,6 +853,12 @@ void nsLookAndFeel::SetIntCacheImpl(
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
size_t i = mFontCache.minIndex();
|
||||
for (const auto& font : aCache.mFonts) {
|
||||
mFontCache[i] = font;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
|
|
@ -58,9 +58,8 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
|
|||
gfxFontStyle& aFontStyle) override;
|
||||
char16_t GetPasswordCharacterImpl() override;
|
||||
|
||||
nsTArray<LookAndFeelInt> GetIntCacheImpl() override;
|
||||
void SetIntCacheImpl(
|
||||
const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) override;
|
||||
LookAndFeelCache GetCacheImpl() override;
|
||||
void SetCacheImpl(const LookAndFeelCache& aCache) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -81,13 +80,13 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
|
|||
|
||||
nscolor GetColorForSysColorIndex(int index);
|
||||
|
||||
LookAndFeelFontInfo GetLookAndFeelFontInfoInternal(const LOGFONTW& aLogFont,
|
||||
bool aUseShellDlg);
|
||||
LookAndFeelFont GetLookAndFeelFontInternal(const LOGFONTW& aLogFont,
|
||||
bool aUseShellDlg);
|
||||
|
||||
LookAndFeelFontInfo GetLookAndFeelFontInfo(LookAndFeel::FontID anID);
|
||||
LookAndFeelFont GetLookAndFeelFont(LookAndFeel::FontID anID);
|
||||
|
||||
bool GetSysFontInfo(LookAndFeel::FontID anID, nsString& aFontName,
|
||||
gfxFontStyle& aFontStyle);
|
||||
bool GetSysFont(LookAndFeel::FontID anID, nsString& aFontName,
|
||||
gfxFontStyle& aFontStyle);
|
||||
|
||||
// Content process cached values that get shipped over from the browser
|
||||
// process.
|
||||
|
@ -127,6 +126,10 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
|
|||
size_t(FontID::MAXIMUM) + 1 - size_t(FontID::MINIMUM)>
|
||||
mSystemFontCache;
|
||||
|
||||
mozilla::RangedArray<LookAndFeelFont, size_t(FontID::MINIMUM),
|
||||
size_t(FontID::MAXIMUM) + 1 - size_t(FontID::MINIMUM)>
|
||||
mFontCache;
|
||||
|
||||
nsCOMPtr<nsIWindowsRegKey> mDwmKey;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче