Bug 1610570: Add a 'NoTaint=allvalid' attribute as well, and cut Gamepad over to it r=cmartin

Depends on D108247

Differential Revision: https://phabricator.services.mozilla.com/D108248
This commit is contained in:
Tom Ritter 2021-03-23 15:15:39 +00:00
parent fb447b901d
commit 6470917122
9 changed files with 31 additions and 47 deletions

View File

@ -17,9 +17,8 @@ void StartGamepadMonitoring();
void StopGamepadMonitoring();
void SetGamepadLightIndicatorColor(const Tainted<GamepadHandle>& aGamepadHandle,
const Tainted<uint32_t>& aLightColorIndex,
const Tainted<uint8_t>& aRed,
const Tainted<uint8_t>& aGreen,
const Tainted<uint8_t>& aBlue);
const uint8_t& aRed, const uint8_t& aGreen,
const uint8_t& aBlue);
} // namespace dom
} // namespace mozilla

View File

@ -109,9 +109,8 @@ void StopGamepadMonitoring() {
void SetGamepadLightIndicatorColor(const Tainted<GamepadHandle>& aGamepadHandle,
const Tainted<uint32_t>& aLightColorIndex,
const Tainted<uint8_t>& aRed,
const Tainted<uint8_t>& aGreen,
const Tainted<uint8_t>& aBlue) {
const uint8_t& aRed, const uint8_t& aGreen,
const uint8_t& aBlue) {
NS_WARNING("Android doesn't support gamepad light indicator.");
}

View File

@ -213,9 +213,8 @@ class DarwinGamepadService {
void Shutdown();
void SetLightIndicatorColor(const Tainted<GamepadHandle>& aGamepadHandle,
const Tainted<uint32_t>& aLightColorIndex,
const Tainted<uint8_t>& aRed,
const Tainted<uint8_t>& aGreen,
const Tainted<uint8_t>& aBlue);
const uint8_t& aRed, const uint8_t& aGreen,
const uint8_t& aBlue);
friend class DarwinGamepadServiceStartupRunnable;
friend class DarwinGamepadServiceShutdownRunnable;
};
@ -573,8 +572,8 @@ void DarwinGamepadService::Shutdown() {
void DarwinGamepadService::SetLightIndicatorColor(
const Tainted<GamepadHandle>& aGamepadHandle,
const Tainted<uint32_t>& aLightColorIndex, const Tainted<uint8_t>& aRed,
const Tainted<uint8_t>& aGreen, const Tainted<uint8_t>& aBlue) {
const Tainted<uint32_t>& aLightColorIndex, const uint8_t& aRed,
const uint8_t& aGreen, const uint8_t& aBlue) {
// We get aControllerIdx from GamepadPlatformService::AddGamepad(),
// It begins from 1 and is stored at Gamepad.id.
const Gamepad* gamepad = MOZ_FIND_AND_VALIDATE(
@ -593,13 +592,7 @@ void DarwinGamepadService::SetLightIndicatorColor(
}
std::vector<uint8_t> report;
remapper->GetLightColorReport(
MOZ_NO_VALIDATE(aRed, "uint8_t's range is the range of all valid values"),
MOZ_NO_VALIDATE(aGreen,
"uint8_t's range is the range of all valid values"),
MOZ_NO_VALIDATE(aBlue,
"uint8_t's range is the range of all valid values"),
report);
remapper->GetLightColorReport(aRed, aGreen, aBlue, report);
gamepad->WriteOutputReport(report);
}
@ -630,9 +623,8 @@ void StopGamepadMonitoring() {
void SetGamepadLightIndicatorColor(const Tainted<GamepadHandle>& aGamepadHandle,
const Tainted<uint32_t>& aLightColorIndex,
const Tainted<uint8_t>& aRed,
const Tainted<uint8_t>& aGreen,
const Tainted<uint8_t>& aBlue) {
const uint8_t& aRed, const uint8_t& aGreen,
const uint8_t& aBlue) {
MOZ_ASSERT(gService);
if (!gService) {
return;

View File

@ -89,9 +89,8 @@ mozilla::ipc::IPCResult GamepadEventChannelParent::RecvStopVibrateHaptic(
mozilla::ipc::IPCResult GamepadEventChannelParent::RecvLightIndicatorColor(
const Tainted<GamepadHandle>& aHandle,
const Tainted<uint32_t>& aLightColorIndex, const Tainted<uint8_t>& aRed,
const Tainted<uint8_t>& aGreen, const Tainted<uint8_t>& aBlue,
const uint32_t& aPromiseID) {
const Tainted<uint32_t>& aLightColorIndex, const uint8_t& aRed,
const uint8_t& aGreen, const uint8_t& aBlue, const uint32_t& aPromiseID) {
SetGamepadLightIndicatorColor(aHandle, aLightColorIndex, aRed, aGreen, aBlue);
if (SendReplyGamepadPromise(aPromiseID)) {

View File

@ -26,9 +26,8 @@ class GamepadEventChannelParent final : public PGamepadEventChannelParent {
const Tainted<GamepadHandle>& aHandle);
mozilla::ipc::IPCResult RecvLightIndicatorColor(
const Tainted<GamepadHandle>& aHandle,
const Tainted<uint32_t>& aLightColorIndex, const Tainted<uint8_t>& aRed,
const Tainted<uint8_t>& aGreen, const Tainted<uint8_t>& aBlue,
const uint32_t& aPromiseID);
const Tainted<uint32_t>& aLightColorIndex, const uint8_t& aRed,
const uint8_t& aGreen, const uint8_t& aBlue, const uint32_t& aPromiseID);
void DispatchUpdateEvent(const GamepadChangeEvent& aEvent);
GamepadEventChannelParent(const GamepadEventChannelParent&) = delete;

View File

@ -19,7 +19,8 @@ refcounted protocol PGamepadEventChannel {
double aIntensity, double aDuration, [NoTaint=passback] uint32_t aPromiseID);
[Tainted] async StopVibrateHaptic(GamepadHandle aHandle);
[Tainted] async LightIndicatorColor(GamepadHandle aHandle, uint32_t aLightColorIndex,
uint8_t aRed, uint8_t aGreen, uint8_t aBlue, [NoTaint=passback] uint32_t aPromiseID);
[NoTaint=allvalid] uint8_t aRed, [NoTaint=allvalid] uint8_t aGreen,
[NoTaint=allvalid] uint8_t aBlue, [NoTaint=passback] uint32_t aPromiseID);
child:
async GamepadUpdate(GamepadChangeEvent aGamepadEvent);

View File

@ -353,9 +353,8 @@ void StopGamepadMonitoring() {
void SetGamepadLightIndicatorColor(const Tainted<GamepadHandle>& aGamepadHandle,
const Tainted<uint32_t>& aLightColorIndex,
const Tainted<uint8_t>& aRed,
const Tainted<uint8_t>& aGreen,
const Tainted<uint8_t>& aBlue) {
const uint8_t& aRed, const uint8_t& aGreen,
const uint8_t& aBlue) {
// TODO: Bug 1523355.
NS_WARNING("Linux doesn't support gamepad light indicator.");
}

View File

@ -335,9 +335,8 @@ class WindowsGamepadService {
bool HandleRawInput(HRAWINPUT handle);
void SetLightIndicatorColor(const Tainted<GamepadHandle>& aGamepadHandle,
const Tainted<uint32_t>& aLightColorIndex,
const Tainted<uint8_t>& aRed,
const Tainted<uint8_t>& aGreen,
const Tainted<uint8_t>& aBlue);
const uint8_t& aRed, const uint8_t& aGreen,
const uint8_t& aBlue);
size_t WriteOutputReport(const std::vector<uint8_t>& aReport);
static void XInputMessageLoopOnceCallback(nsITimer* aTimer, void* aClosure);
static void DevicesChangeCallback(nsITimer* aTimer, void* aService);
@ -892,8 +891,8 @@ bool WindowsGamepadService::HandleRawInput(HRAWINPUT handle) {
void WindowsGamepadService::SetLightIndicatorColor(
const Tainted<GamepadHandle>& aGamepadHandle,
const Tainted<uint32_t>& aLightColorIndex, const Tainted<uint8_t>& aRed,
const Tainted<uint8_t>& aGreen, const Tainted<uint8_t>& aBlue) {
const Tainted<uint32_t>& aLightColorIndex, const uint8_t& aRed,
const uint8_t& aGreen, const uint8_t& aBlue) {
// We get aControllerIdx from GamepadPlatformService::AddGamepad(),
// It begins from 1 and is stored at Gamepad.id.
const Gamepad* gamepad = (MOZ_FIND_AND_VALIDATE(
@ -912,13 +911,7 @@ void WindowsGamepadService::SetLightIndicatorColor(
}
std::vector<uint8_t> report;
remapper->GetLightColorReport(
MOZ_NO_VALIDATE(aRed, "uint8_t's range is the range of all valid values"),
MOZ_NO_VALIDATE(aGreen,
"uint8_t's range is the range of all valid values"),
MOZ_NO_VALIDATE(aBlue,
"uint8_t's range is the range of all valid values"),
report);
remapper->GetLightColorReport(aRed, aGreen, aBlue, report);
WriteOutputReport(report);
}
@ -1130,9 +1123,8 @@ void StopGamepadMonitoring() {
void SetGamepadLightIndicatorColor(const Tainted<GamepadHandle>& aGamepadHandle,
const Tainted<uint32_t>& aLightColorIndex,
const Tainted<uint8_t>& aRed,
const Tainted<uint8_t>& aGreen,
const Tainted<uint8_t>& aBlue) {
const uint8_t& aRed, const uint8_t& aGreen,
const uint8_t& aBlue) {
MOZ_ASSERT(gService);
if (!gService) {
return;

View File

@ -1301,7 +1301,11 @@ class GatherDecls(TcheckVisitor):
self.checkAttributes(
param.attributes,
{
"NoTaint": ("passback",)
# Passback indicates that the argument is unused by the Parent and is
# merely returned to the Child later.
# AllValid indicates that the entire span of values representable by
# the type are acceptable. e.g. 0-255 in a uint8
"NoTaint": ("passback", "allvalid")
},
)