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

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

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

Powered by Google App Engine
This is Rietveld 408576698