diff --git a/dom/base/Selection.cpp b/dom/base/Selection.cpp index 6d376ede21e9..4754bbade9cf 100644 --- a/dom/base/Selection.cpp +++ b/dom/base/Selection.cpp @@ -900,8 +900,7 @@ nsresult Selection::AddRangesForUserSelectableNodes( // pref, disabled by default. // See https://github.com/w3c/selection-api/issues/53. const bool executeDefaultAction = MaybeDispatchSelectstartEvent( - *aRange, nsFrameSelection::sSelectionEventsOnTextControlsEnabled, - doc); + *aRange, StaticPrefs::dom_select_events_textcontrols_enabled(), doc); if (!executeDefaultAction) { return NS_OK; diff --git a/dom/base/SelectionChangeEventDispatcher.cpp b/dom/base/SelectionChangeEventDispatcher.cpp index 4c63d7b7de51..f53637081dfd 100644 --- a/dom/base/SelectionChangeEventDispatcher.cpp +++ b/dom/base/SelectionChangeEventDispatcher.cpp @@ -124,7 +124,7 @@ void SelectionChangeEventDispatcher::OnSelectionChange(Document* aDoc, // controls, so for now we only support doing that under a pref, disabled by // default. // See https://github.com/w3c/selection-api/issues/53. - if (nsFrameSelection::sSelectionEventsOnTextControlsEnabled) { + if (StaticPrefs::dom_select_events_textcontrols_enabled()) { nsCOMPtr target; // Check if we should be firing this event to a different node than the diff --git a/layout/generic/nsFrameSelection.cpp b/layout/generic/nsFrameSelection.cpp index 5e5e63de5915..fdc69977d513 100644 --- a/layout/generic/nsFrameSelection.cpp +++ b/layout/generic/nsFrameSelection.cpp @@ -339,14 +339,6 @@ nsFrameSelection::nsFrameSelection(PresShell* aPresShell, nsIContent* aLimiter, // This should only ever be initialized on the main thread, so we are OK here. MOZ_ASSERT(NS_IsMainThread()); - static bool prefCachesInitialized = false; - if (!prefCachesInitialized) { - prefCachesInitialized = true; - - Preferences::AddBoolVarCache(&sSelectionEventsOnTextControlsEnabled, - "dom.select_events.textcontrols.enabled", - false); - } mAccessibleCaretEnabled = aAccessibleCaretEnabled; if (mAccessibleCaretEnabled) { @@ -355,9 +347,9 @@ nsFrameSelection::nsFrameSelection(PresShell* aPresShell, nsIContent* aLimiter, } bool plaintextControl = (aLimiter != nullptr); - bool initSelectEvents = plaintextControl - ? sSelectionEventsOnTextControlsEnabled - : StaticPrefs::dom_select_events_enabled(); + bool initSelectEvents = + plaintextControl ? StaticPrefs::dom_select_events_textcontrols_enabled() + : StaticPrefs::dom_select_events_enabled(); Document* doc = aPresShell->GetDocument(); if (initSelectEvents || (doc && doc->NodePrincipal()->IsSystemPrincipal())) { @@ -643,8 +635,6 @@ static nsINode* GetCellParent(nsINode* aDomNode) { return nullptr; } -bool nsFrameSelection::sSelectionEventsOnTextControlsEnabled = false; - nsresult nsFrameSelection::MoveCaret(nsDirection aDirection, bool aContinueSelection, const nsSelectionAmount aAmount, diff --git a/layout/generic/nsFrameSelection.h b/layout/generic/nsFrameSelection.h index 218858e721ea..3b8cd531fcdf 100644 --- a/layout/generic/nsFrameSelection.h +++ b/layout/generic/nsFrameSelection.h @@ -928,8 +928,6 @@ class nsFrameSelection final { bool mDragState = false; // for drag purposes bool mAccessibleCaretEnabled = false; - - static bool sSelectionEventsOnTextControlsEnabled; }; #endif /* nsFrameSelection_h___ */ diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 771f9f00e8f8..99b6ee49292f 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -2475,6 +2475,12 @@ value: true mirror: always +# Whether or not selection events on text controls are enabled. +- name: dom.select_events.textcontrols.enabled + type: bool + value: @IS_NIGHTLY_BUILD@ + mirror: always + - name: dom.separate_event_queue_for_post_message.enabled type: bool value: true diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 0ab5a8b28e2b..ade3b4d78e46 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -255,13 +255,6 @@ pref("dom.indexedDB.logging.profiler-marks", false); // Whether or not File Handle is enabled. pref("dom.fileHandle.enabled", true); -// Whether or not selection events on text controls are enabled -#ifdef NIGHTLY_BUILD - pref("dom.select_events.textcontrols.enabled", true); -#else - pref("dom.select_events.textcontrols.enabled", false); -#endif - // The number of workers per domain allowed to run concurrently. // We're going for effectively infinite, while preventing abuse. pref("dom.workers.maxPerDomain", 512);