зеркало из https://github.com/mozilla/gecko-dev.git
Bug 798821 - On Windows, restrict enabling of W3C touch interfaces to devices that support touch input. Also convert touch pref to 3-state value. r=bsmedberg, a=bajaj
This commit is contained in:
Родитель
a6a2c4eda7
Коммит
d65c2158d6
|
@ -279,7 +279,7 @@ pref("image.mem.min_discard_timeout_ms", 10000);
|
|||
pref("image.mem.max_decoded_image_kb", 5120); /* 5MB */
|
||||
|
||||
// enable touch events interfaces
|
||||
pref("dom.w3c_touch_events.enabled", true);
|
||||
pref("dom.w3c_touch_events.enabled", 1);
|
||||
pref("dom.w3c_touch_events.safetyX", 0); // escape borders in units of 1/240"
|
||||
pref("dom.w3c_touch_events.safetyY", 120); // escape borders in units of 1/240"
|
||||
|
||||
|
|
|
@ -407,7 +407,7 @@ user_pref("security.warn_viewing_mixed", false);
|
|||
user_pref("app.update.enabled", false);
|
||||
user_pref("app.update.staging.enabled", false);
|
||||
user_pref("browser.panorama.experienced_first_run", true); // Assume experienced
|
||||
user_pref("dom.w3c_touch_events.enabled", true);
|
||||
user_pref("dom.w3c_touch_events.enabled", 1);
|
||||
user_pref("toolkit.telemetry.prompted", 2);
|
||||
// Existing tests assume there is no font size inflation.
|
||||
user_pref("font.size.inflation.emPerLine", 0);
|
||||
|
|
|
@ -373,6 +373,13 @@ nsDOMTouchEvent::GetShiftKey(bool* aShiftKey)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
extern int32_t IsTouchDeviceSupportPresent();
|
||||
} }
|
||||
#endif
|
||||
|
||||
bool
|
||||
nsDOMTouchEvent::PrefEnabled()
|
||||
{
|
||||
|
@ -380,7 +387,20 @@ nsDOMTouchEvent::PrefEnabled()
|
|||
static bool sPrefValue = false;
|
||||
if (!sDidCheckPref) {
|
||||
sDidCheckPref = true;
|
||||
sPrefValue = Preferences::GetBool("dom.w3c_touch_events.enabled", false);
|
||||
int32_t flag = 0;
|
||||
if (NS_SUCCEEDED(Preferences::GetInt("dom.w3c_touch_events.enabled",
|
||||
&flag))) {
|
||||
if (flag == 2) {
|
||||
#ifdef XP_WIN
|
||||
// On Windows we auto-detect based on device support.
|
||||
sPrefValue = mozilla::widget::IsTouchDeviceSupportPresent();
|
||||
#else
|
||||
NS_ERROR("Not implemented");
|
||||
#endif
|
||||
} else {
|
||||
sPrefValue = !!flag;
|
||||
}
|
||||
}
|
||||
if (sPrefValue) {
|
||||
nsContentUtils::InitializeTouchEventTable();
|
||||
}
|
||||
|
|
|
@ -35,6 +35,15 @@ function getBoolPref(prefName, def) {
|
|||
}
|
||||
}
|
||||
|
||||
function getIntPref(prefName, def) {
|
||||
try {
|
||||
return Services.prefs.getIntPref(prefName);
|
||||
}
|
||||
catch(err) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
function exposeAll(obj) {
|
||||
// Filter for Objects and Arrays.
|
||||
if (typeof obj !== "object" || !obj)
|
||||
|
@ -236,7 +245,9 @@ function BrowserElementParent(frameLoader, hasRemoteFrame) {
|
|||
// Define methods on the frame element.
|
||||
defineMethod('setVisible', this._setVisible);
|
||||
defineMethod('sendMouseEvent', this._sendMouseEvent);
|
||||
if (getBoolPref(TOUCH_EVENTS_ENABLED_PREF, false)) {
|
||||
|
||||
// 0 = disabled, 1 = enabled, 2 - auto detect
|
||||
if (getIntPref(TOUCH_EVENTS_ENABLED_PREF, 0) != 0) {
|
||||
defineMethod('sendTouchEvent', this._sendTouchEvent);
|
||||
}
|
||||
defineMethod('goBack', this._goBack);
|
||||
|
|
|
@ -36,7 +36,7 @@ function runTest() {
|
|||
break;
|
||||
case "#click":
|
||||
ok(true, "Receive a click event.");
|
||||
if (SpecialPowers.getBoolPref("dom.w3c_touch_events.enabled")) {
|
||||
if (SpecialPowers.getIntPref("dom.w3c_touch_events.enabled") != 0) {
|
||||
iframe.sendTouchEvent("touchstart", [1], [10], [10], [2], [2],
|
||||
[20], [0.5], 1, 0);
|
||||
} else {
|
||||
|
|
|
@ -539,7 +539,7 @@ pref("content.image.allow_locking", false);
|
|||
pref("image.mem.min_discard_timeout_ms", 10000);
|
||||
|
||||
// enable touch events interfaces
|
||||
pref("dom.w3c_touch_events.enabled", true);
|
||||
pref("dom.w3c_touch_events.enabled", 1);
|
||||
|
||||
#ifdef MOZ_SAFE_BROWSING
|
||||
pref("browser.safebrowsing.enabled", true);
|
||||
|
|
|
@ -582,7 +582,7 @@ pref("content.image.allow_locking", false);
|
|||
pref("image.mem.min_discard_timeout_ms", 10000);
|
||||
|
||||
// enable touch events interfaces
|
||||
pref("dom.w3c_touch_events.enabled", true);
|
||||
pref("dom.w3c_touch_events.enabled", 1);
|
||||
pref("dom.w3c_touch_events.safetyX", 5); // escape borders in units of 1/240"
|
||||
pref("dom.w3c_touch_events.safetyY", 20); // escape borders in units of 1/240"
|
||||
|
||||
|
|
|
@ -1366,7 +1366,7 @@ var TouchEventHandler = {
|
|||
},
|
||||
|
||||
sendEvent: function(aName, aData, aElement) {
|
||||
if (!Services.prefs.getBoolPref("dom.w3c_touch_events.enabled"))
|
||||
if (!Services.prefs.getIntPref("dom.w3c_touch_events.enabled"))
|
||||
return true;
|
||||
|
||||
let evt = content.document.createEvent("touchevent");
|
||||
|
|
|
@ -3744,8 +3744,9 @@ pref("dom.mozSettings.enabled", false);
|
|||
pref("dom.mozPermissionSettings.enabled", false);
|
||||
|
||||
// W3C touch events
|
||||
// 0 - disabled, 1 - enabled, 2 - autodetect (win)
|
||||
#ifdef XP_WIN
|
||||
pref("dom.w3c_touch_events.enabled", true);
|
||||
pref("dom.w3c_touch_events.enabled", 2);
|
||||
#endif
|
||||
|
||||
// enable JS dump() function.
|
||||
|
|
|
@ -39,18 +39,22 @@ static int32_t GetSystemParam(long flag, int32_t def)
|
|||
return ::SystemParametersInfo(flag, 0, &value, 0) ? value : def;
|
||||
}
|
||||
|
||||
static int32_t IsTouchPresent()
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
// This is in use here and in nsDOMTouchEvent.cpp
|
||||
int32_t IsTouchDeviceSupportPresent()
|
||||
{
|
||||
int32_t touchCapabilities;
|
||||
touchCapabilities = ::GetSystemMetrics(SM_DIGITIZER);
|
||||
return ((touchCapabilities & NID_READY) &&
|
||||
(touchCapabilities & (NID_EXTERNAL_TOUCH | NID_INTEGRATED_TOUCH)));
|
||||
}
|
||||
} }
|
||||
|
||||
nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
|
||||
{
|
||||
mozilla::Telemetry::Accumulate(mozilla::Telemetry::TOUCH_ENABLED_DEVICE,
|
||||
IsTouchPresent());
|
||||
IsTouchDeviceSupportPresent());
|
||||
}
|
||||
|
||||
nsLookAndFeel::~nsLookAndFeel()
|
||||
|
@ -376,7 +380,7 @@ nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
|
|||
aResult = !IsAppThemed();
|
||||
break;
|
||||
case eIntID_TouchEnabled:
|
||||
aResult = IsTouchPresent();
|
||||
aResult = IsTouchDeviceSupportPresent();
|
||||
break;
|
||||
case eIntID_WindowsDefaultTheme:
|
||||
aResult = nsUXThemeData::IsDefaultWindowTheme();
|
||||
|
|
Загрузка…
Ссылка в новой задаче