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

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: Use __func__ instead per styleguide Created 3 years, 7 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 overflow_list_(nullptr), 219 overflow_list_(nullptr),
219 cast_button_(nullptr), 220 cast_button_(nullptr),
220 fullscreen_button_(nullptr), 221 fullscreen_button_(nullptr),
221 download_button_(nullptr), 222 download_button_(nullptr),
222 media_event_listener_(new MediaControlsMediaEventListener(this)), 223 media_event_listener_(new MediaControlsMediaEventListener(this)),
223 window_event_listener_(MediaControlsWindowEventListener::Create( 224 window_event_listener_(MediaControlsWindowEventListener::Create(
224 this, 225 this,
225 WTF::Bind(&MediaControlsImpl::HideAllMenus, 226 WTF::Bind(&MediaControlsImpl::HideAllMenus,
226 WrapWeakPersistent(this)))), 227 WrapWeakPersistent(this)))),
227 orientation_lock_delegate_(nullptr), 228 orientation_lock_delegate_(nullptr),
229 rotate_to_fullscreen_delegate_(nullptr),
228 hide_media_controls_timer_( 230 hide_media_controls_timer_(
229 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, 231 TaskRunnerHelper::Get(TaskType::kUnspecedTimer,
230 &media_element.GetDocument()), 232 &media_element.GetDocument()),
231 this, 233 this,
232 &MediaControlsImpl::HideMediaControlsTimerFired), 234 &MediaControlsImpl::HideMediaControlsTimerFired),
233 hide_timer_behavior_flags_(kIgnoreNone), 235 hide_timer_behavior_flags_(kIgnoreNone),
234 is_mouse_over_controls_(false), 236 is_mouse_over_controls_(false),
235 is_paused_for_scrubbing_(false), 237 is_paused_for_scrubbing_(false),
236 resize_observer_(ResizeObserver::Create( 238 resize_observer_(ResizeObserver::Create(
237 media_element.GetDocument(), 239 media_element.GetDocument(),
238 new MediaControlsResizeObserverCallback(this))), 240 new MediaControlsResizeObserverCallback(this))),
239 element_size_changed_timer_( 241 element_size_changed_timer_(
240 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, 242 TaskRunnerHelper::Get(TaskType::kUnspecedTimer,
241 &media_element.GetDocument()), 243 &media_element.GetDocument()),
242 this, 244 this,
243 &MediaControlsImpl::ElementSizeChangedTimerFired), 245 &MediaControlsImpl::ElementSizeChangedTimerFired),
244 keep_showing_until_timer_fires_(false) { 246 keep_showing_until_timer_fires_(false) {
245 resize_observer_->observe(&media_element); 247 resize_observer_->observe(&media_element);
246 } 248 }
247 249
248 MediaControlsImpl* MediaControlsImpl::Create(HTMLMediaElement& media_element, 250 MediaControlsImpl* MediaControlsImpl::Create(HTMLMediaElement& media_element,
249 ShadowRoot& shadow_root) { 251 ShadowRoot& shadow_root) {
250 MediaControlsImpl* controls = new MediaControlsImpl(media_element); 252 MediaControlsImpl* controls = new MediaControlsImpl(media_element);
251 controls->SetShadowPseudoId(AtomicString("-webkit-media-controls")); 253 controls->SetShadowPseudoId(AtomicString("-webkit-media-controls"));
252 controls->InitializeControls(); 254 controls->InitializeControls();
253 controls->Reset(); 255 controls->Reset();
254 256
255 // Initialize the orientation lock when going fullscreen feature. 257 // RotateToFullscreen and FullscreenOrientationLock are not yet compatible
256 if (RuntimeEnabledFeatures::videoFullscreenOrientationLockEnabled() && 258 // so enabling RotateToFullscreen disables FullscreenOrientationLock.
259 // TODO(johnme): Make it possible to use both features simultaneously.
260 if (RuntimeEnabledFeatures::videoRotateToFullscreenEnabled() &&
257 media_element.IsHTMLVideoElement()) { 261 media_element.IsHTMLVideoElement()) {
262 // Initialize the rotate-to-fullscreen feature.
263 controls->rotate_to_fullscreen_delegate_ =
264 new MediaControlsRotateToFullscreenDelegate(
265 toHTMLVideoElement(media_element));
266 } else if (RuntimeEnabledFeatures::videoFullscreenOrientationLockEnabled() &&
267 media_element.IsHTMLVideoElement()) {
268 // Initialize the orientation lock when going fullscreen feature.
258 controls->orientation_lock_delegate_ = 269 controls->orientation_lock_delegate_ =
259 new MediaControlsOrientationLockDelegate( 270 new MediaControlsOrientationLockDelegate(
260 toHTMLVideoElement(media_element)); 271 toHTMLVideoElement(media_element));
261 } 272 }
262 273
263 shadow_root.AppendChild(controls); 274 shadow_root.AppendChild(controls);
264 return controls; 275 return controls;
265 } 276 }
266 277
267 // The media controls DOM structure looks like: 278 // The media controls DOM structure looks like:
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 return HTMLDivElement::InsertedInto(root); 412 return HTMLDivElement::InsertedInto(root);
402 413
403 // TODO(mlamouri): we should show the controls instead of having 414 // TODO(mlamouri): we should show the controls instead of having
404 // HTMLMediaElement do it. 415 // HTMLMediaElement do it.
405 416
406 // 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
407 // when a menu is visible. 418 // when a menu is visible.
408 media_event_listener_->Attach(); 419 media_event_listener_->Attach();
409 if (orientation_lock_delegate_) 420 if (orientation_lock_delegate_)
410 orientation_lock_delegate_->Attach(); 421 orientation_lock_delegate_->Attach();
422 if (rotate_to_fullscreen_delegate_)
423 rotate_to_fullscreen_delegate_->Attach();
411 424
412 if (!resize_observer_) { 425 if (!resize_observer_) {
413 resize_observer_ = 426 resize_observer_ =
414 ResizeObserver::Create(MediaElement().GetDocument(), 427 ResizeObserver::Create(MediaElement().GetDocument(),
415 new MediaControlsResizeObserverCallback(this)); 428 new MediaControlsResizeObserverCallback(this));
416 HTMLMediaElement& html_media_element = MediaElement(); 429 HTMLMediaElement& html_media_element = MediaElement();
417 resize_observer_->observe(&html_media_element); 430 resize_observer_->observe(&html_media_element);
418 } 431 }
419 432
420 return HTMLDivElement::InsertedInto(root); 433 return HTMLDivElement::InsertedInto(root);
421 } 434 }
422 435
423 void MediaControlsImpl::RemovedFrom(ContainerNode*) { 436 void MediaControlsImpl::RemovedFrom(ContainerNode*) {
424 DCHECK(!MediaElement().isConnected()); 437 DCHECK(!MediaElement().isConnected());
425 438
426 // TODO(mlamouri): we hide show the controls instead of having 439 // TODO(mlamouri): we hide show the controls instead of having
427 // HTMLMediaElement do it. 440 // HTMLMediaElement do it.
428 441
429 window_event_listener_->Stop(); 442 window_event_listener_->Stop();
430 media_event_listener_->Detach(); 443 media_event_listener_->Detach();
431 if (orientation_lock_delegate_) 444 if (orientation_lock_delegate_)
432 orientation_lock_delegate_->Detach(); 445 orientation_lock_delegate_->Detach();
446 if (rotate_to_fullscreen_delegate_)
447 rotate_to_fullscreen_delegate_->Detach();
433 448
434 resize_observer_.Clear(); 449 resize_observer_.Clear();
435 } 450 }
436 451
437 void MediaControlsImpl::Reset() { 452 void MediaControlsImpl::Reset() {
438 EventDispatchForbiddenScope::AllowUserAgentEvents allow_events_in_shadow; 453 EventDispatchForbiddenScope::AllowUserAgentEvents allow_events_in_shadow;
439 BatchedControlUpdate batch(this); 454 BatchedControlUpdate batch(this);
440 455
441 const double duration = MediaElement().duration(); 456 const double duration = MediaElement().duration();
442 duration_display_->setTextContent( 457 duration_display_->setTextContent(
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 visitor->Trace(duration_display_); 1138 visitor->Trace(duration_display_);
1124 visitor->Trace(enclosure_); 1139 visitor->Trace(enclosure_);
1125 visitor->Trace(text_track_list_); 1140 visitor->Trace(text_track_list_);
1126 visitor->Trace(overflow_menu_); 1141 visitor->Trace(overflow_menu_);
1127 visitor->Trace(overflow_list_); 1142 visitor->Trace(overflow_list_);
1128 visitor->Trace(cast_button_); 1143 visitor->Trace(cast_button_);
1129 visitor->Trace(overlay_cast_button_); 1144 visitor->Trace(overlay_cast_button_);
1130 visitor->Trace(media_event_listener_); 1145 visitor->Trace(media_event_listener_);
1131 visitor->Trace(window_event_listener_); 1146 visitor->Trace(window_event_listener_);
1132 visitor->Trace(orientation_lock_delegate_); 1147 visitor->Trace(orientation_lock_delegate_);
1148 visitor->Trace(rotate_to_fullscreen_delegate_);
1133 MediaControls::Trace(visitor); 1149 MediaControls::Trace(visitor);
1134 HTMLDivElement::Trace(visitor); 1150 HTMLDivElement::Trace(visitor);
1135 } 1151 }
1136 1152
1137 } // namespace blink 1153 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698