Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010 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 21 matching lines...) Expand all Loading... | |
| 32 #include "core/dom/Attribute.h" | 32 #include "core/dom/Attribute.h" |
| 33 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
| 34 #include "core/dom/ExceptionCode.h" | 34 #include "core/dom/ExceptionCode.h" |
| 35 #include "core/dom/Fullscreen.h" | 35 #include "core/dom/Fullscreen.h" |
| 36 #include "core/dom/shadow/ShadowRoot.h" | 36 #include "core/dom/shadow/ShadowRoot.h" |
| 37 #include "core/frame/ImageBitmap.h" | 37 #include "core/frame/ImageBitmap.h" |
| 38 #include "core/frame/LocalDOMWindow.h" | 38 #include "core/frame/LocalDOMWindow.h" |
| 39 #include "core/frame/Settings.h" | 39 #include "core/frame/Settings.h" |
| 40 #include "core/html/media/MediaCustomControlsFullscreenDetector.h" | 40 #include "core/html/media/MediaCustomControlsFullscreenDetector.h" |
| 41 #include "core/html/parser/HTMLParserIdioms.h" | 41 #include "core/html/parser/HTMLParserIdioms.h" |
| 42 #include "core/html/shadow/MediaRemotingInterstitial.h" | |
| 42 #include "core/imagebitmap/ImageBitmapOptions.h" | 43 #include "core/imagebitmap/ImageBitmapOptions.h" |
| 43 #include "core/layout/LayoutImage.h" | 44 #include "core/layout/LayoutImage.h" |
| 44 #include "core/layout/LayoutVideo.h" | 45 #include "core/layout/LayoutVideo.h" |
| 45 #include "platform/Histogram.h" | 46 #include "platform/Histogram.h" |
| 46 #include "platform/RuntimeEnabledFeatures.h" | 47 #include "platform/RuntimeEnabledFeatures.h" |
| 47 #include "platform/UserGestureIndicator.h" | 48 #include "platform/UserGestureIndicator.h" |
| 48 #include "platform/graphics/GraphicsContext.h" | 49 #include "platform/graphics/GraphicsContext.h" |
| 49 #include "platform/graphics/ImageBuffer.h" | 50 #include "platform/graphics/ImageBuffer.h" |
| 50 #include "platform/graphics/gpu/Extensions3DUtil.h" | 51 #include "platform/graphics/gpu/Extensions3DUtil.h" |
| 51 #include "public/platform/WebCanvas.h" | 52 #include "public/platform/WebCanvas.h" |
| 52 | 53 |
| 53 namespace blink { | 54 namespace blink { |
| 54 | 55 |
| 55 using namespace HTMLNames; | 56 using namespace HTMLNames; |
| 56 | 57 |
| 57 namespace { | 58 namespace { |
| 58 | 59 |
| 59 // This enum is used to record histograms. Do not reorder. | 60 // This enum is used to record histograms. Do not reorder. |
| 60 enum VideoPersistenceControlsType { | 61 enum VideoPersistenceControlsType { |
| 61 VideoPersistenceControlsTypeNative = 0, | 62 VideoPersistenceControlsTypeNative = 0, |
| 62 VideoPersistenceControlsTypeCustom, | 63 VideoPersistenceControlsTypeCustom, |
| 63 VideoPersistenceControlsTypeCount | 64 VideoPersistenceControlsTypeCount |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 } // anonymous namespace | 67 } // anonymous namespace |
| 67 | 68 |
| 68 inline HTMLVideoElement::HTMLVideoElement(Document& document) | 69 inline HTMLVideoElement::HTMLVideoElement(Document& document) |
| 69 : HTMLMediaElement(videoTag, document) { | 70 : HTMLMediaElement(videoTag, document), |
| 71 m_mediaRemotingDisabled(false), | |
| 72 m_mediaRemotingStarted(false), | |
| 73 m_remotingInterstitial(nullptr) { | |
| 70 if (document.settings()) { | 74 if (document.settings()) { |
| 71 m_defaultPosterURL = | 75 m_defaultPosterURL = |
| 72 AtomicString(document.settings()->getDefaultVideoPosterURL()); | 76 AtomicString(document.settings()->getDefaultVideoPosterURL()); |
| 73 } | 77 } |
| 74 | 78 |
| 75 if (RuntimeEnabledFeatures::videoFullscreenDetectionEnabled()) { | 79 if (RuntimeEnabledFeatures::videoFullscreenDetectionEnabled()) { |
| 76 m_customControlsFullscreenDetector = | 80 m_customControlsFullscreenDetector = |
| 77 new MediaCustomControlsFullscreenDetector(*this); | 81 new MediaCustomControlsFullscreenDetector(*this); |
| 78 } | 82 } |
| 79 } | 83 } |
| 80 | 84 |
| 81 HTMLVideoElement* HTMLVideoElement::create(Document& document) { | 85 HTMLVideoElement* HTMLVideoElement::create(Document& document) { |
| 82 HTMLVideoElement* video = new HTMLVideoElement(document); | 86 HTMLVideoElement* video = new HTMLVideoElement(document); |
| 83 video->ensureUserAgentShadowRoot(); | 87 video->ensureUserAgentShadowRoot(); |
| 84 video->suspendIfNeeded(); | 88 video->suspendIfNeeded(); |
| 85 return video; | 89 return video; |
| 86 } | 90 } |
| 87 | 91 |
| 88 DEFINE_TRACE(HTMLVideoElement) { | 92 DEFINE_TRACE(HTMLVideoElement) { |
| 89 visitor->trace(m_imageLoader); | 93 visitor->trace(m_imageLoader); |
| 90 visitor->trace(m_customControlsFullscreenDetector); | 94 visitor->trace(m_customControlsFullscreenDetector); |
| 95 visitor->trace(m_remotingInterstitial); | |
| 91 HTMLMediaElement::trace(visitor); | 96 HTMLMediaElement::trace(visitor); |
| 92 } | 97 } |
| 93 | 98 |
| 94 Node::InsertionNotificationRequest HTMLVideoElement::insertedInto( | 99 Node::InsertionNotificationRequest HTMLVideoElement::insertedInto( |
| 95 ContainerNode* insertionPoint) { | 100 ContainerNode* insertionPoint) { |
| 96 if (insertionPoint->isConnected() && m_customControlsFullscreenDetector) | 101 if (insertionPoint->isConnected() && m_customControlsFullscreenDetector) |
| 97 m_customControlsFullscreenDetector->attach(); | 102 m_customControlsFullscreenDetector->attach(); |
| 98 | 103 |
| 99 return HTMLMediaElement::insertedInto(insertionPoint); | 104 return HTMLMediaElement::insertedInto(insertionPoint); |
| 100 } | 105 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 if (!m_imageLoader) | 177 if (!m_imageLoader) |
| 173 m_imageLoader = HTMLImageLoader::create(this); | 178 m_imageLoader = HTMLImageLoader::create(this); |
| 174 m_imageLoader->updateFromElement(ImageLoader::UpdateIgnorePreviousError); | 179 m_imageLoader->updateFromElement(ImageLoader::UpdateIgnorePreviousError); |
| 175 } else { | 180 } else { |
| 176 if (layoutObject()) | 181 if (layoutObject()) |
| 177 toLayoutImage(layoutObject())->imageResource()->setImageResource(0); | 182 toLayoutImage(layoutObject())->imageResource()->setImageResource(0); |
| 178 } | 183 } |
| 179 // Notify the player when the poster image URL changes. | 184 // Notify the player when the poster image URL changes. |
| 180 if (webMediaPlayer()) | 185 if (webMediaPlayer()) |
| 181 webMediaPlayer()->setPoster(posterImageURL()); | 186 webMediaPlayer()->setPoster(posterImageURL()); |
| 187 if (m_remotingInterstitial) | |
| 188 m_remotingInterstitial->onPosterImageChanged(); | |
| 182 } else { | 189 } else { |
| 183 HTMLMediaElement::parseAttribute(params); | 190 HTMLMediaElement::parseAttribute(params); |
| 184 } | 191 } |
| 185 } | 192 } |
| 186 | 193 |
| 187 unsigned HTMLVideoElement::videoWidth() const { | 194 unsigned HTMLVideoElement::videoWidth() const { |
| 188 if (!webMediaPlayer()) | 195 if (!webMediaPlayer()) |
| 189 return 0; | 196 return 0; |
| 190 return webMediaPlayer()->naturalSize().width; | 197 return webMediaPlayer()->naturalSize().width; |
| 191 } | 198 } |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 471 exceptionState)) | 478 exceptionState)) |
| 472 return ScriptPromise(); | 479 return ScriptPromise(); |
| 473 if (!ImageBitmap::isResizeOptionValid(options, exceptionState)) | 480 if (!ImageBitmap::isResizeOptionValid(options, exceptionState)) |
| 474 return ScriptPromise(); | 481 return ScriptPromise(); |
| 475 return ImageBitmapSource::fulfillImageBitmap( | 482 return ImageBitmapSource::fulfillImageBitmap( |
| 476 scriptState, | 483 scriptState, |
| 477 ImageBitmap::create(this, cropRect, | 484 ImageBitmap::create(this, cropRect, |
| 478 eventTarget.toLocalDOMWindow()->document(), options)); | 485 eventTarget.toLocalDOMWindow()->document(), options)); |
| 479 } | 486 } |
| 480 | 487 |
| 488 void HTMLVideoElement::mediaRemotingStarted() { | |
| 489 m_mediaRemotingStarted = true; | |
| 490 if (!m_remotingInterstitial) { | |
| 491 m_remotingInterstitial = new MediaRemotingInterstitial(*this); | |
| 492 ShadowRoot& shadowRoot = ensureUserAgentShadowRoot(); | |
| 493 shadowRoot.insertBefore(m_remotingInterstitial, shadowRoot.firstChild()); | |
| 494 HTMLMediaElement::assertShadowRootChildren(shadowRoot); | |
| 495 } | |
| 496 if (m_remotingInterstitial) | |
| 497 m_remotingInterstitial->show(); | |
| 498 } | |
| 499 | |
| 500 void HTMLVideoElement::mediaRemotingStopped() { | |
| 501 m_mediaRemotingStarted = false; | |
| 502 if (m_remotingInterstitial) | |
| 503 m_remotingInterstitial->hide(); | |
| 504 } | |
| 505 | |
| 506 void HTMLVideoElement::disableMediaRemoting() { | |
| 507 if (webMediaPlayer()) | |
| 508 webMediaPlayer()->requestRemotePlaybackDisabled(true); | |
| 509 m_mediaRemotingDisabled = true; | |
| 510 m_mediaRemotingStarted = false; | |
| 511 if (m_remotingInterstitial) | |
| 512 m_remotingInterstitial->hide(); | |
|
mlamouri (slow - plz ping)
2017/04/07 13:18:32
Maybe you should call `mediaRemotingStopped()`.
xjz
2017/04/07 23:07:01
Done.
| |
| 513 } | |
| 514 | |
| 481 } // namespace blink | 515 } // namespace blink |
| OLD | NEW |