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; | 43 static const unsigned invalidCueIndex = UINT_MAX; |
44 | 44 |
45 TextTrackCue::TextTrackCue(double start, double end) | 45 TextTrackCue::TextTrackCue(double start, double end) |
46 : m_startTime(start) | 46 : m_startTime(start) |
47 , m_endTime(end) | 47 , m_endTime(end) |
| 48 , m_track(nullptr) |
48 , m_cueIndex(invalidCueIndex) | 49 , m_cueIndex(invalidCueIndex) |
49 , m_track(nullptr) | |
50 , m_isActive(false) | 50 , m_isActive(false) |
51 , m_pauseOnExit(false) | 51 , m_pauseOnExit(false) |
52 { | 52 { |
53 } | 53 } |
54 | 54 |
55 void TextTrackCue::cueWillChange() | 55 void TextTrackCue::cueWillChange() |
56 { | 56 { |
57 if (m_track) | 57 if (m_track) |
58 m_track->cueWillChange(this); | 58 m_track->cueWillChange(this); |
59 } | 59 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 void TextTrackCue::setPauseOnExit(bool value) | 114 void TextTrackCue::setPauseOnExit(bool value) |
115 { | 115 { |
116 if (m_pauseOnExit == value) | 116 if (m_pauseOnExit == value) |
117 return; | 117 return; |
118 | 118 |
119 cueWillChange(); | 119 cueWillChange(); |
120 m_pauseOnExit = value; | 120 m_pauseOnExit = value; |
121 cueDidChange(); | 121 cueDidChange(); |
122 } | 122 } |
123 | 123 |
124 int TextTrackCue::cueIndex() | |
125 { | |
126 if (m_cueIndex == invalidCueIndex) | |
127 m_cueIndex = track()->cues()->getCueIndex(this); | |
128 | |
129 return m_cueIndex; | |
130 } | |
131 | |
132 void TextTrackCue::invalidateCueIndex() | 124 void TextTrackCue::invalidateCueIndex() |
133 { | 125 { |
134 m_cueIndex = invalidCueIndex; | 126 m_cueIndex = invalidCueIndex; |
135 } | 127 } |
136 | 128 |
| 129 unsigned TextTrackCue::cueIndex() |
| 130 { |
| 131 // This method can only be called on cues while they are associated with |
| 132 // a(n enabled) track (and hence that track's list of cues should exist.) |
| 133 ASSERT(track() && track()->cues()); |
| 134 TextTrackCueList* cueList = track()->cues(); |
| 135 if (!cueList->isCueIndexValid(m_cueIndex)) |
| 136 cueList->validateCueIndexes(); |
| 137 return m_cueIndex; |
| 138 } |
| 139 |
137 bool TextTrackCue::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event) | 140 bool TextTrackCue::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event) |
138 { | 141 { |
139 // When a TextTrack's mode is disabled: no cues are active, no events fired. | 142 // When a TextTrack's mode is disabled: no cues are active, no events fired. |
140 if (!track() || track()->mode() == TextTrack::disabledKeyword()) | 143 if (!track() || track()->mode() == TextTrack::disabledKeyword()) |
141 return false; | 144 return false; |
142 | 145 |
143 return EventTarget::dispatchEvent(event); | 146 return EventTarget::dispatchEvent(event); |
144 } | 147 } |
145 | 148 |
146 bool TextTrackCue::isActive() | 149 bool TextTrackCue::isActive() |
147 { | 150 { |
148 return m_isActive && track() && track()->mode() != TextTrack::disabledKeywor
d(); | 151 return m_isActive && track() && track()->mode() != TextTrack::disabledKeywor
d(); |
149 } | 152 } |
150 | 153 |
151 const AtomicString& TextTrackCue::interfaceName() const | 154 const AtomicString& TextTrackCue::interfaceName() const |
152 { | 155 { |
153 return EventTargetNames::TextTrackCue; | 156 return EventTargetNames::TextTrackCue; |
154 } | 157 } |
155 | 158 |
156 DEFINE_TRACE(TextTrackCue) | 159 DEFINE_TRACE(TextTrackCue) |
157 { | 160 { |
158 visitor->trace(m_track); | 161 visitor->trace(m_track); |
159 EventTargetWithInlineData::trace(visitor); | 162 EventTargetWithInlineData::trace(visitor); |
160 } | 163 } |
161 | 164 |
162 } // namespace blink | 165 } // namespace blink |
OLD | NEW |