Skip to content
Permalink
Browse files
Auto-pip should use main content heuristic.
https://bugs.webkit.org/show_bug.cgi?id=186065
<rdar://problem/35862502>

Reviewed by Eric Carlson.

Make the m_pipStandbyElement clearable, which will allow the auto-pip mechanism to be torn down. Add
a WebProcess-side notification when the main content changes, to facilitate this.

* WebProcess/FullScreen/WebFullScreenManager.cpp:
(WebKit::WebFullScreenManager::videoControlsManagerDidChange):
(WebKit::WebFullScreenManager::setPIPStandbyElement):
(WebKit::WebFullScreenManager::didEnterFullScreen):
(WebKit::WebFullScreenManager::willExitFullScreen):
* WebProcess/FullScreen/WebFullScreenManager.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::videoControlsManagerDidChange):
* WebProcess/WebPage/WebPage.h:
* WebProcess/cocoa/PlaybackSessionManager.h:
* WebProcess/cocoa/PlaybackSessionManager.mm:
(WebKit::PlaybackSessionManager::setUpPlaybackControlsManager):
(WebKit::PlaybackSessionManager::clearPlaybackControlsManager):
(WebKit::PlaybackSessionManager::currentPlaybackControlsElement const):


Canonical link: https://commits.webkit.org/201525@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232301 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
jernoble committed May 30, 2018
1 parent 355df8e commit 1b45ec686d02bc61fe9af9dfd656285619a1eb09
@@ -1,3 +1,29 @@
2018-05-30 Jer Noble <jer.noble@apple.com>

Auto-pip should use main content heuristic.
https://bugs.webkit.org/show_bug.cgi?id=186065
<rdar://problem/35862502>

Reviewed by Eric Carlson.

Make the m_pipStandbyElement clearable, which will allow the auto-pip mechanism to be torn down. Add
a WebProcess-side notification when the main content changes, to facilitate this.

* WebProcess/FullScreen/WebFullScreenManager.cpp:
(WebKit::WebFullScreenManager::videoControlsManagerDidChange):
(WebKit::WebFullScreenManager::setPIPStandbyElement):
(WebKit::WebFullScreenManager::didEnterFullScreen):
(WebKit::WebFullScreenManager::willExitFullScreen):
* WebProcess/FullScreen/WebFullScreenManager.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::videoControlsManagerDidChange):
* WebProcess/WebPage/WebPage.h:
* WebProcess/cocoa/PlaybackSessionManager.h:
* WebProcess/cocoa/PlaybackSessionManager.mm:
(WebKit::PlaybackSessionManager::setUpPlaybackControlsManager):
(WebKit::PlaybackSessionManager::clearPlaybackControlsManager):
(WebKit::PlaybackSessionManager::currentPlaybackControlsElement const):

2018-05-30 Jer Noble <jer.noble@apple.com>

Fix a few issues in WKFullScreenViewController
@@ -45,6 +45,10 @@
#include <WebCore/Settings.h>
#include <WebCore/TypedElementDescendantIterator.h>

#if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
#include "PlaybackSessionManager.h"
#endif

using namespace WebCore;

namespace WebKit {
@@ -81,6 +85,28 @@ WebCore::Element* WebFullScreenManager::element()
return m_element.get();
}

void WebFullScreenManager::videoControlsManagerDidChange()
{
#if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
auto* currentPlaybackControlsElement = m_page->playbackSessionManager().currentPlaybackControlsElement();
setPIPStandbyElement(is<HTMLVideoElement>(currentPlaybackControlsElement) ? downcast<HTMLVideoElement>(currentPlaybackControlsElement) : nullptr);
#endif
}

void WebFullScreenManager::setPIPStandbyElement(WebCore::HTMLVideoElement* pipStandbyElement)
{
if (pipStandbyElement == m_pipStandbyElement)
return;

if (m_pipStandbyElement)
m_pipStandbyElement->setVideoFullscreenStandby(false);

m_pipStandbyElement = pipStandbyElement;

if (m_pipStandbyElement)
m_pipStandbyElement->setVideoFullscreenStandby(true);
}

