Skip to content

Instantly share code, notes, and snippets.

@humphd
Created January 17, 2013 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save humphd/4555696 to your computer and use it in GitHub Desktop.
Save humphd/4555696 to your computer and use it in GitHub Desktop.
Patch update work so far (WIP). Based on mozilla-central git revision 1acf9935d4
diff --git a/configure.in b/configure.in
index 07cffe0..b07885c 100644
--- a/configure.in
+++ b/configure.in
@@ -4262,6 +4262,7 @@ MOZ_OMX_PLUGIN=
MOZ_VP8=
MOZ_VP8_ERROR_CONCEALMENT=
MOZ_VP8_ENCODER=
+MOZ_WEBVTT=1
VPX_AS=
VPX_ASFLAGS=
VPX_AS_DASH_C_FLAG=
@@ -8867,6 +8868,7 @@ AC_SUBST(MOZ_VP8_ERROR_CONCEALMENT)
AC_SUBST(MOZ_VP8_ENCODER)
AC_SUBST(MOZ_VP8)
AC_SUBST(MOZ_OGG)
+AC_SUBST(MOZ_WEBVTT)
AC_SUBST(VPX_AS)
AC_SUBST(VPX_ASFLAGS)
AC_SUBST(VPX_DASH_C_FLAG)
diff --git a/content/base/public/nsINode.h b/content/base/public/nsINode.h
index 9c221d2..daefa37 100644
--- a/content/base/public/nsINode.h
+++ b/content/base/public/nsINode.h
@@ -1492,7 +1492,10 @@ protected:
public:
// Optimized way to get classinfo.
- virtual nsXPCClassInfo* GetClassInfo() = 0;
+ virtual nsXPCClassInfo* GetClassInfo()
+ {
+ return nullptr;
+ }
// Makes nsINode object to keep aObject alive.
void BindObject(nsISupports* aObject);
diff --git a/content/html/content/public/nsHTMLMediaElement.h b/content/html/content/public/nsHTMLMediaElement.h
index 92da452..153e614 100644
--- a/content/html/content/public/nsHTMLMediaElement.h
+++ b/content/html/content/public/nsHTMLMediaElement.h
@@ -27,6 +27,9 @@
#include "DecoderTraits.h"
#include "MediaMetadataManager.h"
#include "AudioChannelAgent.h"
+//XXXhumph:
+//#include "nsTextTrack.h"
+#include "webvtt.h"
// Define to output information on decoding and painting framerate
/* #define DEBUG_FRAME_RATE 1 */
@@ -905,6 +908,13 @@ protected:
// An agent used to join audio channel service.
nsCOMPtr<nsIAudioChannelAgent> mAudioChannelAgent;
+
+ //XXXhumph: commented out in ralph's original patch
+ // Contains a list of our attached text track objects.
+ //nsTArray<nsCOMPtr<nsTextTrack>> mTextTracks;
+
+public:
+ webvtt_cue *mCues;
};
#endif
diff --git a/content/html/content/src/HTMLTrackElement.cpp b/content/html/content/src/HTMLTrackElement.cpp
new file mode 100644
index 0000000..02e915c
--- /dev/null
+++ b/content/html/content/src/HTMLTrackElement.cpp
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/dom/HTMLTrackElement.h"
+#include "mozilla/dom/HTMLTrackElementBinding.h"
+#include "mozilla/ErrorResult.h"
+#include "nsContentUtils.h"
+
+NS_IMPL_NS_NEW_HTML_ELEMENT(Track)
+//DOMCI_NODE_DATA(HTMLTrackElement, mozilla::dom::HTMLTrackElement)
+
+namespace mozilla {
+namespace dom {
+
+HTMLTrackElement::~HTMLTrackElement()
+{
+}
+
+NS_IMPL_ADDREF_INHERITED(HTMLTrackElement, Element)
+NS_IMPL_RELEASE_INHERITED(HTMLTrackElement, Element)
+
+// QueryInterface implementation for HTMLTrackElement
+NS_INTERFACE_TABLE_HEAD(HTMLTrackElement)
+ NS_HTML_CONTENT_INTERFACE_TABLE1(HTMLTrackElement,
+ nsIDOMHTMLElement)
+ NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(HTMLTrackElement,
+ nsGenericHTMLElement)
+NS_HTML_CONTENT_INTERFACE_MAP_END
+
+NS_IMPL_ELEMENT_CLONE(HTMLTrackElement)
+
+JSObject*
+HTMLTrackElement::WrapNode(JSContext* cx, JSObject* scope, bool* triedToWrap)
+{
+ return HTMLTrackElementBinding::Wrap(cx, scope, this, triedToWrap);
+}
+
+// attribute DOMString kind
+NS_IMETHODIMP
+HTMLTrackElement::GetKind(nsAString& aKind)
+{
+ nsString kind;
+ GetKind(kind);
+ aKind = kind;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+HTMLTrackElement::SetKind(const nsAString& aKind)
+{
+ mozilla::ErrorResult rv;
+ SetKind(aKind, rv);
+ return rv.ErrorCode();
+}
+
+// attribute DOMString src
+NS_IMETHODIMP
+HTMLTrackElement::GetSrc(nsAString& aSrc)
+{
+ nsString src;
+ GetKind(src);
+ aSrc = src;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+HTMLTrackElement::SetSrc(const nsAString& aSrc)
+{
+ mozilla::ErrorResult rv;
+ SetSrc(aSrc, rv);
+ return rv.ErrorCode();
+}
+
+// attribute DOMString srclang
+NS_IMETHODIMP
+HTMLTrackElement::GetSrclang(nsAString& aSrclang)
+{
+ nsString srclang;
+ GetKind(srclang);
+ aSrclang = srclang;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+HTMLTrackElement::SetSrclang(const nsAString& aSrclang)
+{
+ mozilla::ErrorResult rv;
+ SetSrclang(aSrclang, rv);
+ return rv.ErrorCode();
+}
+
+// attribute DOMString label
+NS_IMETHODIMP
+HTMLTrackElement::GetLabel(nsAString& aLabel)
+{
+ nsString label;
+ GetKind(label);
+ aLabel = label;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+HTMLTrackElement::SetLabel(const nsAString& aLabel)
+{
+ mozilla::ErrorResult rv;
+ SetLabel(aLabel, rv);
+ return rv.ErrorCode();
+}
+
+} // namespace dom
+} // namespace mozilla
diff --git a/content/html/content/src/HTMLTrackElement.h b/content/html/content/src/HTMLTrackElement.h
new file mode 100644
index 0000000..df5d8ea
--- /dev/null
+++ b/content/html/content/src/HTMLTrackElement.h
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_dom_HTMLTrackElement_h
+#define mozilla_dom_HTMLTrackElement_h
+
+#include "nsIDOMHTMLElement.h"
+#include "nsIDOMEventTarget.h"
+#include "nsGenericHTMLElement.h"
+#include "nsGkAtoms.h"
+//#include "nsStyleConsts.h"
+//#include "nsIAtom.h"
+//#include "nsRuleData.h"
+
+namespace mozilla {
+namespace dom {
+
+class HTMLTrackElement : public nsGenericHTMLElement,
+ public nsIDOMHTMLElement
+{
+public:
+ HTMLTrackElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+ : nsGenericHTMLElement(aNodeInfo)
+ {
+ SetIsDOMBinding();
+ }
+ virtual ~HTMLTrackElement();
+
+ // nsISupports
+ NS_DECL_ISUPPORTS_INHERITED
+
+ // nsIDOMNode
+ NS_FORWARD_NSIDOMNODE_TO_NSINODE
+
+ // nsIDOMElement
+ NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
+
+ // nsIDOMHTMLElement
+ NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+
+ // nsIDOMHTMLTrackElement
+ NS_IMETHOD GetKind(nsAString& aKind);
+ NS_IMETHOD SetKind(const nsAString& aKind);
+ NS_IMETHOD GetSrc(nsAString& aSrc);
+ NS_IMETHOD SetSrc(const nsAString& aSrc);
+ NS_IMETHOD GetSrclang(nsAString& aSrclang);
+ NS_IMETHOD SetSrclang(const nsAString& aSrclang);
+ NS_IMETHOD GetLabel(nsAString& aLabel);
+ NS_IMETHOD SetLabel(const nsAString& aLabel);
+
+ // HTMLTrackElement WebIDL
+ void GetKind(nsString& aKind)
+ {
+ GetHTMLAttr(nsGkAtoms::kind, aKind);
+ }
+ void SetKind(const nsAString& aKind, mozilla::ErrorResult& aError)
+ {
+ SetHTMLAttr(nsGkAtoms::kind, aKind, aError);
+ }
+
+ void GetSrc(nsString& aSrc)
+ {
+ GetHTMLAttr(nsGkAtoms::src, aSrc);
+ }
+ void SetSrc(const nsAString& aSrc, mozilla::ErrorResult& aError)
+ {
+ SetHTMLAttr(nsGkAtoms::src, aSrc, aError);
+ }
+
+ void GetSrclang(nsString& aSrclang)
+ {
+ GetHTMLAttr(nsGkAtoms::srclang, aSrclang);
+ }
+ void SetSrclang(const nsAString& aSrclang, mozilla::ErrorResult& aError)
+ {
+ SetHTMLAttr(nsGkAtoms::srclang, aSrclang, aError);
+ }
+
+ void GetLabel(nsString& aLabel)
+ {
+ GetHTMLAttr(nsGkAtoms::label, aLabel);
+ }
+ void SetLabel(const nsAString& aLabel, mozilla::ErrorResult& aError)
+ {
+ SetHTMLAttr(nsGkAtoms::label, aLabel, aError);
+ }
+
+ virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
+// virtual nsXPCClassInfo* GetClassInfo();
+ virtual nsIDOMNode* AsDOMNode() { return this; }
+
+protected:
+ virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
+ bool *aTriedToWrap) MOZ_OVERRIDE;
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_HTMLTrackElement_h
diff --git a/content/html/content/src/Makefile.in b/content/html/content/src/Makefile.in
index 7e847b7..aa37130 100644
--- a/content/html/content/src/Makefile.in
+++ b/content/html/content/src/Makefile.in
@@ -131,8 +131,13 @@ CPPSRCS += \
nsMediaFragmentURIParser.cpp \
nsHTMLSourceElement.cpp \
nsTimeRanges.cpp \
+ HTMLTrackElement.cpp \
nsHTMLVideoElement.cpp \
$(NULL)
+
+EXPORTS_mozilla/dom += \
+ HTMLTrackElement.h \
+ $(NULL)
endif
# we don't want the shared lib, but we want to force the creation of a static lib.
diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h
index 9661f9c..0ebe5e4 100644
--- a/content/html/content/src/nsGenericHTMLElement.h
+++ b/content/html/content/src/nsGenericHTMLElement.h
@@ -1919,6 +1919,9 @@ NS_DECLARE_NS_NEW_HTML_ELEMENT(TextArea)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Tfoot)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Thead)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Title)
+#if defined(MOZ_MEDIA)
+NS_DECLARE_NS_NEW_HTML_ELEMENT(Track)
+#endif
NS_DECLARE_NS_NEW_HTML_ELEMENT(UList)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Unknown)
#if defined(MOZ_MEDIA)
diff --git a/content/html/content/src/nsHTMLMediaElement.cpp b/content/html/content/src/nsHTMLMediaElement.cpp
index 4ccd10a..292d551 100644
--- a/content/html/content/src/nsHTMLMediaElement.cpp
+++ b/content/html/content/src/nsHTMLMediaElement.cpp
@@ -105,6 +105,9 @@
#ifdef MOZ_WMF
#include "WMFDecoder.h"
#endif
+#ifdef MOZ_WEBVTT
+#include "nsWebVTTDecoder.h"
+#endif
#ifdef PR_LOGGING
static PRLogModuleInfo* gMediaElementLog;
@@ -3411,6 +3414,25 @@ void nsHTMLMediaElement::FireTimeUpdate(bool aPeriodic)
mFragmentStart = -1.0;
mDecoder->SetFragmentEndTime(mFragmentEnd);
}
+
+ // HACK: update current text track cue from here
+ nsIFrame* frame = GetPrimaryFrame();
+ if (frame && frame->GetType() == nsGkAtoms::HTMLVideoFrame) {
+ nsIContent *overlay = static_cast<nsVideoFrame*>(frame)->GetCaptionOverlay();
+ long mstime = time * 1e3;
+ webvtt_cue *cue = mCues;
+ while (cue) {
+ if (cue->start < mstime && cue->end > mstime)
+ break;
+ cue = cue->next;
+ }
+ const char *text = cue ? cue->text : "";
+ nsCOMPtr<nsIDOMHTMLElement> div = do_QueryInterface(overlay);
+ char timestring[1024] = "mollis non commodo et";
+ snprintf(timestring, 1024, "<p>Cue update %lf</p>\n"
+ "<p>%s</p>\n", time, text);
+ div->SetInnerHTML(NS_ConvertUTF8toUTF16(timestring));
+ }
}
void nsHTMLMediaElement::GetCurrentSpec(nsCString& aString)
diff --git a/content/media/Makefile.in b/content/media/Makefile.in
index 4b0525a..2a2940e 100644
--- a/content/media/Makefile.in
+++ b/content/media/Makefile.in
@@ -88,6 +88,10 @@ ifdef MOZ_WEBM
PARALLEL_DIRS += webm
endif
+ifdef MOZ_WEBVTT
+PARALLEL_DIRS += webvtt
+endif
+
ifdef MOZ_GSTREAMER
PARALLEL_DIRS += gstreamer
endif
diff --git a/content/media/MediaDecoder.h b/content/media/MediaDecoder.h
index 41c14b1..db57a7e 100644
--- a/content/media/MediaDecoder.h
+++ b/content/media/MediaDecoder.h
@@ -4,7 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
-Each video element based on MediaDecoder has a state machine to manage
+Each media element based on MediaDecoder has a state machine to manage
its play state and keep the current frame up to date. All state machines
share time in a single shared thread. Each decoder also has one thread
dedicated to decoding audio and video data. This thread is shutdown when
@@ -19,7 +19,7 @@ decoding operations and A/V sync.
Each state machine runs on the shared state machine thread. Every time some
action is required for a state machine, it is scheduled to run on the shared
-the state machine thread. The state machine runs one "cycle" on the state
+state machine thread. The state machine runs one "cycle" on the state
machine thread, and then returns. If necessary, it will schedule itself to
run again in future. While running this cycle, it must not block the
thread, as other state machines' events may need to run. State shared
@@ -138,8 +138,8 @@ player SHUTDOWN decoder SHUTDOWN
The general sequence of events is:
-1) The video element calls Load on MediaDecoder. This creates the
- state machine and starts the channel for downloading the
+1) The media element calls Load on nsMediaDecoder. This creates
+ the state machine and starts the channel for downloading the
file. It instantiates and schedules the MediaDecoderStateMachine. The
high level LOADING state is entered, which results in the decode
thread being created and starting to decode metadata. These are
diff --git a/content/media/webvtt/Makefile.in b/content/media/webvtt/Makefile.in
new file mode 100644
index 0000000..452cfed
--- /dev/null
+++ b/content/media/webvtt/Makefile.in
@@ -0,0 +1,65 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Mozilla code.
+#
+# The Initial Developer of the Original Code is the Mozilla Foundation.
+# Portions created by the Initial Developer are Copyright (C) 2011
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Ralph Giles <giles@mozilla.com>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# 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 *****
+
+DEPTH = ../../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = content
+LIBRARY_NAME = gkconnwebvtt_s
+LIBXUL_LIBRARY = 1
+
+FORCE_STATIC_LIB = 1
+
+EXPORTS += \
+ nsWebVTTDecoder.h \
+ nsWebVTTReader.h \
+ $(NULL)
+
+CPPSRCS = \
+ nsWebVTTDecoder.cpp \
+ nsWebVTTReader.h \
+ $(NULL)
+
+include $(topsrcdir)/config/rules.mk
+
+INCLUDES += \
+ -I$(srcdir)/../../base/src \
+ -I$(srcdir)/../../html/content/src \
+ $(NULL)
diff --git a/content/media/webvtt/nsWebVTTDecoder.cpp b/content/media/webvtt/nsWebVTTDecoder.cpp
new file mode 100644
index 0000000..2b9e046
--- /dev/null
+++ b/content/media/webvtt/nsWebVTTDecoder.cpp
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla code.
+ *
+ * The Initial Developer of the Original Code is the Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Ralph Giles <giles@mozilla.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * 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 "MediaDecoderStateMachine.h"
+#include "nsWebVTTDecoder.h"
+#include "nsWebVTTReader.h"
+
+mozilla::MediaDecoderStateMachine*
+nsWebVTTDecoder::CreateStateMachine()
+{
+ return new mozilla::MediaDecoderStateMachine(this, new nsWebVTTReader(this));
+}
diff --git a/content/media/webvtt/nsWebVTTDecoder.h b/content/media/webvtt/nsWebVTTDecoder.h
new file mode 100644
index 0000000..7b917aa
--- /dev/null
+++ b/content/media/webvtt/nsWebVTTDecoder.h
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla code.
+ *
+ * The Initial Developer of the Original Code is the Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Ralph Giles <giles@mozilla.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * 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 ***** */
+#if !defined(nsWebVTTDecoder_h_)
+#define nsWebVTTDecoder_h_
+
+#include "MediaDecoder.h"
+#include "MediaDecoderStateMachine.h"
+
+class nsWebVTTDecoder : public mozilla::MediaDecoder
+{
+public:
+ virtual mozilla::MediaDecoder* Clone() { return new nsWebVTTDecoder(); }
+ virtual mozilla::MediaDecoderStateMachine* CreateStateMachine();
+};
+
+#endif
diff --git a/content/media/webvtt/nsWebVTTReader.cpp b/content/media/webvtt/nsWebVTTReader.cpp
new file mode 100644
index 0000000..d657dd0
--- /dev/null
+++ b/content/media/webvtt/nsWebVTTReader.cpp
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla code.
+ *
+ * The Initial Developer of the Original Code is the Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Ralph Giles <giles@mozilla.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * 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 ***** */
+#if !defined(nsWebVTTReader_h_)
+#define nsWebVTTReader_h_
+
+#include "nsBuiltinDecoderReader.h"
+#include "nsWebVTTReader.h"
+
+#include "webvtt/webvtt.h"
+
+nsWebVTTReader::nsWebVTTReader(nsBuildinDecoder* aDecoder)
+ : nsBuiltinDecoderReader(aDecoder)
+{
+ MOZ_COUNT_CTOR(nsWebVTTReader);
+}
+
+nsWebVTTReader::~nsWebVTTReader()
+{
+ MOZ_COUNT_DTOR(nsWebMReader);
+}
+
+nsresult
+nsWebVTTReader::ReadMetadata(mozilla::VideoInfo* aInfo,
+ mozilla::MetadataTags** aTags)
+{
+ // TODO:
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+#endif /* nsWebVTTReader_h_ */
diff --git a/content/media/webvtt/nsWebVTTReader.h b/content/media/webvtt/nsWebVTTReader.h
new file mode 100644
index 0000000..fd24add
--- /dev/null
+++ b/content/media/webvtt/nsWebVTTReader.h
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla code.
+ *
+ * The Initial Developer of the Original Code is the Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Ralph Giles <giles@mozilla.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * 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 ***** */
+#if !defined(nsWebVTTReader_h_)
+#define nsWebVTTReader_h_
+
+#include "MediaDecoderReader.h"
+#include "MediaDecoder.h"
+
+class nsWebVTTReader : public mozilla::MediaDecoderReader
+{
+public:
+ nsWebVTTReader(mozilla::MediaDecoder* aDecoder);
+ ~nsWebVTTReader();
+
+ virtual nsresult Init(mozilla::MediaDecoderReader* aCloneDonor);
+ virtual nsresult ResetDecode();
+ virtual bool DecodeAudioData();
+ virtual bool DecodeVideoFrame(bool &aKeyframeSkip, PRInt64 aTimeThreshold);
+
+ virtual bool HasAudio()
+ {
+ NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
+ return false;
+ }
+
+ virtual bool HasVideo()
+ {
+ NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
+ return false;
+ }
+
+ virtual nsresult ReadMetadata(mozilla::VideoInfo* aInfo, mozilla::MetadataTags** aTags);
+ virtual nsresult Seek(PRInt64 aTime, PRInt64 aStartTime, PRInt64 aEndTime, PRInt64 aCurrentTime);
+ virtual nsresult GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime);
+};
+
+#endif /* nsWebVTTReader_h_ */
diff --git a/dom/media/Makefile.in b/dom/media/Makefile.in
index 3d16220..2ea3261 100644
--- a/dom/media/Makefile.in
+++ b/dom/media/Makefile.in
@@ -33,15 +33,24 @@ XPIDLSRCS = \
nsIMediaManager.idl \
$(NULL)
-EXPORTS_NAMESPACE = mozilla
+EXPORTS_NAMESPACES = \
+ mozilla \
+ mozilla/dom \
+ $(NULL)
EXPORTS_mozilla = \
MediaManager.h \
$(NULL)
+EXPORTS_mozilla/dom = \
+ TextTrack.h \
+ $(NULL)
+
CPPSRCS = \
MediaManager.cpp \
$(NULL)
+#XXXhumph:
+# TextTrack.cpp \
ifdef MOZ_WEBRTC
LOCAL_INCLUDES += \
diff --git a/dom/media/TextTrack.cpp b/dom/media/TextTrack.cpp
new file mode 100644
index 0000000..33d295f
--- /dev/null
+++ b/dom/media/TextTrack.cpp
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 et tw=78: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/dom/TextTrack.h"
+
+//#include "nsDOMClassInfoID.h"
+//#include "nsContentUtils.h"
+#include "mozilla/dom/TextTrackBinding.h"
+
+namespace mozilla {
+namespace dom {
+
+NS_IMPL_CYCLE_COLLECTING_ADDREF(TextTrack)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(TextTrack)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TextTrack)
+ NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_MAP_END
+
+NS_IMPL_CYCLE_COLLECTION_CLASS(TextTrack)
+
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(TextTrack)
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+
+} // namespace dom
+} // namespace mozilla
diff --git a/dom/media/TextTrack.h b/dom/media/TextTrack.h
new file mode 100644
index 0000000..542825c
--- /dev/null
+++ b/dom/media/TextTrack.h
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 et tw=78: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_dom_TextTrack_h
+#define mozilla_dom_TextTrack_h
+
+#include "nsCycleCollectionParticipant.h"
+#include "nsTraceRefcnt.h"
+
+namespace mozilla {
+namespace dom {
+
+class TextTrack MOZ_FINAL : public nsISupports
+{
+public:
+ TextTrack()
+ {
+ MOZ_COUNT_CTOR(TextTrack);
+ }
+
+ ~TextTrack()
+ {
+ MOZ_COUNT_DTOR(TextTrack);
+ }
+
+ NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+ NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TextTrack)
+
+// XXXhumph: do rest of decl for this...
+
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_TextTrack_h
diff --git a/dom/webidl/HTMLTrackElement.webidl b/dom/webidl/HTMLTrackElement.webidl
new file mode 100644
index 0000000..ab806b1
--- /dev/null
+++ b/dom/webidl/HTMLTrackElement.webidl
@@ -0,0 +1,27 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * The origin of this IDL file is
+ * http://www.whatwg.org/specs/web-apps/current-work/#the-track-element
+ */
+
+interface HTMLTrackElement : HTMLElement {
+ attribute DOMString kind;
+ attribute DOMString src;
+ attribute DOMString srclang;
+ attribute DOMString label;
+// TODOhumph
+// attribute boolean default;
+
+ const unsigned short NONE = 0;
+ const unsigned short LOADING = 1;
+ const unsigned short LOADED = 2;
+ const unsigned short ERROR = 3;
+// TODOhumph
+// readonly attribute unsigned short readyState;
+
+// TODOhumph
+// readonly attribute TextTrack track;
+};
diff --git a/dom/webidl/TextTrack.webidl b/dom/webidl/TextTrack.webidl
new file mode 100644
index 0000000..410c994
--- /dev/null
+++ b/dom/webidl/TextTrack.webidl
@@ -0,0 +1,27 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * The origin of this IDL file is
+ * http://www.whatwg.org/specs/web-apps/current-work/#texttrack
+ */
+
+enum TextTrackMode { "disabled", "hidden", "showing" };
+
+interface TextTrack : EventTarget {
+ readonly attribute DOMString kind;
+ readonly attribute DOMString label;
+ readonly attribute DOMString language;
+ readonly attribute DOMString inBandMetadataTrackDispatchType;
+
+ attribute TextTrackMode mode;
+
+ readonly attribute TextTrackCueList? cues;
+ readonly attribute TextTrackCueList? activeCues;
+
+ void addCue(TextTrackCue cue);
+ void removeCue(TextTrackCue cue);
+
+ attribute EventHandler oncuechange;
+};
diff --git a/dom/webidl/TextTrackCue.webidl b/dom/webidl/TextTrackCue.webidl
new file mode 100644
index 0000000..3666f72
--- /dev/null
+++ b/dom/webidl/TextTrackCue.webidl
@@ -0,0 +1,32 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * The origin of this IDL file is
+ * http://www.whatwg.org/specs/web-apps/current-work/#texttrackcue
+ */
+
+enum AutoKeyword { "auto" };
+
+[Constructor(double startTime, double endTime, DOMString text)]
+interface TextTrackCue : EventTarget {
+ readonly attribute TextTrack? track;
+
+ attribute DOMString id;
+ attribute double startTime;
+ attribute double endTime;
+ attribute boolean pauseOnExit;
+ attribute DOMString vertical;
+ attribute boolean snapToLines;
+// XXXhumph: https://www.w3.org/Bugs/Public/show_bug.cgi?id=20651
+// attribute (long or AutoKeyword) line;
+ attribute long position;
+ attribute long size;
+ attribute DOMString align;
+ attribute DOMString text;
+ DocumentFragment getCueAsHTML();
+
+ attribute EventHandler onenter;
+ attribute EventHandler onexit;
+};
diff --git a/dom/webidl/TextTrackCueList.webidl b/dom/webidl/TextTrackCueList.webidl
new file mode 100644
index 0000000..7ab31ce
--- /dev/null
+++ b/dom/webidl/TextTrackCueList.webidl
@@ -0,0 +1,15 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * The origin of this IDL file is
+ * http://www.whatwg.org/specs/web-apps/current-work/#texttrackcuelist
+ */
+
+interface TextTrackCueList {
+ readonly attribute unsigned long length;
+ getter TextTrackCue (unsigned long index);
+ TextTrackCue? getCueById(DOMString id);
+};
+
diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk
index 4e458dc..d8c1f58 100644
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -191,6 +191,15 @@ webidl_files += \
$(NULL)
endif
+ifdef MOZ_WEBVTT
+webidl_files += \
+ HTMLTrackElement.webidl \
+ TextTrack.webidl \
+ TextTrackCue.webidl \
+ TextTrackCueList.webidl \
+ $(NULL)
+endif
+
ifdef ENABLE_TESTS
test_webidl_files := \
TestCodeGen.webidl \
diff --git a/editor/libeditor/html/nsHTMLEditUtils.cpp b/editor/libeditor/html/nsHTMLEditUtils.cpp
index b3c513b..9da59af 100644
--- a/editor/libeditor/html/nsHTMLEditUtils.cpp
+++ b/editor/libeditor/html/nsHTMLEditUtils.cpp
@@ -751,6 +751,9 @@ static const nsElementInfo kElements[eHTMLTag_userdefined] = {
ELEM(thead, true, false, GROUP_NONE, GROUP_TBODY_CONTENT),
ELEM(title, true, false, GROUP_HEAD_CONTENT, GROUP_LEAF),
ELEM(tr, true, false, GROUP_TBODY_CONTENT, GROUP_TR_CONTENT),
+#if defined(MOZ_MEDIA)
+ ELEM(track, false, false, GROUP_NONE, GROUP_NONE),
+#endif
ELEM(tt, true, true, GROUP_FONTSTYLE, GROUP_INLINE_ELEMENT),
ELEM(u, true, true, GROUP_FONTSTYLE, GROUP_INLINE_ELEMENT),
// XXX Can contain self and ol because editor does sublists illegally.
diff --git a/js/xpconnect/src/xpcObjectHelper.h b/js/xpconnect/src/xpcObjectHelper.h
index c7a4d99..cb117e0 100644
--- a/js/xpconnect/src/xpcObjectHelper.h
+++ b/js/xpconnect/src/xpcObjectHelper.h
@@ -74,8 +74,10 @@ public:
nsXPCClassInfo *GetXPCClassInfo()
{
if (!mXPCClassInfo) {
- if (mIsNode)
- mXPCClassInfo = static_cast<nsINode*>(GetCanonical())->GetClassInfo();
+ nsXPCClassInfo *xpcClassInfo;
+ if (mIsNode &&
+ (xpcClassInfo = static_cast<nsINode*>(GetCanonical())->GetClassInfo()))
+ mXPCClassInfo = xpcClassInfo;
else
CallQueryInterface(mObject, getter_AddRefs(mXPCClassInfo));
}
diff --git a/layout/build/Makefile.in b/layout/build/Makefile.in
index 8bb3707..07db367 100644
--- a/layout/build/Makefile.in
+++ b/layout/build/Makefile.in
@@ -209,6 +209,12 @@ SHARED_LIBRARY_LIBS += \
$(NULL)
endif
+ifdef MOZ_WEBVTT
+SHARED_LIBRARY_LIBS += \
+ $(DEPTH)/media/webvtt/$(LIB_PREFIX)webvtt.$(LIB_SUFFIX) \
+ $(NULL)
+endif
+
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
INCLUDES += \
-I$(srcdir)/../../base/src \
diff --git a/layout/generic/nsVideoFrame.cpp b/layout/generic/nsVideoFrame.cpp
index fd47f93..12be339 100644
--- a/layout/generic/nsVideoFrame.cpp
+++ b/layout/generic/nsVideoFrame.cpp
@@ -15,6 +15,7 @@
#include "nsHTMLVideoElement.h"
#include "nsIDOMHTMLVideoElement.h"
#include "nsIDOMHTMLImageElement.h"
+#include "nsIDOMHTMLElement.h"
#include "nsDisplayList.h"
#include "gfxContext.h"
#include "gfxImageSurface.h"
@@ -62,6 +63,8 @@ nsVideoFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
{
nsNodeInfoManager *nodeInfoManager = GetContent()->GetCurrentDoc()->NodeInfoManager();
nsCOMPtr<nsINodeInfo> nodeInfo;
+ Element *element;
+
if (HasVideoElement()) {
// Create an anonymous image element as a child to hold the poster
// image. We may not have a poster image now, but one could be added
@@ -71,7 +74,7 @@ nsVideoFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
kNameSpaceID_XHTML,
nsIDOMNode::ELEMENT_NODE);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
- Element* element = NS_NewHTMLImageElement(nodeInfo.forget());
+ element = NS_NewHTMLImageElement(nodeInfo.forget());
mPosterImage = element;
NS_ENSURE_TRUE(mPosterImage, NS_ERROR_OUT_OF_MEMORY);
@@ -111,6 +114,30 @@ nsVideoFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
if (!aElements.AppendElement(mVideoControls))
return NS_ERROR_OUT_OF_MEMORY;
+ // Set up the caption overlay div for showing any TextTrack data
+ nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::div,
+ nullptr,
+ kNameSpaceID_XHTML,
+ nsIDOMNode::ELEMENT_NODE);
+ NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
+ element = NS_NewHTMLDivElement(nodeInfo.forget());
+ mCaptionDiv = element;
+ NS_ENSURE_TRUE(mCaptionDiv, NS_ERROR_OUT_OF_MEMORY);
+ // hang a class name on the div for default styling
+ nsresult rv = mCaptionDiv->SetAttr(kNameSpaceID_None,
+ nsGkAtoms::_class,
+ NS_LITERAL_STRING("captionDiv"),
+ true);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ if (!aElements.AppendElement(mCaptionDiv))
+ return NS_ERROR_OUT_OF_MEMORY;
+
+ // add a test string so we can test the div
+ nsCOMPtr<nsIDOMHTMLElement> div = do_QueryInterface(mCaptionDiv);
+ rv = div->SetInnerHTML(NS_LITERAL_STRING("<p>Lorem ipsum dolor</p>"));
+ NS_ENSURE_SUCCESS(rv, rv);
+
return NS_OK;
}
@@ -120,11 +147,13 @@ nsVideoFrame::AppendAnonymousContentTo(nsBaseContentList& aElements,
{
aElements.MaybeAppendElement(mPosterImage);
aElements.MaybeAppendElement(mVideoControls);
+ aElements.MaybeAppendElement(mCaptionDiv);
}
void
nsVideoFrame::DestroyFrom(nsIFrame* aDestructRoot)
{
+ nsContentUtils::DestroyAnonymousContent(&mCaptionDiv);
nsContentUtils::DestroyAnonymousContent(&mVideoControls);
nsContentUtils::DestroyAnonymousContent(&mPosterImage);
nsContainerFrame::DestroyFrom(aDestructRoot);
@@ -245,7 +274,7 @@ nsVideoFrame::Reflow(nsPresContext* aPresContext,
for (nsIFrame *child = mFrames.FirstChild();
child;
child = child->GetNextSibling()) {
- if (child->GetType() == nsGkAtoms::imageFrame) {
+ if (child->GetContent() == mPosterImage) {
// Reflow the poster frame.
nsImageFrame* imageFrame = static_cast<nsImageFrame*>(child);
nsHTMLReflowMetrics kidDesiredSize;
@@ -285,7 +314,7 @@ nsVideoFrame::Reflow(nsPresContext* aPresContext,
posterTopLeft.x, posterTopLeft.y, 0, aStatus);
FinishReflowChild(imageFrame, aPresContext, &kidReflowState, kidDesiredSize,
posterTopLeft.x, posterTopLeft.y, 0);
- } else if (child->GetType() == nsGkAtoms::boxFrame) {
+ } else if (child->GetContent() == mVideoControls) {
// Reflow the video controls frame.
nsBoxLayoutState boxState(PresContext(), aReflowState.rendContext);
nsBoxFrame::LayoutChildAt(boxState,
@@ -294,6 +323,24 @@ nsVideoFrame::Reflow(nsPresContext* aPresContext,
mBorderPadding.top,
aReflowState.ComputedWidth(),
aReflowState.ComputedHeight()));
+ } else if (child->GetContent() == mCaptionDiv) {
+ // Reflow to caption div
+ nsHTMLReflowMetrics kidDesiredSize;
+ nsSize availableSize = nsSize(aReflowState.availableWidth,
+ aReflowState.availableHeight);
+ nsHTMLReflowState kidReflowState(aPresContext,
+ aReflowState,
+ child,
+ availableSize,
+ aMetrics.width,
+ aMetrics.height);
+ kidReflowState.SetComputedWidth(aReflowState.ComputedWidth());
+ kidReflowState.SetComputedHeight(aReflowState.ComputedHeight());
+ ReflowChild(child, aPresContext, kidDesiredSize, kidReflowState,
+ mBorderPadding.left, mBorderPadding.top, 0, aStatus);
+ FinishReflowChild(child, aPresContext,
+ &kidReflowState, kidDesiredSize,
+ mBorderPadding.left, mBorderPadding.top, 0);
}
}
aMetrics.SetOverflowAreasToDesiredBounds();
@@ -385,17 +432,13 @@ nsVideoFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
NS_ENSURE_SUCCESS(rv, rv);
}
- // Add child frames to display list. We expect up to two children, an image
- // frame for the poster, and the box frame for the video controls.
+ // Add child frames to display list. We expect various children,
+ // but only want to draw mPosterImage conditionally. Others we
+ // always add to the display list.
for (nsIFrame *child = mFrames.FirstChild();
child;
child = child->GetNextSibling()) {
- if (child->GetType() == nsGkAtoms::imageFrame && ShouldDisplayPoster()) {
- rv = child->BuildDisplayListForStackingContext(aBuilder,
- aDirtyRect - child->GetOffsetTo(this),
- &replacedContent);
- NS_ENSURE_SUCCESS(rv,rv);
- } else if (child->GetType() == nsGkAtoms::boxFrame) {
+ if (child->GetContent() != mPosterImage || ShouldDisplayPoster()) {
rv = child->BuildDisplayListForStackingContext(aBuilder,
aDirtyRect - child->GetOffsetTo(this),
&replacedContent);
diff --git a/layout/generic/nsVideoFrame.h b/layout/generic/nsVideoFrame.h
index 2a28075..9ff1e5d 100644
--- a/layout/generic/nsVideoFrame.h
+++ b/layout/generic/nsVideoFrame.h
@@ -89,6 +89,8 @@ public:
// a video frame, the poster will never be displayed again.
bool ShouldDisplayPoster();
+ nsIContent *GetCaptionOverlay() { return mCaptionDiv; }
+
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const;
#endif
@@ -123,6 +125,10 @@ protected:
// Anonymous child which is the image element of the poster frame.
nsCOMPtr<nsIContent> mPosterImage;
+
+ // Anonymous child which is the text track caption display div.
+ nsCOMPtr<nsIContent> mCaptionDiv;
+
};
#endif /* nsVideoFrame_h___ */
diff --git a/layout/style/html.css b/layout/style/html.css
index a988d68..7fbc008 100644
--- a/layout/style/html.css
+++ b/layout/style/html.css
@@ -723,6 +723,19 @@ audio:not([controls]) {
-moz-transform: translate(0) !important;
}
+video > div.captionDiv {
+ text-align: center;
+ font-weight: bold;
+ font-size: 24px;
+ pointer-events: none;
+}
+
+video > div.captionDiv p {
+ color: gold;
+ background-color: rgba(105,105,105,0.4);
+ pointer-events: auto;
+}
+
/* emulation of non-standard HTML <marquee> tag */
marquee {
width: -moz-available;
diff --git a/media/webvtt/Makefile.in b/media/webvtt/Makefile.in
new file mode 100644
index 0000000..5efbc4b
--- /dev/null
+++ b/media/webvtt/Makefile.in
@@ -0,0 +1,60 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Mozilla code.
+#
+# The Initial Developer of the Original Code is the Mozilla Foundation.
+# Portions created by the Initial Developer are Copyright (C) 2011
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Ralph Giles <giles@mozilla.com>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# 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 *****
+
+DEPTH = ../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = webvtt
+LIBRARY_NAME = webvtt
+FORCE_STATIC_LIB= 1
+
+EXPORTS = \
+ webvtt.h \
+ $(NULL)
+
+VPATH += \
+ $(srcdir)/src \
+ $(NULL)
+
+CSRCS = \
+ webvtt.c \
+ $(NULL)
+
+include $(topsrcdir)/config/rules.mk
diff --git a/media/webvtt/update.sh b/media/webvtt/update.sh
new file mode 100755
index 0000000..7ee6874
--- /dev/null
+++ b/media/webvtt/update.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+# script to update the webvtt library source
+
+URL=https://github.com/rillian/webvtt.git
+SRCDIR=src
+
+if [ -d ${SRCDIR}/.git ]; then
+ echo "Updating existing checkout..."
+ cd ${SRCDIR} && git pull
+else
+ echo "Downloading source from ${URL}"
+ git clone ${URL} ${SRCDIR}
+fi
diff --git a/parser/htmlparser/public/nsHTMLTagList.h b/parser/htmlparser/public/nsHTMLTagList.h
index 898336f..8d09b17 100644
--- a/parser/htmlparser/public/nsHTMLTagList.h
+++ b/parser/htmlparser/public/nsHTMLTagList.h
@@ -155,6 +155,9 @@ HTML_TAG(thead, TableSection)
HTML_TAG(title, Title)
HTML_TAG(tr, TableRow)
HTML_HTMLELEMENT_TAG(tt)
+#if defined(MOZ_MEDIA)
+HTML_TAG(track, Track)
+#endif
HTML_HTMLELEMENT_TAG(u)
HTML_TAG(ul, UList)
HTML_HTMLELEMENT_TAG(var)
diff --git a/parser/htmlparser/src/nsElementTable.cpp b/parser/htmlparser/src/nsElementTable.cpp
index d233ab5..7c6fd76 100644
--- a/parser/htmlparser/src/nsElementTable.cpp
+++ b/parser/htmlparser/src/nsElementTable.cpp
@@ -45,6 +45,7 @@ DECL_TAG_LIST(gTRParents,{eHTMLTag_tbody COMMA eHTMLTag_tfoot COMMA eHTMLTag_the
DECL_TAG_LIST(gTREndParents,{eHTMLTag_tbody COMMA eHTMLTag_tfoot COMMA eHTMLTag_thead COMMA eHTMLTag_table COMMA eHTMLTag_applet})
#ifdef MOZ_MEDIA
DECL_TAG_LIST(gSourceParents,{eHTMLTag_video COMMA eHTMLTag_audio})
+DECL_TAG_LIST(gTrackParents,{eHTMLTag_video COMMA eHTMLTag_audio})
#endif
//*********************************************************************************************
@@ -1219,6 +1220,17 @@ const nsHTMLElement gHTMLElements[] = {
/*special props, prop-range*/ 0, kDefaultPropRange,
/*special parents,kids*/ 0,0,
},
+#if defined(MOZ_MEDIA)
+ {
+ /*tag*/ eHTMLTag_track,
+ /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
+ /*rootnodes,endrootnodes*/ &gTrackParents,&gTrackParents,
+ /*autoclose starttags and endtags*/ &gPAutoClose, 0, 0,0,
+ /*parent,incl,exclgroups*/ kSpecial, kNone, kNone,
+ /*special props, prop-range*/ kNonContainer,kNoPropRange,
+ /*special parents,kids*/ &gTrackParents,0,
+ },
+#endif
{
/*tag*/ eHTMLTag_u,
/*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
diff --git a/parser/htmlparser/src/nsHTMLTags.cpp b/parser/htmlparser/src/nsHTMLTags.cpp
index 401d1d0..ecb16cf 100644
--- a/parser/htmlparser/src/nsHTMLTags.cpp
+++ b/parser/htmlparser/src/nsHTMLTags.cpp
@@ -256,6 +256,10 @@ static const PRUnichar sHTMLTagUnicodeName_title[] =
{'t', 'i', 't', 'l', 'e', '\0'};
static const PRUnichar sHTMLTagUnicodeName_tr[] =
{'t', 'r', '\0'};
+#if defined(MOZ_MEDIA)
+static const PRUnichar sHTMLTagUnicodeName_track[] =
+ {'t', 'r', 'a', 'c', 'k', '\0'};
+#endif
static const PRUnichar sHTMLTagUnicodeName_tt[] =
{'t', 't', '\0'};
static const PRUnichar sHTMLTagUnicodeName_u[] =
diff --git a/toolkit/toolkit-tiers.mk b/toolkit/toolkit-tiers.mk
index 69401f4..d89a955 100644
--- a/toolkit/toolkit-tiers.mk
+++ b/toolkit/toolkit-tiers.mk
@@ -123,6 +123,10 @@ tier_platform_dirs += \
$(NULL)
endif
+ifdef MOZ_WEBVTT
+tier_platform_dirs += media/webvtt
+endif
+
ifdef MOZ_SYDNEYAUDIO
tier_platform_dirs += \
media/libsydneyaudio \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment