Title: [124214] trunk/Source/WebCore
Revision
124214
Author
[email protected]
Date
2012-07-31 09:21:12 -0700 (Tue, 31 Jul 2012)

Log Message

[Blackberry][FullScreen] HTML5 <video> controls are scaled differently depending on the current webpage scale
https://bugs.webkit.org/show_bug.cgi?id=90884
PR #162839

Reviewed by Rob Buis.
Patch by Antonio Gomes <[email protected]>

The way the BlackBerry port implements the FULLSCREEN_API for media
elements might result in the controls being oversized, proportionally
to the current page scale. That happens because the fullscreen element
gets sized to be as big as the viewport size, and the viewport size might
get outstretched to fit to the screen dimensions.

In order to fix that, the patch strips out the Page scale factor from
the media controls multiplier.

Patch also changes many integer-based calculations to be float-based, in
order to get the needed precision.

Internally reviewed by Jacky Jiang.

* platform/blackberry/RenderThemeBlackBerry.cpp:
(WebCore):
(WebCore::determineFullScreenMultiplier):
(WebCore::RenderThemeBlackBerry::adjustSliderThumbSize):
(WebCore::RenderThemeBlackBerry::adjustMediaControlStyle):
(WebCore::RenderThemeBlackBerry::adjustSliderTrackStyle):
(WebCore::RenderThemeBlackBerry::paintMediaSliderTrack):
(WebCore::RenderThemeBlackBerry::paintMediaSliderThumb):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (124213 => 124214)


--- trunk/Source/WebCore/ChangeLog	2012-07-31 16:10:39 UTC (rev 124213)
+++ trunk/Source/WebCore/ChangeLog	2012-07-31 16:21:12 UTC (rev 124214)
@@ -1,3 +1,34 @@
+2012-07-17  Antonio Gomes  <[email protected]>
+
+        [Blackberry][FullScreen] HTML5 <video> controls are scaled differently depending on the current webpage scale
+        https://bugs.webkit.org/show_bug.cgi?id=90884
+        PR #162839
+
+        Reviewed by Rob Buis.
+
+        The way the BlackBerry port implements the FULLSCREEN_API for media
+        elements might result in the controls being oversized, proportionally
+        to the current page scale. That happens because the fullscreen element
+        gets sized to be as big as the viewport size, and the viewport size might
+        get outstretched to fit to the screen dimensions.
+
+        In order to fix that, the patch strips out the Page scale factor from
+        the media controls multiplier.
+
+        Patch also changes many integer-based calculations to be float-based, in
+        order to get the needed precision.
+
+        Internally reviewed by Jacky Jiang.
+
+        * platform/blackberry/RenderThemeBlackBerry.cpp:
+        (WebCore):
+        (WebCore::determineFullScreenMultiplier):
+        (WebCore::RenderThemeBlackBerry::adjustSliderThumbSize):
+        (WebCore::RenderThemeBlackBerry::adjustMediaControlStyle):
+        (WebCore::RenderThemeBlackBerry::adjustSliderTrackStyle):
+        (WebCore::RenderThemeBlackBerry::paintMediaSliderTrack):
+        (WebCore::RenderThemeBlackBerry::paintMediaSliderThumb):
+
 2012-07-31  Stephen White  <[email protected]>
 
         Remove the clone() method from FilterOperation (and subclasses).

Modified: trunk/Source/WebCore/platform/blackberry/RenderThemeBlackBerry.cpp (124213 => 124214)


--- trunk/Source/WebCore/platform/blackberry/RenderThemeBlackBerry.cpp	2012-07-31 16:10:39 UTC (rev 124213)
+++ trunk/Source/WebCore/platform/blackberry/RenderThemeBlackBerry.cpp	2012-07-31 16:21:12 UTC (rev 124214)
@@ -24,10 +24,12 @@
 #include "CSSValueKeywords.h"
 #include "Frame.h"
 #include "HTMLMediaElement.h"
+#include "HostWindow.h"
 #include "MediaControlElements.h"
 #include "MediaPlayerPrivateBlackBerry.h"
 #include "Page.h"
 #include "PaintInfo.h"
+#include "RenderFullScreen.h"
 #include "RenderProgress.h"
 #include "RenderSlider.h"
 #include "RenderView.h"
@@ -39,13 +41,13 @@
 const unsigned smallRadius = 1;
 const unsigned largeRadius = 3;
 const unsigned lineWidth = 1;
-const int marginSize = 4;
-const int mediaControlsHeight = 32;
-const int mediaSliderThumbWidth = 40;
-const int mediaSliderThumbHeight = 13;
-const int mediaSliderThumbRadius = 5;
-const int sliderThumbWidth = 15;
-const int sliderThumbHeight = 25;
+const float marginSize = 4;
+const float mediaControlsHeight = 32;
+const float mediaSliderThumbWidth = 40;
+const float mediaSliderThumbHeight = 13;
+const float mediaSliderThumbRadius = 5;
+const float sliderThumbWidth = 15;
+const float sliderThumbHeight = 25;
 
 // Checkbox check scalers
 const float checkboxLeftX = 7 / 40.0;
@@ -158,13 +160,23 @@
     return toRenderSlider(object);
 }
 
