зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1909462 - Switch requestAnimationFrame handles to be uint32_t per spec. r=webidl,emilio
The current version of the spec indicates that we should be using uint32_t instead of int32_t for the handles with requestAnimationFrame and cancelAnimationFrame. https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#animation-frames Differential Revision: https://phabricator.services.mozilla.com/D217427
This commit is contained in:
Родитель
2bae304ffb
Коммит
cedce6cd39
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace mozilla::dom {
|
||||
|
||||
FrameRequest::FrameRequest(FrameRequestCallback& aCallback, int32_t aHandle)
|
||||
FrameRequest::FrameRequest(FrameRequestCallback& aCallback, uint32_t aHandle)
|
||||
: mCallback(&aCallback), mHandle(aHandle) {
|
||||
LogFrameRequestCallback::LogDispatch(mCallback);
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ FrameRequest::FrameRequest(FrameRequestCallback& aCallback, int32_t aHandle)
|
|||
FrameRequest::~FrameRequest() = default;
|
||||
|
||||
nsresult FrameRequestManager::Schedule(FrameRequestCallback& aCallback,
|
||||
int32_t* aHandle) {
|
||||
if (mCallbackCounter == INT32_MAX) {
|
||||
uint32_t* aHandle) {
|
||||
if (mCallbackCounter == UINT32_MAX) {
|
||||
// Can't increment without overflowing; bail out
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ nsresult FrameRequestManager::Schedule(FrameRequestCallback& aCallback,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
bool FrameRequestManager::Cancel(int32_t aHandle) {
|
||||
bool FrameRequestManager::Cancel(uint32_t aHandle) {
|
||||
// mCallbacks is stored sorted by handle
|
||||
if (mCallbacks.RemoveElementSorted(aHandle)) {
|
||||
return true;
|
||||
|
|
|
@ -15,16 +15,16 @@
|
|||
namespace mozilla::dom {
|
||||
|
||||
struct FrameRequest {
|
||||
FrameRequest(FrameRequestCallback& aCallback, int32_t aHandle);
|
||||
FrameRequest(FrameRequestCallback& aCallback, uint32_t aHandle);
|
||||
~FrameRequest();
|
||||
|
||||
// Comparator operators to allow RemoveElementSorted with an
|
||||
// integer argument on arrays of FrameRequest
|
||||
bool operator==(int32_t aHandle) const { return mHandle == aHandle; }
|
||||
bool operator<(int32_t aHandle) const { return mHandle < aHandle; }
|
||||
bool operator==(uint32_t aHandle) const { return mHandle == aHandle; }
|
||||
bool operator<(uint32_t aHandle) const { return mHandle < aHandle; }
|
||||
|
||||
RefPtr<FrameRequestCallback> mCallback;
|
||||
int32_t mHandle;
|
||||
uint32_t mHandle;
|
||||
};
|
||||
|
||||
class FrameRequestManager {
|
||||
|
@ -32,12 +32,12 @@ class FrameRequestManager {
|
|||
FrameRequestManager() = default;
|
||||
~FrameRequestManager() = default;
|
||||
|
||||
nsresult Schedule(FrameRequestCallback& aCallback, int32_t* aHandle);
|
||||
bool Cancel(int32_t aHandle);
|
||||
nsresult Schedule(FrameRequestCallback& aCallback, uint32_t* aHandle);
|
||||
bool Cancel(uint32_t aHandle);
|
||||
|
||||
bool IsEmpty() const { return mCallbacks.IsEmpty(); }
|
||||
|
||||
bool IsCanceled(int32_t aHandle) const {
|
||||
bool IsCanceled(uint32_t aHandle) const {
|
||||
return !mCanceledCallbacks.empty() && mCanceledCallbacks.has(aHandle);
|
||||
}
|
||||
|
||||
|
@ -55,12 +55,12 @@ class FrameRequestManager {
|
|||
|
||||
// The set of frame request callbacks that were canceled but which we failed
|
||||
// to find in mFrameRequestCallbacks.
|
||||
HashSet<int32_t> mCanceledCallbacks;
|
||||
HashSet<uint32_t> mCanceledCallbacks;
|
||||
|
||||
/**
|
||||
* The current frame request callback handle
|
||||
*/
|
||||
int32_t mCallbackCounter = 0;
|
||||
uint32_t mCallbackCounter = 0;
|
||||
};
|
||||
|
||||
inline void ImplCycleCollectionUnlink(FrameRequestManager& aField) {
|
||||
|
|
|
@ -13683,7 +13683,7 @@ void Document::UnlinkOriginalDocumentIfStatic() {
|
|||
}
|
||||
|
||||
nsresult Document::ScheduleFrameRequestCallback(FrameRequestCallback& aCallback,
|
||||
int32_t* aHandle) {
|
||||
uint32_t* aHandle) {
|
||||
nsresult rv = mFrameRequestManager.Schedule(aCallback, aHandle);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
|
@ -13693,13 +13693,13 @@ nsresult Document::ScheduleFrameRequestCallback(FrameRequestCallback& aCallback,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void Document::CancelFrameRequestCallback(int32_t aHandle) {
|
||||
void Document::CancelFrameRequestCallback(uint32_t aHandle) {
|
||||
if (mFrameRequestManager.Cancel(aHandle)) {
|
||||
UpdateFrameRequestCallbackSchedulingState();
|
||||
}
|
||||
}
|
||||
|
||||
bool Document::IsCanceledFrameRequestCallback(int32_t aHandle) const {
|
||||
bool Document::IsCanceledFrameRequestCallback(uint32_t aHandle) const {
|
||||
return mFrameRequestManager.IsCanceled(aHandle);
|
||||
}
|
||||
|
||||
|
|
|
@ -3040,15 +3040,15 @@ class Document : public nsINode,
|
|||
SVGSVGElement* GetSVGRootElement() const;
|
||||
|
||||
nsresult ScheduleFrameRequestCallback(FrameRequestCallback& aCallback,
|
||||
int32_t* aHandle);
|
||||
void CancelFrameRequestCallback(int32_t aHandle);
|
||||
uint32_t* aHandle);
|
||||
void CancelFrameRequestCallback(uint32_t aHandle);
|
||||
|
||||
/**
|
||||
* Returns true if the handle refers to a callback that was canceled that
|
||||
* we did not find in our list of callbacks (e.g. because it is one of those
|
||||
* in the set of callbacks currently queued to be run).
|
||||
*/
|
||||
bool IsCanceledFrameRequestCallback(int32_t aHandle) const;
|
||||
bool IsCanceledFrameRequestCallback(uint32_t aHandle) const;
|
||||
|
||||
/**
|
||||
* Put this document's frame request callbacks into the provided
|
||||
|
|
|
@ -3524,7 +3524,7 @@ double nsGlobalWindowInner::GetDesktopToDeviceScale(ErrorResult& aError) {
|
|||
return presContext->DeviceContext()->GetDesktopToDeviceScale().scale;
|
||||
}
|
||||
|
||||
int32_t nsGlobalWindowInner::RequestAnimationFrame(
|
||||
uint32_t nsGlobalWindowInner::RequestAnimationFrame(
|
||||
FrameRequestCallback& aCallback, ErrorResult& aError) {
|
||||
if (!mDoc) {
|
||||
return 0;
|
||||
|
@ -3537,12 +3537,12 @@ int32_t nsGlobalWindowInner::RequestAnimationFrame(
|
|||
DebuggerNotificationDispatch(this,
|
||||
DebuggerNotificationType::RequestAnimationFrame);
|
||||
|
||||
int32_t handle;
|
||||
uint32_t handle;
|
||||
aError = mDoc->ScheduleFrameRequestCallback(aCallback, &handle);
|
||||
return handle;
|
||||
}
|
||||
|
||||
void nsGlobalWindowInner::CancelAnimationFrame(int32_t aHandle,
|
||||
void nsGlobalWindowInner::CancelAnimationFrame(uint32_t aHandle,
|
||||
ErrorResult& aError) {
|
||||
if (!mDoc) {
|
||||
return;
|
||||
|
|
|
@ -816,11 +816,11 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
|
|||
mozilla::ErrorResult& aError);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
int32_t RequestAnimationFrame(mozilla::dom::FrameRequestCallback& aCallback,
|
||||
mozilla::ErrorResult& aError);
|
||||
uint32_t RequestAnimationFrame(mozilla::dom::FrameRequestCallback& aCallback,
|
||||
mozilla::ErrorResult& aError);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
void CancelAnimationFrame(int32_t aHandle, mozilla::ErrorResult& aError);
|
||||
void CancelAnimationFrame(uint32_t aHandle, mozilla::ErrorResult& aError);
|
||||
|
||||
uint32_t RequestIdleCallback(JSContext* aCx,
|
||||
mozilla::dom::IdleRequestCallback& aCallback,
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
callback FrameRequestCallback = undefined (DOMHighResTimeStamp time);
|
||||
|
||||
interface mixin AnimationFrameProvider {
|
||||
[Throws] long requestAnimationFrame(FrameRequestCallback callback);
|
||||
[Throws] undefined cancelAnimationFrame(long handle);
|
||||
[Throws] unsigned long requestAnimationFrame(FrameRequestCallback callback);
|
||||
[Throws] undefined cancelAnimationFrame(unsigned long handle);
|
||||
};
|
||||
|
|
|
@ -950,7 +950,7 @@ void DedicatedWorkerGlobalScope::Close() {
|
|||
mWorkerPrivate->CloseInternal();
|
||||
}
|
||||
|
||||
int32_t DedicatedWorkerGlobalScope::RequestAnimationFrame(
|
||||
uint32_t DedicatedWorkerGlobalScope::RequestAnimationFrame(
|
||||
FrameRequestCallback& aCallback, ErrorResult& aError) {
|
||||
AssertIsOnWorkerThread();
|
||||
|
||||
|
@ -986,7 +986,7 @@ int32_t DedicatedWorkerGlobalScope::RequestAnimationFrame(
|
|||
}
|
||||
}
|
||||
|
||||
int32_t handle = 0;
|
||||
uint32_t handle = 0;
|
||||
aError = mFrameRequestManager.Schedule(aCallback, &handle);
|
||||
if (!aError.Failed() && mDocumentVisible) {
|
||||
mVsyncChild->TryObserve();
|
||||
|
@ -994,7 +994,7 @@ int32_t DedicatedWorkerGlobalScope::RequestAnimationFrame(
|
|||
return handle;
|
||||
}
|
||||
|
||||
void DedicatedWorkerGlobalScope::CancelAnimationFrame(int32_t aHandle,
|
||||
void DedicatedWorkerGlobalScope::CancelAnimationFrame(uint32_t aHandle,
|
||||
ErrorResult& aError) {
|
||||
AssertIsOnWorkerThread();
|
||||
|
||||
|
|
|
@ -409,11 +409,11 @@ class DedicatedWorkerGlobalScope final
|
|||
void Close();
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
int32_t RequestAnimationFrame(FrameRequestCallback& aCallback,
|
||||
ErrorResult& aError);
|
||||
uint32_t RequestAnimationFrame(FrameRequestCallback& aCallback,
|
||||
ErrorResult& aError);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
void CancelAnimationFrame(int32_t aHandle, ErrorResult& aError);
|
||||
void CancelAnimationFrame(uint32_t aHandle, ErrorResult& aError);
|
||||
|
||||
void OnDocumentVisible(bool aVisible) override;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче