Bug 1648944 - Part 1: Split select event flags into each event name r=masayuki

Differential Revision: https://phabricator.services.mozilla.com/D86700
This commit is contained in:
Kagami Sascha Rosylight 2021-07-20 13:46:44 +00:00
Родитель 7dbc091004
Коммит b09a40408c
5 изменённых файлов: 23 добавлений и 10 удалений

Просмотреть файл

@ -884,7 +884,9 @@ nsresult Selection::AddRangesForUserSelectableNodes(
// pref, disabled by default.
// See https://github.com/w3c/selection-api/issues/53.
const bool executeDefaultAction = MaybeDispatchSelectstartEvent(
*aRange, StaticPrefs::dom_select_events_textcontrols_enabled(), doc);
*aRange,
StaticPrefs::dom_select_events_textcontrols_selectstart_enabled(),
doc);
if (!executeDefaultAction) {
return NS_OK;

Просмотреть файл

@ -138,7 +138,8 @@ 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 (textControl && !StaticPrefs::dom_select_events_textcontrols_enabled()) {
if (textControl &&
!StaticPrefs::dom_select_events_textcontrols_selectionchange_enabled()) {
return;
}

Просмотреть файл

@ -2104,7 +2104,7 @@ void TextControlState::SetSelectionRange(
// XXX(krosylight): Shouldn't it fire before select event?
// Currently Gecko and Blink both fire selectionchange after select.
if (IsSelectionCached() &&
StaticPrefs::dom_select_events_textcontrols_enabled()) {
StaticPrefs::dom_select_events_textcontrols_selectionchange_enabled()) {
asyncDispatcher = new AsyncEventDispatcher(
mTextCtrlElement, eSelectionChange, CanBubble::eNo);
asyncDispatcher->PostDOMEvent();

Просмотреть файл

@ -46,10 +46,15 @@
var cancel = false;
var selectstartTarget = null;
async function UpdateSelectEventsOntextControlsPref(aEnabled) {
await SpecialPowers.pushPrefEnv({'set': [['dom.select_events.textcontrols.enabled', aEnabled]]});
async function UpdateSelectEventsOnTextControlsPref(aEnabled) {
await SpecialPowers.pushPrefEnv({
'set': [
['dom.select_events.textcontrols.selectstart.enabled', aEnabled],
['dom.select_events.textcontrols.selectionchange.enabled', aEnabled]
]
});
}
await UpdateSelectEventsOntextControlsPref(false);
await UpdateSelectEventsOnTextControlsPref(false);
document.addEventListener('selectstart', function(aEvent) {
console.log("originaltarget", aEvent.originalTarget, "new", selectstartTarget);
@ -331,7 +336,7 @@
// Releasing the mouse shouldn't do anything
await mouseAction(elt("input"), 50, "mouseup", 0, 0, 0, 0);
await UpdateSelectEventsOntextControlsPref(true);
await UpdateSelectEventsOnTextControlsPref(true);
await mouseAction(elt("input"), 50, "mousedown", 0, 0, 0, 0);
@ -374,7 +379,7 @@
await mouseAction(elt("input"), 100, "mouseup", 0, 0, 0, 0);
await UpdateSelectEventsOntextControlsPref(false);
await UpdateSelectEventsOnTextControlsPref(false);
// Without the dom.select_events.textcontrols.enabled pref,
// pressing the mouse shouldn't do anything.
@ -385,7 +390,7 @@
// Releasing the mouse shouldn't do anything
await mouseAction(elt("textarea"), 50, "mouseup", 0, 0, 0, 0);
await UpdateSelectEventsOntextControlsPref(true);
await UpdateSelectEventsOnTextControlsPref(true);
// Select a region
await mouseAction(elt("textarea"), 50, "mousedown", 0, 0, 0, 0);

Просмотреть файл

@ -3096,7 +3096,12 @@
mirror: always
# Whether or not selection events on text controls are enabled.
- name: dom.select_events.textcontrols.enabled
- name: dom.select_events.textcontrols.selectionchange.enabled
type: bool
value: true
mirror: always
- name: dom.select_events.textcontrols.selectstart.enabled
type: bool
value: @IS_NIGHTLY_BUILD@
mirror: always