| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 constexpr float kMostlyFillViewportThreshold = 0.85f; | 128 constexpr float kMostlyFillViewportThreshold = 0.85f; |
| 129 constexpr double kMostlyFillViewportBecomeStableSeconds = 5; | 129 constexpr double kMostlyFillViewportBecomeStableSeconds = 5; |
| 130 constexpr double kCheckViewportIntersectionIntervalSeconds = 1; | 130 constexpr double kCheckViewportIntersectionIntervalSeconds = 1; |
| 131 | 131 |
| 132 enum MediaControlsShow { | 132 enum MediaControlsShow { |
| 133 MediaControlsShowAttribute = 0, | 133 MediaControlsShowAttribute = 0, |
| 134 MediaControlsShowFullscreen, | 134 MediaControlsShowFullscreen, |
| 135 MediaControlsShowNoScript, | 135 MediaControlsShowNoScript, |
| 136 MediaControlsShowNotShown, | 136 MediaControlsShowNotShown, |
| 137 MediaControlsShowDisabledSettings, |
| 137 MediaControlsShowMax | 138 MediaControlsShowMax |
| 138 }; | 139 }; |
| 139 | 140 |
| 140 String urlForLoggingMedia(const KURL& url) { | 141 String urlForLoggingMedia(const KURL& url) { |
| 141 static const unsigned maximumURLLengthForLogging = 128; | 142 static const unsigned maximumURLLengthForLogging = 128; |
| 142 | 143 |
| 143 if (url.getString().length() < maximumURLLengthForLogging) | 144 if (url.getString().length() < maximumURLLengthForLogging) |
| 144 return url.getString(); | 145 return url.getString(); |
| 145 return url.getString().substring(0, maximumURLLengthForLogging) + "..."; | 146 return url.getString().substring(0, maximumURLLengthForLogging) + "..."; |
| 146 } | 147 } |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 return false; | 366 return false; |
| 366 | 367 |
| 367 return url.getString().contains("m3u8"); | 368 return url.getString().contains("m3u8"); |
| 368 } | 369 } |
| 369 | 370 |
| 370 bool HTMLMediaElement::mediaTracksEnabledInternally() { | 371 bool HTMLMediaElement::mediaTracksEnabledInternally() { |
| 371 return RuntimeEnabledFeatures::audioVideoTracksEnabled() || | 372 return RuntimeEnabledFeatures::audioVideoTracksEnabled() || |
| 372 RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled(); | 373 RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled(); |
| 373 } | 374 } |
| 374 | 375 |
| 376 void HTMLMediaElement::onMediaControlsEnabledChange(Document* document) { |
| 377 auto it = documentToElementSetMap().find(document); |
| 378 if (it == documentToElementSetMap().end()) |
| 379 return; |
| 380 DCHECK(it->value); |
| 381 WeakMediaElementSet& elements = *it->value; |
| 382 for (const auto& element : elements) { |
| 383 element->updateControlsVisibility(); |
| 384 element->mediaControls()->onMediaControlsEnabledChange(); |
| 385 } |
| 386 } |
| 387 |
| 375 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, | 388 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, |
| 376 Document& document) | 389 Document& document) |
| 377 : HTMLElement(tagName, document), | 390 : HTMLElement(tagName, document), |
| 378 SuspendableObject(&document), | 391 SuspendableObject(&document), |
| 379 m_loadTimer(TaskRunnerHelper::get(TaskType::Unthrottled, &document), | 392 m_loadTimer(TaskRunnerHelper::get(TaskType::Unthrottled, &document), |
| 380 this, | 393 this, |
| 381 &HTMLMediaElement::loadTimerFired), | 394 &HTMLMediaElement::loadTimerFired), |
| 382 m_progressEventTimer( | 395 m_progressEventTimer( |
| 383 TaskRunnerHelper::get(TaskType::Unthrottled, &document), | 396 TaskRunnerHelper::get(TaskType::Unthrottled, &document), |
| 384 this, | 397 this, |
| (...skipping 1994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2379 return fastHasAttribute(loopAttr); | 2392 return fastHasAttribute(loopAttr); |
| 2380 } | 2393 } |
| 2381 | 2394 |
| 2382 void HTMLMediaElement::setLoop(bool b) { | 2395 void HTMLMediaElement::setLoop(bool b) { |
| 2383 BLINK_MEDIA_LOG << "setLoop(" << (void*)this << ", " << boolString(b) << ")"; | 2396 BLINK_MEDIA_LOG << "setLoop(" << (void*)this << ", " << boolString(b) << ")"; |
| 2384 setBooleanAttribute(loopAttr, b); | 2397 setBooleanAttribute(loopAttr, b); |
| 2385 } | 2398 } |
| 2386 | 2399 |
| 2387 bool HTMLMediaElement::shouldShowControls( | 2400 bool HTMLMediaElement::shouldShowControls( |
| 2388 const RecordMetricsBehavior recordMetrics) const { | 2401 const RecordMetricsBehavior recordMetrics) const { |
| 2402 Settings* settings = document().settings(); |
| 2403 if (settings && !settings->getMediaControlsEnabled()) { |
| 2404 if (recordMetrics == RecordMetricsBehavior::DoRecord) |
| 2405 showControlsHistogram().count(MediaControlsShowDisabledSettings); |
| 2406 return false; |
| 2407 } |
| 2408 |
| 2389 if (fastHasAttribute(controlsAttr)) { | 2409 if (fastHasAttribute(controlsAttr)) { |
| 2390 if (recordMetrics == RecordMetricsBehavior::DoRecord) | 2410 if (recordMetrics == RecordMetricsBehavior::DoRecord) |
| 2391 showControlsHistogram().count(MediaControlsShowAttribute); | 2411 showControlsHistogram().count(MediaControlsShowAttribute); |
| 2392 return true; | 2412 return true; |
| 2393 } | 2413 } |
| 2394 | 2414 |
| 2395 if (isFullscreen()) { | 2415 if (isFullscreen()) { |
| 2396 if (recordMetrics == RecordMetricsBehavior::DoRecord) | 2416 if (recordMetrics == RecordMetricsBehavior::DoRecord) |
| 2397 showControlsHistogram().count(MediaControlsShowFullscreen); | 2417 showControlsHistogram().count(MediaControlsShowFullscreen); |
| 2398 return true; | 2418 return true; |
| (...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4148 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); | 4168 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); |
| 4149 } | 4169 } |
| 4150 | 4170 |
| 4151 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { | 4171 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { |
| 4152 m_mostlyFillingViewport = true; | 4172 m_mostlyFillingViewport = true; |
| 4153 if (m_webMediaPlayer) | 4173 if (m_webMediaPlayer) |
| 4154 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); | 4174 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); |
| 4155 } | 4175 } |
| 4156 | 4176 |
| 4157 } // namespace blink | 4177 } // namespace blink |
| OLD | NEW |