Chromium Code Reviews| 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 return false; | 200 return false; |
| 201 | 201 |
| 202 const LayoutStyle& style = object->styleRef(); | 202 const LayoutStyle& 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 |
| 207 // Draw the buffered range. Since the element may have multiple buffered ran ges and it'd be | 207 // Draw the buffered range. Since the element may have multiple buffered ran ges and it'd be |
| 208 // distracting/'busy' to show all of them, show only the buffered range cont aining the current play head. | 208 // distracting/'busy' to show all of them, show only the buffered range cont aining the current play head. |
| 209 RefPtrWillBeRawPtr<TimeRanges> bufferedTimeRanges = mediaElement->buffered() ; | 209 RefPtrWillBeRawPtr<TimeRanges> bufferedTimeRanges = mediaElement->buffered() ; |
| 210 float duration = mediaElement->duration(); | 210 double duration = mediaElement->duration(); |
| 211 float currentTime = mediaElement->currentTime(); | 211 double currentTime = mediaElement->currentTime(); |
| 212 if (std::isnan(duration) || std::isinf(duration) || !duration || std::isnan( currentTime)) | 212 if (std::isnan(duration) || std::isinf(duration) || !duration || std::isnan( currentTime) |
| 213 || bufferedTimeRanges->length() == 0) | |
| 213 return true; | 214 return true; |
| 214 | 215 |
| 215 for (unsigned i = 0; i < bufferedTimeRanges->length(); ++i) { | 216 unsigned nearestIdx = bufferedTimeRanges->nearestRange(currentTime); |
|
philipj_slow
2015/03/06 03:16:17
So I was thinking that we could have a getter for
landell
2015/03/06 13:49:06
I agree. To me the problem is that the TimeRanges
| |
| 216 float start = bufferedTimeRanges->start(i, ASSERT_NO_EXCEPTION); | 217 double start = bufferedTimeRanges->start(nearestIdx, ASSERT_NO_EXCEPTION); |
| 217 float end = bufferedTimeRanges->end(i, ASSERT_NO_EXCEPTION); | 218 double end = bufferedTimeRanges->end(nearestIdx, ASSERT_NO_EXCEPTION); |
| 218 if (std::isnan(start) || std::isnan(end) || start > currentTime || end < currentTime) | 219 if (std::isnan(start) || std::isnan(end)) { |
|
philipj_slow
2015/03/06 03:16:17
Could we fix the whole problem by tweaking this to
landell
2015/03/06 13:49:06
I can look at such a solution. Don't know if the s
| |
| 219 continue; | 220 return true; |
| 220 int startPosition = int(start * rect.width() / duration); | 221 } |
| 221 int currentPosition = int(currentTime * rect.width() / duration); | |
| 222 int endPosition = int(end * rect.width() / duration); | |
| 223 | 222 |
| 224 // Add half the thumb width proportionally adjusted to the current paint ing position. | 223 int startPosition = int(start * rect.width() / duration); |
| 225 int thumbCenter = mediaSliderThumbWidth / 2; | 224 int currentPosition = int(currentTime * rect.width() / duration); |
| 226 int addWidth = thumbCenter * (1.0 - 2.0 * currentPosition / rect.width() ); | 225 int endPosition = int(end * rect.width() / duration); |
| 227 currentPosition += addWidth; | 226 |
| 227 // Add half the thumb width proportionally adjusted to the current painting position. | |
| 228 int thumbCenter = mediaSliderThumbWidth / 2; | |
| 229 int addWidth = thumbCenter * (1.0 - 2.0 * currentPosition / rect.width()); | |
| 230 currentPosition += addWidth; | |
| 231 | |
| 232 // Only paint ranges that will intersect with the slider thumb | |
|
philipj_slow
2015/03/06 03:16:17
I see no explicit delta, so I guess the resolution
landell
2015/03/06 13:49:06
My thinking was that it made sense to make the del
| |
| 233 if (currentPosition <= endPosition + thumbCenter | |
| 234 || currentPosition >= startPosition - thumbCenter) { | |
| 228 | 235 |
| 229 // Draw white-ish highlight before current time. | 236 // Draw white-ish highlight before current time. |
| 230 Color startColor = Color(195, 195, 195); | 237 Color startColor = Color(195, 195, 195); |
| 231 Color endColor = Color(217, 217, 217); | 238 Color endColor = Color(217, 217, 217); |
| 232 if (currentPosition > startPosition) | 239 if (currentPosition > startPosition) |
| 233 paintSliderRangeHighlight(rect, style, context, startPosition, curre ntPosition, startColor, endColor); | 240 paintSliderRangeHighlight(rect, style, context, startPosition, curre ntPosition, startColor, endColor); |
| 234 | 241 |
| 235 // Draw grey-ish highlight after current time. | 242 // Draw grey-ish highlight after current time. |
| 236 startColor = Color(60, 60, 60); | 243 startColor = Color(60, 60, 60); |
| 237 endColor = Color(76, 76, 76); | 244 endColor = Color(76, 76, 76); |
| 238 | 245 |
| 239 if (endPosition > currentPosition) | 246 if (endPosition > currentPosition) |
| 240 paintSliderRangeHighlight(rect, style, context, currentPosition, end Position, startColor, endColor); | 247 paintSliderRangeHighlight(rect, style, context, currentPosition, end Position, startColor, endColor); |
| 241 | |
| 242 return true; | |
| 243 } | 248 } |
| 244 | 249 |
| 245 return true; | 250 return true; |
| 246 } | 251 } |
| 247 | 252 |
| 248 static bool paintMediaSliderThumb(LayoutObject* object, const PaintInfo& paintIn fo, const IntRect& rect) | 253 static bool paintMediaSliderThumb(LayoutObject* object, const PaintInfo& paintIn fo, const IntRect& rect) |
| 249 { | 254 { |
| 250 if (!object->node()) | 255 if (!object->node()) |
| 251 return false; | 256 return false; |
| 252 | 257 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 { | 471 { |
| 467 return formatChromiumMediaControlsTime(time, time); | 472 return formatChromiumMediaControlsTime(time, time); |
| 468 } | 473 } |
| 469 | 474 |
| 470 String LayoutMediaControls::formatMediaControlsCurrentTime(float currentTime, fl oat duration) | 475 String LayoutMediaControls::formatMediaControlsCurrentTime(float currentTime, fl oat duration) |
| 471 { | 476 { |
| 472 return formatChromiumMediaControlsTime(currentTime, duration); | 477 return formatChromiumMediaControlsTime(currentTime, duration); |
| 473 } | 478 } |
| 474 | 479 |
| 475 } // namespace blink | 480 } // namespace blink |
| OLD | NEW |