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

Side by Side Diff: third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp

Issue 2830713003: [Media controls] Add rotate-to-fullscreen gesture behind flag (Closed)
Patch Set: 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) 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2011, 2012 Google Inc. All rights 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 27 matching lines...) Expand all
38 #include "core/frame/UseCounter.h" 38 #include "core/frame/UseCounter.h"
39 #include "core/html/HTMLMediaElement.h" 39 #include "core/html/HTMLMediaElement.h"
40 #include "core/html/HTMLVideoElement.h" 40 #include "core/html/HTMLVideoElement.h"
41 #include "core/html/media/HTMLMediaElementControlsList.h" 41 #include "core/html/media/HTMLMediaElementControlsList.h"
42 #include "core/html/track/TextTrackContainer.h" 42 #include "core/html/track/TextTrackContainer.h"
43 #include "core/html/track/TextTrackList.h" 43 #include "core/html/track/TextTrackList.h"
44 #include "core/layout/LayoutObject.h" 44 #include "core/layout/LayoutObject.h"
45 #include "core/layout/LayoutTheme.h" 45 #include "core/layout/LayoutTheme.h"
46 #include "modules/media_controls/MediaControlsMediaEventListener.h" 46 #include "modules/media_controls/MediaControlsMediaEventListener.h"
47 #include "modules/media_controls/MediaControlsOrientationLockDelegate.h" 47 #include "modules/media_controls/MediaControlsOrientationLockDelegate.h"
48 #include "modules/media_controls/MediaControlsRotateToFullscreenDelegate.h"
48 #include "modules/media_controls/MediaControlsWindowEventListener.h" 49 #include "modules/media_controls/MediaControlsWindowEventListener.h"
49 #include "modules/media_controls/elements/MediaControlCastButtonElement.h" 50 #include "modules/media_controls/elements/MediaControlCastButtonElement.h"
50 #include "modules/media_controls/elements/MediaControlCurrentTimeDisplayElement. h" 51 #include "modules/media_controls/elements/MediaControlCurrentTimeDisplayElement. h"
51 #include "modules/media_controls/elements/MediaControlDownloadButtonElement.h" 52 #include "modules/media_controls/elements/MediaControlDownloadButtonElement.h"
52 #include "modules/media_controls/elements/MediaControlFullscreenButtonElement.h" 53 #include "modules/media_controls/elements/MediaControlFullscreenButtonElement.h"
53 #include "modules/media_controls/elements/MediaControlMuteButtonElement.h" 54 #include "modules/media_controls/elements/MediaControlMuteButtonElement.h"
54 #include "modules/media_controls/elements/MediaControlOverflowMenuButtonElement. h" 55 #include "modules/media_controls/elements/MediaControlOverflowMenuButtonElement. h"
55 #include "modules/media_controls/elements/MediaControlOverflowMenuListElement.h" 56 #include "modules/media_controls/elements/MediaControlOverflowMenuListElement.h"
56 #include "modules/media_controls/elements/MediaControlOverlayEnclosureElement.h" 57 #include "modules/media_controls/elements/MediaControlOverlayEnclosureElement.h"
57 #include "modules/media_controls/elements/MediaControlOverlayPlayButtonElement.h " 58 #include "modules/media_controls/elements/MediaControlOverlayPlayButtonElement.h "
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 overflow_list_(nullptr), 217 overflow_list_(nullptr),
217 cast_button_(nullptr), 218 cast_button_(nullptr),
218 fullscreen_button_(nullptr), 219 fullscreen_button_(nullptr),
219 download_button_(nullptr), 220 download_button_(nullptr),
220 media_event_listener_(new MediaControlsMediaEventListener(this)), 221 media_event_listener_(new MediaControlsMediaEventListener(this)),
221 window_event_listener_(MediaControlsWindowEventListener::Create( 222 window_event_listener_(MediaControlsWindowEventListener::Create(
222 this, 223 this,
223 WTF::Bind(&MediaControlsImpl::HideAllMenus, 224 WTF::Bind(&MediaControlsImpl::HideAllMenus,
224 WrapWeakPersistent(this)))), 225 WrapWeakPersistent(this)))),
225 orientation_lock_delegate_(nullptr), 226 orientation_lock_delegate_(nullptr),
227 rotate_to_fullscreen_delegate_(nullptr),
226 hide_media_controls_timer_( 228 hide_media_controls_timer_(
227 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, 229 TaskRunnerHelper::Get(TaskType::kUnspecedTimer,
228 &media_element.GetDocument()), 230 &media_element.GetDocument()),
229 this, 231 this,
230 &MediaControlsImpl::HideMediaControlsTimerFired), 232 &MediaControlsImpl::HideMediaControlsTimerFired),
231 hide_timer_behavior_flags_(kIgnoreNone), 233 hide_timer_behavior_flags_(kIgnoreNone),
232 is_mouse_over_controls_(false), 234 is_mouse_over_controls_(false),
233 is_paused_for_scrubbing_(false), 235 is_paused_for_scrubbing_(false),
234 resize_observer_(ResizeObserver::Create( 236 resize_observer_(ResizeObserver::Create(
235 media_element.GetDocument(), 237 media_element.GetDocument(),
236 new MediaControlsResizeObserverCallback(this))), 238 new MediaControlsResizeObserverCallback(this))),
237 element_size_changed_timer_( 239 element_size_changed_timer_(
238 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, 240 TaskRunnerHelper::Get(TaskType::kUnspecedTimer,
239 &media_element.GetDocument()), 241 &media_element.GetDocument()),
240 this, 242 this,
241 &MediaControlsImpl::ElementSizeChangedTimerFired), 243 &MediaControlsImpl::ElementSizeChangedTimerFired),
242 keep_showing_until_timer_fires_(false) { 244 keep_showing_until_timer_fires_(false) {
243 resize_observer_->observe(&media_element); 245 resize_observer_->observe(&media_element);
244 } 246 }
245 247
246 MediaControlsImpl* MediaControlsImpl::Create(HTMLMediaElement& media_element, 248 MediaControlsImpl* MediaControlsImpl::Create(HTMLMediaElement& media_element,
247 ShadowRoot& shadow_root) { 249 ShadowRoot& shadow_root) {
248 MediaControlsImpl* controls = new MediaControlsImpl(media_element); 250 MediaControlsImpl* controls = new MediaControlsImpl(media_element);
249 controls->SetShadowPseudoId(AtomicString("-webkit-media-controls")); 251 controls->SetShadowPseudoId(AtomicString("-webkit-media-controls"));
250 controls->InitializeControls(); 252 controls->InitializeControls();
251 controls->Reset(); 253 controls->Reset();
252 254
253 // Initialize the orientation lock when going fullscreen feature. 255 if (RuntimeEnabledFeatures::videoRotateToFullscreenEnabled() &&
254 if (RuntimeEnabledFeatures::videoFullscreenOrientationLockEnabled() &&
255 media_element.IsHTMLVideoElement()) { 256 media_element.IsHTMLVideoElement()) {
257 // Initialize the rotate-to-fullscreen feature.
258 controls->rotate_to_fullscreen_delegate_ =
259 new MediaControlsRotateToFullscreenDelegate(
260 toHTMLVideoElement(media_element));
261 } // TODO(johnme): Make it possible to use both features simultaneously.
mlamouri (slow - plz ping) 2017/04/19 17:10:45 Maybe say that they are not compatible now so if t
johnme 2017/04/19 18:21:28 Done.
262 else if (RuntimeEnabledFeatures::videoFullscreenOrientationLockEnabled() &&
263 media_element.IsHTMLVideoElement()) {
264 // Initialize the orientation lock when going fullscreen feature.
256 controls->orientation_lock_delegate_ = 265 controls->orientation_lock_delegate_ =
257 new MediaControlsOrientationLockDelegate( 266 new MediaControlsOrientationLockDelegate(
258 toHTMLVideoElement(media_element)); 267 toHTMLVideoElement(media_element));
259 } 268 }
260 269
261 shadow_root.AppendChild(controls); 270 shadow_root.AppendChild(controls);
262 return controls; 271 return controls;
263 } 272 }
264 273
265 // The media controls DOM structure looks like: 274 // The media controls DOM structure looks like:
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 return HTMLDivElement::InsertedInto(root); 412 return HTMLDivElement::InsertedInto(root);
404 413
405 // TODO(mlamouri): we should show the controls instead of having 414 // TODO(mlamouri): we should show the controls instead of having
406 // HTMLMediaElement do it. 415 // HTMLMediaElement do it.
407 416
408 // m_windowEventListener doesn't need to be re-attached as it's only needed 417 // m_windowEventListener doesn't need to be re-attached as it's only needed
409 // when a menu is visible. 418 // when a menu is visible.
410 media_event_listener_->Attach(); 419 media_event_listener_->Attach();
411 if (orientation_lock_delegate_) 420 if (orientation_lock_delegate_)
412 orientation_lock_delegate_->Attach(); 421 orientation_lock_delegate_->Attach();
422 if (rotate_to_fullscreen_delegate_)
423 rotate_to_fullscreen_delegate_->Attach();
413 424
414 if (!resize_observer_) { 425 if (!resize_observer_) {
415 resize_observer_ = 426 resize_observer_ =
416 ResizeObserver::Create(MediaElement().GetDocument(), 427 ResizeObserver::Create(MediaElement().GetDocument(),
417 new MediaControlsResizeObserverCallback(this)); 428 new MediaControlsResizeObserverCallback(this));
418 HTMLMediaElement& html_media_element = MediaElement(); 429 HTMLMediaElement& html_media_element = MediaElement();
419 resize_observer_->observe(&html_media_element); 430 resize_observer_->observe(&html_media_element);
420 } 431 }
421 432
422 return HTMLDivElement::InsertedInto(root); 433 return HTMLDivElement::InsertedInto(root);
423 } 434 }
424 435
425 void MediaControlsImpl::RemovedFrom(ContainerNode*) { 436 void MediaControlsImpl::RemovedFrom(ContainerNode*) {
426 DCHECK(!MediaElement().isConnected()); 437 DCHECK(!MediaElement().isConnected());
427 438
428 // TODO(mlamouri): we hide show the controls instead of having 439 // TODO(mlamouri): we hide show the controls instead of having
429 // HTMLMediaElement do it. 440 // HTMLMediaElement do it.
430 441
431 window_event_listener_->Stop(); 442 window_event_listener_->Stop();
432 media_event_listener_->Detach(); 443 media_event_listener_->Detach();
433 if (orientation_lock_delegate_) 444 if (orientation_lock_delegate_)
434 orientation_lock_delegate_->Detach(); 445 orientation_lock_delegate_->Detach();
446 if (rotate_to_fullscreen_delegate_)
447 rotate_to_fullscreen_delegate_->Detach();
435 448
436 resize_observer_.Clear(); 449 resize_observer_.Clear();
437 } 450 }
438 451
439 void MediaControlsImpl::Reset() { 452 void MediaControlsImpl::Reset() {
440 EventDispatchForbiddenScope::AllowUserAgentEvents allow_events_in_shadow; 453 EventDispatchForbiddenScope::AllowUserAgentEvents allow_events_in_shadow;
441 BatchedControlUpdate batch(this); 454 BatchedControlUpdate batch(this);
442 455
443 const double duration = MediaElement().duration(); 456 const double duration = MediaElement().duration();
444 duration_display_->setTextContent( 457 duration_display_->setTextContent(
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 visitor->Trace(duration_display_); 1138 visitor->Trace(duration_display_);
1126 visitor->Trace(enclosure_); 1139 visitor->Trace(enclosure_);
1127 visitor->Trace(text_track_list_); 1140 visitor->Trace(text_track_list_);
1128 visitor->Trace(overflow_menu_); 1141 visitor->Trace(overflow_menu_);
1129 visitor->Trace(overflow_list_); 1142 visitor->Trace(overflow_list_);
1130 visitor->Trace(cast_button_); 1143 visitor->Trace(cast_button_);
1131 visitor->Trace(overlay_cast_button_); 1144 visitor->Trace(overlay_cast_button_);
1132 visitor->Trace(media_event_listener_); 1145 visitor->Trace(media_event_listener_);
1133 visitor->Trace(window_event_listener_); 1146 visitor->Trace(window_event_listener_);
1134 visitor->Trace(orientation_lock_delegate_); 1147 visitor->Trace(orientation_lock_delegate_);
1148 visitor->Trace(rotate_to_fullscreen_delegate_);
1135 MediaControls::Trace(visitor); 1149 MediaControls::Trace(visitor);
1136 HTMLDivElement::Trace(visitor); 1150 HTMLDivElement::Trace(visitor);
1137 } 1151 }
1138 1152
1139 } // namespace blink 1153 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698