diff --git a/layout/base/AccessibleCaret.cpp b/layout/base/AccessibleCaret.cpp index 3a317782fe9e..ab6e2741d144 100644 --- a/layout/base/AccessibleCaret.cpp +++ b/layout/base/AccessibleCaret.cpp @@ -8,7 +8,7 @@ #include "AccessibleCaretLogger.h" #include "mozilla/FloatingPoint.h" -#include "mozilla/Preferences.h" +#include "mozilla/StaticPrefs.h" #include "mozilla/ToString.h" #include "nsCanvasFrame.h" #include "nsCaret.h" @@ -30,10 +30,6 @@ using namespace dom; NS_IMPL_ISUPPORTS(AccessibleCaret::DummyTouchListener, nsIDOMEventListener) -float AccessibleCaret::sWidth = 0.0f; -float AccessibleCaret::sHeight = 0.0f; -float AccessibleCaret::sMarginLeft = 0.0f; - NS_NAMED_LITERAL_STRING(AccessibleCaret::sTextOverlayElementId, "text-overlay"); NS_NAMED_LITERAL_STRING(AccessibleCaret::sCaretImageElementId, "image"); @@ -78,14 +74,6 @@ AccessibleCaret::AccessibleCaret(nsIPresShell* aPresShell) MOZ_ASSERT(mPresShell->GetDocument()); InjectCaretElement(mPresShell->GetDocument()); } - - static bool prefsAdded = false; - if (!prefsAdded) { - Preferences::AddFloatVarCache(&sWidth, "layout.accessiblecaret.width"); - Preferences::AddFloatVarCache(&sHeight, "layout.accessiblecaret.height"); - Preferences::AddFloatVarCache(&sMarginLeft, "layout.accessiblecaret.margin-left"); - prefsAdded = true; - } } AccessibleCaret::~AccessibleCaret() @@ -316,11 +304,12 @@ AccessibleCaret::SetCaretElementStyle(const nsRect& aRect, float aZoomLevel) nsPresContext::AppUnitsToIntCSSPixels(position.y)); // We can't use AppendPrintf here, because it does locale-specific // formatting of floating-point values. - styleStr.AppendFloat(sWidth/aZoomLevel); + styleStr.AppendFloat(StaticPrefs::layout_accessiblecaret_width() / aZoomLevel); styleStr.AppendLiteral("px; height: "); - styleStr.AppendFloat(sHeight/aZoomLevel); + styleStr.AppendFloat(StaticPrefs::layout_accessiblecaret_height() / aZoomLevel); styleStr.AppendLiteral("px; margin-left: "); - styleStr.AppendFloat(sMarginLeft/aZoomLevel); + styleStr.AppendFloat( + StaticPrefs::layout_accessiblecaret_margin_left() / aZoomLevel); styleStr.AppendLiteral("px"); CaretElement().SetAttr(kNameSpaceID_None, nsGkAtoms::style, styleStr, true); diff --git a/layout/base/AccessibleCaret.h b/layout/base/AccessibleCaret.h index b8a15de09e20..f21b20218aea 100644 --- a/layout/base/AccessibleCaret.h +++ b/layout/base/AccessibleCaret.h @@ -229,9 +229,6 @@ protected: RefPtr mDummyTouchListener{new DummyTouchListener()}; // Static class variables - static float sWidth; - static float sHeight; - static float sMarginLeft; static const nsLiteralString sTextOverlayElementId; static const nsLiteralString sCaretImageElementId; diff --git a/modules/libpref/init/StaticPrefList.h b/modules/libpref/init/StaticPrefList.h index 33dc9faed20a..381181255e5b 100644 --- a/modules/libpref/init/StaticPrefList.h +++ b/modules/libpref/init/StaticPrefList.h @@ -446,6 +446,26 @@ VARCACHE_PREF( // Layout prefs //--------------------------------------------------------------------------- +// CSS attributes (width, height, margin-left) of the AccessibleCaret in CSS +// pixels. +VARCACHE_PREF( + "layout.accessiblecaret.width", + layout_accessiblecaret_width, + float, 34.0f +) + +VARCACHE_PREF( + "layout.accessiblecaret.height", + layout_accessiblecaret_height, + float, 36.0f +) + +VARCACHE_PREF( + "layout.accessiblecaret.margin-left", + layout_accessiblecaret_margin_left, + float, -18.5f +) + // Is parallel CSS parsing enabled? VARCACHE_PREF( "layout.css.parsing.parallel", diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index a14f14a599fd..816718fdb5aa 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -5525,11 +5525,6 @@ pref("layout.accessiblecaret.enabled", false); // overriding the layout.accessiblecaret.enabled pref. pref("layout.accessiblecaret.enabled_on_touch", true); -// CSS attributes of the AccessibleCaret in CSS pixels. -pref("layout.accessiblecaret.width", "34.0"); -pref("layout.accessiblecaret.height", "36.0"); -pref("layout.accessiblecaret.margin-left", "-18.5"); - // Show the caret when long tapping on an empty content. pref("layout.accessiblecaret.caret_shown_when_long_tapping_on_empty_content", false);