Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: Source/core/html/track/LoadableTextTrack.cpp

Issue 177003025: Remove TextTrackClient interface to simplify TextTrack code. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/track/LoadableTextTrack.h ('k') | Source/core/html/track/TextTrack.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/html/track/LoadableTextTrack.h" 27 #include "core/html/track/LoadableTextTrack.h"
28 28
29 #include "core/dom/ElementTraversal.h" 29 #include "core/dom/ElementTraversal.h"
30 #include "core/html/HTMLMediaElement.h"
30 #include "core/html/HTMLTrackElement.h" 31 #include "core/html/HTMLTrackElement.h"
31 #include "core/html/track/TextTrackCueList.h" 32 #include "core/html/track/TextTrackCueList.h"
32 #include "core/html/track/vtt/VTTRegionList.h" 33 #include "core/html/track/vtt/VTTRegionList.h"
33 34
34 namespace WebCore { 35 namespace WebCore {
35 36
36 using namespace HTMLNames; 37 using namespace HTMLNames;
37 38
38 LoadableTextTrack::LoadableTextTrack(HTMLTrackElement* track) 39 LoadableTextTrack::LoadableTextTrack(HTMLTrackElement* track)
39 : TextTrack(track->document(), track, emptyAtom, emptyAtom, emptyAtom, empty Atom, TrackElement) 40 : TextTrack(track->document(), emptyAtom, emptyAtom, emptyAtom, emptyAtom, T rackElement)
40 , m_trackElement(track) 41 , m_trackElement(track)
41 , m_loadTimer(this, &LoadableTextTrack::loadTimerFired) 42 , m_loadTimer(this, &LoadableTextTrack::loadTimerFired)
42 , m_isDefault(false) 43 , m_isDefault(false)
43 { 44 {
44 } 45 }
45 46
46 LoadableTextTrack::~LoadableTextTrack() 47 LoadableTextTrack::~LoadableTextTrack()
47 { 48 {
49 ASSERT(!m_trackElement);
48 } 50 }
49 51
50 void LoadableTextTrack::clearClient() 52 void LoadableTextTrack::clearTrackElement()
51 { 53 {
52 m_trackElement = 0; 54 m_trackElement = 0;
53 TextTrack::clearClient(); 55 }
56
57 void LoadableTextTrack::setMode(const AtomicString& mode)
58 {
59 TextTrack::setMode(mode);
60 if (!m_trackElement)
61 return;
62
63 if (m_trackElement->readyState() == HTMLTrackElement::NONE)
64 m_trackElement->scheduleLoad();
54 } 65 }
55 66
56 void LoadableTextTrack::scheduleLoad(const KURL& url) 67 void LoadableTextTrack::scheduleLoad(const KURL& url)
57 { 68 {
58 if (url == m_url) { 69 if (url == m_url) {
59 // If loading of the resource from this URL is in progress, return early . 70 // If loading of the resource from this URL is in progress, return early .
60 ASSERT(m_loader && m_trackElement); 71 ASSERT(m_loader && m_trackElement);
61 if (m_loader->loadState() < TextTrackLoader::Finished) 72 if (m_loader->loadState() < TextTrackLoader::Finished)
62 return; 73 return;
63 74
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 m_loader->getNewCues(newCues); 115 m_loader->getNewCues(newCues);
105 116
106 if (!m_cues) 117 if (!m_cues)
107 m_cues = TextTrackCueList::create(); 118 m_cues = TextTrackCueList::create();
108 119
109 for (size_t i = 0; i < newCues.size(); ++i) { 120 for (size_t i = 0; i < newCues.size(); ++i) {
110 newCues[i]->setTrack(this); 121 newCues[i]->setTrack(this);
111 m_cues->add(newCues[i]); 122 m_cues->add(newCues[i]);
112 } 123 }
113 124
114 if (client()) 125 if (mediaElement())
115 client()->textTrackAddCues(this, m_cues.get()); 126 mediaElement()->textTrackAddCues(this, m_cues.get());
116 } 127 }
117 128
118 void LoadableTextTrack::cueLoadingCompleted(TextTrackLoader* loader, bool loadin gFailed) 129 void LoadableTextTrack::cueLoadingCompleted(TextTrackLoader* loader, bool loadin gFailed)
119 { 130 {
120 ASSERT_UNUSED(loader, m_loader == loader); 131 ASSERT_UNUSED(loader, m_loader == loader);
121 132
122 if (!m_trackElement) 133 if (!m_trackElement)
123 return; 134 return;
124 135
125 m_trackElement->didCompleteLoad(loadingFailed ? HTMLTrackElement::Failure : HTMLTrackElement::Success); 136 m_trackElement->didCompleteLoad(loadingFailed ? HTMLTrackElement::Failure : HTMLTrackElement::Success);
(...skipping 24 matching lines...) Expand all
150 if (child == m_trackElement) 161 if (child == m_trackElement)
151 return index; 162 return index;
152 ++index; 163 ++index;
153 } 164 }
154 ASSERT_NOT_REACHED(); 165 ASSERT_NOT_REACHED();
155 166
156 return 0; 167 return 0;
157 } 168 }
158 169
159 } // namespace WebCore 170 } // namespace WebCore
160
OLDNEW
« no previous file with comments | « Source/core/html/track/LoadableTextTrack.h ('k') | Source/core/html/track/TextTrack.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698