Skip to content

Commit

Permalink
[media-controls] Duplicate buttons in top leading corner of fullscree…
Browse files Browse the repository at this point in the history
…n video

https://bugs.webkit.org/show_bug.cgi?id=246414
rdar://100870340

Reviewed by Devin Rousso.

254333@main attempted to hide the hide the cancel and PiP buttons in fullscreen
if the current playback element already has those buttons. However, at the time
the `EnterFullScreen` message in sent to the UIProcess, the `PlaybackSessionManager`
may not have a current playback element.

To fix, explicitly check if the element entering fullscreen is a `<video>` and
that it has controls. Additionally, rename `isVideoElement` to
`isVideoElementWithControls` for accuracy.

* Source/WebKit/UIProcess/WebFullScreenManagerProxy.cpp:
(WebKit::WebFullScreenManagerProxy::isVideoElementWithControls const):
(WebKit::WebFullScreenManagerProxy::enterFullScreen):
(WebKit::WebFullScreenManagerProxy::isVideoElement const): Deleted.
* Source/WebKit/UIProcess/WebFullScreenManagerProxy.h:
* Source/WebKit/UIProcess/WebFullScreenManagerProxy.messages.in:
* Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
(-[WKFullScreenWindowController enterFullScreen:]):
* Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp:
(WebKit::WebFullScreenManager::enterFullScreenForElement):
* Source/WebKit/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.cpp:
(WebKit::InjectedBundlePageFullScreenClient::enterFullScreenForElement):
* Source/WebKit/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.h:

Canonical link: https://commits.webkit.org/255503@main
  • Loading branch information
pxlcoder committed Oct 13, 2022
1 parent 48f8da1 commit 5d182d0
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 18 deletions.
10 changes: 5 additions & 5 deletions Source/WebKit/UIProcess/WebFullScreenManagerProxy.cpp
Expand Up @@ -171,19 +171,19 @@ bool WebFullScreenManagerProxy::blocksReturnToFullscreenFromPictureInPicture() c
}

#if HAVE(UIKIT_WEBKIT_INTERNALS)
bool WebFullScreenManagerProxy::isVideoElement() const
bool WebFullScreenManagerProxy::isVideoElementWithControls() const
{
return m_isVideoElement;
return m_isVideoElementWithControls;
}
#endif

