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

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: Address review 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) 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 // RotateToFullscreen and FullscreenOrientationLock are not yet compatible
254 if (RuntimeEnabledFeatures::videoFullscreenOrientationLockEnabled() && 256 // so enabling RotateToFullscreen disables FullscreenOrientationLock.
257 // TODO(johnme): Make it possible to use both features simultaneously.
258 if (RuntimeEnabledFeatures::videoRotateToFullscreenEnabled() &&
255 media_element.IsHTMLVideoElement()) { 259 media_element.IsHTMLVideoElement()) {
260 // Initialize the rotate-to-fullscreen feature.
261 controls->rotate_to_fullscreen_delegate_ =
262 new MediaControlsRotateToFullscreenDelegate(
263 toHTMLVideoElement(media_element));
264 } else if (RuntimeEnabledFeatures::videoFullscreenOrientationLockEnabled() &&
265 media_element.IsHTMLVideoElement()) {
266 // Initialize the orientation lock when going fullscreen feature.
256 controls->orientation_lock_delegate_ = 267 controls->orientation_lock_delegate_ =
257 new MediaControlsOrientationLockDelegate( 268 new MediaControlsOrientationLockDelegate(
258 toHTMLVideoElement(media_element)); 269 toHTMLVideoElement(media_element));
259 } 270 }
260 271
261 shadow_root.AppendChild(controls); 272 shadow_root.AppendChild(controls);
262 return controls; 273 return controls;
263 } 274 }
264 275
265 // The media controls DOM structure looks like: 276 // The media controls DOM structure looks like:
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 return HTMLDivElement::InsertedInto(root); 414 return HTMLDivElement::InsertedInto(root);
404 415
405 // TODO(mlamouri): we should show the controls instead of having 416 // TODO(mlamouri): we should show the controls instead of having
406 // HTMLMediaElement do it. 417 // HTMLMediaElement do it.
407 418
408 // m_windowEventListener doesn't need to be re-attached as it's only needed 419 // m_windowEventListener doesn't need to be re-attached as it's only needed
409 // when a menu is visible. 420 // when a menu is visible.
410 media_event_listener_->Attach(); 421 media_event_listener_->Attach();
411 if (orientation_lock_delegate_) 422 if (orientation_lock_delegate_)
412 orientation_lock_delegate_->Attach(); 423 orientation_lock_delegate_->Attach();
424 if (rotate_to_fullscreen_delegate_)
425 rotate_to_fullscreen_delegate_->Attach();
413 426
414 if (!resize_observer_) { 427 if (!resize_observer_) {
415 resize_observer_ = 428 resize_observer_ =
416 ResizeObserver::Create(MediaElement().GetDocument(), 429 ResizeObserver::Create(MediaElement().GetDocument(),
417 new MediaControlsResizeObserverCallback(this)); 430 new MediaControlsResizeObserverCallback(this));
418 HTMLMediaElement& html_media_element = MediaElement(); 431 HTMLMediaElement& html_media_element = MediaElement();
419 resize_observer_->observe(&html_media_element); 432 resize_observer_->observe(&html_media_element);
420 } 433 }
421 434
422 return HTMLDivElement::InsertedInto(root); 435 return HTMLDivElement::InsertedInto(root);
423 } 436 }
424 437
425 void MediaControlsImpl::RemovedFrom(ContainerNode*) { 438 void MediaControlsImpl::RemovedFrom(ContainerNode*) {
426 DCHECK(!MediaElement().isConnected()); 439 DCHECK(!MediaElement().isConnected());
427 440
428 // TODO(mlamouri): we hide show the controls instead of having 441 // TODO(mlamouri): we hide show the controls instead of having
429 // HTMLMediaElement do it. 442 // HTMLMediaElement do it.
430 443
431 window_event_listener_->Stop(); 444 window_event_listener_->Stop();
432 media_event_listener_->Detach(); 445 media_event_listener_->Detach();
433 if (orientation_lock_delegate_) 446 if (orientation_lock_delegate_)
434 orientation_lock_delegate_->Detach(); 447 orientation_lock_delegate_->Detach();
448 if (rotate_to_fullscreen_delegate_)
449 rotate_to_fullscreen_delegate_->Detach();
435 450
436 resize_observer_.Clear(); 451 resize_observer_.Clear();
437 } 452 }
438 453
439 void MediaControlsImpl::Reset() { 454 void MediaControlsImpl::Reset() {
440 EventDispatchForbiddenScope::AllowUserAgentEvents allow_events_in_shadow; 455 EventDispatchForbiddenScope::AllowUserAgentEvents allow_events_in_shadow;
441 BatchedControlUpdate batch(this); 456 BatchedControlUpdate batch(this);
442 457
443 const double duration = MediaElement().duration(); 458 const double duration = MediaElement().duration();
444 duration_display_->setTextContent( 459 duration_display_->setTextContent(
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 visitor->Trace(duration_display_); 1140 visitor->Trace(duration_display_);
1126 visitor->Trace(enclosure_); 1141 visitor->Trace(enclosure_);
1127 visitor->Trace(text_track_list_); 1142 visitor->Trace(text_track_list_);
1128 visitor->Trace(overflow_menu_); 1143 visitor->Trace(overflow_menu_);
1129 visitor->Trace(overflow_list_); 1144 visitor->Trace(overflow_list_);
1130 visitor->Trace(cast_button_); 1145 visitor->Trace(cast_button_);
1131 visitor->Trace(overlay_cast_button_); 1146 visitor->Trace(overlay_cast_button_);
1132 visitor->Trace(media_event_listener_); 1147 visitor->Trace(media_event_listener_);
1133 visitor->Trace(window_event_listener_); 1148 visitor->Trace(window_event_listener_);
1134 visitor->Trace(orientation_lock_delegate_); 1149 visitor->Trace(orientation_lock_delegate_);
1150 visitor->Trace(rotate_to_fullscreen_delegate_);
1135 MediaControls::Trace(visitor); 1151 MediaControls::Trace(visitor);
1136 HTMLDivElement::Trace(visitor); 1152 HTMLDivElement::Trace(visitor);
1137 } 1153 }
1138 1154
1139 } // namespace blink 1155 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698