Bug 681562 - Restrict DeviceMotion to the active document. r=smaug

This commit is contained in:
Doug Turner 2011-08-31 19:39:49 -07:00
Родитель 316e8aa92b
Коммит 1effc134d0
1 изменённых файлов: 11 добавлений и 4 удалений

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

@ -39,6 +39,7 @@
#include "nsAutoPtr.h"
#include "nsIDOMEvent.h"
#include "nsIDOMWindow.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMDocument.h"
#include "nsIDOMEventTarget.h"
#include "nsIServiceManager.h"
@ -232,6 +233,12 @@ nsDeviceMotion::DeviceMotionChanged(PRUint32 type, double x, double y, double z)
for (PRUint32 i = mWindowListeners.Length(); i > 0 ; ) {
--i;
// check to see if this window is in the background. if
// it is, don't send any device motion to it.
nsCOMPtr<nsPIDOMWindow> pwindow = do_QueryInterface(mWindowListeners[i]);
if (!pwindow || pwindow->GetOuterWindow()->IsBackground())
continue;
nsCOMPtr<nsIDOMDocument> domdoc;
mWindowListeners[i]->GetDocument(getter_AddRefs(domdoc));
@ -248,10 +255,10 @@ nsDeviceMotion::DeviceMotionChanged(PRUint32 type, double x, double y, double z)
void
nsDeviceMotion::FireDOMOrientationEvent(nsIDOMDocument *domdoc,
nsIDOMEventTarget *target,
double alpha,
double beta,
double gamma)
nsIDOMEventTarget *target,
double alpha,
double beta,
double gamma)
{
nsCOMPtr<nsIDOMEvent> event;
PRBool defaultActionEnabled = PR_TRUE;