Skip to content

Commit 8733310

Browse files
author
Chih-Yi Leu
committed
Bug 1221730 - Change GamepadServiceTest into webidl. r=qdot, r=baku
--HG-- extra : rebase_source : 8e04725e80467a17d1a1a775f791782abe842c1b
1 parent 42a49e9 commit 8733310

31 files changed

+637
-262
lines changed

browser/installer/package-manifest.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,6 @@
219219
@RESPATH@/components/dom_xhr.xpt
220220
@RESPATH@/components/dom_xpath.xpt
221221
@RESPATH@/components/dom_xul.xpt
222-
#ifdef MOZ_GAMEPAD
223-
@RESPATH@/components/dom_gamepad.xpt
224-
#endif
225222
@RESPATH@/components/dom_payment.xpt
226223
@RESPATH@/components/dom_presentation.xpt
227224
@RESPATH@/components/downloads.xpt

dom/base/Navigator.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
#include "mozilla/Telemetry.h"
3333
#include "BatteryManager.h"
3434
#include "mozilla/dom/DeviceStorageAreaListener.h"
35+
#ifdef MOZ_GAMEPAD
36+
#include "mozilla/dom/GamepadServiceTest.h"
37+
#endif
3538
#include "mozilla/dom/PowerManager.h"
3639
#include "mozilla/dom/WakeLock.h"
3740
#include "mozilla/dom/power/PowerManagerService.h"
@@ -265,6 +268,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Navigator)
265268
#endif
266269
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDeviceStorageAreaListener)
267270
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPresentation)
271+
#ifdef MOZ_GAMEPAD
272+
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGamepadServiceTest)
273+
#endif
268274
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVRGetDevicesPromises)
269275
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
270276
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
@@ -407,6 +413,13 @@ Navigator::Invalidate()
407413
mDeviceStorageAreaListener = nullptr;
408414
}
409415

416+
#ifdef MOZ_GAMEPAD
417+
if (mGamepadServiceTest) {
418+
mGamepadServiceTest->Shutdown();
419+
mGamepadServiceTest = nullptr;
420+
}
421+
#endif
422+
410423
mVRGetDevicesPromises.Clear();
411424
}
412425

@@ -2020,6 +2033,15 @@ Navigator::GetGamepads(nsTArray<RefPtr<Gamepad> >& aGamepads,
20202033
win->SetHasGamepadEventListener(true);
20212034
win->GetGamepads(aGamepads);
20222035
}
2036+
2037+
GamepadServiceTest*
2038+
Navigator::RequestGamepadServiceTest()
2039+
{
2040+
if (!mGamepadServiceTest) {
2041+
mGamepadServiceTest = GamepadServiceTest::CreateTestService(mWindow);
2042+
}
2043+
return mGamepadServiceTest;
2044+
}
20232045
#endif
20242046

20252047
already_AddRefed<Promise>

dom/base/Navigator.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class MobileMessageManager;
7171
class MozIdleObserver;
7272
#ifdef MOZ_GAMEPAD
7373
class Gamepad;
74+
class GamepadServiceTest;
7475
#endif // MOZ_GAMEPAD
7576
class NavigatorUserMediaSuccessCallback;
7677
class NavigatorUserMediaErrorCallback;
@@ -265,6 +266,7 @@ class Navigator final : public nsIDOMNavigator
265266
#endif // MOZ_B2G_RIL
266267
#ifdef MOZ_GAMEPAD
267268
void GetGamepads(nsTArray<RefPtr<Gamepad> >& aGamepads, ErrorResult& aRv);
269+
GamepadServiceTest* RequestGamepadServiceTest();
268270
#endif // MOZ_GAMEPAD
269271
already_AddRefed<Promise> GetVRDevices(ErrorResult& aRv);
270272
void NotifyVRDevicesUpdated();
@@ -398,7 +400,9 @@ class Navigator final : public nsIDOMNavigator
398400
nsCOMPtr<nsPIDOMWindowInner> mWindow;
399401
RefPtr<DeviceStorageAreaListener> mDeviceStorageAreaListener;
400402
RefPtr<Presentation> mPresentation;
401-
403+
#ifdef MOZ_GAMEPAD
404+
RefPtr<GamepadServiceTest> mGamepadServiceTest;
405+
#endif
402406
nsTArray<RefPtr<Promise> > mVRGetDevicesPromises;
403407
nsTArray<uint32_t> mRequestedVibrationPattern;
404408
};

0 commit comments

Comments
 (0)