Bug 882718 - Implement GetCueListByTimeInterval() at TextTrackCueList object. r=rillian
☠☠ backed out by 21c996f83437 ☠ ☠
authorbechen <bechen@mozilla.com>
Wed, 25 May 2016 16:11:24 +0800
changeset 338706 f2bf27c13c370a06e62934d811cf6a42115c97c8
parent 338705 453431d7a2c8842d757e98dd566e81c5a9419dd1
child 338707 f6363fdbbf29df048f219c68e8dedf35cb6cd6f9
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrillian
bugs882718
milestone49.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 882718 - Implement GetCueListByTimeInterval() at TextTrackCueList object. r=rillian MozReview-Commit-ID: 1T3EEfG83ec
dom/media/TextTrackCueList.cpp
dom/media/TextTrackCueList.h
--- a/dom/media/TextTrackCueList.cpp
+++ b/dom/media/TextTrackCueList.cpp
@@ -120,10 +120,24 @@ TextTrackCueList::GetArray(nsTArray<RefP
 void
 TextTrackCueList::SetCuesInactive()
 {
   for(uint32_t i = 0; i < mList.Length(); ++i) {
     mList[i]->SetActive(false);
   }
 }
 
+already_AddRefed<TextTrackCueList>
+TextTrackCueList::GetCueListByTimeInterval(media::Interval<double>& aInterval)
+{
+  RefPtr<TextTrackCueList> output = new TextTrackCueList(mParent);
+  for (uint32_t i = 0; i < mList.Length(); ++i) {
+    TextTrackCue* cue = mList[i];
+    if (cue->StartTime() <= aInterval.mEnd &&
+        aInterval.mStart <= cue->EndTime()) {
+      output->AddCue(*cue);
+    }
+  }
+  return output.forget();
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/dom/media/TextTrackCueList.h
+++ b/dom/media/TextTrackCueList.h
@@ -7,16 +7,17 @@
 #ifndef mozilla_dom_TextTrackCueList_h
 #define mozilla_dom_TextTrackCueList_h
 
 #include "nsTArray.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 #include "mozilla/ErrorResult.h"
+#include "Intervals.h"
 
 namespace mozilla {
 namespace dom {
 
 class TextTrackCue;
 
 class TextTrackCueList final : public nsISupports
                              , public nsWrapperCache
@@ -51,16 +52,19 @@ public:
   void AddCue(TextTrackCue& aCue);
   void RemoveCue(TextTrackCue& aCue, ErrorResult& aRv);
   void RemoveCueAt(uint32_t aIndex);
   void RemoveAll();
   void GetArray(nsTArray<RefPtr<TextTrackCue> >& aCues);
 
   void SetCuesInactive();
 
+  already_AddRefed<TextTrackCueList>
+  GetCueListByTimeInterval(media::Interval<double>& aInterval);
+
 private:
   ~TextTrackCueList();
 
   nsCOMPtr<nsISupports> mParent;
 
   // A sorted list of TextTrackCues sorted by earliest start time. If the start
   // times are equal then it will be sorted by end time, earliest first.
   nsTArray< RefPtr<TextTrackCue> > mList;