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

Side by Side Diff: Source/core/rendering/RenderMediaControls.cpp

Issue 291163004: Implement media cast buttons (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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) 2009 Apple Inc. 2 * Copyright (C) 2009 Apple Inc.
3 * Copyright (C) 2009 Google Inc. 3 * Copyright (C) 2009 Google Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
15 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 15 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include "config.h" 28 #include "config.h"
29 #include "core/rendering/RenderMediaControls.h" 29 #include "core/rendering/RenderMediaControls.h"
30 #include "base/logging.h"
30 31
31 #include "bindings/v8/ExceptionStatePlaceholder.h" 32 #include "bindings/v8/ExceptionStatePlaceholder.h"
32 #include "core/html/HTMLMediaElement.h" 33 #include "core/html/HTMLMediaElement.h"
33 #include "core/html/TimeRanges.h" 34 #include "core/html/TimeRanges.h"
34 #include "core/rendering/PaintInfo.h" 35 #include "core/rendering/PaintInfo.h"
35 #include "platform/graphics/Gradient.h" 36 #include "platform/graphics/Gradient.h"
36 #include "platform/graphics/GraphicsContext.h" 37 #include "platform/graphics/GraphicsContext.h"
37 38
38 namespace WebCore { 39 namespace WebCore {
39 40
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 return false; 329 return false;
329 330
330 static Image* mediaClosedCaptionButton = platformResource("mediaplayerClosed Caption"); 331 static Image* mediaClosedCaptionButton = platformResource("mediaplayerClosed Caption");
331 static Image* mediaClosedCaptionButtonDisabled = platformResource("mediaplay erClosedCaptionDisabled"); 332 static Image* mediaClosedCaptionButtonDisabled = platformResource("mediaplay erClosedCaptionDisabled");
332 333
333 if (mediaElement->closedCaptionsVisible()) 334 if (mediaElement->closedCaptionsVisible())
334 return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionButto n); 335 return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionButto n);
335 336
336 return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionButtonDis abled); 337 return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionButtonDis abled);
337 } 338 }
339 static bool paintMediaCastOffButton(RenderObject* object, const PaintInfo& paint Info, const IntRect& rect)
340 {
341 LOG(INFO) << "Painting Cast Off Button";
342 HTMLMediaElement* mediaElement = toParentMediaElement(object);
343 if (!mediaElement)
344 return false;
338 345
346 static Image* mediaCastOffButton = platformResource("mediaplayerCastOff");
347 return paintMediaButton(paintInfo.context, rect, mediaCastOffButton);
348
349 }
350
351 static bool paintMediaCastOnButton(RenderObject* object, const PaintInfo& paintI nfo, const IntRect& rect)
352 {
353 LOG(INFO) << "Painting Cast On Button";
354 HTMLMediaElement* mediaElement = toParentMediaElement(object);
355 if (!mediaElement)
356 return false;
357
358 static Image* mediaCastOnButton = platformResource("mediaplayerCastOn");
359 return paintMediaButton(paintInfo.context, rect, mediaCastOnButton);
360
361 }
339 362
340 bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, R enderObject* object, const PaintInfo& paintInfo, const IntRect& rect) 363 bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, R enderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
341 { 364 {
342 switch (part) { 365 switch (part) {
343 case MediaMuteButton: 366 case MediaMuteButton:
344 case MediaUnMuteButton: 367 case MediaUnMuteButton:
345 return paintMediaMuteButton(object, paintInfo, rect); 368 return paintMediaMuteButton(object, paintInfo, rect);
346 case MediaPauseButton: 369 case MediaPauseButton:
347 case MediaPlayButton: 370 case MediaPlayButton:
348 return paintMediaPlayButton(object, paintInfo, rect); 371 return paintMediaPlayButton(object, paintInfo, rect);
349 case MediaShowClosedCaptionsButton: 372 case MediaShowClosedCaptionsButton:
350 return paintMediaToggleClosedCaptionsButton(object, paintInfo, rect); 373 return paintMediaToggleClosedCaptionsButton(object, paintInfo, rect);
351 case MediaSlider: 374 case MediaSlider:
352 return paintMediaSlider(object, paintInfo, rect); 375 return paintMediaSlider(object, paintInfo, rect);
353 case MediaSliderThumb: 376 case MediaSliderThumb:
354 return paintMediaSliderThumb(object, paintInfo, rect); 377 return paintMediaSliderThumb(object, paintInfo, rect);
355 case MediaVolumeSlider: 378 case MediaVolumeSlider:
356 return paintMediaVolumeSlider(object, paintInfo, rect); 379 return paintMediaVolumeSlider(object, paintInfo, rect);
357 case MediaVolumeSliderThumb: 380 case MediaVolumeSliderThumb:
358 return paintMediaVolumeSliderThumb(object, paintInfo, rect); 381 return paintMediaVolumeSliderThumb(object, paintInfo, rect);
359 case MediaEnterFullscreenButton: 382 case MediaEnterFullscreenButton:
360 case MediaExitFullscreenButton: 383 case MediaExitFullscreenButton:
361 return paintMediaFullscreenButton(object, paintInfo, rect); 384 return paintMediaFullscreenButton(object, paintInfo, rect);
362 case MediaOverlayPlayButton: 385 case MediaOverlayPlayButton:
363 return paintMediaOverlayPlayButton(object, paintInfo, rect); 386 return paintMediaOverlayPlayButton(object, paintInfo, rect);
387 case MediaCastOffButton:
388 return paintMediaCastOffButton(object, paintInfo, rect);
389 case MediaCastOnButton:
390 return paintMediaCastOnButton(object, paintInfo, rect);
364 case MediaVolumeSliderContainer: 391 case MediaVolumeSliderContainer:
365 case MediaTimelineContainer: 392 case MediaTimelineContainer:
366 case MediaCurrentTimeDisplay: 393 case MediaCurrentTimeDisplay:
367 case MediaTimeRemainingDisplay: 394 case MediaTimeRemainingDisplay:
368 case MediaControlsPanel: 395 case MediaControlsPanel:
369 case MediaStatusDisplay: 396 case MediaStatusDisplay:
370 case MediaHideClosedCaptionsButton: 397 case MediaHideClosedCaptionsButton:
371 case MediaTextTrackDisplayContainer: 398 case MediaTextTrackDisplayContainer:
372 case MediaTextTrackDisplay: 399 case MediaTextTrackDisplay:
373 case MediaFullScreenVolumeSlider: 400 case MediaFullScreenVolumeSlider:
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 { 461 {
435 return formatChromiumMediaControlsTime(time, time); 462 return formatChromiumMediaControlsTime(time, time);
436 } 463 }
437 464
438 String RenderMediaControls::formatMediaControlsCurrentTime(float currentTime, fl oat duration) 465 String RenderMediaControls::formatMediaControlsCurrentTime(float currentTime, fl oat duration)
439 { 466 {
440 return formatChromiumMediaControlsTime(currentTime, duration); 467 return formatChromiumMediaControlsTime(currentTime, duration);
441 } 468 }
442 469
443 } // namespace WebCore 470 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698