Bug 861325 - Use an optional NamedConstructor argument for HTMLAudioElement; r=bzbarsky
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 12 Apr 2013 15:35:46 -0400
changeset 128713 7973e5a69dc5e616fd2adc5b7e9adc62e58179f1
parent 128712 6155cad4bea38e3fafa84c419f589cae2d82fc28
child 128714 a18b89e5b3e621e0961a2758844c8ceb0877dae4
push id26460
push usereakhgari@mozilla.com
push dateSat, 13 Apr 2013 19:06:14 +0000
treeherdermozilla-inbound@7973e5a69dc5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs861325
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 861325 - Use an optional NamedConstructor argument for HTMLAudioElement; r=bzbarsky
content/html/content/public/HTMLAudioElement.h
content/html/content/src/HTMLAudioElement.cpp
dom/webidl/HTMLAudioElement.webidl
--- a/content/html/content/public/HTMLAudioElement.h
+++ b/content/html/content/public/HTMLAudioElement.h
@@ -42,19 +42,17 @@ public:
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
   virtual nsresult SetAcceptHeader(nsIHttpChannel* aChannel);
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
 
   // WebIDL
 
   static already_AddRefed<HTMLAudioElement> Audio(const GlobalObject& global,
-                                                  ErrorResult& aRv);
-  static already_AddRefed<HTMLAudioElement> Audio(const GlobalObject& global,
-                                                  const nsAString& src,
+                                                  const Optional<nsAString>& src,
                                                   ErrorResult& aRv);
 
   void MozSetup(uint32_t aChannels, uint32_t aRate, ErrorResult& aRv);
 
   uint32_t MozWriteAudio(const Float32Array& aData, ErrorResult& aRv)
   {
     return MozWriteAudio(aData.Data(), aData.Length(), aRv);
   }
--- a/content/html/content/src/HTMLAudioElement.cpp
+++ b/content/html/content/src/HTMLAudioElement.cpp
@@ -51,17 +51,19 @@ HTMLAudioElement::HTMLAudioElement(alrea
 }
 
 HTMLAudioElement::~HTMLAudioElement()
 {
 }
 
 
 already_AddRefed<HTMLAudioElement>
-HTMLAudioElement::Audio(const GlobalObject& aGlobal, ErrorResult& aRv)
+HTMLAudioElement::Audio(const GlobalObject& aGlobal,
+                        const Optional<nsAString>& aSrc,
+                        ErrorResult& aRv)
 {
   nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.Get());
   nsIDocument* doc;
   if (!win || !(doc = win->GetExtantDoc())) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
@@ -71,25 +73,18 @@ HTMLAudioElement::Audio(const GlobalObje
                                         nsIDOMNode::ELEMENT_NODE);
 
   nsRefPtr<HTMLAudioElement> audio = new HTMLAudioElement(nodeInfo.forget());
   audio->SetHTMLAttr(nsGkAtoms::preload, NS_LITERAL_STRING("auto"), aRv);
   if (aRv.Failed()) {
     return nullptr;
   }
 
-  return audio.forget();
-}
-
-already_AddRefed<HTMLAudioElement>
-HTMLAudioElement::Audio(const GlobalObject& aGlobal, const nsAString& aSrc, ErrorResult& aRv)
-{
-  nsRefPtr<HTMLAudioElement> audio = Audio(aGlobal, aRv);
-  if (audio) {
-    aRv = audio->SetSrc(aSrc);
+  if (aSrc.WasPassed()) {
+    aRv = audio->SetSrc(aSrc.Value());
   }
 
   return audio.forget();
 }
 
 void
 HTMLAudioElement::MozSetup(uint32_t aChannels, uint32_t aRate, ErrorResult& aRv)
 {
--- a/dom/webidl/HTMLAudioElement.webidl
+++ b/dom/webidl/HTMLAudioElement.webidl
@@ -6,18 +6,17 @@
  * The origin of this IDL file is
  * http://www.whatwg.org/specs/web-apps/current-work/#the-audio-element
  *
  * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
  * Opera Software ASA. You are granted a license to use, reproduce
  * and create derivative works of this document.
  */
 
-[NamedConstructor=Audio(),
- NamedConstructor=Audio(DOMString src)]
+[NamedConstructor=Audio(optional DOMString src)]
 interface HTMLAudioElement : HTMLMediaElement {};
 
 partial interface HTMLAudioElement
 {
   // Setup the audio stream for writing
   [Pref="media.audio_data.enabled", Throws]
   void mozSetup(unsigned long channels, unsigned long rate);