Skip to content

Commit

Permalink
Bug 825392 - Parent Touch objects to the EventTarget's global. r=bz
Browse files Browse the repository at this point in the history
  • Loading branch information
bholley committed Mar 19, 2014
1 parent 6980085 commit 3a4162f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 18 additions & 0 deletions dom/events/Touch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
3 changes: 2 additions & 1 deletion dom/events/Touch.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class Touch MOZ_FINAL : public nsISupports

virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
EventTarget* GetParentObject() { return mTarget; }

EventTarget* GetParentObject();

// WebIDL
int32_t Identifier() const { return mIdentifier; }
Expand Down

0 comments on commit 3a4162f

Please sign in to comment.