Skip to content

Commit

Permalink
Bug 1753574 - Remove unnecessary nullptr check for screen orientation…
Browse files Browse the repository at this point in the history
… promise. r=smaug

We never return `nullptr` for the promise of screen orientation lock.  So this
is unnecessary now to check `nullptr`.

Differential Revision: https://phabricator.services.mozilla.com/D137969
  • Loading branch information
makotokato committed Mar 2, 2022
1 parent 7d833e9 commit ad14d19
Showing 1 changed file with 11 additions and 28 deletions.
39 changes: 11 additions & 28 deletions dom/base/ScreenOrientation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,27 +188,16 @@ ScreenOrientation::LockOrientationTask::Run() {
return NS_OK;
}

RefPtr<LockOrientationPromise> lockOrientationPromise =
mScreenOrientation->LockDeviceOrientation(mOrientationLock,
mIsFullscreen);

if (NS_WARN_IF(!lockOrientationPromise)) {
mPromise->MaybeReject(NS_ERROR_UNEXPECTED);
mDocument->ClearOrientationPendingPromise();
return NS_OK;
}

lockOrientationPromise->Then(
GetCurrentSerialEventTarget(), __func__,
[self = RefPtr{this}](
const LockOrientationPromise::ResolveOrRejectValue& aValue) {
if (aValue.IsResolve()) {
return NS_OK;
}
self->mPromise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
self->mDocument->ClearOrientationPendingPromise();
return NS_OK;
});
mScreenOrientation->LockDeviceOrientation(mOrientationLock, mIsFullscreen)
->Then(GetCurrentSerialEventTarget(), __func__,
[self = RefPtr{this}](
const LockOrientationPromise::ResolveOrRejectValue& aValue) {
if (aValue.IsResolve()) {
return;
}
self->mPromise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
self->mDocument->ClearOrientationPendingPromise();
});

BrowsingContext* bc = mDocument->GetBrowsingContext();
if (OrientationLockContains(bc->GetCurrentOrientationType()) ||
Expand Down Expand Up @@ -392,14 +381,8 @@ RefPtr<LockOrientationPromise> ScreenOrientation::LockDeviceOrientation(
}
}

RefPtr<LockOrientationPromise> halPromise =
hal::LockScreenOrientation(aOrientation);
if (!halPromise) {
return LockOrientationPromise::CreateAndReject(false, __func__);
}

mTriedToLockDeviceOrientation = true;
return halPromise;
return hal::LockScreenOrientation(aOrientation);
}

void ScreenOrientation::Unlock(ErrorResult& aRv) {
Expand Down

0 comments on commit ad14d19

Please sign in to comment.