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

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

Issue 456323002: [WIP] Re-implement MediaControls in Blink-in-JS (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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
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 10 matching lines...) Expand all
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "core/html/shadow/MediaControls.h" 28 #include "core/html/shadow/MediaControls.h"
29 29
30 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 30 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
31 #include "bindings/core/v8/V8MediaControls.h"
32 #include "bindings/core/v8/PrivateScriptRunner.h"
31 #include "core/events/MouseEvent.h" 33 #include "core/events/MouseEvent.h"
32 #include "core/frame/Settings.h" 34 #include "core/frame/Settings.h"
33 #include "core/html/HTMLMediaElement.h" 35 #include "core/html/HTMLMediaElement.h"
34 #include "core/html/MediaController.h" 36 #include "core/html/MediaController.h"
35 #include "core/rendering/RenderTheme.h" 37 #include "core/rendering/RenderTheme.h"
36 38
37 namespace blink { 39 namespace blink {
38 40
39 // If you change this value, then also update the corresponding value in 41 // If you change this value, then also update the corresponding value in
40 // LayoutTests/media/media-controls.js. 42 // LayoutTests/media/media-controls.js.
(...skipping 17 matching lines...) Expand all
58 , m_muteButton(nullptr) 60 , m_muteButton(nullptr)
59 , m_volumeSlider(nullptr) 61 , m_volumeSlider(nullptr)
60 , m_toggleClosedCaptionsButton(nullptr) 62 , m_toggleClosedCaptionsButton(nullptr)
61 , m_fullScreenButton(nullptr) 63 , m_fullScreenButton(nullptr)
62 , m_durationDisplay(nullptr) 64 , m_durationDisplay(nullptr)
63 , m_enclosure(nullptr) 65 , m_enclosure(nullptr)
64 , m_hideMediaControlsTimer(this, &MediaControls::hideMediaControlsTimerFired ) 66 , m_hideMediaControlsTimer(this, &MediaControls::hideMediaControlsTimerFired )
65 , m_isMouseOverControls(false) 67 , m_isMouseOverControls(false)
66 , m_isPausedForScrubbing(false) 68 , m_isPausedForScrubbing(false)
67 { 69 {
70 ScriptWrappable::init(this);
71 v8::Handle<v8::Value> classObject = PrivateScriptRunner::installClassIfNeede d(document().frame(), "MediaControls");
72 RELEASE_ASSERT(!classObject.IsEmpty());
68 } 73 }
69 74
70 PassRefPtrWillBeRawPtr<MediaControls> MediaControls::create(HTMLMediaElement& me diaElement) 75 PassRefPtrWillBeRawPtr<MediaControls> MediaControls::create(HTMLMediaElement& me diaElement)
71 { 76 {
72 RefPtrWillBeRawPtr<MediaControls> controls = adoptRefWillBeNoop(new MediaCon trols(mediaElement)); 77 RefPtrWillBeRawPtr<MediaControls> controls = adoptRefWillBeNoop(new MediaCon trols(mediaElement));
73 78
74 if (controls->initializeControls()) 79 if (!controls->initializeControls())
75 return controls.release(); 80 return nullptr;
76 81
77 return nullptr; 82 PassRefPtrWillBeRawPtr<HTMLMediaElement> media(&mediaElement);
83 if (!V8MediaControls::createdCallbackMethodImplementedInPrivateScript(contro ls->document().frame(), controls.get(), media))
84 return nullptr;
85
86 return controls.release();
78 } 87 }
79 88
80 bool MediaControls::initializeControls() 89 bool MediaControls::initializeControls()
81 { 90 {
82 TrackExceptionState exceptionState; 91 TrackExceptionState exceptionState;
83 92
84 if (document().settings() && document().settings()->mediaControlsOverlayPlay ButtonEnabled()) { 93 if (document().settings() && document().settings()->mediaControlsOverlayPlay ButtonEnabled()) {
85 RefPtrWillBeRawPtr<MediaControlOverlayEnclosureElement> overlayEnclosure = MediaControlOverlayEnclosureElement::create(*this); 94 RefPtrWillBeRawPtr<MediaControlOverlayEnclosureElement> overlayEnclosure = MediaControlOverlayEnclosureElement::create(*this);
86 RefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> overlayPlayButt on = MediaControlOverlayPlayButtonElement::create(*this); 95 RefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> overlayPlayButt on = MediaControlOverlayPlayButtonElement::create(*this);
87 m_overlayPlayButton = overlayPlayButton.get(); 96 m_overlayPlayButton = overlayPlayButton.get();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 m_timeline->setPosition(mediaElement().currentTime()); 185 m_timeline->setPosition(mediaElement().currentTime());
177 186
178 if (!mediaElement().hasAudio()) 187 if (!mediaElement().hasAudio())
179 m_volumeSlider->hide(); 188 m_volumeSlider->hide();
180 else 189 else
181 m_volumeSlider->show(); 190 m_volumeSlider->show();
182 updateVolume(); 191 updateVolume();
183 192
184 refreshClosedCaptionsButtonVisibility(); 193 refreshClosedCaptionsButtonVisibility();
185 194
186 if (mediaElement().hasVideo() && fullscreenIsSupported(document())) 195 if (mediaElement().hasVideo() && fullscreenIsSupported())
187 m_fullScreenButton->show(); 196 m_fullScreenButton->show();
188 else 197 else
189 m_fullScreenButton->hide(); 198 m_fullScreenButton->hide();
190 199
191 makeOpaque(); 200 makeOpaque();
201
202 V8MediaControls::resetMethodImplementedInPrivateScript(document().frame(), t his);
192 } 203 }
193 204
194 void MediaControls::show() 205 void MediaControls::show()
195 { 206 {
196 makeOpaque(); 207 makeOpaque();
197 m_panel->setIsDisplayed(true); 208 m_panel->setIsDisplayed(true);
198 m_panel->show(); 209 m_panel->show();
199 if (m_overlayPlayButton) 210 if (m_overlayPlayButton)
200 m_overlayPlayButton->updateDisplayType(); 211 m_overlayPlayButton->updateDisplayType();
201 } 212 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 366
356 void MediaControls::exitedFullscreen() 367 void MediaControls::exitedFullscreen()
357 { 368 {
358 m_fullScreenButton->setIsFullscreen(false); 369 m_fullScreenButton->setIsFullscreen(false);
359 stopHideMediaControlsTimer(); 370 stopHideMediaControlsTimer();
360 startHideMediaControlsTimer(); 371 startHideMediaControlsTimer();
361 } 372 }
362 373
363 void MediaControls::defaultEventHandler(Event* event) 374 void MediaControls::defaultEventHandler(Event* event)
364 { 375 {
376 return;
377
365 HTMLDivElement::defaultEventHandler(event); 378 HTMLDivElement::defaultEventHandler(event);
366 379
367 if (event->type() == EventTypeNames::mouseover) { 380 if (event->type() == EventTypeNames::mouseover) {
368 if (!containsRelatedTarget(event)) { 381 if (!containsRelatedTarget(event)) {
369 m_isMouseOverControls = true; 382 m_isMouseOverControls = true;
370 if (!mediaElement().togglePlayStateWillPlay()) { 383 if (!mediaElement().togglePlayStateWillPlay()) {
371 makeOpaque(); 384 makeOpaque();
372 if (shouldHideMediaControls()) 385 if (shouldHideMediaControls())
373 startHideMediaControlsTimer(); 386 startHideMediaControlsTimer();
374 } 387 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 } 474 }
462 475
463 void MediaControls::updateTextTrackDisplay() 476 void MediaControls::updateTextTrackDisplay()
464 { 477 {
465 if (!m_textDisplayContainer) 478 if (!m_textDisplayContainer)
466 createTextTrackDisplay(); 479 createTextTrackDisplay();
467 480
468 m_textDisplayContainer->updateDisplay(); 481 m_textDisplayContainer->updateDisplay();
469 } 482 }
470 483
484 bool MediaControls::fullscreenIsSupported()
485 {
486 return blink::fullscreenIsSupported(document());
487 }
488
471 void MediaControls::trace(Visitor* visitor) 489 void MediaControls::trace(Visitor* visitor)
472 { 490 {
473 visitor->trace(m_mediaElement); 491 visitor->trace(m_mediaElement);
474 visitor->trace(m_panel); 492 visitor->trace(m_panel);
475 visitor->trace(m_textDisplayContainer); 493 visitor->trace(m_textDisplayContainer);
476 visitor->trace(m_overlayPlayButton); 494 visitor->trace(m_overlayPlayButton);
477 visitor->trace(m_overlayEnclosure); 495 visitor->trace(m_overlayEnclosure);
478 visitor->trace(m_playButton); 496 visitor->trace(m_playButton);
479 visitor->trace(m_currentTimeDisplay); 497 visitor->trace(m_currentTimeDisplay);
480 visitor->trace(m_timeline); 498 visitor->trace(m_timeline);
481 visitor->trace(m_muteButton); 499 visitor->trace(m_muteButton);
482 visitor->trace(m_volumeSlider); 500 visitor->trace(m_volumeSlider);
483 visitor->trace(m_toggleClosedCaptionsButton); 501 visitor->trace(m_toggleClosedCaptionsButton);
484 visitor->trace(m_fullScreenButton); 502 visitor->trace(m_fullScreenButton);
485 visitor->trace(m_durationDisplay); 503 visitor->trace(m_durationDisplay);
486 visitor->trace(m_enclosure); 504 visitor->trace(m_enclosure);
487 HTMLDivElement::trace(visitor); 505 HTMLDivElement::trace(visitor);
488 } 506 }
489 507
490 } 508 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698