Fix zoom issue when enter fullscreen from media element
authorSeonae Kim <sunaeluv.kim@samsung.com>
Wed, 10 Apr 2013 05:26:34 +0000 (14:26 +0900)
committerGerrit Code Review <gerrit2@kim11>
Thu, 11 Apr 2013 12:49:18 +0000 (21:49 +0900)
[Title] Fix zoom issue when enter fullscreen from media element
[Issue] N/A
[Problem] In case of first enterance, media controls is bigger than the second case.
[Cause] A scale factor of content is used.
[Solution] Change a calculated scale factor from content to viewport

Change-Id: I41b381cfe4ed3cffc723942ba1d8b4be1d65f8c9

Source/WebCore/html/shadow/MediaControlElements.cpp
Source/WebCore/html/shadow/MediaControlRootElement.cpp
Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp
Source/WebKit2/UIProcess/API/efl/PageClientImpl.h
Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp
Source/WebKit2/UIProcess/WebFullScreenManagerProxy.h
Source/WebKit2/UIProcess/WebFullScreenManagerProxy.messages.in
Source/WebKit2/UIProcess/efl/WebFullScreenManagerProxyEfl.cpp
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.cpp
Source/cmake/OptionsTizen.cmake
Source/cmakeconfig.h.cmake

index 896e21d..937ba66 100644 (file)
@@ -1098,11 +1098,6 @@ void MediaControlFullscreenButtonElement::defaultEventHandler(Event* event)
             if (document()->webkitIsFullScreen() && document()->webkitCurrentFullScreenElement() == toParentMediaElement(this))
                 document()->webkitCancelFullScreen();
             else {
-#if ENABLE(TIZEN_GSTREAMER_VIDEO)
-                // Scale content with minimum scale value to show control elements properly.
-                FrameView* frameView = document()->frame()->view();
-                frameView->requestVisibleContentRectRestore(IntPoint(), 0.0);
-#endif
                 document()->requestFullScreenForElement(toParentMediaElement(this), 0, Document::ExemptIFrameAllowFullScreenRequirement);
             }
         } else
index 7ebc452..1f7df22 100644 (file)
@@ -523,12 +523,6 @@ 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);
-#endif
     }
 
 #if !ENABLE(TIZEN_GSTREAMER_VIDEO)
@@ -556,10 +550,6 @@ 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);
-#endif
-
 #if !ENABLE(TIZEN_GSTREAMER_VIDEO)
     stopHideFullscreenControlsTimer();
 #endif
index 31ed791..063a472 100755 (executable)
@@ -229,6 +229,11 @@ double PageClientImpl::availableMinimumScale()
     // recalculate minimum scale factor if contents' width exceeds viewport layout width and userScalable is true.
     // minimum scale factor shouldn't be smaller than 0.25(minimum zoom level)
     IntSize contentsSize = m_viewImpl->page()->contentsSize();
+#if ENABLE(TIZEN_FULLSCREEN_API)
+    if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
+        contentsSize = viewSize();
+#endif
+
     double horizontalMinScale = max(((double)viewSize().width() / contentsSize.width()), 0.25);
     double verticalMinScale = max(((double)viewSize().height() / contentsSize.height()), 0.25);
     return min(max(horizontalMinScale, verticalMinScale), m_viewportConstraints.maximumScale);
index 8086a86..1dceceb 100755 (executable)
@@ -107,6 +107,9 @@ public:
     };
 
     ViewportConstraints viewportConstraints() { return m_viewportConstraints; }
+#if ENABLE(TIZEN_FULLSCREEN_API)
+    void setMinimumScale(double minimumScale) { m_viewportConstraints.minimumScale = minimumScale; }
+#endif
     ViewportConstraints computeViewportConstraints(const WebCore::ViewportAttributes&);
     double adjustScaleWithViewport(double);
 #if USE(TILED_BACKING_STORE) && ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
index ce8814e..0ff6002 100755 (executable)
@@ -315,7 +315,12 @@ void DrawingAreaProxyImpl::sendUpdateBackingStoreState(RespondImmediatelyOrNot r
 
     m_isWaitingForDidUpdateBackingStoreState = respondImmediatelyOrNot == RespondImmediately;
 
+#if ENABLE(TIZEN_FULLSCREEN_API)
+    float scaleFactor = (m_webPageProxy->fullScreenManager()->isFullScreen()) ? 1.0f : m_webPageProxy->deviceScaleFactor();
+    m_webPageProxy->process()->send(Messages::DrawingArea::UpdateBackingStoreState(m_nextBackingStoreStateID, respondImmediatelyOrNot == RespondImmediately, scaleFactor, m_size, m_scrollOffset), m_webPageProxy->pageID());
+#else
     m_webPageProxy->process()->send(Messages::DrawingArea::UpdateBackingStoreState(m_nextBackingStoreStateID, respondImmediatelyOrNot == RespondImmediately, m_webPageProxy->deviceScaleFactor(), m_size, m_scrollOffset), m_webPageProxy->pageID());
+#endif
     m_scrollOffset = IntSize();
 
     if (m_isWaitingForDidUpdateBackingStoreState) {
index ba7572f..a858c05 100644 (file)
@@ -95,12 +95,20 @@ private:
     void supportsFullScreen(bool withKeyboard, bool&);
     void enterFullScreen();
     void exitFullScreen();
+#if ENABLE(TIZEN_FULLSCREEN_API)
+    void enterFullScreenForMediaElement();
+    void exitFullScreenForMediaElement();
+#endif
     void beganEnterFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame);
     void beganExitFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame);
 
     WebPageProxy* m_page;
     PlatformWebView* m_webView;
     bool m_isFullScreen;
