Bug 1920800 Remove oldImages from check for flushed old principal handle a=RyanVM

The logic should be equivalent when frame IDs on aImages are contiguously
increasing from IDs on previously set frames.

There are currently no callers passing empty aImages, but the logic in this
case would now be as described in the documentation of
UpdatePrincipalHandleForFrameID():

> We will notify mElement that aPrincipalHandle has been applied when all
> FrameIDs prior to aFrameID have been flushed out.

Original Revision: https://phabricator.services.mozilla.com/D223922

Differential Revision: https://phabricator.services.mozilla.com/D224435
This commit is contained in:
Karl Tomlinson 2024-10-03 13:57:39 +00:00
parent 212631ffcc
commit 49292941a3

View file

@ -153,18 +153,13 @@ void VideoFrameContainer::SetCurrentFramesLocked(
mImageContainer->GetCurrentImages(&oldImages);
PrincipalHandle principalHandle = PRINCIPAL_HANDLE_NONE;
ImageContainer::FrameID lastFrameIDForOldPrincipalHandle =
mFrameIDForPendingPrincipalHandle - 1;
if (mPendingPrincipalHandle != PRINCIPAL_HANDLE_NONE &&
((!oldImages.IsEmpty() &&
oldImages.LastElement().mFrameID >= lastFrameIDForOldPrincipalHandle) ||
(!aImages.IsEmpty() &&
aImages[0].mFrameID > lastFrameIDForOldPrincipalHandle))) {
// We are releasing the last FrameID prior to
// `lastFrameIDForOldPrincipalHandle` OR there are no FrameIDs prior to
// `lastFrameIDForOldPrincipalHandle` in the new set of images. This means
// that the old principal handle has been flushed out and we can notify our
// video element about this change.
(aImages.IsEmpty() ||
aImages[0].mFrameID >= mFrameIDForPendingPrincipalHandle)) {
// There are no FrameIDs prior to `mFrameIDForPendingPrincipalHandle`
// in the new set of images.
// This means that the old principal handle has been flushed out and we
// can notify our video element about this change.
principalHandle = mPendingPrincipalHandle;
mLastPrincipalHandle = mPendingPrincipalHandle;
mPendingPrincipalHandle = PRINCIPAL_HANDLE_NONE;