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(); |
(...skipping 12 matching lines...) Expand all Loading... |
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() const; | 83 HTMLMediaElement* mediaElement() const; |
83 Node* owner() const; | 84 Node* owner() const; |
84 | 85 |
85 void addCue(PassRefPtr<TextTrackCue>); | 86 void addCue(PassRefPtrWillBeRawPtr<TextTrackCue>); |
86 void removeCue(TextTrackCue*, ExceptionState&); | 87 void removeCue(TextTrackCue*, ExceptionState&); |
87 | 88 |
88 VTTRegionList* regions(); | 89 VTTRegionList* regions(); |
89 void addRegion(PassRefPtr<VTTRegion>); | 90 void addRegion(PassRefPtrWillBeRawPtr<VTTRegion>); |
90 void removeRegion(VTTRegion*, ExceptionState&); | 91 void removeRegion(VTTRegion*, ExceptionState&); |
91 | 92 |
92 void cueWillChange(TextTrackCue*); | 93 void cueWillChange(TextTrackCue*); |
93 void cueDidChange(TextTrackCue*); | 94 void cueDidChange(TextTrackCue*); |
94 | 95 |
95 DEFINE_ATTRIBUTE_EVENT_LISTENER(cuechange); | 96 DEFINE_ATTRIBUTE_EVENT_LISTENER(cuechange); |
96 | 97 |
97 enum TextTrackType { TrackElement, AddTrack, InBand }; | 98 enum TextTrackType { TrackElement, AddTrack, InBand }; |
98 TextTrackType trackType() const { return m_trackType; } | 99 TextTrackType trackType() const { return m_trackType; } |
99 | 100 |
100 int trackIndex(); | 101 int trackIndex(); |
101 void invalidateTrackIndex(); | 102 void invalidateTrackIndex(); |
102 | 103 |
103 bool isRendered(); | 104 bool isRendered(); |
104 int trackIndexRelativeToRenderedTracks(); | 105 int trackIndexRelativeToRenderedTracks(); |
105 | 106 |
106 bool hasBeenConfigured() const { return m_hasBeenConfigured; } | 107 bool hasBeenConfigured() const { return m_hasBeenConfigured; } |
107 void setHasBeenConfigured(bool flag) { m_hasBeenConfigured = flag; } | 108 void setHasBeenConfigured(bool flag) { m_hasBeenConfigured = flag; } |
108 | 109 |
109 virtual bool isDefault() const { return false; } | 110 virtual bool isDefault() const { return false; } |
110 virtual void setIsDefault(bool) { } | 111 virtual void setIsDefault(bool) { } |
111 | 112 |
112 void removeAllCues(); | 113 void removeAllCues(); |
113 | 114 |
114 Document& document() const { return *m_document; } | |
115 | |
116 // EventTarget methods | 115 // EventTarget methods |
117 virtual const AtomicString& interfaceName() const OVERRIDE; | 116 virtual const AtomicString& interfaceName() const OVERRIDE; |
118 virtual ExecutionContext* executionContext() const OVERRIDE; | 117 virtual ExecutionContext* executionContext() const OVERRIDE; |
119 | 118 |
| 119 virtual void trace(Visitor*) OVERRIDE; |
| 120 |
120 protected: | 121 protected: |
121 TextTrack(Document&, const AtomicString& kind, const AtomicString& label, co
nst AtomicString& language, const AtomicString& id, TextTrackType); | 122 TextTrack(Document&, const AtomicString& kind, const AtomicString& label, co
nst AtomicString& language, const AtomicString& id, TextTrackType); |
122 | 123 |
123 virtual bool isValidKind(const AtomicString& kind) const OVERRIDE { return i
sValidKindKeyword(kind); } | 124 virtual bool isValidKind(const AtomicString& kind) const OVERRIDE { return i
sValidKindKeyword(kind); } |
124 virtual AtomicString defaultKind() const OVERRIDE { return subtitlesKeyword(
); } | 125 virtual AtomicString defaultKind() const OVERRIDE { return subtitlesKeyword(
); } |
125 | 126 |
126 RefPtr<TextTrackCueList> m_cues; | 127 RefPtrWillBeMember<TextTrackCueList> m_cues; |
127 | 128 |
128 private: | 129 private: |
129 VTTRegionList* ensureVTTRegionList(); | 130 VTTRegionList* ensureVTTRegionList(); |
130 RefPtr<VTTRegionList> m_regions; | 131 RefPtrWillBeMember<VTTRegionList> m_regions; |
131 | 132 |
132 TextTrackCueList* ensureTextTrackCueList(); | 133 TextTrackCueList* ensureTextTrackCueList(); |
133 | 134 |
134 // FIXME: Remove this pointer and get the Document from m_client | 135 RawPtrWillBeMember<TextTrackList> m_trackList; |
135 Document* m_document; | |
136 | |
137 TextTrackList* m_trackList; | |
138 AtomicString m_mode; | 136 AtomicString m_mode; |
139 TextTrackType m_trackType; | 137 TextTrackType m_trackType; |
140 ReadinessState m_readinessState; | 138 ReadinessState m_readinessState; |
141 int m_trackIndex; | 139 int m_trackIndex; |
142 int m_renderedTrackIndex; | 140 int m_renderedTrackIndex; |
143 bool m_hasBeenConfigured; | 141 bool m_hasBeenConfigured; |
144 }; | 142 }; |
145 | 143 |
146 } // namespace WebCore | 144 } // namespace WebCore |
147 | 145 |
148 #endif | 146 #endif |
OLD | NEW |