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

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

Issue 171663005: Consistently use ElementTraversal API when looking for an Element (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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/HTMLDetailsElement.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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 HTMLElement::parseAttribute(name, value); 457 HTMLElement::parseAttribute(name, value);
458 } 458 }
459 459
460 void HTMLMediaElement::finishParsingChildren() 460 void HTMLMediaElement::finishParsingChildren()
461 { 461 {
462 HTMLElement::finishParsingChildren(); 462 HTMLElement::finishParsingChildren();
463 463
464 if (!RuntimeEnabledFeatures::videoTrackEnabled()) 464 if (!RuntimeEnabledFeatures::videoTrackEnabled())
465 return; 465 return;
466 466
467 for (Node* node = firstChild(); node; node = node->nextSibling()) { 467 for (Element* child = ElementTraversal::firstWithin(*this); child; child = E lementTraversal::nextSibling(*child)) {
468 if (node->hasTagName(trackTag)) { 468 if (child->hasTagName(trackTag)) {
469 scheduleDelayedAction(LoadTextTrackResource); 469 scheduleDelayedAction(LoadTextTrackResource);
470 break; 470 break;
471 } 471 }
472 } 472 }
473 } 473 }
474 474
475 bool HTMLMediaElement::rendererIsNeeded(const RenderStyle& style) 475 bool HTMLMediaElement::rendererIsNeeded(const RenderStyle& style)
476 { 476 {
477 return controls() ? HTMLElement::rendererIsNeeded(style) : false; 477 return controls() ? HTMLElement::rendererIsNeeded(style) : false;
478 } 478 }
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 733
734 void HTMLMediaElement::selectMediaResource() 734 void HTMLMediaElement::selectMediaResource()
735 { 735 {
736 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource"); 736 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource");
737 737
738 enum Mode { attribute, children }; 738 enum Mode { attribute, children };
739 739
740 // 3 - If the media element has a src attribute, then let mode be attribute. 740 // 3 - If the media element has a src attribute, then let mode be attribute.
741 Mode mode = attribute; 741 Mode mode = attribute;
742 if (!fastHasAttribute(srcAttr)) { 742 if (!fastHasAttribute(srcAttr)) {
743 Node* node; 743 Element* element;
744 for (node = firstChild(); node; node = node->nextSibling()) { 744 for (element = ElementTraversal::firstWithin(*this); element; element = ElementTraversal::nextSibling(*element)) {
745 if (node->hasTagName(sourceTag)) 745 if (element->hasTagName(sourceTag))
746 break; 746 break;
747 } 747 }
748 748
749 // Otherwise, if the media element does not have a src attribute but has a source 749 // Otherwise, if the media element does not have a src attribute but has a source
750 // element child, then let mode be children and let candidate be the fir st such 750 // element child, then let mode be children and let candidate be the fir st such
751 // source element child in tree order. 751 // source element child in tree order.
752 if (node) { 752 if (element) {
753 mode = children; 753 mode = children;
754 m_nextChildNodeToConsider = node; 754 m_nextChildNodeToConsider = element;
755 m_currentSourceNode = 0; 755 m_currentSourceNode = 0;
756 } else { 756 } else {
757 // Otherwise the media element has neither a src attribute nor a sou rce element 757 // Otherwise the media element has neither a src attribute nor a sou rce element
758 // child: set the networkState to NETWORK_EMPTY, and abort these ste ps; the 758 // child: set the networkState to NETWORK_EMPTY, and abort these ste ps; the
759 // synchronous section ends. 759 // synchronous section ends.
760 m_loadState = WaitingForSource; 760 m_loadState = WaitingForSource;
761 setShouldDelayLoadEvent(false); 761 setShouldDelayLoadEvent(false);
762 m_networkState = NETWORK_EMPTY; 762 m_networkState = NETWORK_EMPTY;
763 763
764 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource, nothing to lo ad"); 764 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource, nothing to lo ad");
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 1183
1184 void HTMLMediaElement::textTrackModeChanged(TextTrack* track) 1184 void HTMLMediaElement::textTrackModeChanged(TextTrack* track)
1185 { 1185 {
1186 if (track->trackType() == TextTrack::TrackElement) { 1186 if (track->trackType() == TextTrack::TrackElement) {
1187 // 4.8.10.12.3 Sourcing out-of-band text tracks 1187 // 4.8.10.12.3 Sourcing out-of-band text tracks
1188 // ... when a text track corresponding to a track element is created wit h text track 1188 // ... when a text track corresponding to a track element is created wit h text track
1189 // mode set to disabled and subsequently changes its text track mode to hidden, showing, 1189 // mode set to disabled and subsequently changes its text track mode to hidden, showing,
1190 // or showing by default for the first time, the user agent must immedia tely and synchronously 1190 // or showing by default for the first time, the user agent must immedia tely and synchronously
1191 // run the following algorithm ... 1191 // run the following algorithm ...
1192 1192
1193 for (Node* node = firstChild(); node; node = node->nextSibling()) { 1193 for (Element* child = ElementTraversal::firstWithin(*this); child; child = ElementTraversal::nextSibling(*child)) {
1194 if (!node->hasTagName(trackTag)) 1194 if (!child->hasTagName(trackTag))
1195 continue; 1195 continue;
1196 HTMLTrackElement* trackElement = toHTMLTrackElement(node); 1196 HTMLTrackElement* trackElement = toHTMLTrackElement(child);
1197 if (trackElement->track() != track) 1197 if (trackElement->track() != track)
1198 continue; 1198 continue;
1199 1199
1200 // Mark this track as "configured" so configureTextTracks won't chan ge the mode again. 1200 // Mark this track as "configured" so configureTextTracks won't chan ge the mode again.
1201 track->setHasBeenConfigured(true); 1201 track->setHasBeenConfigured(true);
1202 if (track->mode() != TextTrack::disabledKeyword()) { 1202 if (track->mode() != TextTrack::disabledKeyword()) {
1203 if (trackElement->readyState() == HTMLTrackElement::LOADED) 1203 if (trackElement->readyState() == HTMLTrackElement::LOADED)
1204 textTrackAddCues(track, track->cues()); 1204 textTrackAddCues(track, track->cues());
1205 1205
1206 // If this is the first added track, create the list of text tra cks. 1206 // If this is the first added track, create the list of text tra cks.
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 1415
1416 // 6 - Abort the overall resource selection algorithm. 1416 // 6 - Abort the overall resource selection algorithm.
1417 m_currentSourceNode = 0; 1417 m_currentSourceNode = 0;
1418 } 1418 }
1419 1419
1420 void HTMLMediaElement::cancelPendingEventsAndCallbacks() 1420 void HTMLMediaElement::cancelPendingEventsAndCallbacks()
1421 { 1421 {
1422 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks"); 1422 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks");
1423 m_asyncEventQueue->cancelAllEvents(); 1423 m_asyncEventQueue->cancelAllEvents();
1424 1424
1425 for (Node* node = firstChild(); node; node = node->nextSibling()) { 1425 for (Element* child = ElementTraversal::firstWithin(*this); child; child = E lementTraversal::nextSibling(*child)) {
1426 if (node->hasTagName(sourceTag)) 1426 if (child->hasTagName(sourceTag))
1427 toHTMLSourceElement(node)->cancelPendingErrorEvent(); 1427 toHTMLSourceElement(child)->cancelPendingErrorEvent();
1428 } 1428 }
1429 } 1429 }
1430 1430
1431 void HTMLMediaElement::mediaPlayerNetworkStateChanged() 1431 void HTMLMediaElement::mediaPlayerNetworkStateChanged()
1432 { 1432 {
1433 setNetworkState(m_player->networkState()); 1433 setNetworkState(m_player->networkState());
1434 } 1434 }
1435 1435
1436 void HTMLMediaElement::mediaLoadingFailed(MediaPlayer::NetworkState error) 1436 void HTMLMediaElement::mediaLoadingFailed(MediaPlayer::NetworkState error)
1437 { 1437 {
(...skipping 2482 matching lines...) Expand 10 before | Expand all | Expand 10 after
3920 { 3920 {
3921 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); 3921 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource));
3922 } 3922 }
3923 3923
3924 bool HTMLMediaElement::isInteractiveContent() const 3924 bool HTMLMediaElement::isInteractiveContent() const
3925 { 3925 {
3926 return fastHasAttribute(controlsAttr); 3926 return fastHasAttribute(controlsAttr);
3927 } 3927 }
3928 3928
3929 } 3929 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLDetailsElement.cpp ('k') | Source/core/html/HTMLObjectElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698