dom/gamepad/Gamepad.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #ifndef mozilla_dom_gamepad_Gamepad_h
michael@0 6 #define mozilla_dom_gamepad_Gamepad_h
michael@0 7
michael@0 8 #include "mozilla/ErrorResult.h"
michael@0 9 #include "mozilla/dom/GamepadButton.h"
michael@0 10 #include <stdint.h>
michael@0 11 #include "nsCOMPtr.h"
michael@0 12 #include "nsString.h"
michael@0 13 #include "nsTArray.h"
michael@0 14 #include "nsWrapperCache.h"
michael@0 15
michael@0 16 namespace mozilla {
michael@0 17 namespace dom {
michael@0 18
michael@0 19 enum GamepadMappingType
michael@0 20 {
michael@0 21 NoMapping = 0,
michael@0 22 StandardMapping = 1
michael@0 23 };
michael@0 24
michael@0 25 class Gamepad : public nsISupports,
michael@0 26 public nsWrapperCache
michael@0 27 {
michael@0 28 public:
michael@0 29 Gamepad(nsISupports* aParent,
michael@0 30 const nsAString& aID, uint32_t aIndex,
michael@0 31 GamepadMappingType aMapping,
michael@0 32 uint32_t aNumButtons, uint32_t aNumAxes);
michael@0 33 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
michael@0 34 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Gamepad)
michael@0 35
michael@0 36 void SetConnected(bool aConnected);
michael@0 37 void SetButton(uint32_t aButton, bool aPressed, double aValue);
michael@0 38 void SetAxis(uint32_t aAxis, double aValue);
michael@0 39 void SetIndex(uint32_t aIndex);
michael@0 40
michael@0 41 // Make the state of this gamepad equivalent to other.
michael@0 42 void SyncState(Gamepad* aOther);
michael@0 43
michael@0 44 // Return a new Gamepad containing the same data as this object,
michael@0 45 // parented to aParent.
michael@0 46 already_AddRefed<Gamepad> Clone(nsISupports* aParent);
michael@0 47
michael@0 48 nsISupports* GetParentObject() const
michael@0 49 {
michael@0 50 return mParent;
michael@0 51 }
michael@0 52
michael@0 53 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
michael@0 54
michael@0 55 void GetId(nsAString& aID) const
michael@0 56 {
michael@0 57 aID = mID;
michael@0 58 }
michael@0 59
michael@0 60 void GetMapping(nsAString& aMapping) const
michael@0 61 {
michael@0 62 if (mMapping == StandardMapping) {
michael@0 63 aMapping = NS_LITERAL_STRING("standard");
michael@0 64 } else {
michael@0 65 aMapping = NS_LITERAL_STRING("");
michael@0 66 }
michael@0 67 }
michael@0 68
michael@0 69 bool Connected() const
michael@0 70 {
michael@0 71 return mConnected;
michael@0 72 }
michael@0 73
michael@0 74 uint32_t Index() const
michael@0 75 {
michael@0 76 return mIndex;
michael@0 77 }
michael@0 78
michael@0 79 void GetButtons(nsTArray<nsRefPtr<GamepadButton>>& aButtons) const
michael@0 80 {
michael@0 81 aButtons = mButtons;
michael@0 82 }
michael@0 83
michael@0 84 void GetAxes(nsTArray<double>& aAxes) const
michael@0 85 {
michael@0 86 aAxes = mAxes;
michael@0 87 }
michael@0 88
michael@0 89 private:
michael@0 90 virtual ~Gamepad() {}
michael@0 91
michael@0 92 protected:
michael@0 93 nsCOMPtr<nsISupports> mParent;
michael@0 94 nsString mID;
michael@0 95 uint32_t mIndex;
michael@0 96
michael@0 97 // The mapping in use.
michael@0 98 GamepadMappingType mMapping;
michael@0 99
michael@0 100 // true if this gamepad is currently connected.
michael@0 101 bool mConnected;
michael@0 102
michael@0 103 // Current state of buttons, axes.
michael@0 104 nsTArray<nsRefPtr<GamepadButton>> mButtons;
michael@0 105 nsTArray<double> mAxes;
michael@0 106 };
michael@0 107
michael@0 108 } // namespace dom
michael@0 109 } // namespace mozilla
michael@0 110
michael@0 111 #endif // mozilla_dom_gamepad_Gamepad_h

mercurial