- Revision
- 175384
- Author
- [email protected]
- Date
- 2014-10-30 15:06:12 -0700 (Thu, 30 Oct 2014)
Log Message
The Page's muted setting should not affect the HTMLMediaElement's 'muted' IDL attribute.
https://bugs.webkit.org/show_bug.cgi?id=138215
Reviewed by Eric Carlson.
Source/WebCore:
Add m_muted in Page to keep track of the Page's muted state. Change AudioProducer::setMuted()
to pageMutedStateDidChange(). When that method is called, the AudioProducer is supposed to
update its muted state again taking the Page's muted state into account.
Add HTMLMediaElement::effectiveMuted(), which returns the effective muted state of the
HTMLMediaElement, taking the Page's muted state into account.
Test: media/video-muted-after-setting-page-muted-state.html
* dom/Document.cpp:
(WebCore::Document::pageMutedStateDidChange):
(WebCore::Document::setMuted): Deleted.
* dom/Document.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setMuted):
Set the MediaPlayer's muted state to the result of effectiveMuted() rather than m_muted.
(WebCore::HTMLMediaElement::updateVolume):
Ditto, and also make sure the MediaController's muted state does not override the Page's
muted state.
(WebCore::HTMLMediaElement::updatePlayState):
Set the MediaPlayer's muted state to the result of effectiveMuted() rather than muted().
(WebCore::HTMLMediaElement::pageMutedStateDidChange):
Call updateVolume(), which will update the MediaPlayer's muted state.
(WebCore::HTMLMediaElement::effectiveMuted):
Figure out the muted value taking Page's muted state into account.
* html/HTMLMediaElement.h:
* page/AudioProducer.h:
* page/Page.cpp:
(WebCore::Page::Page):
(WebCore::Page::setMuted):
Update m_muted, and only iterate through the frames' documents to call pageMutedStateDidChange()
if m_muted changes.
* page/Page.h:
(WebCore::Page::isMuted):
* testing/Internals.cpp:
(WebCore::Internals::setPageMuted):
Expose a way to set the Page's muted state in Internals for testing.
* testing/Internals.h:
* testing/Internals.idl:
LayoutTests:
* media/video-muted-after-setting-page-muted-state-expected.txt: Added.
* media/video-muted-after-setting-page-muted-state.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (175383 => 175384)
--- trunk/LayoutTests/ChangeLog 2014-10-30 21:39:27 UTC (rev 175383)
+++ trunk/LayoutTests/ChangeLog 2014-10-30 22:06:12 UTC (rev 175384)
@@ -1,3 +1,13 @@
+2014-10-30 Ada Chan <[email protected]>
+
+ The Page's muted setting should not affect the HTMLMediaElement's 'muted' IDL attribute.
+ https://bugs.webkit.org/show_bug.cgi?id=138215
+
+ Reviewed by Eric Carlson.
+
+ * media/video-muted-after-setting-page-muted-state-expected.txt: Added.
+ * media/video-muted-after-setting-page-muted-state.html: Added.
+
2014-10-30 Brady Eidson <[email protected]>
IndexedDB is deleting data when a PK is shared amongst two objectStores
Added: trunk/LayoutTests/media/video-muted-after-setting-page-muted-state-expected.txt (0 => 175384)
--- trunk/LayoutTests/media/video-muted-after-setting-page-muted-state-expected.txt (rev 0)
+++ trunk/LayoutTests/media/video-muted-after-setting-page-muted-state-expected.txt 2014-10-30 22:06:12 UTC (rev 175384)
@@ -0,0 +1,10 @@
+
+Test 'muted' IDL attribute after setting the Page's muted state. The Page's muted state should not affect the 'muted' IDL attribute.
+
+EXPECTED (video.muted == 'false') OK
+EXPECTED (video.muted == 'false') OK
+RUN(video.muted = true)
+EXPECTED (video.muted == 'true') OK
+EXPECTED (video.muted == 'true') OK
+END OF TEST
+
Added: trunk/LayoutTests/media/video-muted-after-setting-page-muted-state.html (0 => 175384)
--- trunk/LayoutTests/media/video-muted-after-setting-page-muted-state.html (rev 0)
+++ trunk/LayoutTests/media/video-muted-after-setting-page-muted-state.html 2014-10-30 22:06:12 UTC (rev 175384)
@@ -0,0 +1,17 @@
+<video controls></video>
+<p>Test 'muted' IDL attribute after setting the Page's muted state. The Page's muted state should not affect the 'muted' IDL attribute.<p>
+<script src=""
+<script src=""
+<script>
+ testExpected("video.muted", false);
+ if (window.internals)
+ internals.setPageMuted(true);
+ testExpected("video.muted", false);
+
+ run("video.muted = true");
+ testExpected("video.muted", true);
+ if (window.internals)
+ internals.setPageMuted(false);
+ testExpected("video.muted", true);
+ endTest();
+</script>
Modified: trunk/Source/WebCore/ChangeLog (175383 => 175384)
--- trunk/Source/WebCore/ChangeLog 2014-10-30 21:39:27 UTC (rev 175383)
+++ trunk/Source/WebCore/ChangeLog 2014-10-30 22:06:12 UTC (rev 175384)
@@ -1,3 +1,50 @@
+2014-10-30 Ada Chan <[email protected]>
+
+ The Page's muted setting should not affect the HTMLMediaElement's 'muted' IDL attribute.
+ https://bugs.webkit.org/show_bug.cgi?id=138215
+
+ Reviewed by Eric Carlson.
+
+ Add m_muted in Page to keep track of the Page's muted state. Change AudioProducer::setMuted()
+ to pageMutedStateDidChange(). When that method is called, the AudioProducer is supposed to
+ update its muted state again taking the Page's muted state into account.
+
+ Add HTMLMediaElement::effectiveMuted(), which returns the effective muted state of the
+ HTMLMediaElement, taking the Page's muted state into account.
+
+ Test: media/video-muted-after-setting-page-muted-state.html
+
+ * dom/Document.cpp:
+ (WebCore::Document::pageMutedStateDidChange):
+ (WebCore::Document::setMuted): Deleted.
+ * dom/Document.h:
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::setMuted):
+ Set the MediaPlayer's muted state to the result of effectiveMuted() rather than m_muted.
+ (WebCore::HTMLMediaElement::updateVolume):
+ Ditto, and also make sure the MediaController's muted state does not override the Page's
+ muted state.
+ (WebCore::HTMLMediaElement::updatePlayState):
+ Set the MediaPlayer's muted state to the result of effectiveMuted() rather than muted().
+ (WebCore::HTMLMediaElement::pageMutedStateDidChange):
+ Call updateVolume(), which will update the MediaPlayer's muted state.
+ (WebCore::HTMLMediaElement::effectiveMuted):
+ Figure out the muted value taking Page's muted state into account.
+ * html/HTMLMediaElement.h:
+ * page/AudioProducer.h:
+ * page/Page.cpp:
+ (WebCore::Page::Page):
+ (WebCore::Page::setMuted):
+ Update m_muted, and only iterate through the frames' documents to call pageMutedStateDidChange()
+ if m_muted changes.
+ * page/Page.h:
+ (WebCore::Page::isMuted):
+ * testing/Internals.cpp:
+ (WebCore::Internals::setPageMuted):
+ Expose a way to set the Page's muted state in Internals for testing.
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
2014-10-30 Myles C. Maxfield <[email protected]>
Use references in calculateMinimumPageHeight() for non-optional arguments
Modified: trunk/Source/WebCore/dom/Document.cpp (175383 => 175384)
--- trunk/Source/WebCore/dom/Document.cpp 2014-10-30 21:39:27 UTC (rev 175383)
+++ trunk/Source/WebCore/dom/Document.cpp 2014-10-30 22:06:12 UTC (rev 175384)
@@ -3304,10 +3304,10 @@
page()->updateIsPlayingAudio();
}
-void Document::setMuted(bool muted)
+void Document::pageMutedStateDidChange()
{
for (auto audioProducer : m_audioProducers)
- audioProducer->setMuted(muted);
+ audioProducer->pageMutedStateDidChange();
}
void Document::styleResolverChanged(StyleResolverUpdateFlag updateFlag)
Modified: trunk/Source/WebCore/dom/Document.h (175383 => 175384)
--- trunk/Source/WebCore/dom/Document.h 2014-10-30 21:39:27 UTC (rev 175383)
+++ trunk/Source/WebCore/dom/Document.h 2014-10-30 22:06:12 UTC (rev 175384)
@@ -1292,7 +1292,7 @@
void removeAudioProducer(AudioProducer*);
bool isPlayingAudio() const { return m_isPlayingAudio; }
void updateIsPlayingAudio();
- void setMuted(bool);
+ void pageMutedStateDidChange();
protected:
enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 };
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (175383 => 175384)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2014-10-30 21:39:27 UTC (rev 175383)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2014-10-30 22:06:12 UTC (rev 175384)
@@ -3001,7 +3001,7 @@
// Avoid recursion when the player reports volume changes.
if (!processingMediaPlayerCallback()) {
if (m_player) {
- m_player->setMuted(m_muted);
+ m_player->setMuted(effectiveMuted());
if (hasMediaControls())
mediaControls()->changedMute();
}
@@ -4470,11 +4470,11 @@
if (!processingMediaPlayerCallback()) {
Page* page = document().page();
double volumeMultiplier = page ? page->mediaVolume() : 1;
- bool shouldMute = muted();
+ bool shouldMute = effectiveMuted();
if (m_mediaController) {
volumeMultiplier *= m_mediaController->volume();
- shouldMute = m_mediaController->muted();
+ shouldMute = m_mediaController->muted() || (page && page->isMuted());
}
m_player->setMuted(shouldMute);
@@ -4520,7 +4520,7 @@
// Set rate, muted before calling play in case they were set before the media engine was setup.
// The media engine should just stash the rate and muted values since it isn't already playing.
m_player->setRate(effectivePlaybackRate());
- m_player->setMuted(muted());
+ m_player->setMuted(effectiveMuted());
m_player->play();
}
@@ -6032,6 +6032,16 @@
return isPlaying() && hasAudio();
}
+void HTMLMediaElement::pageMutedStateDidChange()
+{
+ updateVolume();
+}
+
+bool HTMLMediaElement::effectiveMuted() const
+{
+ return muted() || (document().page() && document().page()->isMuted());
+}
+
bool HTMLMediaElement::doesHaveAttribute(const AtomicString& attribute, AtomicString* value) const
{
QualifiedName attributeName(nullAtom, attribute, nullAtom);
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (175383 => 175384)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2014-10-30 21:39:27 UTC (rev 175383)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2014-10-30 22:06:12 UTC (rev 175384)
@@ -712,7 +712,10 @@
// AudioProducer overrides
virtual bool isPlayingAudio() override;
+ virtual void pageMutedStateDidChange() override;
+ bool effectiveMuted() const;
+
void registerWithDocument(Document&);
void unregisterWithDocument(Document&);
Modified: trunk/Source/WebCore/page/AudioProducer.h (175383 => 175384)
--- trunk/Source/WebCore/page/AudioProducer.h 2014-10-30 21:39:27 UTC (rev 175383)
+++ trunk/Source/WebCore/page/AudioProducer.h 2014-10-30 22:06:12 UTC (rev 175384)
@@ -31,7 +31,7 @@
class AudioProducer {
public:
virtual bool isPlayingAudio() = 0;
- virtual void setMuted(bool) = 0;
+ virtual void pageMutedStateDidChange() = 0;
protected:
virtual ~AudioProducer() { }
Modified: trunk/Source/WebCore/page/Page.cpp (175383 => 175384)
--- trunk/Source/WebCore/page/Page.cpp 2014-10-30 21:39:27 UTC (rev 175383)
+++ trunk/Source/WebCore/page/Page.cpp 2014-10-30 22:06:12 UTC (rev 175384)
@@ -160,6 +160,7 @@
, m_inLowQualityInterpolationMode(false)
, m_areMemoryCacheClientCallsEnabled(true)
, m_mediaVolume(1)
+ , m_muted(false)
, m_pageScaleFactor(1)
, m_zoomedOutPageScaleFactor(0)
, m_deviceScaleFactor(1)
@@ -1215,8 +1216,13 @@
void Page::setMuted(bool muted)
{
+ if (m_muted == muted)
+ return;
+
+ m_muted = muted;
+
for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
- frame->document()->setMuted(muted);
+ frame->document()->pageMutedStateDidChange();
}
#if !ASSERT_DISABLED
Modified: trunk/Source/WebCore/page/Page.h (175383 => 175384)
--- trunk/Source/WebCore/page/Page.h 2014-10-30 21:39:27 UTC (rev 175383)
+++ trunk/Source/WebCore/page/Page.h 2014-10-30 22:06:12 UTC (rev 175384)
@@ -438,6 +438,7 @@
bool isPlayingAudio() const { return m_isPlayingAudio; }
void updateIsPlayingAudio();
+ bool isMuted() const { return m_muted; }
WEBCORE_EXPORT void setMuted(bool);
private:
@@ -517,6 +518,7 @@
bool m_inLowQualityInterpolationMode;
bool m_areMemoryCacheClientCallsEnabled;
float m_mediaVolume;
+ bool m_muted;
float m_pageScaleFactor;
float m_zoomedOutPageScaleFactor;
Modified: trunk/Source/WebCore/testing/Internals.cpp (175383 => 175384)
--- trunk/Source/WebCore/testing/Internals.cpp 2014-10-30 21:39:27 UTC (rev 175383)
+++ trunk/Source/WebCore/testing/Internals.cpp 2014-10-30 22:06:12 UTC (rev 175384)
@@ -2402,4 +2402,14 @@
return MockPageOverlayClient::shared().layerTreeAsText(document->frame()->mainFrame());
}
+void Internals::setPageMuted(bool muted)
+{
+ Document* document = contextDocument();
+ if (!document)
+ return;
+
+ if (Page* page = document->page())
+ page->setMuted(muted);
}
+
+}
Modified: trunk/Source/WebCore/testing/Internals.h (175383 => 175384)
--- trunk/Source/WebCore/testing/Internals.h 2014-10-30 21:39:27 UTC (rev 175383)
+++ trunk/Source/WebCore/testing/Internals.h 2014-10-30 22:06:12 UTC (rev 175384)
@@ -346,6 +346,8 @@
void installMockPageOverlay(const String& overlayType, ExceptionCode&);
String pageOverlayLayerTreeAsText(ExceptionCode&) const;
+ void setPageMuted(bool);
+
private:
explicit Internals(Document*);
Document* contextDocument() const;
Modified: trunk/Source/WebCore/testing/Internals.idl (175383 => 175384)
--- trunk/Source/WebCore/testing/Internals.idl 2014-10-30 21:39:27 UTC (rev 175383)
+++ trunk/Source/WebCore/testing/Internals.idl 2014-10-30 22:06:12 UTC (rev 175384)
@@ -301,4 +301,6 @@
[RaisesException] void installMockPageOverlay(PageOverlayType type);
[RaisesException] DOMString pageOverlayLayerTreeAsText();
+
+ void setPageMuted(boolean muted);
};