- Revision
- 135915
- Author
- [email protected]
- Date
- 2012-11-27 13:52:47 -0800 (Tue, 27 Nov 2012)
Log Message
Entering Tab View after a bunch of YouTube pages were opened in background tabs makes all of them start playing simultaneously
https://bugs.webkit.org/show_bug.cgi?id=103358
Reviewed by Adele Peterson.
To fix this, this patch adds WKPageSetMayStartMediaWhenInWindow(), which allows the client to
prevent media from starting automatically when the view is put in a window.
* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode): Encode mayStartMediaWhenInWindow.
(WebKit::WebPageCreationParameters::decode): Decode mayStartMediaWhenInWindow.
* Shared/WebPageCreationParameters.h:
(WebPageCreationParameters): Added boolean member mayStartMediaWhenInWindow.
* UIProcess/API/C/WKPage.cpp:
(WKPageSetMayStartMediaWhenInWindow): Added. Calls through to WebPageProxy.
* UIProcess/API/C/WKPagePrivate.h: Declared WKPageSetMayStartMediaWhenInWindow.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy): Added initializiation of m_mayStartMediaWhenInWindow
to true, the value matching the current behavior.
(WebKit::WebPageProxy::setMayStartMediaWhenInWindow): Added. Updates
m_mayStartMediaWhenInWindow and sends a message to the Web process to do the same.
(WebKit::WebPageProxy::creationParameters): Changed to set mayStartMediaWhenInWindow in the
process creation parameters.
* UIProcess/WebPageProxy.h:
(WebPageProxy): Declared setMayStartMediaWhenInWindow() and added member variable
m_mayStartMediaWhenInWindow.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage): Initialized m_mayStartMediaWhenInWindow from the creation
parameters.
(WebKit::WebPage::setIsInWindow): Made starting of media upon being added to a window
conditional on m_mayStartMediaWhenInWindow.
(WebKit::WebPage::setMayStartMediaWhenInWindow): Added. Sets m_mayStartMediaWhenInWindow. If
already in a window when changing from false to true, starts m_setCanStartMediaTimer.
* WebProcess/WebPage/WebPage.h:
(WebPage): Declared setMayStartMediaWhenInWindow() and added member variable m_mayStartMediaWhenInWindow.
* WebProcess/WebPage/WebPage.messages.in: Added SetMayStartMediaWhenInWindow.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (135914 => 135915)
--- trunk/Source/WebKit2/ChangeLog 2012-11-27 21:50:15 UTC (rev 135914)
+++ trunk/Source/WebKit2/ChangeLog 2012-11-27 21:52:47 UTC (rev 135915)
@@ -1,3 +1,42 @@
+2012-11-27 Dan Bernstein <[email protected]>
+
+ Entering Tab View after a bunch of YouTube pages were opened in background tabs makes all of them start playing simultaneously
+ https://bugs.webkit.org/show_bug.cgi?id=103358
+
+ Reviewed by Adele Peterson.
+
+ To fix this, this patch adds WKPageSetMayStartMediaWhenInWindow(), which allows the client to
+ prevent media from starting automatically when the view is put in a window.
+
+ * Shared/WebPageCreationParameters.cpp:
+ (WebKit::WebPageCreationParameters::encode): Encode mayStartMediaWhenInWindow.
+ (WebKit::WebPageCreationParameters::decode): Decode mayStartMediaWhenInWindow.
+ * Shared/WebPageCreationParameters.h:
+ (WebPageCreationParameters): Added boolean member mayStartMediaWhenInWindow.
+ * UIProcess/API/C/WKPage.cpp:
+ (WKPageSetMayStartMediaWhenInWindow): Added. Calls through to WebPageProxy.
+ * UIProcess/API/C/WKPagePrivate.h: Declared WKPageSetMayStartMediaWhenInWindow.
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::WebPageProxy): Added initializiation of m_mayStartMediaWhenInWindow
+ to true, the value matching the current behavior.
+ (WebKit::WebPageProxy::setMayStartMediaWhenInWindow): Added. Updates
+ m_mayStartMediaWhenInWindow and sends a message to the Web process to do the same.
+ (WebKit::WebPageProxy::creationParameters): Changed to set mayStartMediaWhenInWindow in the
+ process creation parameters.
+ * UIProcess/WebPageProxy.h:
+ (WebPageProxy): Declared setMayStartMediaWhenInWindow() and added member variable
+ m_mayStartMediaWhenInWindow.
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::WebPage): Initialized m_mayStartMediaWhenInWindow from the creation
+ parameters.
+ (WebKit::WebPage::setIsInWindow): Made starting of media upon being added to a window
+ conditional on m_mayStartMediaWhenInWindow.
+ (WebKit::WebPage::setMayStartMediaWhenInWindow): Added. Sets m_mayStartMediaWhenInWindow. If
+ already in a window when changing from false to true, starts m_setCanStartMediaTimer.
+ * WebProcess/WebPage/WebPage.h:
+ (WebPage): Declared setMayStartMediaWhenInWindow() and added member variable m_mayStartMediaWhenInWindow.
+ * WebProcess/WebPage/WebPage.messages.in: Added SetMayStartMediaWhenInWindow.
+
2012-11-27 Pratik Solanki <[email protected]>
objc/objc-runtime.h does not exist on all PLATFORM(MAC)
Modified: trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp (135914 => 135915)
--- trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp 2012-11-27 21:50:15 UTC (rev 135914)
+++ trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp 2012-11-27 21:52:47 UTC (rev 135915)
@@ -57,6 +57,7 @@
encoder << canRunModal;
encoder << deviceScaleFactor;
encoder << mediaVolume;
+ encoder << mayStartMediaWhenInWindow;
#if PLATFORM(MAC)
encoder << isSmartInsertDeleteEnabled;
@@ -119,6 +120,8 @@
return false;
if (!decoder->decode(parameters.mediaVolume))
return false;
+ if (!decoder->decode(parameters.mayStartMediaWhenInWindow))
+ return false;
#if PLATFORM(MAC)
if (!decoder->decode(parameters.isSmartInsertDeleteEnabled))
Modified: trunk/Source/WebKit2/Shared/WebPageCreationParameters.h (135914 => 135915)
--- trunk/Source/WebKit2/Shared/WebPageCreationParameters.h 2012-11-27 21:50:15 UTC (rev 135914)
+++ trunk/Source/WebKit2/Shared/WebPageCreationParameters.h 2012-11-27 21:52:47 UTC (rev 135915)
@@ -85,6 +85,7 @@
float deviceScaleFactor;
float mediaVolume;
+ bool mayStartMediaWhenInWindow;
#if PLATFORM(MAC)
bool isSmartInsertDeleteEnabled;
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (135914 => 135915)
--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp 2012-11-27 21:50:15 UTC (rev 135914)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp 2012-11-27 21:52:47 UTC (rev 135915)
@@ -764,3 +764,8 @@
{
return toAPI(toImpl(pageRef)->relatedPages().leakRef());
}
+
+void WKPageSetMayStartMediaWhenInWindow(WKPageRef pageRef, bool mayStartMedia)
+{
+ toImpl(pageRef)->setMayStartMediaWhenInWindow(mayStartMedia);
+}
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h (135914 => 135915)
--- trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h 2012-11-27 21:50:15 UTC (rev 135914)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h 2012-11-27 21:52:47 UTC (rev 135915)
@@ -93,6 +93,7 @@
WK_EXPORT void WKPageSetShouldSendEventsSynchronously(WKPageRef page, bool sync);
WK_EXPORT void WKPageSetMediaVolume(WKPageRef page, float volume);
+WK_EXPORT void WKPageSetMayStartMediaWhenInWindow(WKPageRef page, bool mayStartMedia);
WK_EXPORT WKArrayRef WKPageCopyRelatedPages(WKPageRef page);
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (135914 => 135915)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2012-11-27 21:50:15 UTC (rev 135914)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2012-11-27 21:52:47 UTC (rev 135915)
@@ -234,6 +234,7 @@
, m_shouldSendEventsSynchronously(false)
, m_suppressVisibilityUpdates(false)
, m_mediaVolume(1)
+ , m_mayStartMediaWhenInWindow(true)
#if ENABLE(PAGE_VISIBILITY_API)
, m_visibilityState(PageVisibilityStateVisible)
#endif
@@ -2782,6 +2783,19 @@
m_process->send(Messages::WebPage::SetMediaVolume(volume), m_pageID);
}
+void WebPageProxy::setMayStartMediaWhenInWindow(bool mayStartMedia)
+{
+ if (mayStartMedia == m_mayStartMediaWhenInWindow)
+ return;
+
+ m_mayStartMediaWhenInWindow = mayStartMedia;
+
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::SetMayStartMediaWhenInWindow(mayStartMedia), m_pageID);
+}
+
#if PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(GTK)
void WebPageProxy::handleDownloadRequest(DownloadProxy* download)
{
@@ -3763,6 +3777,7 @@
parameters.canRunModal = m_canRunModal;
parameters.deviceScaleFactor = m_intrinsicDeviceScaleFactor;
parameters.mediaVolume = m_mediaVolume;
+ parameters.mayStartMediaWhenInWindow = m_mayStartMediaWhenInWindow;
#if PLATFORM(MAC)
parameters.isSmartInsertDeleteEnabled = m_isSmartInsertDeleteEnabled;
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (135914 => 135915)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2012-11-27 21:50:15 UTC (rev 135914)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2012-11-27 21:52:47 UTC (rev 135915)
@@ -736,6 +736,7 @@
void printMainFrame();
void setMediaVolume(float);
+ void setMayStartMediaWhenInWindow(bool);
// WebPopupMenuProxy::Client
virtual NativeWebMouseEvent* currentlyProcessedMouseDownEvent();
@@ -1238,6 +1239,7 @@
bool m_suppressVisibilityUpdates;
float m_mediaVolume;
+ bool m_mayStartMediaWhenInWindow;
#if PLATFORM(QT)
WTF::HashSet<RefPtr<QtRefCountedNetworkRequestData> > m_applicationSchemeRequests;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (135914 => 135915)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2012-11-27 21:50:15 UTC (rev 135914)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2012-11-27 21:52:47 UTC (rev 135915)
@@ -325,6 +325,7 @@
#endif
m_page->setCanStartMedia(false);
+ m_mayStartMediaWhenInWindow = parameters.mayStartMediaWhenInWindow;
m_pageGroup = WebProcess::shared().webPageGroup(parameters.pageGroupData);
m_page->setGroupName(m_pageGroup->identifier());
@@ -1893,7 +1894,9 @@
// Defer the call to Page::setCanStartMedia() since it ends up sending a syncrhonous messages to the UI process
// in order to get plug-in connections, and the UI process will be waiting for the Web process to update the backing
// store after moving the view into a window, until it times out and paints white. See <rdar://problem/9242771>.
- m_setCanStartMediaTimer.startOneShot(0);
+ if (m_mayStartMediaWhenInWindow)
+ m_setCanStartMediaTimer.startOneShot(0);
+
m_page->didMoveOnscreen();
}
}
@@ -3318,6 +3321,16 @@
m_page->setMediaVolume(volume);
}
+void WebPage::setMayStartMediaWhenInWindow(bool mayStartMedia)
+{
+ if (mayStartMedia == m_mayStartMediaWhenInWindow)
+ return;
+
+ m_mayStartMediaWhenInWindow = mayStartMedia;
+ if (m_mayStartMediaWhenInWindow && m_page->isOnscreen())
+ m_setCanStartMediaTimer.startOneShot(0);
+}
+
void WebPage::runModal()
{
if (m_isClosed)
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (135914 => 135915)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2012-11-27 21:50:15 UTC (rev 135914)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2012-11-27 21:52:47 UTC (rev 135915)
@@ -525,6 +525,7 @@
#endif
void setMediaVolume(float);
+ void setMayStartMediaWhenInWindow(bool);
bool mainFrameHasCustomRepresentation() const;
@@ -851,6 +852,7 @@
#endif
WebCore::RunLoop::Timer<WebPage> m_setCanStartMediaTimer;
+ bool m_mayStartMediaWhenInWindow;
HashMap<uint64_t, RefPtr<WebUndoStep> > m_undoStepMap;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (135914 => 135915)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2012-11-27 21:50:15 UTC (rev 135914)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2012-11-27 21:52:47 UTC (rev 135915)
@@ -226,6 +226,7 @@
# Media
SetMediaVolume(float volume)
+ SetMayStartMediaWhenInWindow(bool mayStartMedia)
SetMemoryCacheMessagesEnabled(bool memoryCacheMessagesEnabled)