Title: [122379] branches/chromium/1180/Source/WebCore
Revision
122379
Author
[email protected]
Date
2012-07-11 15:42:29 -0700 (Wed, 11 Jul 2012)

Log Message

Merging r120939 and r121043 to 1180 branch (Chrome video controls visual update).

BUG=134726
TEST=none

Modified Paths

Diff

Modified: branches/chromium/1180/Source/WebCore/css/mediaControlsChromium.css (122378 => 122379)


--- branches/chromium/1180/Source/WebCore/css/mediaControlsChromium.css	2012-07-11 22:41:25 UTC (rev 122378)
+++ branches/chromium/1180/Source/WebCore/css/mediaControlsChromium.css	2012-07-11 22:42:29 UTC (rev 122379)
@@ -162,7 +162,7 @@
     -webkit-box-sizing: border-box;
     height: 100%;
     width: 100%;
-    border: 1px solid rgb(130, 130, 130);
+    border: 1px solid rgba(230, 230, 230, 0.35);
     border-radius: 4px;
     background-color: transparent; /* Background drawing is managed by C++ code to draw ranges. */
 }

Modified: branches/chromium/1180/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp (122378 => 122379)


--- branches/chromium/1180/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp	2012-07-11 22:41:25 UTC (rev 122378)
+++ branches/chromium/1180/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp	2012-07-11 22:42:29 UTC (rev 122379)
@@ -242,12 +242,22 @@
 
     m_panelMuteButton->show();
 
-    if (m_volumeSlider)
-        m_volumeSlider->setVolume(m_mediaController->volume());
+    if (m_volumeSlider) {
+        if (!m_mediaController->hasAudio())
+            m_volumeSlider->hide();
+        else {
+            m_volumeSlider->show();
+            m_volumeSlider->setVolume(m_mediaController->volume());
+        }
+    }
 
 #if ENABLE(FULLSCREEN_MEDIA_CONTROLS)
-    m_fullscreenButton->show();
+    if (m_mediaController->supportsFullscreen())
+        m_fullscreenButton->show();
+    else
+        m_fullscreenButton->hide();
 #endif
+
     makeOpaque();
 }
 
@@ -309,7 +319,6 @@
     if (!page)
         return;
 
-    m_timeline->hide();
     m_panelMuteButton->hide();
     m_volumeSlider->hide();
 #if ENABLE(FULLSCREEN_MEDIA_CONTROLS)

Modified: branches/chromium/1180/Source/WebCore/rendering/RenderMediaControlsChromium.cpp (122378 => 122379)


--- branches/chromium/1180/Source/WebCore/rendering/RenderMediaControlsChromium.cpp	2012-07-11 22:41:25 UTC (rev 122378)
+++ branches/chromium/1180/Source/WebCore/rendering/RenderMediaControlsChromium.cpp	2012-07-11 22:42:29 UTC (rev 122379)
@@ -121,29 +121,37 @@
 {
     int borderRadius = rect.height() / 2;
     IntSize radii(borderRadius, borderRadius);
-    Color sliderBackgroundColor = Color(29, 29, 29);
+    Color sliderBackgroundColor = Color(11, 11, 11);
     context->save();
     context->fillRoundedRect(rect, radii, radii, radii, radii, sliderBackgroundColor, ColorSpaceDeviceRGB);
     context->restore();
 }
 
