Bug 454971. Support 'new Audio()' constructor. r+sr=roc
authorMatthew Gregan <kinetik@flim.org>
Tue, 19 May 2009 17:18:41 +1200
changeset 28568 df4a4ef0e00ee9bf73cffdaa06984503f7f83c60
parent 28567 d9d952a6226033030c783daa4ed42ab29d8fc7db
child 28569 2230bf80e2f7fbc3ad3d37ba2c25774c58163630
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs454971
milestone1.9.2a1pre
Bug 454971. Support 'new Audio()' constructor. r+sr=roc
content/html/content/public/nsHTMLAudioElement.h
content/html/content/src/Makefile.in
content/html/content/src/nsHTMLAudioElement.cpp
content/media/video/test/Makefile.in
content/media/video/test/sound.ogg
content/media/video/test/test_audio1.html
content/media/video/test/test_audio2.html
layout/build/nsLayoutCID.h
layout/build/nsLayoutModule.cpp
--- a/content/html/content/public/nsHTMLAudioElement.h
+++ b/content/html/content/public/nsHTMLAudioElement.h
@@ -31,23 +31,25 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 #include "nsIDOMHTMLAudioElement.h"
+#include "nsIJSNativeInitializer.h"
 #include "nsHTMLMediaElement.h"
 
 typedef PRUint16 nsMediaNetworkState;
 typedef PRUint16 nsMediaReadyState;
 
 class nsHTMLAudioElement : public nsHTMLMediaElement,
-                           public nsIDOMHTMLAudioElement
+                           public nsIDOMHTMLAudioElement,
+                           public nsIJSNativeInitializer
 {
 public:
   nsHTMLAudioElement(nsINodeInfo *aNodeInfo, PRBool aFromParser = PR_FALSE);
   virtual ~nsHTMLAudioElement();
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
@@ -61,10 +63,14 @@ public:
   NS_FORWARD_NSIDOMHTMLELEMENT(nsHTMLMediaElement::)
 
   // nsIDOMHTMLMediaElement
   NS_FORWARD_NSIDOMHTMLMEDIAELEMENT(nsHTMLMediaElement::)
 
   // nsIDOMHTMLAudioElement
   NS_DECL_NSIDOMHTMLAUDIOELEMENT
 
+  // nsIJSNativeInitializer
+  NS_IMETHOD Initialize(nsISupports* aOwner, JSContext* aContext,
+                        JSObject* aObj, PRUint32 argc, jsval* argv);
+
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 };
--- a/content/html/content/src/Makefile.in
+++ b/content/html/content/src/Makefile.in
@@ -151,12 +151,13 @@ FORCE_STATIC_LIB = 1
 include $(topsrcdir)/config/rules.mk
 
 INCLUDES	+= \
 		-I$(srcdir)/../../../base/src \
 		-I$(srcdir)/../../../events/src \
 		-I$(srcdir)/../../../xbl/src \
 		-I$(srcdir)/../../../../layout/style \
 		-I$(srcdir)/../../../../layout/tables \
+		-I$(srcdir)/../../../../dom/base \
 		-I$(srcdir) \
 		$(NULL)
 
 DEFINES += -D_IMPL_NS_LAYOUT
--- a/content/html/content/src/nsHTMLAudioElement.cpp
+++ b/content/html/content/src/nsHTMLAudioElement.cpp
@@ -54,39 +54,79 @@
 #include "nsNetUtil.h"
 #include "nsXPCOMStrings.h"
 #include "prlock.h"
 #include "nsThreadUtils.h"
 
 #include "nsIScriptSecurityManager.h"
 #include "nsIXPConnect.h"
 #include "jsapi.h"
+#include "nsJSUtils.h"
 
 #include "nsIRenderingContext.h"
 #include "nsITimer.h"
 
 #include "nsEventDispatcher.h"
 #include "nsIDOMDocumentEvent.h"
 #include "nsIDOMProgressEvent.h"
 #include "nsHTMLMediaError.h"
 
-NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Audio)
+nsGenericHTMLElement*
+NS_NewHTMLAudioElement(nsINodeInfo *aNodeInfo, PRBool aFromParser)
+{
+  /*
+   * nsHTMLAudioElement's will be created without a nsINodeInfo passed in
+   * if someone says "var audio = new Audio();" in JavaScript, in a case like
+   * that we request the nsINodeInfo from the document's nodeinfo list.
+   */
+  nsCOMPtr<nsINodeInfo> nodeInfo(aNodeInfo);
+  if (!nodeInfo) {
+    nsCOMPtr<nsIDocument> doc =
+      do_QueryInterface(nsContentUtils::GetDocumentFromCaller());
+    NS_ENSURE_TRUE(doc, nsnull);
+
+    nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::audio, nsnull,
+                                                   kNameSpaceID_None);
+    NS_ENSURE_TRUE(nodeInfo, nsnull);
+  }
+
+  return new nsHTMLAudioElement(nodeInfo, aFromParser);
+}
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLAudioElement, nsHTMLMediaElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLAudioElement, nsHTMLMediaElement)
 
 NS_INTERFACE_TABLE_HEAD(nsHTMLAudioElement)
-  NS_HTML_CONTENT_INTERFACE_TABLE2(nsHTMLAudioElement, nsIDOMHTMLMediaElement, nsIDOMHTMLAudioElement)
+NS_HTML_CONTENT_INTERFACE_TABLE3(nsHTMLAudioElement, nsIDOMHTMLMediaElement,
+                                 nsIDOMHTMLAudioElement, nsIJSNativeInitializer)
   NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLAudioElement,
                                                nsHTMLMediaElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLAudioElement)
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLAudioElement)
 
 
 nsHTMLAudioElement::nsHTMLAudioElement(nsINodeInfo *aNodeInfo, PRBool aFromParser)
   : nsHTMLMediaElement(aNodeInfo, aFromParser)
 {
 }
 
 nsHTMLAudioElement::~nsHTMLAudioElement()
 {
 }
+
+NS_IMETHODIMP
+nsHTMLAudioElement::Initialize(nsISupports* aOwner, JSContext* aContext,
+                               JSObject *aObj, PRUint32 argc, jsval *argv)
+{
+  if (argc <= 0) {
+    // Nothing to do here if we don't get any arguments.
+    return NS_OK;
+  }
+
+  // The only (optional) argument is the url of the audio
+  JSString* jsstr = JS_ValueToString(aContext, argv[0]);
+  if (!jsstr)
+    return NS_ERROR_FAILURE;
+
+  nsDependentJSString str(jsstr);
+  return SetAttr(kNameSpaceID_None, nsGkAtoms::src, str, PR_TRUE);
+}
--- a/content/media/video/test/Makefile.in
+++ b/content/media/video/test/Makefile.in
@@ -60,16 +60,18 @@ include $(topsrcdir)/config/rules.mk
 		use_large_cache.js \
 		$(NULL)
 
 ifdef MOZ_OGG
 _TEST_FILES += \
 		dynamic_redirect.sjs \
 		test_access_control.html \
 		file_access_controls.html \
+		test_audio1.html \
+		test_audio2.html \
 		test_bug448534.html \
 		test_bug461281.html \
 		test_bug468190.html \
 		test_bug482461.html \
 		test_bug493187.html \
 		test_can_play_type_ogg.html \
 		test_closing_connections.html \
 		test_contentDuration1.html \
@@ -103,16 +105,17 @@ ifdef MOZ_OGG
 		redirect.sjs \
 		contentDuration1.sjs \
 		contentDuration2.sjs \
 		contentDuration3.sjs \
 		contentDuration4.sjs \
 		contentDuration5.sjs \
 		contentDuration6.sjs \
 		seek.ogv \
+		sound.ogg \
 		$(NULL)
 
 # These tests disabled until we figure out random failures.
 # Bug 492821:
 # test_videoDocumentTitle.html
 # Bug 493692:
 # test_autobuffer2.html
 
