|
Lines 31-36
a/Source/WebCore/Modules/pictureinpicture/HTMLVideoElementPictureInPicture.cpp_sec1
|
| 31 |
|
31 |
|
| 32 |
#include "HTMLVideoElement.h" |
32 |
#include "HTMLVideoElement.h" |
| 33 |
#include "JSDOMPromiseDeferred.h" |
33 |
#include "JSDOMPromiseDeferred.h" |
|
|
34 |
#include "JSPictureInPictureWindow.h" |
| 34 |
#include "Logging.h" |
35 |
#include "Logging.h" |
| 35 |
#include "PictureInPictureWindow.h" |
36 |
#include "PictureInPictureWindow.h" |
| 36 |
#include "VideoTrackList.h" |
37 |
#include "VideoTrackList.h" |
|
Lines 42-47
WTF_MAKE_ISO_ALLOCATED_IMPL(HTMLVideoElementPictureInPicture);
a/Source/WebCore/Modules/pictureinpicture/HTMLVideoElementPictureInPicture.cpp_sec2
|
| 42 |
|
43 |
|
| 43 |
HTMLVideoElementPictureInPicture::HTMLVideoElementPictureInPicture(HTMLVideoElement& videoElement) |
44 |
HTMLVideoElementPictureInPicture::HTMLVideoElementPictureInPicture(HTMLVideoElement& videoElement) |
| 44 |
: m_videoElement(videoElement) |
45 |
: m_videoElement(videoElement) |
|
|
46 |
, m_pictureInPictureWindow(PictureInPictureWindow::create(videoElement.document())) |
| 45 |
#if !RELEASE_LOG_DISABLED |
47 |
#if !RELEASE_LOG_DISABLED |
| 46 |
, m_logger(videoElement.document().logger()) |
48 |
, m_logger(videoElement.document().logger()) |
| 47 |
, m_logIdentifier(uniqueLogIdentifier()) |
49 |
, m_logIdentifier(uniqueLogIdentifier()) |
|
Lines 70-80
HTMLVideoElementPictureInPicture* HTMLVideoElementPictureInPicture::from(HTMLVid
a/Source/WebCore/Modules/pictureinpicture/HTMLVideoElementPictureInPicture.cpp_sec3
|
| 70 |
|
72 |
|
| 71 |
void HTMLVideoElementPictureInPicture::requestPictureInPicture(HTMLVideoElement& videoElement, Ref<DeferredPromise>&& promise) |
73 |
void HTMLVideoElementPictureInPicture::requestPictureInPicture(HTMLVideoElement& videoElement, Ref<DeferredPromise>&& promise) |
| 72 |
{ |
74 |
{ |
| 73 |
if (!videoElement.player() || !videoElement.player()->supportsPictureInPicture()) { |
|
|
| 74 |
promise->reject(NotSupportedError, "The video element does not support the Picture-in-Picture mode."); |
| 75 |
return; |
| 76 |
} |
| 77 |
|
| 78 |
if (videoElement.readyState() == HTMLMediaElementEnums::HAVE_NOTHING) { |
75 |
if (videoElement.readyState() == HTMLMediaElementEnums::HAVE_NOTHING) { |
| 79 |
promise->reject(InvalidStateError, "The video element is not ready to enter the Picture-in-Picture mode."); |
76 |
promise->reject(InvalidStateError, "The video element is not ready to enter the Picture-in-Picture mode."); |
| 80 |
return; |
77 |
return; |
|
Lines 93-104
void HTMLVideoElementPictureInPicture::requestPictureInPicture(HTMLVideoElement&
a/Source/WebCore/Modules/pictureinpicture/HTMLVideoElementPictureInPicture.cpp_sec4
|
| 93 |
return; |
90 |
return; |
| 94 |
} |
91 |
} |
| 95 |
|
92 |
|
|
|
93 |
auto videoElementPictureInPicture = HTMLVideoElementPictureInPicture::from(videoElement); |
| 96 |
if (videoElement.document().pictureInPictureElement() == &videoElement) { |
94 |
if (videoElement.document().pictureInPictureElement() == &videoElement) { |
| 97 |
promise->reject(NotAllowedError, "The video element is already in the Picture-in-Picture mode."); |
95 |
promise->resolve<IDLInterface<PictureInPictureWindow>>(*(videoElementPictureInPicture->m_pictureInPictureWindow)); |
| 98 |
return; |
96 |
return; |
| 99 |
} |
97 |
} |
| 100 |
|
98 |
|
| 101 |
auto videoElementPictureInPicture = HTMLVideoElementPictureInPicture::from(videoElement); |
|
|
| 102 |
if (videoElementPictureInPicture->m_enterPictureInPicturePromise || videoElementPictureInPicture->m_exitPictureInPicturePromise) { |
99 |
if (videoElementPictureInPicture->m_enterPictureInPicturePromise || videoElementPictureInPicture->m_exitPictureInPicturePromise) { |
| 103 |
promise->reject(NotAllowedError, "The video element is processing a Picture-in-Picture request."); |
100 |
promise->reject(NotAllowedError, "The video element is processing a Picture-in-Picture request."); |
| 104 |
return; |
101 |
return; |
|
Lines 143-159
void HTMLVideoElementPictureInPicture::exitPictureInPicture(Ref<DeferredPromise>
a/Source/WebCore/Modules/pictureinpicture/HTMLVideoElementPictureInPicture.cpp_sec5
|
| 143 |
m_videoElement.webkitSetPresentationMode(HTMLVideoElement::VideoPresentationMode::Inline); |
140 |
m_videoElement.webkitSetPresentationMode(HTMLVideoElement::VideoPresentationMode::Inline); |
| 144 |
} |
141 |
} |
| 145 |
|
142 |
|
| 146 |
void HTMLVideoElementPictureInPicture::didEnterPictureInPicture(IntSize windowSize) |
143 |
void HTMLVideoElementPictureInPicture::didEnterPictureInPicture(const IntSize& windowSize) |
| 147 |
{ |
144 |
{ |
| 148 |
INFO_LOG(LOGIDENTIFIER); |
145 |
INFO_LOG(LOGIDENTIFIER); |
| 149 |
m_videoElement.document().setPictureInPictureElement(&m_videoElement); |
146 |
m_videoElement.document().setPictureInPictureElement(&m_videoElement); |
|
|
147 |
m_pictureInPictureWindow->setSize(windowSize); |
| 148 |
|
| 150 |
if (m_enterPictureInPicturePromise) { |
149 |
if (m_enterPictureInPicturePromise) { |
| 151 |
EnterPictureInPictureEvent::Init initializer; |
150 |
EnterPictureInPictureEvent::Init initializer; |
| 152 |
initializer.bubbles = true; |
151 |
initializer.bubbles = true; |
| 153 |
initializer.pictureInPictureWindow = PictureInPictureWindow::create(m_videoElement.document(), windowSize.width(), windowSize.height()); |
152 |
initializer.pictureInPictureWindow = m_pictureInPictureWindow; |
| 154 |
m_videoElement.scheduleEvent(EnterPictureInPictureEvent::create(eventNames().enterpictureinpictureEvent, WTFMove(initializer))); |
153 |
m_videoElement.scheduleEvent(EnterPictureInPictureEvent::create(eventNames().enterpictureinpictureEvent, WTFMove(initializer))); |
| 155 |
|
154 |
m_enterPictureInPicturePromise->resolve<IDLInterface<PictureInPictureWindow>>(*m_pictureInPictureWindow); |
| 156 |
m_enterPictureInPicturePromise->resolve(); |
|
|
| 157 |
m_enterPictureInPicturePromise = nullptr; |
155 |
m_enterPictureInPicturePromise = nullptr; |
| 158 |
} |
156 |
} |
| 159 |
} |
157 |
} |
|
Lines 161-175
void HTMLVideoElementPictureInPicture::didEnterPictureInPicture(IntSize windowSi
a/Source/WebCore/Modules/pictureinpicture/HTMLVideoElementPictureInPicture.cpp_sec6
|
| 161 |
void HTMLVideoElementPictureInPicture::didExitPictureInPicture() |
159 |
void HTMLVideoElementPictureInPicture::didExitPictureInPicture() |
| 162 |
{ |
160 |
{ |
| 163 |
INFO_LOG(LOGIDENTIFIER); |
161 |
INFO_LOG(LOGIDENTIFIER); |
|
|
162 |
m_pictureInPictureWindow->close(); |
| 164 |
m_videoElement.document().setPictureInPictureElement(nullptr); |
163 |
m_videoElement.document().setPictureInPictureElement(nullptr); |
|
|
164 |
|
| 165 |
if (m_exitPictureInPicturePromise) { |
165 |
if (m_exitPictureInPicturePromise) { |
| 166 |
m_videoElement.scheduleEvent(Event::create(eventNames().leavepictureinpictureEvent, Event::CanBubble::Yes, Event::IsCancelable::No)); |
166 |
m_videoElement.scheduleEvent(Event::create(eventNames().leavepictureinpictureEvent, Event::CanBubble::Yes, Event::IsCancelable::No)); |
| 167 |
|
|
|
| 168 |
m_exitPictureInPicturePromise->resolve(); |
167 |
m_exitPictureInPicturePromise->resolve(); |
| 169 |
m_exitPictureInPicturePromise = nullptr; |
168 |
m_exitPictureInPicturePromise = nullptr; |
| 170 |
} |
169 |
} |
| 171 |
} |
170 |
} |
| 172 |
|
171 |
|
|
|
172 |
void HTMLVideoElementPictureInPicture::pictureInPictureWindowResized(const IntSize& windowSize) |
| 173 |
{ |
| 174 |
if (m_pictureInPictureWindow->width() == windowSize.width() && m_pictureInPictureWindow->height() == windowSize.height()) |
| 175 |
return; |
| 176 |
|
| 177 |
m_pictureInPictureWindow->setSize(windowSize); |
| 178 |
auto resizeEvent = Event::create(eventNames().resizeEvent, Event::CanBubble::Yes, Event::IsCancelable::No); |
| 179 |
resizeEvent->setTarget(m_pictureInPictureWindow); |
| 180 |
m_videoElement.scheduleEvent(WTFMove(resizeEvent)); |
| 181 |
} |
| 182 |
|
| 173 |
#if !RELEASE_LOG_DISABLED |
183 |
#if !RELEASE_LOG_DISABLED |
| 174 |
WTFLogChannel& HTMLVideoElementPictureInPicture::logChannel() const |
184 |
WTFLogChannel& HTMLVideoElementPictureInPicture::logChannel() const |
| 175 |
{ |
185 |
{ |
|
Lines 177-186
WTFLogChannel& HTMLVideoElementPictureInPicture::logChannel() const
a/Source/WebCore/Modules/pictureinpicture/HTMLVideoElementPictureInPicture.cpp_sec7
|
| 177 |
} |
187 |
} |
| 178 |
#endif |
188 |
#endif |
| 179 |
|
189 |
|
| 180 |
void HTMLVideoElementPictureInPicture::pictureInPictureWindowResized(IntSize) |
|
|
| 181 |
{ |
| 182 |
} |
| 183 |
|
| 184 |
} // namespace WebCore |
190 |
} // namespace WebCore |
| 185 |
|
191 |
|
| 186 |
#endif // ENABLE(PICTURE_IN_PICTURE_API) |
192 |
#endif // ENABLE(PICTURE_IN_PICTURE_API) |