Commit e3b780f0 authored by François Beaufort's avatar François Beaufort Committed by Commit Bot

[Picture-in-Picture] Add enterpictureinpicture video event

Bug: 806249
Change-Id: I64d5e3aeea52b04c4f79e5b7d302f6ffe914ff8a
Reviewed-on: https://chromium-review.googlesource.com/893461Reviewed-by: default avatarMike West <mkwst@chromium.org>
Reviewed-by: default avatarMounir Lamouri (slow) <mlamouri@chromium.org>
Reviewed-by: default avatarapacible <apacible@chromium.org>
Commit-Queue: Mounir Lamouri (slow) <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534049}
parent 5b79ba3c
<!DOCTYPE html>
<title>Test enterpictureinpicture event</title>
<script src='../../resources/testharness.js'></script>
<script src='../../resources/testharnessreport.js'></script>
<script src="../../resources/testdriver.js"></script>
<script src="../../resources/testdriver-vendor.js"></script>
<script src="resources/picture-in-picture-helpers.js"></script>
<body></body>
<script>
async_test(t => {
const video = document.createElement('video');
video.addEventListener('enterpictureinpicture', t.step_func_done(event => {
assert_equals(event.target, video);
assert_equals(event.bubbles, true);
assert_equals(event.cancelable, false);
assert_equals(event.composed, false);
assert_equals(document.pictureInPictureElement, video);
}));
return requestPictureInPictureWithTrustedClick(video);
});
</script>
...@@ -1084,6 +1084,7 @@ html element video ...@@ -1084,6 +1084,7 @@ html element video
property muted property muted
property networkState property networkState
property onencrypted property onencrypted
property onenterpictureinpicture
property onwaitingforkey property onwaitingforkey
property pause property pause
property paused property paused
......
...@@ -3645,6 +3645,7 @@ interface HTMLVideoElement : HTMLMediaElement ...@@ -3645,6 +3645,7 @@ interface HTMLVideoElement : HTMLMediaElement
attribute @@toStringTag attribute @@toStringTag
getter disablePictureInPicture getter disablePictureInPicture
getter height getter height
getter onenterpictureinpicture
getter poster getter poster
getter videoHeight getter videoHeight
getter videoWidth getter videoWidth
...@@ -3662,6 +3663,7 @@ interface HTMLVideoElement : HTMLMediaElement ...@@ -3662,6 +3663,7 @@ interface HTMLVideoElement : HTMLMediaElement
method webkitExitFullscreen method webkitExitFullscreen
setter disablePictureInPicture setter disablePictureInPicture
setter height setter height
setter onenterpictureinpicture
setter poster setter poster
setter width setter width
interface HashChangeEvent : Event interface HashChangeEvent : Event
......
...@@ -107,6 +107,7 @@ ...@@ -107,6 +107,7 @@
"ended", "ended",
"endEvent", "endEvent",
"enter", "enter",
"enterpictureinpicture",
"error", "error",
"exit", "exit",
"fetch", "fetch",
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
"modules/notifications/Notification", "modules/notifications/Notification",
"modules/payments/PaymentRequest", "modules/payments/PaymentRequest",
"modules/permissions/PermissionStatus", "modules/permissions/PermissionStatus",
"modules/picture_in_picture/HTMLVideoElementPictureInPicture",
"modules/presentation/PresentationAvailability", "modules/presentation/PresentationAvailability",
"modules/presentation/PresentationConnection", "modules/presentation/PresentationConnection",
"modules/presentation/PresentationConnectionList", "modules/presentation/PresentationConnectionList",
......
include_rules = [ include_rules = [
"-modules", "-modules",
"+modules/EventTargetModules.h",
"+modules/ModulesExport.h", "+modules/ModulesExport.h",
"+modules/picture_in_picture", "+modules/picture_in_picture",
] ]
\ No newline at end of file
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "modules/picture_in_picture/HTMLVideoElementPictureInPicture.h" #include "modules/picture_in_picture/HTMLVideoElementPictureInPicture.h"
#include "core/dom/DOMException.h" #include "core/dom/DOMException.h"
#include "core/dom/events/Event.h"
#include "core/html/media/HTMLVideoElement.h" #include "core/html/media/HTMLVideoElement.h"
#include "modules/picture_in_picture/PictureInPictureController.h" #include "modules/picture_in_picture/PictureInPictureController.h"
#include "platform/feature_policy/FeaturePolicy.h" #include "platform/feature_policy/FeaturePolicy.h"
...@@ -63,11 +64,13 @@ ScriptPromise HTMLVideoElementPictureInPicture::requestPictureInPicture( ...@@ -63,11 +64,13 @@ ScriptPromise HTMLVideoElementPictureInPicture::requestPictureInPicture(
} }
// TODO(crbug.com/806249): Call element.enterPictureInPicture(). // TODO(crbug.com/806249): Call element.enterPictureInPicture().
// TODO(crbug.com/806249): Trigger enterpictureinpicture event.
PictureInPictureController::Ensure(document).SetPictureInPictureElement( PictureInPictureController::Ensure(document).SetPictureInPictureElement(
element); element);
element.DispatchEvent(
Event::CreateBubble(EventTypeNames::enterpictureinpicture));
return ScriptPromise::CastUndefined(script_state); return ScriptPromise::CastUndefined(script_state);
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define HTMLVideoElementPictureInPicture_h #define HTMLVideoElementPictureInPicture_h
#include "core/dom/QualifiedName.h" #include "core/dom/QualifiedName.h"
#include "modules/EventTargetModules.h"
#include "modules/ModulesExport.h" #include "modules/ModulesExport.h"
#include "platform/heap/Handle.h" #include "platform/heap/Handle.h"
...@@ -26,6 +27,8 @@ class MODULES_EXPORT HTMLVideoElementPictureInPicture { ...@@ -26,6 +27,8 @@ class MODULES_EXPORT HTMLVideoElementPictureInPicture {
static void SetBooleanAttribute(const QualifiedName&, static void SetBooleanAttribute(const QualifiedName&,
HTMLVideoElement&, HTMLVideoElement&,
bool); bool);
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(enterpictureinpicture);
}; };
} // namespace blink } // namespace blink
......
...@@ -12,7 +12,7 @@ partial interface HTMLVideoElement { ...@@ -12,7 +12,7 @@ partial interface HTMLVideoElement {
[CallWith=ScriptState] Promise<void> requestPictureInPicture(); [CallWith=ScriptState] Promise<void> requestPictureInPicture();
// TODO(crbug.com/806249): Implement PiP video events. // TODO(crbug.com/806249): Implement PiP video events.
//attribute EventHandler onenterpictureinpicture; attribute EventHandler onenterpictureinpicture;
//attribute EventHandler onleavepictureinpicture; //attribute EventHandler onleavepictureinpicture;
[CEReactions, Reflect] attribute boolean disablePictureInPicture; [CEReactions, Reflect] attribute boolean disablePictureInPicture;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment