[EFL][WK2] Convert from device view size to UI view size only in EwkView.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Mar 2013 09:35:21 +0000 (09:35 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Mar 2013 09:35:21 +0000 (09:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=110197

Patch by Huang Dongsung <luxtella@company100.net> on 2013-03-06
Reviewed by Kenneth Rohde Christiansen.

Signed off for WebKit2 by Benjamin Poulain.

Device scale factor is a property of the physical display, so only EwkView
should deal with converting device view size to UI (a.k.a Density Independent Pixel)
view size. It increases readability because we can regard a view size in
other classes (e.g. WebView, PageViewportController, WebPage) except for
EwkView as UI size.

* UIProcess/API/efl/EwkView.cpp:
(EwkView::setDeviceScaleFactor):
(EwkView::setDeviceSize):
(EwkView::size):
(EwkView::deviceSize):
(EwkView::scheduleUpdateDisplay):
(EwkView::createGLSurface):
(EwkView::handleEvasObjectCalculate):
* UIProcess/API/efl/EwkView.h:
(EwkView):
* UIProcess/efl/WebView.cpp:
(WebKit::WebView::paintToCurrentGLContext):
(WebKit::WebView::updateViewportSize):

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

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

index 28b1f8e..efe2f17 100644 (file)
@@ -1,3 +1,32 @@
+2013-03-06  Huang Dongsung  <luxtella@company100.net>
+
+        [EFL][WK2] Convert from device view size to UI view size only in EwkView.
+        https://bugs.webkit.org/show_bug.cgi?id=110197
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Signed off for WebKit2 by Benjamin Poulain.
+
+        Device scale factor is a property of the physical display, so only EwkView
+        should deal with converting device view size to UI (a.k.a Density Independent Pixel)
+        view size. It increases readability because we can regard a view size in
+        other classes (e.g. WebView, PageViewportController, WebPage) except for
+        EwkView as UI size.
+
+        * UIProcess/API/efl/EwkView.cpp:
+        (EwkView::setDeviceScaleFactor):
+        (EwkView::setDeviceSize):
+        (EwkView::size):
+        (EwkView::deviceSize):
+        (EwkView::scheduleUpdateDisplay):
+        (EwkView::createGLSurface):
+        (EwkView::handleEvasObjectCalculate):
+        * UIProcess/API/efl/EwkView.h:
+        (EwkView):
+        * UIProcess/efl/WebView.cpp:
+        (WebKit::WebView::paintToCurrentGLContext):
+        (WebKit::WebView::updateViewportSize):
+
 2013-03-06  Christophe Dumez  <ch.dumez@sisa.samsung.com>
 
         [EFL][WK2] Use Vector::reserveInitialCapacity() in WebEventFactory::createWebTouchEvent()
index 7a3cadc..b52c52e 100644 (file)
@@ -458,7 +458,7 @@ void EwkView::setDeviceScaleFactor(float scale)
     page()->setIntrinsicDeviceScaleFactor(scale);
 
     // Update internal viewport size after device-scale change.
-    setSize(m_size);
+    setDeviceSize(deviceSize());
 }
 
 float EwkView::deviceScaleFactor() const
@@ -466,21 +466,31 @@ float EwkView::deviceScaleFactor() const
     return WKPageGetBackingScaleFactor(wkPage());
 }
 
-void EwkView::setSize(const IntSize& size)
+void EwkView::setDeviceSize(const IntSize& deviceSize)
 {
-    m_size = size;
+    m_deviceSize = deviceSize;
 
     DrawingAreaProxy* drawingArea = page()->drawingArea();
     if (!drawingArea)
         return;
 
-    FloatSize dipSize(m_size);
-    // Web Process expects sizes in UI units, and not raw device units.
-    dipSize.scale(1 / deviceScaleFactor());
-    drawingArea->setSize(roundedIntSize(dipSize), IntSize());
+    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;
@@ -551,7 +561,7 @@ void EwkView::displayTimerFired(Timer<EwkView>*)
 
 void EwkView::scheduleUpdateDisplay()
 {
-    if (size().isEmpty())
+    if (m_deviceSize.isEmpty())
         return;
 
     if (!m_displayTimer.isActive())
@@ -749,7 +759,7 @@ bool EwkView::createGLSurface()
     };
 
     // Recreate to current size: Replaces if non-null, and frees existing surface after (OwnPtr).
-    m_evasGLSurface = EvasGLSurface::create(m_evasGL.get(), &evasGLConfig, size());
+    m_evasGLSurface = EvasGLSurface::create(m_evasGL.get(), &evasGLConfig, deviceSize());
     if (!m_evasGLSurface)
         return false;
 
@@ -761,7 +771,7 @@ bool EwkView::createGLSurface()
 
     Evas_GL_API* gl = evas_gl_api_get(m_evasGL.get());
 
-    const WKPoint& boundsEnd = WKViewUserViewportToContents(wkView(), WKPointMake(size().width(), size().height()));
+    const WKPoint& boundsEnd = WKViewUserViewportToContents(wkView(), WKPointMake(deviceSize().width(), deviceSize().height()));
     gl->glViewport(0, 0, boundsEnd.x, boundsEnd.y);
     gl->glClearColor(1.0, 1.0, 1.0, 0);
     gl->glClear(GL_COLOR_BUFFER_BIT);
@@ -1111,7 +1121,7 @@ void EwkView::handleEvasObjectCalculate(Evas_Object* evasObject)
         smartData->view.w = width;
         smartData->view.h = height;
 
-        self->setSize(IntSize(width, height));
+        self->setDeviceSize(IntSize(width, height));
         self->setNeedsSurfaceResize();
     }
 }
index 71dad2d..2cc6e27 100644 (file)
@@ -131,8 +131,8 @@ public:
     void setDeviceScaleFactor(float scale);
     float deviceScaleFactor() const;
 
-    void setSize(const WebCore::IntSize&);
-    WebCore::IntSize size() const { return m_size; }
+    WebCore::IntSize size() const;
+    WebCore::IntSize deviceSize() const;
 
     WebCore::AffineTransform transformToScreen() const;
 
@@ -216,6 +216,7 @@ private:
     EwkView(Evas_Object* evasObject, PassRefPtr<EwkContext> context, WKPageGroupRef pageGroup, ViewBehavior);
     ~EwkView();
 
+    void setDeviceSize(const WebCore::IntSize&);
     Ewk_View_Smart_Data* smartData() const;
 
     void displayTimerFired(WebCore::Timer<EwkView>*);
@@ -255,7 +256,7 @@ private:
     OwnPtr<Evas_GL> m_evasGL;
     OwnPtr<WebKit::EvasGLContext> m_evasGLContext;
     OwnPtr<WebKit::EvasGLSurface> m_evasGLSurface;
-    WebCore::IntSize m_size;
+    WebCore::IntSize m_deviceSize;
     WebCore::TransformationMatrix m_userViewportTransform;
     bool m_pendingSurfaceResize;
     RefPtr<WebKit::WebView> m_webView;
index 2973198..33fdb5d 100644 (file)
@@ -102,7 +102,7 @@ void WebView::paintToCurrentGLContext()
     // FIXME: We need to clean up this code as it is split over CoordGfx and Page.
     scene->setDrawsBackground(m_page->drawsBackground());
 
-    FloatRect viewport = m_userViewportTransform.mapRect(IntRect(IntPoint(), m_ewkView->size()));
+    FloatRect viewport = m_userViewportTransform.mapRect(IntRect(IntPoint(), m_ewkView->deviceSize()));
     scene->paintToCurrentGLContext(transformToScene().toTransformationMatrix(), /* opacity */ 1, viewport);
 }
 
@@ -196,14 +196,11 @@ void WebView::didCommitLoad()
 
 void WebView::updateViewportSize()
 {
-    FloatSize size = m_ewkView->size();
-    // The viewport controller expects sizes in UI units, and not raw device units.
-    size.scale(1 / m_page->deviceScaleFactor());
     if (m_page->useFixedLayout()) {
-        m_ewkView->pageViewportController()->didChangeViewportSize(size);
+        m_ewkView->pageViewportController()->didChangeViewportSize(m_ewkView->size());
         return;
     }
-    m_page->drawingArea()->setVisibleContentsRect(FloatRect(m_ewkView->pagePosition(), size), FloatPoint());
+    m_page->drawingArea()->setVisibleContentsRect(FloatRect(m_ewkView->pagePosition(), m_ewkView->size()), FloatPoint());
 }
 
 void WebView::didChangeContentsSize(const WebCore::IntSize& size)