Bug 852055 - Pass an EventTarget argument to Document.createTouch in WebIDL r=bz
authorDavid Zbarsky <dzbarsky@gmail.com>
Fri, 19 Apr 2013 04:49:20 -0400
changeset 129304 4d79c33d1b83a32d6d522f563d0a6af50057ba55
parent 129303 465dfbf5f49045d42163f3f5641e45afafe46aa6
child 129305 8674d8a06e677ab7a7997fb8850f3036da4ceb1a
push idunknown
push userunknown
push dateunknown
reviewersbz
bugs852055
milestone23.0a1
Bug 852055 - Pass an EventTarget argument to Document.createTouch in WebIDL r=bz
content/base/public/nsIDocument.h
content/base/src/nsDocument.cpp
dom/webidl/Document.webidl
--- a/content/base/public/nsIDocument.h
+++ b/content/base/public/nsIDocument.h
@@ -2086,17 +2086,17 @@ public:
   already_AddRefed<nsIDOMXPathNSResolver>
     CreateNSResolver(nsINode* aNodeResolver, mozilla::ErrorResult& rv);
   already_AddRefed<nsISupports>
     Evaluate(const nsAString& aExpression, nsINode* aContextNode,
              nsIDOMXPathNSResolver* aResolver, uint16_t aType,
              nsISupports* aResult, mozilla::ErrorResult& rv);
   // Touch event handlers already on nsINode
   already_AddRefed<nsIDOMTouch>
-    CreateTouch(nsIDOMWindow* aView, nsISupports* aTarget,
+    CreateTouch(nsIDOMWindow* aView, mozilla::dom::EventTarget* aTarget,
                 int32_t aIdentifier, int32_t aPageX, int32_t aPageY,
                 int32_t aScreenX, int32_t aScreenY, int32_t aClientX,
                 int32_t aClientY, int32_t aRadiusX, int32_t aRadiusY,
                 float aRotationAngle, float aForce);
   already_AddRefed<nsIDOMTouchList> CreateTouchList();
   already_AddRefed<nsIDOMTouchList>
     CreateTouchList(nsIDOMTouch* aTouch,
                     const mozilla::dom::Sequence<nsRefPtr<nsIDOMTouch> >& aTouches);
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -9158,36 +9158,36 @@ nsDocument::CreateTouch(nsIDOMWindow* aV
                         int32_t aClientX,
                         int32_t aClientY,
                         int32_t aRadiusX,
                         int32_t aRadiusY,
                         float aRotationAngle,
                         float aForce,
                         nsIDOMTouch** aRetVal)
 {
-  *aRetVal = nsIDocument::CreateTouch(aView, aTarget, aIdentifier, aPageX,
+  nsCOMPtr<EventTarget> target = do_QueryInterface(aTarget);
+  *aRetVal = nsIDocument::CreateTouch(aView, target, aIdentifier, aPageX,
                                       aPageY, aScreenX, aScreenY, aClientX,
                                       aClientY, aRadiusX, aRadiusY,
                                       aRotationAngle, aForce).get();
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMTouch>
 nsIDocument::CreateTouch(nsIDOMWindow* aView,
-                         nsISupports* aTarget,
+                         EventTarget* aTarget,
                          int32_t aIdentifier,
                          int32_t aPageX, int32_t aPageY,
                          int32_t aScreenX, int32_t aScreenY,
                          int32_t aClientX, int32_t aClientY,
                          int32_t aRadiusX, int32_t aRadiusY,
                          float aRotationAngle,
                          float aForce)
 {
-  nsCOMPtr<EventTarget> target = do_QueryInterface(aTarget);
-  nsCOMPtr<nsIDOMTouch> touch = new Touch(target,
+  nsCOMPtr<nsIDOMTouch> touch = new Touch(aTarget,
                                           aIdentifier,
                                           aPageX, aPageY,
                                           aScreenX, aScreenY,
                                           aClientX, aClientY,
                                           aRadiusX, aRadiusY,
                                           aRotationAngle,
                                           aForce);
   return touch.forget();
--- a/dom/webidl/Document.webidl
+++ b/dom/webidl/Document.webidl
@@ -287,21 +287,17 @@ partial interface Document {
   [Throws]
   void loadBindingDocument(DOMString documentURL);
 
   // nsIDOMDocumentTouch
   // XXXbz I can't find the sane spec for this stuff, so just cribbing
   // from our xpidl for now.
   [Creator, Func="nsGenericHTMLElement::TouchEventsEnabled"]
   Touch createTouch(optional Window? view = null,
-                    // Nasty hack, because we can't do EventTarget arguments yet
-                    // (they would need to be non-castable, but trying to do
-                    // XPConnect unwrapping with nsDOMEventTargetHelper fails).
-                    // optional EventTarget? target = null,
-                    optional nsISupports? target = null,
+                    optional EventTarget? target = null,
                     optional long identifier = 0,
                     optional long pageX = 0,
                     optional long pageY = 0,
                     optional long screenX = 0,
                     optional long screenY = 0,
                     optional long clientX = 0,
                     optional long clientY = 0,
                     optional long radiusX = 0,