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

Unified Diff: Source/core/layout/LayoutTheme.cpp

Issue 1156993013: New media playback UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: actually got the other CL number right... Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/layout/LayoutTheme.cpp
diff --git a/Source/core/layout/LayoutTheme.cpp b/Source/core/layout/LayoutTheme.cpp
index 48c070c059dbd403cf10de807f5a3a06c815acec..a3eced6287ae33e16d82047e963672acca1e67e4 100644
--- a/Source/core/layout/LayoutTheme.cpp
+++ b/Source/core/layout/LayoutTheme.cpp
@@ -228,38 +228,56 @@ String LayoutTheme::extraDefaultStyleSheet()
return runtimeCSS.toString();
}
-static String formatChromiumMediaControlsTime(float time, float duration)
+static String formatChromiumMediaControlsTime(float time, float duration, bool includeSeparator)
{
if (!std::isfinite(time))
time = 0;
if (!std::isfinite(duration))
duration = 0;
int seconds = static_cast<int>(fabsf(time));
- int hours = seconds / (60 * 60);
- int minutes = (seconds / 60) % 60;
+ int minutes = seconds / 60;
+
seconds %= 60;
// duration defines the format of how the time is rendered
int durationSecs = static_cast<int>(fabsf(duration));
- int durationHours = durationSecs / (60 * 60);
- int durationMins = (durationSecs / 60) % 60;
+ int durationMins = durationSecs / 60;
+
+ if (!RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) {
+ int hours = seconds / (60 * 60);
+ int durationHours = durationSecs / (60 * 60);
+ durationMins %= 60;
+ minutes %= 60;
+ if (durationHours || hours)
+ return String::format("%s%01d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds);
+ if (durationMins > 9)
+ return String::format("%s%02d:%02d", (time < 0 ? "-" : ""), minutes, seconds);
+
+ return String::format("%s%01d:%02d", (time < 0 ? "-" : ""), minutes, seconds);
+ }
+
+ // New UI includes a leading "/ " before duration.
+ const char* separator = includeSeparator ? "/ " : "";
- if (durationHours || hours)
- return String::format("%s%01d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds);
- if (durationMins > 9)
- return String::format("%s%02d:%02d", (time < 0 ? "-" : ""), minutes, seconds);
+ // 0-9 minutes duration is 0:00
+ // 10-60 minutes duration is 00:00
+ // >60 minutes duration is 000:00
philipj_slow 2015/08/03 13:52:35 Previously you said "the 61:00 is intended" but th
liberato (no reviews please) 2015/08/04 15:07:00 Done.
+ if (durationMins > 60 || minutes > 60)
+ return String::format("%s%s%03d:%02d", separator, (time < 0 ? "-" : ""), minutes, seconds);
+ if (durationMins > 10)
+ return String::format("%s%s%02d:%02d", separator, (time < 0 ? "-" : ""), minutes, seconds);
- return String::format("%s%01d:%02d", (time < 0 ? "-" : ""), minutes, seconds);
+ return String::format("%s%s%01d:%02d", separator, (time < 0 ? "-" : ""), minutes, seconds);
}
String LayoutTheme::formatMediaControlsTime(float time) const
{
- return formatChromiumMediaControlsTime(time, time);
+ return formatChromiumMediaControlsTime(time, time, true);
}
String LayoutTheme::formatMediaControlsCurrentTime(float currentTime, float duration) const
{
- return formatChromiumMediaControlsTime(currentTime, duration);
+ return formatChromiumMediaControlsTime(currentTime, duration, false);
}
Color LayoutTheme::activeSelectionBackgroundColor() const

Powered by Google App Engine
This is Rietveld 408576698