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

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

Issue 189923002: Use new Traversal<HTML*Element> API in HTML code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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/HTMLMapElement.cpp ('k') | Source/core/html/HTMLObjectElement.cpp » ('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) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple 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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 HTMLElement::parseAttribute(name, value); 451 HTMLElement::parseAttribute(name, value);
452 } 452 }
453 453
454 void HTMLMediaElement::finishParsingChildren() 454 void HTMLMediaElement::finishParsingChildren()
455 { 455 {
456 HTMLElement::finishParsingChildren(); 456 HTMLElement::finishParsingChildren();
457 457
458 if (!RuntimeEnabledFeatures::videoTrackEnabled()) 458 if (!RuntimeEnabledFeatures::videoTrackEnabled())
459 return; 459 return;
460 460
461 for (Element* child = ElementTraversal::firstWithin(*this); child; child = E lementTraversal::nextSibling(*child)) { 461 if (Traversal<HTMLTrackElement>::firstChild(*this))
462 if (child->hasTagName(trackTag)) { 462 scheduleDelayedAction(LoadTextTrackResource);
463 scheduleDelayedAction(LoadTextTrackResource);
464 break;
465 }
466 }
467 } 463 }
468 464
469 bool HTMLMediaElement::rendererIsNeeded(const RenderStyle& style) 465 bool HTMLMediaElement::rendererIsNeeded(const RenderStyle& style)
470 { 466 {
471 return controls() ? HTMLElement::rendererIsNeeded(style) : false; 467 return controls() ? HTMLElement::rendererIsNeeded(style) : false;
472 } 468 }
473 469
474 RenderObject* HTMLMediaElement::createRenderer(RenderStyle*) 470 RenderObject* HTMLMediaElement::createRenderer(RenderStyle*)
475 { 471 {
476 return new RenderMedia(this); 472 return new RenderMedia(this);
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 749
754 void HTMLMediaElement::selectMediaResource() 750 void HTMLMediaElement::selectMediaResource()
755 { 751 {
756 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource"); 752 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource");
757 753
758 enum Mode { attribute, children }; 754 enum Mode { attribute, children };
759 755
760 // 3 - If the media element has a src attribute, then let mode be attribute. 756 // 3 - If the media element has a src attribute, then let mode be attribute.
761 Mode mode = attribute; 757 Mode mode = attribute;
762 if (!fastHasAttribute(srcAttr)) { 758 if (!fastHasAttribute(srcAttr)) {
763 Element* element;
764 for (element = ElementTraversal::firstWithin(*this); element; element = ElementTraversal::nextSibling(*element)) {
765 if (element->hasTagName(sourceTag))
766 break;
767 }
768
769 // Otherwise, if the media element does not have a src attribute but has a source 759 // Otherwise, if the media element does not have a src attribute but has a source
770 // element child, then let mode be children and let candidate be the fir st such 760 // element child, then let mode be children and let candidate be the fir st such
771 // source element child in tree order. 761 // source element child in tree order.
772 if (element) { 762 if (HTMLSourceElement* element = Traversal<HTMLSourceElement>::firstChil d(*this)) {
773 mode = children; 763 mode = children;
774 m_nextChildNodeToConsider = element; 764 m_nextChildNodeToConsider = element;
775 m_currentSourceNode = nullptr; 765 m_currentSourceNode = nullptr;
776 } else { 766 } else {
777 // Otherwise the media element has neither a src attribute nor a sou rce element 767 // Otherwise the media element has neither a src attribute nor a sou rce element
778 // child: set the networkState to NETWORK_EMPTY, and abort these ste ps; the 768 // child: set the networkState to NETWORK_EMPTY, and abort these ste ps; the
779 // synchronous section ends. 769 // synchronous section ends.
780 m_loadState = WaitingForSource; 770 m_loadState = WaitingForSource;
781 setShouldDelayLoadEvent(false); 771 setShouldDelayLoadEvent(false);
782 m_networkState = NETWORK_EMPTY; 772 m_networkState = NETWORK_EMPTY;
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 1193
1204 void HTMLMediaElement::textTrackModeChanged(TextTrack* track) 1194 void HTMLMediaElement::textTrackModeChanged(TextTrack* track)
1205 { 1195 {
1206 if (track->trackType() == TextTrack::TrackElement) { 1196 if (track->trackType() == TextTrack::TrackElement) {
1207 // 4.8.10.12.3 Sourcing out-of-band text tracks 1197 // 4.8.10.12.3 Sourcing out-of-band text tracks
1208 // ... when a text track corresponding to a track element is created wit h text track 1198 // ... when a text track corresponding to a track element is created wit h text track
1209 // mode set to disabled and subsequently changes its text track mode to hidden, showing, 1199 // mode set to disabled and subsequently changes its text track mode to hidden, showing,
1210 // or showing by default for the first time, the user agent must immedia tely and synchronously 1200 // or showing by default for the first time, the user agent must immedia tely and synchronously
1211 // run the following algorithm ... 1201 // run the following algorithm ...
1212 1202
1213 for (Element* child = ElementTraversal::firstWithin(*this); child; child = ElementTraversal::nextSibling(*child)) { 1203 for (HTMLTrackElement* trackElement = Traversal<HTMLTrackElement>::first Child(*this); trackElement; trackElement = Traversal<HTMLTrackElement>::nextSibl ing(*trackElement)) {
1214 if (!child->hasTagName(trackTag))
1215 continue;
1216 HTMLTrackElement* trackElement = toHTMLTrackElement(child);
1217 if (trackElement->track() != track) 1204 if (trackElement->track() != track)
1218 continue; 1205 continue;
1219 1206
1220 // Mark this track as "configured" so configureTextTracks won't chan ge the mode again. 1207 // Mark this track as "configured" so configureTextTracks won't chan ge the mode again.
1221 track->setHasBeenConfigured(true); 1208 track->setHasBeenConfigured(true);
1222 if (track->mode() != TextTrack::disabledKeyword()) { 1209 if (track->mode() != TextTrack::disabledKeyword()) {
1223 if (trackElement->readyState() == HTMLTrackElement::LOADED) 1210 if (trackElement->readyState() == HTMLTrackElement::LOADED)
1224 textTrackAddCues(track, track->cues()); 1211 textTrackAddCues(track, track->cues());
1225 1212
1226 // If this is the first added track, create the list of text tra cks. 1213 // If this is the first added track, create the list of text tra cks.
1227 if (!m_textTracks) 1214 if (!m_textTracks)
1228 m_textTracks = TextTrackList::create(this); 1215 m_textTracks = TextTrackList::create(this);
1229 } 1216 }
1230 break; 1217 break;
1231 } 1218 }
1232 } else if (track->trackType() == TextTrack::AddTrack && track->mode() != Tex tTrack::disabledKeyword()) 1219 } else if (track->trackType() == TextTrack::AddTrack && track->mode() != Tex tTrack::disabledKeyword()) {
1233 textTrackAddCues(track, track->cues()); 1220 textTrackAddCues(track, track->cues());
1221 }
1234 1222
1235 configureTextTrackDisplay(AssumeVisibleChange); 1223 configureTextTrackDisplay(AssumeVisibleChange);
1236 1224
1237 ASSERT(textTracks()->contains(track)); 1225 ASSERT(textTracks()->contains(track));
1238 textTracks()->scheduleChangeEvent(); 1226 textTracks()->scheduleChangeEvent();
1239 } 1227 }
1240 1228
1241 void HTMLMediaElement::textTrackKindChanged(TextTrack* track) 1229 void HTMLMediaElement::textTrackKindChanged(TextTrack* track)
1242 { 1230 {
1243 if (track->kind() != TextTrack::captionsKeyword() && track->kind() != TextTr ack::subtitlesKeyword() && track->mode() == TextTrack::showingKeyword()) 1231 if (track->kind() != TextTrack::captionsKeyword() && track->kind() != TextTr ack::subtitlesKeyword() && track->mode() == TextTrack::showingKeyword())
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 1424
1437 // 6 - Abort the overall resource selection algorithm. 1425 // 6 - Abort the overall resource selection algorithm.
1438 m_currentSourceNode = nullptr; 1426 m_currentSourceNode = nullptr;
1439 } 1427 }
1440 1428
1441 void HTMLMediaElement::cancelPendingEventsAndCallbacks() 1429 void HTMLMediaElement::cancelPendingEventsAndCallbacks()
1442 { 1430 {
1443 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks"); 1431 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks");
1444 m_asyncEventQueue->cancelAllEvents(); 1432 m_asyncEventQueue->cancelAllEvents();
1445 1433
1446 for (Element* child = ElementTraversal::firstWithin(*this); child; child = E lementTraversal::nextSibling(*child)) { 1434 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source))
1447 if (child->hasTagName(sourceTag)) 1435 source->cancelPendingErrorEvent();
1448 toHTMLSourceElement(child)->cancelPendingErrorEvent();
1449 }
1450 } 1436 }
1451 1437
1452 void HTMLMediaElement::mediaPlayerNetworkStateChanged() 1438 void HTMLMediaElement::mediaPlayerNetworkStateChanged()
1453 { 1439 {
1454 setNetworkState(m_player->networkState()); 1440 setNetworkState(m_player->networkState());
1455 } 1441 }
1456 1442
1457 void HTMLMediaElement::mediaLoadingFailed(MediaPlayer::NetworkState error) 1443 void HTMLMediaElement::mediaLoadingFailed(MediaPlayer::NetworkState error)
1458 { 1444 {
1459 stopPeriodicTimers(); 1445 stopPeriodicTimers();
(...skipping 2469 matching lines...) Expand 10 before | Expand all | Expand 10 after
3929 { 3915 {
3930 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); 3916 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource));
3931 } 3917 }
3932 3918
3933 bool HTMLMediaElement::isInteractiveContent() const 3919 bool HTMLMediaElement::isInteractiveContent() const
3934 { 3920 {
3935 return fastHasAttribute(controlsAttr); 3921 return fastHasAttribute(controlsAttr);
3936 } 3922 }
3937 3923
3938 } 3924 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLMapElement.cpp ('k') | Source/core/html/HTMLObjectElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698