зеркало из https://github.com/mozilla/gecko-dev.git
Bug 550410. Provide a pref to disable orientation events. r=dveditz
--HG-- extra : rebase_source : 0bc3ffef8341a4a34b166a41e9dcd1a405b1ec89
This commit is contained in:
Родитель
af87bbaf6d
Коммит
7996ebdb6b
|
@ -2860,6 +2860,9 @@ pref("mozilla.widget.render-mode", -1);
|
|||
// Enable/Disable the geolocation API for content
|
||||
pref("geo.enabled", true);
|
||||
|
||||
// Enable/Disable the orientation API for content
|
||||
pref("accelerometer.enabled", true);
|
||||
|
||||
// Enable/Disable HTML5 parser
|
||||
pref("html5.enable", false);
|
||||
// Toggle which thread the HTML5 parser uses for stream parsing
|
||||
|
|
|
@ -104,15 +104,21 @@ nsAccelerometer::nsAccelerometer()
|
|||
mLastY(10),
|
||||
mLastZ(10),
|
||||
mStarted(PR_FALSE),
|
||||
mEnabled(PR_TRUE),
|
||||
mNewListener(PR_FALSE),
|
||||
mUpdateInterval(50) /* default to 50 ms */
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch> prefSrv = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
PRInt32 value;
|
||||
if (prefSrv) {
|
||||
PRInt32 value;
|
||||
nsresult rv = prefSrv->GetIntPref("accelerometer.update.interval", &value);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mUpdateInterval = value;
|
||||
|
||||
PRBool bvalue;
|
||||
rv = prefSrv->GetBoolPref("accelerometer.enabled", &bvalue);
|
||||
if (NS_SUCCEEDED(rv) && bvalue == PR_FALSE)
|
||||
mEnabled = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,6 +203,9 @@ NS_IMETHODIMP nsAccelerometer::RemoveWindowListener(nsIDOMWindow *aWindow)
|
|||
void
|
||||
nsAccelerometer::AccelerationChanged(double x, double y, double z)
|
||||
{
|
||||
if (!mEnabled)
|
||||
return;
|
||||
|
||||
if (x > 1)
|
||||
x = 1;
|
||||
if (y > 1)
|
||||
|
|
|
@ -76,6 +76,7 @@ private:
|
|||
protected:
|
||||
|
||||
PRUint32 mUpdateInterval;
|
||||
PRBool mEnabled;
|
||||
|
||||
virtual void Startup() = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
|
|
Загрузка…
Ссылка в новой задаче