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

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

Issue 92783002: Move code that applies to audio and video tracks into TrackBase. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@tmp
Patch Set: Rebased again Created 6 years, 11 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
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/html/track/TextTrack.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 10 matching lines...) Expand all
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #ifndef TextTrack_h 27 #ifndef TextTrack_h
28 #define TextTrack_h 28 #define TextTrack_h
29 29
30 #include "bindings/v8/ScriptWrappable.h" 30 #include "bindings/v8/ScriptWrappable.h"
31 #include "core/events/EventTarget.h"
31 #include "core/html/track/TrackBase.h" 32 #include "core/html/track/TrackBase.h"
32 #include "wtf/text/WTFString.h" 33 #include "wtf/text/WTFString.h"
33 34
34 namespace WebCore { 35 namespace WebCore {
35 36
36 class Document; 37 class Document;
37 class ExceptionState; 38 class ExceptionState;
38 class HTMLMediaElement; 39 class HTMLMediaElement;
39 class TextTrack; 40 class TextTrack;
40 class TextTrackCue; 41 class TextTrackCue;
41 class TextTrackCueList; 42 class TextTrackCueList;
43 class TextTrackList;
42 class VTTRegion; 44 class VTTRegion;
43 class VTTRegionList; 45 class VTTRegionList;
44 46
45 class TextTrackClient { 47 class TextTrackClient {
46 public: 48 public:
47 virtual ~TextTrackClient() { } 49 virtual ~TextTrackClient() { }
48 virtual void textTrackKindChanged(TextTrack*) = 0; 50 virtual void textTrackKindChanged(TextTrack*) = 0;
49 virtual void textTrackModeChanged(TextTrack*) = 0; 51 virtual void textTrackModeChanged(TextTrack*) = 0;
50 virtual void textTrackAddCues(TextTrack*, const TextTrackCueList*) = 0; 52 virtual void textTrackAddCues(TextTrack*, const TextTrackCueList*) = 0;
51 virtual void textTrackRemoveCues(TextTrack*, const TextTrackCueList*) = 0; 53 virtual void textTrackRemoveCues(TextTrack*, const TextTrackCueList*) = 0;
52 virtual void textTrackAddCue(TextTrack*, PassRefPtr<TextTrackCue>) = 0; 54 virtual void textTrackAddCue(TextTrack*, PassRefPtr<TextTrackCue>) = 0;
53 virtual void textTrackRemoveCue(TextTrack*, PassRefPtr<TextTrackCue>) = 0; 55 virtual void textTrackRemoveCue(TextTrack*, PassRefPtr<TextTrackCue>) = 0;
54 }; 56 };
55 57
56 class TextTrack : public TrackBase, public ScriptWrappable { 58 class TextTrack : public TrackBase, public ScriptWrappable, public EventTargetWi thInlineData {
59 REFCOUNTED_EVENT_TARGET(TrackBase);
57 public: 60 public:
58 static PassRefPtr<TextTrack> create(Document& document, TextTrackClient* cli ent, const AtomicString& kind, const AtomicString& label, const AtomicString& la nguage) 61 static PassRefPtr<TextTrack> create(Document& document, TextTrackClient* cli ent, const AtomicString& kind, const AtomicString& label, const AtomicString& la nguage)
59 { 62 {
60 return adoptRef(new TextTrack(document, client, kind, label, language, e mptyAtom, AddTrack)); 63 return adoptRef(new TextTrack(document, client, kind, label, language, e mptyAtom, AddTrack));
61 } 64 }
62 virtual ~TextTrack(); 65 virtual ~TextTrack();
63 66
64 void setMediaElement(HTMLMediaElement* element) { m_mediaElement = element; } 67 void setTrackList(TextTrackList* trackList) { m_trackList = trackList; }
65 HTMLMediaElement* mediaElement() { return m_mediaElement; } 68 TextTrackList* trackList() { return m_trackList; }
66 69
67 const AtomicString& kind() const { return m_kind; } 70 virtual void setKind(const AtomicString&) OVERRIDE;
68 void setKind(const AtomicString&);
69 71
70 static const AtomicString& subtitlesKeyword(); 72 static const AtomicString& subtitlesKeyword();
71 static const AtomicString& captionsKeyword(); 73 static const AtomicString& captionsKeyword();
72 static const AtomicString& descriptionsKeyword(); 74 static const AtomicString& descriptionsKeyword();
73 static const AtomicString& chaptersKeyword(); 75 static const AtomicString& chaptersKeyword();
74 static const AtomicString& metadataKeyword(); 76 static const AtomicString& metadataKeyword();
75 static bool isValidKindKeyword(const AtomicString&); 77 static bool isValidKindKeyword(const AtomicString&);
76 78
77 AtomicString label() const { return m_label; }
78 void setLabel(const AtomicString& label) { m_label = label; }
79
80 AtomicString language() const { return m_language; }
81 void setLanguage(const AtomicString& language) { m_language = language; }
82
83 AtomicString id() const { return m_id; }
84 void setId(const AtomicString& id) { m_id = id; }
85
86 static const AtomicString& disabledKeyword(); 79 static const AtomicString& disabledKeyword();
87 static const AtomicString& hiddenKeyword(); 80 static const AtomicString& hiddenKeyword();
88 static const AtomicString& showingKeyword(); 81 static const AtomicString& showingKeyword();
89 82
90 AtomicString mode() const { return m_mode; } 83 AtomicString mode() const { return m_mode; }
91 void setMode(const AtomicString&); 84 void setMode(const AtomicString&);
92 85
93 enum ReadinessState { NotLoaded = 0, Loading = 1, Loaded = 2, FailedToLoad = 3 }; 86 enum ReadinessState { NotLoaded = 0, Loading = 1, Loaded = 2, FailedToLoad = 3 };
94 ReadinessState readinessState() const { return m_readinessState; } 87 ReadinessState readinessState() const { return m_readinessState; }
95 void setReadinessState(ReadinessState state) { m_readinessState = state; } 88 void setReadinessState(ReadinessState state) { m_readinessState = state; }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 124
132 Document& document() const { return *m_document; } 125 Document& document() const { return *m_document; }
133 126
134 // EventTarget methods 127 // EventTarget methods
135 virtual const AtomicString& interfaceName() const OVERRIDE; 128 virtual const AtomicString& interfaceName() const OVERRIDE;
136 virtual ExecutionContext* executionContext() const OVERRIDE; 129 virtual ExecutionContext* executionContext() const OVERRIDE;
137 130
138 protected: 131 protected:
139 TextTrack(Document&, TextTrackClient*, const AtomicString& kind, const Atomi cString& label, const AtomicString& language, const AtomicString& id, TextTrackT ype); 132 TextTrack(Document&, TextTrackClient*, const AtomicString& kind, const Atomi cString& label, const AtomicString& language, const AtomicString& id, TextTrackT ype);
140 133
134 virtual bool isValidKind(const AtomicString& kind) const OVERRIDE { return i sValidKindKeyword(kind); }
135 virtual AtomicString defaultKind() const OVERRIDE { return subtitlesKeyword( ); }
136
141 RefPtr<TextTrackCueList> m_cues; 137 RefPtr<TextTrackCueList> m_cues;
142 138
143 private: 139 private:
144 VTTRegionList* ensureVTTRegionList(); 140 VTTRegionList* ensureVTTRegionList();
145 RefPtr<VTTRegionList> m_regions; 141 RefPtr<VTTRegionList> m_regions;
146 142
147 TextTrackCueList* ensureTextTrackCueList(); 143 TextTrackCueList* ensureTextTrackCueList();
148 144
149 // FIXME: Remove this pointer and get the Document from m_client 145 // FIXME: Remove this pointer and get the Document from m_client
150 Document* m_document; 146 Document* m_document;
151 147
152 HTMLMediaElement* m_mediaElement; 148 TextTrackList* m_trackList;
153 AtomicString m_kind;
154 AtomicString m_label;
155 AtomicString m_language;
156 AtomicString m_id;
157 AtomicString m_mode; 149 AtomicString m_mode;
158 TextTrackClient* m_client; 150 TextTrackClient* m_client;
159 TextTrackType m_trackType; 151 TextTrackType m_trackType;
160 ReadinessState m_readinessState; 152 ReadinessState m_readinessState;
161 int m_trackIndex; 153 int m_trackIndex;
162 int m_renderedTrackIndex; 154 int m_renderedTrackIndex;
163 bool m_hasBeenConfigured; 155 bool m_hasBeenConfigured;
164 }; 156 };
165 157
166 } // namespace WebCore 158 } // namespace WebCore
167 159
168 #endif 160 #endif
OLDNEW
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/html/track/TextTrack.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698