diff --git a/content/events/test/Makefile.in b/content/events/test/Makefile.in index 5d7c62ec7f7..48808537362 100644 --- a/content/events/test/Makefile.in +++ b/content/events/test/Makefile.in @@ -85,7 +85,6 @@ _TEST_FILES = \ test_bug741666.html \ test_dom_keyboard_event.html \ test_dom_mouse_event.html \ - test_bug742376.html \ $(NULL) #bug 585630 diff --git a/content/events/test/test_bug742376.html b/content/events/test/test_bug742376.html deleted file mode 100644 index 156a679d4b2..00000000000 --- a/content/events/test/test_bug742376.html +++ /dev/null @@ -1,58 +0,0 @@ - - - - - Test for Bug 742376 - - - - - - -Mozilla Bug 742376 - - - - - diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 2ce84bc30ee..4b19d71d521 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -10040,44 +10040,35 @@ nsGlobalWindow::EnableDeviceSensor(PRUint32 aType) } } + if (alreadyEnabled) + return; + mEnabledSensors.AppendElement(aType); - if (alreadyEnabled) { - return; - } - nsCOMPtr ac = do_GetService(NS_DEVICE_SENSORS_CONTRACTID); - if (ac) { + if (ac) ac->AddWindowListener(aType, this); - } } void nsGlobalWindow::DisableDeviceSensor(PRUint32 aType) { PRInt32 doomedElement = -1; - PRInt32 listenerCount = 0; for (PRUint32 i = 0; i < mEnabledSensors.Length(); i++) { if (mEnabledSensors[i] == aType) { doomedElement = i; - listenerCount++; + break; } } - if (doomedElement == -1) { + if (doomedElement == -1) return; - } mEnabledSensors.RemoveElementAt(doomedElement); - if (listenerCount > 1) { - return; - } - nsCOMPtr ac = do_GetService(NS_DEVICE_SENSORS_CONTRACTID); - if (ac) { + if (ac) ac->RemoveWindowListener(aType, this); - } } NS_IMETHODIMP diff --git a/dom/system/nsDeviceSensors.cpp b/dom/system/nsDeviceSensors.cpp index c69cefb29bf..8722c0b29a7 100644 --- a/dom/system/nsDeviceSensors.cpp +++ b/dom/system/nsDeviceSensors.cpp @@ -118,17 +118,6 @@ nsDeviceSensors::~nsDeviceSensors() } } -NS_IMETHODIMP nsDeviceSensors::ListenerCount(PRUint32 aType, PRInt32 *aRetVal) -{ - if (!mEnabled) { - *aRetVal = 0; - return NS_OK; - } - - *aRetVal = mWindowListeners[aType]->Length(); - return NS_OK; -} - NS_IMETHODIMP nsDeviceSensors::AddWindowListener(PRUint32 aType, nsIDOMWindow *aWindow) { if (!mEnabled) diff --git a/xpcom/system/nsIDeviceSensors.idl b/xpcom/system/nsIDeviceSensors.idl index b57f878afc3..482c168e2c0 100644 --- a/xpcom/system/nsIDeviceSensors.idl +++ b/xpcom/system/nsIDeviceSensors.idl @@ -24,14 +24,11 @@ interface nsIDeviceSensorData : nsISupports readonly attribute double z; }; -[scriptable, uuid(83306c9f-1c8f-43c4-900a-245d7f219511)] +[scriptable, uuid(b672bfe0-4479-4094-a9ef-1b6847720d07)] interface nsIDeviceSensors : nsISupports { - long listenerCount(in unsigned long aType); - // Holds pointers, not AddRef objects -- it is up to the caller // to call RemoveWindowListener before the window is deleted. - [noscript] void addWindowListener(in unsigned long aType, in nsIDOMWindow aWindow); [noscript] void removeWindowListener(in unsigned long aType, in nsIDOMWindow aWindow); [noscript] void removeWindowAsListener(in nsIDOMWindow aWindow);