void WebFullScreenManagerProxy::enterFullScreen(bool blocksReturnToFullscreenFromPictureInPicture, bool isVideoElement, FloatSize videoDimensions)
void WebFullScreenManagerProxy::enterFullScreen(bool blocksReturnToFullscreenFromPictureInPicture, bool isVideoElementWithControls, FloatSize videoDimensions)
{
m_blocksReturnToFullscreenFromPictureInPicture = blocksReturnToFullscreenFromPictureInPicture;
#if HAVE(UIKIT_WEBKIT_INTERNALS)
m_isVideoElement = isVideoElement;
m_isVideoElementWithControls = isVideoElementWithControls;
#else
UNUSED_PARAM(isVideoElement);
UNUSED_PARAM(isVideoElementWithControls);
#endif
#if PLATFORM(IOS_FAMILY)
m_client.enterFullScreen(videoDimensions);
Expand Down
6 changes: 3 additions & 3 deletions Source/WebKit/UIProcess/WebFullScreenManagerProxy.h
Expand Up @@ -71,7 +71,7 @@ class WebFullScreenManagerProxy : public IPC::MessageReceiver {
bool isFullScreen();
bool blocksReturnToFullscreenFromPictureInPicture() const;
#if HAVE(UIKIT_WEBKIT_INTERNALS)
bool isVideoElement() const;
bool isVideoElementWithControls() const;
#endif
void close();

Expand Down Expand Up @@ -99,7 +99,7 @@ class WebFullScreenManagerProxy : public IPC::MessageReceiver {

private:
void supportsFullScreen(bool withKeyboard, CompletionHandler<void(bool)>&&);
void enterFullScreen(bool blocksReturnToFullscreenFromPictureInPicture, bool isVideoElement, WebCore::FloatSize videoDimensions);
void enterFullScreen(bool blocksReturnToFullscreenFromPictureInPicture, bool isVideoElementWithControls, WebCore::FloatSize videoDimensions);
void exitFullScreen();
void beganEnterFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame);
void beganExitFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame);
Expand All @@ -113,7 +113,7 @@ class WebFullScreenManagerProxy : public IPC::MessageReceiver {
FullscreenState m_fullscreenState { FullscreenState::NotInFullscreen };
bool m_blocksReturnToFullscreenFromPictureInPicture { false };
#if HAVE(UIKIT_WEBKIT_INTERNALS)
bool m_isVideoElement { false };
bool m_isVideoElementWithControls { false };
#endif
Vector<CompletionHandler<void()>> m_closeCompletionHandlers;
};
Expand Down
Expand Up @@ -23,7 +23,7 @@
#if ENABLE(FULLSCREEN_API)
messages -> WebFullScreenManagerProxy NotRefCounted {
SupportsFullScreen(bool withKeyboard) -> (bool supportsFullScreen) Synchronous
EnterFullScreen(bool blocksReturnToFullscreenFromPictureInPicture, bool isVideoElement, WebCore::FloatSize videoDimensions)
EnterFullScreen(bool blocksReturnToFullscreenFromPictureInPicture, bool isVideoElementWithControls, WebCore::FloatSize videoDimensions)
ExitFullScreen()
BeganEnterFullScreen(WebCore::IntRect initialRect, WebCore::IntRect finalRect)
BeganExitFullScreen(WebCore::IntRect initialRect, WebCore::IntRect finalRect)
Expand Down
Expand Up @@ -571,7 +571,7 @@ - (void)enterFullScreen:(CGSize)videoDimensions
[_fullscreenViewController setExitFullScreenAction:@selector(requestExitFullScreen)];
_fullscreenViewController.get().view.frame = _rootViewController.get().view.bounds;
#if HAVE(UIKIT_WEBKIT_INTERNALS)
[_fullscreenViewController hideMediaControls:manager->isVideoElement()];
[_fullscreenViewController hideMediaControls:manager->isVideoElementWithControls()];
#endif
[self _updateLocationInfo];

Expand Down
11 changes: 6 additions & 5 deletions Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp
Expand Up @@ -171,12 +171,13 @@ void WebFullScreenManager::enterFullScreenForElement(WebCore::Element* element)

setElement(*element);

bool isVideoElement = false;
bool isVideoElementWithControls = false;
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
if (auto* currentPlaybackControlsElement = m_page->playbackSessionManager().currentPlaybackControlsElement()) {
if (auto* videoElement = dynamicDowncast<HTMLVideoElement>(element))
isVideoElementWithControls = videoElement->controls();

if (auto* currentPlaybackControlsElement = m_page->playbackSessionManager().currentPlaybackControlsElement())
currentPlaybackControlsElement->prepareForVideoFullscreenStandby();
isVideoElement = currentPlaybackControlsElement->controls();
}
#endif

m_initialFrame = screenRectOfContents(m_element.get());
Expand All @@ -186,7 +187,7 @@ void WebFullScreenManager::enterFullScreenForElement(WebCore::Element* element)
#else
FloatSize videoDimensions;
#endif
m_page->injectedBundleFullScreenClient().enterFullScreenForElement(m_page.get(), element, m_element->document().quirks().blocksReturnToFullscreenFromPictureInPictureQuirk(), isVideoElement, videoDimensions);
m_page->injectedBundleFullScreenClient().enterFullScreenForElement(m_page.get(), element, m_element->document().quirks().blocksReturnToFullscreenFromPictureInPictureQuirk(), isVideoElementWithControls, videoDimensions);
}

void WebFullScreenManager::exitFullScreenForElement(WebCore::Element* element)
Expand Down
Expand Up @@ -51,13 +51,13 @@ bool InjectedBundlePageFullScreenClient::supportsFullScreen(WebPage *page, bool
return supports;
}

void InjectedBundlePageFullScreenClient::enterFullScreenForElement(WebPage *page, WebCore::Element *element, bool blocksReturnToFullscreenFromPictureInPicture, bool isVideoElement, FloatSize videoDimensions)
void InjectedBundlePageFullScreenClient::enterFullScreenForElement(WebPage *page, WebCore::Element *element, bool blocksReturnToFullscreenFromPictureInPicture, bool isVideoElementWithControls, FloatSize videoDimensions)
{
if (m_client.enterFullScreenForElement) {
RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::getOrCreate(element);
m_client.enterFullScreenForElement(toAPI(page), toAPI(nodeHandle.get()));
} else
page->send(Messages::WebFullScreenManagerProxy::EnterFullScreen(blocksReturnToFullscreenFromPictureInPicture, isVideoElement, videoDimensions));
page->send(Messages::WebFullScreenManagerProxy::EnterFullScreen(blocksReturnToFullscreenFromPictureInPicture, isVideoElementWithControls, videoDimensions));
}

void InjectedBundlePageFullScreenClient::exitFullScreenForElement(WebPage *page, WebCore::Element *element)
Expand Down
Expand Up @@ -51,7 +51,7 @@ class WebPage;
class InjectedBundlePageFullScreenClient : public API::Client<WKBundlePageFullScreenClientBase> {
public:
bool supportsFullScreen(WebPage*, bool withKeyboard);
void enterFullScreenForElement(WebPage*, WebCore::Element*, bool blocksReturnToFullscreenFromPictureInPicture, bool isVideoElement, WebCore::FloatSize videoDimensions);
void enterFullScreenForElement(WebPage*, WebCore::Element*, bool blocksReturnToFullscreenFromPictureInPicture, bool isVideoElementWithControls, WebCore::FloatSize videoDimensions);
void exitFullScreenForElement(WebPage*, WebCore::Element*);
void beganEnterFullScreen(WebPage*, WebCore::IntRect& initialFrame, WebCore::IntRect& finalFrame);
void beganExitFullScreen(WebPage*, WebCore::IntRect& initialFrame, WebCore::IntRect& finalFrame);
Expand Down

0 comments on commit 5d182d0

Please sign in to comment.