Modified: trunk/Source/WebCore/ChangeLog (251457 => 251458)
--- trunk/Source/WebCore/ChangeLog 2019-10-22 21:23:26 UTC (rev 251457)
+++ trunk/Source/WebCore/ChangeLog 2019-10-22 21:28:35 UTC (rev 251458)
@@ -1,3 +1,22 @@
+2019-10-22 Peng Liu <peng.l...@apple.com>
+
+ [Picture-in-Picture Web API] The implementation needs runtime logging
+ https://bugs.webkit.org/show_bug.cgi?id=202774
+
+ Reviewed by Eric Carlson.
+
+ Add runtime logging, no new tests needed.
+
+ * Modules/pictureinpicture/HTMLVideoElementPictureInPicture.cpp:
+ (WebCore::HTMLVideoElementPictureInPicture::HTMLVideoElementPictureInPicture):
+ (WebCore::HTMLVideoElementPictureInPicture::~HTMLVideoElementPictureInPicture):
+ (WebCore::HTMLVideoElementPictureInPicture::requestPictureInPicture):
+ (WebCore::HTMLVideoElementPictureInPicture::exitPictureInPicture):
+ (WebCore::HTMLVideoElementPictureInPicture::didEnterPictureInPicture):
+ (WebCore::HTMLVideoElementPictureInPicture::didExitPictureInPicture):
+ (WebCore::HTMLVideoElementPictureInPicture::logChannel const):
+ * Modules/pictureinpicture/HTMLVideoElementPictureInPicture.h:
+
2019-10-22 Yusuke Suzuki <ysuz...@apple.com>
[JSC] Remove non-LargeAllocation restriction for JSCallee
Modified: trunk/Source/WebCore/Modules/pictureinpicture/HTMLVideoElementPictureInPicture.cpp (251457 => 251458)
--- trunk/Source/WebCore/Modules/pictureinpicture/HTMLVideoElementPictureInPicture.cpp 2019-10-22 21:23:26 UTC (rev 251457)
+++ trunk/Source/WebCore/Modules/pictureinpicture/HTMLVideoElementPictureInPicture.cpp 2019-10-22 21:28:35 UTC (rev 251458)
@@ -31,6 +31,7 @@
#include "HTMLVideoElement.h"
#include "JSDOMPromiseDeferred.h"
+#include "Logging.h"
#include "PictureInPictureWindow.h"
#include "VideoTrackList.h"
#include <wtf/IsoMallocInlines.h>
@@ -41,12 +42,18 @@
HTMLVideoElementPictureInPicture::HTMLVideoElementPictureInPicture(HTMLVideoElement& videoElement)
: m_videoElement(videoElement)
+#if !RELEASE_LOG_DISABLED
+ , m_logger(videoElement.document().logger())
+ , m_logIdentifier(uniqueLogIdentifier())
+#endif
{
+ ALWAYS_LOG(LOGIDENTIFIER);
m_videoElement.setPictureInPictureObserver(this);
}
HTMLVideoElementPictureInPicture::~HTMLVideoElementPictureInPicture()
{
+ ALWAYS_LOG(LOGIDENTIFIER);
m_videoElement.setPictureInPictureObserver(nullptr);
}
@@ -64,18 +71,18 @@
void HTMLVideoElementPictureInPicture::requestPictureInPicture(HTMLVideoElement& videoElement, Ref<DeferredPromise>&& promise)
{
if (!videoElement.player() || !videoElement.player()->supportsPictureInPicture()) {
- promise->reject(NotSupportedError);
+ promise->reject(NotSupportedError, "The video element does not support the Picture-in-Picture mode.");
return;
}
if (videoElement.readyState() == HTMLMediaElementEnums::HAVE_NOTHING) {
- promise->reject(InvalidStateError);
+ promise->reject(InvalidStateError, "The video element is not ready to enter the Picture-in-Picture mode.");
return;
}
#if ENABLE(VIDEO_TRACK)
if (!videoElement.videoTracks() || !videoElement.videoTracks()->length()) {
- promise->reject(InvalidStateError);
+ promise->reject(InvalidStateError, "The video element does not have a video track or it has not detected a video track yet.");
return;
}
#endif
@@ -82,18 +89,18 @@
bool userActivationRequired = !videoElement.document().pictureInPictureElement();
if (userActivationRequired && !UserGestureIndicator::processingUserGesture()) {
- promise->reject(NotAllowedError);
+ promise->reject(NotAllowedError, "The request is not triggered by a user activation.");
return;
}
if (videoElement.document().pictureInPictureElement() == &videoElement) {
- promise->reject(NotAllowedError);
+ promise->reject(NotAllowedError, "The video element is already in the Picture-in-Picture mode.");
return;
}
auto videoElementPictureInPicture = HTMLVideoElementPictureInPicture::from(videoElement);
if (videoElementPictureInPicture->m_enterPictureInPicturePromise || videoElementPictureInPicture->m_exitPictureInPicturePromise) {
- promise->reject(NotAllowedError);
+ promise->reject(NotAllowedError, "The video element is processing a Picture-in-Picture request.");
return;
}
@@ -101,7 +108,7 @@
videoElementPictureInPicture->m_enterPictureInPicturePromise = WTFMove(promise);
videoElement.webkitSetPresentationMode(HTMLVideoElement::VideoPresentationMode::PictureInPicture);
} else
- promise->reject(NotSupportedError);
+ promise->reject(NotSupportedError, "The video element does not support the Picture-in-Picture mode.");
}
bool HTMLVideoElementPictureInPicture::autoPictureInPicture(HTMLVideoElement& videoElement)
@@ -126,6 +133,7 @@
void HTMLVideoElementPictureInPicture::exitPictureInPicture(Ref<DeferredPromise>&& promise)
{
+ INFO_LOG(LOGIDENTIFIER);
if (m_enterPictureInPicturePromise || m_exitPictureInPicturePromise) {
promise->reject(NotAllowedError);
return;
@@ -137,6 +145,7 @@
void HTMLVideoElementPictureInPicture::didEnterPictureInPicture()
{
+ INFO_LOG(LOGIDENTIFIER);
m_videoElement.document().setPictureInPictureElement(&m_videoElement);
if (m_enterPictureInPicturePromise) {
m_enterPictureInPicturePromise->resolve();
@@ -146,6 +155,7 @@
void HTMLVideoElementPictureInPicture::didExitPictureInPicture()
{
+ INFO_LOG(LOGIDENTIFIER);
m_videoElement.document().setPictureInPictureElement(nullptr);
if (m_exitPictureInPicturePromise) {
m_exitPictureInPicturePromise->resolve();
@@ -153,6 +163,13 @@
}
}
+#if !RELEASE_LOG_DISABLED
+WTFLogChannel& HTMLVideoElementPictureInPicture::logChannel() const
+{
+ return LogMedia;
+}
+#endif
+
} // namespace WebCore
#endif // ENABLE(PICTURE_IN_PICTURE_API)
Modified: trunk/Source/WebCore/Modules/pictureinpicture/HTMLVideoElementPictureInPicture.h (251457 => 251458)
--- trunk/Source/WebCore/Modules/pictureinpicture/HTMLVideoElementPictureInPicture.h 2019-10-22 21:23:26 UTC (rev 251457)
+++ trunk/Source/WebCore/Modules/pictureinpicture/HTMLVideoElementPictureInPicture.h 2019-10-22 21:28:35 UTC (rev 251458)
@@ -31,6 +31,7 @@
#include "PictureInPictureObserver.h"
#include "Supplementable.h"
#include <wtf/IsoMalloc.h>
+#include <wtf/LoggerHelper.h>
namespace WebCore {
@@ -40,7 +41,11 @@
class HTMLVideoElementPictureInPicture
: public Supplement<HTMLVideoElement>
- , public PictureInPictureObserver {
+ , public PictureInPictureObserver
+#if !RELEASE_LOG_DISABLED
+ , private LoggerHelper
+#endif
+{
WTF_MAKE_ISO_ALLOCATED(HTMLVideoElementPictureInPicture);
public:
HTMLVideoElementPictureInPicture(HTMLVideoElement&);
@@ -58,6 +63,13 @@
void didEnterPictureInPicture();
void didExitPictureInPicture();
+#if !RELEASE_LOG_DISABLED
+ const Logger& logger() const final { return m_logger.get(); }
+ const void* logIdentifier() const final { return m_logIdentifier; }
+ const char* logClassName() const final { return "HTMLVideoElementPictureInPicture"; }
+ WTFLogChannel& logChannel() const final;
+#endif
+
private:
static const char* supplementName() { return "HTMLVideoElementPictureInPicture"; }
@@ -67,6 +79,11 @@
HTMLVideoElement& m_videoElement;
RefPtr<DeferredPromise> m_enterPictureInPicturePromise;
RefPtr<DeferredPromise> m_exitPictureInPicturePromise;
+
+#if !RELEASE_LOG_DISABLED
+ Ref<const Logger> m_logger;
+ const void* m_logIdentifier;
+#endif
};
} // namespace WebCore