Skip to content

Commit

Permalink
Add new experimental presentation mode for full-window video viewing
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=266241
rdar://119503825

Reviewed by Tim Nguyen and Jer Noble.

This patch adds a new WebKit presentation mode, In-Window Fullscreen, that puts a video element
In a fullscreen mode that is limited to the application's window. This mode is put behind a WebKit internal feature flag. This patch also adds a new pseudo-class for user agents only to style the video element when in this presentation mode: -internal-in-window-full-screen.

* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/Modules/modern-media-controls/media/media-controller.js:
(MediaController.prototype.get isFullscreen):
(WebCore::SelectorChecker::checkOne const):
* Source/WebCore/css/SelectorCheckerTestFunctions.h:
(WebCore::matchesInWindowFullScreenPseudoClass):
* Source/WebCore/css/SelectorPseudoClassAndCompatibilityElementMap.in:
* Source/WebCore/cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::JSC_DEFINE_JIT_OPERATION):
(WebCore::SelectorCompiler::addPseudoClassType):
* Source/WebCore/dom/Element.h:
* Source/WebCore/dom/FullscreenManager.cpp:
(WebCore::FullscreenManager::requestFullscreenForElement):
(WebCore::FullscreenManager::willEnterFullscreen):
* Source/WebCore/dom/FullscreenManager.h:
* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::enterFullscreen):
(WebCore::HTMLMediaElement::exitFullscreen):
(WebCore::HTMLMediaElement::willBecomeFullscreenElement):
(WebCore::HTMLMediaElement::willStopBeingFullscreenElement):
* Source/WebCore/html/HTMLMediaElement.h:
* Source/WebCore/html/HTMLVideoElement.cpp:
(WebCore::toFullscreenMode):
(WebCore::HTMLVideoElement::toPresentationMode):
(WebCore::HTMLVideoElement::webkitSetPresentationMode):
* Source/WebCore/html/HTMLVideoElement.h:
* Source/WebCore/html/HTMLVideoElement.idl:
* Source/WebCore/page/ChromeClient.h:
(WebCore::ChromeClient::enterFullScreenForElement):
* Source/WebCore/platform/graphics/MediaPlayerEnums.h:
* Source/WebKit/UIProcess/WebFullScreenManagerProxy.cpp:
(WebKit::WebFullScreenManagerProxy::willEnterFullScreen):
* Source/WebKit/UIProcess/WebFullScreenManagerProxy.h:
* Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp:
(WebKit::WebFullScreenManager::enterFullScreenForElement):
(WebKit::WebFullScreenManager::exitFullScreenForElement):
(WebKit::WebFullScreenManager::willEnterFullScreen):
* Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.h:
* Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.messages.in:
* Source/WebKit/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.cpp:
(WebKit::InjectedBundlePageFullScreenClient::enterFullScreenForElement):
(WebKit::InjectedBundlePageFullScreenClient::exitFullScreenForElement):
* Source/WebKit/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.h:
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::enterFullScreenForElement):
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h:
* Source/WebKit/WebProcess/cocoa/VideoPresentationManager.mm:
(WebKit::VideoPresentationManager::supportsVideoFullscreen const):

Canonical link: https://commits.webkit.org/273923@main
  • Loading branch information
danae404 committed Feb 1, 2024
1 parent fd1f0b7 commit f35e3cd
Show file tree
Hide file tree
Showing 28 changed files with 124 additions and 53 deletions.
14 changes: 14 additions & 0 deletions Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3247,6 +3247,20 @@ ImperativeSlotAPIEnabled:
WebCore:
default: true

InWindowFullscreenEnabled:
type: bool
status: internal
category: media
humanReadableName: "In-Window Fullscreen"
humanReadableDescription: "Enable In-Window Fullscreen"
defaultValue:
WebKitLegacy:
default: false
WebKit:
default: false
WebCore:
default: false

InactiveMediaCaptureSteamRepromptIntervalInMinutes:
type: double
status: embedder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class MediaController

get isFullscreen()
{
return this.media.webkitSupportsPresentationMode ? this.media.webkitPresentationMode === "fullscreen" : this.media.webkitDisplayingFullscreen;
return this.media.webkitSupportsPresentationMode ? this.media.webkitPresentationMode === "fullscreen" || this.media.webkitPresentationMode === "in-window" : this.media.webkitDisplayingFullscreen;
}

