Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLVideoElement.cpp

Issue 2767823002: Media Remoting: Add interstitial elements to media element shadow dom. (Closed)
Patch Set: Addressed mlamouri's comments. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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_mediaRemotingStatus(NotStarted),
72 m_remotingInterstitial(nullptr) {
70 if (document.settings()) { 73 if (document.settings()) {
71 m_defaultPosterURL = 74 m_defaultPosterURL =
72 AtomicString(document.settings()->getDefaultVideoPosterURL()); 75 AtomicString(document.settings()->getDefaultVideoPosterURL());
73 } 76 }
74 77
75 if (RuntimeEnabledFeatures::videoFullscreenDetectionEnabled()) { 78 if (RuntimeEnabledFeatures::videoFullscreenDetectionEnabled()) {
76 m_customControlsFullscreenDetector = 79 m_customControlsFullscreenDetector =
77 new MediaCustomControlsFullscreenDetector(*this); 80 new MediaCustomControlsFullscreenDetector(*this);
78 } 81 }
79 } 82 }
80 83
81 HTMLVideoElement* HTMLVideoElement::create(Document& document) { 84 HTMLVideoElement* HTMLVideoElement::create(Document& document) {
82 HTMLVideoElement* video = new HTMLVideoElement(document); 85 HTMLVideoElement* video = new HTMLVideoElement(document);
83 video->ensureUserAgentShadowRoot(); 86 video->ensureUserAgentShadowRoot();
84 video->suspendIfNeeded(); 87 video->suspendIfNeeded();
85 return video; 88 return video;
86 } 89 }
87 90
88 DEFINE_TRACE(HTMLVideoElement) { 91 DEFINE_TRACE(HTMLVideoElement) {
89 visitor->trace(m_imageLoader); 92 visitor->trace(m_imageLoader);
90 visitor->trace(m_customControlsFullscreenDetector); 93 visitor->trace(m_customControlsFullscreenDetector);
94 visitor->trace(m_remotingInterstitial);
91 HTMLMediaElement::trace(visitor); 95 HTMLMediaElement::trace(visitor);
92 } 96 }
93 97
94 Node::InsertionNotificationRequest HTMLVideoElement::insertedInto( 98 Node::InsertionNotificationRequest HTMLVideoElement::insertedInto(
95 ContainerNode* insertionPoint) { 99 ContainerNode* insertionPoint) {
96 if (insertionPoint->isConnected() && m_customControlsFullscreenDetector) 100 if (insertionPoint->isConnected() && m_customControlsFullscreenDetector)
97 m_customControlsFullscreenDetector->attach(); 101 m_customControlsFullscreenDetector->attach();
98 102
99 return HTMLMediaElement::insertedInto(insertionPoint); 103 return HTMLMediaElement::insertedInto(insertionPoint);
100 } 104 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 if (!m_imageLoader) 176 if (!m_imageLoader)
173 m_imageLoader = HTMLImageLoader::create(this); 177 m_imageLoader = HTMLImageLoader::create(this);
174 m_imageLoader->updateFromElement(ImageLoader::UpdateIgnorePreviousError); 178 m_imageLoader->updateFromElement(ImageLoader::UpdateIgnorePreviousError);
175 } else { 179 } else {
176 if (layoutObject()) 180 if (layoutObject())
177 toLayoutImage(layoutObject())->imageResource()->setImageResource(0); 181 toLayoutImage(layoutObject())->imageResource()->setImageResource(0);
178 } 182 }
179 // Notify the player when the poster image URL changes. 183 // Notify the player when the poster image URL changes.
180 if (webMediaPlayer()) 184 if (webMediaPlayer())
181 webMediaPlayer()->setPoster(posterImageURL()); 185 webMediaPlayer()->setPoster(posterImageURL());
186 if (m_remotingInterstitial)
mlamouri (slow - plz ping) 2017/04/10 13:44:22 Can you add a TODO explaining that ideally, the or
xjz 2017/04/11 04:29:44 Add comment. It's not TODO, but by design, we need
187 m_remotingInterstitial->onPosterImageChanged();
182 } else { 188 } else {
183 HTMLMediaElement::parseAttribute(params); 189 HTMLMediaElement::parseAttribute(params);
184 } 190 }
185 } 191 }
186 192
187 unsigned HTMLVideoElement::videoWidth() const { 193 unsigned HTMLVideoElement::videoWidth() const {
188 if (!webMediaPlayer()) 194 if (!webMediaPlayer())
189 return 0; 195 return 0;
190 return webMediaPlayer()->naturalSize().width; 196 return webMediaPlayer()->naturalSize().width;
191 } 197 }
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 exceptionState)) 477 exceptionState))
472 return ScriptPromise(); 478 return ScriptPromise();
473 if (!ImageBitmap::isResizeOptionValid(options, exceptionState)) 479 if (!ImageBitmap::isResizeOptionValid(options, exceptionState))
474 return ScriptPromise(); 480 return ScriptPromise();
475 return ImageBitmapSource::fulfillImageBitmap( 481 return ImageBitmapSource::fulfillImageBitmap(
476 scriptState, 482 scriptState,
477 ImageBitmap::create(this, cropRect, 483 ImageBitmap::create(this, cropRect,
478 eventTarget.toLocalDOMWindow()->document(), options)); 484 eventTarget.toLocalDOMWindow()->document(), options));
479 } 485 }
480 486
487 void HTMLVideoElement::mediaRemotingStarted() {
488 DCHECK_EQ(m_mediaRemotingStatus, NotStarted);
489 m_mediaRemotingStatus = Started;
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 if (m_mediaRemotingStatus != Disabled)
502 m_mediaRemotingStatus = NotStarted;
503 if (m_remotingInterstitial)
504 m_remotingInterstitial->hide();
505 }
506
507 void HTMLVideoElement::disableMediaRemoting() {
508 if (webMediaPlayer())
509 webMediaPlayer()->requestRemotePlaybackDisabled(true);
510 m_mediaRemotingStatus = Disabled;
511 mediaRemotingStopped();
512 }
513
481 } // namespace blink 514 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698