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

Side by Side Diff: Source/core/html/HTMLTrackElement.cpp

Issue 60763002: Never create HTMLTrackElement when VideoTrack is not enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: consistency Created 7 years, 1 month 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
« no previous file with comments | « Source/core/html/HTMLTagNames.in ('k') | Source/platform/RuntimeEnabledFeatures.in » ('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
(...skipping 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/html/HTMLTrackElement.h" 27 #include "core/html/HTMLTrackElement.h"
28 28
29 #include "HTMLNames.h" 29 #include "HTMLNames.h"
30 #include "bindings/v8/ExceptionStatePlaceholder.h" 30 #include "bindings/v8/ExceptionStatePlaceholder.h"
31 #include "core/events/Event.h" 31 #include "core/events/Event.h"
32 #include "core/html/HTMLMediaElement.h" 32 #include "core/html/HTMLMediaElement.h"
33 #include "core/frame/ContentSecurityPolicy.h" 33 #include "core/frame/ContentSecurityPolicy.h"
34 #include "RuntimeEnabledFeatures.h"
35 #include "platform/Logging.h" 34 #include "platform/Logging.h"
36 35
37 using namespace std; 36 using namespace std;
38 37
39 namespace WebCore { 38 namespace WebCore {
40 39
41 using namespace HTMLNames; 40 using namespace HTMLNames;
42 41
43 #if !LOG_DISABLED 42 #if !LOG_DISABLED
44 static String urlForLoggingTrack(const KURL& url) 43 static String urlForLoggingTrack(const KURL& url)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 86
88 void HTMLTrackElement::removedFrom(ContainerNode* insertionPoint) 87 void HTMLTrackElement::removedFrom(ContainerNode* insertionPoint)
89 { 88 {
90 if (!parentNode() && isHTMLMediaElement(insertionPoint)) 89 if (!parentNode() && isHTMLMediaElement(insertionPoint))
91 toHTMLMediaElement(insertionPoint)->didRemoveTrack(this); 90 toHTMLMediaElement(insertionPoint)->didRemoveTrack(this);
92 HTMLElement::removedFrom(insertionPoint); 91 HTMLElement::removedFrom(insertionPoint);
93 } 92 }
94 93
95 void HTMLTrackElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value) 94 void HTMLTrackElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value)
96 { 95 {
97 if (RuntimeEnabledFeatures::videoTrackEnabled()) { 96 if (name == srcAttr) {
98 if (name == srcAttr) { 97 if (!value.isEmpty())
99 if (!value.isEmpty()) 98 scheduleLoad();
100 scheduleLoad(); 99 else if (m_track)
101 else if (m_track) 100 m_track->removeAllCues();
102 m_track->removeAllCues();
103 101
104 // 4.8.10.12.3 Sourcing out-of-band text tracks 102 // 4.8.10.12.3 Sourcing out-of-band text tracks
105 // As the kind, label, and srclang attributes are set, changed, or remov ed, the text track must update accordingly... 103 // As the kind, label, and srclang attributes are set, changed, or removed, the text track must update accordingly...
106 } else if (name == kindAttr) 104 } else if (name == kindAttr) {
107 track()->setKind(value.lower()); 105 track()->setKind(value.lower());
108 else if (name == labelAttr) 106 } else if (name == labelAttr) {
109 track()->setLabel(value); 107 track()->setLabel(value);
110 else if (name == srclangAttr) 108 } else if (name == srclangAttr) {
111 track()->setLanguage(value); 109 track()->setLanguage(value);
112 else if (name == defaultAttr) 110 } else if (name == defaultAttr) {
113 track()->setIsDefault(!value.isNull()); 111 track()->setIsDefault(!value.isNull());
114 } 112 }
115 113
116 HTMLElement::parseAttribute(name, value); 114 HTMLElement::parseAttribute(name, value);
117 } 115 }
118 116
119 String HTMLTrackElement::kind() 117 String HTMLTrackElement::kind()
120 { 118 {
121 return track()->kind(); 119 return track()->kind();
122 } 120 }
123 121
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 178
181 void HTMLTrackElement::scheduleLoad() 179 void HTMLTrackElement::scheduleLoad()
182 { 180 {
183 LOG(Media, "HTMLTrackElement::scheduleLoad"); 181 LOG(Media, "HTMLTrackElement::scheduleLoad");
184 182
185 // 1. If another occurrence of this algorithm is already running for this te xt track and its track element, 183 // 1. If another occurrence of this algorithm is already running for this te xt track and its track element,
186 // abort these steps, letting that other algorithm take care of this element . 184 // abort these steps, letting that other algorithm take care of this element .
187 if (m_loadTimer.isActive()) 185 if (m_loadTimer.isActive())
188 return; 186 return;
189 187
190 if (!RuntimeEnabledFeatures::videoTrackEnabled())
191 return;
192
193 // 2. If the text track's text track mode is not set to one of hidden or sho wing, abort these steps. 188 // 2. If the text track's text track mode is not set to one of hidden or sho wing, abort these steps.
194 if (ensureTrack()->mode() != TextTrack::hiddenKeyword() && ensureTrack()->mo de() != TextTrack::showingKeyword()) 189 if (ensureTrack()->mode() != TextTrack::hiddenKeyword() && ensureTrack()->mo de() != TextTrack::showingKeyword())
195 return; 190 return;
196 191
197 // 3. If the text track's track element does not have a media element as a p arent, abort these steps. 192 // 3. If the text track's track element does not have a media element as a p arent, abort these steps.
198 if (!mediaElement()) 193 if (!mediaElement())
199 return; 194 return;
200 195
201 // 4. Run the remainder of these steps asynchronously, allowing whatever cau sed these steps to run to continue. 196 // 4. Run the remainder of these steps asynchronously, allowing whatever cau sed these steps to run to continue.
202 m_loadTimer.startOneShot(0); 197 m_loadTimer.startOneShot(0);
(...skipping 17 matching lines...) Expand all
220 if (!canLoadUrl(url)) { 215 if (!canLoadUrl(url)) {
221 didCompleteLoad(HTMLTrackElement::Failure); 216 didCompleteLoad(HTMLTrackElement::Failure);
222 return; 217 return;
223 } 218 }
224 219
225 ensureTrack()->scheduleLoad(url); 220 ensureTrack()->scheduleLoad(url);
226 } 221 }
227 222
228 bool HTMLTrackElement::canLoadUrl(const KURL& url) 223 bool HTMLTrackElement::canLoadUrl(const KURL& url)
229 { 224 {
230 if (!RuntimeEnabledFeatures::videoTrackEnabled())
231 return false;
232
233 HTMLMediaElement* parent = mediaElement(); 225 HTMLMediaElement* parent = mediaElement();
234 if (!parent) 226 if (!parent)
235 return false; 227 return false;
236 228
237 // 4.8.10.12.3 Sourcing out-of-band text tracks 229 // 4.8.10.12.3 Sourcing out-of-band text tracks
238 230
239 // 4. Download: If URL is not the empty string, perform a potentially CORS-e nabled fetch of URL, with the 231 // 4. Download: If URL is not the empty string, perform a potentially CORS-e nabled fetch of URL, with the
240 // mode being the state of the media element's crossorigin content attribute , the origin being the 232 // mode being the state of the media element's crossorigin content attribute , the origin being the
241 // origin of the media element's Document, and the default origin behaviour set to fail. 233 // origin of the media element's Document, and the default origin behaviour set to fail.
242 if (url.isEmpty()) 234 if (url.isEmpty())
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 HTMLMediaElement* HTMLTrackElement::mediaElement() const 339 HTMLMediaElement* HTMLTrackElement::mediaElement() const
348 { 340 {
349 Element* parent = parentElement(); 341 Element* parent = parentElement();
350 if (parent && parent->isMediaElement()) 342 if (parent && parent->isMediaElement())
351 return toHTMLMediaElement(parentNode()); 343 return toHTMLMediaElement(parentNode());
352 return 0; 344 return 0;
353 } 345 }
354 346
355 } 347 }
356 348
OLDNEW
« no previous file with comments | « Source/core/html/HTMLTagNames.in ('k') | Source/platform/RuntimeEnabledFeatures.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698