[WK2][EFL] WebView should own view size
authormikhail.pozdnyakov@intel.com <mikhail.pozdnyakov@intel.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Apr 2013 10:47:46 +0000 (10:47 +0000)
committermikhail.pozdnyakov@intel.com <mikhail.pozdnyakov@intel.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Apr 2013 10:47:46 +0000 (10:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=110753

Reviewed by Andreas Kling.

WebView owns view size. WKViewGetSize and WKViewSetSize API
is exposed accordingly. Usage of EFL-specific ewkView inside
toolkit-agnostic WebView class is reduced.

* UIProcess/API/C/efl/WKView.cpp:
(WKViewGetSize):
(WKViewSetSize):
* UIProcess/API/C/efl/WKView.h:
* UIProcess/API/efl/EwkView.cpp:
(EwkView::setDeviceScaleFactor):
(EwkView::size):
(EwkView::deviceSize):
(EwkView::scheduleUpdateDisplay):
(EwkView::handleEvasObjectCalculate):
* UIProcess/API/efl/EwkView.h:
(EwkView):
* UIProcess/efl/WebView.cpp:
(WebKit::WebView::setSize):
(WebKit):
(WebKit::WebView::paintToCurrentGLContext):
(WebKit::WebView::updateViewportSize):
(WebKit::WebView::viewSize):
(WebKit::WebView::dipSize):
* UIProcess/efl/WebView.h:
(WebView):
(WebKit::WebView::size):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@147617 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/efl/WKView.cpp
Source/WebKit2/UIProcess/API/C/efl/WKView.h
Source/WebKit2/UIProcess/API/efl/EwkView.cpp
Source/WebKit2/UIProcess/API/efl/EwkView.h
Source/WebKit2/UIProcess/efl/WebView.cpp
Source/WebKit2/UIProcess/efl/WebView.h

index a030ccc..2c28e91 100644 (file)
@@ -1,3 +1,37 @@
+2013-04-04  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
+
+        [WK2][EFL] WebView should own view size
+        https://bugs.webkit.org/show_bug.cgi?id=110753
+
+        Reviewed by Andreas Kling.
+
+        WebView owns view size. WKViewGetSize and WKViewSetSize API
+        is exposed accordingly. Usage of EFL-specific ewkView inside
+        toolkit-agnostic WebView class is reduced.
+
+        * UIProcess/API/C/efl/WKView.cpp:
+        (WKViewGetSize):
+        (WKViewSetSize):
+        * UIProcess/API/C/efl/WKView.h:
+        * UIProcess/API/efl/EwkView.cpp:
+        (EwkView::setDeviceScaleFactor):
+        (EwkView::size):
+        (EwkView::deviceSize):
+        (EwkView::scheduleUpdateDisplay):
+        (EwkView::handleEvasObjectCalculate):
+        * UIProcess/API/efl/EwkView.h:
+        (EwkView):
+        * UIProcess/efl/WebView.cpp:
+        (WebKit::WebView::setSize):
+        (WebKit):
+        (WebKit::WebView::paintToCurrentGLContext):
+        (WebKit::WebView::updateViewportSize):
+        (WebKit::WebView::viewSize):
+        (WebKit::WebView::dipSize):
+        * UIProcess/efl/WebView.h:
+        (WebView):
+        (WebKit::WebView::size):
+
 2013-04-03  Anders Carlsson  <andersca@apple.com>
 
         Don't try to set the exception port for server connections
index 691f6a1..78766ce 100644 (file)
@@ -40,6 +40,16 @@ void WKViewInitialize(WKViewRef viewRef)
     toImpl(viewRef)->initialize();
 }
 
