Bug 975688 part.16 Clean up dom::PointerEvent code r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 27 Feb 2014 19:51:15 +0900
changeset 171278 fa3367ca202d4a3fd607103f8115c48711bd9e55
parent 171277 b3ee0a6cbd75b5f821645847534bff3e227c4d17
child 171279 cfc7b6e52e335c6755afe08287bc5dc774b7b1db
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewerssmaug
bugs975688
milestone30.0a1
Bug 975688 part.16 Clean up dom::PointerEvent code r=smaug
dom/events/PointerEvent.cpp
dom/events/PointerEvent.h
--- a/dom/events/PointerEvent.cpp
+++ b/dom/events/PointerEvent.cpp
@@ -1,29 +1,30 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
  * Portions Copyright 2013 Microsoft Open Technologies, Inc. */
 
-#include "PointerEvent.h"
+#include "mozilla/dom/PointerEvent.h"
 #include "mozilla/MouseEvents.h"
 #include "prtime.h"
 
 namespace mozilla {
 namespace dom {
 
 PointerEvent::PointerEvent(EventTarget* aOwner,
                            nsPresContext* aPresContext,
                            WidgetPointerEvent* aEvent)
   : MouseEvent(aOwner, aPresContext,
                aEvent ? aEvent : new WidgetPointerEvent(false, 0, nullptr))
 {
-  NS_ASSERTION(mEvent->eventStructType == NS_POINTER_EVENT, "event type mismatch NS_POINTER_EVENT");
+  NS_ASSERTION(mEvent->eventStructType == NS_POINTER_EVENT,
+               "event type mismatch NS_POINTER_EVENT");
 
   WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent();
   if (aEvent) {
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
     mEvent->refPoint.x = mEvent->refPoint.y = 0;
@@ -44,30 +45,31 @@ ConvertStringToPointerType(const nsAStri
     return nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
   }
 
   return nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
 }
 
 //static
 already_AddRefed<PointerEvent>
-PointerEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
+PointerEvent::Constructor(const GlobalObject& aGlobal,
                           const nsAString& aType,
-                          const mozilla::dom::PointerEventInit& aParam,
-                          mozilla::ErrorResult& aRv)
+                          const PointerEventInit& aParam,
+                          ErrorResult& aRv)
 {
-  nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
+  nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
   nsRefPtr<PointerEvent> e = new PointerEvent(t, nullptr, nullptr);
   bool trusted = e->Init(t);
 
   aRv = e->InitMouseEvent(aType, aParam.mBubbles, aParam.mCancelable,
                           aParam.mView, aParam.mDetail, aParam.mScreenX,
                           aParam.mScreenY, aParam.mClientX, aParam.mClientY,
                           aParam.mCtrlKey, aParam.mAltKey, aParam.mShiftKey,
-                          aParam.mMetaKey, aParam.mButton, aParam.mRelatedTarget);
+                          aParam.mMetaKey, aParam.mButton,
+                          aParam.mRelatedTarget);
   if (aRv.Failed()) {
     return nullptr;
   }
 
   WidgetPointerEvent* widgetEvent = e->mEvent->AsPointerEvent();
   widgetEvent->pointerId = aParam.mPointerId;
   widgetEvent->width = aParam.mWidth;
   widgetEvent->height = aParam.mHeight;
@@ -96,56 +98,65 @@ PointerEvent::GetPointerType(nsAString& 
       aPointerType.AssignLiteral("touch");
       break;
     case nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN:
       aPointerType.AssignLiteral("");
       break;
   }
 }
 
-int32_t PointerEvent::PointerId()
+int32_t
+PointerEvent::PointerId()
 {
   return mEvent->AsPointerEvent()->pointerId;
 }
 
-int32_t PointerEvent::Width()
+int32_t
+PointerEvent::Width()
 {
   return mEvent->AsPointerEvent()->width;
 }
 
-int32_t PointerEvent::Height()
+int32_t
+PointerEvent::Height()
 {
   return mEvent->AsPointerEvent()->height;
 }
 
-float PointerEvent::Pressure()
+float
+PointerEvent::Pressure()
 {
   return mEvent->AsPointerEvent()->pressure;
 }
 
-int32_t PointerEvent::TiltX()
+int32_t
+PointerEvent::TiltX()
 {
   return mEvent->AsPointerEvent()->tiltX;
 }
 
-int32_t PointerEvent::TiltY()
+int32_t
+PointerEvent::TiltY()
 {
   return mEvent->AsPointerEvent()->tiltY;
 }
 
-bool PointerEvent::IsPrimary()
+bool
+PointerEvent::IsPrimary()
 {
   return mEvent->AsPointerEvent()->isPrimary;
 }
 
 } // namespace dom
 } // namespace mozilla
 
 using namespace mozilla;
+using namespace mozilla::dom;
 
-nsresult NS_NewDOMPointerEvent(nsIDOMEvent** aInstancePtrResult,
-                               dom::EventTarget* aOwner,
-                               nsPresContext* aPresContext,
-                               WidgetPointerEvent *aEvent)
+nsresult
+NS_NewDOMPointerEvent(nsIDOMEvent** aInstancePtrResult,
+                      EventTarget* aOwner,
+                      nsPresContext* aPresContext,
+                      WidgetPointerEvent *aEvent)
 {
-  dom::PointerEvent *it = new dom::PointerEvent(aOwner, aPresContext, aEvent);
+  PointerEvent *it = new PointerEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
--- a/dom/events/PointerEvent.h
+++ b/dom/events/PointerEvent.h
@@ -1,16 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
  * Portions Copyright 2013 Microsoft Open Technologies, Inc. */
 
-#ifndef PointerEvent_h__
-#define PointerEvent_h__
+#ifndef mozilla_dom_PointerEvent_h_
+#define mozilla_dom_PointerEvent_h_
 
 #include "mozilla/dom/MouseEvent.h"
 #include "mozilla/dom/PointerEventBinding.h"
 
 class nsPresContext;
 
 namespace mozilla {
 namespace dom {
@@ -20,31 +20,31 @@ class PointerEvent : public MouseEvent
 public:
   PointerEvent(EventTarget* aOwner,
                nsPresContext* aPresContext,
                WidgetPointerEvent* aEvent);
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::PointerEventBinding::Wrap(aCx, aScope, this);
+    return PointerEventBinding::Wrap(aCx, aScope, this);
   }
 
   static already_AddRefed<PointerEvent>
   Constructor(const GlobalObject& aGlobal,
               const nsAString& aType,
               const PointerEventInit& aParam,
-              mozilla::ErrorResult& aRv);
+              ErrorResult& aRv);
 
   int32_t PointerId();
   int32_t Width();
   int32_t Height();
   float Pressure();
   int32_t TiltX();
   int32_t TiltY();
   bool IsPrimary();
   void GetPointerType(nsAString& aPointerType);
 };
 
 } // namespace dom
 } // namespace mozilla
 
-#endif
+#endif // mozilla_dom_PointerEvent_h_