void WebFullScreenManager::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& decoder)
{
didReceiveWebFullScreenManagerMessage(connection, decoder);
@@ -125,10 +151,9 @@ void WebFullScreenManager::didEnterFullScreen()
ASSERT(m_element);
m_element->document().webkitDidEnterFullScreenForElement(m_element.get());

#if ENABLE(VIDEO)
m_pipStandbyElement = descendantsOfType<HTMLVideoElement>(*m_element).first();
if (m_pipStandbyElement)
m_pipStandbyElement->setVideoFullscreenStandby(true);
#if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
auto* currentPlaybackControlsElement = m_page->playbackSessionManager().currentPlaybackControlsElement();
setPIPStandbyElement(is<HTMLVideoElement>(currentPlaybackControlsElement) ? downcast<HTMLVideoElement>(currentPlaybackControlsElement) : nullptr);
#endif
}

@@ -137,9 +162,7 @@ void WebFullScreenManager::willExitFullScreen()
ASSERT(m_element);

#if ENABLE(VIDEO)
if (m_pipStandbyElement)
m_pipStandbyElement->setVideoFullscreenStandby(false);
m_pipStandbyElement = nullptr;
setPIPStandbyElement(nullptr);
#endif

m_finalFrame = screenRectOfContents(m_element.get());
@@ -65,11 +65,15 @@ class WebFullScreenManager : public RefCounted<WebFullScreenManager> {

WebCore::Element* element();

void videoControlsManagerDidChange();

void close();

protected:
WebFullScreenManager(WebPage*);

void setPIPStandbyElement(WebCore::HTMLVideoElement*);

void setAnimatingFullScreen(bool);
void requestExitFullScreen();
void saveScrollPosition();
@@ -3289,6 +3289,15 @@ VideoFullscreenManager& WebPage::videoFullscreenManager()
m_videoFullscreenManager = VideoFullscreenManager::create(*this, playbackSessionManager());
return *m_videoFullscreenManager;
}

void WebPage::videoControlsManagerDidChange()
{
#if ENABLE(FULLSCREEN_API)
if (auto* manager = fullScreenManager())
manager->videoControlsManagerDidChange();
#endif
}

#endif

#if PLATFORM(IOS)
@@ -298,6 +298,7 @@ class WebPage : public API::ObjectImpl<API::Object::Type::BundlePage>, public IP
#if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
PlaybackSessionManager& playbackSessionManager();
VideoFullscreenManager& videoFullscreenManager();
void videoControlsManagerDidChange();
#endif

#if PLATFORM(IOS)
@@ -109,6 +109,8 @@ class PlaybackSessionManager : public RefCounted<PlaybackSessionManager>, privat
void clearPlaybackControlsManager();
uint64_t contextIdForMediaElement(WebCore::HTMLMediaElement&);

WebCore::HTMLMediaElement* currentPlaybackControlsElement() const;

protected:
friend class PlaybackSessionInterfaceContext;
friend class VideoFullscreenManager;
@@ -278,19 +278,21 @@ static uint64_t nextContextId()
}

addClientForContext(m_controlsManagerContextId);

m_page->videoControlsManagerDidChange();
m_page->send(Messages::PlaybackSessionManagerProxy::SetUpPlaybackControlsManagerWithID(m_controlsManagerContextId), m_page->pageID());
}

void PlaybackSessionManager::clearPlaybackControlsManager()
{
#if PLATFORM(MAC)
if (!m_controlsManagerContextId)
return;

removeClientForContext(m_controlsManagerContextId);
m_controlsManagerContextId = 0;

m_page->videoControlsManagerDidChange();
m_page->send(Messages::PlaybackSessionManagerProxy::ClearPlaybackControlsManager(), m_page->pageID());
#endif
}

uint64_t PlaybackSessionManager::contextIdForMediaElement(WebCore::HTMLMediaElement& mediaElement)
@@ -301,6 +303,18 @@ static uint64_t nextContextId()
return contextId;
}

WebCore::HTMLMediaElement* PlaybackSessionManager::currentPlaybackControlsElement() const
{
if (!m_controlsManagerContextId)
return nullptr;

auto iter = m_contextMap.find(m_controlsManagerContextId);
if (iter == m_contextMap.end())
return nullptr;

return std::get<0>(iter->value)->mediaElement();
}

#pragma mark Interface to PlaybackSessionInterfaceContext:

void PlaybackSessionManager::resetMediaState(uint64_t contextId)

0 comments on commit 1b45ec6

Please sign in to comment.