| Index: third_party/WebKit/Source/core/html/HTMLVideoElement.cpp
|
| diff --git a/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp b/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp
|
| index 90a86f6e9897604811faebcbd56eb3150fb0f959..82e313ec93509780da9f1457ebff991bac3dd932 100644
|
| --- a/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp
|
| +++ b/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp
|
| @@ -30,9 +30,14 @@
|
| #include "core/CSSPropertyNames.h"
|
| #include "core/HTMLNames.h"
|
| #include "core/dom/Attribute.h"
|
| +#include "core/dom/ClientRect.h"
|
| #include "core/dom/Document.h"
|
| +#include "core/dom/DocumentUserGestureToken.h"
|
| #include "core/dom/ExceptionCode.h"
|
| #include "core/dom/Fullscreen.h"
|
| +#include "core/dom/ResizeObserver.h"
|
| +#include "core/dom/ResizeObserverCallback.h"
|
| +#include "core/dom/ResizeObserverEntry.h"
|
| #include "core/dom/shadow/ShadowRoot.h"
|
| #include "core/frame/ImageBitmap.h"
|
| #include "core/frame/LocalDOMWindow.h"
|
| @@ -53,8 +58,53 @@ namespace blink {
|
|
|
| using namespace HTMLNames;
|
|
|
| +class HTMLVideoElementResizeObserverCallback final
|
| + : public ResizeObserverCallback {
|
| + public:
|
| + explicit HTMLVideoElementResizeObserverCallback(HTMLVideoElement* video)
|
| + : m_video(video), m_prevOrientationLandscape(false) {
|
| + DCHECK(video);
|
| + }
|
| +
|
| + ~HTMLVideoElementResizeObserverCallback() override = default;
|
| +
|
| + void handleEvent(const HeapVector<Member<ResizeObserverEntry>>& entries,
|
| + ResizeObserver* observer) override {
|
| + if (!m_video->document().settings() ||
|
| + !m_video->document().settings()->getEmbeddedMediaExperienceEnabled())
|
| + return;
|
| +
|
| + DCHECK_EQ(1u, entries.size());
|
| + float documentWidth = entries[0]->contentRect()->width();
|
| + float documentHeight = entries[0]->contentRect()->height();
|
| +
|
| + if (!m_prevOrientationLandscape && documentWidth > documentHeight) {
|
| + UserGestureIndicator gesture(
|
| + DocumentUserGestureToken::create(&m_video->document()));
|
| + m_video->webkitEnterFullscreen();
|
| + }
|
| +
|
| + m_prevOrientationLandscape = documentWidth > documentHeight;
|
| + }
|
| +
|
| + DEFINE_INLINE_TRACE() {
|
| + visitor->trace(m_video);
|
| + ResizeObserverCallback::trace(visitor);
|
| + }
|
| +
|
| + private:
|
| + Member<HTMLVideoElement> m_video;
|
| + bool m_prevOrientationLandscape;
|
| +};
|
| +
|
| inline HTMLVideoElement::HTMLVideoElement(Document& document)
|
| - : HTMLMediaElement(videoTag, document) {
|
| + : HTMLMediaElement(videoTag, document),
|
| + m_customControlsFullscreenDetector(
|
| + new MediaCustomControlsFullscreenDetector(*this)),
|
| + m_resizeObserver(ResizeObserver::create(
|
| + document,
|
| + new HTMLVideoElementResizeObserverCallback(this))) {
|
| + m_resizeObserver->observe(document.documentElement());
|
| if (document.settings()) {
|
| m_defaultPosterURL =
|
| AtomicString(document.settings()->getDefaultVideoPosterURL());
|
| @@ -76,10 +126,12 @@ HTMLVideoElement* HTMLVideoElement::create(Document& document) {
|
| DEFINE_TRACE(HTMLVideoElement) {
|
| visitor->trace(m_imageLoader);
|
| visitor->trace(m_customControlsFullscreenDetector);
|
| + visitor->trace(m_resizeObserver);
|
| HTMLMediaElement::trace(visitor);
|
| }
|
|
|
| void HTMLVideoElement::contextDestroyed(ExecutionContext* context) {
|
| + m_resizeObserver.clear();
|
| if (m_customControlsFullscreenDetector)
|
| m_customControlsFullscreenDetector->contextDestroyed();
|
|
|
|
|