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 are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 22 matching lines...) Expand all Loading... | |
33 #include "core/html/track/TextTrackCue.h" | 33 #include "core/html/track/TextTrackCue.h" |
34 | 34 |
35 #include "bindings/core/v8/ExceptionMessages.h" | 35 #include "bindings/core/v8/ExceptionMessages.h" |
36 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 36 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
37 #include "core/events/Event.h" | 37 #include "core/events/Event.h" |
38 #include "core/html/track/TextTrack.h" | 38 #include "core/html/track/TextTrack.h" |
39 #include "core/html/track/TextTrackCueList.h" | 39 #include "core/html/track/TextTrackCueList.h" |
40 | 40 |
41 namespace blink { | 41 namespace blink { |
42 | 42 |
43 static const int invalidCueIndex = -1; | |
44 | |
45 TextTrackCue::TextTrackCue(double start, double end) | 43 TextTrackCue::TextTrackCue(double start, double end) |
46 : m_startTime(start) | 44 : m_startTime(start) |
47 , m_endTime(end) | 45 , m_endTime(end) |
48 , m_cueIndex(invalidCueIndex) | |
49 , m_track(nullptr) | 46 , m_track(nullptr) |
47 , m_cueIndex(UINT_MAX) | |
50 , m_isActive(false) | 48 , m_isActive(false) |
51 , m_pauseOnExit(false) | 49 , m_pauseOnExit(false) |
52 { | 50 { |
53 } | 51 } |
54 | 52 |
55 void TextTrackCue::cueWillChange() | 53 void TextTrackCue::cueWillChange() |
56 { | 54 { |
57 if (m_track) | 55 if (m_track) |
58 m_track->cueWillChange(this); | 56 m_track->cueWillChange(this); |
59 } | 57 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 void TextTrackCue::setPauseOnExit(bool value) | 112 void TextTrackCue::setPauseOnExit(bool value) |
115 { | 113 { |
116 if (m_pauseOnExit == value) | 114 if (m_pauseOnExit == value) |
117 return; | 115 return; |
118 | 116 |
119 cueWillChange(); | 117 cueWillChange(); |
120 m_pauseOnExit = value; | 118 m_pauseOnExit = value; |
121 cueDidChange(); | 119 cueDidChange(); |
122 } | 120 } |
123 | 121 |
124 int TextTrackCue::cueIndex() | 122 unsigned TextTrackCue::cueIndex() |
125 { | 123 { |
126 if (m_cueIndex == invalidCueIndex) | 124 // This method can only be called on cues while they are associated with |
127 m_cueIndex = track()->cues()->getCueIndex(this); | 125 // a(n enabled) track (and hence that tracks list of cues should exist.) |
philipj_slow
2015/02/26 15:43:12
s/tracks/track's/
fs
2015/02/26 16:09:34
Done.
| |
128 | 126 ASSERT(track() && track()->cues()); |
127 TextTrackCueList* cueList = track()->cues(); | |
128 if (!cueList->isCueIndexValid(m_cueIndex)) | |
129 cueList->validateCueIndexes(); | |
129 return m_cueIndex; | 130 return m_cueIndex; |
130 } | 131 } |
131 | 132 |
132 void TextTrackCue::invalidateCueIndex() | |
133 { | |
134 m_cueIndex = invalidCueIndex; | |
135 } | |
136 | |
137 bool TextTrackCue::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event) | 133 bool TextTrackCue::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event) |
138 { | 134 { |
139 // When a TextTrack's mode is disabled: no cues are active, no events fired. | 135 // When a TextTrack's mode is disabled: no cues are active, no events fired. |
140 if (!track() || track()->mode() == TextTrack::disabledKeyword()) | 136 if (!track() || track()->mode() == TextTrack::disabledKeyword()) |
141 return false; | 137 return false; |
142 | 138 |
143 return EventTarget::dispatchEvent(event); | 139 return EventTarget::dispatchEvent(event); |
144 } | 140 } |
145 | 141 |
146 bool TextTrackCue::isActive() | 142 bool TextTrackCue::isActive() |
147 { | 143 { |
148 return m_isActive && track() && track()->mode() != TextTrack::disabledKeywor d(); | 144 return m_isActive && track() && track()->mode() != TextTrack::disabledKeywor d(); |
149 } | 145 } |
150 | 146 |
151 const AtomicString& TextTrackCue::interfaceName() const | 147 const AtomicString& TextTrackCue::interfaceName() const |
152 { | 148 { |
153 return EventTargetNames::TextTrackCue; | 149 return EventTargetNames::TextTrackCue; |
154 } | 150 } |
155 | 151 |
156 DEFINE_TRACE(TextTrackCue) | 152 DEFINE_TRACE(TextTrackCue) |
157 { | 153 { |
158 visitor->trace(m_track); | 154 visitor->trace(m_track); |
159 EventTargetWithInlineData::trace(visitor); | 155 EventTargetWithInlineData::trace(visitor); |
160 } | 156 } |
161 | 157 |
162 } // namespace blink | 158 } // namespace blink |
OLD | NEW |