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

Unified Diff: Source/core/html/HTMLMediaElement.cpp

Issue 353383003: Use Traversal<HTMLSourceElement> to find the next source candidate (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLMediaElement.cpp
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp
index fc8703819fa07c010facb070678d03f1f8120be2..d7565bb8e95c7a65cc174d6077ce4796a5a37240 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -711,7 +711,7 @@ void HTMLMediaElement::prepareForLoad()
// 1 - Abort any already-running instance of the resource selection algorithm for this element.
m_loadState = WaitingForSource;
- m_currentSourceNode = nullptr;
+ m_currentSourceElement = nullptr;
// 2 - If there are any tasks from the media element's media element event task source in
// one of the task queues, then remove those tasks.
@@ -826,8 +826,8 @@ void HTMLMediaElement::selectMediaResource()
// source element child in tree order.
if (HTMLSourceElement* element = Traversal<HTMLSourceElement>::firstChild(*this)) {
mode = children;
- m_nextChildNodeToConsider = element;
- m_currentSourceNode = nullptr;
+ m_nextSourceElement = element;
+ m_currentSourceElement = nullptr;
} else {
// Otherwise the media element has neither a src attribute nor a source element
// child: set the networkState to NETWORK_EMPTY, and abort these steps; the
@@ -1543,7 +1543,7 @@ void HTMLMediaElement::noneSupported()
stopPeriodicTimers();
m_loadState = WaitingForSource;
- m_currentSourceNode = nullptr;
+ m_currentSourceElement = nullptr;
// 4.8.10.5
// 6 - Reaching this step indicates that the media resource failed to load or that the given
@@ -1599,7 +1599,7 @@ void HTMLMediaElement::mediaEngineError(PassRefPtrWillBeRawPtr<MediaError> err)
setShouldDelayLoadEvent(false);
// 6 - Abort the overall resource selection algorithm.
- m_currentSourceNode = nullptr;
+ m_currentSourceElement = nullptr;
}
void HTMLMediaElement::cancelPendingEventsAndCallbacks()
@@ -1626,8 +1626,8 @@ void HTMLMediaElement::mediaLoadingFailed(MediaPlayer::NetworkState error)
// resource selection algorithm
// Step 9.Otherwise.9 - Failed with elements: Queue a task, using the DOM manipulation task source, to fire a simple event named error at the candidate element.
- if (m_currentSourceNode)
- m_currentSourceNode->scheduleErrorEvent();
+ if (m_currentSourceElement)
+ m_currentSourceElement->scheduleErrorEvent();
else
WTF_LOG(Media, "HTMLMediaElement::setNetworkState - error event not sent, <source> was removed");
@@ -2830,13 +2830,13 @@ bool HTMLMediaElement::havePotentialSourceChild()
{
// Stash the current <source> node and next nodes so we can restore them after checking
// to see there is another potential.
- RefPtrWillBeRawPtr<HTMLSourceElement> currentSourceNode = m_currentSourceNode;
- RefPtrWillBeRawPtr<Node> nextNode = m_nextChildNodeToConsider;
+ RefPtrWillBeRawPtr<HTMLSourceElement> currentSourceElement = m_currentSourceElement;
+ RefPtrWillBeRawPtr<HTMLSourceElement> nextSourceElement = m_nextSourceElement;
KURL nextURL = selectNextSourceChild(0, 0, DoNothing);
- m_currentSourceNode = currentSourceNode;
- m_nextChildNodeToConsider = nextNode;
+ m_currentSourceElement = currentSourceElement;
+ m_nextSourceElement = nextSourceElement;
return nextURL.isValid();
}
@@ -2850,7 +2850,7 @@ KURL HTMLMediaElement::selectNextSourceChild(ContentType* contentType, String* k
WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild");
#endif
- if (!m_nextChildNodeToConsider) {
+ if (!m_nextSourceElement) {
#if !LOG_DISABLED
if (shouldLog)
WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild -> 0x0000, \"\"");
@@ -2863,7 +2863,7 @@ KURL HTMLMediaElement::selectNextSourceChild(ContentType* contentType, String* k
HTMLSourceElement* source = 0;
String type;
String system;
- bool lookingForStartNode = m_nextChildNodeToConsider;
+ bool lookingForStartNode = m_nextSourceElement;
bool canUseSourceElement = false;
NodeVector potentialSourceNodes;
@@ -2871,7 +2871,7 @@ KURL HTMLMediaElement::selectNextSourceChild(ContentType* contentType, String* k
for (unsigned i = 0; !canUseSourceElement && i < potentialSourceNodes.size(); ++i) {
node = potentialSourceNodes[i].get();
- if (lookingForStartNode && m_nextChildNodeToConsider != node)
+ if (lookingForStartNode && m_nextSourceElement != node)
continue;
lookingForStartNode = false;
@@ -2921,16 +2921,16 @@ check_again:
*contentType = ContentType(type);
if (keySystem)
*keySystem = system;
- m_currentSourceNode = source;
- m_nextChildNodeToConsider = source->nextSibling();
+ m_currentSourceElement = source;
+ m_nextSourceElement = Traversal<HTMLSourceElement>::nextSibling(*source);
} else {
- m_currentSourceNode = nullptr;
- m_nextChildNodeToConsider = nullptr;
+ m_currentSourceElement = nullptr;
+ m_nextSourceElement = nullptr;
}
#if !LOG_DISABLED
if (shouldLog)
- WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild -> %p, %s", m_currentSourceNode.get(), canUseSourceElement ? urlForLoggingMedia(mediaURL).utf8().data() : "");
+ WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild -> %p, %s", m_currentSourceElement.get(), canUseSourceElement ? urlForLoggingMedia(mediaURL).utf8().data() : "");
#endif
return canUseSourceElement ? mediaURL : KURL();
}
@@ -2953,17 +2953,17 @@ void HTMLMediaElement::sourceWasAdded(HTMLSourceElement* source)
// the media element's resource selection algorithm.
if (networkState() == HTMLMediaElement::NETWORK_EMPTY) {
scheduleDelayedAction(LoadMediaResource);
- m_nextChildNodeToConsider = source;
+ m_nextSourceElement = source;
return;
}
- if (m_currentSourceNode && source == m_currentSourceNode->nextSibling()) {
+ if (m_currentSourceElement && source == Traversal<HTMLSourceElement>::nextSibling(*m_currentSourceElement)) {
WTF_LOG(Media, "HTMLMediaElement::sourceWasAdded - <source> inserted immediately after current source");
- m_nextChildNodeToConsider = source;
+ m_nextSourceElement = source;
return;
}
- if (m_nextChildNodeToConsider)
+ if (m_nextSourceElement)
return;
// 4.8.9.5, resource selection algorithm, source elements section:
@@ -2977,7 +2977,7 @@ void HTMLMediaElement::sourceWasAdded(HTMLSourceElement* source)
m_networkState = NETWORK_LOADING;
// 25. Jump back to the find next candidate step above.
- m_nextChildNodeToConsider = source;
+ m_nextSourceElement = source;
scheduleNextSourceChild();
}
@@ -2990,19 +2990,19 @@ void HTMLMediaElement::sourceWasRemoved(HTMLSourceElement* source)
WTF_LOG(Media, "HTMLMediaElement::sourceWasRemoved - 'src' is %s", urlForLoggingMedia(url).utf8().data());
#endif
- if (source != m_currentSourceNode && source != m_nextChildNodeToConsider)
+ if (source != m_currentSourceElement && source != m_nextSourceElement)
return;
- if (source == m_nextChildNodeToConsider) {
- if (m_currentSourceNode)
- m_nextChildNodeToConsider = m_currentSourceNode->nextSibling();
- WTF_LOG(Media, "HTMLMediaElement::sourceRemoved - m_nextChildNodeToConsider set to %p", m_nextChildNodeToConsider.get());
- } else if (source == m_currentSourceNode) {
- // Clear the current source node pointer, but don't change the movie as the spec says:
+ if (source == m_nextSourceElement) {
+ if (m_currentSourceElement)
+ m_nextSourceElement = Traversal<HTMLSourceElement>::nextSibling(*m_currentSourceElement);
+ WTF_LOG(Media, "HTMLMediaElement::sourceRemoved - m_nextSourceElement set to %p", m_nextSourceElement.get());
+ } else if (source == m_currentSourceElement) {
+ // Clear the current source element pointer, but don't change the movie as the spec says:
// 4.8.8 - Dynamically modifying a source element and its attribute when the element is already
// inserted in a video or audio element will have no effect.
- m_currentSourceNode = nullptr;
- WTF_LOG(Media, "HTMLMediaElement::sourceRemoved - m_currentSourceNode set to 0");
+ m_currentSourceElement = nullptr;
+ WTF_LOG(Media, "HTMLMediaElement::sourceRemoved - m_currentSourceElement set to 0");
}
}
@@ -3365,7 +3365,7 @@ void HTMLMediaElement::userCancelledLoad()
setShouldDelayLoadEvent(false);
// 6 - Abort the overall resource selection algorithm.
- m_currentSourceNode = nullptr;
+ m_currentSourceElement = nullptr;
// Reset m_readyState since m_player is gone.
m_readyState = HAVE_NOTHING;
@@ -3914,8 +3914,8 @@ void HTMLMediaElement::trace(Visitor* visitor)
{
visitor->trace(m_asyncEventQueue);
visitor->trace(m_error);
- visitor->trace(m_currentSourceNode);
- visitor->trace(m_nextChildNodeToConsider);
+ visitor->trace(m_currentSourceElement);
+ visitor->trace(m_nextSourceElement);
visitor->trace(m_audioTracks);
visitor->trace(m_videoTracks);
visitor->trace(m_textTracks);
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698