From b17bace20c1a6cf0e868eb6da3fc3a7a4f0bb2de Mon Sep 17 00:00:00 2001 From: Rick Eyre Date: Wed, 18 Sep 2013 12:46:51 -0400 Subject: [PATCH] Bug 917945 - Part 3: Add VTTRegions to its TextTrack upon receiving them. r=rillian, r=bz --- content/media/WebVTTListener.cpp | 14 ++++- content/media/test/Makefile.in | 2 + content/media/test/region.vtt | 5 ++ content/media/test/test_texttrackregion.html | 66 ++++++++++++++++++++ 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 content/media/test/region.vtt create mode 100644 content/media/test/test_texttrackregion.html diff --git a/content/media/WebVTTListener.cpp b/content/media/WebVTTListener.cpp index 4343c9d36678..b942ff0419e1 100644 --- a/content/media/WebVTTListener.cpp +++ b/content/media/WebVTTListener.cpp @@ -5,6 +5,8 @@ #include "WebVTTListener.h" #include "mozilla/dom/TextTrackCue.h" +#include "mozilla/dom/TextTrackRegion.h" +#include "mozilla/dom/VTTRegionBinding.h" #include "mozilla/dom/HTMLTrackElement.h" #include "nsIInputStream.h" #include "nsIWebVTTParserWrapper.h" @@ -172,7 +174,17 @@ WebVTTListener::OnCue(const JS::Value &aCue, JSContext* aCx) NS_IMETHODIMP WebVTTListener::OnRegion(const JS::Value &aRegion, JSContext* aCx) { - // TODO: Implement VTTRegions see bug 897504 + if (!aRegion.isObject()) { + return NS_ERROR_FAILURE; + } + + TextTrackRegion* region; + nsresult rv = UNWRAP_OBJECT(VTTRegion, aCx, &aRegion.toObject(), + region); + NS_ENSURE_SUCCESS(rv, rv); + + mElement->mTrack->AddRegion(*region); + return NS_OK; } diff --git a/content/media/test/Makefile.in b/content/media/test/Makefile.in index 3d6b6ff79656..8a5e64b31527 100644 --- a/content/media/test/Makefile.in +++ b/content/media/test/Makefile.in @@ -140,6 +140,7 @@ MOCHITEST_FILES = \ $(filter disabled-for-intermittent-failures--bug-608634, test_error_in_video_document.html) \ test_texttrack.html \ test_texttrackcue.html \ + test_texttrackregion.html \ test_timeupdate_small_files.html \ test_unseekable.html \ test_VideoPlaybackQuality.html \ @@ -272,6 +273,7 @@ MOCHITEST_FILES += \ notags.mp3 \ id3tags.mp3 \ basic.vtt \ + region.vtt \ long.vtt \ $(NULL) diff --git a/content/media/test/region.vtt b/content/media/test/region.vtt new file mode 100644 index 000000000000..883341fc6882 --- /dev/null +++ b/content/media/test/region.vtt @@ -0,0 +1,5 @@ +WEBVTT +Region: id=fred width=62% lines=5 regionanchor=4%,78% viewportanchor=10%,90% scroll=up + +00:01.000 --> 00:02.000 region:fred +Test here. diff --git a/content/media/test/test_texttrackregion.html b/content/media/test/test_texttrackregion.html new file mode 100644 index 000000000000..b34e2c9864e3 --- /dev/null +++ b/content/media/test/test_texttrackregion.html @@ -0,0 +1,66 @@ + + + + + + Test for Bug 917945 - VTTRegion + + + + + +

+
+
+
+
+
+ +