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. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 return mediaElement->networkState() != HTMLMediaElement::NETWORK_EMPTY | 59 return mediaElement->networkState() != HTMLMediaElement::NETWORK_EMPTY |
60 && mediaElement->networkState() != HTMLMediaElement::NETWORK_NO_SOURCE; | 60 && mediaElement->networkState() != HTMLMediaElement::NETWORK_NO_SOURCE; |
61 } | 61 } |
62 | 62 |
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(LayoutObject* 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 |
84 if (mediaElement->muted() || mediaElement->volume() <= 0) | 84 if (mediaElement->muted() || mediaElement->volume() <= 0) |
85 return paintMediaButton(paintInfo.context, rect, soundLevel0); | 85 return paintMediaButton(paintInfo.context, rect, soundLevel0); |
86 | 86 |
87 if (mediaElement->volume() <= 0.33) | 87 if (mediaElement->volume() <= 0.33) |
88 return paintMediaButton(paintInfo.context, rect, soundLevel1); | 88 return paintMediaButton(paintInfo.context, rect, soundLevel1); |
89 | 89 |
90 if (mediaElement->volume() <= 0.66) | 90 if (mediaElement->volume() <= 0.66) |
91 return paintMediaButton(paintInfo.context, rect, soundLevel2); | 91 return paintMediaButton(paintInfo.context, rect, soundLevel2); |
92 | 92 |
93 return paintMediaButton(paintInfo.context, rect, soundLevel3); | 93 return paintMediaButton(paintInfo.context, rect, soundLevel3); |
94 } | 94 } |
95 | 95 |
96 static bool paintMediaPlayButton(RenderObject* object, const PaintInfo& paintInf
o, const IntRect& rect) | 96 static bool paintMediaPlayButton(LayoutObject* object, const PaintInfo& paintInf
o, const IntRect& rect) |
97 { | 97 { |
98 HTMLMediaElement* mediaElement = toParentMediaElement(object); | 98 HTMLMediaElement* mediaElement = toParentMediaElement(object); |
99 if (!mediaElement) | 99 if (!mediaElement) |
100 return false; | 100 return false; |
101 | 101 |
102 static Image* mediaPlay = platformResource("mediaplayerPlay"); | 102 static Image* mediaPlay = platformResource("mediaplayerPlay"); |
103 static Image* mediaPause = platformResource("mediaplayerPause"); | 103 static Image* mediaPause = platformResource("mediaplayerPause"); |
104 static Image* mediaPlayDisabled = platformResource("mediaplayerPlayDisabled"
); | 104 static Image* mediaPlayDisabled = platformResource("mediaplayerPlayDisabled"
); |
105 | 105 |
106 if (!hasSource(mediaElement)) | 106 if (!hasSource(mediaElement)) |
107 return paintMediaButton(paintInfo.context, rect, mediaPlayDisabled); | 107 return paintMediaButton(paintInfo.context, rect, mediaPlayDisabled); |
108 | 108 |
109 Image * image = !object->node()->isMediaControlElement() || mediaControlElem
entType(object->node()) == MediaPlayButton ? mediaPlay : mediaPause; | 109 Image * image = !object->node()->isMediaControlElement() || mediaControlElem
entType(object->node()) == MediaPlayButton ? mediaPlay : mediaPause; |
110 return paintMediaButton(paintInfo.context, rect, image); | 110 return paintMediaButton(paintInfo.context, rect, image); |
111 } | 111 } |
112 | 112 |
113 static bool paintMediaOverlayPlayButton(RenderObject* object, const PaintInfo& p
aintInfo, const IntRect& rect) | 113 static bool paintMediaOverlayPlayButton(LayoutObject* object, const PaintInfo& p
aintInfo, const IntRect& rect) |
114 { | 114 { |
115 HTMLMediaElement* mediaElement = toParentMediaElement(object); | 115 HTMLMediaElement* mediaElement = toParentMediaElement(object); |
116 if (!mediaElement) | 116 if (!mediaElement) |
117 return false; | 117 return false; |
118 | 118 |
119 if (!hasSource(mediaElement) || !mediaElement->togglePlayStateWillPlay()) | 119 if (!hasSource(mediaElement) || !mediaElement->togglePlayStateWillPlay()) |
120 return false; | 120 return false; |
121 | 121 |
122 static Image* mediaOverlayPlay = platformResource("mediaplayerOverlayPlay"); | 122 static Image* mediaOverlayPlay = platformResource("mediaplayerOverlayPlay"); |
123 return paintMediaButton(paintInfo.context, rect, mediaOverlayPlay); | 123 return paintMediaButton(paintInfo.context, rect, mediaOverlayPlay); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 else if (endOffset < borderRadius) | 186 else if (endOffset < borderRadius) |
187 context->fillRoundedRect(highlightRect, IntSize(0, 0), radii, IntSize(0,
0), radii, startColor); | 187 context->fillRoundedRect(highlightRect, IntSize(0, 0), radii, IntSize(0,
0), radii, startColor); |
188 else | 188 else |
189 context->fillRect(highlightRect); | 189 context->fillRect(highlightRect); |
190 | 190 |
191 context->restore(); | 191 context->restore(); |
192 } | 192 } |
193 | 193 |
194 const int mediaSliderThumbWidth = 32; | 194 const int mediaSliderThumbWidth = 32; |
195 | 195 |
196 static bool paintMediaSlider(RenderObject* object, const PaintInfo& paintInfo, c
onst IntRect& rect) | 196 static bool paintMediaSlider(LayoutObject* object, const PaintInfo& paintInfo, c
onst IntRect& rect) |
197 { | 197 { |
198 HTMLMediaElement* mediaElement = toParentMediaElement(object); | 198 HTMLMediaElement* mediaElement = toParentMediaElement(object); |
199 if (!mediaElement) | 199 if (!mediaElement) |
200 return false; | 200 return false; |
201 | 201 |
202 const RenderStyle& style = object->styleRef(); | 202 const RenderStyle& style = object->styleRef(); |
203 GraphicsContext* context = paintInfo.context; | 203 GraphicsContext* context = paintInfo.context; |
204 | 204 |
205 paintRoundedSliderBackground(rect, style, context); | 205 paintRoundedSliderBackground(rect, style, context); |
206 | 206 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 238 |
239 if (endPosition > currentPosition) | 239 if (endPosition > currentPosition) |
240 paintSliderRangeHighlight(rect, style, context, currentPosition, end
Position, startColor, endColor); | 240 paintSliderRangeHighlight(rect, style, context, currentPosition, end
Position, startColor, endColor); |
241 | 241 |
242 return true; | 242 return true; |
243 } | 243 } |
244 | 244 |
245 return true; | 245 return true; |
246 } | 246 } |
247 | 247 |
248 static bool paintMediaSliderThumb(RenderObject* object, const PaintInfo& paintIn
fo, const IntRect& rect) | 248 static bool paintMediaSliderThumb(LayoutObject* object, const PaintInfo& paintIn
fo, const IntRect& rect) |
249 { | 249 { |
250 if (!object->node()) | 250 if (!object->node()) |
251 return false; | 251 return false; |
252 | 252 |
253 HTMLMediaElement* mediaElement = toParentMediaElement(object->node()->shadow
Host()); | 253 HTMLMediaElement* mediaElement = toParentMediaElement(object->node()->shadow
Host()); |
254 if (!mediaElement) | 254 if (!mediaElement) |
255 return false; | 255 return false; |
256 | 256 |
257 if (!hasSource(mediaElement)) | 257 if (!hasSource(mediaElement)) |
258 return true; | 258 return true; |
259 | 259 |
260 Image* mediaSliderThumb = getMediaSliderThumb(); | 260 Image* mediaSliderThumb = getMediaSliderThumb(); |
261 return paintMediaButton(paintInfo.context, rect, mediaSliderThumb); | 261 return paintMediaButton(paintInfo.context, rect, mediaSliderThumb); |
262 } | 262 } |
263 | 263 |
264 const int mediaVolumeSliderThumbWidth = 24; | 264 const int mediaVolumeSliderThumbWidth = 24; |
265 | 265 |
266 static bool paintMediaVolumeSlider(RenderObject* object, const PaintInfo& paintI
nfo, const IntRect& rect) | 266 static bool paintMediaVolumeSlider(LayoutObject* object, const PaintInfo& paintI
nfo, const IntRect& rect) |
267 { | 267 { |
268 HTMLMediaElement* mediaElement = toParentMediaElement(object); | 268 HTMLMediaElement* mediaElement = toParentMediaElement(object); |
269 if (!mediaElement) | 269 if (!mediaElement) |
270 return false; | 270 return false; |
271 | 271 |
272 GraphicsContext* context = paintInfo.context; | 272 GraphicsContext* context = paintInfo.context; |
273 const RenderStyle& style = object->styleRef(); | 273 const RenderStyle& style = object->styleRef(); |
274 | 274 |
275 paintRoundedSliderBackground(rect, style, context); | 275 paintRoundedSliderBackground(rect, style, context); |
276 | 276 |
(...skipping 16 matching lines...) Expand all Loading... |
293 } | 293 } |
294 | 294 |
295 Color startColor = Color(195, 195, 195); | 295 Color startColor = Color(195, 195, 195); |
296 Color endColor = Color(217, 217, 217); | 296 Color endColor = Color(217, 217, 217); |
297 | 297 |
298 paintSliderRangeHighlight(rect, style, context, 0.0, fillWidth, startColor,
endColor); | 298 paintSliderRangeHighlight(rect, style, context, 0.0, fillWidth, startColor,
endColor); |
299 | 299 |
300 return true; | 300 return true; |
301 } | 301 } |
302 | 302 |
303 static bool paintMediaVolumeSliderThumb(RenderObject* object, const PaintInfo& p
aintInfo, const IntRect& rect) | 303 static bool paintMediaVolumeSliderThumb(LayoutObject* object, const PaintInfo& p
aintInfo, const IntRect& rect) |
304 { | 304 { |
305 if (!object->node()) | 305 if (!object->node()) |
306 return false; | 306 return false; |
307 | 307 |
308 HTMLMediaElement* mediaElement = toParentMediaElement(object->node()->shadow
Host()); | 308 HTMLMediaElement* mediaElement = toParentMediaElement(object->node()->shadow
Host()); |
309 if (!mediaElement) | 309 if (!mediaElement) |
310 return false; | 310 return false; |
311 | 311 |
312 if (!hasSource(mediaElement) || !mediaElement->hasAudio()) | 312 if (!hasSource(mediaElement) || !mediaElement->hasAudio()) |
313 return true; | 313 return true; |
314 | 314 |
315 static Image* mediaVolumeSliderThumb = platformResource("mediaplayerVolumeSl
iderThumb"); | 315 static Image* mediaVolumeSliderThumb = platformResource("mediaplayerVolumeSl
iderThumb"); |
316 return paintMediaButton(paintInfo.context, rect, mediaVolumeSliderThumb); | 316 return paintMediaButton(paintInfo.context, rect, mediaVolumeSliderThumb); |
317 } | 317 } |
318 | 318 |
319 static bool paintMediaFullscreenButton(RenderObject* object, const PaintInfo& pa
intInfo, const IntRect& rect) | 319 static bool paintMediaFullscreenButton(LayoutObject* object, const PaintInfo& pa
intInfo, const IntRect& rect) |
320 { | 320 { |
321 HTMLMediaElement* mediaElement = toParentMediaElement(object); | 321 HTMLMediaElement* mediaElement = toParentMediaElement(object); |
322 if (!mediaElement) | 322 if (!mediaElement) |
323 return false; | 323 return false; |
324 | 324 |
325 static Image* mediaFullscreenButton = platformResource("mediaplayerFullscree
n"); | 325 static Image* mediaFullscreenButton = platformResource("mediaplayerFullscree
n"); |
326 return paintMediaButton(paintInfo.context, rect, mediaFullscreenButton); | 326 return paintMediaButton(paintInfo.context, rect, mediaFullscreenButton); |
327 } | 327 } |
328 | 328 |
329 static bool paintMediaToggleClosedCaptionsButton(RenderObject* object, const Pai
ntInfo& paintInfo, const IntRect& rect) | 329 static bool paintMediaToggleClosedCaptionsButton(LayoutObject* object, const Pai
ntInfo& paintInfo, const IntRect& rect) |
330 { | 330 { |
331 HTMLMediaElement* mediaElement = toParentMediaElement(object); | 331 HTMLMediaElement* mediaElement = toParentMediaElement(object); |
332 if (!mediaElement) | 332 if (!mediaElement) |
333 return false; | 333 return false; |
334 | 334 |
335 static Image* mediaClosedCaptionButton = platformResource("mediaplayerClosed
Caption"); | 335 static Image* mediaClosedCaptionButton = platformResource("mediaplayerClosed
Caption"); |
336 static Image* mediaClosedCaptionButtonDisabled = platformResource("mediaplay
erClosedCaptionDisabled"); | 336 static Image* mediaClosedCaptionButtonDisabled = platformResource("mediaplay
erClosedCaptionDisabled"); |
337 | 337 |
338 if (mediaElement->closedCaptionsVisible()) | 338 if (mediaElement->closedCaptionsVisible()) |
339 return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionButto
n); | 339 return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionButto
n); |
340 | 340 |
341 return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionButtonDis
abled); | 341 return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionButtonDis
abled); |
342 } | 342 } |
343 static bool paintMediaCastButton(RenderObject* object, const PaintInfo& paintInf
o, const IntRect& rect) | 343 static bool paintMediaCastButton(LayoutObject* object, const PaintInfo& paintInf
o, const IntRect& rect) |
344 { | 344 { |
345 HTMLMediaElement* mediaElement = toParentMediaElement(object); | 345 HTMLMediaElement* mediaElement = toParentMediaElement(object); |
346 if (!mediaElement) | 346 if (!mediaElement) |
347 return false; | 347 return false; |
348 | 348 |
349 static Image* mediaCastOn = platformResource("mediaplayerCastOn"); | 349 static Image* mediaCastOn = platformResource("mediaplayerCastOn"); |
350 static Image* mediaCastOff = platformResource("mediaplayerCastOff"); | 350 static Image* mediaCastOff = platformResource("mediaplayerCastOff"); |
351 // To ensure that the overlaid cast button is visible when overlaid on pale
videos we use a | 351 // To ensure that the overlaid cast button is visible when overlaid on pale
videos we use a |
352 // different version of it for the overlaid case with a semi-opaque backgrou
nd. | 352 // different version of it for the overlaid case with a semi-opaque backgrou
nd. |
353 static Image* mediaOverlayCastOff = platformResource("mediaplayerOverlayCast
Off"); | 353 static Image* mediaOverlayCastOff = platformResource("mediaplayerOverlayCast
Off"); |
354 | 354 |
355 switch (mediaControlElementType(object->node())) { | 355 switch (mediaControlElementType(object->node())) { |
356 case MediaCastOnButton: | 356 case MediaCastOnButton: |
357 case MediaOverlayCastOnButton: | 357 case MediaOverlayCastOnButton: |
358 return paintMediaButton(paintInfo.context, rect, mediaCastOn); | 358 return paintMediaButton(paintInfo.context, rect, mediaCastOn); |
359 case MediaCastOffButton: | 359 case MediaCastOffButton: |
360 return paintMediaButton(paintInfo.context, rect, mediaCastOff); | 360 return paintMediaButton(paintInfo.context, rect, mediaCastOff); |
361 case MediaOverlayCastOffButton: | 361 case MediaOverlayCastOffButton: |
362 return paintMediaButton(paintInfo.context, rect, mediaOverlayCastOff); | 362 return paintMediaButton(paintInfo.context, rect, mediaOverlayCastOff); |
363 default: | 363 default: |
364 ASSERT_NOT_REACHED(); | 364 ASSERT_NOT_REACHED(); |
365 return false; | 365 return false; |
366 } | 366 } |
367 } | 367 } |
368 | 368 |
369 bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, R
enderObject* object, const PaintInfo& paintInfo, const IntRect& rect) | 369 bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, L
ayoutObject* object, const PaintInfo& paintInfo, const IntRect& rect) |
370 { | 370 { |
371 switch (part) { | 371 switch (part) { |
372 case MediaMuteButton: | 372 case MediaMuteButton: |
373 case MediaUnMuteButton: | 373 case MediaUnMuteButton: |
374 return paintMediaMuteButton(object, paintInfo, rect); | 374 return paintMediaMuteButton(object, paintInfo, rect); |
375 case MediaPauseButton: | 375 case MediaPauseButton: |
376 case MediaPlayButton: | 376 case MediaPlayButton: |
377 return paintMediaPlayButton(object, paintInfo, rect); | 377 return paintMediaPlayButton(object, paintInfo, rect); |
378 case MediaShowClosedCaptionsButton: | 378 case MediaShowClosedCaptionsButton: |
379 return paintMediaToggleClosedCaptionsButton(object, paintInfo, rect); | 379 return paintMediaToggleClosedCaptionsButton(object, paintInfo, rect); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 { | 468 { |
469 return formatChromiumMediaControlsTime(time, time); | 469 return formatChromiumMediaControlsTime(time, time); |
470 } | 470 } |
471 | 471 |
472 String RenderMediaControls::formatMediaControlsCurrentTime(float currentTime, fl
oat duration) | 472 String RenderMediaControls::formatMediaControlsCurrentTime(float currentTime, fl
oat duration) |
473 { | 473 { |
474 return formatChromiumMediaControlsTime(currentTime, duration); | 474 return formatChromiumMediaControlsTime(currentTime, duration); |
475 } | 475 } |
476 | 476 |
477 } // namespace blink | 477 } // namespace blink |
OLD | NEW |