Diff
Modified: trunk/LayoutTests/ChangeLog (94317 => 94318)
--- trunk/LayoutTests/ChangeLog 2011-09-01 18:03:39 UTC (rev 94317)
+++ trunk/LayoutTests/ChangeLog 2011-09-01 18:10:51 UTC (rev 94318)
@@ -1,3 +1,13 @@
+2011-09-01 Eric Carlson <[email protected]>
+
+ Add 'muted' content attribute to HTMLMediaElement
+ https://bugs.webkit.org/show_bug.cgi?id=58369
+
+ Reviewed by Darin Adler.
+
+ * media/video-defaultmuted-expected.txt: Added.
+ * media/video-defaultmuted.html: Added.
+
2011-08-30 Adrienne Walker <[email protected]>
[chromium] Fix scissor rects on clipped nested iframes
Added: trunk/LayoutTests/media/video-defaultmuted-expected.txt (0 => 94318)
--- trunk/LayoutTests/media/video-defaultmuted-expected.txt (rev 0)
+++ trunk/LayoutTests/media/video-defaultmuted-expected.txt 2011-09-01 18:10:51 UTC (rev 94318)
@@ -0,0 +1,72 @@
+Test 'muted' content attribute
+
+
+
+*** Test with 'muted' content attribute
+
+RUN(video = document.createElement('video'))
+RUN(video.setAttribute('controls', 'controls'))
+RUN(video.setAttribute('muted', 'muted'))
+
+*** Test before setting src, IDL attribute should default to false
+EXPECTED (video.muted == 'false') OK
+EXPECTED (video.defaultMuted == 'true') OK
+
+EVENT(loadedmetadata)
+
+*** After setting url, content attribute should have set IDL attribute
+EXPECTED (video.muted == 'true') OK
+EXPECTED (video.defaultMuted == 'true') OK
+
+*** Change 'defaultMuted', IDL attribute should not change but content attribute should.
+RUN(video.defaultMuted = false)
+EXPECTED (video.muted == 'true') OK
+EXPECTED (video.defaultMuted == 'false') OK
+EXPECTED (video.hasAttribute('muted') == 'false') OK
+
+*** Change 'muted' IDL attribute, content attribute should not change
+RUN(video.muted = false)
+EXPECTED (video.muted == 'false') OK
+EXPECTED (video.defaultMuted == 'false') OK
+EXPECTED (video.hasAttribute('muted') == 'false') OK
+
+*** Remove 'muted' content attribute, it should have no effect on IDL attribute
+RUN(video.removeAttribute('muted'))
+EXPECTED (video.muted == 'false') OK
+EXPECTED (video.defaultMuted == 'false') OK
+
+
+*** Test without 'muted' content attribute
+
+RUN(video = document.createElement('video'))
+RUN(video.setAttribute('controls', 'controls'))
+
+*** Test before setting src, IDL attribute should default to false
+EXPECTED (video.muted == 'false') OK
+EXPECTED (video.defaultMuted == 'false') OK
+
+EVENT(loadedmetadata)
+
+*** After setting url, content attribute should have set IDL attribute
+EXPECTED (video.muted == 'false') OK
+EXPECTED (video.defaultMuted == 'false') OK
+
+*** Change 'defaultMuted', IDL attribute should not change but content attribute should.
+RUN(video.defaultMuted = true)
+EXPECTED (video.muted == 'false') OK
+EXPECTED (video.defaultMuted == 'true') OK
+EXPECTED (video.hasAttribute('muted') == 'true') OK
+
+*** Change 'muted' IDL attribute, content attribute should not change
+RUN(video.muted = false)
+EXPECTED (video.muted == 'false') OK
+EXPECTED (video.defaultMuted == 'true') OK
+EXPECTED (video.hasAttribute('muted') == 'true') OK
+
+*** Add 'muted' content attribute, it should have no effect on IDL attribute
+RUN(video.setAttribute('muted', 'muted'))
+EXPECTED (video.muted == 'false') OK
+EXPECTED (video.defaultMuted == 'true') OK
+
+END OF TEST
+
Added: trunk/LayoutTests/media/video-defaultmuted.html (0 => 94318)
--- trunk/LayoutTests/media/video-defaultmuted.html (rev 0)
+++ trunk/LayoutTests/media/video-defaultmuted.html 2011-09-01 18:10:51 UTC (rev 94318)
@@ -0,0 +1,90 @@
+<!doctype html>
+<html>
+ <head>
+ <script src=""
+ <script src=""
+ <script>
+ var index = 0;
+
+ function testMuted(expectedMuted, expectedDefaultMuted)
+ {
+ testExpected("video.muted", expectedMuted);
+ testExpected("video.defaultMuted", expectedDefaultMuted);
+ }
+
+ function test(defaultMuted)
+ {
+ consoleWrite("<br><br><b>*** Test <em>" + (defaultMuted ? "with" : "without") + "</em> 'muted' content attribute</b><br>");
+
+ run("video = document.createElement('video')");
+ run("video.setAttribute('controls', 'controls')");
+ video.setAttribute('width', '300');
+ if (defaultMuted)
+ run("video.setAttribute('muted', 'muted')");
+ document.getElementById('parent').appendChild(video);
+
+ consoleWrite("<br>*** Test before setting src, IDL attribute should default to false");
+ testMuted(false, defaultMuted);
+
+ var loadedmetadata = function(evt)
+ {
+ consoleWrite("<br>EVENT(" + evt.type + ")");
+
+ consoleWrite("<br>*** After setting url, content attribute should have set IDL attribute");
+ testMuted(defaultMuted, defaultMuted);
+
+ consoleWrite("<br>*** Change 'defaultMuted', IDL attribute should not change but content attribute should.");
+ var newDefaultMuted = !defaultMuted;
+ run("video.defaultMuted = " + newDefaultMuted);
+ testMuted(defaultMuted, newDefaultMuted);
+ testExpected("video.hasAttribute('muted')", newDefaultMuted);
+
+ consoleWrite("<br>*** Change 'muted' IDL attribute, content attribute should not change");
+ run("video.muted = false");
+ testMuted(false, newDefaultMuted);
+ testExpected("video.hasAttribute('muted')", newDefaultMuted);
+
+ var action = "" ? "Remove" : "Add";
+ consoleWrite("<br>*** " + action + " 'muted' content attribute, it should have no effect on IDL attribute");
+ if (defaultMuted)
+ run("video.removeAttribute('muted')");
+ else
+ run("video.setAttribute('muted', 'muted')");
+ testMuted(false, video.hasAttribute('muted'));
+
+ runNextTest();
+ }
+ video.addEventListener('loadedmetadata', loadedmetadata);
+ video.src = "" "content/test");
+ }
+
+ function runNextTest()
+ {
+ if (video) {
+ video.parentNode.removeChild(video);
+ video = null;
+ }
+
+ switch (++index)
+ {
+ case 1:
+ test(true);
+ break;
+ case 2:
+ test(false);
+ break;
+ case 3:
+ consoleWrite("");
+ endTest();
+ break;
+ }
+ }
+
+ </script>
+ </head>
+
+ <body _onload_="runNextTest()">
+ <div id="parent"></div>
+ <p>Test 'muted' content attribute<p>
+ </body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (94317 => 94318)
--- trunk/Source/WebCore/ChangeLog 2011-09-01 18:03:39 UTC (rev 94317)
+++ trunk/Source/WebCore/ChangeLog 2011-09-01 18:10:51 UTC (rev 94318)
@@ -1,3 +1,17 @@
+2011-09-01 Eric Carlson <[email protected]>
+
+ Add 'muted' content attribute to HTMLMediaElement
+ https://bugs.webkit.org/show_bug.cgi?id=58369
+
+ Reviewed by Darin Adler.
+
+ Test: media/video-defaultmuted.html
+
+ * html/HTMLAttributeNames.in: Add muted.
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::loadResource): Deal with the 'muted' attribute.
+ * html/HTMLMediaElement.idl: Add defaultMuted.
+
2011-09-01 Tim Horton <[email protected]>
REGRESSION: Rendering artifacts on a rotated, pattern filled shape
Modified: trunk/Source/WebCore/html/HTMLAttributeNames.in (94317 => 94318)
--- trunk/Source/WebCore/html/HTMLAttributeNames.in 2011-09-01 18:03:39 UTC (rev 94317)
+++ trunk/Source/WebCore/html/HTMLAttributeNames.in 2011-09-01 18:10:51 UTC (rev 94318)
@@ -146,6 +146,7 @@
method
min
multiple
+muted
name
nohref
noresize
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (94317 => 94318)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2011-09-01 18:03:39 UTC (rev 94317)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2011-09-01 18:10:51 UTC (rev 94318)
@@ -808,6 +808,9 @@
if (!autoplay())
m_player->setPreload(m_preload);
m_player->setPreservesPitch(m_webkitPreservesPitch);
+
+ if (hasAttribute(mutedAttr))
+ m_muted = true;
updateVolume();
if (!m_player->load(url.string(), contentType))
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (94317 => 94318)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2011-09-01 18:03:39 UTC (rev 94317)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2011-09-01 18:10:51 UTC (rev 94318)
@@ -159,6 +159,7 @@
void setVolume(float, ExceptionCode&);
bool muted() const;
void setMuted(bool);
+
void togglePlayState();
void beginScrubbing();
void endScrubbing();
Modified: trunk/Source/WebCore/html/HTMLMediaElement.idl (94317 => 94318)
--- trunk/Source/WebCore/html/HTMLMediaElement.idl 2011-09-01 18:03:39 UTC (rev 94317)
+++ trunk/Source/WebCore/html/HTMLMediaElement.idl 2011-09-01 18:10:51 UTC (rev 94318)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2010, 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -78,7 +78,8 @@
attribute float volume
setter raises (DOMException);
attribute boolean muted;
-
+ attribute [Reflect=muted] boolean defaultMuted;
+
// WebKit extensions
attribute boolean webkitPreservesPitch;