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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 , m_userGestureRequiredForPlay(false) | 406 , m_userGestureRequiredForPlay(false) |
407 , m_playing(false) | 407 , m_playing(false) |
408 , m_shouldDelayLoadEvent(false) | 408 , m_shouldDelayLoadEvent(false) |
409 , m_haveFiredLoadedData(false) | 409 , m_haveFiredLoadedData(false) |
410 , m_autoplaying(true) | 410 , m_autoplaying(true) |
411 , m_muted(false) | 411 , m_muted(false) |
412 , m_paused(true) | 412 , m_paused(true) |
413 , m_seeking(false) | 413 , m_seeking(false) |
414 , m_sentStalledEvent(false) | 414 , m_sentStalledEvent(false) |
415 , m_sentEndEvent(false) | 415 , m_sentEndEvent(false) |
416 , m_closedCaptionsVisible(false) | |
417 , m_ignorePreloadNone(false) | 416 , m_ignorePreloadNone(false) |
| 417 , m_textTracksVisible(false) |
| 418 , m_shouldPerformAutomaticTrackSelection(true) |
418 , m_tracksAreReady(true) | 419 , m_tracksAreReady(true) |
419 , m_processingPreferenceChange(false) | 420 , m_processingPreferenceChange(false) |
420 , m_remoteRoutesAvailable(false) | 421 , m_remoteRoutesAvailable(false) |
421 , m_playingRemotely(false) | 422 , m_playingRemotely(false) |
422 , m_inOverlayFullscreenVideo(false) | 423 , m_inOverlayFullscreenVideo(false) |
423 , m_audioTracks(AudioTrackList::create(*this)) | 424 , m_audioTracks(AudioTrackList::create(*this)) |
424 , m_videoTracks(VideoTrackList::create(*this)) | 425 , m_videoTracks(VideoTrackList::create(*this)) |
425 , m_textTracks(nullptr) | 426 , m_textTracks(nullptr) |
426 , m_playPromiseResolveTask(CancellableTaskFactory::create(this, &HTMLMediaEl
ement::resolvePlayPromises)) | 427 , m_playPromiseResolveTask(CancellableTaskFactory::create(this, &HTMLMediaEl
ement::resolvePlayPromises)) |
427 , m_playPromiseRejectTask(CancellableTaskFactory::create(this, &HTMLMediaEle
ment::rejectPlayPromises)) | 428 , m_playPromiseRejectTask(CancellableTaskFactory::create(this, &HTMLMediaEle
ment::rejectPlayPromises)) |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1224 // Mark this track as "configured" so configureTextTracks won't change the m
ode again. | 1225 // Mark this track as "configured" so configureTextTracks won't change the m
ode again. |
1225 if (track->trackType() == TextTrack::TrackElement) | 1226 if (track->trackType() == TextTrack::TrackElement) |
1226 track->setHasBeenConfigured(true); | 1227 track->setHasBeenConfigured(true); |
1227 | 1228 |
1228 configureTextTrackDisplay(); | 1229 configureTextTrackDisplay(); |
1229 | 1230 |
1230 ASSERT(textTracks()->contains(track)); | 1231 ASSERT(textTracks()->contains(track)); |
1231 textTracks()->scheduleChangeEvent(); | 1232 textTracks()->scheduleChangeEvent(); |
1232 } | 1233 } |
1233 | 1234 |
| 1235 void HTMLMediaElement::disableAutomaticTextTrackSelection() |
| 1236 { |
| 1237 m_shouldPerformAutomaticTrackSelection = false; |
| 1238 } |
| 1239 |
1234 bool HTMLMediaElement::isSafeToLoadURL(const KURL& url, InvalidURLAction actionI
fInvalid) | 1240 bool HTMLMediaElement::isSafeToLoadURL(const KURL& url, InvalidURLAction actionI
fInvalid) |
1235 { | 1241 { |
1236 if (!url.isValid()) { | 1242 if (!url.isValid()) { |
1237 WTF_LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%p, %s) -> FALSE becau
se url is invalid", this, urlForLoggingMedia(url).utf8().data()); | 1243 WTF_LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%p, %s) -> FALSE becau
se url is invalid", this, urlForLoggingMedia(url).utf8().data()); |
1238 return false; | 1244 return false; |
1239 } | 1245 } |
1240 | 1246 |
1241 LocalFrame* frame = document().frame(); | 1247 LocalFrame* frame = document().frame(); |
1242 if (!frame || !document().getSecurityOrigin()->canDisplay(url)) { | 1248 if (!frame || !document().getSecurityOrigin()->canDisplay(url)) { |
1243 if (actionIfInvalid == Complain) | 1249 if (actionIfInvalid == Complain) |
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2580 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack); | 2586 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack); |
2581 if (index != kNotFound) | 2587 if (index != kNotFound) |
2582 m_textTracksWhenResourceSelectionBegan.remove(index); | 2588 m_textTracksWhenResourceSelectionBegan.remove(index); |
2583 } | 2589 } |
2584 | 2590 |
2585 void HTMLMediaElement::honorUserPreferencesForAutomaticTextTrackSelection() | 2591 void HTMLMediaElement::honorUserPreferencesForAutomaticTextTrackSelection() |
2586 { | 2592 { |
2587 if (!m_textTracks || !m_textTracks->length()) | 2593 if (!m_textTracks || !m_textTracks->length()) |
2588 return; | 2594 return; |
2589 | 2595 |
| 2596 if (!m_shouldPerformAutomaticTrackSelection) |
| 2597 return; |
| 2598 |
2590 AutomaticTrackSelection::Configuration configuration; | 2599 AutomaticTrackSelection::Configuration configuration; |
2591 if (m_processingPreferenceChange) | 2600 if (m_processingPreferenceChange) |
2592 configuration.disableCurrentlyEnabledTracks = true; | 2601 configuration.disableCurrentlyEnabledTracks = true; |
2593 if (m_closedCaptionsVisible) | 2602 if (m_textTracksVisible) |
2594 configuration.forceEnableSubtitleOrCaptionTrack = true; | 2603 configuration.forceEnableSubtitleOrCaptionTrack = true; |
2595 | 2604 |
2596 Settings* settings = document().settings(); | 2605 Settings* settings = document().settings(); |
2597 if (settings) | 2606 if (settings) |
2598 configuration.textTrackKindUserPreference = settings->textTrackKindUserP
reference(); | 2607 configuration.textTrackKindUserPreference = settings->textTrackKindUserP
reference(); |
2599 | 2608 |
2600 AutomaticTrackSelection trackSelection(configuration); | 2609 AutomaticTrackSelection trackSelection(configuration); |
2601 trackSelection.perform(*m_textTracks); | 2610 trackSelection.perform(*m_textTracks); |
2602 | 2611 |
2603 textTracksChanged(); | 2612 textTracksChanged(); |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3253 continue; | 3262 continue; |
3254 | 3263 |
3255 if (track->kind() == TextTrack::captionsKeyword() | 3264 if (track->kind() == TextTrack::captionsKeyword() |
3256 || track->kind() == TextTrack::subtitlesKeyword()) | 3265 || track->kind() == TextTrack::subtitlesKeyword()) |
3257 return true; | 3266 return true; |
3258 } | 3267 } |
3259 } | 3268 } |
3260 return false; | 3269 return false; |
3261 } | 3270 } |
3262 | 3271 |
3263 bool HTMLMediaElement::closedCaptionsVisible() const | 3272 bool HTMLMediaElement::textTracksVisible() const |
3264 { | 3273 { |
3265 return m_closedCaptionsVisible; | 3274 return m_textTracksVisible; |
3266 } | 3275 } |
3267 | 3276 |
3268 static void assertShadowRootChildren(ShadowRoot& shadowRoot) | 3277 static void assertShadowRootChildren(ShadowRoot& shadowRoot) |
3269 { | 3278 { |
3270 #if ENABLE(ASSERT) | 3279 #if ENABLE(ASSERT) |
3271 // There can be up to two children, either or both of the text | 3280 // There can be up to two children, either or both of the text |
3272 // track container and media controls. If both are present, the | 3281 // track container and media controls. If both are present, the |
3273 // text track container must be the first child. | 3282 // text track container must be the first child. |
3274 unsigned numberOfChildren = shadowRoot.countChildren(); | 3283 unsigned numberOfChildren = shadowRoot.countChildren(); |
3275 ASSERT(numberOfChildren <= 2); | 3284 ASSERT(numberOfChildren <= 2); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3311 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidNotSt
artExposingControls); | 3320 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidNotSt
artExposingControls); |
3312 } | 3321 } |
3313 | 3322 |
3314 void HTMLMediaElement::mediaControlsDidBecomeVisible() | 3323 void HTMLMediaElement::mediaControlsDidBecomeVisible() |
3315 { | 3324 { |
3316 WTF_LOG(Media, "HTMLMediaElement::mediaControlsDidBecomeVisible(%p)", this); | 3325 WTF_LOG(Media, "HTMLMediaElement::mediaControlsDidBecomeVisible(%p)", this); |
3317 | 3326 |
3318 // When the user agent starts exposing a user interface for a video element, | 3327 // When the user agent starts exposing a user interface for a video element, |
3319 // the user agent should run the rules for updating the text track rendering | 3328 // the user agent should run the rules for updating the text track rendering |
3320 // of each of the text tracks in the video element's list of text tracks ... | 3329 // of each of the text tracks in the video element's list of text tracks ... |
3321 if (isHTMLVideoElement() && closedCaptionsVisible()) | 3330 if (isHTMLVideoElement() && textTracksVisible()) |
3322 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS
tartExposingControls); | 3331 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS
tartExposingControls); |
3323 } | 3332 } |
3324 | 3333 |
3325 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible) | |
3326 { | |
3327 WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%p, %s)", this, b
oolString(closedCaptionVisible)); | |
3328 | |
3329 if (!hasClosedCaptions()) | |
3330 return; | |
3331 | |
3332 m_closedCaptionsVisible = closedCaptionVisible; | |
3333 | |
3334 markCaptionAndSubtitleTracksAsUnconfigured(); | |
3335 m_processingPreferenceChange = true; | |
3336 honorUserPreferencesForAutomaticTextTrackSelection(); | |
3337 m_processingPreferenceChange = false; | |
3338 | |
3339 // As track visibility changed while m_processingPreferenceChange was set, | |
3340 // there was no call to updateTextTrackDisplay(). This call is not in the | |
3341 // spec, see the note in configureTextTrackDisplay(). | |
3342 updateTextTrackDisplay(); | |
3343 } | |
3344 | |
3345 void HTMLMediaElement::setTextTrackKindUserPreferenceForAllMediaElements(Documen
t* document) | 3334 void HTMLMediaElement::setTextTrackKindUserPreferenceForAllMediaElements(Documen
t* document) |
3346 { | 3335 { |
3347 auto it = documentToElementSetMap().find(document); | 3336 auto it = documentToElementSetMap().find(document); |
3348 if (it == documentToElementSetMap().end()) | 3337 if (it == documentToElementSetMap().end()) |
3349 return; | 3338 return; |
3350 ASSERT(it->value); | 3339 ASSERT(it->value); |
3351 WeakMediaElementSet& elements = *it->value; | 3340 WeakMediaElementSet& elements = *it->value; |
3352 for (const auto& element : elements) | 3341 for (const auto& element : elements) |
3353 element->automaticTrackSelectionForUpdatedUserPreference(); | 3342 element->automaticTrackSelectionForUpdatedUserPreference(); |
3354 } | 3343 } |
3355 | 3344 |
3356 void HTMLMediaElement::automaticTrackSelectionForUpdatedUserPreference() | 3345 void HTMLMediaElement::automaticTrackSelectionForUpdatedUserPreference() |
3357 { | 3346 { |
3358 if (!m_textTracks || !m_textTracks->length()) | 3347 if (!m_textTracks || !m_textTracks->length()) |
3359 return; | 3348 return; |
3360 | 3349 |
3361 markCaptionAndSubtitleTracksAsUnconfigured(); | 3350 markCaptionAndSubtitleTracksAsUnconfigured(); |
3362 m_processingPreferenceChange = true; | 3351 m_processingPreferenceChange = true; |
3363 m_closedCaptionsVisible = false; | 3352 m_textTracksVisible = false; |
3364 honorUserPreferencesForAutomaticTextTrackSelection(); | 3353 honorUserPreferencesForAutomaticTextTrackSelection(); |
3365 m_processingPreferenceChange = false; | 3354 m_processingPreferenceChange = false; |
3366 | 3355 |
3367 // If a track is set to 'showing' post performing automatic track selection, | 3356 // If a track is set to 'showing' post performing automatic track selection, |
3368 // set closed captions state to visible to update the CC button and display
the track. | 3357 // set text tracks state to visible to update the CC button and display the
track. |
3369 m_closedCaptionsVisible = m_textTracks->hasShowingTracks(); | 3358 m_textTracksVisible = m_textTracks->hasShowingTracks(); |
3370 updateTextTrackDisplay(); | 3359 updateTextTrackDisplay(); |
3371 } | 3360 } |
3372 | 3361 |
3373 void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured() | 3362 void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured() |
3374 { | 3363 { |
3375 if (!m_textTracks) | 3364 if (!m_textTracks) |
3376 return; | 3365 return; |
3377 | 3366 |
3378 // Mark all tracks as not "configured" so that | 3367 // Mark all tracks as not "configured" so that |
3379 // honorUserPreferencesForAutomaticTextTrackSelection() will reconsider | 3368 // honorUserPreferencesForAutomaticTextTrackSelection() will reconsider |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3484 | 3473 |
3485 void HTMLMediaElement::configureTextTrackDisplay() | 3474 void HTMLMediaElement::configureTextTrackDisplay() |
3486 { | 3475 { |
3487 ASSERT(m_textTracks); | 3476 ASSERT(m_textTracks); |
3488 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackDisplay(%p)", this); | 3477 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackDisplay(%p)", this); |
3489 | 3478 |
3490 if (m_processingPreferenceChange) | 3479 if (m_processingPreferenceChange) |
3491 return; | 3480 return; |
3492 | 3481 |
3493 bool haveVisibleTextTrack = m_textTracks->hasShowingTracks(); | 3482 bool haveVisibleTextTrack = m_textTracks->hasShowingTracks(); |
3494 m_closedCaptionsVisible = haveVisibleTextTrack; | 3483 m_textTracksVisible = haveVisibleTextTrack; |
3495 | 3484 |
3496 if (!haveVisibleTextTrack && !mediaControls()) | 3485 if (!haveVisibleTextTrack && !mediaControls()) |
3497 return; | 3486 return; |
3498 | 3487 |
3499 if (mediaControls()) | 3488 if (mediaControls()) |
3500 mediaControls()->changedClosedCaptionsVisibility(); | 3489 mediaControls()->changedClosedCaptionsVisibility(); |
3501 | 3490 |
3502 cueTimeline().updateActiveCues(currentTime()); | 3491 cueTimeline().updateActiveCues(currentTime()); |
3503 | 3492 |
3504 // Note: The "time marches on" algorithm (updateActiveCues) runs the "rules | 3493 // Note: The "time marches on" algorithm (updateActiveCues) runs the "rules |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3852 | 3841 |
3853 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co
nst | 3842 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co
nst |
3854 { | 3843 { |
3855 IntRect result; | 3844 IntRect result; |
3856 if (LayoutObject* object = m_element->layoutObject()) | 3845 if (LayoutObject* object = m_element->layoutObject()) |
3857 result = object->absoluteBoundingBoxRect(); | 3846 result = object->absoluteBoundingBoxRect(); |
3858 return result; | 3847 return result; |
3859 } | 3848 } |
3860 | 3849 |
3861 } // namespace blink | 3850 } // namespace blink |
OLD | NEW |