From 07de26de179b62f9663e3cafff21874b55acf026 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Sun, 28 Jan 2024 05:57:50 +0000 Subject: [PATCH] Bug 1876811: Remove nsPresContext's cache for about:config pref "layout.scrollbar.side". r=TYLin Instead, just directly use the StaticPrefs getter for this pref at the one usage-site, and remove the now-unnecessary GetCachedIntPref getter and enum-parameter-type that was previously used to query the value. This patch doesn't change behavior. Differential Revision: https://phabricator.services.mozilla.com/D199782 --- layout/base/nsPresContext.cpp | 3 --- layout/base/nsPresContext.h | 19 ------------------- layout/generic/nsGfxScrollFrame.cpp | 4 +--- 3 files changed, 1 insertion(+), 25 deletions(-) diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index d9145a00b43e..0107f6fd6a00 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -274,7 +274,6 @@ nsPresContext::nsPresContext(dom::Document* aDocument, nsPresContextType aType) mCanPaginatedScroll(false), mDoScaledTwips(true), mIsRootPaginatedDocument(false), - mPrefScrollbarSide(0), mPendingThemeChanged(false), mPendingThemeChangeKind(0), mPendingUIResolutionChanged(false), @@ -432,8 +431,6 @@ void nsPresContext::GetUserPreferences() { PreferenceSheet::EnsureInitialized(); - mPrefScrollbarSide = StaticPrefs::layout_scrollbar_side(); - Document()->SetMayNeedFontPrefsUpdate(); // * image animation diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index 519e35d8e39e..bc4e70dbcf4a 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -101,9 +101,6 @@ class PaletteCache; } // namespace gfx } // namespace mozilla -// supported values for cached integer pref types -enum nsPresContext_CachedIntPrefType { kPresContext_ScrollbarSide = 1 }; - // IDs for the default variable and fixed fonts (not to be changed, see // nsFont.h) To be used for Get/SetDefaultFont(). The other IDs in nsFont.h are // also supported. @@ -376,21 +373,6 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr { */ void EmulateMedium(nsAtom* aMediaType); - /** Get a cached integer pref, by its type */ - // * - initially created for bugs 30910, 61883, 74186, 84398 - int32_t GetCachedIntPref(nsPresContext_CachedIntPrefType aPrefType) const { - // If called with a constant parameter, the compiler should optimize - // this switch statement away. - switch (aPrefType) { - case kPresContext_ScrollbarSide: - return mPrefScrollbarSide; - default: - NS_ERROR("invalid arg passed to GetCachedIntPref"); - } - - return false; - } - const mozilla::PreferenceSheet::Prefs& PrefSheetPrefs() const { return mozilla::PreferenceSheet::PrefsFor(*mDocument); } @@ -1352,7 +1334,6 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr { unsigned mCanPaginatedScroll : 1; unsigned mDoScaledTwips : 1; unsigned mIsRootPaginatedDocument : 1; - unsigned mPrefScrollbarSide : 2; unsigned mPendingThemeChanged : 1; // widget::ThemeChangeKind unsigned mPendingThemeChangeKind : kThemeChangeKindBits; diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 5eebebacc3fa..d8cfb3ba1800 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -6018,15 +6018,13 @@ nsSize nsHTMLScrollFrame::GetSnapportSize() const { } bool nsHTMLScrollFrame::IsScrollbarOnRight() const { - nsPresContext* presContext = PresContext(); - // The position of the scrollbar in top-level windows depends on the pref // layout.scrollbar.side. For non-top-level elements, it depends only on the // directionaliy of the element (equivalent to a value of "1" for the pref). if (!mIsRoot) { return IsPhysicalLTR(); } - switch (presContext->GetCachedIntPref(kPresContext_ScrollbarSide)) { + switch (StaticPrefs::layout_scrollbar_side()) { default: case 0: // UI directionality return StaticPrefs::bidi_direction() == IBMBIDI_TEXTDIRECTION_LTR;