| 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 26 matching lines...) Expand all Loading... |
| 37 #include "platform/graphics/Gradient.h" | 37 #include "platform/graphics/Gradient.h" |
| 38 #include "platform/graphics/GraphicsContext.h" | 38 #include "platform/graphics/GraphicsContext.h" |
| 39 | 39 |
| 40 namespace blink { | 40 namespace blink { |
| 41 | 41 |
| 42 static const double kCurrentTimeBufferedDelta = 1.0; | 42 static const double kCurrentTimeBufferedDelta = 1.0; |
| 43 | 43 |
| 44 typedef WTF::HashMap<const char*, Image*> MediaControlImageMap; | 44 typedef WTF::HashMap<const char*, Image*> MediaControlImageMap; |
| 45 static MediaControlImageMap* gMediaControlImageMap = 0; | 45 static MediaControlImageMap* gMediaControlImageMap = 0; |
| 46 | 46 |
| 47 // Current UI slider thumbs sizes. | 47 // Slider thumb sizes, shard between time and volume. |
| 48 static const int mediaSliderThumbWidth = 32; | |
| 49 static const int mediaSliderThumbHeight = 24; | |
| 50 static const int mediaVolumeSliderThumbHeight = 24; | |
| 51 static const int mediaVolumeSliderThumbWidth = 24; | |
| 52 | |
| 53 // New UI slider thumb sizes, shard between time and volume. | |
| 54 static const int mediaSliderThumbTouchWidthNew = 36; // Touch zone size. | 48 static const int mediaSliderThumbTouchWidthNew = 36; // Touch zone size. |
| 55 static const int mediaSliderThumbTouchHeightNew = 48; | 49 static const int mediaSliderThumbTouchHeightNew = 48; |
| 56 static const int mediaSliderThumbPaintWidthNew = 12; // Painted area. | 50 static const int mediaSliderThumbPaintWidthNew = 12; // Painted area. |
| 57 static const int mediaSliderThumbPaintHeightNew = 12; | 51 static const int mediaSliderThumbPaintHeightNew = 12; |
| 58 | 52 |
| 59 // New UI overlay play button size. | 53 // Overlay play button size. |
| 60 static const int mediaOverlayPlayButtonWidthNew = 48; | 54 static const int mediaOverlayPlayButtonWidthNew = 48; |
| 61 static const int mediaOverlayPlayButtonHeightNew = 48; | 55 static const int mediaOverlayPlayButtonHeightNew = 48; |
| 62 | 56 |
| 63 // Alpha for disabled elements. | 57 // Alpha for disabled elements. |
| 64 static const float kDisabledAlpha = 0.4; | 58 static const float kDisabledAlpha = 0.4; |
| 65 | 59 |
| 66 static Image* platformResource(const char* name) { | 60 static Image* platformResource(const char* name) { |
| 67 if (!gMediaControlImageMap) | 61 if (!gMediaControlImageMap) |
| 68 gMediaControlImageMap = new MediaControlImageMap(); | 62 gMediaControlImageMap = new MediaControlImageMap(); |
| 69 if (Image* image = gMediaControlImageMap->get(name)) | 63 if (Image* image = gMediaControlImageMap->get(name)) |
| 70 return image; | 64 return image; |
| 71 if (Image* image = Image::loadPlatformResource(name).leakRef()) { | 65 if (Image* image = Image::loadPlatformResource(name).leakRef()) { |
| 72 gMediaControlImageMap->set(name, image); | 66 gMediaControlImageMap->set(name, image); |
| 73 return image; | 67 return image; |
| 74 } | 68 } |
| 75 ASSERT_NOT_REACHED(); | 69 ASSERT_NOT_REACHED(); |
| 76 return 0; | 70 return 0; |
| 77 } | 71 } |
| 78 | 72 |
| 79 static Image* platformResource(const char* currentName, const char* newName) { | |
| 80 // Return currentName or newName based on current or new playback. | |
| 81 return platformResource(RuntimeEnabledFeatures::newMediaPlaybackUiEnabled() | |
| 82 ? newName | |
| 83 : currentName); | |
| 84 } | |
| 85 | |
| 86 static bool hasSource(const HTMLMediaElement* mediaElement) { | 73 static bool hasSource(const HTMLMediaElement* mediaElement) { |
| 87 return mediaElement->getNetworkState() != HTMLMediaElement::kNetworkEmpty && | 74 return mediaElement->getNetworkState() != HTMLMediaElement::kNetworkEmpty && |
| 88 mediaElement->getNetworkState() != HTMLMediaElement::kNetworkNoSource; | 75 mediaElement->getNetworkState() != HTMLMediaElement::kNetworkNoSource; |
| 89 } | 76 } |
| 90 | 77 |
| 91 static FloatRect adjustRectForPadding(IntRect rect, | 78 static FloatRect adjustRectForPadding(IntRect rect, |
| 92 const LayoutObject* object) { | 79 const LayoutObject* object) { |
| 93 FloatRect adjustedRect(rect); | 80 FloatRect adjustedRect(rect); |
| 94 | 81 |
| 95 if (!object) | 82 if (!object) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 107 } | 94 } |
| 108 | 95 |
| 109 return adjustedRect; | 96 return adjustedRect; |
| 110 } | 97 } |
| 111 | 98 |
| 112 static bool paintMediaButton(GraphicsContext& context, | 99 static bool paintMediaButton(GraphicsContext& context, |
| 113 const IntRect& rect, | 100 const IntRect& rect, |
| 114 Image* image, | 101 Image* image, |
| 115 const LayoutObject* object, | 102 const LayoutObject* object, |
| 116 bool isEnabled) { | 103 bool isEnabled) { |
| 117 if (!RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) { | |
| 118 context.drawImage(image, rect); | |
| 119 return true; | |
| 120 } | |
| 121 | |
| 122 FloatRect drawRect = adjustRectForPadding(rect, object); | 104 FloatRect drawRect = adjustRectForPadding(rect, object); |
| 123 | 105 |
| 124 if (!isEnabled) | 106 if (!isEnabled) |
| 125 context.beginLayer(kDisabledAlpha); | 107 context.beginLayer(kDisabledAlpha); |
| 126 | 108 |
| 127 context.drawImage(image, drawRect); | 109 context.drawImage(image, drawRect); |
| 128 | 110 |
| 129 if (!isEnabled) | 111 if (!isEnabled) |
| 130 context.endLayer(); | 112 context.endLayer(); |
| 131 | 113 |
| 132 return true; | 114 return true; |
| 133 } | 115 } |
| 134 | 116 |
| 135 static bool paintMediaButton(GraphicsContext& context, | 117 static bool paintMediaButton(GraphicsContext& context, |
| 136 const IntRect& rect, | 118 const IntRect& rect, |
| 137 Image* image, | 119 Image* image, |
| 138 bool isEnabled = true) { | 120 bool isEnabled = true) { |
| 139 return paintMediaButton(context, rect, image, 0, isEnabled); | 121 return paintMediaButton(context, rect, image, 0, isEnabled); |
| 140 } | 122 } |
| 141 | 123 |
| 142 bool MediaControlsPainter::paintMediaMuteButton(const LayoutObject& object, | 124 bool MediaControlsPainter::paintMediaMuteButton(const LayoutObject& object, |
| 143 const PaintInfo& paintInfo, | 125 const PaintInfo& paintInfo, |
| 144 const IntRect& rect) { | 126 const IntRect& rect) { |
| 145 const HTMLMediaElement* mediaElement = toParentMediaElement(object); | 127 const HTMLMediaElement* mediaElement = toParentMediaElement(object); |
| 146 if (!mediaElement) | 128 if (!mediaElement) |
| 147 return false; | 129 return false; |
| 148 | 130 |
| 149 // The new UI uses "muted" and "not muted" only. | 131 // The new UI uses "muted" and "not muted" only. |
| 150 static Image* soundLevel3 = | 132 static Image* soundLevel3 = platformResource("mediaplayerSoundLevel3New"); |
| 151 platformResource("mediaplayerSoundLevel3", "mediaplayerSoundLevel3New"); | 133 static Image* soundLevel2 = platformResource("mediaplayerSoundLevel3New"); |
| 152 static Image* soundLevel2 = | 134 static Image* soundLevel1 = platformResource("mediaplayerSoundLevel3New"); |
| 153 platformResource("mediaplayerSoundLevel2", "mediaplayerSoundLevel3New"); | 135 static Image* soundLevel0 = platformResource("mediaplayerSoundLevel0New"); |
| 154 static Image* soundLevel1 = | 136 static Image* soundDisabled = platformResource("mediaplayerSoundLevel0New"); |
| 155 platformResource("mediaplayerSoundLevel1", "mediaplayerSoundLevel3New"); | |
| 156 static Image* soundLevel0 = | |
| 157 platformResource("mediaplayerSoundLevel0", "mediaplayerSoundLevel0New"); | |
| 158 static Image* soundDisabled = | |
| 159 platformResource("mediaplayerSoundDisabled", "mediaplayerSoundLevel0New"); | |
| 160 | 137 |
| 161 if (!hasSource(mediaElement) || !mediaElement->hasAudio()) | 138 if (!hasSource(mediaElement) || !mediaElement->hasAudio()) |
| 162 return paintMediaButton(paintInfo.context, rect, soundDisabled, &object, | 139 return paintMediaButton(paintInfo.context, rect, soundDisabled, &object, |
| 163 false); | 140 false); |
| 164 | 141 |
| 165 if (mediaElement->muted() || mediaElement->volume() <= 0) | 142 if (mediaElement->muted() || mediaElement->volume() <= 0) |
| 166 return paintMediaButton(paintInfo.context, rect, soundLevel0, &object, | 143 return paintMediaButton(paintInfo.context, rect, soundLevel0, &object, |
| 167 true); | 144 true); |
| 168 | 145 |
| 169 if (mediaElement->volume() <= 0.33) | 146 if (mediaElement->volume() <= 0.33) |
| 170 return paintMediaButton(paintInfo.context, rect, soundLevel1, &object, | 147 return paintMediaButton(paintInfo.context, rect, soundLevel1, &object, |
| 171 true); | 148 true); |
| 172 | 149 |
| 173 if (mediaElement->volume() <= 0.66) | 150 if (mediaElement->volume() <= 0.66) |
| 174 return paintMediaButton(paintInfo.context, rect, soundLevel2, &object, | 151 return paintMediaButton(paintInfo.context, rect, soundLevel2, &object, |
| 175 true); | 152 true); |
| 176 | 153 |
| 177 return paintMediaButton(paintInfo.context, rect, soundLevel3, &object, true); | 154 return paintMediaButton(paintInfo.context, rect, soundLevel3, &object, true); |
| 178 } | 155 } |
| 179 | 156 |
| 180 bool MediaControlsPainter::paintMediaPlayButton(const LayoutObject& object, | 157 bool MediaControlsPainter::paintMediaPlayButton(const LayoutObject& object, |
| 181 const PaintInfo& paintInfo, | 158 const PaintInfo& paintInfo, |
| 182 const IntRect& rect) { | 159 const IntRect& rect) { |
| 183 const HTMLMediaElement* mediaElement = toParentMediaElement(object); | 160 const HTMLMediaElement* mediaElement = toParentMediaElement(object); |
| 184 if (!mediaElement) | 161 if (!mediaElement) |
| 185 return false; | 162 return false; |
| 186 | 163 |
| 187 static Image* mediaPlay = | 164 static Image* mediaPlay = platformResource("mediaplayerPlayNew"); |
| 188 platformResource("mediaplayerPlay", "mediaplayerPlayNew"); | 165 static Image* mediaPause = platformResource("mediaplayerPauseNew"); |
| 189 static Image* mediaPause = | |
| 190 platformResource("mediaplayerPause", "mediaplayerPauseNew"); | |
| 191 // For this case, the new UI draws the normal icon, but the entire panel | 166 // For this case, the new UI draws the normal icon, but the entire panel |
| 192 // grays out. | 167 // grays out. |
| 193 static Image* mediaPlayDisabled = | 168 static Image* mediaPlayDisabled = platformResource("mediaplayerPlayNew"); |
| 194 platformResource("mediaplayerPlayDisabled", "mediaplayerPlayNew"); | |
| 195 | 169 |
| 196 if (!hasSource(mediaElement)) | 170 if (!hasSource(mediaElement)) |
| 197 return paintMediaButton(paintInfo.context, rect, mediaPlayDisabled, &object, | 171 return paintMediaButton(paintInfo.context, rect, mediaPlayDisabled, &object, |
| 198 false); | 172 false); |
| 199 | 173 |
| 200 Image* image = | 174 Image* image = |
| 201 !object.node()->isMediaControlElement() || | 175 !object.node()->isMediaControlElement() || |
| 202 mediaControlElementType(object.node()) == MediaPlayButton | 176 mediaControlElementType(object.node()) == MediaPlayButton |
| 203 ? mediaPlay | 177 ? mediaPlay |
| 204 : mediaPause; | 178 : mediaPause; |
| 205 return paintMediaButton(paintInfo.context, rect, image, &object, true); | 179 return paintMediaButton(paintInfo.context, rect, image, &object, true); |
| 206 } | 180 } |
| 207 | 181 |
| 208 bool MediaControlsPainter::paintMediaOverlayPlayButton( | 182 bool MediaControlsPainter::paintMediaOverlayPlayButton( |
| 209 const LayoutObject& object, | 183 const LayoutObject& object, |
| 210 const PaintInfo& paintInfo, | 184 const PaintInfo& paintInfo, |
| 211 const IntRect& rect) { | 185 const IntRect& rect) { |
| 212 const HTMLMediaElement* mediaElement = toParentMediaElement(object); | 186 const HTMLMediaElement* mediaElement = toParentMediaElement(object); |
| 213 if (!mediaElement) | 187 if (!mediaElement) |
| 214 return false; | 188 return false; |
| 215 | 189 |
| 216 if (!hasSource(mediaElement) || !mediaElement->paused()) | 190 if (!hasSource(mediaElement) || !mediaElement->paused()) |
| 217 return false; | 191 return false; |
| 218 | 192 |
| 219 static Image* mediaOverlayPlay = | 193 static Image* mediaOverlayPlay = |
| 220 platformResource("mediaplayerOverlayPlay", "mediaplayerOverlayPlayNew"); | 194 platformResource("mediaplayerOverlayPlayNew"); |
| 221 | 195 |
| 222 IntRect buttonRect(rect); | 196 IntRect buttonRect(rect); |
| 223 if (RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) { | 197 |
| 224 // Overlay play button covers the entire player, so center and draw a | 198 // Overlay play button covers the entire player, so center and draw a |
| 225 // smaller button. Center in the entire element. | 199 // smaller button. Center in the entire element. |
| 226 // TODO(liberato): object.enclosingBox()? | 200 // TODO(liberato): object.enclosingBox()? |
| 227 const LayoutBox* box = mediaElement->layoutObject()->enclosingBox(); | 201 const LayoutBox* box = mediaElement->layoutObject()->enclosingBox(); |
| 228 if (!box) | 202 if (!box) |
| 229 return false; | 203 return false; |
| 230 int mediaHeight = box->pixelSnappedHeight(); | 204 int mediaHeight = box->pixelSnappedHeight(); |
| 231 buttonRect.setX(rect.center().x() - mediaOverlayPlayButtonWidthNew / 2); | 205 buttonRect.setX(rect.center().x() - mediaOverlayPlayButtonWidthNew / 2); |
| 232 buttonRect.setY(rect.center().y() - mediaOverlayPlayButtonHeightNew / 2 + | 206 buttonRect.setY(rect.center().y() - mediaOverlayPlayButtonHeightNew / 2 + |
| 233 (mediaHeight - rect.height()) / 2); | 207 (mediaHeight - rect.height()) / 2); |
| 234 buttonRect.setWidth(mediaOverlayPlayButtonWidthNew); | 208 buttonRect.setWidth(mediaOverlayPlayButtonWidthNew); |
| 235 buttonRect.setHeight(mediaOverlayPlayButtonHeightNew); | 209 buttonRect.setHeight(mediaOverlayPlayButtonHeightNew); |
| 236 } | |
| 237 | 210 |
| 238 return paintMediaButton(paintInfo.context, buttonRect, mediaOverlayPlay); | 211 return paintMediaButton(paintInfo.context, buttonRect, mediaOverlayPlay); |
| 239 } | 212 } |
| 240 | 213 |
| 241 static Image* getMediaSliderThumb() { | |
| 242 static Image* mediaSliderThumb = | |
| 243 platformResource("mediaplayerSliderThumb", "mediaplayerSliderThumbNew"); | |
| 244 return mediaSliderThumb; | |
| 245 } | |
| 246 | |
| 247 static void paintRoundedSliderBackground(const IntRect& rect, | 214 static void paintRoundedSliderBackground(const IntRect& rect, |
| 248 const ComputedStyle& style, | 215 const ComputedStyle& style, |
| 249 GraphicsContext& context, | 216 GraphicsContext& context, |
| 250 Color sliderBackgroundColor) { | 217 Color sliderBackgroundColor) { |
| 251 float borderRadius = rect.height() / 2; | 218 float borderRadius = rect.height() / 2; |
| 252 FloatSize radii(borderRadius, borderRadius); | 219 FloatSize radii(borderRadius, borderRadius); |
| 253 | 220 |
| 254 context.fillRoundedRect(FloatRoundedRect(rect, radii, radii, radii, radii), | 221 context.fillRoundedRect(FloatRoundedRect(rect, radii, radii, radii, radii), |
| 255 sliderBackgroundColor); | 222 sliderBackgroundColor); |
| 256 } | 223 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 bool MediaControlsPainter::paintMediaSlider(const LayoutObject& object, | 290 bool MediaControlsPainter::paintMediaSlider(const LayoutObject& object, |
| 324 const PaintInfo& paintInfo, | 291 const PaintInfo& paintInfo, |
| 325 const IntRect& rect) { | 292 const IntRect& rect) { |
| 326 const HTMLMediaElement* mediaElement = toParentMediaElement(object); | 293 const HTMLMediaElement* mediaElement = toParentMediaElement(object); |
| 327 if (!mediaElement) | 294 if (!mediaElement) |
| 328 return false; | 295 return false; |
| 329 | 296 |
| 330 GraphicsContext& context = paintInfo.context; | 297 GraphicsContext& context = paintInfo.context; |
| 331 | 298 |
| 332 // Should we paint the slider partially transparent? | 299 // Should we paint the slider partially transparent? |
| 333 bool drawUiGrayed = !hasSource(mediaElement) && | 300 bool drawUiGrayed = !hasSource(mediaElement); |
| 334 RuntimeEnabledFeatures::newMediaPlaybackUiEnabled(); | |
| 335 if (drawUiGrayed) | 301 if (drawUiGrayed) |
| 336 context.beginLayer(kDisabledAlpha); | 302 context.beginLayer(kDisabledAlpha); |
| 337 | 303 |
| 338 paintMediaSliderInternal(object, paintInfo, rect); | 304 paintMediaSliderInternal(object, paintInfo, rect); |
| 339 | 305 |
| 340 if (drawUiGrayed) | 306 if (drawUiGrayed) |
| 341 context.endLayer(); | 307 context.endLayer(); |
| 342 | 308 |
| 343 return true; | 309 return true; |
| 344 } | 310 } |
| 345 | 311 |
| 346 void MediaControlsPainter::paintMediaSliderInternal(const LayoutObject& object, | 312 void MediaControlsPainter::paintMediaSliderInternal(const LayoutObject& object, |
| 347 const PaintInfo& paintInfo, | 313 const PaintInfo& paintInfo, |
| 348 const IntRect& rect) { | 314 const IntRect& rect) { |
| 349 const bool useNewUi = RuntimeEnabledFeatures::newMediaPlaybackUiEnabled(); | |
| 350 const HTMLMediaElement* mediaElement = toParentMediaElement(object); | 315 const HTMLMediaElement* mediaElement = toParentMediaElement(object); |
| 351 if (!mediaElement) | 316 if (!mediaElement) |
| 352 return; | 317 return; |
| 353 | 318 |
| 354 const ComputedStyle& style = object.styleRef(); | 319 const ComputedStyle& style = object.styleRef(); |
| 355 GraphicsContext& context = paintInfo.context; | 320 GraphicsContext& context = paintInfo.context; |
| 356 | 321 |
| 357 // Paint the slider bar in the "no data buffered" state. | 322 // Paint the slider bar in the "no data buffered" state. |
| 358 Color sliderBackgroundColor; | 323 paintRoundedSliderBackground(rect, style, context, Color(0xda, 0xda, 0xda)); |
| 359 if (!useNewUi) | |
| 360 sliderBackgroundColor = Color(11, 11, 11); | |
| 361 else | |
| 362 sliderBackgroundColor = Color(0xda, 0xda, 0xda); | |
| 363 | |
| 364 paintRoundedSliderBackground(rect, style, context, sliderBackgroundColor); | |
| 365 | 324 |
| 366 // Draw the buffered range. Since the element may have multiple buffered | 325 // Draw the buffered range. Since the element may have multiple buffered |
| 367 // ranges and it'd be distracting/'busy' to show all of them, show only the | 326 // ranges and it'd be distracting/'busy' to show all of them, show only the |
| 368 // buffered range containing the current play head. | 327 // buffered range containing the current play head. |
| 369 TimeRanges* bufferedTimeRanges = mediaElement->buffered(); | 328 TimeRanges* bufferedTimeRanges = mediaElement->buffered(); |
| 370 float duration = mediaElement->duration(); | 329 float duration = mediaElement->duration(); |
| 371 float currentTime = mediaElement->currentTime(); | 330 float currentTime = mediaElement->currentTime(); |
| 372 if (std::isnan(duration) || std::isinf(duration) || !duration || | 331 if (std::isnan(duration) || std::isinf(duration) || !duration || |
| 373 std::isnan(currentTime)) | 332 std::isnan(currentTime)) |
| 374 return; | 333 return; |
| 375 | 334 |
| 376 for (unsigned i = 0; i < bufferedTimeRanges->length(); ++i) { | 335 for (unsigned i = 0; i < bufferedTimeRanges->length(); ++i) { |
| 377 float start = bufferedTimeRanges->start(i, ASSERT_NO_EXCEPTION); | 336 float start = bufferedTimeRanges->start(i, ASSERT_NO_EXCEPTION); |
| 378 float end = bufferedTimeRanges->end(i, ASSERT_NO_EXCEPTION); | 337 float end = bufferedTimeRanges->end(i, ASSERT_NO_EXCEPTION); |
| 379 // The delta is there to avoid corner cases when buffered | 338 // The delta is there to avoid corner cases when buffered |
| 380 // ranges is out of sync with current time because of | 339 // ranges is out of sync with current time because of |
| 381 // asynchronous media pipeline and current time caching in | 340 // asynchronous media pipeline and current time caching in |
| 382 // HTMLMediaElement. | 341 // HTMLMediaElement. |
| 383 // This is related to https://www.w3.org/Bugs/Public/show_bug.cgi?id=28125 | 342 // This is related to https://www.w3.org/Bugs/Public/show_bug.cgi?id=28125 |
| 384 // FIXME: Remove this workaround when WebMediaPlayer | 343 // FIXME: Remove this workaround when WebMediaPlayer |
| 385 // has an asynchronous pause interface. | 344 // has an asynchronous pause interface. |
| 386 if (std::isnan(start) || std::isnan(end) || | 345 if (std::isnan(start) || std::isnan(end) || |
| 387 start > currentTime + kCurrentTimeBufferedDelta || end < currentTime) | 346 start > currentTime + kCurrentTimeBufferedDelta || end < currentTime) |
| 388 continue; | 347 continue; |
| 389 int startPosition = int(start * rect.width() / duration); | 348 int startPosition = int(start * rect.width() / duration); |
| 390 int currentPosition = int(currentTime * rect.width() / duration); | 349 int currentPosition = int(currentTime * rect.width() / duration); |
| 391 int endPosition = int(end * rect.width() / duration); | 350 int endPosition = int(end * rect.width() / duration); |
| 392 | 351 |
| 393 if (!useNewUi) { | 352 // Draw highlight before current time. |
| 394 // Add half the thumb width proportionally adjusted to the current | 353 Color startColor = Color(0x42, 0x85, 0xf4); |
| 395 // painting position. | 354 Color endColor = Color(0x42, 0x85, 0xf4); |
| 396 int thumbCenter = mediaSliderThumbWidth / 2; | 355 |
| 397 int addWidth = thumbCenter * (1.0 - 2.0 * currentPosition / rect.width()); | 356 if (currentPosition > startPosition) { |
| 398 currentPosition += addWidth; | 357 paintSliderRangeHighlight(rect, style, context, startPosition, |
| 358 currentPosition, startColor, endColor); |
| 399 } | 359 } |
| 400 | 360 |
| 401 // Draw highlight before current time. | 361 // Draw dark grey highlight after current time. |
| 402 Color startColor; | 362 startColor = endColor = Color(0x5a, 0x5a, 0x5a); |
| 403 Color endColor; | |
| 404 if (!useNewUi) { | |
| 405 startColor = Color(195, 195, 195); // white-ish. | |
| 406 endColor = Color(217, 217, 217); | |
| 407 } else { | |
| 408 startColor = endColor = Color(0x42, 0x85, 0xf4); // blue. | |
| 409 } | |
| 410 | 363 |
| 411 if (currentPosition > startPosition) | 364 if (endPosition > currentPosition) { |
| 412 paintSliderRangeHighlight(rect, style, context, startPosition, | |
| 413 currentPosition, startColor, endColor); | |
| 414 | |
| 415 // Draw grey-ish highlight after current time. | |
| 416 if (!useNewUi) { | |
| 417 startColor = Color(60, 60, 60); | |
| 418 endColor = Color(76, 76, 76); | |
| 419 } else { | |
| 420 startColor = endColor = Color(0x5a, 0x5a, 0x5a); // dark grey | |
| 421 } | |
| 422 | |
| 423 if (endPosition > currentPosition) | |
| 424 paintSliderRangeHighlight(rect, style, context, currentPosition, | 365 paintSliderRangeHighlight(rect, style, context, currentPosition, |
| 425 endPosition, startColor, endColor); | 366 endPosition, startColor, endColor); |
| 426 | 367 } |
| 427 return; | 368 return; |
| 428 } | 369 } |
| 429 } | 370 } |
| 430 | 371 |
| 431 void MediaControlsPainter::adjustMediaSliderThumbPaintSize( | 372 void MediaControlsPainter::adjustMediaSliderThumbPaintSize( |
| 432 const IntRect& rect, | 373 const IntRect& rect, |
| 433 const ComputedStyle& style, | 374 const ComputedStyle& style, |
| 434 IntRect& rectOut) { | 375 IntRect& rectOut) { |
| 435 // Adjust the rectangle to be centered, the right size for the image. | 376 // Adjust the rectangle to be centered, the right size for the image. |
| 436 // We do this because it's quite hard to get the thumb touch target | 377 // We do this because it's quite hard to get the thumb touch target |
| 437 // to match. So, we provide the touch target size with | 378 // to match. So, we provide the touch target size with |
| 438 // adjustMediaSliderThumbSize(), and scale it back when we paint. | 379 // adjustMediaSliderThumbSize(), and scale it back when we paint. |
| 439 rectOut = rect; | 380 rectOut = rect; |
| 440 | 381 |
| 441 if (!RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) { | 382 const float zoomLevel = style.effectiveZoom(); |
| 442 // ...except for the old UI. | 383 const float zoomedPaintWidth = mediaSliderThumbPaintWidthNew * zoomLevel; |
| 443 return; | 384 const float zoomedPaintHeight = mediaSliderThumbPaintHeightNew * zoomLevel; |
| 444 } | |
| 445 | |
| 446 float zoomLevel = style.effectiveZoom(); | |
| 447 float zoomedPaintWidth = mediaSliderThumbPaintWidthNew * zoomLevel; | |
| 448 float zoomedPaintHeight = mediaSliderThumbPaintHeightNew * zoomLevel; | |
| 449 | 385 |
| 450 rectOut.setX(rect.center().x() - zoomedPaintWidth / 2); | 386 rectOut.setX(rect.center().x() - zoomedPaintWidth / 2); |
| 451 rectOut.setY(rect.center().y() - zoomedPaintHeight / 2); | 387 rectOut.setY(rect.center().y() - zoomedPaintHeight / 2); |
| 452 rectOut.setWidth(zoomedPaintWidth); | 388 rectOut.setWidth(zoomedPaintWidth); |
| 453 rectOut.setHeight(zoomedPaintHeight); | 389 rectOut.setHeight(zoomedPaintHeight); |
| 454 } | 390 } |
| 455 | 391 |
| 456 bool MediaControlsPainter::paintMediaSliderThumb(const LayoutObject& object, | 392 bool MediaControlsPainter::paintMediaSliderThumb(const LayoutObject& object, |
| 457 const PaintInfo& paintInfo, | 393 const PaintInfo& paintInfo, |
| 458 const IntRect& rect) { | 394 const IntRect& rect) { |
| 459 if (!object.node()) | 395 if (!object.node()) |
| 460 return false; | 396 return false; |
| 461 | 397 |
| 462 const HTMLMediaElement* mediaElement = | 398 const HTMLMediaElement* mediaElement = |
| 463 toParentMediaElement(object.node()->ownerShadowHost()); | 399 toParentMediaElement(object.node()->ownerShadowHost()); |
| 464 if (!mediaElement) | 400 if (!mediaElement) |
| 465 return false; | 401 return false; |
| 466 | 402 |
| 467 if (!hasSource(mediaElement)) | 403 if (!hasSource(mediaElement)) |
| 468 return true; | 404 return true; |
| 469 | 405 |
| 470 Image* mediaSliderThumb = getMediaSliderThumb(); | 406 static Image* mediaSliderThumb = |
| 407 platformResource("mediaplayerSliderThumbNew"); |
| 471 IntRect paintRect; | 408 IntRect paintRect; |
| 472 const ComputedStyle& style = object.styleRef(); | 409 const ComputedStyle& style = object.styleRef(); |
| 473 adjustMediaSliderThumbPaintSize(rect, style, paintRect); | 410 adjustMediaSliderThumbPaintSize(rect, style, paintRect); |
| 474 return paintMediaButton(paintInfo.context, paintRect, mediaSliderThumb); | 411 return paintMediaButton(paintInfo.context, paintRect, mediaSliderThumb); |
| 475 } | 412 } |
| 476 | 413 |
| 477 bool MediaControlsPainter::paintMediaVolumeSlider(const LayoutObject& object, | 414 bool MediaControlsPainter::paintMediaVolumeSlider(const LayoutObject& object, |
| 478 const PaintInfo& paintInfo, | 415 const PaintInfo& paintInfo, |
| 479 const IntRect& rect) { | 416 const IntRect& rect) { |
| 480 const HTMLMediaElement* mediaElement = toParentMediaElement(object); | 417 const HTMLMediaElement* mediaElement = toParentMediaElement(object); |
| 481 if (!mediaElement) | 418 if (!mediaElement) |
| 482 return false; | 419 return false; |
| 483 | 420 |
| 484 GraphicsContext& context = paintInfo.context; | 421 GraphicsContext& context = paintInfo.context; |
| 485 const ComputedStyle& style = object.styleRef(); | 422 const ComputedStyle& style = object.styleRef(); |
| 486 | 423 |
| 487 // Paint the slider bar. | 424 // Paint the slider bar. |
| 488 Color sliderBackgroundColor; | 425 paintRoundedSliderBackground(rect, style, context, Color(0x5a, 0x5a, 0x5a)); |
| 489 if (!RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) | |
| 490 sliderBackgroundColor = Color(11, 11, 11); | |
| 491 else | |
| 492 sliderBackgroundColor = Color(0x5a, 0x5a, 0x5a); // dark grey | |
| 493 paintRoundedSliderBackground(rect, style, context, sliderBackgroundColor); | |
| 494 | 426 |
| 495 // Calculate volume position for white background rectangle. | 427 // Calculate volume position for white background rectangle. |
| 496 float volume = mediaElement->volume(); | 428 float volume = mediaElement->volume(); |
| 497 if (std::isnan(volume) || volume < 0) | 429 if (std::isnan(volume) || volume < 0) |
| 498 return true; | 430 return true; |
| 499 if (volume > 1) | 431 if (volume > 1) |
| 500 volume = 1; | 432 volume = 1; |
| 501 if (!hasSource(mediaElement) || !mediaElement->hasAudio() || | 433 if (!hasSource(mediaElement) || !mediaElement->hasAudio() || |
| 502 mediaElement->muted()) | 434 mediaElement->muted()) |
| 503 volume = 0; | 435 volume = 0; |
| 504 | 436 |
| 505 // Calculate the position relative to the center of the thumb. | 437 // Calculate the position relative to the center of the thumb. |
| 506 float fillWidth = 0; | 438 const float fillWidth = volume * rect.width(); |
| 507 if (!RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) { | 439 static const Color startColor = Color(0x42, 0x85, 0xf4); |
| 508 if (volume > 0) { | 440 static const Color endColor = Color(217, 217, 217); |
| 509 float thumbCenter = mediaVolumeSliderThumbWidth / 2; | |
| 510 float zoomLevel = style.effectiveZoom(); | |
| 511 float positionWidth = volume * (rect.width() - (zoomLevel * thumbCenter)); | |
| 512 fillWidth = positionWidth + (zoomLevel * thumbCenter / 2); | |
| 513 } | |
| 514 } else { | |
| 515 fillWidth = volume * rect.width(); | |
| 516 } | |
| 517 | |
| 518 Color startColor = Color(195, 195, 195); | |
| 519 Color endColor = Color(217, 217, 217); | |
| 520 if (RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) | |
| 521 startColor = endColor = Color(0x42, 0x85, 0xf4); // blue. | |
| 522 | |
| 523 paintSliderRangeHighlight(rect, style, context, 0.0, fillWidth, startColor, | 441 paintSliderRangeHighlight(rect, style, context, 0.0, fillWidth, startColor, |
| 524 endColor); | 442 endColor); |
| 525 | 443 |
| 526 return true; | 444 return true; |
| 527 } | 445 } |
| 528 | 446 |
| 529 bool MediaControlsPainter::paintMediaVolumeSliderThumb( | 447 bool MediaControlsPainter::paintMediaVolumeSliderThumb( |
| 530 const LayoutObject& object, | 448 const LayoutObject& object, |
| 531 const PaintInfo& paintInfo, | 449 const PaintInfo& paintInfo, |
| 532 const IntRect& rect) { | 450 const IntRect& rect) { |
| 533 if (!object.node()) | 451 if (!object.node()) |
| 534 return false; | 452 return false; |
| 535 | 453 |
| 536 const HTMLMediaElement* mediaElement = | 454 const HTMLMediaElement* mediaElement = |
| 537 toParentMediaElement(object.node()->ownerShadowHost()); | 455 toParentMediaElement(object.node()->ownerShadowHost()); |
| 538 if (!mediaElement) | 456 if (!mediaElement) |
| 539 return false; | 457 return false; |
| 540 | 458 |
| 541 if (!hasSource(mediaElement) || !mediaElement->hasAudio()) | 459 if (!hasSource(mediaElement) || !mediaElement->hasAudio()) |
| 542 return true; | 460 return true; |
| 543 | 461 |
| 544 static Image* mediaVolumeSliderThumb = platformResource( | 462 static Image* mediaVolumeSliderThumb = |
| 545 "mediaplayerVolumeSliderThumb", "mediaplayerVolumeSliderThumbNew"); | 463 platformResource("mediaplayerVolumeSliderThumbNew"); |
| 546 | 464 |
| 547 IntRect paintRect; | 465 IntRect paintRect; |
| 548 const ComputedStyle& style = object.styleRef(); | 466 const ComputedStyle& style = object.styleRef(); |
| 549 adjustMediaSliderThumbPaintSize(rect, style, paintRect); | 467 adjustMediaSliderThumbPaintSize(rect, style, paintRect); |
| 550 return paintMediaButton(paintInfo.context, paintRect, mediaVolumeSliderThumb); | 468 return paintMediaButton(paintInfo.context, paintRect, mediaVolumeSliderThumb); |
| 551 } | 469 } |
| 552 | 470 |
| 553 bool MediaControlsPainter::paintMediaFullscreenButton( | 471 bool MediaControlsPainter::paintMediaFullscreenButton( |
| 554 const LayoutObject& object, | 472 const LayoutObject& object, |
| 555 const PaintInfo& paintInfo, | 473 const PaintInfo& paintInfo, |
| 556 const IntRect& rect) { | 474 const IntRect& rect) { |
| 557 const HTMLMediaElement* mediaElement = toParentMediaElement(object); | 475 const HTMLMediaElement* mediaElement = toParentMediaElement(object); |
| 558 if (!mediaElement) | 476 if (!mediaElement) |
| 559 return false; | 477 return false; |
| 560 | 478 |
| 561 // With the new player UI, we have separate assets for enter / exit | 479 // With the new player UI, we have separate assets for enter / exit |
| 562 // fullscreen mode. | 480 // fullscreen mode. |
| 563 static Image* mediaEnterFullscreenButton = | 481 static Image* mediaEnterFullscreenButton = |
| 564 platformResource("mediaplayerFullscreen", "mediaplayerEnterFullscreen"); | 482 platformResource("mediaplayerEnterFullscreen"); |
| 565 static Image* mediaExitFullscreenButton = | 483 static Image* mediaExitFullscreenButton = |
| 566 platformResource("mediaplayerFullscreen", "mediaplayerExitFullscreen"); | 484 platformResource("mediaplayerExitFullscreen"); |
| 567 | 485 |
| 568 bool isEnabled = hasSource(mediaElement); | 486 bool isEnabled = hasSource(mediaElement); |
| 569 | 487 |
| 570 if (mediaControlElementType(object.node()) == MediaExitFullscreenButton) | 488 if (mediaControlElementType(object.node()) == MediaExitFullscreenButton) |
| 571 return paintMediaButton(paintInfo.context, rect, mediaExitFullscreenButton, | 489 return paintMediaButton(paintInfo.context, rect, mediaExitFullscreenButton, |
| 572 &object, isEnabled); | 490 &object, isEnabled); |
| 573 return paintMediaButton(paintInfo.context, rect, mediaEnterFullscreenButton, | 491 return paintMediaButton(paintInfo.context, rect, mediaEnterFullscreenButton, |
| 574 &object, isEnabled); | 492 &object, isEnabled); |
| 575 } | 493 } |
| 576 | 494 |
| 577 bool MediaControlsPainter::paintMediaToggleClosedCaptionsButton( | 495 bool MediaControlsPainter::paintMediaToggleClosedCaptionsButton( |
| 578 const LayoutObject& object, | 496 const LayoutObject& object, |
| 579 const PaintInfo& paintInfo, | 497 const PaintInfo& paintInfo, |
| 580 const IntRect& rect) { | 498 const IntRect& rect) { |
| 581 const HTMLMediaElement* mediaElement = toParentMediaElement(object); | 499 const HTMLMediaElement* mediaElement = toParentMediaElement(object); |
| 582 if (!mediaElement) | 500 if (!mediaElement) |
| 583 return false; | 501 return false; |
| 584 | 502 |
| 585 static Image* mediaClosedCaptionButton = platformResource( | 503 static Image* mediaClosedCaptionButton = |
| 586 "mediaplayerClosedCaption", "mediaplayerClosedCaptionNew"); | 504 platformResource("mediaplayerClosedCaptionNew"); |
| 587 static Image* mediaClosedCaptionButtonDisabled = | 505 static Image* mediaClosedCaptionButtonDisabled = |
| 588 platformResource("mediaplayerClosedCaptionDisabled", | 506 platformResource("mediaplayerClosedCaptionDisabledNew"); |
| 589 "mediaplayerClosedCaptionDisabledNew"); | |
| 590 | 507 |
| 591 bool isEnabled = mediaElement->hasClosedCaptions(); | 508 bool isEnabled = mediaElement->hasClosedCaptions(); |
| 592 | 509 |
| 593 if (mediaElement->textTracksVisible()) | 510 if (mediaElement->textTracksVisible()) |
| 594 return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionButton, | 511 return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionButton, |
| 595 &object, isEnabled); | 512 &object, isEnabled); |
| 596 | 513 |
| 597 return paintMediaButton(paintInfo.context, rect, | 514 return paintMediaButton(paintInfo.context, rect, |
| 598 mediaClosedCaptionButtonDisabled, &object, isEnabled); | 515 mediaClosedCaptionButtonDisabled, &object, isEnabled); |
| 599 } | 516 } |
| 600 | 517 |
| 601 bool MediaControlsPainter::paintMediaCastButton(const LayoutObject& object, | 518 bool MediaControlsPainter::paintMediaCastButton(const LayoutObject& object, |
| 602 const PaintInfo& paintInfo, | 519 const PaintInfo& paintInfo, |
| 603 const IntRect& rect) { | 520 const IntRect& rect) { |
| 604 const HTMLMediaElement* mediaElement = toParentMediaElement(object); | 521 const HTMLMediaElement* mediaElement = toParentMediaElement(object); |
| 605 if (!mediaElement) | 522 if (!mediaElement) |
| 606 return false; | 523 return false; |
| 607 | 524 |
| 608 static Image* mediaCastOn = | 525 static Image* mediaCastOn = platformResource("mediaplayerCastOnNew"); |
| 609 platformResource("mediaplayerCastOn", "mediaplayerCastOnNew"); | 526 static Image* mediaCastOff = platformResource("mediaplayerCastOffNew"); |
| 610 static Image* mediaCastOff = | |
| 611 platformResource("mediaplayerCastOff", "mediaplayerCastOffNew"); | |
| 612 // To ensure that the overlaid cast button is visible when overlaid on pale | 527 // To ensure that the overlaid cast button is visible when overlaid on pale |
| 613 // videos we use a different version of it for the overlaid case with a | 528 // videos we use a different version of it for the overlaid case with a |
| 614 // semi-opaque background. | 529 // semi-opaque background. |
| 615 static Image* mediaOverlayCastOff = platformResource( | 530 static Image* mediaOverlayCastOff = |
| 616 "mediaplayerOverlayCastOff", "mediaplayerOverlayCastOffNew"); | 531 platformResource("mediaplayerOverlayCastOffNew"); |
| 617 | 532 |
| 618 bool isEnabled = mediaElement->hasRemoteRoutes(); | 533 bool isEnabled = mediaElement->hasRemoteRoutes(); |
| 619 | 534 |
| 620 switch (mediaControlElementType(object.node())) { | 535 switch (mediaControlElementType(object.node())) { |
| 621 case MediaCastOnButton: | 536 case MediaCastOnButton: |
| 622 return paintMediaButton(paintInfo.context, rect, mediaCastOn, &object, | 537 return paintMediaButton(paintInfo.context, rect, mediaCastOn, &object, |
| 623 isEnabled); | 538 isEnabled); |
| 624 case MediaOverlayCastOnButton: | 539 case MediaOverlayCastOnButton: |
| 625 return paintMediaButton(paintInfo.context, rect, mediaCastOn); | 540 return paintMediaButton(paintInfo.context, rect, mediaCastOn); |
| 626 case MediaCastOffButton: | 541 case MediaCastOffButton: |
| 627 return paintMediaButton(paintInfo.context, rect, mediaCastOff, &object, | 542 return paintMediaButton(paintInfo.context, rect, mediaCastOff, &object, |
| 628 isEnabled); | 543 isEnabled); |
| 629 case MediaOverlayCastOffButton: | 544 case MediaOverlayCastOffButton: |
| 630 return paintMediaButton(paintInfo.context, rect, mediaOverlayCastOff); | 545 return paintMediaButton(paintInfo.context, rect, mediaOverlayCastOff); |
| 631 default: | 546 default: |
| 632 ASSERT_NOT_REACHED(); | 547 ASSERT_NOT_REACHED(); |
| 633 return false; | 548 return false; |
| 634 } | 549 } |
| 635 } | 550 } |
| 636 | 551 |
| 637 bool MediaControlsPainter::paintMediaTrackSelectionCheckmark( | 552 bool MediaControlsPainter::paintMediaTrackSelectionCheckmark( |
| 638 const LayoutObject& object, | 553 const LayoutObject& object, |
| 639 const PaintInfo& paintInfo, | 554 const PaintInfo& paintInfo, |
| 640 const IntRect& rect) { | 555 const IntRect& rect) { |
| 641 const HTMLMediaElement* mediaElement = toParentMediaElement(object); | 556 const HTMLMediaElement* mediaElement = toParentMediaElement(object); |
| 642 if (!mediaElement) | 557 if (!mediaElement) |
| 643 return false; | 558 return false; |
| 644 | 559 |
| 645 static Image* mediaTrackSelectionCheckmark = | 560 static Image* mediaTrackSelectionCheckmark = |
| 646 platformResource("mediaplayerTrackSelectionCheckmark", | 561 platformResource("mediaplayerTrackSelectionCheckmarkNew"); |
| 647 "mediaplayerTrackSelectionCheckmarkNew"); | |
| 648 return paintMediaButton(paintInfo.context, rect, | 562 return paintMediaButton(paintInfo.context, rect, |
| 649 mediaTrackSelectionCheckmark); | 563 mediaTrackSelectionCheckmark); |
| 650 } | 564 } |
| 651 | 565 |
| 652 bool MediaControlsPainter::paintMediaClosedCaptionsIcon( | 566 bool MediaControlsPainter::paintMediaClosedCaptionsIcon( |
| 653 const LayoutObject& object, | 567 const LayoutObject& object, |
| 654 const PaintInfo& paintInfo, | 568 const PaintInfo& paintInfo, |
| 655 const IntRect& rect) { | 569 const IntRect& rect) { |
| 656 const HTMLMediaElement* mediaElement = toParentMediaElement(object); | 570 const HTMLMediaElement* mediaElement = toParentMediaElement(object); |
| 657 if (!mediaElement) | 571 if (!mediaElement) |
| 658 return false; | 572 return false; |
| 659 | 573 |
| 660 static Image* mediaClosedCaptionsIcon = platformResource( | 574 static Image* mediaClosedCaptionsIcon = |
| 661 "mediaplayerClosedCaptionsIcon", "mediaplayerClosedCaptionsIconNew"); | 575 platformResource("mediaplayerClosedCaptionsIconNew"); |
| 662 return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionsIcon); | 576 return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionsIcon); |
| 663 } | 577 } |
| 664 | 578 |
| 665 bool MediaControlsPainter::paintMediaSubtitlesIcon(const LayoutObject& object, | 579 bool MediaControlsPainter::paintMediaSubtitlesIcon(const LayoutObject& object, |
| 666 const PaintInfo& paintInfo, | 580 const PaintInfo& paintInfo, |
| 667 const IntRect& rect) { | 581 const IntRect& rect) { |
| 668 const HTMLMediaElement* mediaElement = toParentMediaElement(object); | 582 const HTMLMediaElement* mediaElement = toParentMediaElement(object); |
| 669 if (!mediaElement) | 583 if (!mediaElement) |
| 670 return false; | 584 return false; |
| 671 | 585 |
| 672 static Image* mediaSubtitlesIcon = platformResource( | 586 static Image* mediaSubtitlesIcon = |
| 673 "mediaplayerSubtitlesIcon", "mediaplayerSubtitlesIconNew"); | 587 platformResource("mediaplayerSubtitlesIconNew"); |
| 674 return paintMediaButton(paintInfo.context, rect, mediaSubtitlesIcon); | 588 return paintMediaButton(paintInfo.context, rect, mediaSubtitlesIcon); |
| 675 } | 589 } |
| 676 | 590 |
| 677 bool MediaControlsPainter::paintMediaOverflowMenu(const LayoutObject& object, | 591 bool MediaControlsPainter::paintMediaOverflowMenu(const LayoutObject& object, |
| 678 const PaintInfo& paintInfo, | 592 const PaintInfo& paintInfo, |
| 679 const IntRect& rect) { | 593 const IntRect& rect) { |
| 680 const HTMLMediaElement* mediaElement = toParentMediaElement(object); | 594 const HTMLMediaElement* mediaElement = toParentMediaElement(object); |
| 681 if (!mediaElement) | 595 if (!mediaElement) |
| 682 return false; | 596 return false; |
| 683 | 597 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 695 return false; | 609 return false; |
| 696 | 610 |
| 697 bool isEnabled = hasSource(mediaElement); | 611 bool isEnabled = hasSource(mediaElement); |
| 698 | 612 |
| 699 static Image* mediaDownloadIcon = platformResource("mediaplayerDownloadIcon"); | 613 static Image* mediaDownloadIcon = platformResource("mediaplayerDownloadIcon"); |
| 700 return paintMediaButton(paintInfo.context, rect, mediaDownloadIcon, &object, | 614 return paintMediaButton(paintInfo.context, rect, mediaDownloadIcon, &object, |
| 701 isEnabled); | 615 isEnabled); |
| 702 } | 616 } |
| 703 | 617 |
| 704 void MediaControlsPainter::adjustMediaSliderThumbSize(ComputedStyle& style) { | 618 void MediaControlsPainter::adjustMediaSliderThumbSize(ComputedStyle& style) { |
| 705 static Image* mediaSliderThumb = | 619 const float zoomLevel = style.effectiveZoom(); |
| 706 platformResource("mediaplayerSliderThumb", "mediaplayerSliderThumbNew"); | |
| 707 static Image* mediaVolumeSliderThumb = platformResource( | |
| 708 "mediaplayerVolumeSliderThumb", "mediaplayerVolumeSliderThumbNew"); | |
| 709 int width = 0; | |
| 710 int height = 0; | |
| 711 | 620 |
| 712 Image* thumbImage = 0; | 621 style.setWidth(Length( |
| 713 | 622 static_cast<int>(mediaSliderThumbTouchWidthNew * zoomLevel), Fixed)); |
| 714 if (RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) { | 623 style.setHeight(Length( |
| 715 // Volume and time sliders are the same. | 624 static_cast<int>(mediaSliderThumbTouchHeightNew * zoomLevel), Fixed)); |
| 716 thumbImage = mediaSliderThumb; | |
| 717 width = mediaSliderThumbTouchWidthNew; | |
| 718 height = mediaSliderThumbTouchHeightNew; | |
| 719 } else if (style.appearance() == MediaSliderThumbPart) { | |
| 720 thumbImage = mediaSliderThumb; | |
| 721 width = mediaSliderThumbWidth; | |
| 722 height = mediaSliderThumbHeight; | |
| 723 } else if (style.appearance() == MediaVolumeSliderThumbPart) { | |
| 724 thumbImage = mediaVolumeSliderThumb; | |
| 725 width = mediaVolumeSliderThumbWidth; | |
| 726 height = mediaVolumeSliderThumbHeight; | |
| 727 } | |
| 728 | |
| 729 float zoomLevel = style.effectiveZoom(); | |
| 730 if (thumbImage) { | |
| 731 style.setWidth(Length(static_cast<int>(width * zoomLevel), Fixed)); | |
| 732 style.setHeight(Length(static_cast<int>(height * zoomLevel), Fixed)); | |
| 733 } | |
| 734 } | 625 } |
| 735 | 626 |
| 736 } // namespace blink | 627 } // namespace blink |
| OLD | NEW |