-static int determineFullScreenMultiplier(Element* element)
+static float determineFullScreenMultiplier(Element* element)
 {
-    int fullScreenMultiplier = 1;
+    float fullScreenMultiplier = 1.0;
 #if ENABLE(FULLSCREEN_API) && ENABLE(VIDEO)
     if (element && element->document()->webkitIsFullScreen() && element->document()->webkitCurrentFullScreenElement() == toParentMediaElement(element)) {
         if (element->document()->page()->deviceScaleFactor() < scaleFactorThreshold)
             fullScreenMultiplier = fullScreenEnlargementFactor;
+
+        // The way the BlackBerry port implements the FULLSCREEN_API for media elements
+        // might result in the controls being oversized, proportionally to the current page
+        // scale. That happens because the fullscreen element gets sized to be as big as the
+        // viewport size, and the viewport size might get outstretched to fit to the screen dimensions.
+        // To fix that, lets strips out the Page scale factor from the media controls multiplier.
+        float scaleFactor = element->document()->view()->hostWindow()->platformPageClient()->currentZoomFactor();
+        static ViewportArguments defaultViewportArguments;
+        float scaleFactorFudge = element->document()->page()->viewportArguments() != defaultViewportArguments ? .5 : .85;
+        fullScreenMultiplier /= scaleFactor * scaleFactorFudge;
     }
 #endif
     return fullScreenMultiplier;
@@ -629,7 +641,7 @@
 
 void RenderThemeBlackBerry::adjustSliderThumbSize(RenderStyle* style, Element* element) const
 {
-    int fullScreenMultiplier = 1;
+    float fullScreenMultiplier = 1;
     ControlPart part = style->appearance();
 
     if (part == MediaSliderThumbPart || part == MediaVolumeSliderThumbPart) {
@@ -750,14 +762,15 @@
 
 void RenderThemeBlackBerry::adjustMediaControlStyle(StyleResolver*, RenderStyle* style, Element* element) const
 {
-    int fullScreenMultiplier = determineFullScreenMultiplier(element);
+    float fullScreenMultiplier = determineFullScreenMultiplier(element);
 
     // We use multiples of mediaControlsHeight to make all objects scale evenly
     Length controlsHeight(mediaControlsHeight * fullScreenMultiplier, Fixed);
     Length timeWidth(mediaControlsHeight * 3 / 2 * fullScreenMultiplier, Fixed);
     Length volumeHeight(mediaControlsHeight * 4 * fullScreenMultiplier, Fixed);
     Length padding(mediaControlsHeight / 8 * fullScreenMultiplier, Fixed);
-    int fontSize = mediaControlsHeight / 2 * fullScreenMultiplier;
+    float fontSize = mediaControlsHeight / 2 * fullScreenMultiplier;
+
     switch (style->appearance()) {
     case MediaPlayButtonPart:
     case MediaEnterFullscreenButtonPart:
@@ -785,7 +798,7 @@
 
 void RenderThemeBlackBerry::adjustSliderTrackStyle(StyleResolver*, RenderStyle* style, Element* element) const
 {
-    int fullScreenMultiplier = determineFullScreenMultiplier(element);
+    float fullScreenMultiplier = determineFullScreenMultiplier(element);
 
     // We use multiples of mediaControlsHeight to make all objects scale evenly
     Length controlsHeight(mediaControlsHeight * fullScreenMultiplier, Fixed);
@@ -881,7 +894,7 @@
     if (!mediaElement)
         return false;
 
-    int fullScreenMultiplier = determineFullScreenMultiplier(mediaElement);
+    float fullScreenMultiplier = determineFullScreenMultiplier(mediaElement);
     float loaded = 0;
     // FIXME: replace loaded with commented out one when buffer bug is fixed (see comment in
     // MediaPlayerPrivateMMrenderer::percentLoaded).
@@ -890,14 +903,14 @@
         loaded = static_cast<MediaPlayerPrivate *>(mediaElement->player()->implementation())->percentLoaded();
     float position = mediaElement->duration() > 0 ? (mediaElement->currentTime() / mediaElement->duration()) : 0;
 
-    int x = rect.x() + 2 * fullScreenMultiplier - fullScreenMultiplier / 2;
-    int y = rect.y() + 14 * fullScreenMultiplier + fullScreenMultiplier / 2;
-    int w = rect.width() - 4 * fullScreenMultiplier + fullScreenMultiplier / 2;
-    int h = 2 * fullScreenMultiplier;
+    int x = ceil(rect.x() + 2 * fullScreenMultiplier - fullScreenMultiplier / 2);
+    int y = ceil(rect.y() + 14 * fullScreenMultiplier + fullScreenMultiplier / 2);
+    int w = ceil(rect.width() - 4 * fullScreenMultiplier + fullScreenMultiplier / 2);
+    int h = ceil(2 * fullScreenMultiplier);
     IntRect rect2(x, y, w, h);
 
-    int wPlayed = (w * position);
-    int wLoaded = (w - mediaSliderThumbWidth * fullScreenMultiplier) * loaded + mediaSliderThumbWidth * fullScreenMultiplier;
+    int wPlayed = ceil(w * position);
+    int wLoaded = ceil((w - mediaSliderThumbWidth * fullScreenMultiplier) * loaded + mediaSliderThumbWidth * fullScreenMultiplier);
 
     IntRect played(x, y, wPlayed, h);
     IntRect buffered(x, y, wLoaded, h);
@@ -929,7 +942,7 @@
     if (!slider)
         return false;
 
-    int fullScreenMultiplier = determineFullScreenMultiplier(toElement(slider->node()));
+    float fullScreenMultiplier = determineFullScreenMultiplier(toElement(slider->node()));
 
     paintInfo.context->save();
     Path mediaThumbRoundedRectangle;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to