mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1187782 (part 4) - Replace nsBaseHashtable::EnumerateRead() calls in dom/base/ with iterators. r=khuey.
This commit is contained in:
parent
087874d2bd
commit
298af7337f
@ -12869,18 +12869,6 @@ nsGlobalWindow::RemoveGamepad(uint32_t aIndex)
|
||||
mGamepads.Remove(aIndex);
|
||||
}
|
||||
|
||||
// static
|
||||
PLDHashOperator
|
||||
nsGlobalWindow::EnumGamepadsForGet(const uint32_t& aKey, Gamepad* aData,
|
||||
void* aUserArg)
|
||||
{
|
||||
nsTArray<RefPtr<Gamepad> >* array =
|
||||
static_cast<nsTArray<RefPtr<Gamepad> >*>(aUserArg);
|
||||
array->EnsureLengthAtLeast(aData->Index() + 1);
|
||||
(*array)[aData->Index()] = aData;
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
void
|
||||
nsGlobalWindow::GetGamepads(nsTArray<RefPtr<Gamepad> >& aGamepads)
|
||||
{
|
||||
@ -12888,7 +12876,11 @@ nsGlobalWindow::GetGamepads(nsTArray<RefPtr<Gamepad> >& aGamepads)
|
||||
aGamepads.Clear();
|
||||
// mGamepads.Count() may not be sufficient, but it's not harmful.
|
||||
aGamepads.SetCapacity(mGamepads.Count());
|
||||
mGamepads.EnumerateRead(EnumGamepadsForGet, &aGamepads);
|
||||
for (auto iter = mGamepads.Iter(); !iter.Done(); iter.Next()) {
|
||||
Gamepad* gamepad = iter.UserData();
|
||||
aGamepads.EnsureLengthAtLeast(gamepad->Index() + 1);
|
||||
aGamepads[gamepad->Index()] = gamepad;
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<Gamepad>
|
||||
@ -12918,22 +12910,15 @@ nsGlobalWindow::HasSeenGamepadInput()
|
||||
return mHasSeenGamepadInput;
|
||||
}
|
||||
|
||||
// static
|
||||
PLDHashOperator
|
||||
nsGlobalWindow::EnumGamepadsForSync(const uint32_t& aKey, Gamepad* aData,
|
||||
void* aUserArg)
|
||||
{
|
||||
RefPtr<GamepadService> gamepadsvc(GamepadService::GetService());
|
||||
gamepadsvc->SyncGamepadState(aKey, aData);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
void
|
||||
nsGlobalWindow::SyncGamepadState()
|
||||
{
|
||||
MOZ_ASSERT(IsInnerWindow());
|
||||
if (mHasSeenGamepadInput) {
|
||||
mGamepads.EnumerateRead(EnumGamepadsForSync, nullptr);
|
||||
RefPtr<GamepadService> gamepadsvc(GamepadService::GetService());
|
||||
for (auto iter = mGamepads.Iter(); !iter.Done(); iter.Next()) {
|
||||
gamepadsvc->SyncGamepadState(iter.Key(), iter.UserData());
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // MOZ_GAMEPAD
|
||||
|
@ -763,12 +763,6 @@ public:
|
||||
void SetHasSeenGamepadInput(bool aHasSeen);
|
||||
bool HasSeenGamepadInput();
|
||||
void SyncGamepadState();
|
||||
static PLDHashOperator EnumGamepadsForSync(const uint32_t& aKey,
|
||||
mozilla::dom::Gamepad* aData,
|
||||
void* aUserArg);
|
||||
static PLDHashOperator EnumGamepadsForGet(const uint32_t& aKey,
|
||||
mozilla::dom::Gamepad* aData,
|
||||
void* aUserArg);
|
||||
#endif
|
||||
|
||||
// Inner windows only.
|
||||
|
Loading…
Reference in New Issue
Block a user