Bug 1286722: [MSE] P1. Add mediasource event handler attributes. r=bz
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 14 Jul 2016 18:28:19 +1000
changeset 305072 501b4b7d83ea
parent 305071 a9bcf6959e2a
child 305073 5b9850e2567a
push id30453
push usercbook@mozilla.com
push dateSun, 17 Jul 2016 07:16:01 +0000
treeherdermozilla-central@9ee862a030f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1286722
milestone50.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 1286722: [MSE] P1. Add mediasource event handler attributes. r=bz See https://github.com/w3c/media-source/issues/66 MozReview-Commit-ID: 9fANabkz5ud
dom/base/nsGkAtomList.h
dom/media/mediasource/MediaSource.h
dom/media/mediasource/SourceBuffer.h
dom/media/mediasource/SourceBufferList.h
dom/webidl/MediaSource.webidl
dom/webidl/SourceBuffer.webidl
dom/webidl/SourceBufferList.webidl
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -2449,8 +2449,18 @@ GK_ATOM(nsuri_xml, "http://www.w3.org/XM
 GK_ATOM(nsuri_xhtml, "http://www.w3.org/1999/xhtml")
 GK_ATOM(nsuri_xlink, "http://www.w3.org/1999/xlink")
 GK_ATOM(nsuri_xslt, "http://www.w3.org/1999/XSL/Transform")
 GK_ATOM(nsuri_xbl, "http://www.mozilla.org/xbl")
 GK_ATOM(nsuri_mathml, "http://www.w3.org/1998/Math/MathML")
 GK_ATOM(nsuri_rdf, "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
 GK_ATOM(nsuri_xul, "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul")
 GK_ATOM(nsuri_svg, "http://www.w3.org/2000/svg")
+
+// MSE
+GK_ATOM(onsourceopen, "onsourceopen")
+GK_ATOM(onsourceended, "onsourceended")
+GK_ATOM(onsourceclosed, "onsourceclosed")
+GK_ATOM(onupdatestart, "onupdatestart")
+GK_ATOM(onupdate, "onupdate")
+GK_ATOM(onupdateend, "onupdateend")
+GK_ATOM(onaddsourcebuffer, "onaddsourcebuffer")
+GK_ATOM(onremovesourcebuffer, "onremovesourcebuffer")
--- a/dom/media/mediasource/MediaSource.h
+++ b/dom/media/mediasource/MediaSource.h
@@ -67,16 +67,21 @@ public:
   void EndOfStream(const Optional<MediaSourceEndOfStreamError>& aError, ErrorResult& aRv);
 
   void SetLiveSeekableRange(double aStart, double aEnd, ErrorResult& aRv);
   void ClearLiveSeekableRange(ErrorResult& aRv);
 
   static bool IsTypeSupported(const GlobalObject&, const nsAString& aType);
 
   static bool Enabled(JSContext* cx, JSObject* aGlobal);
+
+  IMPL_EVENT_HANDLER(sourceopen);
+  IMPL_EVENT_HANDLER(sourceended);
+  IMPL_EVENT_HANDLER(sourceclosed);
+
   /** End WebIDL Methods. */
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaSource, DOMEventTargetHelper)
   NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOM_MEDIASOURCE_IMPLEMENTATION_IID)
 
   nsPIDOMWindowInner* GetParentObject() const;
 
--- a/dom/media/mediasource/SourceBuffer.h
+++ b/dom/media/mediasource/SourceBuffer.h
@@ -82,16 +82,23 @@ public:
 
   void AppendBuffer(const ArrayBuffer& aData, ErrorResult& aRv);
   void AppendBuffer(const ArrayBufferView& aData, ErrorResult& aRv);
 
   void Abort(ErrorResult& aRv);
   void AbortBufferAppend();
 
   void Remove(double aStart, double aEnd, ErrorResult& aRv);
+
+  IMPL_EVENT_HANDLER(updatestart);
+  IMPL_EVENT_HANDLER(update);
+  IMPL_EVENT_HANDLER(updateend);
+  IMPL_EVENT_HANDLER(error);
+  IMPL_EVENT_HANDLER(abort);
+
   /** End WebIDL Methods. */
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SourceBuffer, DOMEventTargetHelper)
 
   SourceBuffer(MediaSource* aMediaSource, const nsACString& aType);
 
   MediaSource* GetParentObject() const;
--- a/dom/media/mediasource/SourceBufferList.h
+++ b/dom/media/mediasource/SourceBufferList.h
@@ -30,16 +30,20 @@ class MediaSource;
 
 class SourceBufferList final : public DOMEventTargetHelper
 {
 public:
   /** WebIDL Methods. */
   SourceBuffer* IndexedGetter(uint32_t aIndex, bool& aFound);
 
   uint32_t Length();
+
+  IMPL_EVENT_HANDLER(addsourcebuffer);
+  IMPL_EVENT_HANDLER(removesourcebuffer);
+
   /** End WebIDL methods. */
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SourceBufferList,
                                            DOMEventTargetHelper)
 
   explicit SourceBufferList(MediaSource* aMediaSource);
 
--- a/dom/webidl/MediaSource.webidl
+++ b/dom/webidl/MediaSource.webidl
@@ -23,16 +23,19 @@ enum MediaSourceEndOfStreamError {
 
 [Constructor, Func="mozilla::dom::MediaSource::Enabled"]
 interface MediaSource : EventTarget {
   readonly attribute SourceBufferList sourceBuffers;
   readonly attribute SourceBufferList activeSourceBuffers;
   readonly attribute MediaSourceReadyState readyState;
   [SetterThrows]
   attribute unrestricted double duration;
+  attribute EventHandler onsourceopen;
+  attribute EventHandler onsourceended;
+  attribute EventHandler onsourceclosed;
   [NewObject, Throws]
   SourceBuffer addSourceBuffer(DOMString type);
   [Throws]
   void removeSourceBuffer(SourceBuffer sourceBuffer);
   [Throws]
   void endOfStream(optional MediaSourceEndOfStreamError error);
   [Throws]
   void setLiveSeekableRange(double start, double end);
--- a/dom/webidl/SourceBuffer.webidl
+++ b/dom/webidl/SourceBuffer.webidl
@@ -26,16 +26,21 @@ interface SourceBuffer : EventTarget {
   attribute double timestampOffset;
   //readonly attribute AudioTrackList audioTracks;
   //readonly attribute VideoTrackList videoTracks;
   //readonly attribute TextTrackList textTracks;
   [SetterThrows]
   attribute double appendWindowStart;
   [SetterThrows]
   attribute unrestricted double appendWindowEnd;
+  attribute EventHandler onupdatestart;
+  attribute EventHandler onupdate;
+  attribute EventHandler onupdateend;
+  attribute EventHandler onerror;
+  attribute EventHandler onabort;
   [Throws]
   void appendBuffer(ArrayBuffer data);
   [Throws]
   void appendBuffer(ArrayBufferView data);
   //[Throws]
   //void appendStream(Stream stream, [EnforceRange] optional unsigned long long maxSize);
   [Throws]
   void abort();
--- a/dom/webidl/SourceBufferList.webidl
+++ b/dom/webidl/SourceBufferList.webidl
@@ -8,10 +8,12 @@
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
 [Func="mozilla::dom::MediaSource::Enabled"]
 interface SourceBufferList : EventTarget {
   readonly attribute unsigned long length;
+  attribute EventHandler onaddsourcebuffer;
+  attribute EventHandler onremovesourcebuffer;
   getter SourceBuffer (unsigned long index);
 };