Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: Source/core/html/track/CueTimeline.h

Issue 913133003: Move text track active list management to CueTimeline (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rename to CueTimeline. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CueTimeline_h
6 #define CueTimeline_h
7
8 #include "core/html/track/TextTrackCue.h"
9 #include "core/html/track/vtt/VTTCue.h"
10 #include "platform/PODIntervalTree.h"
11 #include "platform/heap/Handle.h"
12 #include "wtf/Vector.h"
13
14 namespace blink {
15
16 class HTMLMediaElement;
17 class TextTrackCueList;
18
19 typedef PODIntervalTree<double, TextTrackCue*> CueIntervalTree;
20 typedef CueIntervalTree::IntervalType CueInterval;
21 typedef Vector<CueInterval> CueList;
22
23 // This class manages the timeline and rendering updates of cues associated
24 // with TextTracks. Owned by a HTMLMediaElement.
25 class CueTimeline : public NoBaseWillBeGarbageCollectedFinalized<CueTimeline> {
26 public:
27 CueTimeline(HTMLMediaElement&);
28
29 void addCues(TextTrack*, const TextTrackCueList*);
30 void addCue(TextTrack*, PassRefPtrWillBeRawPtr<TextTrackCue>);
31 void removeCues(TextTrack*, const TextTrackCueList*);
32 void removeCue(TextTrack*, PassRefPtrWillBeRawPtr<TextTrackCue>);
33
34 void updateActiveCues(double);
35
36 bool ignoreUpdateRequests() const { return m_ignoreUpdate > 0; }
37 void beginIgnoringUpdateRequests();
38 void endIgnoringUpdateRequests();
39
40 CueList currentlyActiveCues() const { return m_currentlyActiveCues; }
41
42 DECLARE_TRACE();
43
44 private:
45 HTMLMediaElement& mediaElement() const { return *m_mediaElement; }
46
47 RawPtrWillBeMember<HTMLMediaElement> m_mediaElement;
48
49 CueIntervalTree m_cueTree;
50
51 CueList m_currentlyActiveCues;
52 double m_lastUpdateTime;
53
54 int m_ignoreUpdate;
55 };
56
57 class TrackDisplayUpdateScope {
58 STACK_ALLOCATED();
59 public:
60 TrackDisplayUpdateScope(CueTimeline& cueTimeline)
61 {
62 m_cueTimeline = &cueTimeline;
63 m_cueTimeline->beginIgnoringUpdateRequests();
64 }
65 ~TrackDisplayUpdateScope()
66 {
67 ASSERT(m_cueTimeline);
68 m_cueTimeline->endIgnoringUpdateRequests();
69 }
70
71 private:
72 RawPtrWillBeMember<CueTimeline> m_cueTimeline;
73 };
74
75 #ifndef NDEBUG
76 // Template specializations required by PodIntervalTree in debug mode.
77 template <>
78 struct ValueToString<double> {
79 static String string(const double value)
80 {
81 return String::number(value);
82 }
83 };
84
85 template <>
86 struct ValueToString<TextTrackCue*> {
87 static String string(TextTrackCue* const& cue)
88 {
89 return cue->toString();
90 }
91 };
92 #endif
93
94 } // namespace blink
95
96 #endif // CueTimeline_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698