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 kVideoPersistenceControlsTypeNative = 0, | 62 kVideoPersistenceControlsTypeNative = 0, |
62 kVideoPersistenceControlsTypeCustom, | 63 kVideoPersistenceControlsTypeCustom, |
63 kVideoPersistenceControlsTypeCount | 64 kVideoPersistenceControlsTypeCount |
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 media_remoting_status_(kNotStarted), |
| 72 remoting_interstitial_(nullptr) { |
70 if (document.GetSettings()) { | 73 if (document.GetSettings()) { |
71 default_poster_url_ = | 74 default_poster_url_ = |
72 AtomicString(document.GetSettings()->GetDefaultVideoPosterURL()); | 75 AtomicString(document.GetSettings()->GetDefaultVideoPosterURL()); |
73 } | 76 } |
74 | 77 |
75 if (RuntimeEnabledFeatures::videoFullscreenDetectionEnabled()) { | 78 if (RuntimeEnabledFeatures::videoFullscreenDetectionEnabled()) { |
76 custom_controls_fullscreen_detector_ = | 79 custom_controls_fullscreen_detector_ = |
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(image_loader_); | 92 visitor->Trace(image_loader_); |
90 visitor->Trace(custom_controls_fullscreen_detector_); | 93 visitor->Trace(custom_controls_fullscreen_detector_); |
| 94 visitor->Trace(remoting_interstitial_); |
91 HTMLMediaElement::Trace(visitor); | 95 HTMLMediaElement::Trace(visitor); |
92 } | 96 } |
93 | 97 |
94 Node::InsertionNotificationRequest HTMLVideoElement::InsertedInto( | 98 Node::InsertionNotificationRequest HTMLVideoElement::InsertedInto( |
95 ContainerNode* insertion_point) { | 99 ContainerNode* insertion_point) { |
96 if (insertion_point->isConnected() && custom_controls_fullscreen_detector_) | 100 if (insertion_point->isConnected() && custom_controls_fullscreen_detector_) |
97 custom_controls_fullscreen_detector_->Attach(); | 101 custom_controls_fullscreen_detector_->Attach(); |
98 | 102 |
99 return HTMLMediaElement::InsertedInto(insertion_point); | 103 return HTMLMediaElement::InsertedInto(insertion_point); |
100 } | 104 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 if (!image_loader_) | 176 if (!image_loader_) |
173 image_loader_ = HTMLImageLoader::Create(this); | 177 image_loader_ = HTMLImageLoader::Create(this); |
174 image_loader_->UpdateFromElement(ImageLoader::kUpdateIgnorePreviousError); | 178 image_loader_->UpdateFromElement(ImageLoader::kUpdateIgnorePreviousError); |
175 } else { | 179 } else { |
176 if (GetLayoutObject()) | 180 if (GetLayoutObject()) |
177 ToLayoutImage(GetLayoutObject())->ImageResource()->SetImageResource(0); | 181 ToLayoutImage(GetLayoutObject())->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 (GetWebMediaPlayer()) | 184 if (GetWebMediaPlayer()) |
181 GetWebMediaPlayer()->SetPoster(PosterImageURL()); | 185 GetWebMediaPlayer()->SetPoster(PosterImageURL()); |
| 186 // Media remoting doesn't show the original poster image, instead, it shows |
| 187 // a grayscaled and blurred copy. |
| 188 if (remoting_interstitial_) |
| 189 remoting_interstitial_->OnPosterImageChanged(); |
182 } else { | 190 } else { |
183 HTMLMediaElement::ParseAttribute(params); | 191 HTMLMediaElement::ParseAttribute(params); |
184 } | 192 } |
185 } | 193 } |
186 | 194 |
187 unsigned HTMLVideoElement::videoWidth() const { | 195 unsigned HTMLVideoElement::videoWidth() const { |
188 if (!GetWebMediaPlayer()) | 196 if (!GetWebMediaPlayer()) |
189 return 0; | 197 return 0; |
190 return GetWebMediaPlayer()->NaturalSize().width; | 198 return GetWebMediaPlayer()->NaturalSize().width; |
191 } | 199 } |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 exception_state)) | 481 exception_state)) |
474 return ScriptPromise(); | 482 return ScriptPromise(); |
475 if (!ImageBitmap::IsResizeOptionValid(options, exception_state)) | 483 if (!ImageBitmap::IsResizeOptionValid(options, exception_state)) |
476 return ScriptPromise(); | 484 return ScriptPromise(); |
477 return ImageBitmapSource::FulfillImageBitmap( | 485 return ImageBitmapSource::FulfillImageBitmap( |
478 script_state, ImageBitmap::Create( | 486 script_state, ImageBitmap::Create( |
479 this, crop_rect, | 487 this, crop_rect, |
480 event_target.ToLocalDOMWindow()->document(), options)); | 488 event_target.ToLocalDOMWindow()->document(), options)); |
481 } | 489 } |
482 | 490 |
| 491 void HTMLVideoElement::MediaRemotingStarted() { |
| 492 DCHECK_EQ(media_remoting_status_, kNotStarted); |
| 493 media_remoting_status_ = kStarted; |
| 494 if (!remoting_interstitial_) { |
| 495 remoting_interstitial_ = new MediaRemotingInterstitial(*this); |
| 496 ShadowRoot& shadow_root = EnsureUserAgentShadowRoot(); |
| 497 shadow_root.InsertBefore(remoting_interstitial_, shadow_root.FirstChild()); |
| 498 HTMLMediaElement::AssertShadowRootChildren(shadow_root); |
| 499 } |
| 500 remoting_interstitial_->Show(); |
| 501 } |
| 502 |
| 503 void HTMLVideoElement::MediaRemotingStopped() { |
| 504 if (media_remoting_status_ != kDisabled) |
| 505 media_remoting_status_ = kNotStarted; |
| 506 DCHECK(remoting_interstitial_); |
| 507 remoting_interstitial_->Hide(); |
| 508 } |
| 509 |
| 510 void HTMLVideoElement::DisableMediaRemoting() { |
| 511 if (GetWebMediaPlayer()) |
| 512 GetWebMediaPlayer()->RequestRemotePlaybackDisabled(true); |
| 513 media_remoting_status_ = kDisabled; |
| 514 MediaRemotingStopped(); |
| 515 } |
| 516 |
483 } // namespace blink | 517 } // namespace blink |
OLD | NEW |