+WKSize WKViewGetSize(WKViewRef viewRef)
+{
+    return toAPI(toImpl(viewRef)->size());
+}
+
+void WKViewSetSize(WKViewRef viewRef, WKSize size)
+{
+    toImpl(viewRef)->setSize(toIntSize(size));
+}
+
 void WKViewSetViewClient(WKViewRef viewRef, const WKViewClient* client)
 {
     toImpl(viewRef)->initializeClient(client);
index ca34ba4..b534d34 100644 (file)
@@ -52,6 +52,10 @@ enum { kWKViewClientCurrentVersion = 0 };
 WK_EXPORT WKViewRef WKViewCreate(WKContextRef context, WKPageGroupRef pageGroup);
 
 WK_EXPORT void WKViewInitialize(WKViewRef);
+
+WK_EXPORT WKSize WKViewGetSize(WKViewRef);
+WK_EXPORT void WKViewSetSize(WKViewRef, WKSize size);
+
 WK_EXPORT void WKViewSetViewClient(WKViewRef, const WKViewClient*);
 
 WK_EXPORT void WKViewSetUserViewportTranslation(WKViewRef, double tx, double ty);
index 062a392..ca34aed 100644 (file)
@@ -465,10 +465,11 @@ void EwkView::setCursor(const Cursor& cursor)
 
 void EwkView::setDeviceScaleFactor(float scale)
 {
+    const WKSize& deviceSize = WKViewGetSize(wkView());
     page()->setIntrinsicDeviceScaleFactor(scale);
 
     // Update internal viewport size after device-scale change.
-    setDeviceSize(deviceSize());
+    WKViewSetSize(wkView(), deviceSize);
 }
 
 float EwkView::deviceScaleFactor() const
@@ -476,31 +477,6 @@ float EwkView::deviceScaleFactor() const
     return WKPageGetBackingScaleFactor(wkPage());
 }
 
-void EwkView::setDeviceSize(const IntSize& deviceSize)
-{
-    m_deviceSize = deviceSize;
-
-    DrawingAreaProxy* drawingArea = page()->drawingArea();
-    if (!drawingArea)
-        return;
-
-    drawingArea->setSize(size(), IntSize());
-    webView()->updateViewportSize();
-}
-
-IntSize EwkView::size() const
-{
-    // WebPage expects a size in UI units, and not raw device units.
-    FloatSize uiSize = m_deviceSize;
-    uiSize.scale(1 / deviceScaleFactor());
-    return roundedIntSize(uiSize);
-}
-
-IntSize EwkView::deviceSize() const
-{
-    return m_deviceSize;
-}
-
 AffineTransform EwkView::transformToScreen() const
 {
     AffineTransform transform;
@@ -539,6 +515,19 @@ inline Ewk_View_Smart_Data* EwkView::smartData() const
     return toSmartData(m_evasObject);
 }
 
+inline IntSize EwkView::size() const
+{
+    // WebPage expects a size in UI units, and not raw device units.
+    FloatSize uiSize = deviceSize();
+    uiSize.scale(1 / deviceScaleFactor());
+    return roundedIntSize(uiSize);
+}
+
+inline IntSize EwkView::deviceSize() const
+{
+    return toIntSize(WKViewGetSize(wkView()));
+}
+
 void EwkView::displayTimerFired(Timer<EwkView>*)
 {
     Ewk_View_Smart_Data* sd = smartData();
@@ -571,7 +560,7 @@ void EwkView::displayTimerFired(Timer<EwkView>*)
 
 void EwkView::scheduleUpdateDisplay()
 {
-    if (m_deviceSize.isEmpty())
+    if (deviceSize().isEmpty())
         return;
 
     if (!m_displayTimer.isActive())
@@ -1125,7 +1114,10 @@ void EwkView::handleEvasObjectCalculate(Evas_Object* evasObject)
         smartData->view.w = width;
         smartData->view.h = height;
 
-        self->setDeviceSize(IntSize(width, height));
+        WKViewSetSize(self->wkView(), WKSizeMake(width, height));
+        if (WKPageUseFixedLayout(self->wkPage()))
+            self->pageViewportController()->didChangeViewportSize(self->size());
+
         self->setNeedsSurfaceResize();
     }
 }
index 01ec548..26098aa 100644 (file)
@@ -125,9 +125,6 @@ public:
     void setDeviceScaleFactor(float scale);
     float deviceScaleFactor() const;
 
-    WebCore::IntSize size() const;
-    WebCore::IntSize deviceSize() const;
-
     WebCore::AffineTransform transformToScreen() const;
 
     const char* url() const { return m_url; }
@@ -212,6 +209,9 @@ private:
     void setDeviceSize(const WebCore::IntSize&);
     Ewk_View_Smart_Data* smartData() const;
 
+    WebCore::IntSize size() const;
+    WebCore::IntSize deviceSize() const;
+
     void displayTimerFired(WebCore::Timer<EwkView>*);
 
     // Evas_Smart_Class callback interface:
@@ -251,7 +251,6 @@ private:
     OwnPtr<Evas_GL> m_evasGL;
     OwnPtr<WebKit::EvasGLContext> m_evasGLContext;
     OwnPtr<WebKit::EvasGLSurface> m_evasGLSurface;
-    WebCore::IntSize m_deviceSize;
     WebCore::TransformationMatrix m_userViewportTransform;
     bool m_pendingSurfaceResize;
     OwnPtr<WebKit::PageLoadClientEfl> m_pageLoadClient;
