Changeset 101185 in webkit
- Timestamp:
- Nov 25, 2011, 8:28:39 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 deleted
- 11 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/media/track/track-add-remove-cue-expected.txt (added)
-
LayoutTests/media/track/track-add-remove-cue.html (added)
-
LayoutTests/media/track/track-webvtt-tc012-out-of-order-expected.txt (deleted)
-
LayoutTests/media/track/track-webvtt-tc012-out-of-order.html (deleted)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/html/HTMLTrackElement.cpp (modified) (3 diffs)
-
Source/WebCore/html/LoadableTextTrack.cpp (modified) (1 diff)
-
Source/WebCore/html/TextTrack.cpp (modified) (1 diff)
-
Source/WebCore/html/TextTrack.h (modified) (1 diff)
-
Source/WebCore/html/TextTrackCue.cpp (modified) (2 diffs)
-
Source/WebCore/html/TextTrackCue.h (modified) (3 diffs)
-
Source/WebCore/html/TextTrackCueList.cpp (modified) (2 diffs)
-
Source/WebCore/html/TextTrackCueList.h (modified) (1 diff)
-
Source/WebCore/loader/TextTrackLoader.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r101183 r101185 1 2011-11-25 Eric Carlson <eric.carlson@apple.com> 2 3 Implement addCue and removeCue in TextTrack 4 https://bugs.webkit.org/show_bug.cgi?id=72554 5 6 Reviewed by Darin Adler. 7 8 * media/track/track-add-remove-cue-expected.txt: Added. 9 * media/track/track-add-remove-cue.html: Added. 10 * media/track/track-webvtt-tc012-out-of-order-expected.txt: Removed. 11 * media/track/track-webvtt-tc012-out-of-order.html: Removed. 12 1 13 2011-11-25 Kentaro Hara <haraken@chromium.org> 2 14 -
trunk/Source/WebCore/ChangeLog
r101184 r101185 1 2011-11-25 Eric Carlson <eric.carlson@apple.com> 2 3 Implement addCue and removeCue in TextTrack 4 https://bugs.webkit.org/show_bug.cgi?id=72554 5 6 Reviewed by Darin Adler. 7 8 Test: media/track/track-add-remove-cue.html 9 10 * html/HTMLTrackElement.cpp: 11 (WebCore::HTMLTrackElement::ensureTrack): Go ahead and allocate a Track even if the feature 12 is disabled, it just won't load anything. 13 (WebCore::HTMLTrackElement::scheduleLoad): Early return if the featue is disabled. 14 (WebCore::HTMLTrackElement::canLoadUrl): Ditto. 15 16 * html/LoadableTextTrack.cpp: 17 (WebCore::LoadableTextTrack::newCuesAvailable): Add new cues one at a time because 18 cues->add(Vector<TextTrackCue*>&) is gone. 19 20 * html/TextTrack.cpp: 21 (WebCore::TextTrack::addCue): Implement. 22 (WebCore::TextTrack::removeCue): Ditto. 23 * html/TextTrack.h: 24 25 (WebCore::TextTrackCue::TextTrackCue): Initialize every member variable. 26 (WebCore::TextTrackCue::track): m_track is now a RefPtr. 27 (WebCore::TextTrackCue::setTrack): Ditto. 28 * html/TextTrackCue.h: 29 30 * html/TextTrackCueList.cpp: 31 (WebCore::TextTrackCueList::add): Don't ignore out of order cues, the spec text is not 32 a conformance requirement. Return bool to indicate success or failure. 33 (WebCore::TextTrackCueList::remove): Return bool to indicate success or failure. 34 * html/TextTrackCueList.h: 35 36 * loader/TextTrackLoader.cpp: 37 (WebCore::TextTrackLoader::notifyFinished): Don't change m_state once it is set to Failed. 38 1 39 2011-11-25 Kentaro Hara <haraken@chromium.org> 2 40 -
trunk/Source/WebCore/html/HTMLTrackElement.cpp
r101088 r101185 159 159 LoadableTextTrack* HTMLTrackElement::ensureTrack() 160 160 { 161 if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled())162 return 0;163 164 161 if (!m_track) { 165 162 // The kind attribute is an enumerated attribute, limited only to know values. It defaults to 'subtitles' if missing or invalid. … … 184 181 void HTMLTrackElement::scheduleLoad() 185 182 { 183 if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled()) 184 return; 185 186 186 if (!mediaElement()) 187 187 return; … … 195 195 bool HTMLTrackElement::canLoadUrl(LoadableTextTrack*, const KURL& url) 196 196 { 197 if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled()) 198 return false; 199 197 200 HTMLMediaElement* parent = mediaElement(); 198 201 if (!parent) -
trunk/Source/WebCore/html/LoadableTextTrack.cpp
r101088 r101185 86 86 m_loader->getNewCues(newCues); 87 87 88 for (size_t i = 0; i < newCues.size(); ++i)89 newCues[i]->setTrack(this);90 91 88 if (!m_cues) 92 89 m_cues = TextTrackCueList::create(); 93 m_cues->add(newCues); 90 91 for (size_t i = 0; i < newCues.size(); ++i) { 92 newCues[i]->setTrack(this); 93 m_cues->add(newCues[i]); 94 } 94 95 95 96 if (client()) -
trunk/Source/WebCore/html/TextTrack.cpp
r101088 r101185 167 167 } 168 168 169 void TextTrack::addCue(PassRefPtr<TextTrackCue>, ExceptionCode&) 170 { 171 // FIXME(62890): Implement. 169 void TextTrack::addCue(PassRefPtr<TextTrackCue> prpCue, ExceptionCode& ec) 170 { 171 if (!prpCue) 172 return; 173 174 RefPtr<TextTrackCue> cue = prpCue; 175 176 // 4.8.10.12.4 Text track API 177 178 // The addCue(cue) method of TextTrack objects, when invoked, must run the following steps: 179 180 // 1. If the given cue is already associated with a text track other than 181 // the method's TextTrack object's text track, then throw an InvalidStateError 182 // exception and abort these steps. 183 TextTrack* cueTrack = cue->track(); 184 if (cueTrack && cueTrack != this) { 185 ec = INVALID_STATE_ERR; 186 return; 187 } 188 189 // 2. Associate cue with the method's TextTrack object's text track, if it is 190 // not currently associated with a text track. 191 cue->setTrack(this); 192 193 // 3. If the given cue is already listed in the method's TextTrack object's text 194 // track's text track list of cues, then throw an InvalidStateError exception. 195 // 4. Add cue to the method's TextTrack object's text track's text track list of cues. 196 if (!m_cues->add(cue)) { 197 ec = INVALID_STATE_ERR; 198 return; 199 } 172 200 173 } 174 175 void TextTrack::removeCue(PassRefPtr<TextTrackCue>, ExceptionCode&) 176 { 177 // FIXME(62890): Implement. 178 } 179 180 void TextTrack::newCuesLoaded() 181 { 182 // FIXME(62890): Implement. 183 } 184 185 void TextTrack::fetchNewestCues(Vector<TextTrackCue*>&) 186 { 187 // FIXME(62890): Implement. 201 if (m_client) 202 m_client->textTrackAddCue(this, cue.get()); 203 } 204 205 void TextTrack::removeCue(TextTrackCue* cue, ExceptionCode& ec) 206 { 207 if (!cue) 208 return; 209 210 // 4.8.10.12.4 Text track API 211 212 // The removeCue(cue) method of TextTrack objects, when invoked, must run the following steps: 213 214 // 1. If the given cue is not associated with the method's TextTrack 215 // object's text track, then throw an InvalidStateError exception. 216 if (cue->track() != this) { 217 ec = INVALID_STATE_ERR; 218 return; 219 } 220 221 // 2. If the given cue is not currently listed in the method's TextTrack 222 // object's text track's text track list of cues, then throw a NotFoundError exception. 223 // 3. Remove cue from the method's TextTrack object's text track's text track list of cues. 224 if (!m_cues->remove(cue)) { 225 ec = INVALID_STATE_ERR; 226 return; 227 } 228 229 cue->setTrack(0); 230 if (m_client) 231 m_client->textTrackRemoveCue(this, cue); 188 232 } 189 233 -
trunk/Source/WebCore/html/TextTrack.h
r101088 r101185 94 94 95 95 void addCue(PassRefPtr<TextTrackCue>, ExceptionCode&); 96 void removeCue(PassRefPtr<TextTrackCue>, ExceptionCode&); 97 98 void newCuesLoaded(); 99 void fetchNewestCues(Vector<TextTrackCue*>&); 96 void removeCue(TextTrackCue*, ExceptionCode&); 100 97 101 98 virtual void fireCueChangeEvent(); -
trunk/Source/WebCore/html/TextTrackCue.cpp
r100064 r101185 48 48 , m_endTime(end) 49 49 , m_content(content) 50 , m_pauseOnExit(pauseOnExit)51 50 , m_writingDirection(Horizontal) 52 , m_snapToLines(true)53 51 , m_linePosition(-1) 54 52 , m_textPosition(50) 55 53 , m_cueSize(100) 56 54 , m_cueAlignment(Middle) 55 , m_scriptExecutionContext(context) 57 56 , m_isActive(false) 58 , m_scriptExecutionContext(context) 57 , m_pauseOnExit(pauseOnExit) 58 , m_snapToLines(true) 59 59 { 60 60 parseSettings(settings); … … 67 67 TextTrack* TextTrackCue::track() const 68 68 { 69 return m_track ;70 } 71 72 void TextTrackCue::setTrack( TextTrack*track)69 return m_track.get(); 70 } 71 72 void TextTrackCue::setTrack(PassRefPtr<TextTrack>track) 73 73 { 74 74 m_track = track; -
trunk/Source/WebCore/html/TextTrackCue.h
r100064 r101185 58 58 59 59 TextTrack* track() const; 60 void setTrack( TextTrack*);60 void setTrack(PassRefPtr<TextTrack>); 61 61 62 62 String id() const; … … 101 101 virtual void derefEventTarget() { deref(); } 102 102 103 TextTrack* m_track;104 105 103 String m_id; 106 104 double m_startTime; 107 105 double m_endTime; 108 106 String m_content; 109 bool m_pauseOnExit;110 107 Direction m_writingDirection; 111 bool m_snapToLines;112 108 int m_linePosition; 113 109 int m_textPosition; … … 115 111 Alignment m_cueAlignment; 116 112 RefPtr<DocumentFragment> m_documentFragment; 113 RefPtr<TextTrack> m_track; 114 115 EventTargetData m_eventTargetData; 116 ScriptExecutionContext* m_scriptExecutionContext; 117 117 118 118 bool m_isActive; 119 120 EventTargetData m_eventTargetData; 121 ScriptExecutionContext* m_scriptExecutionContext; 119 bool m_pauseOnExit; 120 bool m_snapToLines; 122 121 }; 123 122 -
trunk/Source/WebCore/html/TextTrackCueList.cpp
r100085 r101185 71 71 } 72 72 73 void TextTrackCueList::add(const Vector<RefPtr<TextTrackCue> >& newCues)73 bool TextTrackCueList::add(PassRefPtr<TextTrackCue> cue) 74 74 { 75 for (size_t i = 0; i < newCues.size(); ++i) 76 add(newCues[i]); 75 return add(cue, 0, m_list.size()); 77 76 } 78 77 79 void TextTrackCueList::add(PassRefPtr<TextTrackCue> cue) 80 { 81 // WebVTT cue timings 82 // 1. The time represented by this WebVTT timestamp must be greater than or equal 83 // to the start time offsets of all previous cues in the file. 84 // http://www.whatwg.org/specs/web-apps/current-work/#webvtt-cue-timings 85 // Note: because this requirement is specific to WebVTT, we may want to check first 86 // whether the cues in this list came from a WebVTT file. 87 if (!m_list.isEmpty() && cue->startTime() < m_list.last()->startTime()) 88 return; 89 add(cue, 0, m_list.size()); 90 } 91 92 void TextTrackCueList::add(PassRefPtr<TextTrackCue> cue, size_t start, size_t end) 78 bool TextTrackCueList::add(PassRefPtr<TextTrackCue> prpCue, size_t start, size_t end) 93 79 { 94 80 ASSERT(start <= m_list.size()); … … 97 83 // Maintain text track cue order: 98 84 // http://www.whatwg.org/specs/web-apps/current-work/#text-track-cue-order 99 RefPtr<TextTrackCue> newCue = cue;85 RefPtr<TextTrackCue> cue = prpCue; 100 86 if (start == end) { 101 m_list.insert(start, newCue); 102 return; 87 if (!m_list.isEmpty() && (m_list[start - 1].get() == cue.get())) 88 return false; 89 90 m_list.insert(start, cue); 91 return true; 103 92 } 104 93 105 94 size_t index = (start + end) / 2; 106 if ( newCue->startTime() < m_list[index]->startTime() || (newCue->startTime() == m_list[index]->startTime() && newCue->endTime() > m_list[index]->endTime()))107 add(newCue.release(), start, index);108 else 109 add(newCue.release(), index + 1, end);95 if (cue->startTime() < m_list[index]->startTime() || (cue->startTime() == m_list[index]->startTime() && cue->endTime() > m_list[index]->endTime())) 96 return add(cue.release(), start, index); 97 98 return add(cue.release(), index + 1, end); 110 99 } 111 100 112 voidTextTrackCueList::remove(TextTrackCue* cue)101 bool TextTrackCueList::remove(TextTrackCue* cue) 113 102 { 114 103 size_t index = m_list.find(cue); 115 104 if (index == notFound) 116 return; 105 return false; 106 117 107 cue->setIsActive(false); 118 108 m_list.remove(index); 109 return true; 119 110 } 120 111 -
trunk/Source/WebCore/html/TextTrackCueList.h
r100064 r101185 50 50 TextTrackCueList* activeCues(); 51 51 52 void add(PassRefPtr<TextTrackCue>); 53 void add(const Vector<RefPtr<TextTrackCue> >&); 54 void remove(TextTrackCue*); 52 bool add(PassRefPtr<TextTrackCue>); 53 bool remove(TextTrackCue*); 55 54 bool contains(TextTrackCue*) const; 56 55 57 56 private: 58 57 TextTrackCueList(); 59 voidadd(PassRefPtr<TextTrackCue>, size_t, size_t);58 bool add(PassRefPtr<TextTrackCue>, size_t, size_t); 60 59 void clear(); 61 60 -
trunk/Source/WebCore/loader/TextTrackLoader.cpp
r99984 r101185 146 146 processNewCueData(resource); 147 147 148 m_state = resource->errorOccurred() ? Failed : Finished; 148 if (m_state != Failed) 149 m_state = resource->errorOccurred() ? Failed : Finished; 149 150 150 151 if (!m_cueLoadTimer.isActive())
Note:
See TracChangeset
for help on using the changeset viewer.