@@ -160,17 +163,17 @@ ifdef MOZ_WAVE
 		test_wav_seek7.html \
 		test_wav_seek8.html \
 		test_wav_seek_past_end.html \
 		test_wav_seek_then_play.html \
 		test_wav_standalone.html \
 		test_wav_timeupdate1.html \
 		test_wav_timeupdate2.html \
 		test_wav_trailing.html \
- 		test_wav_trunc.html \
+		test_wav_trunc.html \
 		test_wav_trunc_seek.html \
 		r11025_s16_c1.wav \
 		r11025_s16_c1_trailing.wav \
 		r11025_u8_c1.wav \
 		r11025_u8_c1_trunc.wav \
 		r16000_u8_c1_list.wav \
 		$(NULL)
 else
new file mode 100644
index 0000000000000000000000000000000000000000..edda4e9128435b0cc9ba500c9daca90e2be30acf
GIT binary patch
literal 2603
zc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wf%2zx;)H?m$<p?^JEY<&esQ_0h?Wu6`l@9|2F#OVVDFU+>$5t4oH}H9k)8fuv
z4C5iUxD65@w2J!J-JgVXNfrq8mS8WS|7S6N=OhMu{t9a<x#zx6sjGLKy6WH`g#)Po
zI3%4SEzB7sj>)!9Z;;Cf0=h^-XODG?Fol=my$jslAa@Z}7$Sq(<TASmTkax^S|z-P
z*fN(rTZ_2tMxF{4NF7;P9YsX7oAVDEaYRZ&c^O5Nq`P2-=+z`{!n_Bwal}hT@kVc;
zA7AcrS7SOEb=#zq1+saF!1aj3i0fqbeq137IH5!!hHv&luP`qag`QG<80O_OP6ly}
zQj&lP=#Iib-A1j>OF<jz0K|FELoF1+Qz;zNBUCmNqX?4@aqwZ0&>>mCh-L65Av13m
z;^4EoEDOHG<wjH2iG6Rqmv%&6d#nQ{bt!z=mKSJBt27xKIy5PKg95Gq0DG8C0?~@!
r4P6yz4^5<$bzV#Twvz!J$<8JXw13;#@C_1<bguqD@VyT3y^enam-FtA
new file mode 100644
--- /dev/null
+++ b/content/media/video/test/test_audio1.html
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Media test: Audio Constructor Test 1</title>
+  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+var a1 = new Audio();
+a1.addEventListener('load', function() {
+  is(a1.networkState, HTMLMediaElement.NETWORK_LOADED, "Audio loaded");
+  SimpleTest.finish();
+}, false);
+a1.src = 'sound.ogg';
+a1.load();
+
+SimpleTest.waitForExplicitFinish();
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/content/media/video/test/test_audio2.html
@@ -0,0 +1,23 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Media test: Audio Constructor Test 2</title>
+  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+var a1 = Audio('sound.ogg');
+a1.addEventListener('load', function() {
+  is(a1.networkState, HTMLMediaElement.NETWORK_LOADED, "Audio loaded");
+  SimpleTest.finish();
+}, false);
+a1.load();
+
+SimpleTest.waitForExplicitFinish();
+</script>
+</pre>
+</body>
+</html>
--- a/layout/build/nsLayoutCID.h
+++ b/layout/build/nsLayoutCID.h
@@ -224,9 +224,17 @@
 
 // {14632191-AC21-4BDF-83E7-2363AD17E838}
 #define NS_XULPOPUPMANAGER_CID \
 { 0x14632191, 0xac21, 0x4bdf, { 0x83, 0xe7, 0x23, 0x63, 0xad, 0x17, 0xe8, 0x38 } }
 
 // {93ad72a6-02cd-4716-9626-d47d5ec275ec}
 #define NS_DOMJSON_CID \
 { 0x93ad72a6, 0x02cd, 0x4716, { 0x96, 0x26, 0xd4, 0x7d, 0x5e, 0xc2, 0x75, 0xec } }
+
+#ifdef MOZ_MEDIA
+#define NS_HTMLAUDIOELEMENT_CID                   \
+{ /* 1d40026b-4c44-4f6f-b158-26bb5e9c65e9 */      \
+ 0x1d40026b, 0x4c44, 0x4f6f,                      \
+ {0xb1, 0x58, 0x26, 0xbb, 0x5e, 0x9c, 0x65, 0xe9}}
+#endif
+
 #endif /* nsLayoutCID_h__ */
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -218,16 +218,21 @@ class nsIDocumentLoaderFactory;
 #define PRODUCT_NAME "Gecko"
 
 #define NS_HTMLIMGELEMENT_CONTRACTID \
   "@mozilla.org/content/element/html;1?name=img"
 
 #define NS_HTMLOPTIONELEMENT_CONTRACTID \
   "@mozilla.org/content/element/html;1?name=option"
 
+#ifdef MOZ_MEDIA
+#define NS_HTMLAUDIOELEMENT_CONTRACTID \
+  "@mozilla.org/content/element/html;1?name=audio"
+#endif
+
 /* 0ddf4df8-4dbb-4133-8b79-9afb966514f5 */
 #define NS_PLUGINDOCLOADERFACTORY_CID \
 { 0x0ddf4df8, 0x4dbb, 0x4133, { 0x8b, 0x79, 0x9a, 0xfb, 0x96, 0x65, 0x14, 0xf5 } }
 
 #define NS_WINDOWCOMMANDTABLE_CID \
  { /* 0DE2FBFA-6B7F-11D7-BBBA-0003938A9D96 */        \
   0x0DE2FBFA, 0x6B7F, 0x11D7, {0xBB, 0xBA, 0x00, 0x03, 0x93, 0x8A, 0x9D, 0x96} }
 
@@ -487,16 +492,17 @@ MAKE_CTOR(CreateDOMSelection,           
 MAKE_CTOR(CreateSelection,                nsFrameSelection,            NS_NewSelection)
 MAKE_CTOR(CreateRange,                    nsIDOMRange,                 NS_NewRange)
 MAKE_CTOR(CreateRangeUtils,               nsIRangeUtils,               NS_NewRangeUtils)
 MAKE_CTOR(CreateContentIterator,          nsIContentIterator,          NS_NewContentIterator)
 MAKE_CTOR(CreatePreContentIterator,       nsIContentIterator,          NS_NewPreContentIterator)
 MAKE_CTOR(CreateSubtreeIterator,          nsIContentIterator,          NS_NewContentSubtreeIterator)
 // CreateHTMLImgElement, see below
 // CreateHTMLOptionElement, see below
+// CreateHTMLAudioElement, see below
 MAKE_CTOR(CreateTextEncoder,              nsIDocumentEncoder,          NS_NewTextEncoder)
 MAKE_CTOR(CreateHTMLCopyTextEncoder,      nsIDocumentEncoder,          NS_NewHTMLCopyTextEncoder)
 MAKE_CTOR(CreateXMLContentSerializer,     nsIContentSerializer,        NS_NewXMLContentSerializer)
 MAKE_CTOR(CreateHTMLContentSerializer,    nsIContentSerializer,        NS_NewHTMLContentSerializer)
 MAKE_CTOR(CreateXHTMLContentSerializer,   nsIContentSerializer,        NS_NewXHTMLContentSerializer)
 MAKE_CTOR(CreatePlainTextSerializer,      nsIContentSerializer,        NS_NewPlainTextSerializer)
 MAKE_CTOR(CreateHTMLFragmentSink,         nsIFragmentContentSink,      NS_NewHTMLFragmentContentSink)
 MAKE_CTOR(CreateHTMLFragmentSink2,        nsIFragmentContentSink,      NS_NewHTMLFragmentContentSink2)
@@ -668,16 +674,63 @@ UnregisterHTMLOptionElement(nsIComponent
                             nsIFile* aPath,
                             const char* aRegistryLocation,
                             const nsModuleComponentInfo* aInfo)
 {
   // XXX remove category entry
   return NS_OK;
 }
 
+#ifdef MOZ_MEDIA
+static NS_IMETHODIMP
+CreateHTMLAudioElement(nsISupports* aOuter, REFNSIID aIID, void** aResult)
+{
+  *aResult = nsnull;
+  if (aOuter)
+    return NS_ERROR_NO_AGGREGATION;
+  // Note! NS_NewHTMLAudioElement is special cased to handle a null nodeinfo
+  nsCOMPtr<nsIContent> inst(NS_NewHTMLAudioElement(nsnull));
+  return inst ? inst->QueryInterface(aIID, aResult) : NS_ERROR_OUT_OF_MEMORY;
+}
+
+static NS_IMETHODIMP
+RegisterHTMLAudioElement(nsIComponentManager *aCompMgr,
+                         nsIFile* aPath,
+                         const char* aRegistryLocation,
+                         const char* aComponentType,
+                         const nsModuleComponentInfo* aInfo)
+{
+  nsCOMPtr<nsICategoryManager> catman =
+    do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
+
+  if (!catman)
+    return NS_ERROR_FAILURE;
+
+  nsXPIDLCString previous;
+  nsresult rv = catman->AddCategoryEntry(JAVASCRIPT_GLOBAL_CONSTRUCTOR_CATEGORY,
+                                         "Audio", NS_HTMLAUDIOELEMENT_CONTRACTID,
+                                         PR_TRUE, PR_TRUE, getter_Copies(previous));
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  return catman->AddCategoryEntry(JAVASCRIPT_GLOBAL_CONSTRUCTOR_PROTO_ALIAS_CATEGORY,
+                                  "Audio", "HTMLAudioElement",
+                                  PR_TRUE, PR_TRUE, getter_Copies(previous));
+}
+
+static NS_IMETHODIMP
+UnregisterHTMLAudioElement(nsIComponentManager* aCompMgr,
+                           nsIFile* aPath,
+                           const char* aRegistryLocation,
+                           const nsModuleComponentInfo* aInfo)
+{
+  // XXX remove category entry
+  return NS_OK;
+}
+#endif
+
 static NS_METHOD
 RegisterDataDocumentContentPolicy(nsIComponentManager *aCompMgr,
                                   nsIFile* aPath,
                                   const char* aRegistryLocation,
                                   const char* aComponentType,
                                   const nsModuleComponentInfo* aInfo)
 {
   nsresult rv;
@@ -995,31 +1048,40 @@ static const nsModuleComponentInfo gComp
     "@mozilla.org/content/subtree-content-iterator;1",
     CreateSubtreeIterator },
 
   { "Inspector CSS Utils",
     NS_INSPECTORCSSUTILS_CID,
     nsnull,
     nsInspectorCSSUtilsConstructor },
 
-  // Needed to support "new Option;" and "new Image;" in JavaScript
+  // Needed to support "new Option;", "new Image;" and "new Audio;" in JavaScript
   { "HTML img element",
     NS_HTMLIMAGEELEMENT_CID,
     NS_HTMLIMGELEMENT_CONTRACTID,
     CreateHTMLImgElement,
     RegisterHTMLImgElement, 
     UnregisterHTMLImgElement },
 
   { "HTML option element",
     NS_HTMLOPTIONELEMENT_CID,
     NS_HTMLOPTIONELEMENT_CONTRACTID,
     CreateHTMLOptionElement,
     RegisterHTMLOptionElement,
     UnregisterHTMLOptionElement },
 
+#ifdef MOZ_MEDIA
+  { "HTML audio element",
+    NS_HTMLAUDIOELEMENT_CID,
+    NS_HTMLAUDIOELEMENT_CONTRACTID,
+    CreateHTMLAudioElement,
+    RegisterHTMLAudioElement,
+    UnregisterHTMLAudioElement },
+#endif
+
 #ifdef MOZ_ENABLE_CANVAS
   { "Canvas 2D Rendering Context",
     NS_CANVASRENDERINGCONTEXT2D_CID,
     "@mozilla.org/content/canvas-rendering-context;1?id=2d",
     CreateCanvasRenderingContext2D },
 #endif
 
   { "XML document encoder",