index e5e80c2..b59d441 100644 (file)
@@ -95,6 +95,13 @@ void WebView::initialize()
         scene->setActive(true);
 }
 
+void WebView::setSize(const WebCore::IntSize& size)
+{
+    m_size = size;
+
+    updateViewportSize();
+}
+
 void WebView::setUserViewportTranslation(double tx, double ty)
 {
     m_userViewportTransform = TransformationMatrix().translate(tx, ty);
@@ -113,8 +120,8 @@ void WebView::paintToCurrentGLContext()
 
     // FIXME: We need to clean up this code as it is split over CoordGfx and Page.
     scene->setDrawsBackground(m_page->drawsBackground());
+    const FloatRect& viewport = m_userViewportTransform.mapRect(IntRect(IntPoint(), m_size));
 
-    FloatRect viewport = m_userViewportTransform.mapRect(IntRect(IntPoint(), m_ewkView->deviceSize()));
     scene->paintToCurrentGLContext(transformToScene().toTransformationMatrix(), /* opacity */ 1, viewport);
 }
 
@@ -206,17 +213,6 @@ void WebView::didCommitLoad()
     m_ewkView->scheduleUpdateDisplay();
 }
 
-void WebView::updateViewportSize()
-{
-    if (m_page->useFixedLayout()) {
-        m_ewkView->pageViewportController()->didChangeViewportSize(m_ewkView->size());
-        return;
-    }
-    FloatPoint uiPosition(m_ewkView->pagePosition());
-    uiPosition.scale(1 / m_ewkView->pageScaleFactor(), 1 / m_ewkView->pageScaleFactor());
-    m_page->drawingArea()->setVisibleContentsRect(FloatRect(uiPosition, m_ewkView->size()), FloatPoint());
-}
-
 void WebView::didChangeContentsSize(const WebCore::IntSize& size)
 {
     m_client.didChangeContentsSize(this, size);
@@ -252,6 +248,23 @@ CoordinatedGraphicsScene* WebView::coordinatedGraphicsScene()
     return layerTreeHostProxy->coordinatedGraphicsScene();
 }
 
+void WebView::updateViewportSize()
+{
+    if (DrawingAreaProxy* drawingArea = page()->drawingArea()) {
+        // Web Process expects sizes in UI units, and not raw device units.
+        drawingArea->setSize(roundedIntSize(dipSize()), IntSize());
+        drawingArea->setVisibleContentsRect(FloatRect(m_ewkView->pagePosition(), dipSize()), FloatPoint());
+    }
+}
+
+inline WebCore::FloatSize WebView::dipSize() const
+{
+    FloatSize dipSize(size());
+    dipSize.scale(1 / m_page->deviceScaleFactor());
+
+    return dipSize;
+}
+
 // Page Client
 
 PassOwnPtr<DrawingAreaProxy> WebView::createDrawingAreaProxy()
@@ -277,7 +290,7 @@ void WebView::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntS
 
 WebCore::IntSize WebView::viewSize()
 {
-    return m_ewkView->size();
+    return roundedIntSize(dipSize());
 }
 
 bool WebView::isViewWindowActive()
index 7816042..18a1897 100644 (file)
@@ -57,6 +57,9 @@ public:
 
     void initialize();
 
+    void setSize(const WebCore::IntSize&);
+    const WebCore::IntSize& size() const { return m_size; }
+
     void setUserViewportTranslation(double tx, double ty);
     WebCore::IntPoint userViewportToContents(const WebCore::IntPoint&) const;
 
@@ -89,8 +92,7 @@ public:
     Evas_Object* evasObject();
     WebPageProxy* page() { return m_page.get(); }
 
-    void didCommitLoad();
-    void updateViewportSize();
+    void didCommitLoad();    
     void didChangeContentsSize(const WebCore::IntSize&);
 
     // FIXME: Should become private when Web Events creation is moved to WebView.
@@ -101,6 +103,8 @@ private:
     WebView(WebContext*, WebPageGroup*);
     WebCore::CoordinatedGraphicsScene* coordinatedGraphicsScene();
 
+    void updateViewportSize();
+    WebCore::FloatSize dipSize() const;
     // PageClient
     PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy() OVERRIDE;
 
@@ -180,6 +184,7 @@ private:
     RefPtr<WebPageProxy> m_page;
     DefaultUndoController m_undoController;
     WebCore::TransformationMatrix m_userViewportTransform;
+    WebCore::IntSize m_size; // Size in device units.
 };
 
 }