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

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

Issue 205583009: Remove VideoTrack runtime feature since we always support TextTracks. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 8 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 | « no previous file | Source/core/html/HTMLMediaElement.idl » ('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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 setMediaGroup(value); 420 setMediaGroup(value);
421 } else { 421 } else {
422 HTMLElement::parseAttribute(name, value); 422 HTMLElement::parseAttribute(name, value);
423 } 423 }
424 } 424 }
425 425
426 void HTMLMediaElement::finishParsingChildren() 426 void HTMLMediaElement::finishParsingChildren()
427 { 427 {
428 HTMLElement::finishParsingChildren(); 428 HTMLElement::finishParsingChildren();
429 429
430 if (!RuntimeEnabledFeatures::videoTrackEnabled())
431 return;
432
433 if (Traversal<HTMLTrackElement>::firstChild(*this)) 430 if (Traversal<HTMLTrackElement>::firstChild(*this))
434 scheduleDelayedAction(LoadTextTrackResource); 431 scheduleDelayedAction(LoadTextTrackResource);
435 } 432 }
436 433
437 bool HTMLMediaElement::rendererIsNeeded(const RenderStyle& style) 434 bool HTMLMediaElement::rendererIsNeeded(const RenderStyle& style)
438 { 435 {
439 return controls() ? HTMLElement::rendererIsNeeded(style) : false; 436 return controls() ? HTMLElement::rendererIsNeeded(style) : false;
440 } 437 }
441 438
442 RenderObject* HTMLMediaElement::createRenderer(RenderStyle*) 439 RenderObject* HTMLMediaElement::createRenderer(RenderStyle*)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 487
491 void HTMLMediaElement::scheduleDelayedAction(DelayedActionType actionType) 488 void HTMLMediaElement::scheduleDelayedAction(DelayedActionType actionType)
492 { 489 {
493 WTF_LOG(Media, "HTMLMediaElement::scheduleDelayedAction"); 490 WTF_LOG(Media, "HTMLMediaElement::scheduleDelayedAction");
494 491
495 if ((actionType & LoadMediaResource) && !(m_pendingActionFlags & LoadMediaRe source)) { 492 if ((actionType & LoadMediaResource) && !(m_pendingActionFlags & LoadMediaRe source)) {
496 prepareForLoad(); 493 prepareForLoad();
497 m_pendingActionFlags |= LoadMediaResource; 494 m_pendingActionFlags |= LoadMediaResource;
498 } 495 }
499 496
500 if (RuntimeEnabledFeatures::videoTrackEnabled() && (actionType & LoadTextTra ckResource)) 497 if (actionType & LoadTextTrackResource)
501 m_pendingActionFlags |= LoadTextTrackResource; 498 m_pendingActionFlags |= LoadTextTrackResource;
502 499
503 if (!m_loadTimer.isActive()) 500 if (!m_loadTimer.isActive())
504 m_loadTimer.startOneShot(0, FROM_HERE); 501 m_loadTimer.startOneShot(0, FROM_HERE);
505 } 502 }
506 503
507 void HTMLMediaElement::scheduleNextSourceChild() 504 void HTMLMediaElement::scheduleNextSourceChild()
508 { 505 {
509 // Schedule the timer to try the next <source> element WITHOUT resetting sta te ala prepareForLoad. 506 // Schedule the timer to try the next <source> element WITHOUT resetting sta te ala prepareForLoad.
510 m_pendingActionFlags |= LoadMediaResource; 507 m_pendingActionFlags |= LoadMediaResource;
511 m_loadTimer.startOneShot(0, FROM_HERE); 508 m_loadTimer.startOneShot(0, FROM_HERE);
512 } 509 }
513 510
514 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName) 511 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName)
515 { 512 {
516 scheduleEvent(Event::createCancelable(eventName)); 513 scheduleEvent(Event::createCancelable(eventName));
517 } 514 }
518 515
519 void HTMLMediaElement::scheduleEvent(PassRefPtr<Event> event) 516 void HTMLMediaElement::scheduleEvent(PassRefPtr<Event> event)
520 { 517 {
521 #if LOG_MEDIA_EVENTS 518 #if LOG_MEDIA_EVENTS
522 WTF_LOG(Media, "HTMLMediaElement::scheduleEvent - scheduling '%s'", event->t ype().ascii().data()); 519 WTF_LOG(Media, "HTMLMediaElement::scheduleEvent - scheduling '%s'", event->t ype().ascii().data());
523 #endif 520 #endif
524 m_asyncEventQueue->enqueueEvent(event); 521 m_asyncEventQueue->enqueueEvent(event);
525 } 522 }
526 523
527 void HTMLMediaElement::loadTimerFired(Timer<HTMLMediaElement>*) 524 void HTMLMediaElement::loadTimerFired(Timer<HTMLMediaElement>*)
528 { 525 {
529 if (RuntimeEnabledFeatures::videoTrackEnabled() && (m_pendingActionFlags & L oadTextTrackResource)) 526 if (m_pendingActionFlags & LoadTextTrackResource)
530 configureTextTracks(); 527 configureTextTracks();
531 528
532 if (m_pendingActionFlags & LoadMediaResource) { 529 if (m_pendingActionFlags & LoadMediaResource) {
533 if (m_loadState == LoadingFromSourceElement) 530 if (m_loadState == LoadingFromSourceElement)
534 loadNextSourceChild(); 531 loadNextSourceChild();
535 else 532 else
536 loadInternal(); 533 loadInternal();
537 } 534 }
538 535
539 m_pendingActionFlags = 0; 536 m_pendingActionFlags = 0;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 // FIXME: Make this less subtle. The position only becomes 0 because of the createMediaPlayer() call 653 // FIXME: Make this less subtle. The position only becomes 0 because of the createMediaPlayer() call
657 // above. 654 // above.
658 refreshCachedTime(); 655 refreshCachedTime();
659 invalidateCachedTime(); 656 invalidateCachedTime();
660 657
661 // 4.9 - Set the timeline offset to Not-a-Number (NaN). 658 // 4.9 - Set the timeline offset to Not-a-Number (NaN).
662 // 4.10 - Update the duration attribute to Not-a-Number (NaN). 659 // 4.10 - Update the duration attribute to Not-a-Number (NaN).
663 660
664 661
665 updateMediaController(); 662 updateMediaController();
666 if (RuntimeEnabledFeatures::videoTrackEnabled()) 663 updateActiveTextTrackCues(0);
667 updateActiveTextTrackCues(0);
668 } 664 }
669 665
670 // 5 - Set the playbackRate attribute to the value of the defaultPlaybackRat e attribute. 666 // 5 - Set the playbackRate attribute to the value of the defaultPlaybackRat e attribute.
671 setPlaybackRate(defaultPlaybackRate(), IGNORE_EXCEPTION); 667 setPlaybackRate(defaultPlaybackRate(), IGNORE_EXCEPTION);
672 668
673 // 6 - Set the error attribute to null and the autoplaying flag to true. 669 // 6 - Set the error attribute to null and the autoplaying flag to true.
674 m_error = nullptr; 670 m_error = nullptr;
675 m_autoplaying = true; 671 m_autoplaying = true;
676 672
677 // 7 - Invoke the media element's resource selection algorithm. 673 // 7 - Invoke the media element's resource selection algorithm.
(...skipping 18 matching lines...) Expand all
696 // event may have already fired by then. 692 // event may have already fired by then.
697 setShouldDelayLoadEvent(true); 693 setShouldDelayLoadEvent(true);
698 694
699 configureMediaControls(); 695 configureMediaControls();
700 } 696 }
701 697
702 void HTMLMediaElement::loadInternal() 698 void HTMLMediaElement::loadInternal()
703 { 699 {
704 // HTMLMediaElement::textTracksAreReady will need "... the text tracks whose mode was not in the 700 // HTMLMediaElement::textTracksAreReady will need "... the text tracks whose mode was not in the
705 // disabled state when the element's resource selection algorithm last start ed". 701 // disabled state when the element's resource selection algorithm last start ed".
706 if (RuntimeEnabledFeatures::videoTrackEnabled()) { 702 m_textTracksWhenResourceSelectionBegan.clear();
707 m_textTracksWhenResourceSelectionBegan.clear(); 703 if (m_textTracks) {
708 if (m_textTracks) { 704 for (unsigned i = 0; i < m_textTracks->length(); ++i) {
709 for (unsigned i = 0; i < m_textTracks->length(); ++i) { 705 TextTrack* track = m_textTracks->item(i);
710 TextTrack* track = m_textTracks->item(i); 706 if (track->mode() != TextTrack::disabledKeyword())
711 if (track->mode() != TextTrack::disabledKeyword()) 707 m_textTracksWhenResourceSelectionBegan.append(track);
712 m_textTracksWhenResourceSelectionBegan.append(track);
713 }
714 } 708 }
715 } 709 }
716 710
717 selectMediaResource(); 711 selectMediaResource();
718 } 712 }
719 713
720 void HTMLMediaElement::selectMediaResource() 714 void HTMLMediaElement::selectMediaResource()
721 { 715 {
722 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource"); 716 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource");
723 717
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 void HTMLMediaElement::setReadyState(MediaPlayer::ReadyState state) 1532 void HTMLMediaElement::setReadyState(MediaPlayer::ReadyState state)
1539 { 1533 {
1540 WTF_LOG(Media, "HTMLMediaElement::setReadyState(%d) - current state is %d,", static_cast<int>(state), static_cast<int>(m_readyState)); 1534 WTF_LOG(Media, "HTMLMediaElement::setReadyState(%d) - current state is %d,", static_cast<int>(state), static_cast<int>(m_readyState));
1541 1535
1542 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay ing() uses it 1536 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay ing() uses it
1543 bool wasPotentiallyPlaying = potentiallyPlaying(); 1537 bool wasPotentiallyPlaying = potentiallyPlaying();
1544 1538
1545 ReadyState oldState = m_readyState; 1539 ReadyState oldState = m_readyState;
1546 ReadyState newState = static_cast<ReadyState>(state); 1540 ReadyState newState = static_cast<ReadyState>(state);
1547 1541
1548 bool tracksAreReady = !RuntimeEnabledFeatures::videoTrackEnabled() || textTr acksAreReady(); 1542 bool tracksAreReady = textTracksAreReady();
1549 1543
1550 if (newState == oldState && m_tracksAreReady == tracksAreReady) 1544 if (newState == oldState && m_tracksAreReady == tracksAreReady)
1551 return; 1545 return;
1552 1546
1553 m_tracksAreReady = tracksAreReady; 1547 m_tracksAreReady = tracksAreReady;
1554 1548
1555 if (tracksAreReady) 1549 if (tracksAreReady)
1556 m_readyState = newState; 1550 m_readyState = newState;
1557 else { 1551 else {
1558 // If a media file has text tracks the readyState may not progress beyon d HAVE_FUTURE_DATA until 1552 // If a media file has text tracks the readyState may not progress beyon d HAVE_FUTURE_DATA until
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 } 1631 }
1638 1632
1639 if (shouldUpdateDisplayState) { 1633 if (shouldUpdateDisplayState) {
1640 updateDisplayState(); 1634 updateDisplayState();
1641 if (hasMediaControls()) 1635 if (hasMediaControls())
1642 mediaControls()->refreshClosedCaptionsButtonVisibility(); 1636 mediaControls()->refreshClosedCaptionsButtonVisibility();
1643 } 1637 }
1644 1638
1645 updatePlayState(); 1639 updatePlayState();
1646 updateMediaController(); 1640 updateMediaController();
1647 if (RuntimeEnabledFeatures::videoTrackEnabled()) 1641 updateActiveTextTrackCues(currentTime());
1648 updateActiveTextTrackCues(currentTime());
1649 } 1642 }
1650 1643
1651 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) 1644 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*)
1652 { 1645 {
1653 ASSERT(m_player); 1646 ASSERT(m_player);
1654 if (m_networkState != NETWORK_LOADING) 1647 if (m_networkState != NETWORK_LOADING)
1655 return; 1648 return;
1656 1649
1657 double time = WTF::currentTime(); 1650 double time = WTF::currentTime();
1658 double timedelta = time - m_previousProgressTime; 1651 double timedelta = time - m_previousProgressTime;
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
2170 2163
2171 if (!m_seeking) 2164 if (!m_seeking)
2172 scheduleTimeupdateEvent(true); 2165 scheduleTimeupdateEvent(true);
2173 2166
2174 if (!m_playbackRate) 2167 if (!m_playbackRate)
2175 return; 2168 return;
2176 2169
2177 if (!m_paused && hasMediaControls()) 2170 if (!m_paused && hasMediaControls())
2178 mediaControls()->playbackProgressed(); 2171 mediaControls()->playbackProgressed();
2179 2172
2180 if (RuntimeEnabledFeatures::videoTrackEnabled()) 2173 updateActiveTextTrackCues(currentTime());
2181 updateActiveTextTrackCues(currentTime());
2182 } 2174 }
2183 2175
2184 void HTMLMediaElement::scheduleTimeupdateEvent(bool periodicEvent) 2176 void HTMLMediaElement::scheduleTimeupdateEvent(bool periodicEvent)
2185 { 2177 {
2186 double now = WTF::currentTime(); 2178 double now = WTF::currentTime();
2187 double timedelta = now - m_lastTimeUpdateEventWallTime; 2179 double timedelta = now - m_lastTimeUpdateEventWallTime;
2188 2180
2189 // throttle the periodic events 2181 // throttle the periodic events
2190 if (periodicEvent && timedelta < maxTimeupdateEventFrequency) 2182 if (periodicEvent && timedelta < maxTimeupdateEventFrequency)
2191 return; 2183 return;
(...skipping 28 matching lines...) Expand all
2220 } else { 2212 } else {
2221 if (paused()) 2213 if (paused())
2222 play(); 2214 play();
2223 else 2215 else
2224 pause(); 2216 pause();
2225 } 2217 }
2226 } 2218 }
2227 2219
2228 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) 2220 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack)
2229 { 2221 {
2230 if (!RuntimeEnabledFeatures::videoTrackEnabled())
2231 return;
2232
2233 // 4.8.10.12.2 Sourcing in-band text tracks 2222 // 4.8.10.12.2 Sourcing in-band text tracks
2234 // 1. Associate the relevant data with a new text track and its correspondin g new TextTrack object. 2223 // 1. Associate the relevant data with a new text track and its correspondin g new TextTrack object.
2235 RefPtr<InbandTextTrack> textTrack = InbandTextTrack::create(document(), webT rack); 2224 RefPtr<InbandTextTrack> textTrack = InbandTextTrack::create(document(), webT rack);
2236 2225
2237 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data, 2226 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data,
2238 // as defined by the relevant specification. If there is no label in that da ta, then the label must 2227 // as defined by the relevant specification. If there is no label in that da ta, then the label must
2239 // be set to the empty string. 2228 // be set to the empty string.
2240 // 3. Associate the text track list of cues with the rules for updating the text track rendering appropriate 2229 // 3. Associate the text track list of cues with the rules for updating the text track rendering appropriate
2241 // for the format in question. 2230 // for the format in question.
2242 // 4. If the new text track's kind is metadata, then set the text track in-b and metadata track dispatch type 2231 // 4. If the new text track's kind is metadata, then set the text track in-b and metadata track dispatch type
(...skipping 12 matching lines...) Expand all
2255 2244
2256 // 8. Add the new text track to the media element's list of text tracks. 2245 // 8. Add the new text track to the media element's list of text tracks.
2257 // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent 2246 // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent
2258 // interface, with the track attribute initialized to the text track's TextT rack object, at the media element's 2247 // interface, with the track attribute initialized to the text track's TextT rack object, at the media element's
2259 // textTracks attribute's TextTrackList object. 2248 // textTracks attribute's TextTrackList object.
2260 addTextTrack(textTrack.get()); 2249 addTextTrack(textTrack.get());
2261 } 2250 }
2262 2251
2263 void HTMLMediaElement::mediaPlayerDidRemoveTextTrack(WebInbandTextTrack* webTrac k) 2252 void HTMLMediaElement::mediaPlayerDidRemoveTextTrack(WebInbandTextTrack* webTrac k)
2264 { 2253 {
2265 if (!RuntimeEnabledFeatures::videoTrackEnabled())
2266 return;
2267
2268 if (!m_textTracks) 2254 if (!m_textTracks)
2269 return; 2255 return;
2270 2256
2271 // This cast is safe because we created the InbandTextTrack with the WebInba ndTextTrack 2257 // This cast is safe because we created the InbandTextTrack with the WebInba ndTextTrack
2272 // passed to mediaPlayerDidAddTextTrack. 2258 // passed to mediaPlayerDidAddTextTrack.
2273 RefPtr<InbandTextTrack> textTrack = static_cast<InbandTextTrack*>(webTrack-> client()); 2259 RefPtr<InbandTextTrack> textTrack = static_cast<InbandTextTrack*>(webTrack-> client());
2274 if (!textTrack) 2260 if (!textTrack)
2275 return; 2261 return;
2276 2262
2277 removeTextTrack(textTrack.get()); 2263 removeTextTrack(textTrack.get());
(...skipping 24 matching lines...) Expand all
2302 { 2288 {
2303 if (m_textTracks) { 2289 if (m_textTracks) {
2304 TrackDisplayUpdateScope scope(this); 2290 TrackDisplayUpdateScope scope(this);
2305 m_textTracks->removeAllInbandTracks(); 2291 m_textTracks->removeAllInbandTracks();
2306 closeCaptionTracksChanged(); 2292 closeCaptionTracksChanged();
2307 } 2293 }
2308 } 2294 }
2309 2295
2310 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicString& kind, c onst AtomicString& label, const AtomicString& language, ExceptionState& exceptio nState) 2296 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicString& kind, c onst AtomicString& label, const AtomicString& language, ExceptionState& exceptio nState)
2311 { 2297 {
2312 ASSERT(RuntimeEnabledFeatures::videoTrackEnabled());
2313
2314 // 4.8.10.12.4 Text track API 2298 // 4.8.10.12.4 Text track API
2315 // The addTextTrack(kind, label, language) method of media elements, when in voked, must run the following steps: 2299 // The addTextTrack(kind, label, language) method of media elements, when in voked, must run the following steps:
2316 2300
2317 // 1. If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps 2301 // 1. If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps
2318 if (!TextTrack::isValidKindKeyword(kind)) { 2302 if (!TextTrack::isValidKindKeyword(kind)) {
2319 exceptionState.throwDOMException(SyntaxError, "The 'kind' provided ('" + kind + "') is invalid."); 2303 exceptionState.throwDOMException(SyntaxError, "The 'kind' provided ('" + kind + "') is invalid.");
2320 return nullptr; 2304 return nullptr;
2321 } 2305 }
2322 2306
2323 // 2. If the label argument was omitted, let label be the empty string. 2307 // 2. If the label argument was omitted, let label be the empty string.
(...skipping 14 matching lines...) Expand all
2338 textTrack->setReadinessState(TextTrack::Loaded); 2322 textTrack->setReadinessState(TextTrack::Loaded);
2339 2323
2340 // ... its text track mode to the text track hidden mode, and its text track list of cues to an empty list ... 2324 // ... its text track mode to the text track hidden mode, and its text track list of cues to an empty list ...
2341 textTrack->setMode(TextTrack::hiddenKeyword()); 2325 textTrack->setMode(TextTrack::hiddenKeyword());
2342 2326
2343 return textTrack.release(); 2327 return textTrack.release();
2344 } 2328 }
2345 2329
2346 TextTrackList* HTMLMediaElement::textTracks() 2330 TextTrackList* HTMLMediaElement::textTracks()
2347 { 2331 {
2348 ASSERT(RuntimeEnabledFeatures::videoTrackEnabled());
2349
2350 if (!m_textTracks) 2332 if (!m_textTracks)
2351 m_textTracks = TextTrackList::create(this); 2333 m_textTracks = TextTrackList::create(this);
2352 2334
2353 return m_textTracks.get(); 2335 return m_textTracks.get();
2354 } 2336 }
2355 2337
2356 void HTMLMediaElement::didAddTrackElement(HTMLTrackElement* trackElement) 2338 void HTMLMediaElement::didAddTrackElement(HTMLTrackElement* trackElement)
2357 { 2339 {
2358 if (!RuntimeEnabledFeatures::videoTrackEnabled())
2359 return;
2360
2361 // 4.8.10.12.3 Sourcing out-of-band text tracks 2340 // 4.8.10.12.3 Sourcing out-of-band text tracks
2362 // When a track element's parent element changes and the new parent is a med ia element, 2341 // When a track element's parent element changes and the new parent is a med ia element,
2363 // then the user agent must add the track element's corresponding text track to the 2342 // then the user agent must add the track element's corresponding text track to the
2364 // media element's list of text tracks ... [continues in TextTrackList::appe nd] 2343 // media element's list of text tracks ... [continues in TextTrackList::appe nd]
2365 RefPtr<TextTrack> textTrack = trackElement->track(); 2344 RefPtr<TextTrack> textTrack = trackElement->track();
2366 if (!textTrack) 2345 if (!textTrack)
2367 return; 2346 return;
2368 2347
2369 addTextTrack(textTrack.get()); 2348 addTextTrack(textTrack.get());
2370 2349
2371 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks 2350 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks
2372 // in the markup have been added. 2351 // in the markup have been added.
2373 if (isFinishedParsingChildren()) 2352 if (isFinishedParsingChildren())
2374 scheduleDelayedAction(LoadTextTrackResource); 2353 scheduleDelayedAction(LoadTextTrackResource);
2375 2354
2376 if (hasMediaControls()) 2355 if (hasMediaControls())
2377 mediaControls()->closedCaptionTracksChanged(); 2356 mediaControls()->closedCaptionTracksChanged();
2378 } 2357 }
2379 2358
2380 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement) 2359 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement)
2381 { 2360 {
2382 if (!RuntimeEnabledFeatures::videoTrackEnabled())
2383 return;
2384
2385 #if !LOG_DISABLED 2361 #if !LOG_DISABLED
2386 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr); 2362 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr);
2387 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement - 'src' is %s", urlF orLoggingMedia(url).utf8().data()); 2363 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement - 'src' is %s", urlF orLoggingMedia(url).utf8().data());
2388 #endif 2364 #endif
2389 2365
2390 RefPtr<TextTrack> textTrack = trackElement->track(); 2366 RefPtr<TextTrack> textTrack = trackElement->track();
2391 if (!textTrack) 2367 if (!textTrack)
2392 return; 2368 return;
2393 2369
2394 textTrack->setHasBeenConfigured(false); 2370 textTrack->setHasBeenConfigured(false);
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
2751 // inserted in a video or audio element will have no effect. 2727 // inserted in a video or audio element will have no effect.
2752 m_currentSourceNode = nullptr; 2728 m_currentSourceNode = nullptr;
2753 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved - m_currentSourceNode se t to 0"); 2729 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved - m_currentSourceNode se t to 0");
2754 } 2730 }
2755 } 2731 }
2756 2732
2757 void HTMLMediaElement::mediaPlayerTimeChanged() 2733 void HTMLMediaElement::mediaPlayerTimeChanged()
2758 { 2734 {
2759 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged"); 2735 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged");
2760 2736
2761 if (RuntimeEnabledFeatures::videoTrackEnabled()) 2737 updateActiveTextTrackCues(currentTime());
2762 updateActiveTextTrackCues(currentTime());
2763 2738
2764 invalidateCachedTime(); 2739 invalidateCachedTime();
2765 2740
2766 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek. 2741 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek.
2767 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !m_player->seeking()) 2742 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !m_player->seeking())
2768 finishSeek(); 2743 finishSeek();
2769 2744
2770 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity, 2745 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity,
2771 // it will only queue a 'timeupdate' event if we haven't already posted one at the current 2746 // it will only queue a 'timeupdate' event if we haven't already posted one at the current
2772 // movie time. 2747 // movie time.
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
3115 3090
3116 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. 3091 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event.
3117 setShouldDelayLoadEvent(false); 3092 setShouldDelayLoadEvent(false);
3118 3093
3119 // 6 - Abort the overall resource selection algorithm. 3094 // 6 - Abort the overall resource selection algorithm.
3120 m_currentSourceNode = nullptr; 3095 m_currentSourceNode = nullptr;
3121 3096
3122 // Reset m_readyState since m_player is gone. 3097 // Reset m_readyState since m_player is gone.
3123 m_readyState = HAVE_NOTHING; 3098 m_readyState = HAVE_NOTHING;
3124 updateMediaController(); 3099 updateMediaController();
3125 if (RuntimeEnabledFeatures::videoTrackEnabled()) 3100 updateActiveTextTrackCues(0);
3126 updateActiveTextTrackCues(0);
3127 } 3101 }
3128 3102
3129 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClient() 3103 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClient()
3130 { 3104 {
3131 #if ENABLE(WEB_AUDIO) 3105 #if ENABLE(WEB_AUDIO)
3132 if (m_audioSourceNode) 3106 if (m_audioSourceNode)
3133 m_audioSourceNode->lock(); 3107 m_audioSourceNode->lock();
3134 3108
3135 if (audioSourceProvider()) 3109 if (audioSourceProvider())
3136 audioSourceProvider()->setClient(0); 3110 audioSourceProvider()->setClient(0);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
3231 document().renderView()->compositor()->setCompositingLayersNeedRebuild() ; 3205 document().renderView()->compositor()->setCompositingLayersNeedRebuild() ;
3232 } 3206 }
3233 3207
3234 blink::WebLayer* HTMLMediaElement::platformLayer() const 3208 blink::WebLayer* HTMLMediaElement::platformLayer() const
3235 { 3209 {
3236 return m_webLayer; 3210 return m_webLayer;
3237 } 3211 }
3238 3212
3239 bool HTMLMediaElement::hasClosedCaptions() const 3213 bool HTMLMediaElement::hasClosedCaptions() const
3240 { 3214 {
3241 if (RuntimeEnabledFeatures::videoTrackEnabled() && m_textTracks) { 3215 if (m_textTracks) {
3242 for (unsigned i = 0; i < m_textTracks->length(); ++i) { 3216 for (unsigned i = 0; i < m_textTracks->length(); ++i) {
3243 if (m_textTracks->item(i)->readinessState() == TextTrack::FailedToLo ad) 3217 if (m_textTracks->item(i)->readinessState() == TextTrack::FailedToLo ad)
3244 continue; 3218 continue;
3245 3219
3246 if (m_textTracks->item(i)->kind() == TextTrack::captionsKeyword() 3220 if (m_textTracks->item(i)->kind() == TextTrack::captionsKeyword()
3247 || m_textTracks->item(i)->kind() == TextTrack::subtitlesKeyword( )) 3221 || m_textTracks->item(i)->kind() == TextTrack::subtitlesKeyword( ))
3248 return true; 3222 return true;
3249 } 3223 }
3250 } 3224 }
3251 return false; 3225 return false;
(...skipping 16 matching lines...) Expand all
3268 3242
3269 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible) 3243 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible)
3270 { 3244 {
3271 WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%s)", boolString( closedCaptionVisible)); 3245 WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%s)", boolString( closedCaptionVisible));
3272 3246
3273 if (!m_player || !hasClosedCaptions()) 3247 if (!m_player || !hasClosedCaptions())
3274 return; 3248 return;
3275 3249
3276 m_closedCaptionsVisible = closedCaptionVisible; 3250 m_closedCaptionsVisible = closedCaptionVisible;
3277 3251
3278 if (RuntimeEnabledFeatures::videoTrackEnabled()) { 3252 m_processingPreferenceChange = true;
3279 m_processingPreferenceChange = true; 3253 markCaptionAndSubtitleTracksAsUnconfigured();
3280 markCaptionAndSubtitleTracksAsUnconfigured(); 3254 m_processingPreferenceChange = false;
3281 m_processingPreferenceChange = false;
3282 3255
3283 updateTextTrackDisplay(); 3256 updateTextTrackDisplay();
3284 }
3285 } 3257 }
3286 3258
3287 unsigned HTMLMediaElement::webkitAudioDecodedByteCount() const 3259 unsigned HTMLMediaElement::webkitAudioDecodedByteCount() const
3288 { 3260 {
3289 if (!m_player) 3261 if (!m_player)
3290 return 0; 3262 return 0;
3291 return m_player->audioDecodedByteCount(); 3263 return m_player->audioDecodedByteCount();
3292 } 3264 }
3293 3265
3294 unsigned HTMLMediaElement::webkitVideoDecodedByteCount() const 3266 unsigned HTMLMediaElement::webkitVideoDecodedByteCount() const
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
3394 m_haveVisibleTextTrack = haveVisibleTextTrack; 3366 m_haveVisibleTextTrack = haveVisibleTextTrack;
3395 m_closedCaptionsVisible = m_haveVisibleTextTrack; 3367 m_closedCaptionsVisible = m_haveVisibleTextTrack;
3396 3368
3397 if (!m_haveVisibleTextTrack && !hasMediaControls()) 3369 if (!m_haveVisibleTextTrack && !hasMediaControls())
3398 return; 3370 return;
3399 if (!hasMediaControls() && !createMediaControls()) 3371 if (!hasMediaControls() && !createMediaControls())
3400 return; 3372 return;
3401 3373
3402 mediaControls()->changedClosedCaptionsVisibility(); 3374 mediaControls()->changedClosedCaptionsVisibility();
3403 3375
3404 if (RuntimeEnabledFeatures::videoTrackEnabled()) { 3376 updateActiveTextTrackCues(currentTime());
3405 updateActiveTextTrackCues(currentTime()); 3377 updateTextTrackDisplay();
3406 updateTextTrackDisplay();
3407 }
3408 } 3378 }
3409 3379
3410 void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured() 3380 void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured()
3411 { 3381 {
3412 if (!m_textTracks) 3382 if (!m_textTracks)
3413 return; 3383 return;
3414 3384
3415 // Mark all tracks as not "configured" so that configureTextTracks() 3385 // Mark all tracks as not "configured" so that configureTextTracks()
3416 // will reconsider which tracks to display in light of new user preferences 3386 // will reconsider which tracks to display in light of new user preferences
3417 // (e.g. default tracks should not be displayed if the user has turned off 3387 // (e.g. default tracks should not be displayed if the user has turned off
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
3671 { 3641 {
3672 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); 3642 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource));
3673 } 3643 }
3674 3644
3675 bool HTMLMediaElement::isInteractiveContent() const 3645 bool HTMLMediaElement::isInteractiveContent() const
3676 { 3646 {
3677 return fastHasAttribute(controlsAttr); 3647 return fastHasAttribute(controlsAttr);
3678 } 3648 }
3679 3649
3680 } 3650 }
OLDNEW
« no previous file with comments | « no previous file | Source/core/html/HTMLMediaElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698