Bug 825392 - Parent Touch objects to the EventTarget's global. r=bz

This commit is contained in:
Bobby Holley 2014-03-19 13:35:45 -03:00
parent a228c689cc
commit 42d8c2c8cd
2 changed files with 20 additions and 1 deletions

View File

@ -8,6 +8,7 @@
#include "mozilla/dom/EventTarget.h"
#include "mozilla/dom/TouchBinding.h"
#include "mozilla/dom/TouchEvent.h"
#include "nsGlobalWindow.h"
#include "nsContentUtils.h"
#include "nsIContent.h"
@ -139,5 +140,22 @@ Touch::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
return TouchBinding::Wrap(aCx, aScope, this);
}
// Parent ourselves to the window of the target. This achieves the desirable
// effects of parenting to the target, but avoids making the touch inaccessible
// when the target happens to be NAC and therefore reflected into the XBL scope.
EventTarget*
Touch::GetParentObject()
{
if (!mTarget) {
return nullptr;
}
nsCOMPtr<nsPIDOMWindow> outer = do_QueryInterface(mTarget->GetOwnerGlobal());
if (!outer) {
return nullptr;
}
MOZ_ASSERT(outer->IsOuterWindow());
return static_cast<nsGlobalWindow*>(outer->GetCurrentInnerWindow());
}
} // namespace dom
} // namespace mozilla

View File

@ -58,7 +58,8 @@ public:
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
EventTarget* GetParentObject() { return mTarget; }
EventTarget* GetParentObject();
// WebIDL
int32_t Identifier() const { return mIdentifier; }