Apply a zoom property when resolution is changed
authorSeonae Kim <sunaeluv.kim@samsung.com>
Sun, 14 Apr 2013 07:49:58 +0000 (16:49 +0900)
committerGerrit Code Review <gerrit2@kim11>
Thu, 18 Apr 2013 02:04:21 +0000 (11:04 +0900)
[Title] Apply a zoom property when resolution is changed
[Issue] N/A
[Problem] If screen resolution is changed, the size of media controls is not accurate.
[Cause] We did not consider other resolution.
[Solution] Adjust the control size using a zoom property

Change-Id: I361e65ecfacf62301240268f4207f5a17c1715f8

Source/WebCore/css/mediaControlsTizenFullscreenHorizontal.css
Source/WebCore/css/mediaControlsTizenFullscreenVertical.css
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/shadow/MediaControlRootElement.cpp
Source/WebCore/html/shadow/MediaControlRootElement.h
Source/WebCore/html/shadow/MediaControls.h
Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp

index b8b9597..d3473d7 100755 (executable)
@@ -28,7 +28,8 @@
 
 
 video:-webkit-full-screen::-webkit-media-controls-panel {
-    position: relative;
+    -webkit-transform-origin: left bottom;
+    position: fixed;
     left: 0px;
     bottom: 0px;
     width: 1280px;
index ca4a9e7..39e1bdd 100755 (executable)
@@ -28,7 +28,8 @@
 
 
 video:-webkit-full-screen::-webkit-media-controls-panel {
-    position: relative;
+    -webkit-transform-origin: left bottom;
+    position: fixed;
     left: 0px;
     bottom: 0px;
     width: 720px;
index 9a84f28..b218137 100755 (executable)
@@ -170,6 +170,8 @@ enum {
     ROTATE_270,
     ROTATE_ERROR
 };
+
+int HTMLMediaElement::s_rotation = ROTATE_0;
 #endif
 
 using namespace HTMLNames;
@@ -289,9 +291,6 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* docum
 #if ENABLE(TIZEN_GSTREAMER_VIDEO)
     , m_suspended(false)
 #endif
-#if ENABLE(TIZEN_DEVICE_ROTATION)
-    , m_rotation(ROTATE_0)
-#endif
 {
     LOG(Media, "HTMLMediaElement::HTMLMediaElement");
     document->registerForMediaVolumeCallbacks(this);
@@ -343,12 +342,12 @@ HTMLMediaElement::~HTMLMediaElement()
 #if ENABLE(TIZEN_DEVICE_ROTATION)
 bool HTMLMediaElement::isHorizontal()
 {
-    return (m_rotation == ROTATE_90 || m_rotation == ROTATE_270) ? true : false;
+    return (s_rotation == ROTATE_90 || s_rotation == ROTATE_270) ? true : false;
 }
 
 bool HTMLMediaElement::isVertical()
 {
-    return (m_rotation == ROTATE_0 || m_rotation == ROTATE_180) ? true : false;
+    return (s_rotation == ROTATE_0 || s_rotation == ROTATE_180) ? true : false;
 }
 
 void HTMLMediaElement::registerRotationCallback()
@@ -415,10 +414,10 @@ void HTMLMediaElement::onRotationChanged(uint64_t timeStamp, sensor_data_accurac
         return;
 
     int rotation = that->calcRotation(x, y, z);
-    if (rotation == ROTATE_ERROR || rotation == that->m_rotation)
+    if (rotation == ROTATE_ERROR || rotation == s_rotation)
         return;
 
-    that->m_rotation = rotation;
+    s_rotation = rotation;
 }
 #endif
 
@@ -4234,6 +4233,16 @@ void HTMLMediaElement::exitFullscreen()
     }
 }
 
+#if ENABLE(TIZEN_FULLSCREEN_API)
+void HTMLMediaElement::updateMediaControlsStyle()
+{
+    if (hasMediaControls())
+        mediaControls()->updateMediaControlScale();
+
+    recalcStyle(Node::Force);
+}
+#endif
+
 void HTMLMediaElement::didBecomeFullscreenElement()
 {
     if (hasMediaControls())
index f389887..6a2eecb 100755 (executable)
@@ -342,10 +342,12 @@ public:
 #endif
 
 #if ENABLE(TIZEN_DEVICE_ROTATION)
-    bool isHorizontal();
-    bool isVertical();
+    static bool isHorizontal();
+    static bool isVertical();
+#endif
 
-    int rotation() { return m_rotation; }
+#if ENABLE(TIZEN_FULLSCREEN_API)
+    void updateMediaControlsStyle();
 #endif
 
 protected:
@@ -728,7 +730,7 @@ private:
 #endif
 #if ENABLE(TIZEN_DEVICE_ROTATION)
     sensor_h m_handle;
-    int m_rotation;
+    static int s_rotation;
 #endif
 };
 
index 4643002..f488ca5 100644 (file)
 #include "TextTrackCue.h"
 #endif
 
+#if ENABLE(TIZEN_FULLSCREEN_API)
+#include "Settings.h"
+#endif
+
 using namespace std;
 
 namespace WebCore {
 
 static const double timeWithoutMouseMovementBeforeHidingControls = 3;
+#if ENABLE(TIZEN_FULLSCREEN_API)
+const IntSize compareResolution(720, 1280);
+#endif
 
 MediaControlRootElement::MediaControlRootElement(Document* document)
     : MediaControls(document)
@@ -508,6 +515,24 @@ void MediaControlRootElement::changedVolume()
         m_volumeSlider->setVolume(m_mediaController->volume());
 }
 
+#if ENABLE(TIZEN_FULLSCREEN_API)
+void MediaControlRootElement::updateMediaControlScale()
+{
+    if (!document()->page())
+        return;
+
+    double scaleFactor = 1 / document()->page()->chrome()->contentsScaleFactor();
+
+#if ENABLE(TIZEN_DEVICE_ROTATION)
+    Settings* settings = document()->settings();
+    if (settings && settings->deviceWidth() != compareResolution.width())
+        scaleFactor *= (settings->deviceWidth() / static_cast<double>(HTMLMediaElement::isHorizontal() ? compareResolution.height() : compareResolution.width()));
+#endif
+
+    m_panel->setInlineStyleProperty(CSSPropertyWebkitTransform, "scale(" + String::number(scaleFactor) + ", " + String::number(scaleFactor) + ")", false);
+}
+#endif
+
 void MediaControlRootElement::enteredFullscreen()
 {
     m_isFullscreen = true;
@@ -529,13 +554,11 @@ void MediaControlRootElement::enteredFullscreen()
 
     if (Page* page = document()->page()) {
         page->chrome()->setCursorHiddenUntilMouseMoves(true);
+    }
 
-#if ENABLE(TIZEN_GSTREAMER_VIDEO) && ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
-        float scaleFactor = page->chrome()->contentsScaleFactor();
-        if (scaleFactor > 0)
-            m_panel->setInlineStyleProperty(CSSPropertyZoom, 1 / scaleFactor, CSSPrimitiveValue::CSS_NUMBER);
+#if ENABLE(TIZEN_FULLSCREEN_API)
+    updateMediaControlScale();
 #endif
-    }
 
 #if !ENABLE(TIZEN_GSTREAMER_VIDEO)
     startHideFullscreenControlsTimer();
@@ -562,8 +585,8 @@ void MediaControlRootElement::exitedFullscreen()
     // And if we reenter fullscreen we also want the panel in the standard position.
     m_panel->resetPosition();
 
-#if ENABLE(TIZEN_GSTREAMER_VIDEO) && ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
-    m_panel->removeInlineStyleProperty(CSSPropertyZoom);
+#if ENABLE(TIZEN_FULLSCREEN_API)
+    m_panel->removeInlineStyleProperty(CSSPropertyWebkitTransform);
 #endif
 
 #if !ENABLE(TIZEN_GSTREAMER_VIDEO)
index 0f03d9c..260a10d 100644 (file)
@@ -94,6 +94,9 @@ public:
 
     void enteredFullscreen();
     void exitedFullscreen();
+#if ENABLE(TIZEN_FULLSCREEN_API)
+    void updateMediaControlScale();
+#endif
 
     void reportedError();
     void loadedMetadata();
index 28908a9..284f89f 100644 (file)
@@ -61,6 +61,9 @@ class MediaControls : public HTMLDivElement {
 
     virtual void enteredFullscreen() = 0;
     virtual void exitedFullscreen() = 0;
+#if ENABLE(TIZEN_FULLSCREEN_API)
+    virtual void updateMediaControlScale() = 0;
+#endif
 
     virtual void reportedError() = 0;
     virtual void loadedMetadata() = 0;
index 0364dda..730400d 100644 (file)
@@ -142,7 +142,9 @@ void WebFullScreenManager::didExitFullScreen()
 void WebFullScreenManager::updateMediaControlsStyle()
 {
     ASSERT(m_element);
-    m_element->recalcStyle(Node::Force);
+    HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(m_element.get());
+    if (mediaElement)
+        mediaElement->updateMediaControlsStyle();
 }
 #endif