dom/events/DeviceMotionEvent.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #ifndef mozilla_dom_DeviceMotionEvent_h_
     6 #define mozilla_dom_DeviceMotionEvent_h_
     8 #include "mozilla/Attributes.h"
     9 #include "mozilla/dom/DeviceMotionEventBinding.h"
    10 #include "mozilla/dom/Event.h"
    12 namespace mozilla {
    13 namespace dom {
    15 class DeviceRotationRate MOZ_FINAL : public nsWrapperCache
    16 {
    17 public:
    18   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DeviceRotationRate)
    19   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DeviceRotationRate)
    21   DeviceRotationRate(DeviceMotionEvent* aOwner,
    22                      Nullable<double> aAlpha, Nullable<double> aBeta,
    23                      Nullable<double> aGamma);
    25   DeviceMotionEvent* GetParentObject() const
    26   {
    27     return mOwner;
    28   }
    30   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
    31   {
    32     return DeviceRotationRateBinding::Wrap(aCx, this);
    33   }
    35   Nullable<double> GetAlpha() const { return mAlpha; }
    36   Nullable<double> GetBeta() const { return mBeta; }
    37   Nullable<double> GetGamma() const { return mGamma; }
    39 private:
    40   ~DeviceRotationRate();
    42 protected:
    43   nsRefPtr<DeviceMotionEvent> mOwner;
    44   Nullable<double> mAlpha, mBeta, mGamma;
    45 };
    47 class DeviceAcceleration MOZ_FINAL : public nsWrapperCache
    48 {
    49 public:
    50   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DeviceAcceleration)
    51   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DeviceAcceleration)
    53   DeviceAcceleration(DeviceMotionEvent* aOwner,
    54                      Nullable<double> aX, Nullable<double> aY,
    55                      Nullable<double> aZ);
    57   DeviceMotionEvent* GetParentObject() const
    58   {
    59     return mOwner;
    60   }
    62   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
    63   {
    64     return DeviceAccelerationBinding::Wrap(aCx, this);
    65   }
    67   Nullable<double> GetX() const { return mX; }
    68   Nullable<double> GetY() const { return mY; }
    69   Nullable<double> GetZ() const { return mZ; }
    71 private:
    72   ~DeviceAcceleration();
    74 protected:
    75   nsRefPtr<DeviceMotionEvent> mOwner;
    76   Nullable<double> mX, mY, mZ;
    77 };
    79 class DeviceMotionEvent MOZ_FINAL : public Event
    80 {
    81 public:
    83   DeviceMotionEvent(EventTarget* aOwner,
    84                     nsPresContext* aPresContext,
    85                     WidgetEvent* aEvent)
    86     : Event(aOwner, aPresContext, aEvent)
    87   {
    88   }
    90   NS_DECL_ISUPPORTS_INHERITED
    92   // Forward to Event
    93   NS_FORWARD_TO_EVENT
    95   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeviceMotionEvent, Event)
    97   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
    98   {
    99     return DeviceMotionEventBinding::Wrap(aCx, this);
   100   }
   102   DeviceAcceleration* GetAcceleration() const
   103   {
   104     return mAcceleration;
   105   }
   107   DeviceAcceleration* GetAccelerationIncludingGravity() const
   108   {
   109     return mAccelerationIncludingGravity;
   110   }
   112   DeviceRotationRate* GetRotationRate() const
   113   {
   114     return mRotationRate;
   115   }
   117   Nullable<double> GetInterval() const
   118   {
   119     return mInterval;
   120   }
   122   void InitDeviceMotionEvent(
   123          const nsAString& aType,
   124          bool aCanBubble,
   125          bool aCancelable,
   126          const DeviceAccelerationInit& aAcceleration,
   127          const DeviceAccelerationInit& aAccelerationIncludingGravity,
   128          const DeviceRotationRateInit& aRotationRate,
   129          Nullable<double> aInterval,
   130          ErrorResult& aRv);
   132   static already_AddRefed<DeviceMotionEvent>
   133   Constructor(const GlobalObject& aGlobal,
   134               const nsAString& aType,
   135               const DeviceMotionEventInit& aEventInitDict,
   136               ErrorResult& aRv);
   138 protected:
   139   nsRefPtr<DeviceAcceleration> mAcceleration;
   140   nsRefPtr<DeviceAcceleration> mAccelerationIncludingGravity;
   141   nsRefPtr<DeviceRotationRate> mRotationRate;
   142   Nullable<double> mInterval;
   143 };
   145 } // namespace dom
   146 } // namespace mozilla
   148 #endif // mozilla_dom_DeviceMotionEvent_h_

mercurial