-static void paintSliderRangeHighlight(const IntRect& rect, const RenderStyle* style, GraphicsContext* context, float startFraction, float widthFraction)
+static void paintSliderRangeHighlight(const IntRect& rect, const RenderStyle* style, GraphicsContext* context, int startPosition, int endPosition, Color startColor, Color endColor)
 {
-    if (startFraction < 0)
-        startFraction = 0;
-    if (widthFraction > 1)
-        widthFraction = 1;
-    float endFraction = startFraction + widthFraction;
-    if (endFraction > 1) {
-        widthFraction = widthFraction - startFraction;
-        endFraction = startFraction + widthFraction;
+    // Calculate border radius; need to avoid being smaller than half the slider height
+    // because of https://bugs.webkit.org/show_bug.cgi?id=30143.
+    int borderRadius = rect.height() / 2;
+    IntSize radii(borderRadius, borderRadius);
+
+    // Calculate highlight rectangle and edge dimensions.
+    int startOffset = startPosition;
+    int endOffset = rect.width() - endPosition;
+    int rangeWidth = endPosition - startPosition;
+
+    if (rangeWidth <= 0)
+        return;
+
+    // Make sure the range width is bigger than border radius at the edges to retain rounded corners.
+    if (startOffset < borderRadius && rangeWidth < borderRadius)
+        rangeWidth = borderRadius;
+    if (endOffset < borderRadius && rangeWidth < borderRadius) {
+        startPosition -= borderRadius - rangeWidth;
+        rangeWidth = borderRadius;
     }
 
     // Set rectangle to highlight range.
     IntRect highlightRect = rect;
-    int startOffset = startFraction * rect.width();
-    int endOffset = rect.width() - endFraction * rect.width();
-    int rangeWidth = widthFraction * rect.width();
     highlightRect.move(startOffset, 0);
     highlightRect.setWidth(rangeWidth);
 
@@ -151,17 +159,10 @@
     if (highlightRect.isEmpty())
         return;
 
-    // Calculate border radius; need to avoid being smaller than half the slider height
-    // because of https://bugs.webkit.org/show_bug.cgi?id=30143.
-    int borderRadius = rect.height() / 2;
-    IntSize radii(borderRadius, borderRadius);
-
     // Calculate white-grey gradient.
     IntPoint sliderTopLeft = highlightRect.location();
     IntPoint sliderBottomLeft = sliderTopLeft;
     sliderBottomLeft.move(0, highlightRect.height());
-    Color startColor = Color(220, 220, 220);
-    Color endColor = Color(240, 240, 240);
     RefPtr<Gradient> gradient = Gradient::create(sliderTopLeft, sliderBottomLeft);
     gradient->addColorStop(0.0, startColor);
     gradient->addColorStop(1.0, endColor);
@@ -182,6 +183,8 @@
     context->restore();
 }
 
+const int mediaSliderThumbWidth = 32;
+
 static bool paintMediaSlider(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
 {
     HTMLMediaElement* mediaElement = toParentMediaElement(object);
@@ -206,11 +209,28 @@
         float end = bufferedTimeRanges->end(i, ASSERT_NO_EXCEPTION);
         if (isnan(start) || isnan(end) || start > currentTime || end < currentTime)
             continue;
-        float startFraction = start / duration;
-        float endFraction = end / duration;
-        float widthFraction = endFraction - startFraction;
+        int startPosition = int(start * rect.width() / duration);
+        int currentPosition = int(currentTime * rect.width() / duration);
+        int endPosition = int(end * rect.width() / duration);
 
-        paintSliderRangeHighlight(rect, style, context, startFraction, widthFraction);
+        // Add half the thumb width proportionally adjusted to the current painting position.
+        int thumbCenter = mediaSliderThumbWidth / 2;
+        int addWidth = thumbCenter * (1.0 - 2.0 * currentPosition / rect.width());
+        currentPosition += addWidth;
+
+        // Draw white-ish highlight before current time.
+        Color startColor = Color(195, 195, 195);
+        Color endColor = Color(217, 217, 217);
+        if (currentPosition > startPosition)
+            paintSliderRangeHighlight(rect, style, context, startPosition, currentPosition, startColor, endColor);
+
+        // Draw grey-ish highlight after current time.
+        startColor = Color(60, 60, 60);
+        endColor = Color(76, 76, 76);
+
+        if (endPosition > currentPosition)
+            paintSliderRangeHighlight(rect, style, context, currentPosition, endPosition, startColor, endColor);
+
         return true;
     }
 
@@ -264,8 +284,11 @@
         fillWidth = positionWidth + (zoomLevel * thumbCenter / 2);
     }
 
-    paintSliderRangeHighlight(rect, style, context, 0.0, fillWidth / rect.width());
+    Color startColor = Color(195, 195, 195);
+    Color endColor = Color(217, 217, 217);
 
+    paintSliderRangeHighlight(rect, style, context, 0.0, fillWidth, startColor, endColor);
+
     return true;
 }
 
@@ -338,7 +361,6 @@
     return false;
 }
 
-const int mediaSliderThumbWidth = 32;
 const int mediaSliderThumbHeight = 24;
 const int mediaVolumeSliderThumbHeight = 24;
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to