- Revision
- 234143
- Author
- [email protected]
- Date
- 2018-07-24 06:22:03 -0700 (Tue, 24 Jul 2018)
Log Message
WebFullScreenManagerProxy does not need to be ref counted
https://bugs.webkit.org/show_bug.cgi?id=187928
Reviewed by Eric Carlson.
WebFullScreenManagerProxy does not need to be ref counted, it is owned by WebPageProxy.
It is also error-prone because WebFullScreenManagerProxy has a raw pointer to its WebPageProxy
and anybody could extend the lifetime of the WebFullScreenManagerProxy by refing it, which
would make the WebPageProxy pointer stale.
* UIProcess/WebFullScreenManagerProxy.cpp:
(WebKit::WebFullScreenManagerProxy::WebFullScreenManagerProxy):
(WebKit::WebFullScreenManagerProxy::willEnterFullScreen):
(WebKit::WebFullScreenManagerProxy::didEnterFullScreen):
(WebKit::WebFullScreenManagerProxy::willExitFullScreen):
(WebKit::WebFullScreenManagerProxy::didExitFullScreen):
(WebKit::WebFullScreenManagerProxy::setAnimatingFullScreen):
(WebKit::WebFullScreenManagerProxy::requestExitFullScreen):
(WebKit::WebFullScreenManagerProxy::saveScrollPosition):
(WebKit::WebFullScreenManagerProxy::restoreScrollPosition):
(WebKit::WebFullScreenManagerProxy::setFullscreenInsets):
(WebKit::WebFullScreenManagerProxy::setFullscreenAutoHideDuration):
(WebKit::WebFullScreenManagerProxy::setFullscreenControlsHidden):
(WebKit::WebFullScreenManagerProxy::invalidate):
* UIProcess/WebFullScreenManagerProxy.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::m_resetRecentCrashCountTimer):
(WebKit::WebPageProxy::reattachToWebProcess):
* UIProcess/WebPageProxy.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (234142 => 234143)
--- trunk/Source/WebKit/ChangeLog 2018-07-24 10:50:05 UTC (rev 234142)
+++ trunk/Source/WebKit/ChangeLog 2018-07-24 13:22:03 UTC (rev 234143)
@@ -1,3 +1,35 @@
+2018-07-24 Chris Dumez <[email protected]>
+
+ WebFullScreenManagerProxy does not need to be ref counted
+ https://bugs.webkit.org/show_bug.cgi?id=187928
+
+ Reviewed by Eric Carlson.
+
+ WebFullScreenManagerProxy does not need to be ref counted, it is owned by WebPageProxy.
+ It is also error-prone because WebFullScreenManagerProxy has a raw pointer to its WebPageProxy
+ and anybody could extend the lifetime of the WebFullScreenManagerProxy by refing it, which
+ would make the WebPageProxy pointer stale.
+
+ * UIProcess/WebFullScreenManagerProxy.cpp:
+ (WebKit::WebFullScreenManagerProxy::WebFullScreenManagerProxy):
+ (WebKit::WebFullScreenManagerProxy::willEnterFullScreen):
+ (WebKit::WebFullScreenManagerProxy::didEnterFullScreen):
+ (WebKit::WebFullScreenManagerProxy::willExitFullScreen):
+ (WebKit::WebFullScreenManagerProxy::didExitFullScreen):
+ (WebKit::WebFullScreenManagerProxy::setAnimatingFullScreen):
+ (WebKit::WebFullScreenManagerProxy::requestExitFullScreen):
+ (WebKit::WebFullScreenManagerProxy::saveScrollPosition):
+ (WebKit::WebFullScreenManagerProxy::restoreScrollPosition):
+ (WebKit::WebFullScreenManagerProxy::setFullscreenInsets):
+ (WebKit::WebFullScreenManagerProxy::setFullscreenAutoHideDuration):
+ (WebKit::WebFullScreenManagerProxy::setFullscreenControlsHidden):
+ (WebKit::WebFullScreenManagerProxy::invalidate):
+ * UIProcess/WebFullScreenManagerProxy.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::m_resetRecentCrashCountTimer):
+ (WebKit::WebPageProxy::reattachToWebProcess):
+ * UIProcess/WebPageProxy.h:
+
2018-07-24 Zan Dobersek <[email protected]>
[TextureMapper] Separate repaint counter state from debug visuals
Modified: trunk/Source/WebKit/UIProcess/WebFullScreenManagerProxy.cpp (234142 => 234143)
--- trunk/Source/WebKit/UIProcess/WebFullScreenManagerProxy.cpp 2018-07-24 10:50:05 UTC (rev 234142)
+++ trunk/Source/WebKit/UIProcess/WebFullScreenManagerProxy.cpp 2018-07-24 13:22:03 UTC (rev 234143)
@@ -41,64 +41,61 @@
namespace WebKit {
-Ref<WebFullScreenManagerProxy> WebFullScreenManagerProxy::create(WebPageProxy& page, WebFullScreenManagerProxyClient& client)
-{
- return adoptRef(*new WebFullScreenManagerProxy(page, client));
-}
-
WebFullScreenManagerProxy::WebFullScreenManagerProxy(WebPageProxy& page, WebFullScreenManagerProxyClient& client)
- : m_page(&page)
- , m_client(&client)
+ : m_page(page)
+ , m_client(client)
{
- m_page->process().addMessageReceiver(Messages::WebFullScreenManagerProxy::messageReceiverName(), m_page->pageID(), *this);
+ m_page.process().addMessageReceiver(Messages::WebFullScreenManagerProxy::messageReceiverName(), m_page.pageID(), *this);
}
WebFullScreenManagerProxy::~WebFullScreenManagerProxy()
{
+ m_page.process().removeMessageReceiver(Messages::WebFullScreenManagerProxy::messageReceiverName(), m_page.pageID());
+ m_client.closeFullScreenManager();
}
void WebFullScreenManagerProxy::willEnterFullScreen()
{
- m_page->fullscreenClient().willEnterFullscreen(m_page);
- m_page->process().send(Messages::WebFullScreenManager::WillEnterFullScreen(), m_page->pageID());
+ m_page.fullscreenClient().willEnterFullscreen(&m_page);
+ m_page.process().send(Messages::WebFullScreenManager::WillEnterFullScreen(), m_page.pageID());
}
void WebFullScreenManagerProxy::didEnterFullScreen()
{
- m_page->fullscreenClient().didEnterFullscreen(m_page);
- m_page->process().send(Messages::WebFullScreenManager::DidEnterFullScreen(), m_page->pageID());
+ m_page.fullscreenClient().didEnterFullscreen(&m_page);
+ m_page.process().send(Messages::WebFullScreenManager::DidEnterFullScreen(), m_page.pageID());
- if (m_page->isControlledByAutomation()) {
- if (WebAutomationSession* automationSession = m_page->process().processPool().automationSession())
- automationSession->didEnterFullScreenForPage(*m_page);
+ if (m_page.isControlledByAutomation()) {
+ if (WebAutomationSession* automationSession = m_page.process().processPool().automationSession())
+ automationSession->didEnterFullScreenForPage(m_page);
}
}
void WebFullScreenManagerProxy::willExitFullScreen()
{
- m_page->fullscreenClient().willExitFullscreen(m_page);
- m_page->process().send(Messages::WebFullScreenManager::WillExitFullScreen(), m_page->pageID());
+ m_page.fullscreenClient().willExitFullscreen(&m_page);
+ m_page.process().send(Messages::WebFullScreenManager::WillExitFullScreen(), m_page.pageID());
}
void WebFullScreenManagerProxy::didExitFullScreen()
{
- m_page->fullscreenClient().didExitFullscreen(m_page);
- m_page->process().send(Messages::WebFullScreenManager::DidExitFullScreen(), m_page->pageID());
+ m_page.fullscreenClient().didExitFullscreen(&m_page);
+ m_page.process().send(Messages::WebFullScreenManager::DidExitFullScreen(), m_page.pageID());
- if (m_page->isControlledByAutomation()) {
- if (WebAutomationSession* automationSession = m_page->process().processPool().automationSession())
- automationSession->didExitFullScreenForPage(*m_page);
+ if (m_page.isControlledByAutomation()) {
+ if (WebAutomationSession* automationSession = m_page.process().processPool().automationSession())
+ automationSession->didExitFullScreenForPage(m_page);
}
}
void WebFullScreenManagerProxy::setAnimatingFullScreen(bool animating)
{
- m_page->process().send(Messages::WebFullScreenManager::SetAnimatingFullScreen(animating), m_page->pageID());
+ m_page.process().send(Messages::WebFullScreenManager::SetAnimatingFullScreen(animating), m_page.pageID());
}
void WebFullScreenManagerProxy::requestExitFullScreen()
{
- m_page->process().send(Messages::WebFullScreenManager::RequestExitFullScreen(), m_page->pageID());
+ m_page.process().send(Messages::WebFullScreenManager::RequestExitFullScreen(), m_page.pageID());
}
void WebFullScreenManagerProxy::supportsFullScreen(bool withKeyboard, bool& supports)
@@ -112,80 +109,57 @@
void WebFullScreenManagerProxy::saveScrollPosition()
{
- m_page->process().send(Messages::WebFullScreenManager::SaveScrollPosition(), m_page->pageID());
+ m_page.process().send(Messages::WebFullScreenManager::SaveScrollPosition(), m_page.pageID());
}
void WebFullScreenManagerProxy::restoreScrollPosition()
{
- m_page->process().send(Messages::WebFullScreenManager::RestoreScrollPosition(), m_page->pageID());
+ m_page.process().send(Messages::WebFullScreenManager::RestoreScrollPosition(), m_page.pageID());
}
void WebFullScreenManagerProxy::setFullscreenInsets(const WebCore::FloatBoxExtent& insets)
{
- m_page->process().send(Messages::WebFullScreenManager::SetFullscreenInsets(insets), m_page->pageID());
+ m_page.process().send(Messages::WebFullScreenManager::SetFullscreenInsets(insets), m_page.pageID());
}
void WebFullScreenManagerProxy::setFullscreenAutoHideDuration(Seconds duration)
{
- m_page->process().send(Messages::WebFullScreenManager::SetFullscreenAutoHideDuration(duration), m_page->pageID());
+ m_page.process().send(Messages::WebFullScreenManager::SetFullscreenAutoHideDuration(duration), m_page.pageID());
}
void WebFullScreenManagerProxy::setFullscreenControlsHidden(bool hidden)
{
- m_page->process().send(Messages::WebFullScreenManager::SetFullscreenControlsHidden(hidden), m_page->pageID());
+ m_page.process().send(Messages::WebFullScreenManager::SetFullscreenControlsHidden(hidden), m_page.pageID());
}
-void WebFullScreenManagerProxy::invalidate()
-{
- m_page->process().removeMessageReceiver(Messages::WebFullScreenManagerProxy::messageReceiverName(), m_page->pageID());
-
- if (!m_client)
- return;
-
- m_client->closeFullScreenManager();
- m_client = nullptr;
-}
-
void WebFullScreenManagerProxy::close()
{
- if (!m_client)
- return;
- m_client->closeFullScreenManager();
+ m_client.closeFullScreenManager();
}
bool WebFullScreenManagerProxy::isFullScreen()
{
- if (!m_client)
- return false;
- return m_client->isFullScreen();
+ return m_client.isFullScreen();
}
void WebFullScreenManagerProxy::enterFullScreen()
{
- if (!m_client)
- return;
- m_client->enterFullScreen();
+ m_client.enterFullScreen();
}
void WebFullScreenManagerProxy::exitFullScreen()
{
- if (!m_client)
- return;
- m_client->exitFullScreen();
+ m_client.exitFullScreen();
}
void WebFullScreenManagerProxy::beganEnterFullScreen(const IntRect& initialFrame, const IntRect& finalFrame)
{
- if (!m_client)
- return;
- m_client->beganEnterFullScreen(initialFrame, finalFrame);
+ m_client.beganEnterFullScreen(initialFrame, finalFrame);
}
void WebFullScreenManagerProxy::beganExitFullScreen(const IntRect& initialFrame, const IntRect& finalFrame)
{
- if (!m_client)
- return;
- m_client->beganExitFullScreen(initialFrame, finalFrame);
+ m_client.beganExitFullScreen(initialFrame, finalFrame);
}
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/WebFullScreenManagerProxy.h (234142 => 234143)
--- trunk/Source/WebKit/UIProcess/WebFullScreenManagerProxy.h 2018-07-24 10:50:05 UTC (rev 234142)
+++ trunk/Source/WebKit/UIProcess/WebFullScreenManagerProxy.h 2018-07-24 13:22:03 UTC (rev 234143)
@@ -55,13 +55,12 @@
virtual void beganExitFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) = 0;
};
-class WebFullScreenManagerProxy : public RefCounted<WebFullScreenManagerProxy>, public IPC::MessageReceiver {
+class WebFullScreenManagerProxy : public IPC::MessageReceiver {
+ WTF_MAKE_FAST_ALLOCATED;
public:
- static Ref<WebFullScreenManagerProxy> create(WebPageProxy&, WebFullScreenManagerProxyClient&);
+ WebFullScreenManagerProxy(WebPageProxy&, WebFullScreenManagerProxyClient&);
virtual ~WebFullScreenManagerProxy();
- void invalidate();
-
bool isFullScreen();
void close();
@@ -78,8 +77,6 @@
void setFullscreenControlsHidden(bool);
private:
- explicit WebFullScreenManagerProxy(WebPageProxy&, WebFullScreenManagerProxyClient&);
-
void supportsFullScreen(bool withKeyboard, bool&);
void enterFullScreen();
void exitFullScreen();
@@ -89,8 +86,8 @@
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) override;
- WebPageProxy* m_page;
- WebFullScreenManagerProxyClient* m_client;
+ WebPageProxy& m_page;
+ WebFullScreenManagerProxyClient& m_client;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (234142 => 234143)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-07-24 10:50:05 UTC (rev 234142)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-07-24 13:22:03 UTC (rev 234143)
@@ -439,7 +439,7 @@
m_inspector = WebInspectorProxy::create(this);
#if ENABLE(FULLSCREEN_API)
- m_fullScreenManager = WebFullScreenManagerProxy::create(*this, m_pageClient.fullScreenManagerProxyClient());
+ m_fullScreenManager = std::make_unique<WebFullScreenManagerProxy>(*this, m_pageClient.fullScreenManagerProxyClient());
#endif
#if PLATFORM(IOS) && HAVE(AVKIT) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
m_playbackSessionManager = PlaybackSessionManagerProxy::create(*this);
@@ -757,7 +757,7 @@
m_inspector = WebInspectorProxy::create(this);
#if ENABLE(FULLSCREEN_API)
- m_fullScreenManager = WebFullScreenManagerProxy::create(*this, m_pageClient.fullScreenManagerProxyClient());
+ m_fullScreenManager = std::make_unique<WebFullScreenManagerProxy>(*this, m_pageClient.fullScreenManagerProxyClient());
#endif
#if PLATFORM(IOS) && HAVE(AVKIT) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
m_playbackSessionManager = PlaybackSessionManagerProxy::create(*this);
@@ -6024,10 +6024,7 @@
}
#if ENABLE(FULLSCREEN_API)
- if (m_fullScreenManager) {
- m_fullScreenManager->invalidate();
- m_fullScreenManager = nullptr;
- }
+ m_fullScreenManager = nullptr;
#endif
if (m_openPanelResultListener) {
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (234142 => 234143)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-07-24 10:50:05 UTC (rev 234142)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-07-24 13:22:03 UTC (rev 234143)
@@ -1868,7 +1868,7 @@
RefPtr<WebInspectorProxy> m_inspector;
#if ENABLE(FULLSCREEN_API)
- RefPtr<WebFullScreenManagerProxy> m_fullScreenManager;
+ std::unique_ptr<WebFullScreenManagerProxy> m_fullScreenManager;
std::unique_ptr<API::FullscreenClient> m_fullscreenClient;
#endif