[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.20-204-g221d8e8
eric at webkit.org
eric at webkit.org
Wed Feb 10 22:12:08 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 1ae716af83b56551dc977b5ef0cebee5035753f9
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Feb 4 07:48:37 2010 +0000
2010-02-03 Nicholas Young <nicholas.young at nokia.com>
Reviewed by Eric Carlson.
Defer formatting of times displayed on media controls to the current theme.
https://bugs.webkit.org/show_bug.cgi?id=34405
No new tests needed. Refactoring Only.
* rendering/MediaControlElements.cpp: Removed formatTime()
(WebCore::MediaControlTimeDisplayElement::setCurrentValue): No longer sets inner text
* rendering/MediaControlElements.h:
* rendering/RenderMedia.cpp:
(WebCore::RenderMedia::updateTimeDisplay): Asks the theme to format the time display elements
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::formatMediaControlsTime): new virtual method
(WebCore::RenderTheme::formatMediaControlsCurrentTime): new virtual method
(WebCore::RenderTheme::formatMediaControlsRemainingTime): new virtual method
* rendering/RenderTheme.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54326 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index f1ee817..27a4106 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,23 @@
+2010-02-03 Nicholas Young <nicholas.young at nokia.com>
+
+ Reviewed by Eric Carlson.
+
+ Defer formatting of times displayed on media controls to the current theme.
+ https://bugs.webkit.org/show_bug.cgi?id=34405
+
+ No new tests needed. Refactoring Only.
+
+ * rendering/MediaControlElements.cpp: Removed formatTime()
+ (WebCore::MediaControlTimeDisplayElement::setCurrentValue): No longer sets inner text
+ * rendering/MediaControlElements.h:
+ * rendering/RenderMedia.cpp:
+ (WebCore::RenderMedia::updateTimeDisplay): Asks the theme to format the time display elements
+ * rendering/RenderTheme.cpp:
+ (WebCore::RenderTheme::formatMediaControlsTime): new virtual method
+ (WebCore::RenderTheme::formatMediaControlsCurrentTime): new virtual method
+ (WebCore::RenderTheme::formatMediaControlsRemainingTime): new virtual method
+ * rendering/RenderTheme.h:
+
2010-02-03 Steve Falkenburg <sfalken at apple.com>
Windows Debug_All build fix.
diff --git a/WebCore/rendering/MediaControlElements.cpp b/WebCore/rendering/MediaControlElements.cpp
index 31a91ab..2b7a8c8 100644
--- a/WebCore/rendering/MediaControlElements.cpp
+++ b/WebCore/rendering/MediaControlElements.cpp
@@ -731,30 +731,9 @@ void MediaControlTimeDisplayElement::setVisible(bool visible)
renderer()->setStyle(style.get());
}
-String MediaControlTimeDisplayElement::formatTime(float time)
-{
- if (!isfinite(time))
- time = 0;
- int seconds = (int)fabsf(time);
- int hours = seconds / (60 * 60);
- int minutes = (seconds / 60) % 60;
- seconds %= 60;
- if (hours) {
- if (hours > 9)
- return String::format("%s%02d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds);
-
- return String::format("%s%01d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds);
- }
-
- return String::format("%s%02d:%02d", (time < 0 ? "-" : ""), minutes, seconds);
-}
-
void MediaControlTimeDisplayElement::setCurrentValue(float time)
{
m_currentValue = time;
-
- ExceptionCode ec;
- setInnerText(formatTime(m_currentValue), ec);
}
diff --git a/WebCore/rendering/MediaControlElements.h b/WebCore/rendering/MediaControlElements.h
index 0ba4aba..21831ce 100644
--- a/WebCore/rendering/MediaControlElements.h
+++ b/WebCore/rendering/MediaControlElements.h
@@ -268,8 +268,6 @@ public:
float currentValue() const { return m_currentValue; }
private:
- String formatTime(float time);
-
float m_currentValue;
bool m_isVisible;
};
diff --git a/WebCore/rendering/RenderMedia.cpp b/WebCore/rendering/RenderMedia.cpp
index 8acebfb..7100435 100644
--- a/WebCore/rendering/RenderMedia.cpp
+++ b/WebCore/rendering/RenderMedia.cpp
@@ -412,10 +412,15 @@ void RenderMedia::updateTimeDisplay()
{
if (!m_currentTimeDisplay || !m_currentTimeDisplay->renderer() || m_currentTimeDisplay->renderer()->style()->display() == NONE || style()->visibility() != VISIBLE)
return;
+
float now = mediaElement()->currentTime();
float duration = mediaElement()->duration();
+ // Allow the theme to format the time
+ ExceptionCode ec;
+ m_currentTimeDisplay->setInnerText(theme()->formatMediaControlsCurrentTime(now, duration), ec);
m_currentTimeDisplay->setCurrentValue(now);
+ m_timeRemainingDisplay->setInnerText(theme()->formatMediaControlsRemainingTime(now, duration), ec);
m_timeRemainingDisplay->setCurrentValue(now - duration);
}
diff --git a/WebCore/rendering/RenderTheme.cpp b/WebCore/rendering/RenderTheme.cpp
index 1362cee..984a176 100644
--- a/WebCore/rendering/RenderTheme.cpp
+++ b/WebCore/rendering/RenderTheme.cpp
@@ -436,6 +436,35 @@ bool RenderTheme::shouldRenderMediaControlPart(ControlPart part, Element* e)
return true;
}
}
+
+String RenderTheme::formatMediaControlsTime(float time) const
+{
+ if (!isfinite(time))
+ time = 0;
+ int seconds = (int)fabsf(time);
+ int hours = seconds / (60 * 60);
+ int minutes = (seconds / 60) % 60;
+ seconds %= 60;
+ if (hours) {
+ if (hours > 9)
+ return String::format("%s%02d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds);
+
+ return String::format("%s%01d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds);
+ }
+
+ return String::format("%s%02d:%02d", (time < 0 ? "-" : ""), minutes, seconds);
+}
+
+String RenderTheme::formatMediaControlsCurrentTime(float currentTime, float /*duration*/) const
+{
+ return formatMediaControlsTime(currentTime);
+}
+
+String RenderTheme::formatMediaControlsRemainingTime(float currentTime, float duration) const
+{
+ return formatMediaControlsTime(currentTime - duration);
+}
+
#endif
Color RenderTheme::activeSelectionBackgroundColor() const
diff --git a/WebCore/rendering/RenderTheme.h b/WebCore/rendering/RenderTheme.h
index ee39d0c..0a7ea97 100644
--- a/WebCore/rendering/RenderTheme.h
+++ b/WebCore/rendering/RenderTheme.h
@@ -175,6 +175,9 @@ public:
virtual bool shouldRenderMediaControlPart(ControlPart, Element*);
virtual double mediaControlsFadeInDuration() { return 0.1; }
virtual double mediaControlsFadeOutDuration() { return 0.3; }
+ virtual String formatMediaControlsTime(float time) const;
+ virtual String formatMediaControlsCurrentTime(float currentTime, float duration) const;
+ virtual String formatMediaControlsRemainingTime(float currentTime, float duration) const;
#endif
protected:
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list