get layoutTraits()
Expand Down
3 changes: 3 additions & 0 deletions Source/WebCore/css/CSSPseudoSelectors.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
"conditional": "ENABLE(FULLSCREEN_API)"
},
"-internal-html-document": {},
"-internal-in-window-full-screen": {
"conditional": "ENABLE(FULLSCREEN_API)"
},
"-internal-media-document": {},
"-webkit-any": {
"argument": "required",
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/css/SelectorChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,8 @@ bool SelectorChecker::checkOne(CheckingContext& checkingContext, const LocalCont
return matchesAnimatingFullscreenTransitionPseudoClass(element);
case CSSSelector::PseudoClass::InternalFullscreenDocument:
return matchesFullscreenDocumentPseudoClass(element);
case CSSSelector::PseudoClass::InternalInWindowFullScreen:
return matchesInWindowFullScreenPseudoClass(element);
#endif
#if ENABLE(PICTURE_IN_PICTURE_API)
case CSSSelector::PseudoClass::PictureInPicture:
Expand Down
9 changes: 9 additions & 0 deletions Source/WebCore/css/SelectorCheckerTestFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,15 @@ ALWAYS_INLINE bool matchesFullscreenDocumentPseudoClass(const Element& element)
return fullscreenManager && fullscreenManager->fullscreenElement();
}

ALWAYS_INLINE bool matchesInWindowFullScreenPseudoClass(const Element& element)
{
if (&element != element.document().fullscreenManager().currentFullscreenElement())
return false;

auto* mediaElement = dynamicDowncast<HTMLMediaElement>(element);
return mediaElement && mediaElement->fullscreenMode() == HTMLMediaElementEnums::VideoFullscreenModeInWindow;
}

#endif

#if ENABLE(PICTURE_IN_PICTURE_API)
Expand Down
10 changes: 10 additions & 0 deletions Source/WebCore/cssjit/SelectorCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ using PseudoClassesSet = HashSet<CSSSelector::PseudoClass, IntHash<CSSSelector::
v(operationMatchesFullscreenPseudoClass) \
v(operationMatchesFullscreenDocumentPseudoClass) \
v(operationMatchesAnimatingFullscreenTransitionPseudoClass) \
v(operationMatchesInWindowFullScreenPseudoClass) \
v(operationMatchesPictureInPicturePseudoClass) \
v(operationMatchesFutureCuePseudoClass) \
v(operationMatchesPastCuePseudoClass) \
Expand Down Expand Up @@ -257,6 +258,7 @@ static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(operationMatchesLangPseudo
static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(operationMatchesFullscreenPseudoClass, bool, (const Element&));
static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(operationMatchesFullscreenDocumentPseudoClass, bool, (const Element&));
static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(operationMatchesAnimatingFullscreenTransitionPseudoClass, bool, (const Element&));
static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(operationMatchesInWindowFullScreenPseudoClass, bool, (const Element&));
#endif
#if ENABLE(PICTURE_IN_PICTURE_API)
static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(operationMatchesPictureInPicturePseudoClass, bool, (const Element&));
Expand Down Expand Up @@ -908,6 +910,11 @@ JSC_DEFINE_JIT_OPERATION(operationMatchesAnimatingFullscreenTransitionPseudoClas
COUNT_SELECTOR_OPERATION(operationMatchesAnimatingFullscreenTransitionPseudoClass);
return matchesAnimatingFullscreenTransitionPseudoClass(element);
}
JSC_DEFINE_JIT_OPERATION(operationMatchesInWindowFullScreenPseudoClass, bool, (const Element& element))
{
COUNT_SELECTOR_OPERATION(operationMatchesInWindowFullScreenPseudoClass);
return matchesInWindowFullScreenPseudoClass(element);
}
#endif

#if ENABLE(PICTURE_IN_PICTURE_API)
Expand Down Expand Up @@ -1106,6 +1113,9 @@ static inline FunctionType addPseudoClassType(const CSSSelector& selector, Selec
case CSSSelector::PseudoClass::InternalAnimatingFullscreenTransition:
fragment.unoptimizedPseudoClasses.append(CodePtr<JSC::OperationPtrTag>(operationMatchesAnimatingFullscreenTransitionPseudoClass));
return FunctionType::SimpleSelectorChecker;
case CSSSelector::PseudoClass::InternalInWindowFullScreen:
fragment.unoptimizedPseudoClasses.append(CodePtr<JSC::OperationPtrTag>(operationMatchesInWindowFullScreenPseudoClass));
return FunctionType::SimpleSelectorChecker;
#endif

#if ENABLE(PICTURE_IN_PICTURE_API)
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/dom/Element.h
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ class Element : public ContainerNode {
virtual void prepareForDocumentSuspension() { }
virtual void resumeFromDocumentSuspension() { }

virtual void willBecomeFullscreenElement();
void willBecomeFullscreenElement();
virtual void ancestorWillEnterFullscreen() { }
virtual void didBecomeFullscreenElement() { }
virtual void willStopBeingFullscreenElement() { }
Expand Down
16 changes: 10 additions & 6 deletions Source/WebCore/dom/FullscreenManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Ref<Document> FullscreenManager::protectedTopDocument()
}

// https://fullscreen.spec.whatwg.org/#dom-element-requestfullscreen
void FullscreenManager::requestFullscreenForElement(Ref<Element>&& element, RefPtr<DeferredPromise>&& promise, FullscreenCheckType checkType)
void FullscreenManager::requestFullscreenForElement(Ref<Element>&& element, RefPtr<DeferredPromise>&& promise, FullscreenCheckType checkType, HTMLMediaElementEnums::VideoFullscreenMode mode)
{
auto identifier = LOGIDENTIFIER;

Expand Down Expand Up @@ -174,7 +174,7 @@ void FullscreenManager::requestFullscreenForElement(Ref<Element>&& element, RefP
// We cache the top document here, so we still have the correct one when we exit fullscreen after navigation.
m_topDocument = document().topDocument();

protectedDocument()->eventLoop().queueTask(TaskSource::MediaElement, [this, weakThis = WeakPtr { *this }, element = WTFMove(element), promise = WTFMove(promise), checkType, hasKeyboardAccess, failedPreflights, identifier] () mutable {
protectedDocument()->eventLoop().queueTask(TaskSource::MediaElement, [this, weakThis = WeakPtr { *this }, element = WTFMove(element), promise = WTFMove(promise), checkType, hasKeyboardAccess, failedPreflights, identifier, mode] () mutable {
if (!weakThis) {
if (promise)
promise->reject(Exception { ExceptionCode::TypeError });
Expand Down Expand Up @@ -246,7 +246,7 @@ void FullscreenManager::requestFullscreenForElement(Ref<Element>&& element, RefP
// 5. Return, and run the remaining steps asynchronously.
// 6. Optionally, perform some animation.
m_areKeysEnabledInFullscreen = hasKeyboardAccess;
document->eventLoop().queueTask(TaskSource::MediaElement, [this, weakThis = WTFMove(weakThis), promise = WTFMove(promise), element = WTFMove(element), failedPreflights = WTFMove(failedPreflights), identifier] () mutable {
document->eventLoop().queueTask(TaskSource::MediaElement, [this, weakThis = WTFMove(weakThis), promise = WTFMove(promise), element = WTFMove(element), failedPreflights = WTFMove(failedPreflights), identifier, mode] () mutable {
if (!weakThis) {
if (promise)
promise->reject(Exception { ExceptionCode::TypeError });
Expand All @@ -267,7 +267,8 @@ void FullscreenManager::requestFullscreenForElement(Ref<Element>&& element, RefP
m_pendingPromise = WTFMove(promise);

INFO_LOG(identifier, "task - success");
page->chrome().client().enterFullScreenForElement(element);

page->chrome().client().enterFullScreenForElement(element, mode);
});

// 7. Optionally, display a message indicating how the user can exit displaying the context object fullscreen.
Expand Down Expand Up @@ -498,7 +499,7 @@ static void markRendererDirtyAfterTopLayerChange(RenderElement* renderer, Render
renderBox->setNeedsLayout();
}

bool FullscreenManager::willEnterFullscreen(Element& element)
bool FullscreenManager::willEnterFullscreen(Element& element, HTMLMediaElementEnums::VideoFullscreenMode mode)
{
if (backForwardCacheState() != Document::NotInBackForwardCache) {
ERROR_LOG(LOGIDENTIFIER, "Document in the BackForwardCache; bailing");
Expand Down Expand Up @@ -528,7 +529,10 @@ bool FullscreenManager::willEnterFullscreen(Element& element)
INFO_LOG(LOGIDENTIFIER);
ASSERT(page()->settings().fullScreenEnabled());

element.willBecomeFullscreenElement();
if (RefPtr mediaElement = dynamicDowncast<HTMLMediaElement>(element))
mediaElement->willBecomeFullscreenElement(mode);
else
element.willBecomeFullscreenElement();

ASSERT(&element == m_pendingFullscreenElement);
m_pendingFullscreenElement = nullptr;
Expand Down
6 changes: 3 additions & 3 deletions Source/WebCore/dom/FullscreenManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "Document.h"
#include "FrameDestructionObserverInlines.h"
#include "GCReachableRef.h"
#include "HTMLMediaElement.h"
#include "LayoutRect.h"
#include "Page.h"
#include <wtf/Deque.h>
Expand Down Expand Up @@ -70,9 +71,8 @@ class FullscreenManager final : public CanMakeWeakPtr<FullscreenManager>, public
EnforceIFrameAllowFullscreenRequirement,
ExemptIFrameAllowFullscreenRequirement,
};
WEBCORE_EXPORT void requestFullscreenForElement(Ref<Element>&&, RefPtr<DeferredPromise>&&, FullscreenCheckType);

WEBCORE_EXPORT bool willEnterFullscreen(Element&);
WEBCORE_EXPORT void requestFullscreenForElement(Ref<Element>&&, RefPtr<DeferredPromise>&&, FullscreenCheckType, HTMLMediaElementEnums::VideoFullscreenMode = HTMLMediaElementEnums::VideoFullscreenModeStandard);
WEBCORE_EXPORT bool willEnterFullscreen(Element&, HTMLMediaElementEnums::VideoFullscreenMode = HTMLMediaElementEnums::VideoFullscreenModeStandard);
WEBCORE_EXPORT bool didEnterFullscreen();
WEBCORE_EXPORT bool willExitFullscreen();
WEBCORE_EXPORT bool didExitFullscreen();
Expand Down
27 changes: 16 additions & 11 deletions Source/WebCore/html/HTMLMediaElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@ static bool defaultVolumeLocked()
#endif
}

static bool isInWindowOrStandardFullscreen(HTMLMediaElementEnums::VideoFullscreenMode mode)
{
return mode == HTMLMediaElementEnums::VideoFullscreenModeStandard || mode == HTMLMediaElementEnums::VideoFullscreenModeInWindow;
}

HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& document, bool createdByParser)
: HTMLElement(tagName, document, { TypeFlag::HasCustomStyleResolveCallbacks, TypeFlag::HasDidMoveToNewDocument })
, ActiveDOMObject(document)
Expand Down Expand Up @@ -6830,10 +6835,10 @@ void HTMLMediaElement::enterFullscreen(VideoFullscreenMode mode)
#else
constexpr bool videoUsesElementFullscreen = true;
#endif
if (videoUsesElementFullscreen && document().settings().fullScreenEnabled() && mode == VideoFullscreenModeStandard) {
if (videoUsesElementFullscreen && document().settings().fullScreenEnabled() && isInWindowOrStandardFullscreen(mode)) {
m_temporarilyAllowingInlinePlaybackAfterFullscreen = false;
m_waitingToEnterFullscreen = true;
document().fullscreenManager().requestFullscreenForElement(*this, nullptr, FullscreenManager::ExemptIFrameAllowFullscreenRequirement);
document().fullscreenManager().requestFullscreenForElement(*this, nullptr, FullscreenManager::ExemptIFrameAllowFullscreenRequirement, mode);
return;
}
#endif
Expand All @@ -6859,7 +6864,7 @@ void HTMLMediaElement::enterFullscreen(VideoFullscreenMode mode)
ALWAYS_LOG(logIdentifier, "Entering fullscreen mode ", mode, ", m_videoFullscreenStandby = ", m_videoFullscreenStandby);

m_temporarilyAllowingInlinePlaybackAfterFullscreen = false;
if (mode == VideoFullscreenModeStandard)
if (isInWindowOrStandardFullscreen(mode))
m_waitingToEnterFullscreen = true;

auto oldMode = m_videoFullscreenMode;
Expand All @@ -6870,9 +6875,9 @@ void HTMLMediaElement::enterFullscreen(VideoFullscreenMode mode)
if (m_videoFullscreenStandby)
return;

if (mode == VideoFullscreenModeStandard)
if (isInWindowOrStandardFullscreen(mode))
scheduleEvent(eventNames().webkitbeginfullscreenEvent);
else if (oldMode == VideoFullscreenModeStandard && !document().quirks().shouldDisableEndFullscreenEventWhenEnteringPictureInPictureFromFullscreenQuirk())
else if (isInWindowOrStandardFullscreen(oldMode) && !document().quirks().shouldDisableEndFullscreenEventWhenEnteringPictureInPictureFromFullscreenQuirk())
scheduleEvent(eventNames().webkitendfullscreenEvent);

return;
Expand Down Expand Up @@ -6902,7 +6907,7 @@ void HTMLMediaElement::exitFullscreen()
document().fullscreenManager().cancelFullscreen();
}

if (m_videoFullscreenMode == VideoFullscreenModeStandard)
if (isInWindowOrStandardFullscreen(m_videoFullscreenMode))
return;
}
#endif
Expand Down Expand Up @@ -6943,7 +6948,7 @@ void HTMLMediaElement::exitFullscreen()

m_changingVideoFullscreenMode = true;

if (oldVideoFullscreenMode == VideoFullscreenModeStandard) {
if (isInWindowOrStandardFullscreen(oldVideoFullscreenMode)) {
setFullscreenMode(VideoFullscreenModeNone);
// The exit fullscreen request will be sent in dispatchEvent().
scheduleEvent(eventNames().webkitendfullscreenEvent);
Expand Down Expand Up @@ -6996,14 +7001,14 @@ WEBCORE_EXPORT void HTMLMediaElement::setVideoFullscreenStandby(bool value)
});
}

void HTMLMediaElement::willBecomeFullscreenElement()
void HTMLMediaElement::willBecomeFullscreenElement(VideoFullscreenMode mode)
{
#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
HTMLMediaElementEnums::VideoFullscreenMode oldVideoFullscreenMode = m_videoFullscreenMode;
#endif

if (m_videoFullscreenMode != VideoFullscreenModeStandard)
setFullscreenMode(VideoFullscreenModeStandard);
if (!isInWindowOrStandardFullscreen(m_videoFullscreenMode))
setFullscreenMode(mode);

#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
if (oldVideoFullscreenMode == VideoFullscreenModePictureInPicture) {
Expand All @@ -7025,7 +7030,7 @@ void HTMLMediaElement::didBecomeFullscreenElement()

void HTMLMediaElement::willStopBeingFullscreenElement()
{
if (fullscreenMode() == VideoFullscreenModeStandard)
if (isInWindowOrStandardFullscreen(fullscreenMode()))
setFullscreenMode(VideoFullscreenModeNone);
}

Expand Down
3 changes: 1 addition & 2 deletions Source/WebCore/html/HTMLMediaElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ class HTMLMediaElement
WEBCORE_EXPORT void didBecomeFullscreenElement() final;
WEBCORE_EXPORT void willExitFullscreen();
WEBCORE_EXPORT void didStopBeingFullscreenElement() final;
void willBecomeFullscreenElement(VideoFullscreenMode = VideoFullscreenModeStandard);

void scheduleEvent(Ref<Event>&&);

Expand Down Expand Up @@ -737,8 +738,6 @@ class HTMLMediaElement
bool isInteractiveContent() const override;

void setFullscreenMode(VideoFullscreenMode);

void willBecomeFullscreenElement() override;
void willStopBeingFullscreenElement() override;

// ActiveDOMObject API.
Expand Down
8 changes: 8 additions & 0 deletions Source/WebCore/html/HTMLVideoElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ static inline HTMLMediaElementEnums::VideoFullscreenMode toFullscreenMode(HTMLVi
return HTMLMediaElementEnums::VideoFullscreenModePictureInPicture;
case HTMLVideoElement::VideoPresentationMode::Inline:
return HTMLMediaElementEnums::VideoFullscreenModeNone;
case HTMLVideoElement::VideoPresentationMode::InWindow:
return HTMLMediaElementEnums::VideoFullscreenModeInWindow;
}
ASSERT_NOT_REACHED();
return HTMLMediaElementEnums::VideoFullscreenModeNone;
Expand All @@ -464,12 +466,18 @@ HTMLVideoElement::VideoPresentationMode HTMLVideoElement::toPresentationMode(HTM
if (mode == HTMLMediaElementEnums::VideoFullscreenModeNone)
return HTMLVideoElement::VideoPresentationMode::Inline;

if (mode == HTMLMediaElementEnums::VideoFullscreenModeInWindow)
return HTMLVideoElement::VideoPresentationMode::InWindow;

ASSERT_NOT_REACHED();
return HTMLVideoElement::VideoPresentationMode::Inline;
}

void HTMLVideoElement::webkitSetPresentationMode(VideoPresentationMode mode)
{
if (mode == VideoPresentationMode::InWindow && !document().settings().inWindowFullscreenEnabled())
return;

INFO_LOG(LOGIDENTIFIER, ", mode = ", mode);
if (!isChangingVideoFullscreenMode())
setPresentationMode(mode);
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/html/HTMLVideoElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class HTMLVideoElement final : public HTMLMediaElement, public Supplementable<HT
RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;

#if ENABLE(VIDEO_PRESENTATION_MODE)
enum class VideoPresentationMode { Inline, Fullscreen, PictureInPicture };
enum class VideoPresentationMode { Inline, Fullscreen, PictureInPicture, InWindow };
static VideoPresentationMode toPresentationMode(HTMLMediaElementEnums::VideoFullscreenMode);
WEBCORE_EXPORT bool webkitSupportsPresentationMode(VideoPresentationMode) const;
VideoPresentationMode webkitPresentationMode() const;
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/html/HTMLVideoElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@
[Conditional=VIDEO_PRESENTATION_MODE, EnabledBySetting=VideoPresentationModeAPIEnabled] undefined webkitSetPresentationMode(VideoPresentationMode mode);
};

[Conditional=VIDEO_PRESENTATION_MODE] enum VideoPresentationMode { "inline", "fullscreen", "picture-in-picture" };
[Conditional=VIDEO_PRESENTATION_MODE] enum VideoPresentationMode { "inline", "fullscreen", "picture-in-picture", "in-window" };
2 changes: 1 addition & 1 deletion Source/WebCore/page/ChromeClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ class ChromeClient {

#if ENABLE(FULLSCREEN_API)
virtual bool supportsFullScreenForElement(const Element&, bool) { return false; }
virtual void enterFullScreenForElement(Element&) { }
virtual void enterFullScreenForElement(Element&, HTMLMediaElementEnums::VideoFullscreenMode = WebCore::HTMLMediaElementEnums::VideoFullscreenModeStandard) { }
virtual void exitFullScreenForElement(Element*) { }
virtual void setRootFullScreenLayer(GraphicsLayer*) { }
#endif
Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/platform/graphics/MediaPlayerEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ class MediaPlayerEnums {
VideoFullscreenModeNone = 0,
VideoFullscreenModeStandard = 1 << 0,
VideoFullscreenModePictureInPicture = 1 << 1,
VideoFullscreenModeAllValidBitsMask = (VideoFullscreenModeStandard | VideoFullscreenModePictureInPicture)
VideoFullscreenModeInWindow = 1 << 2,
VideoFullscreenModeAllValidBitsMask = (VideoFullscreenModeStandard | VideoFullscreenModePictureInPicture | VideoFullscreenModeInWindow)
};
typedef uint32_t VideoFullscreenMode;
};
Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/UIProcess/WebFullScreenManagerProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ WebFullScreenManagerProxy::~WebFullScreenManagerProxy()
callCloseCompletionHandlers();
}

void WebFullScreenManagerProxy::willEnterFullScreen()
void WebFullScreenManagerProxy::willEnterFullScreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode)
{
ALWAYS_LOG(LOGIDENTIFIER);
m_fullscreenState = FullscreenState::EnteringFullscreen;
m_page.fullscreenClient().willEnterFullscreen(&m_page);
m_page.send(Messages::WebFullScreenManager::WillEnterFullScreen());
m_page.send(Messages::WebFullScreenManager::WillEnterFullScreen(mode));
}

void WebFullScreenManagerProxy::didEnterFullScreen()
Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/UIProcess/WebFullScreenManagerProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#if ENABLE(FULLSCREEN_API)

#include "MessageReceiver.h"
#include <WebCore/HTMLMediaElement.h>
#include <wtf/CompletionHandler.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
Expand Down Expand Up @@ -87,8 +88,7 @@ class WebFullScreenManagerProxy : public IPC::MessageReceiver {
ExitingFullscreen,
};
FullscreenState fullscreenState() const { return m_fullscreenState; }

void willEnterFullScreen();
void willEnterFullScreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode = WebCore::HTMLMediaElementEnums::VideoFullscreenModeStandard);
void didEnterFullScreen();
void willExitFullScreen();
void didExitFullScreen();
Expand Down
Loading

0 comments on commit f35e3cd

Please sign in to comment.