Bug 1543122 - Add a privileged UAWidget-accessible WebIDL API for triggering Picture-in-Picture. r=jya,Ehsan

Differential Revision: https://phabricator.services.mozilla.com/D26777

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mike Conley 2019-04-13 01:22:20 +00:00
Родитель ab8986d79a
Коммит b5797d9c16
3 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -548,5 +548,15 @@ void HTMLVideoElement::EndCloningVisually() {
}
}
void HTMLVideoElement::TogglePictureInPicture(ErrorResult& error) {
// The MozTogglePictureInPicture event is listen for via the
// PictureInPictureChild actor, which is responsible for opening the new
// window and starting the visual clone.
nsresult rv = DispatchEvent(NS_LITERAL_STRING("MozTogglePictureInPicture"));
if (NS_FAILED(rv)) {
error.Throw(rv);
}
}
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -145,6 +145,8 @@ class HTMLVideoElement final : public HTMLMediaElement {
bool IsCloningElementVisually() const { return !!mVisualCloneTarget; }
void TogglePictureInPicture(ErrorResult& rv);
protected:
virtual ~HTMLVideoElement();

Просмотреть файл

@ -69,6 +69,12 @@ partial interface HTMLVideoElement {
// <video> element (see cloneElementVisually).
[Func="IsChromeOrXBLOrUAWidget"]
readonly attribute boolean isCloningElementVisually;
// Fires the privileged MozTogglePictureInPicture event to enter
// Picture-in-Picture. Call this when triggering Picture-in-Picture
// from the video controls UAWidget.
[Throws, Func="IsChromeOrXBLOrUAWidget"]
void togglePictureInPicture();
};
// https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#idl-def-HTMLVideoElement