| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 return false; | 351 return false; |
| 351 | 352 |
| 352 return url.getString().contains("m3u8"); | 353 return url.getString().contains("m3u8"); |
| 353 } | 354 } |
| 354 | 355 |
| 355 bool HTMLMediaElement::mediaTracksEnabledInternally() { | 356 bool HTMLMediaElement::mediaTracksEnabledInternally() { |
| 356 return RuntimeEnabledFeatures::audioVideoTracksEnabled() || | 357 return RuntimeEnabledFeatures::audioVideoTracksEnabled() || |
| 357 RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled(); | 358 RuntimeEnabledFeatures::backgroundVideoTrackOptimizationEnabled(); |
| 358 } | 359 } |
| 359 | 360 |
| 361 void HTMLMediaElement::onMediaControlsEnabledChange(Document* document) { |
| 362 auto it = documentToElementSetMap().find(document); |
| 363 if (it == documentToElementSetMap().end()) |
| 364 return; |
| 365 DCHECK(it->value); |
| 366 WeakMediaElementSet& elements = *it->value; |
| 367 for (const auto& element : elements) |
| 368 element->updateControlsVisibility(); |
| 369 } |
| 370 |
| 360 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, | 371 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, |
| 361 Document& document) | 372 Document& document) |
| 362 : HTMLElement(tagName, document), | 373 : HTMLElement(tagName, document), |
| 363 SuspendableObject(&document), | 374 SuspendableObject(&document), |
| 364 m_loadTimer(TaskRunnerHelper::get(TaskType::Unthrottled, &document), | 375 m_loadTimer(TaskRunnerHelper::get(TaskType::Unthrottled, &document), |
| 365 this, | 376 this, |
| 366 &HTMLMediaElement::loadTimerFired), | 377 &HTMLMediaElement::loadTimerFired), |
| 367 m_progressEventTimer( | 378 m_progressEventTimer( |
| 368 TaskRunnerHelper::get(TaskType::Unthrottled, &document), | 379 TaskRunnerHelper::get(TaskType::Unthrottled, &document), |
| 369 this, | 380 this, |
| (...skipping 1984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2354 return fastHasAttribute(loopAttr); | 2365 return fastHasAttribute(loopAttr); |
| 2355 } | 2366 } |
| 2356 | 2367 |
| 2357 void HTMLMediaElement::setLoop(bool b) { | 2368 void HTMLMediaElement::setLoop(bool b) { |
| 2358 BLINK_MEDIA_LOG << "setLoop(" << (void*)this << ", " << boolString(b) << ")"; | 2369 BLINK_MEDIA_LOG << "setLoop(" << (void*)this << ", " << boolString(b) << ")"; |
| 2359 setBooleanAttribute(loopAttr, b); | 2370 setBooleanAttribute(loopAttr, b); |
| 2360 } | 2371 } |
| 2361 | 2372 |
| 2362 bool HTMLMediaElement::shouldShowControls( | 2373 bool HTMLMediaElement::shouldShowControls( |
| 2363 const RecordMetricsBehavior recordMetrics) const { | 2374 const RecordMetricsBehavior recordMetrics) const { |
| 2375 Settings* settings = document().settings(); |
| 2376 if (settings && !settings->getMediaControlsEnabled()) { |
| 2377 if (recordMetrics == RecordMetricsBehavior::DoRecord) |
| 2378 showControlsHistogram().count(MediaControlsShowDisabledSettings); |
| 2379 return false; |
| 2380 } |
| 2381 |
| 2364 if (fastHasAttribute(controlsAttr)) { | 2382 if (fastHasAttribute(controlsAttr)) { |
| 2365 if (recordMetrics == RecordMetricsBehavior::DoRecord) | 2383 if (recordMetrics == RecordMetricsBehavior::DoRecord) |
| 2366 showControlsHistogram().count(MediaControlsShowAttribute); | 2384 showControlsHistogram().count(MediaControlsShowAttribute); |
| 2367 return true; | 2385 return true; |
| 2368 } | 2386 } |
| 2369 | 2387 |
| 2370 if (isFullscreen()) { | 2388 if (isFullscreen()) { |
| 2371 if (recordMetrics == RecordMetricsBehavior::DoRecord) | 2389 if (recordMetrics == RecordMetricsBehavior::DoRecord) |
| 2372 showControlsHistogram().count(MediaControlsShowFullscreen); | 2390 showControlsHistogram().count(MediaControlsShowFullscreen); |
| 2373 return true; | 2391 return true; |
| (...skipping 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4126 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); | 4144 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); |
| 4127 } | 4145 } |
| 4128 | 4146 |
| 4129 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { | 4147 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { |
| 4130 m_mostlyFillingViewport = true; | 4148 m_mostlyFillingViewport = true; |
| 4131 if (m_webMediaPlayer) | 4149 if (m_webMediaPlayer) |
| 4132 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); | 4150 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); |
| 4133 } | 4151 } |
| 4134 | 4152 |
| 4135 } // namespace blink | 4153 } // namespace blink |
| OLD | NEW |