OLD | NEW |
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 12 matching lines...) Expand all Loading... |
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/events/EventTarget.h" |
32 #include "core/html/track/TrackBase.h" | 32 #include "core/html/track/TrackBase.h" |
| 33 #include "platform/heap/Handle.h" |
33 #include "wtf/text/WTFString.h" | 34 #include "wtf/text/WTFString.h" |
34 | 35 |
35 namespace WebCore { | 36 namespace WebCore { |
36 | 37 |
37 class Document; | 38 class Document; |
38 class ExceptionState; | 39 class ExceptionState; |
39 class HTMLMediaElement; | 40 class HTMLMediaElement; |
40 class TextTrack; | 41 class TextTrack; |
41 class TextTrackCue; | 42 class TextTrackCue; |
42 class TextTrackCueList; | 43 class TextTrackCueList; |
43 class TextTrackList; | 44 class TextTrackList; |
44 class VTTRegion; | 45 class VTTRegion; |
45 class VTTRegionList; | 46 class VTTRegionList; |
46 | 47 |
47 class TextTrack : public TrackBase, public ScriptWrappable, public EventTargetWi
thInlineData { | 48 class TextTrack : public TrackBase, public ScriptWrappable, public EventTargetWi
thInlineData { |
48 REFCOUNTED_EVENT_TARGET(TrackBase); | 49 DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedWillBeRefCountedGarbageCollected<T
rackBase>); |
49 public: | 50 public: |
50 static PassRefPtr<TextTrack> create(Document& document, const AtomicString&
kind, const AtomicString& label, const AtomicString& language) | 51 static PassRefPtrWillBeRawPtr<TextTrack> create(Document& document, const At
omicString& kind, const AtomicString& label, const AtomicString& language) |
51 { | 52 { |
52 return adoptRef(new TextTrack(document, kind, label, language, emptyAtom
, AddTrack)); | 53 return adoptRefWillBeRefCountedGarbageCollected(new TextTrack(document,
kind, label, language, emptyAtom, AddTrack)); |
53 } | 54 } |
54 virtual ~TextTrack(); | 55 virtual ~TextTrack(); |
55 | 56 |
56 virtual void setTrackList(TextTrackList*); | 57 virtual void setTrackList(TextTrackList*); |
57 TextTrackList* trackList() { return m_trackList; } | 58 TextTrackList* trackList() { return m_trackList; } |
58 | 59 |
59 virtual void setKind(const AtomicString&) OVERRIDE; | 60 virtual void setKind(const AtomicString&) OVERRIDE; |
60 | 61 |
61 static const AtomicString& subtitlesKeyword(); | 62 static const AtomicString& subtitlesKeyword(); |
62 static const AtomicString& captionsKeyword(); | 63 static const AtomicString& captionsKeyword(); |
63 static const AtomicString& descriptionsKeyword(); | 64 static const AtomicString& descriptionsKeyword(); |
64 static const AtomicString& chaptersKeyword(); | 65 static const AtomicString& chaptersKeyword(); |
65 static const AtomicString& metadataKeyword(); | 66 static const AtomicString& metadataKeyword(); |
66 static bool isValidKindKeyword(const AtomicString&); | 67 static bool isValidKindKeyword(const AtomicString&); |
67 | 68 |
68 static const AtomicString& disabledKeyword(); | 69 static const AtomicString& disabledKeyword(); |
69 static const AtomicString& hiddenKeyword(); | 70 static const AtomicString& hiddenKeyword(); |
70 static const AtomicString& showingKeyword(); | 71 static const AtomicString& showingKeyword(); |
71 | 72 |
72 AtomicString mode() const { return m_mode; } | 73 AtomicString mode() const { return m_mode; } |
73 virtual void setMode(const AtomicString&); | 74 virtual void setMode(const AtomicString&); |
74 | 75 |
75 enum ReadinessState { NotLoaded = 0, Loading = 1, Loaded = 2, FailedToLoad =
3 }; | 76 enum ReadinessState { NotLoaded = 0, Loading = 1, Loaded = 2, FailedToLoad =
3 }; |
76 ReadinessState readinessState() const { return m_readinessState; } | 77 ReadinessState readinessState() const { return m_readinessState; } |
77 void setReadinessState(ReadinessState state) { m_readinessState = state; } | 78 void setReadinessState(ReadinessState state) { m_readinessState = state; } |
78 | 79 |
79 TextTrackCueList* cues(); | 80 TextTrackCueList* cues(); |
80 TextTrackCueList* activeCues() const; | 81 TextTrackCueList* activeCues() const; |
81 | 82 |
82 HTMLMediaElement* mediaElement(); | 83 HTMLMediaElement* mediaElement() const; |
83 | 84 |
84 void addCue(PassRefPtr<TextTrackCue>); | 85 void addCue(PassRefPtrWillBeRawPtr<TextTrackCue>); |
85 void removeCue(TextTrackCue*, ExceptionState&); | 86 void removeCue(TextTrackCue*, ExceptionState&); |
86 | 87 |
87 VTTRegionList* regions(); | 88 VTTRegionList* regions(); |
88 void addRegion(PassRefPtr<VTTRegion>); | 89 void addRegion(PassRefPtrWillBeRawPtr<VTTRegion>); |
89 void removeRegion(VTTRegion*, ExceptionState&); | 90 void removeRegion(VTTRegion*, ExceptionState&); |
90 | 91 |
91 void cueWillChange(TextTrackCue*); | 92 void cueWillChange(TextTrackCue*); |
92 void cueDidChange(TextTrackCue*); | 93 void cueDidChange(TextTrackCue*); |
93 | 94 |
94 DEFINE_ATTRIBUTE_EVENT_LISTENER(cuechange); | 95 DEFINE_ATTRIBUTE_EVENT_LISTENER(cuechange); |
95 | 96 |
96 enum TextTrackType { TrackElement, AddTrack, InBand }; | 97 enum TextTrackType { TrackElement, AddTrack, InBand }; |
97 TextTrackType trackType() const { return m_trackType; } | 98 TextTrackType trackType() const { return m_trackType; } |
98 | 99 |
99 int trackIndex(); | 100 int trackIndex(); |
100 void invalidateTrackIndex(); | 101 void invalidateTrackIndex(); |
101 | 102 |
102 bool isRendered(); | 103 bool isRendered(); |
103 int trackIndexRelativeToRenderedTracks(); | 104 int trackIndexRelativeToRenderedTracks(); |
104 | 105 |
105 bool hasBeenConfigured() const { return m_hasBeenConfigured; } | 106 bool hasBeenConfigured() const { return m_hasBeenConfigured; } |
106 void setHasBeenConfigured(bool flag) { m_hasBeenConfigured = flag; } | 107 void setHasBeenConfigured(bool flag) { m_hasBeenConfigured = flag; } |
107 | 108 |
108 virtual bool isDefault() const { return false; } | 109 virtual bool isDefault() const { return false; } |
109 virtual void setIsDefault(bool) { } | 110 virtual void setIsDefault(bool) { } |
110 | 111 |
111 void removeAllCues(); | 112 void removeAllCues(); |
112 | 113 |
113 Document& document() const { return *m_document; } | |
114 | |
115 // EventTarget methods | 114 // EventTarget methods |
116 virtual const AtomicString& interfaceName() const OVERRIDE; | 115 virtual const AtomicString& interfaceName() const OVERRIDE; |
117 virtual ExecutionContext* executionContext() const OVERRIDE; | 116 virtual ExecutionContext* executionContext() const OVERRIDE; |
118 | 117 |
| 118 virtual void trace(Visitor*) OVERRIDE; |
| 119 |
119 protected: | 120 protected: |
120 TextTrack(Document&, const AtomicString& kind, const AtomicString& label, co
nst AtomicString& language, const AtomicString& id, TextTrackType); | 121 TextTrack(Document&, const AtomicString& kind, const AtomicString& label, co
nst AtomicString& language, const AtomicString& id, TextTrackType); |
121 | 122 |
122 virtual bool isValidKind(const AtomicString& kind) const OVERRIDE { return i
sValidKindKeyword(kind); } | 123 virtual bool isValidKind(const AtomicString& kind) const OVERRIDE { return i
sValidKindKeyword(kind); } |
123 virtual AtomicString defaultKind() const OVERRIDE { return subtitlesKeyword(
); } | 124 virtual AtomicString defaultKind() const OVERRIDE { return subtitlesKeyword(
); } |
124 | 125 |
125 RefPtr<TextTrackCueList> m_cues; | 126 RefPtrWillBeMember<TextTrackCueList> m_cues; |
126 | 127 |
127 private: | 128 private: |
128 VTTRegionList* ensureVTTRegionList(); | 129 VTTRegionList* ensureVTTRegionList(); |
129 RefPtr<VTTRegionList> m_regions; | 130 RefPtrWillBeMember<VTTRegionList> m_regions; |
130 | 131 |
131 TextTrackCueList* ensureTextTrackCueList(); | 132 TextTrackCueList* ensureTextTrackCueList(); |
132 | 133 |
133 // FIXME: Remove this pointer and get the Document from m_client | 134 RawPtrWillBeMember<TextTrackList> m_trackList; |
134 Document* m_document; | |
135 | |
136 TextTrackList* m_trackList; | |
137 AtomicString m_mode; | 135 AtomicString m_mode; |
138 TextTrackType m_trackType; | 136 TextTrackType m_trackType; |
139 ReadinessState m_readinessState; | 137 ReadinessState m_readinessState; |
140 int m_trackIndex; | 138 int m_trackIndex; |
141 int m_renderedTrackIndex; | 139 int m_renderedTrackIndex; |
142 bool m_hasBeenConfigured; | 140 bool m_hasBeenConfigured; |
143 }; | 141 }; |
144 | 142 |
145 } // namespace WebCore | 143 } // namespace WebCore |
146 | 144 |
147 #endif | 145 #endif |
OLD | NEW |