| OLD | NEW |
| 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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 , m_userGestureRequiredForPlay(false) | 402 , m_userGestureRequiredForPlay(false) |
| 403 , m_playing(false) | 403 , m_playing(false) |
| 404 , m_shouldDelayLoadEvent(false) | 404 , m_shouldDelayLoadEvent(false) |
| 405 , m_haveFiredLoadedData(false) | 405 , m_haveFiredLoadedData(false) |
| 406 , m_autoplaying(true) | 406 , m_autoplaying(true) |
| 407 , m_muted(false) | 407 , m_muted(false) |
| 408 , m_paused(true) | 408 , m_paused(true) |
| 409 , m_seeking(false) | 409 , m_seeking(false) |
| 410 , m_sentStalledEvent(false) | 410 , m_sentStalledEvent(false) |
| 411 , m_sentEndEvent(false) | 411 , m_sentEndEvent(false) |
| 412 , m_closedCaptionsVisible(false) | |
| 413 , m_ignorePreloadNone(false) | 412 , m_ignorePreloadNone(false) |
| 413 , m_textTracksVisible(false) |
| 414 , m_shouldPerformAutomaticTrackSelection(true) |
| 414 , m_tracksAreReady(true) | 415 , m_tracksAreReady(true) |
| 415 , m_processingPreferenceChange(false) | 416 , m_processingPreferenceChange(false) |
| 416 , m_remoteRoutesAvailable(false) | 417 , m_remoteRoutesAvailable(false) |
| 417 , m_playingRemotely(false) | 418 , m_playingRemotely(false) |
| 418 , m_isFinalizing(false) | 419 , m_isFinalizing(false) |
| 419 , m_inOverlayFullscreenVideo(false) | 420 , m_inOverlayFullscreenVideo(false) |
| 420 , m_audioTracks(AudioTrackList::create(*this)) | 421 , m_audioTracks(AudioTrackList::create(*this)) |
| 421 , m_videoTracks(VideoTrackList::create(*this)) | 422 , m_videoTracks(VideoTrackList::create(*this)) |
| 422 , m_textTracks(nullptr) | 423 , m_textTracks(nullptr) |
| 423 , m_playPromiseResolveTask(CancellableTaskFactory::create(this, &HTMLMediaEl
ement::resolvePlayPromises)) | 424 , m_playPromiseResolveTask(CancellableTaskFactory::create(this, &HTMLMediaEl
ement::resolvePlayPromises)) |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 // Mark this track as "configured" so configureTextTracks won't change the m
ode again. | 1246 // Mark this track as "configured" so configureTextTracks won't change the m
ode again. |
| 1246 if (track->trackType() == TextTrack::TrackElement) | 1247 if (track->trackType() == TextTrack::TrackElement) |
| 1247 track->setHasBeenConfigured(true); | 1248 track->setHasBeenConfigured(true); |
| 1248 | 1249 |
| 1249 configureTextTrackDisplay(); | 1250 configureTextTrackDisplay(); |
| 1250 | 1251 |
| 1251 ASSERT(textTracks()->contains(track)); | 1252 ASSERT(textTracks()->contains(track)); |
| 1252 textTracks()->scheduleChangeEvent(); | 1253 textTracks()->scheduleChangeEvent(); |
| 1253 } | 1254 } |
| 1254 | 1255 |
| 1256 void HTMLMediaElement::disableAutomaticTextTrackSelection() |
| 1257 { |
| 1258 m_shouldPerformAutomaticTrackSelection = false; |
| 1259 } |
| 1260 |
| 1255 bool HTMLMediaElement::isSafeToLoadURL(const KURL& url, InvalidURLAction actionI
fInvalid) | 1261 bool HTMLMediaElement::isSafeToLoadURL(const KURL& url, InvalidURLAction actionI
fInvalid) |
| 1256 { | 1262 { |
| 1257 if (!url.isValid()) { | 1263 if (!url.isValid()) { |
| 1258 WTF_LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%p, %s) -> FALSE becau
se url is invalid", this, urlForLoggingMedia(url).utf8().data()); | 1264 WTF_LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%p, %s) -> FALSE becau
se url is invalid", this, urlForLoggingMedia(url).utf8().data()); |
| 1259 return false; | 1265 return false; |
| 1260 } | 1266 } |
| 1261 | 1267 |
| 1262 LocalFrame* frame = document().frame(); | 1268 LocalFrame* frame = document().frame(); |
| 1263 if (!frame || !document().getSecurityOrigin()->canDisplay(url)) { | 1269 if (!frame || !document().getSecurityOrigin()->canDisplay(url)) { |
| 1264 if (actionIfInvalid == Complain) | 1270 if (actionIfInvalid == Complain) |
| (...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2601 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack); | 2607 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack); |
| 2602 if (index != kNotFound) | 2608 if (index != kNotFound) |
| 2603 m_textTracksWhenResourceSelectionBegan.remove(index); | 2609 m_textTracksWhenResourceSelectionBegan.remove(index); |
| 2604 } | 2610 } |
| 2605 | 2611 |
| 2606 void HTMLMediaElement::honorUserPreferencesForAutomaticTextTrackSelection() | 2612 void HTMLMediaElement::honorUserPreferencesForAutomaticTextTrackSelection() |
| 2607 { | 2613 { |
| 2608 if (!m_textTracks || !m_textTracks->length()) | 2614 if (!m_textTracks || !m_textTracks->length()) |
| 2609 return; | 2615 return; |
| 2610 | 2616 |
| 2617 if (!m_shouldPerformAutomaticTrackSelection) |
| 2618 return; |
| 2619 |
| 2611 AutomaticTrackSelection::Configuration configuration; | 2620 AutomaticTrackSelection::Configuration configuration; |
| 2612 if (m_processingPreferenceChange) | 2621 if (m_processingPreferenceChange) |
| 2613 configuration.disableCurrentlyEnabledTracks = true; | 2622 configuration.disableCurrentlyEnabledTracks = true; |
| 2614 if (m_closedCaptionsVisible) | 2623 if (m_textTracksVisible) |
| 2615 configuration.forceEnableSubtitleOrCaptionTrack = true; | 2624 configuration.forceEnableSubtitleOrCaptionTrack = true; |
| 2616 | 2625 |
| 2617 Settings* settings = document().settings(); | 2626 Settings* settings = document().settings(); |
| 2618 if (settings) | 2627 if (settings) |
| 2619 configuration.textTrackKindUserPreference = settings->textTrackKindUserP
reference(); | 2628 configuration.textTrackKindUserPreference = settings->textTrackKindUserP
reference(); |
| 2620 | 2629 |
| 2621 AutomaticTrackSelection trackSelection(configuration); | 2630 AutomaticTrackSelection trackSelection(configuration); |
| 2622 trackSelection.perform(*m_textTracks); | 2631 trackSelection.perform(*m_textTracks); |
| 2623 | 2632 |
| 2624 textTracksChanged(); | 2633 textTracksChanged(); |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3274 continue; | 3283 continue; |
| 3275 | 3284 |
| 3276 if (track->kind() == TextTrack::captionsKeyword() | 3285 if (track->kind() == TextTrack::captionsKeyword() |
| 3277 || track->kind() == TextTrack::subtitlesKeyword()) | 3286 || track->kind() == TextTrack::subtitlesKeyword()) |
| 3278 return true; | 3287 return true; |
| 3279 } | 3288 } |
| 3280 } | 3289 } |
| 3281 return false; | 3290 return false; |
| 3282 } | 3291 } |
| 3283 | 3292 |
| 3284 bool HTMLMediaElement::closedCaptionsVisible() const | 3293 bool HTMLMediaElement::textTracksVisible() const |
| 3285 { | 3294 { |
| 3286 return m_closedCaptionsVisible; | 3295 return m_textTracksVisible; |
| 3287 } | 3296 } |
| 3288 | 3297 |
| 3289 static void assertShadowRootChildren(ShadowRoot& shadowRoot) | 3298 static void assertShadowRootChildren(ShadowRoot& shadowRoot) |
| 3290 { | 3299 { |
| 3291 #if ENABLE(ASSERT) | 3300 #if ENABLE(ASSERT) |
| 3292 // There can be up to two children, either or both of the text | 3301 // There can be up to two children, either or both of the text |
| 3293 // track container and media controls. If both are present, the | 3302 // track container and media controls. If both are present, the |
| 3294 // text track container must be the first child. | 3303 // text track container must be the first child. |
| 3295 unsigned numberOfChildren = shadowRoot.countChildren(); | 3304 unsigned numberOfChildren = shadowRoot.countChildren(); |
| 3296 ASSERT(numberOfChildren <= 2); | 3305 ASSERT(numberOfChildren <= 2); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3332 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidNotSt
artExposingControls); | 3341 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidNotSt
artExposingControls); |
| 3333 } | 3342 } |
| 3334 | 3343 |
| 3335 void HTMLMediaElement::mediaControlsDidBecomeVisible() | 3344 void HTMLMediaElement::mediaControlsDidBecomeVisible() |
| 3336 { | 3345 { |
| 3337 WTF_LOG(Media, "HTMLMediaElement::mediaControlsDidBecomeVisible(%p)", this); | 3346 WTF_LOG(Media, "HTMLMediaElement::mediaControlsDidBecomeVisible(%p)", this); |
| 3338 | 3347 |
| 3339 // When the user agent starts exposing a user interface for a video element, | 3348 // When the user agent starts exposing a user interface for a video element, |
| 3340 // the user agent should run the rules for updating the text track rendering | 3349 // the user agent should run the rules for updating the text track rendering |
| 3341 // of each of the text tracks in the video element's list of text tracks ... | 3350 // of each of the text tracks in the video element's list of text tracks ... |
| 3342 if (isHTMLVideoElement() && closedCaptionsVisible()) | 3351 if (isHTMLVideoElement() && textTracksVisible()) |
| 3343 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS
tartExposingControls); | 3352 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS
tartExposingControls); |
| 3344 } | 3353 } |
| 3345 | 3354 |
| 3346 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible) | |
| 3347 { | |
| 3348 WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%p, %s)", this, b
oolString(closedCaptionVisible)); | |
| 3349 | |
| 3350 if (!hasClosedCaptions()) | |
| 3351 return; | |
| 3352 | |
| 3353 m_closedCaptionsVisible = closedCaptionVisible; | |
| 3354 | |
| 3355 markCaptionAndSubtitleTracksAsUnconfigured(); | |
| 3356 m_processingPreferenceChange = true; | |
| 3357 honorUserPreferencesForAutomaticTextTrackSelection(); | |
| 3358 m_processingPreferenceChange = false; | |
| 3359 | |
| 3360 // As track visibility changed while m_processingPreferenceChange was set, | |
| 3361 // there was no call to updateTextTrackDisplay(). This call is not in the | |
| 3362 // spec, see the note in configureTextTrackDisplay(). | |
| 3363 updateTextTrackDisplay(); | |
| 3364 } | |
| 3365 | |
| 3366 void HTMLMediaElement::setTextTrackKindUserPreferenceForAllMediaElements(Documen
t* document) | 3355 void HTMLMediaElement::setTextTrackKindUserPreferenceForAllMediaElements(Documen
t* document) |
| 3367 { | 3356 { |
| 3368 auto it = documentToElementSetMap().find(document); | 3357 auto it = documentToElementSetMap().find(document); |
| 3369 if (it == documentToElementSetMap().end()) | 3358 if (it == documentToElementSetMap().end()) |
| 3370 return; | 3359 return; |
| 3371 ASSERT(it->value); | 3360 ASSERT(it->value); |
| 3372 WeakMediaElementSet& elements = *it->value; | 3361 WeakMediaElementSet& elements = *it->value; |
| 3373 for (const auto& element : elements) | 3362 for (const auto& element : elements) |
| 3374 element->automaticTrackSelectionForUpdatedUserPreference(); | 3363 element->automaticTrackSelectionForUpdatedUserPreference(); |
| 3375 } | 3364 } |
| 3376 | 3365 |
| 3377 void HTMLMediaElement::automaticTrackSelectionForUpdatedUserPreference() | 3366 void HTMLMediaElement::automaticTrackSelectionForUpdatedUserPreference() |
| 3378 { | 3367 { |
| 3379 if (!m_textTracks || !m_textTracks->length()) | 3368 if (!m_textTracks || !m_textTracks->length()) |
| 3380 return; | 3369 return; |
| 3381 | 3370 |
| 3382 markCaptionAndSubtitleTracksAsUnconfigured(); | 3371 markCaptionAndSubtitleTracksAsUnconfigured(); |
| 3383 m_processingPreferenceChange = true; | 3372 m_processingPreferenceChange = true; |
| 3384 m_closedCaptionsVisible = false; | 3373 m_textTracksVisible = false; |
| 3385 honorUserPreferencesForAutomaticTextTrackSelection(); | 3374 honorUserPreferencesForAutomaticTextTrackSelection(); |
| 3386 m_processingPreferenceChange = false; | 3375 m_processingPreferenceChange = false; |
| 3387 | 3376 |
| 3388 // If a track is set to 'showing' post performing automatic track selection, | 3377 // If a track is set to 'showing' post performing automatic track selection, |
| 3389 // set closed captions state to visible to update the CC button and display
the track. | 3378 // set text tracks state to visible to update the CC button and display the
track. |
| 3390 m_closedCaptionsVisible = m_textTracks->hasShowingTracks(); | 3379 m_textTracksVisible = m_textTracks->hasShowingTracks(); |
| 3391 updateTextTrackDisplay(); | 3380 updateTextTrackDisplay(); |
| 3392 } | 3381 } |
| 3393 | 3382 |
| 3394 void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured() | 3383 void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured() |
| 3395 { | 3384 { |
| 3396 if (!m_textTracks) | 3385 if (!m_textTracks) |
| 3397 return; | 3386 return; |
| 3398 | 3387 |
| 3399 // Mark all tracks as not "configured" so that | 3388 // Mark all tracks as not "configured" so that |
| 3400 // honorUserPreferencesForAutomaticTextTrackSelection() will reconsider | 3389 // honorUserPreferencesForAutomaticTextTrackSelection() will reconsider |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3505 | 3494 |
| 3506 void HTMLMediaElement::configureTextTrackDisplay() | 3495 void HTMLMediaElement::configureTextTrackDisplay() |
| 3507 { | 3496 { |
| 3508 ASSERT(m_textTracks); | 3497 ASSERT(m_textTracks); |
| 3509 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackDisplay(%p)", this); | 3498 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackDisplay(%p)", this); |
| 3510 | 3499 |
| 3511 if (m_processingPreferenceChange) | 3500 if (m_processingPreferenceChange) |
| 3512 return; | 3501 return; |
| 3513 | 3502 |
| 3514 bool haveVisibleTextTrack = m_textTracks->hasShowingTracks(); | 3503 bool haveVisibleTextTrack = m_textTracks->hasShowingTracks(); |
| 3515 m_closedCaptionsVisible = haveVisibleTextTrack; | 3504 m_textTracksVisible = haveVisibleTextTrack; |
| 3516 | 3505 |
| 3517 if (!haveVisibleTextTrack && !mediaControls()) | 3506 if (!haveVisibleTextTrack && !mediaControls()) |
| 3518 return; | 3507 return; |
| 3519 | 3508 |
| 3520 if (mediaControls()) | 3509 if (mediaControls()) |
| 3521 mediaControls()->changedClosedCaptionsVisibility(); | 3510 mediaControls()->changedClosedCaptionsVisibility(); |
| 3522 | 3511 |
| 3523 cueTimeline().updateActiveCues(currentTime()); | 3512 cueTimeline().updateActiveCues(currentTime()); |
| 3524 | 3513 |
| 3525 // Note: The "time marches on" algorithm (updateActiveCues) runs the "rules | 3514 // Note: The "time marches on" algorithm (updateActiveCues) runs the "rules |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3883 } | 3872 } |
| 3884 | 3873 |
| 3885 #if !ENABLE(OILPAN) | 3874 #if !ENABLE(OILPAN) |
| 3886 WeakPtr<HTMLMediaElement> HTMLMediaElement::createWeakPtr() | 3875 WeakPtr<HTMLMediaElement> HTMLMediaElement::createWeakPtr() |
| 3887 { | 3876 { |
| 3888 return m_weakPtrFactory.createWeakPtr(); | 3877 return m_weakPtrFactory.createWeakPtr(); |
| 3889 } | 3878 } |
| 3890 #endif | 3879 #endif |
| 3891 | 3880 |
| 3892 } // namespace blink | 3881 } // namespace blink |
| OLD | NEW |