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

Side by Side Diff: Source/core/html/shadow/MediaControls.cpp

Issue 190463002: Remove document().page() null checks in MediaControls (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 , m_toggleClosedCaptionsButton(0) 49 , m_toggleClosedCaptionsButton(0)
50 , m_fullScreenButton(0) 50 , m_fullScreenButton(0)
51 , m_durationDisplay(0) 51 , m_durationDisplay(0)
52 , m_enclosure(0) 52 , m_enclosure(0)
53 , m_hideFullscreenControlsTimer(this, &MediaControls::hideFullscreenControls TimerFired) 53 , m_hideFullscreenControlsTimer(this, &MediaControls::hideFullscreenControls TimerFired)
54 , m_isFullscreen(false) 54 , m_isFullscreen(false)
55 , m_isMouseOverControls(false) 55 , m_isMouseOverControls(false)
56 { 56 {
57 } 57 }
58 58
59 PassRefPtr<MediaControls> MediaControls::create(Document& document) 59 PassRefPtr<MediaControls> MediaControls::create(Document& document)
eseidel 2014/03/08 20:39:05 One way to test these methods is to do: <iframe i
60 { 60 {
61 if (!document.page())
62 return nullptr;
63
64 RefPtr<MediaControls> controls; 61 RefPtr<MediaControls> controls;
65 #if OS(ANDROID) 62 #if OS(ANDROID)
66 controls = adoptRef(new MediaControlsAndroid(document)); 63 controls = adoptRef(new MediaControlsAndroid(document));
67 #else 64 #else
68 controls = adoptRef(new MediaControls(document)); 65 controls = adoptRef(new MediaControls(document));
69 #endif 66 #endif
70 67
71 if (controls->initializeControls(document)) 68 if (controls->initializeControls(document))
72 return controls.release(); 69 return controls.release();
73 70
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 m_muteButton->setMediaController(controller); 157 m_muteButton->setMediaController(controller);
161 m_volumeSlider->setMediaController(controller); 158 m_volumeSlider->setMediaController(controller);
162 m_toggleClosedCaptionsButton->setMediaController(controller); 159 m_toggleClosedCaptionsButton->setMediaController(controller);
163 m_fullScreenButton->setMediaController(controller); 160 m_fullScreenButton->setMediaController(controller);
164 m_durationDisplay->setMediaController(controller); 161 m_durationDisplay->setMediaController(controller);
165 m_enclosure->setMediaController(controller); 162 m_enclosure->setMediaController(controller);
166 } 163 }
167 164
168 void MediaControls::reset() 165 void MediaControls::reset()
169 { 166 {
170 Page* page = document().page();
171 if (!page)
172 return;
173
174 double duration = m_mediaController->duration(); 167 double duration = m_mediaController->duration();
175 m_durationDisplay->setInnerText(RenderTheme::theme().formatMediaControlsTime (duration), ASSERT_NO_EXCEPTION); 168 m_durationDisplay->setInnerText(RenderTheme::theme().formatMediaControlsTime (duration), ASSERT_NO_EXCEPTION);
176 m_durationDisplay->setCurrentValue(duration); 169 m_durationDisplay->setCurrentValue(duration);
177 170
178 m_playButton->updateDisplayType(); 171 m_playButton->updateDisplayType();
179 172
180 updateCurrentTimeDisplay(); 173 updateCurrentTimeDisplay();
181 174
182 m_timeline->setDuration(m_mediaController->duration()); 175 m_timeline->setDuration(m_mediaController->duration());
183 m_timeline->setPosition(m_mediaController->currentTime()); 176 m_timeline->setPosition(m_mediaController->currentTime());
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 makeOpaque(); 250 makeOpaque();
258 251
259 stopHideFullscreenControlsTimer(); 252 stopHideFullscreenControlsTimer();
260 } 253 }
261 254
262 void MediaControls::updateCurrentTimeDisplay() 255 void MediaControls::updateCurrentTimeDisplay()
263 { 256 {
264 double now = m_mediaController->currentTime(); 257 double now = m_mediaController->currentTime();
265 double duration = m_mediaController->duration(); 258 double duration = m_mediaController->duration();
266 259
267 Page* page = document().page();
268 if (!page)
269 return;
270
271 // After seek, hide duration display and show current time. 260 // After seek, hide duration display and show current time.
272 if (now > 0) { 261 if (now > 0) {
273 m_currentTimeDisplay->show(); 262 m_currentTimeDisplay->show();
274 m_durationDisplay->hide(); 263 m_durationDisplay->hide();
275 } 264 }
276 265
277 // Allow the theme to format the time. 266 // Allow the theme to format the time.
278 m_currentTimeDisplay->setInnerText(RenderTheme::theme().formatMediaControlsC urrentTime(now, duration), IGNORE_EXCEPTION); 267 m_currentTimeDisplay->setInnerText(RenderTheme::theme().formatMediaControlsC urrentTime(now, duration), IGNORE_EXCEPTION);
279 m_currentTimeDisplay->setCurrentValue(now); 268 m_currentTimeDisplay->setCurrentValue(now);
280 } 269 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 return; 365 return;
377 366
378 makeTransparent(); 367 makeTransparent();
379 } 368 }
380 369
381 void MediaControls::startHideFullscreenControlsTimer() 370 void MediaControls::startHideFullscreenControlsTimer()
382 { 371 {
383 if (!m_isFullscreen) 372 if (!m_isFullscreen)
384 return; 373 return;
385 374
386 Page* page = document().page();
387 if (!page)
388 return;
389
390 m_hideFullscreenControlsTimer.startOneShot(timeWithoutMouseMovementBeforeHid ingFullscreenControls); 375 m_hideFullscreenControlsTimer.startOneShot(timeWithoutMouseMovementBeforeHid ingFullscreenControls);
391 } 376 }
392 377
393 void MediaControls::stopHideFullscreenControlsTimer() 378 void MediaControls::stopHideFullscreenControlsTimer()
394 { 379 {
395 m_hideFullscreenControlsTimer.stop(); 380 m_hideFullscreenControlsTimer.stop();
396 } 381 }
397 382
398 const AtomicString& MediaControls::shadowPseudoId() const 383 const AtomicString& MediaControls::shadowPseudoId() const
399 { 384 {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 m_textDisplayContainer->updateDisplay(); 431 m_textDisplayContainer->updateDisplay();
447 } 432 }
448 433
449 void MediaControls::insertTextTrackContainer(PassRefPtr<MediaControlTextTrackCon tainerElement> textTrackContainer) 434 void MediaControls::insertTextTrackContainer(PassRefPtr<MediaControlTextTrackCon tainerElement> textTrackContainer)
450 { 435 {
451 // Insert it before the first controller element so it always displays behin d the controls. 436 // Insert it before the first controller element so it always displays behin d the controls.
452 insertBefore(textTrackContainer, m_enclosure); 437 insertBefore(textTrackContainer, m_enclosure);
453 } 438 }
454 439
455 } 440 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698