Bug 1452751 - add a pref to control whether to default to passive touch listeners on window/document/documentElement/body , r=kats

--HG--
extra : rebase_source : ba015d60e7ab7da183048dc59dfb0fe42930df6d
This commit is contained in:
Olli Pettay 2018-04-09 23:43:17 +03:00
Родитель a403c9345b
Коммит a2485252b4
3 изменённых файлов: 23 добавлений и 2 удалений

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

@ -686,6 +686,21 @@ EventListenerManager::ListenerCanHandle(const Listener* aListener,
return aListener->mEventMessage == aEventMessage;
}
static bool
DefaultToPassiveTouchListeners()
{
static bool sDefaultToPassiveTouchListeners = false;
static bool sIsPrefCached = false;
if (!sIsPrefCached) {
sIsPrefCached = true;
Preferences::AddBoolVarCache(&sDefaultToPassiveTouchListeners,
"dom.event.default_to_passive_touch_listeners");
}
return sDefaultToPassiveTouchListeners;
}
void
EventListenerManager::AddEventListenerByType(
EventListenerHolder aListenerHolder,
@ -702,7 +717,8 @@ EventListenerManager::AddEventListenerByType(
EventListenerFlags flags = aFlags;
if (aPassive.WasPassed()) {
flags.mPassive = aPassive.Value();
} else if (message == eTouchStart || message == eTouchMove) {
} else if ((message == eTouchStart || message == eTouchMove) &&
mIsMainThreadELM && DefaultToPassiveTouchListeners()) {
nsCOMPtr<nsINode> node;
nsCOMPtr<nsPIDOMWindowInner> win;
if ((win = GetTargetAsInnerWindow()) ||

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

@ -76,7 +76,8 @@ var subtests = [
["apz.test.fails_with_native_injection", isWindows]]},
{'file': 'helper_tap_default_passive.html', 'prefs': [["apz.content_response_timeout", 24 * 60 * 60 * 1000],
["apz.test.fails_with_native_injection", isWindows]]},
["apz.test.fails_with_native_injection", isWindows],
["dom.event.default_to_passive_touch_listeners", true]]},
// Simple test to exercise touch-action CSS property
{'file': 'helper_touch_action.html', 'prefs': touch_action_prefs},

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

@ -5917,3 +5917,7 @@ pref("layers.omtp.dump-capture", false);
// a content to view. This is mostly intended to prevent infinite
// loops with faulty converters involved.
pref("general.document_open_conversion_depth_limit", 20);
// If true, touchstart and touchmove listeners on window, document,
// documentElement and document.body are passive by default.
pref("dom.event.default_to_passive_touch_listeners", false);