OLD | NEW |
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/RenderMediaControlsChromium.h" | 29 #include "core/rendering/RenderMediaControls.h" |
30 | 30 |
31 #include "bindings/v8/ExceptionStatePlaceholder.h" | 31 #include "bindings/v8/ExceptionStatePlaceholder.h" |
32 #include "core/html/HTMLMediaElement.h" | 32 #include "core/html/HTMLMediaElement.h" |
33 #include "core/html/TimeRanges.h" | 33 #include "core/html/TimeRanges.h" |
34 #include "core/platform/graphics/Gradient.h" | 34 #include "core/platform/graphics/Gradient.h" |
35 #include "core/platform/graphics/GraphicsContext.h" | 35 #include "core/platform/graphics/GraphicsContext.h" |
36 #include "core/rendering/PaintInfo.h" | 36 #include "core/rendering/PaintInfo.h" |
37 | 37 |
38 namespace WebCore { | 38 namespace WebCore { |
39 | 39 |
(...skipping 23 matching lines...) Expand all Loading... |
63 static bool paintMediaButton(GraphicsContext* context, const IntRect& rect, Imag
e* image) | 63 static bool paintMediaButton(GraphicsContext* context, const IntRect& rect, Imag
e* image) |
64 { | 64 { |
65 context->drawImage(image, rect); | 65 context->drawImage(image, rect); |
66 return true; | 66 return true; |
67 } | 67 } |
68 | 68 |
69 static bool paintMediaMuteButton(RenderObject* object, const PaintInfo& paintInf
o, const IntRect& rect) | 69 static bool paintMediaMuteButton(RenderObject* object, const PaintInfo& paintInf
o, const IntRect& rect) |
70 { | 70 { |
71 HTMLMediaElement* mediaElement = toParentMediaElement(object); | 71 HTMLMediaElement* mediaElement = toParentMediaElement(object); |
72 if (!mediaElement) | 72 if (!mediaElement) |
73 return false; | 73 return false; |
74 | 74 |
75 static Image* soundLevel3 = platformResource("mediaplayerSoundLevel3"); | 75 static Image* soundLevel3 = platformResource("mediaplayerSoundLevel3"); |
76 static Image* soundLevel2 = platformResource("mediaplayerSoundLevel2"); | 76 static Image* soundLevel2 = platformResource("mediaplayerSoundLevel2"); |
77 static Image* soundLevel1 = platformResource("mediaplayerSoundLevel1"); | 77 static Image* soundLevel1 = platformResource("mediaplayerSoundLevel1"); |
78 static Image* soundLevel0 = platformResource("mediaplayerSoundLevel0"); | 78 static Image* soundLevel0 = platformResource("mediaplayerSoundLevel0"); |
79 static Image* soundDisabled = platformResource("mediaplayerSoundDisabled"); | 79 static Image* soundDisabled = platformResource("mediaplayerSoundDisabled"); |
80 | 80 |
81 if (!hasSource(mediaElement) || !mediaElement->hasAudio()) | 81 if (!hasSource(mediaElement) || !mediaElement->hasAudio()) |
82 return paintMediaButton(paintInfo.context, rect, soundDisabled); | 82 return paintMediaButton(paintInfo.context, rect, soundDisabled); |
83 | 83 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 static Image* mediaClosedCaptionButton = platformResource("mediaplayerClosed
Caption"); | 334 static Image* mediaClosedCaptionButton = platformResource("mediaplayerClosed
Caption"); |
335 static Image* mediaClosedCaptionButtonDisabled = platformResource("mediaplay
erClosedCaptionDisabled"); | 335 static Image* mediaClosedCaptionButtonDisabled = platformResource("mediaplay
erClosedCaptionDisabled"); |
336 | 336 |
337 if (mediaElement->webkitClosedCaptionsVisible()) | 337 if (mediaElement->webkitClosedCaptionsVisible()) |
338 return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionButto
n); | 338 return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionButto
n); |
339 | 339 |
340 return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionButtonDis
abled); | 340 return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionButtonDis
abled); |
341 } | 341 } |
342 | 342 |
343 | 343 |
344 bool RenderMediaControlsChromium::paintMediaControlsPart(MediaControlElementType
part, RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) | 344 bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, R
enderObject* object, const PaintInfo& paintInfo, const IntRect& rect) |
345 { | 345 { |
346 switch (part) { | 346 switch (part) { |
347 case MediaMuteButton: | 347 case MediaMuteButton: |
348 case MediaUnMuteButton: | 348 case MediaUnMuteButton: |
349 return paintMediaMuteButton(object, paintInfo, rect); | 349 return paintMediaMuteButton(object, paintInfo, rect); |
350 case MediaPauseButton: | 350 case MediaPauseButton: |
351 case MediaPlayButton: | 351 case MediaPlayButton: |
352 return paintMediaPlayButton(object, paintInfo, rect); | 352 return paintMediaPlayButton(object, paintInfo, rect); |
353 case MediaShowClosedCaptionsButton: | 353 case MediaShowClosedCaptionsButton: |
354 return paintMediaToggleClosedCaptionsButton(object, paintInfo, rect); | 354 return paintMediaToggleClosedCaptionsButton(object, paintInfo, rect); |
(...skipping 28 matching lines...) Expand all Loading... |
383 case MediaFullScreenVolumeSliderThumb: | 383 case MediaFullScreenVolumeSliderThumb: |
384 ASSERT_NOT_REACHED(); | 384 ASSERT_NOT_REACHED(); |
385 break; | 385 break; |
386 } | 386 } |
387 return false; | 387 return false; |
388 } | 388 } |
389 | 389 |
390 const int mediaSliderThumbHeight = 24; | 390 const int mediaSliderThumbHeight = 24; |
391 const int mediaVolumeSliderThumbHeight = 24; | 391 const int mediaVolumeSliderThumbHeight = 24; |
392 | 392 |
393 void RenderMediaControlsChromium::adjustMediaSliderThumbSize(RenderStyle* style) | 393 void RenderMediaControls::adjustMediaSliderThumbSize(RenderStyle* style) |
394 { | 394 { |
395 static Image* mediaSliderThumb = platformResource("mediaplayerSliderThumb"); | 395 static Image* mediaSliderThumb = platformResource("mediaplayerSliderThumb"); |
396 static Image* mediaVolumeSliderThumb = platformResource("mediaplayerVolumeSl
iderThumb"); | 396 static Image* mediaVolumeSliderThumb = platformResource("mediaplayerVolumeSl
iderThumb"); |
397 int width = 0; | 397 int width = 0; |
398 int height = 0; | 398 int height = 0; |
399 | 399 |
400 Image* thumbImage = 0; | 400 Image* thumbImage = 0; |
401 if (style->appearance() == MediaSliderThumbPart) { | 401 if (style->appearance() == MediaSliderThumbPart) { |
402 thumbImage = mediaSliderThumb; | 402 thumbImage = mediaSliderThumb; |
403 width = mediaSliderThumbWidth; | 403 width = mediaSliderThumbWidth; |
(...skipping 28 matching lines...) Expand all Loading... |
432 int durationMins = (durationSecs / 60) % 60; | 432 int durationMins = (durationSecs / 60) % 60; |
433 | 433 |
434 if (durationHours || hours) | 434 if (durationHours || hours) |
435 return String::format("%s%01d:%02d:%02d", (time < 0 ? "-" : ""), hours,
minutes, seconds); | 435 return String::format("%s%01d:%02d:%02d", (time < 0 ? "-" : ""), hours,
minutes, seconds); |
436 if (durationMins > 9) | 436 if (durationMins > 9) |
437 return String::format("%s%02d:%02d", (time < 0 ? "-" : ""), minutes, sec
onds); | 437 return String::format("%s%02d:%02d", (time < 0 ? "-" : ""), minutes, sec
onds); |
438 | 438 |
439 return String::format("%s%01d:%02d", (time < 0 ? "-" : ""), minutes, seconds
); | 439 return String::format("%s%01d:%02d", (time < 0 ? "-" : ""), minutes, seconds
); |
440 } | 440 } |
441 | 441 |
442 String RenderMediaControlsChromium::formatMediaControlsTime(float time) | 442 String RenderMediaControls::formatMediaControlsTime(float time) |
443 { | 443 { |
444 return formatChromiumMediaControlsTime(time, time); | 444 return formatChromiumMediaControlsTime(time, time); |
445 } | 445 } |
446 | 446 |
447 String RenderMediaControlsChromium::formatMediaControlsCurrentTime(float current
Time, float duration) | 447 String RenderMediaControls::formatMediaControlsCurrentTime(float currentTime, fl
oat duration) |
448 { | 448 { |
449 return formatChromiumMediaControlsTime(currentTime, duration); | 449 return formatChromiumMediaControlsTime(currentTime, duration); |
450 } | 450 } |
451 | 451 |
452 } // namespace WebCore | 452 } // namespace WebCore |
OLD | NEW |