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

[Picture-in-Picture] Add PictureInPictureWindow resize event stub

This CL prepares the PictureInPictureWindow interface by adding the
|resize| event handler to PictureInPictureWindow. We currently don't
receive resize events from the backend. Triggering |resize| event will
come in a future CL.

Bug: 806249
Change-Id: Ib10eabc0e35af782dcdb36862535063d2dab0a2c
Reviewed-on: https://chromium-review.googlesource.com/908562Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Reviewed-by: default avatarapacible <apacible@chromium.org>
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#536703}
parent b54dbbb4
......@@ -5105,11 +5105,13 @@ interface PhotoCapabilities
getter imageWidth
getter redEyeReduction
method constructor
interface PictureInPictureWindow
interface PictureInPictureWindow : EventTarget
attribute @@toStringTag
getter height
getter onresize
getter width
method constructor
setter onresize
interface Plugin
attribute @@toStringTag
getter description
......
......@@ -31,6 +31,7 @@
"modules/payments/PaymentRequest",
"modules/permissions/PermissionStatus",
"modules/picture_in_picture/HTMLVideoElementPictureInPicture",
"modules/picture_in_picture/PictureInPictureWindow",
"modules/presentation/PresentationAvailability",
"modules/presentation/PresentationConnection",
"modules/presentation/PresentationConnectionList",
......
......@@ -102,7 +102,8 @@ PictureInPictureController::CreatePictureInPictureWindow(int width,
if (picture_in_picture_window_)
picture_in_picture_window_->OnClose();
picture_in_picture_window_ = new PictureInPictureWindow(width, height);
picture_in_picture_window_ =
new PictureInPictureWindow(GetSupplementable(), width, height);
return picture_in_picture_window_;
}
......
......@@ -4,14 +4,28 @@
#include "modules/picture_in_picture/PictureInPictureWindow.h"
#include "core/dom/ExecutionContext.h"
namespace blink {
PictureInPictureWindow::PictureInPictureWindow(int width, int height)
: width_(width), height_(height) {}
PictureInPictureWindow::PictureInPictureWindow(
ExecutionContext* execution_context,
int width,
int height)
: ContextClient(execution_context), width_(width), height_(height) {}
void PictureInPictureWindow::OnClose() {
width_ = 0;
height_ = 0;
}
const AtomicString& PictureInPictureWindow::InterfaceName() const {
return EventTargetNames::PictureInPictureWindow;
}
void PictureInPictureWindow::Trace(blink::Visitor* visitor) {
EventTargetWithInlineData::Trace(visitor);
ContextClient::Trace(visitor);
}
} // namespace blink
......@@ -5,7 +5,8 @@
#ifndef PictureInPictureWindow_h
#define PictureInPictureWindow_h
#include "platform/bindings/ScriptWrappable.h"
#include "core/dom/ExecutionContext.h"
#include "modules/EventTargetModules.h"
#include "platform/heap/Handle.h"
namespace blink {
......@@ -13,11 +14,13 @@ namespace blink {
// The PictureInPictureWindow is meant to be used only by
// PictureInPictureController and is fundamentally just a simple proxy to get
// information such as dimensions about the current Picture-in-Picture window.
class PictureInPictureWindow : public ScriptWrappable {
class PictureInPictureWindow : public EventTargetWithInlineData,
public ContextClient {
USING_GARBAGE_COLLECTED_MIXIN(PictureInPictureWindow);
DEFINE_WRAPPERTYPEINFO();
public:
PictureInPictureWindow(int width, int height);
PictureInPictureWindow(ExecutionContext*, int width, int height);
int width() const { return width_; }
int height() const { return height_; }
......@@ -25,6 +28,16 @@ class PictureInPictureWindow : public ScriptWrappable {
// Called when Picture-in-Picture window state is closed.
void OnClose();
DEFINE_ATTRIBUTE_EVENT_LISTENER(resize);
// EventTarget overrides.
const AtomicString& InterfaceName() const override;
ExecutionContext* GetExecutionContext() const override {
return ContextClient::GetExecutionContext();
}
void Trace(blink::Visitor*) override;
private:
// The Picture-in-Picture window width in pixels.
int width_;
......
......@@ -6,10 +6,9 @@
[
RuntimeEnabled=PictureInPictureAPI
]
interface PictureInPictureWindow {
interface PictureInPictureWindow : EventTarget {
readonly attribute long width;
readonly attribute long height;
// TODO(crbug.com/806249): Implement PiP window resize event.
// attribute EventHandler onresize;
attribute EventHandler onresize;
};
\ No newline at end of file
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