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

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

Issue 180173002: Rename text track methods to make way for audio & video tracks. (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/HTMLMediaElement.h ('k') | Source/core/html/HTMLTrackElement.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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 addElementToDocumentMap(this, &document); 328 addElementToDocumentMap(this, &document);
329 } 329 }
330 330
331 HTMLMediaElement::~HTMLMediaElement() 331 HTMLMediaElement::~HTMLMediaElement()
332 { 332 {
333 WTF_LOG(Media, "HTMLMediaElement::~HTMLMediaElement"); 333 WTF_LOG(Media, "HTMLMediaElement::~HTMLMediaElement");
334 334
335 m_asyncEventQueue->close(); 335 m_asyncEventQueue->close();
336 336
337 setShouldDelayLoadEvent(false); 337 setShouldDelayLoadEvent(false);
338
338 if (m_textTracks) 339 if (m_textTracks)
339 m_textTracks->clearOwner(); 340 m_textTracks->clearOwnerAndClients();
340 if (m_textTracks) {
341 for (unsigned i = 0; i < m_textTracks->length(); ++i)
342 m_textTracks->item(i)->clearClient();
343 }
344 341
345 if (m_mediaController) { 342 if (m_mediaController) {
346 m_mediaController->removeMediaElement(this); 343 m_mediaController->removeMediaElement(this);
347 m_mediaController = nullptr; 344 m_mediaController = nullptr;
348 } 345 }
349 346
350 closeMediaSource(); 347 closeMediaSource();
351 348
352 setMediaKeysInternal(0); 349 setMediaKeysInternal(0);
353 350
(...skipping 2091 matching lines...) Expand 10 before | Expand all | Expand 10 after
2445 m_lastTimeUpdateEventWallTime = now; 2442 m_lastTimeUpdateEventWallTime = now;
2446 m_lastTimeUpdateEventMovieTime = movieTime; 2443 m_lastTimeUpdateEventMovieTime = movieTime;
2447 } 2444 }
2448 } 2445 }
2449 2446
2450 bool HTMLMediaElement::canPlay() const 2447 bool HTMLMediaElement::canPlay() const
2451 { 2448 {
2452 return paused() || ended() || m_readyState < HAVE_METADATA; 2449 return paused() || ended() || m_readyState < HAVE_METADATA;
2453 } 2450 }
2454 2451
2455 void HTMLMediaElement::mediaPlayerDidAddTrack(WebInbandTextTrack* webTrack) 2452 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack)
2456 { 2453 {
2457 if (!RuntimeEnabledFeatures::videoTrackEnabled()) 2454 if (!RuntimeEnabledFeatures::videoTrackEnabled())
2458 return; 2455 return;
2459 2456
2460 // 4.8.10.12.2 Sourcing in-band text tracks 2457 // 4.8.10.12.2 Sourcing in-band text tracks
2461 // 1. Associate the relevant data with a new text track and its correspondin g new TextTrack object. 2458 // 1. Associate the relevant data with a new text track and its correspondin g new TextTrack object.
2462 RefPtr<InbandTextTrack> textTrack = InbandTextTrack::create(document(), this , webTrack); 2459 RefPtr<InbandTextTrack> textTrack = InbandTextTrack::create(document(), this , webTrack);
2463 2460
2464 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data, 2461 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data,
2465 // as defined by the relevant specification. If there is no label in that da ta, then the label must 2462 // as defined by the relevant specification. If there is no label in that da ta, then the label must
(...skipping 11 matching lines...) Expand all
2477 2474
2478 // 7. Set the new text track's mode to the mode consistent with the user's p references and the requirements of 2475 // 7. Set the new text track's mode to the mode consistent with the user's p references and the requirements of
2479 // the relevant specification for the data. 2476 // the relevant specification for the data.
2480 // - This will happen in configureTextTracks() 2477 // - This will happen in configureTextTracks()
2481 scheduleDelayedAction(LoadTextTrackResource); 2478 scheduleDelayedAction(LoadTextTrackResource);
2482 2479
2483 // 8. Add the new text track to the media element's list of text tracks. 2480 // 8. Add the new text track to the media element's list of text tracks.
2484 // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent 2481 // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent
2485 // interface, with the track attribute initialized to the text track's TextT rack object, at the media element's 2482 // interface, with the track attribute initialized to the text track's TextT rack object, at the media element's
2486 // textTracks attribute's TextTrackList object. 2483 // textTracks attribute's TextTrackList object.
2487 addTrack(textTrack.get()); 2484 addTextTrack(textTrack.get());
2488 } 2485 }
2489 2486
2490 void HTMLMediaElement::mediaPlayerDidRemoveTrack(WebInbandTextTrack* webTrack) 2487 void HTMLMediaElement::mediaPlayerDidRemoveTextTrack(WebInbandTextTrack* webTrac k)
2491 { 2488 {
2492 if (!RuntimeEnabledFeatures::videoTrackEnabled()) 2489 if (!RuntimeEnabledFeatures::videoTrackEnabled())
2493 return; 2490 return;
2494 2491
2495 if (!m_textTracks) 2492 if (!m_textTracks)
2496 return; 2493 return;
2497 2494
2498 // This cast is safe because we created the InbandTextTrack with the WebInba ndTextTrack 2495 // This cast is safe because we created the InbandTextTrack with the WebInba ndTextTrack
2499 // passed to mediaPlayerDidAddTrack. 2496 // passed to mediaPlayerDidAddTextTrack.
2500 RefPtr<InbandTextTrack> textTrack = static_cast<InbandTextTrack*>(webTrack-> client()); 2497 RefPtr<InbandTextTrack> textTrack = static_cast<InbandTextTrack*>(webTrack-> client());
2501 if (!textTrack) 2498 if (!textTrack)
2502 return; 2499 return;
2503 2500
2504 removeTrack(textTrack.get()); 2501 removeTextTrack(textTrack.get());
2505 } 2502 }
2506 2503
2507 void HTMLMediaElement::closeCaptionTracksChanged() 2504 void HTMLMediaElement::closeCaptionTracksChanged()
2508 { 2505 {
2509 if (hasMediaControls()) 2506 if (hasMediaControls())
2510 mediaControls()->closedCaptionTracksChanged(); 2507 mediaControls()->closedCaptionTracksChanged();
2511 } 2508 }
2512 2509
2513 void HTMLMediaElement::addTrack(TextTrack* track) 2510 void HTMLMediaElement::addTextTrack(TextTrack* track)
2514 { 2511 {
2515 textTracks()->append(track); 2512 textTracks()->append(track);
2516 2513
2517 closeCaptionTracksChanged(); 2514 closeCaptionTracksChanged();
2518 } 2515 }
2519 2516
2520 void HTMLMediaElement::removeTrack(TextTrack* track) 2517 void HTMLMediaElement::removeTextTrack(TextTrack* track)
2521 { 2518 {
2522 TrackDisplayUpdateScope scope(this); 2519 TrackDisplayUpdateScope scope(this);
2523 TextTrackCueList* cues = track->cues(); 2520 TextTrackCueList* cues = track->cues();
2524 if (cues) 2521 if (cues)
2525 textTrackRemoveCues(track, cues); 2522 textTrackRemoveCues(track, cues);
2526 m_textTracks->remove(track); 2523 m_textTracks->remove(track);
2527 2524
2528 closeCaptionTracksChanged(); 2525 closeCaptionTracksChanged();
2529 } 2526 }
2530 2527
2531 void HTMLMediaElement::removeAllInbandTracks() 2528 void HTMLMediaElement::removeAllInbandTracks()
2532 { 2529 {
2533 if (!m_textTracks) 2530 if (!m_textTracks)
2534 return; 2531 return;
2535 2532
2536 TrackDisplayUpdateScope scope(this); 2533 TrackDisplayUpdateScope scope(this);
2537 for (int i = m_textTracks->length() - 1; i >= 0; --i) { 2534 for (int i = m_textTracks->length() - 1; i >= 0; --i) {
2538 TextTrack* track = m_textTracks->item(i); 2535 TextTrack* track = m_textTracks->item(i);
2539 2536
2540 if (track->trackType() == TextTrack::InBand) 2537 if (track->trackType() == TextTrack::InBand)
2541 removeTrack(track); 2538 removeTextTrack(track);
2542 } 2539 }
2543 } 2540 }
2544 2541
2545 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicString& kind, c onst AtomicString& label, const AtomicString& language, ExceptionState& exceptio nState) 2542 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicString& kind, c onst AtomicString& label, const AtomicString& language, ExceptionState& exceptio nState)
2546 { 2543 {
2547 ASSERT(RuntimeEnabledFeatures::videoTrackEnabled()); 2544 ASSERT(RuntimeEnabledFeatures::videoTrackEnabled());
2548 2545
2549 // 4.8.10.12.4 Text track API 2546 // 4.8.10.12.4 Text track API
2550 // The addTextTrack(kind, label, language) method of media elements, when in voked, must run the following steps: 2547 // The addTextTrack(kind, label, language) method of media elements, when in voked, must run the following steps:
2551 2548
2552 // 1. If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps 2549 // 1. If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps
2553 if (!TextTrack::isValidKindKeyword(kind)) { 2550 if (!TextTrack::isValidKindKeyword(kind)) {
2554 exceptionState.throwDOMException(SyntaxError, "The 'kind' provided ('" + kind + "') is invalid."); 2551 exceptionState.throwDOMException(SyntaxError, "The 'kind' provided ('" + kind + "') is invalid.");
2555 return nullptr; 2552 return nullptr;
2556 } 2553 }
2557 2554
2558 // 2. If the label argument was omitted, let label be the empty string. 2555 // 2. If the label argument was omitted, let label be the empty string.
2559 // 3. If the language argument was omitted, let language be the empty string . 2556 // 3. If the language argument was omitted, let language be the empty string .
2560 // 4. Create a new TextTrack object. 2557 // 4. Create a new TextTrack object.
2561 2558
2562 // 5. Create a new text track corresponding to the new object, and set its t ext track kind to kind, its text 2559 // 5. Create a new text track corresponding to the new object, and set its t ext track kind to kind, its text
2563 // track label to label, its text track language to language... 2560 // track label to label, its text track language to language...
2564 RefPtr<TextTrack> textTrack = TextTrack::create(document(), this, kind, labe l, language); 2561 RefPtr<TextTrack> textTrack = TextTrack::create(document(), this, kind, labe l, language);
2565 2562
2566 // Note, due to side effects when changing track parameters, we have to 2563 // Note, due to side effects when changing track parameters, we have to
2567 // first append the track to the text track list. 2564 // first append the track to the text track list.
2568 2565
2569 // 6. Add the new text track to the media element's list of text tracks. 2566 // 6. Add the new text track to the media element's list of text tracks.
2570 addTrack(textTrack.get()); 2567 addTextTrack(textTrack.get());
2571 2568
2572 // ... its text track readiness state to the text track loaded state ... 2569 // ... its text track readiness state to the text track loaded state ...
2573 textTrack->setReadinessState(TextTrack::Loaded); 2570 textTrack->setReadinessState(TextTrack::Loaded);
2574 2571
2575 // ... its text track mode to the text track hidden mode, and its text track list of cues to an empty list ... 2572 // ... its text track mode to the text track hidden mode, and its text track list of cues to an empty list ...
2576 textTrack->setMode(TextTrack::hiddenKeyword()); 2573 textTrack->setMode(TextTrack::hiddenKeyword());
2577 2574
2578 return textTrack.release(); 2575 return textTrack.release();
2579 } 2576 }
2580 2577
2581 TextTrackList* HTMLMediaElement::textTracks() 2578 TextTrackList* HTMLMediaElement::textTracks()
2582 { 2579 {
2583 ASSERT(RuntimeEnabledFeatures::videoTrackEnabled()); 2580 ASSERT(RuntimeEnabledFeatures::videoTrackEnabled());
2584 2581
2585 if (!m_textTracks) 2582 if (!m_textTracks)
2586 m_textTracks = TextTrackList::create(this); 2583 m_textTracks = TextTrackList::create(this);
2587 2584
2588 return m_textTracks.get(); 2585 return m_textTracks.get();
2589 } 2586 }
2590 2587
2591 void HTMLMediaElement::didAddTrack(HTMLTrackElement* trackElement) 2588 void HTMLMediaElement::didAddTrackElement(HTMLTrackElement* trackElement)
2592 { 2589 {
2593 ASSERT(trackElement->hasTagName(trackTag)); 2590 ASSERT(trackElement->hasTagName(trackTag));
2594 2591
2595 if (!RuntimeEnabledFeatures::videoTrackEnabled()) 2592 if (!RuntimeEnabledFeatures::videoTrackEnabled())
2596 return; 2593 return;
2597 2594
2598 // 4.8.10.12.3 Sourcing out-of-band text tracks 2595 // 4.8.10.12.3 Sourcing out-of-band text tracks
2599 // When a track element's parent element changes and the new parent is a med ia element, 2596 // When a track element's parent element changes and the new parent is a med ia element,
2600 // then the user agent must add the track element's corresponding text track to the 2597 // then the user agent must add the track element's corresponding text track to the
2601 // media element's list of text tracks ... [continues in TextTrackList::appe nd] 2598 // media element's list of text tracks ... [continues in TextTrackList::appe nd]
2602 RefPtr<TextTrack> textTrack = trackElement->track(); 2599 RefPtr<TextTrack> textTrack = trackElement->track();
2603 if (!textTrack) 2600 if (!textTrack)
2604 return; 2601 return;
2605 2602
2606 addTrack(textTrack.get()); 2603 addTextTrack(textTrack.get());
2607 2604
2608 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks 2605 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks
2609 // in the markup have been added. 2606 // in the markup have been added.
2610 if (isFinishedParsingChildren()) 2607 if (isFinishedParsingChildren())
2611 scheduleDelayedAction(LoadTextTrackResource); 2608 scheduleDelayedAction(LoadTextTrackResource);
2612 2609
2613 if (hasMediaControls()) 2610 if (hasMediaControls())
2614 mediaControls()->closedCaptionTracksChanged(); 2611 mediaControls()->closedCaptionTracksChanged();
2615 } 2612 }
2616 2613
2617 void HTMLMediaElement::didRemoveTrack(HTMLTrackElement* trackElement) 2614 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement)
2618 { 2615 {
2619 ASSERT(trackElement->hasTagName(trackTag)); 2616 ASSERT(trackElement->hasTagName(trackTag));
2620 2617
2621 if (!RuntimeEnabledFeatures::videoTrackEnabled()) 2618 if (!RuntimeEnabledFeatures::videoTrackEnabled())
2622 return; 2619 return;
2623 2620
2624 #if !LOG_DISABLED 2621 #if !LOG_DISABLED
2625 if (trackElement->hasTagName(trackTag)) { 2622 if (trackElement->hasTagName(trackTag)) {
2626 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr); 2623 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr);
2627 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrack - 'src' is %s", urlForL oggingMedia(url).utf8().data()); 2624 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement - 'src' is %s", urlForLoggingMedia(url).utf8().data());
2628 } 2625 }
2629 #endif 2626 #endif
2630 2627
2631 RefPtr<TextTrack> textTrack = trackElement->track(); 2628 RefPtr<TextTrack> textTrack = trackElement->track();
2632 if (!textTrack) 2629 if (!textTrack)
2633 return; 2630 return;
2634 2631
2635 textTrack->setHasBeenConfigured(false); 2632 textTrack->setHasBeenConfigured(false);
2636 2633
2637 if (!m_textTracks) 2634 if (!m_textTracks)
2638 return; 2635 return;
2639 2636
2640 // 4.8.10.12.3 Sourcing out-of-band text tracks 2637 // 4.8.10.12.3 Sourcing out-of-band text tracks
2641 // When a track element's parent element changes and the old parent was a me dia element, 2638 // When a track element's parent element changes and the old parent was a me dia element,
2642 // then the user agent must remove the track element's corresponding text tr ack from the 2639 // then the user agent must remove the track element's corresponding text tr ack from the
2643 // media element's list of text tracks. 2640 // media element's list of text tracks.
2644 removeTrack(textTrack.get()); 2641 removeTextTrack(textTrack.get());
2645 2642
2646 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack.get()); 2643 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack.get());
2647 if (index != kNotFound) 2644 if (index != kNotFound)
2648 m_textTracksWhenResourceSelectionBegan.remove(index); 2645 m_textTracksWhenResourceSelectionBegan.remove(index);
2649 } 2646 }
2650 2647
2651 static int textTrackLanguageSelectionScore(const TextTrack& track) 2648 static int textTrackLanguageSelectionScore(const TextTrack& track)
2652 { 2649 {
2653 if (track.language().isEmpty()) 2650 if (track.language().isEmpty())
2654 return 0; 2651 return 0;
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after
3917 { 3914 {
3918 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); 3915 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource));
3919 } 3916 }
3920 3917
3921 bool HTMLMediaElement::isInteractiveContent() const 3918 bool HTMLMediaElement::isInteractiveContent() const
3922 { 3919 {
3923 return fastHasAttribute(controlsAttr); 3920 return fastHasAttribute(controlsAttr);
3924 } 3921 }
3925 3922
3926 } 3923 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/core/html/HTMLTrackElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698