+#if ENABLE(TIZEN_FULLSCREEN_API)
+    double m_previousMinimumScale;
+    float m_previousScaleFactor;
+#endif
 
     void didReceiveWebFullScreenManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
     void didReceiveSyncWebFullScreenManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::ArgumentEncoder>& reply);
index 97e4613..8ecf0b9 100644 (file)
@@ -25,6 +25,10 @@ messages -> WebFullScreenManagerProxy {
     SupportsFullScreen(bool withKeyboard) -> (bool supportsFullScreen)
     EnterFullScreen()
     ExitFullScreen()
+#if ENABLE(TIZEN_FULLSCREEN_API)
+    EnterFullScreenForMediaElement()
+    ExitFullScreenForMediaElement()
+#endif
     BeganEnterFullScreen(WebCore::IntRect initialRect, WebCore::IntRect finalRect)
     BeganExitFullScreen(WebCore::IntRect initialRect, WebCore::IntRect finalRect)
     Close()
index e744331..28b0845 100755 (executable)
@@ -80,6 +80,39 @@ void WebFullScreenManagerProxy::exitFullScreen()
     m_isFullScreen = false;
 }
 
+#if ENABLE(TIZEN_FULLSCREEN_API)
+void WebFullScreenManagerProxy::enterFullScreenForMediaElement()
+{
+    if (!m_webView)
+        return;
+
+    EwkViewImpl* viewImpl = EwkViewImpl::fromEvasObject(m_webView);
+    PageClientImpl* pageClientImpl = viewImpl->pageClient.get();
+
+    m_previousMinimumScale = pageClientImpl->viewportConstraints().minimumScale;
+    m_previousScaleFactor = viewImpl->scaleFactor();
+
+    pageClientImpl->setMinimumScale(1.0);
+    viewImpl->setScaleFactor(1.0f);
+
+    enterFullScreen();
+}
+
+void WebFullScreenManagerProxy::exitFullScreenForMediaElement()
+{
+    if (!m_webView)
+        return;
+
+    EwkViewImpl* viewImpl = EwkViewImpl::fromEvasObject(m_webView);
+    PageClientImpl* pageClientImpl = viewImpl->pageClient.get();
+
+    pageClientImpl->setMinimumScale(m_previousMinimumScale);
+    viewImpl->setScaleFactor(m_previousScaleFactor);
+
+    exitFullScreen();
+}
+#endif
+
 void WebFullScreenManagerProxy::beganEnterFullScreen(const IntRect& initialFrame, const IntRect& finalFrame)
 {
     notImplemented();
index 96b9a18..af2e28d 100644 (file)
@@ -57,6 +57,10 @@ void InjectedBundlePageFullScreenClient::enterFullScreenForElement(WebPage *page
     if (m_client.enterFullScreenForElement) {
         RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::getOrCreate(element);
         m_client.enterFullScreenForElement(toAPI(page), toAPI(nodeHandle.get()));
+#if ENABLE(TIZEN_FULLSCREEN_API)
+    } else if (element->isMediaElement()) {
+        page->send(Messages::WebFullScreenManagerProxy::EnterFullScreenForMediaElement());
+#endif
     } else
         page->send(Messages::WebFullScreenManagerProxy::EnterFullScreen());
 }
@@ -66,6 +70,10 @@ void InjectedBundlePageFullScreenClient::exitFullScreenForElement(WebPage *page,
     if (m_client.exitFullScreenForElement) {
         RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::getOrCreate(element);
         m_client.exitFullScreenForElement(toAPI(page), toAPI(nodeHandle.get()));
+#if ENABLE(TIZEN_FULLSCREEN_API)
+    } else if (element->isMediaElement()) {
+        page->send(Messages::WebFullScreenManagerProxy::ExitFullScreenForMediaElement());
+#endif
     } else
         page->send(Messages::WebFullScreenManagerProxy::ExitFullScreen());
 }
index 5f2821e..db205aa 100644 (file)
@@ -95,6 +95,7 @@ WEBKIT_OPTION_DEFINE(ENABLE_TIZEN_CSS_ALIASES "Enable Specifying CSS Property Al
 WEBKIT_OPTION_DEFINE(ENABLE_TIZEN_CSS3_TEXT "Enable CSS3 TEXT" ON)
 WEBKIT_OPTION_DEFINE(ENABLE_TIZEN_DBSPACE_PATH "Enable Tizen application's  directory path" ON)
 WEBKIT_OPTION_DEFINE(ENABLE_TIZEN_EXTENSIBLE_API "Enable Tizen extensible api" ON)
+WEBKIT_OPTION_DEFINE(ENABLE_TIZEN_FULLSCREEN_API "Enable Tizen fullscreen api" ON)
 WEBKIT_OPTION_DEFINE(ENABLE_TIZEN_GC_ACTIVITY_CALLBACK "Use GC Activity Callback" ON)
 WEBKIT_OPTION_DEFINE(ENABLE_TIZEN_INTERNATIONAL_TEXT_SUPPORT "Enable International text support for tizen webkit" ON)
 WEBKIT_OPTION_DEFINE(ENABLE_TIZEN_KEYGEN "Enable Tizen WebKit2 feature" ON)
index b5955e9..6161cfb 100644 (file)
 #cmakedefine01 ENABLE_TIZEN_CSS_ALIASES
 #cmakedefine01 ENABLE_TIZEN_CSS3_TEXT
 #cmakedefine01 ENABLE_TIZEN_EXTENSIBLE_API
+#cmakedefine01 ENABLE_TIZEN_FULLSCREEN_API
 #cmakedefine01 ENABLE_TIZEN_INTERNATIONAL_TEXT_SUPPORT
 #cmakedefine01 ENABLE_TIZEN_REGISTER_CONTENT_HANDLER
 #cmakedefine01 ENABLE_TIZEN_RESET_PATH