diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 2addfe417744..c75593f6fcda 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -605,7 +605,7 @@ NS_INTERFACE_MAP_END mozilla::ipc::IPCResult ContentChild::RecvSetXPCOMProcessAttributes( XPCOMInitData&& aXPCOMInit, const StructuredCloneData& aInitialData, - LookAndFeelData&& aLookAndFeelData, + FullLookAndFeel&& aLookAndFeelData, nsTArray&& aFontList, const Maybe& aSharedUASheetHandle, const uintptr_t& aSharedUASheetAddress, @@ -2247,17 +2247,8 @@ mozilla::ipc::IPCResult ContentChild::RecvNotifyVisited( } mozilla::ipc::IPCResult ContentChild::RecvThemeChanged( - LookAndFeelData&& aLookAndFeelData, widget::ThemeChangeKind aKind) { - switch (aLookAndFeelData.type()) { - case LookAndFeelData::TLookAndFeelCache: - LookAndFeel::SetCache(aLookAndFeelData.get_LookAndFeelCache()); - break; - case LookAndFeelData::TFullLookAndFeel: - LookAndFeel::SetData(std::move(aLookAndFeelData.get_FullLookAndFeel())); - break; - default: - MOZ_ASSERT(false, "unreachable"); - } + FullLookAndFeel&& aLookAndFeelData, widget::ThemeChangeKind aKind) { + LookAndFeel::SetData(std::move(aLookAndFeelData)); LookAndFeel::NotifyChangedAllWindows(aKind); return IPC_OK(); } diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index 094cc048ea76..215d616894d0 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -58,8 +58,6 @@ namespace widget { enum class ThemeChangeKind : uint8_t; } -using mozilla::loader::PScriptCacheChild; - #if !defined(XP_WIN) // Returns whether or not the currently running build is an unpackaged // developer build. This check is implemented by looking for omni.ja in the @@ -297,7 +295,7 @@ class ContentChild final : public PContentChild, mozilla::ipc::IPCResult RecvNotifyVisited(nsTArray&&); - mozilla::ipc::IPCResult RecvThemeChanged(LookAndFeelData&& aLookAndFeelData, + mozilla::ipc::IPCResult RecvThemeChanged(FullLookAndFeel&&, widget::ThemeChangeKind); mozilla::ipc::IPCResult RecvUpdateSystemParameters( @@ -535,7 +533,7 @@ class ContentChild final : public PContentChild, mozilla::ipc::IPCResult RecvSetXPCOMProcessAttributes( XPCOMInitData&& aXPCOMInit, const StructuredCloneData& aInitialData, - LookAndFeelData&& aLookAndFeelData, + FullLookAndFeel&& aLookAndFeelData, nsTArray&& aFontList, const Maybe& aSharedUASheetHandle, const uintptr_t& aSharedUASheetAddress, @@ -597,7 +595,7 @@ class ContentChild final : public PContentChild, bool DeallocPSessionStorageObserverChild( PSessionStorageObserverChild* aActor); - LookAndFeelData& BorrowLookAndFeelData() { return mLookAndFeelData; } + FullLookAndFeel& BorrowLookAndFeelData() { return mLookAndFeelData; } /** * Helper function for protocols that use the GPU process when available. @@ -858,7 +856,7 @@ class ContentChild final : public PContentChild, // only on MacOSX and Linux. nsTArray mFontList; // Temporary storage for look and feel data. - LookAndFeelData mLookAndFeelData; + FullLookAndFeel mLookAndFeelData; // Temporary storage for list of shared-fontlist memory blocks. nsTArray mSharedFontListBlocks; diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index aeaae7bc73ba..7d76dd93a80c 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -1642,18 +1642,10 @@ void ContentParent::BroadcastFontListChanged() { } } -static LookAndFeelData GetLookAndFeelData() { - if (StaticPrefs::widget_remote_look_and_feel_AtStartup()) { - return *RemoteLookAndFeel::ExtractData(); - } - return LookAndFeel::GetCache(); -} - void ContentParent::BroadcastThemeUpdate(widget::ThemeChangeKind aKind) { - LookAndFeelData lnfData = GetLookAndFeelData(); - + const FullLookAndFeel& lnf = *RemoteLookAndFeel::ExtractData(); for (auto* cp : AllProcesses(eLive)) { - Unused << cp->SendThemeChanged(lnfData, aKind); + Unused << cp->SendThemeChanged(lnf, aKind); } } @@ -2908,7 +2900,7 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) { nsTArray fontList; gfxPlatform::GetPlatform()->ReadSystemFontList(&fontList); - LookAndFeelData lnfData = GetLookAndFeelData(); + const FullLookAndFeel& lnf = *RemoteLookAndFeel::ExtractData(); // If the shared fontlist is in use, collect its shmem block handles to pass // to the child. @@ -2969,7 +2961,7 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) { } Unused << SendSetXPCOMProcessAttributes( - xpcomInit, initialData, lnfData, fontList, sharedUASheetHandle, + xpcomInit, initialData, lnf, fontList, sharedUASheetHandle, sharedUASheetAddress, sharedFontListBlocks); ipc::WritableSharedMap* sharedData = diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index aaf4ac5e1bd8..18f01bff5b6f 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -583,7 +583,7 @@ child: * Tell the child that the system theme has changed, and that a repaint is * necessary. */ - async ThemeChanged(LookAndFeelData lookAndFeelData, ThemeChangeKind aKind); + async ThemeChanged(FullLookAndFeel lookAndFeelData, ThemeChangeKind aKind); async UpdateSystemParameters(SystemParameterKVPair[] aUpdates); @@ -693,7 +693,7 @@ child: async SetXPCOMProcessAttributes(XPCOMInitData xpcomInit, StructuredCloneData initialData, - LookAndFeelData lookAndFeeldata, + FullLookAndFeel lookAndFeeldata, /* used on MacOSX/Linux/Android only: */ SystemFontListEntry[] systemFontList, SharedMemoryHandle? sharedUASheetHandle, diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index af99593cfc3c..f5801757dfcd 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -11034,15 +11034,6 @@ mirror: always #endif -# Enable the RemoteLookAndFeel in content processes, which will cause all -# LookAndFeel values to be queried in the parent process and sent to content -# processes using IPC. This is required for widgets to paint and behave -# correctly when `security.sandbox.content.headless` is enabled. -- name: widget.remote-look-and-feel - type: bool - value: true - mirror: once - #--------------------------------------------------------------------------- # Prefs starting with "xul." #--------------------------------------------------------------------------- diff --git a/widget/LookAndFeel.h b/widget/LookAndFeel.h index 41a3ed5c1a05..84b27e2009f0 100644 --- a/widget/LookAndFeel.h +++ b/widget/LookAndFeel.h @@ -22,7 +22,6 @@ namespace mozilla { namespace widget { class FullLookAndFeel; -class LookAndFeelCache; } // namespace widget enum class StyleSystemColor : uint8_t; @@ -538,12 +537,6 @@ class LookAndFeel { */ static void NativeInit(); - /** - * If the implementation is caching values, these accessors allow the - * cache to be exported and imported. - */ - static widget::LookAndFeelCache GetCache(); - static void SetCache(const widget::LookAndFeelCache& aCache); static void SetData(widget::FullLookAndFeel&& aTables); static void NotifyChangedAllWindows(widget::ThemeChangeKind); }; diff --git a/widget/LookAndFeelTypes.ipdlh b/widget/LookAndFeelTypes.ipdlh index 3539d3aacb74..ff70225b0429 100644 --- a/widget/LookAndFeelTypes.ipdlh +++ b/widget/LookAndFeelTypes.ipdlh @@ -4,18 +4,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -using mozilla::LookAndFeel::IntID from "mozilla/widget/WidgetMessageUtils.h"; -using mozilla::LookAndFeel::ColorID from "mozilla/widget/WidgetMessageUtils.h"; using nscolor from "nsColor.h"; namespace mozilla { namespace widget { -struct LookAndFeelInt { - IntID id; - int32_t value; -}; - [Comparable] struct LookAndFeelFont { bool haveFont; nsString name; @@ -24,17 +17,6 @@ struct LookAndFeelInt { bool italic; }; -struct LookAndFeelColor { - ColorID id; - nscolor color; -}; - -struct LookAndFeelCache { - LookAndFeelInt[] mInts; - LookAndFeelFont[] mFonts; - LookAndFeelColor[] mColors; -}; - /** * The format allows for some compression compared with having fixed * length arrays for each value type and some indication of whether @@ -85,10 +67,5 @@ struct FullLookAndFeel { #endif }; -union LookAndFeelData { - LookAndFeelCache; - FullLookAndFeel; -}; - } // namespace widget } // namespace mozilla diff --git a/widget/android/nsLookAndFeel.cpp b/widget/android/nsLookAndFeel.cpp index c9bb3d8b7b62..0ec254ac8130 100644 --- a/widget/android/nsLookAndFeel.cpp +++ b/widget/android/nsLookAndFeel.cpp @@ -20,11 +20,7 @@ using mozilla::dom::ContentChild; static const char16_t UNICODE_BULLET = 0x2022; -nsLookAndFeel::nsLookAndFeel(const LookAndFeelCache* aCache) { - if (aCache) { - DoSetCache(*aCache); - } -} +nsLookAndFeel::nsLookAndFeel() = default; nsLookAndFeel::~nsLookAndFeel() {} @@ -496,38 +492,3 @@ void nsLookAndFeel::EnsureInitShowPassword() { mInitializedShowPassword = true; } } - -widget::LookAndFeelCache nsLookAndFeel::GetCacheImpl() { - LookAndFeelCache cache = nsXPLookAndFeel::GetCacheImpl(); - - const IntID kIdsToCache[] = {IntID::PrefersReducedMotion, - IntID::SystemUsesDarkTheme}; - - for (IntID id : kIdsToCache) { - cache.mInts().AppendElement(LookAndFeelInt(id, GetInt(id))); - } - - return cache; -} - -void nsLookAndFeel::SetCacheImpl(const LookAndFeelCache& aCache) { - DoSetCache(aCache); -} - -void nsLookAndFeel::DoSetCache(const LookAndFeelCache& aCache) { - for (const auto& entry : aCache.mInts()) { - switch (entry.id()) { - case IntID::PrefersReducedMotion: - mPrefersReducedMotion = entry.value(); - mPrefersReducedMotionCached = true; - break; - case IntID::SystemUsesDarkTheme: - mSystemUsesDarkTheme = !!entry.value(); - mSystemUsesDarkThemeCached = true; - break; - default: - MOZ_ASSERT_UNREACHABLE("Bogus Int ID in cache"); - break; - } - } -} diff --git a/widget/android/nsLookAndFeel.h b/widget/android/nsLookAndFeel.h index 9d3edaca710a..f7903647ae3f 100644 --- a/widget/android/nsLookAndFeel.h +++ b/widget/android/nsLookAndFeel.h @@ -10,7 +10,7 @@ class nsLookAndFeel final : public nsXPLookAndFeel { public: - explicit nsLookAndFeel(const LookAndFeelCache* aCache); + explicit nsLookAndFeel(); virtual ~nsLookAndFeel(); void NativeInit() final; @@ -23,11 +23,7 @@ class nsLookAndFeel final : public nsXPLookAndFeel { virtual bool GetEchoPasswordImpl() override; virtual uint32_t GetPasswordMaskDelayImpl() override; virtual char16_t GetPasswordCharacterImpl() override; - LookAndFeelCache GetCacheImpl() override; - void SetCacheImpl(const LookAndFeelCache& aCache) override; - protected: - void DoSetCache(const LookAndFeelCache& aCache); bool mInitializedSystemColors = false; mozilla::AndroidSystemColors mSystemColors; diff --git a/widget/cocoa/nsLookAndFeel.h b/widget/cocoa/nsLookAndFeel.h index b0189c37b95b..903ddacf81fe 100644 --- a/widget/cocoa/nsLookAndFeel.h +++ b/widget/cocoa/nsLookAndFeel.h @@ -9,7 +9,7 @@ class nsLookAndFeel final : public nsXPLookAndFeel { public: - explicit nsLookAndFeel(const LookAndFeelCache* aCache); + nsLookAndFeel(); virtual ~nsLookAndFeel(); void NativeInit() final; @@ -27,11 +27,7 @@ class nsLookAndFeel final : public nsXPLookAndFeel { static bool UseOverlayScrollbars(); - LookAndFeelCache GetCacheImpl() override; - void SetCacheImpl(const LookAndFeelCache& aCache) override; - protected: - void DoSetCache(const LookAndFeelCache& aCache); static bool AllowOverlayScrollbarsOverlap(); static bool SystemWantsDarkTheme(); diff --git a/widget/cocoa/nsLookAndFeel.mm b/widget/cocoa/nsLookAndFeel.mm index 1eb54794e0cc..870296242f52 100644 --- a/widget/cocoa/nsLookAndFeel.mm +++ b/widget/cocoa/nsLookAndFeel.mm @@ -46,7 +46,7 @@ using NSAppearanceName = NSString*; static void RegisterRespectSystemAppearancePrefListenerOnce(); -nsLookAndFeel::nsLookAndFeel(const LookAndFeelCache* aCache) +nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel(), mUseOverlayScrollbars(-1), mUseOverlayScrollbarsCached(false), @@ -86,9 +86,6 @@ nsLookAndFeel::nsLookAndFeel(const LookAndFeelCache* aCache) mColorSourceListSelectionFontSmoothingBg(0), mColorActiveSourceListSelectionFontSmoothingBg(0), mInitialized(false) { - if (aCache) { - DoSetCache(*aCache); - } RegisterRespectSystemAppearancePrefListenerOnce(); } @@ -677,159 +674,6 @@ bool nsLookAndFeel::NativeGetFont(FontID aID, nsString& aFontName, gfxFontStyle& NS_OBJC_END_TRY_BLOCK_RETURN(false); } -mozilla::widget::LookAndFeelCache nsLookAndFeel::GetCacheImpl() { - LookAndFeelCache cache = nsXPLookAndFeel::GetCacheImpl(); - - constexpr IntID kIntIdsToCache[] = { - IntID::UseOverlayScrollbars, IntID::AllowOverlayScrollbarsOverlap, - IntID::PrefersReducedMotion, IntID::SystemUsesDarkTheme, IntID::UseAccessibilityTheme}; - - constexpr ColorID kColorIdsToCache[] = { - ColorID::Highlight, - ColorID::Highlighttext, - ColorID::Menutext, - ColorID::TextSelectBackground, - ColorID::TextSelectBackgroundDisabled, - ColorID::TextSelectForeground, - ColorID::Windowtext, - ColorID::Activecaption, - ColorID::Activeborder, - ColorID::Graytext, - ColorID::Inactiveborder, - ColorID::Scrollbar, - ColorID::Threedhighlight, - ColorID::Fieldtext, - ColorID::MozDialog, - ColorID::MozDragtargetzone, - ColorID::MozMacChromeActive, - ColorID::MozMacChromeInactive, - ColorID::MozMacFocusring, - ColorID::MozMacMenutextselect, - ColorID::MozMacDisabledtoolbartext, - ColorID::MozMacMenuselect, - ColorID::MozCellhighlight, - ColorID::MozEventreerow, - ColorID::MozOddtreerow, - ColorID::MozMacMenupopup, - ColorID::MozMacSourceList, - ColorID::MozMacSourceListSelection, - ColorID::MozMacActiveMenuitem, - }; - - for (IntID id : kIntIdsToCache) { - cache.mInts().AppendElement(LookAndFeelInt(id, GetInt(id))); - } - - for (ColorID id : kColorIdsToCache) { - nscolor color = 0; - NativeGetColor(id, color); - cache.mColors().AppendElement(LookAndFeelColor(id, color)); - } - - return cache; -} - -void nsLookAndFeel::SetCacheImpl(const LookAndFeelCache& aCache) { DoSetCache(aCache); } - -void nsLookAndFeel::DoSetCache(const LookAndFeelCache& aCache) { - for (auto entry : aCache.mInts()) { - switch (entry.id()) { - case IntID::UseOverlayScrollbars: - mUseOverlayScrollbars = entry.value(); - mUseOverlayScrollbarsCached = true; - break; - case IntID::AllowOverlayScrollbarsOverlap: - mAllowOverlayScrollbarsOverlap = entry.value(); - mAllowOverlayScrollbarsOverlapCached = true; - break; - case IntID::SystemUsesDarkTheme: - mSystemUsesDarkTheme = entry.value(); - mSystemUsesDarkThemeCached = true; - break; - case IntID::PrefersReducedMotion: - mPrefersReducedMotion = entry.value(); - mPrefersReducedMotionCached = true; - break; - case IntID::UseAccessibilityTheme: - mUseAccessibilityTheme = entry.value(); - mUseAccessibilityThemeCached = true; - break; - default: - MOZ_ASSERT_UNREACHABLE("Bogus Int ID in cache"); - break; - } - } - for (const auto& entry : aCache.mColors()) { - nscolor& slot = [&]() -> nscolor& { - switch (entry.id()) { - case ColorID::Highlight: - return mColorHighlight; - case ColorID::Highlighttext: - return mColorAlternateSelectedControlText; - case ColorID::Menutext: - return mColorText; - case ColorID::TextSelectBackground: - return mColorTextSelectBackground; - case ColorID::TextSelectBackgroundDisabled: - return mColorTextSelectBackgroundDisabled; - case ColorID::TextSelectForeground: - return mColorTextSelectForeground; - case ColorID::Windowtext: - return mColorWindowText; - case ColorID::Activecaption: - return mColorGrid; - case ColorID::Activeborder: - return mColorActiveBorder; - case ColorID::Graytext: - return mColorGrayText; - case ColorID::Inactiveborder: - return mColorControlBackground; - case ColorID::Scrollbar: - return mColorScrollbar; - case ColorID::Threedhighlight: - return mColorThreeDHighlight; - case ColorID::Fieldtext: - return mColorControlText; - case ColorID::MozDialog: - return mColorDialog; - case ColorID::MozDragtargetzone: - return mColorDragTargetZone; - case ColorID::MozMacChromeActive: - return mColorChromeActive; - case ColorID::MozMacChromeInactive: - return mColorChromeInactive; - case ColorID::MozMacFocusring: - return mColorFocusRing; - case ColorID::MozMacMenutextselect: - return mColorTextSelect; - case ColorID::MozMacDisabledtoolbartext: - return mColorDisabledToolbarText; - case ColorID::MozMacMenuselect: - return mColorMenuSelect; - case ColorID::MozCellhighlight: - return mColorCellHighlight; - case ColorID::MozEventreerow: - return mColorEvenTreeRow; - case ColorID::MozOddtreerow: - return mColorOddTreeRow; - case ColorID::MozMacMenupopup: - return mColorMenuFontSmoothingBg; - case ColorID::MozMacSourceList: - return mColorSourceListFontSmoothingBg; - case ColorID::MozMacSourceListSelection: - return mColorSourceListSelectionFontSmoothingBg; - case ColorID::MozMacActiveMenuitem: - return mColorActiveSourceListSelectionFontSmoothingBg; - default: - MOZ_ASSERT_UNREACHABLE("Unknown color in the cache"); - return mColorOddTreeRow; - } - }(); - slot = entry.color(); - } - mInitialized = true; -} - void nsLookAndFeel::EnsureInit() { if (mInitialized) { return; diff --git a/widget/gtk/nsLookAndFeel.cpp b/widget/gtk/nsLookAndFeel.cpp index 0df8718706e2..cf6c26a4dfd1 100644 --- a/widget/gtk/nsLookAndFeel.cpp +++ b/widget/gtk/nsLookAndFeel.cpp @@ -60,11 +60,7 @@ extern mozilla::LazyLogModule gWidgetLog; ((nscolor)NS_RGBA((int)((c).red * 255), (int)((c).green * 255), \ (int)((c).blue * 255), (int)((c).alpha * 255))) -nsLookAndFeel::nsLookAndFeel(const LookAndFeelCache* aCache) { - if (aCache) { - DoSetCache(*aCache); - } -} +nsLookAndFeel::nsLookAndFeel() = default; nsLookAndFeel::~nsLookAndFeel() = default; @@ -273,80 +269,6 @@ void nsLookAndFeel::RefreshImpl() { mInitialized = false; } -widget::LookAndFeelCache nsLookAndFeel::GetCacheImpl() { - LookAndFeelCache cache = nsXPLookAndFeel::GetCacheImpl(); - - constexpr IntID kIntIdsToCache[] = {IntID::SystemUsesDarkTheme, - IntID::PrefersReducedMotion, - IntID::UseAccessibilityTheme}; - - constexpr ColorID kColorIdsToCache[] = { - ColorID::ThemedScrollbar, - ColorID::ThemedScrollbarInactive, - ColorID::ThemedScrollbarThumb, - ColorID::ThemedScrollbarThumbHover, - ColorID::ThemedScrollbarThumbActive, - ColorID::ThemedScrollbarThumbInactive}; - - for (IntID id : kIntIdsToCache) { - cache.mInts().AppendElement(LookAndFeelInt(id, GetInt(id))); - } - - for (ColorID id : kColorIdsToCache) { - cache.mColors().AppendElement(LookAndFeelColor(id, GetColor(id))); - } - - return cache; -} - -void nsLookAndFeel::SetCacheImpl(const LookAndFeelCache& aCache) { - DoSetCache(aCache); -} - -void nsLookAndFeel::DoSetCache(const LookAndFeelCache& aCache) { - for (const auto& entry : aCache.mInts()) { - switch (entry.id()) { - case IntID::SystemUsesDarkTheme: - mSystemUsesDarkTheme = entry.value(); - break; - case IntID::PrefersReducedMotion: - mPrefersReducedMotion = entry.value(); - break; - case IntID::UseAccessibilityTheme: - mHighContrast = entry.value(); - break; - default: - MOZ_ASSERT_UNREACHABLE("Bogus Int ID in cache"); - break; - } - } - for (const auto& entry : aCache.mColors()) { - switch (entry.id()) { - case ColorID::ThemedScrollbar: - mThemedScrollbar = entry.color(); - break; - case ColorID::ThemedScrollbarInactive: - mThemedScrollbarInactive = entry.color(); - break; - case ColorID::ThemedScrollbarThumb: - mThemedScrollbarThumb = entry.color(); - break; - case ColorID::ThemedScrollbarThumbHover: - mThemedScrollbarThumbHover = entry.color(); - break; - case ColorID::ThemedScrollbarThumbActive: - mThemedScrollbarThumbActive = entry.color(); - break; - case ColorID::ThemedScrollbarThumbInactive: - mThemedScrollbarThumbInactive = entry.color(); - break; - default: - MOZ_ASSERT_UNREACHABLE("Bogus Color ID in cache"); - break; - } - } -} - static bool IsSelectionColorForeground(LookAndFeel::ColorID aID) { using ColorID = LookAndFeel::ColorID; switch (aID) { @@ -1106,9 +1028,6 @@ bool nsLookAndFeel::FromParentTheme(IntID aID) { // // This ensures that media queries like (prefers-color-scheme: dark) will // match correctly in content processes. - // - // (When the RemoteLookAndFeel is not in use, the LookAndFeelCache ensures - // we get these values from the parent process theme.) return true; default: return false; @@ -1230,7 +1149,7 @@ void nsLookAndFeel::EnsureInit() { g_object_get(settings, "gtk-enable-animations", &enableAnimations, nullptr); mPrefersReducedMotion = !enableAnimations; - // Colors that we pass to content processes through the LookAndFeelCache. + // Colors that we pass to content processes through RemoteLookAndFeel. if (ShouldHonorThemeScrollbarColors()) { // Some themes style the , while others style the // itself, so we look at both and compose the colors. diff --git a/widget/gtk/nsLookAndFeel.h b/widget/gtk/nsLookAndFeel.h index f8592071713b..ab997290b025 100644 --- a/widget/gtk/nsLookAndFeel.h +++ b/widget/gtk/nsLookAndFeel.h @@ -18,7 +18,7 @@ struct _GtkStyle; class nsLookAndFeel final : public nsXPLookAndFeel { public: - explicit nsLookAndFeel(const LookAndFeelCache* aCache); + nsLookAndFeel(); virtual ~nsLookAndFeel(); void NativeInit() final; @@ -32,9 +32,6 @@ class nsLookAndFeel final : public nsXPLookAndFeel { char16_t GetPasswordCharacterImpl() override; bool GetEchoPasswordImpl() override; - LookAndFeelCache GetCacheImpl() override; - void SetCacheImpl(const LookAndFeelCache& aCache) override; - void WithThemeConfiguredForContent( const std::function& aFn) override; bool FromParentTheme(IntID) override; @@ -48,7 +45,6 @@ class nsLookAndFeel final : public nsXPLookAndFeel { static const nscolor kWhite = NS_RGB(255, 255, 255); protected: - void DoSetCache(const LookAndFeelCache& aCache); bool WidgetUsesImage(WidgetNodeType aNodeType); void RecordLookAndFeelSpecificTelemetry() override; bool ShouldHonorThemeScrollbarColors(); diff --git a/widget/headless/HeadlessLookAndFeel.h b/widget/headless/HeadlessLookAndFeel.h index 8b6cf033fddb..693098d48370 100644 --- a/widget/headless/HeadlessLookAndFeel.h +++ b/widget/headless/HeadlessLookAndFeel.h @@ -23,10 +23,6 @@ namespace widget { // // * in the parent process, when full headless mode (MOZ_HEADLESS=1) is // enabled -// * in content processes, when full headless mode or headless content -// mode (security.sandbox.content.headless) is enabled, unless -// widget.remote-look-and-feel is also enabled, in which case -// RemoteLookAndFeel is used instead. // // The result of this is that when headless content mode is enabled, content // processes use values derived from the parent's nsLookAndFeel (i.e., values @@ -35,7 +31,7 @@ namespace widget { class HeadlessLookAndFeel : public nsXPLookAndFeel { public: - explicit HeadlessLookAndFeel(const LookAndFeelCache* aCache); + explicit HeadlessLookAndFeel(); virtual ~HeadlessLookAndFeel(); void NativeInit() final{}; diff --git a/widget/headless/HeadlessLookAndFeelGTK.cpp b/widget/headless/HeadlessLookAndFeelGTK.cpp index bc40f7d66542..1ea92b18d0d0 100644 --- a/widget/headless/HeadlessLookAndFeelGTK.cpp +++ b/widget/headless/HeadlessLookAndFeelGTK.cpp @@ -8,14 +8,11 @@ #include "mozilla/FontPropertyTypes.h" #include "nsIContent.h" -using mozilla::LookAndFeel; - -namespace mozilla { -namespace widget { +namespace mozilla::widget { static const char16_t UNICODE_BULLET = 0x2022; -HeadlessLookAndFeel::HeadlessLookAndFeel(const LookAndFeelCache* aCache) {} +HeadlessLookAndFeel::HeadlessLookAndFeel() {} HeadlessLookAndFeel::~HeadlessLookAndFeel() = default; @@ -363,5 +360,4 @@ void HeadlessLookAndFeel::RefreshImpl() { nsXPLookAndFeel::RefreshImpl(); } bool HeadlessLookAndFeel::GetEchoPasswordImpl() { return false; } -} // namespace widget -} // namespace mozilla +} // namespace mozilla::widget diff --git a/widget/nsXPLookAndFeel.cpp b/widget/nsXPLookAndFeel.cpp index 1d3e6898545f..961596c8fe89 100644 --- a/widget/nsXPLookAndFeel.cpp +++ b/widget/nsXPLookAndFeel.cpp @@ -322,41 +322,28 @@ nsXPLookAndFeel* nsXPLookAndFeel::GetInstance() { NS_ENSURE_TRUE(!sShutdown, nullptr); // If we're in a content process, then the parent process will have supplied - // us with an initial FullLookAndFeel object (for when the RemoteLookAndFeel - // is to be used) or an initial LookAndFeelCache object (for regular - // LookAndFeel implementations). We grab this data from the ContentChild, + // us with an initial FullLookAndFeel object. + // We grab this data from the ContentChild, // where it's been temporarily stashed, and initialize our new LookAndFeel // object with it. - LookAndFeelCache* lnfCache = nullptr; - FullLookAndFeel* fullLnf = nullptr; - widget::LookAndFeelData* lnfData = nullptr; + FullLookAndFeel* lnf = nullptr; if (auto* cc = mozilla::dom::ContentChild::GetSingleton()) { - lnfData = &cc->BorrowLookAndFeelData(); - switch (lnfData->type()) { - case widget::LookAndFeelData::TLookAndFeelCache: - lnfCache = &lnfData->get_LookAndFeelCache(); - break; - case widget::LookAndFeelData::TFullLookAndFeel: - fullLnf = &lnfData->get_FullLookAndFeel(); - break; - default: - MOZ_ASSERT_UNREACHABLE("unexpected LookAndFeelData type"); - } + lnf = &cc->BorrowLookAndFeelData(); } - if (fullLnf) { - sInstance = new widget::RemoteLookAndFeel(std::move(*fullLnf)); + if (lnf) { + sInstance = new widget::RemoteLookAndFeel(std::move(*lnf)); } else if (gfxPlatform::IsHeadless()) { - sInstance = new widget::HeadlessLookAndFeel(lnfCache); + sInstance = new widget::HeadlessLookAndFeel(); } else { - sInstance = new nsLookAndFeel(lnfCache); + sInstance = new nsLookAndFeel(); } // This is only ever used once during initialization, and can be cleared now. - if (lnfData) { - *lnfData = widget::LookAndFeelData{}; + if (lnf) { + *lnf = {}; } nsNativeBasicTheme::Init(); @@ -1029,10 +1016,6 @@ void nsXPLookAndFeel::RefreshImpl() { } } -widget::LookAndFeelCache nsXPLookAndFeel::GetCacheImpl() { - return LookAndFeelCache{}; -} - static bool sRecordedLookAndFeelTelemetry = false; void nsXPLookAndFeel::RecordTelemetry() { @@ -1121,16 +1104,6 @@ void LookAndFeel::Refresh() { // static void LookAndFeel::NativeInit() { nsLookAndFeel::GetInstance()->NativeInit(); } -// static -widget::LookAndFeelCache LookAndFeel::GetCache() { - return nsLookAndFeel::GetInstance()->GetCacheImpl(); -} - -// static -void LookAndFeel::SetCache(const widget::LookAndFeelCache& aCache) { - nsLookAndFeel::GetInstance()->SetCacheImpl(aCache); -} - // static void LookAndFeel::SetData(widget::FullLookAndFeel&& aTables) { nsLookAndFeel::GetInstance()->SetDataImpl(std::move(aTables)); diff --git a/widget/nsXPLookAndFeel.h b/widget/nsXPLookAndFeel.h index aa58bbfd9c01..f9b48133fa43 100644 --- a/widget/nsXPLookAndFeel.h +++ b/widget/nsXPLookAndFeel.h @@ -15,10 +15,7 @@ class nsLookAndFeel; class nsXPLookAndFeel : public mozilla::LookAndFeel { public: using FullLookAndFeel = mozilla::widget::FullLookAndFeel; - using LookAndFeelCache = mozilla::widget::LookAndFeelCache; - using LookAndFeelInt = mozilla::widget::LookAndFeelInt; using LookAndFeelFont = mozilla::widget::LookAndFeelFont; - using LookAndFeelColor = mozilla::widget::LookAndFeelColor; using LookAndFeelTheme = mozilla::widget::LookAndFeelTheme; virtual ~nsXPLookAndFeel(); @@ -61,8 +58,6 @@ class nsXPLookAndFeel : public mozilla::LookAndFeel { static LookAndFeelFont StyleToLookAndFeelFont(const nsAString& aName, const gfxFontStyle&); - virtual LookAndFeelCache GetCacheImpl(); - virtual void SetCacheImpl(const LookAndFeelCache& aCache) {} virtual void SetDataImpl(FullLookAndFeel&& aTables) {} virtual void NativeInit() = 0; diff --git a/widget/uikit/nsLookAndFeel.h b/widget/uikit/nsLookAndFeel.h index 0f3d628096cd..a1afbe148ff3 100644 --- a/widget/uikit/nsLookAndFeel.h +++ b/widget/uikit/nsLookAndFeel.h @@ -10,7 +10,7 @@ class nsLookAndFeel final : public nsXPLookAndFeel { public: - explicit nsLookAndFeel(const LookAndFeelCache* aCache); + nsLookAndFeel(); virtual ~nsLookAndFeel(); void NativeInit() final; diff --git a/widget/uikit/nsLookAndFeel.mm b/widget/uikit/nsLookAndFeel.mm index 3351a6eb2318..4a20765122cd 100644 --- a/widget/uikit/nsLookAndFeel.mm +++ b/widget/uikit/nsLookAndFeel.mm @@ -13,7 +13,7 @@ #include "gfxFont.h" #include "gfxFontConstants.h" -nsLookAndFeel::nsLookAndFeel(LookAndFeelCache* aCache) : nsXPLookAndFeel(), mInitialized(false) {} +nsLookAndFeel::nsLookAndFeel() : mInitialized(false) {} nsLookAndFeel::~nsLookAndFeel() {} diff --git a/widget/windows/nsLookAndFeel.cpp b/widget/windows/nsLookAndFeel.cpp index 181eeb12e5f9..be1cf9d62aae 100644 --- a/widget/windows/nsLookAndFeel.cpp +++ b/widget/windows/nsLookAndFeel.cpp @@ -89,7 +89,7 @@ static nsresult SystemWantsDarkTheme(int32_t& darkThemeEnabled) { return rv; } -nsLookAndFeel::nsLookAndFeel(const LookAndFeelCache* aCache) +nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel(), mUseAccessibilityTheme(0), mUseDefaultTheme(0), @@ -103,9 +103,6 @@ nsLookAndFeel::nsLookAndFeel(const LookAndFeelCache* aCache) mInitialized(false) { mozilla::Telemetry::Accumulate(mozilla::Telemetry::TOUCH_ENABLED_DEVICE, WinUtils::IsTouchDeviceSupportPresent()); - if (aCache) { - DoSetCache(*aCache); - } } nsLookAndFeel::~nsLookAndFeel() {} @@ -832,77 +829,6 @@ char16_t nsLookAndFeel::GetPasswordCharacterImpl() { return UNICODE_BLACK_CIRCLE_CHAR; } -LookAndFeelCache nsLookAndFeel::GetCacheImpl() { - MOZ_ASSERT(XRE_IsParentProcess()); - - LookAndFeelCache cache = nsXPLookAndFeel::GetCacheImpl(); - - LookAndFeelInt lafInt; - lafInt.id() = IntID::UseAccessibilityTheme; - lafInt.value() = GetInt(IntID::UseAccessibilityTheme); - cache.mInts().AppendElement(lafInt); - - lafInt.id() = IntID::WindowsDefaultTheme; - lafInt.value() = GetInt(IntID::WindowsDefaultTheme); - cache.mInts().AppendElement(lafInt); - - lafInt.id() = IntID::WindowsThemeIdentifier; - lafInt.value() = GetInt(IntID::WindowsThemeIdentifier); - cache.mInts().AppendElement(lafInt); - - lafInt.id() = IntID::PrimaryPointerCapabilities; - lafInt.value() = GetInt(IntID::PrimaryPointerCapabilities); - cache.mInts().AppendElement(lafInt); - - lafInt.id() = IntID::AllPointerCapabilities; - lafInt.value() = GetInt(IntID::AllPointerCapabilities); - cache.mInts().AppendElement(lafInt); - - for (auto id : mozilla::MakeEnumeratedRange(LookAndFeel::FontID::End)) { - cache.mFonts().AppendElement(GetLookAndFeelFont(id)); - } - - return cache; -} - -void nsLookAndFeel::SetCacheImpl(const LookAndFeelCache& aCache) { - DoSetCache(aCache); -} - -void nsLookAndFeel::DoSetCache(const LookAndFeelCache& aCache) { - MOZ_ASSERT(XRE_IsContentProcess()); - MOZ_RELEASE_ASSERT(aCache.mFonts().Length() == FontCache::kSize); - - for (auto entry : aCache.mInts()) { - switch (entry.id()) { - case IntID::UseAccessibilityTheme: - mUseAccessibilityTheme = entry.value(); - break; - case IntID::WindowsDefaultTheme: - mUseDefaultTheme = entry.value(); - break; - case IntID::WindowsThemeIdentifier: - mNativeThemeId = entry.value(); - break; - case IntID::PrimaryPointerCapabilities: - mPrimaryPointerCapabilities = entry.value(); - break; - case IntID::AllPointerCapabilities: - mAllPointerCapabilities = entry.value(); - break; - default: - MOZ_ASSERT_UNREACHABLE("Bogus Int ID in cache"); - break; - } - } - - size_t i = 0; - for (const auto& font : aCache.mFonts()) { - mFontCache[FontID(i)] = font; - ++i; - } -} - /* static */ nsresult nsLookAndFeel::GetAccentColor(nscolor& aColor) { nsresult rv; diff --git a/widget/windows/nsLookAndFeel.h b/widget/windows/nsLookAndFeel.h index 93e857f40c5b..d63470c7580f 100644 --- a/widget/windows/nsLookAndFeel.h +++ b/widget/windows/nsLookAndFeel.h @@ -47,7 +47,7 @@ class nsLookAndFeel final : public nsXPLookAndFeel { static OperatingSystemVersion GetOperatingSystemVersion(); public: - explicit nsLookAndFeel(const LookAndFeelCache* aCache); + nsLookAndFeel(); virtual ~nsLookAndFeel(); void NativeInit() final; @@ -59,9 +59,6 @@ class nsLookAndFeel final : public nsXPLookAndFeel { gfxFontStyle& aFontStyle) override; char16_t GetPasswordCharacterImpl() override; - LookAndFeelCache GetCacheImpl() override; - void SetCacheImpl(const LookAndFeelCache& aCache) override; - private: enum CachedValueKind { PrimaryPointerCapabilitiesKind, @@ -69,8 +66,6 @@ class nsLookAndFeel final : public nsXPLookAndFeel { CachedValueKindMax = AllPointerCapabilitiesKind, }; - void DoSetCache(const LookAndFeelCache& aCache); - /** * Fetches the Windows accent color from the Windows settings if * the accent color is set to apply to the title bar, otherwise