[CoordinatedGraphics] Regressions in WebView's contentScaleFactor/contentPosition
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Dec 2013 16:30:51 +0000 (16:30 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Dec 2013 16:30:51 +0000 (16:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=125943

Patch by Nick Diego Yamane <nick.yamane@openbossa.org> on 2013-12-19
Reviewed by Noam Rosenthal.

When WebView::pageDidRequestScroll is called it is scaling position requested
to scroll before store it as contentPosition, that is not necessary since WebView
already stores the requested contentScaleFactor so it's able to do that internally
when needed, what simplifies the API and improves the readability of webview's code.
This patch reverts changes from https://bugs.webkit.org/show_bug.cgi?id=118548, which
was causing some regressions in contentScaleFactor/contentPosition related stuff.
Besides that WebView::pageDidRequestScroll calls viewClient callback with the wrong
position (different from the position stored in WebView).

* UIProcess/API/efl/EwkView.cpp:
(EwkView::scrollBy):
* UIProcess/CoordinatedGraphics/WebView.cpp:
(WebKit::WebView::transformToScene):
(WebKit::WebView::updateViewportSize):
(WebKit::WebView::pageDidRequestScroll):
* UIProcess/efl/PageViewportControllerClientEfl.cpp:
(WebKit::PageViewportControllerClientEfl::setViewportPosition):

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/efl/EwkView.cpp
Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.cpp
Source/WebKit2/UIProcess/efl/PageViewportControllerClientEfl.cpp

index 57dd353..4d8eed5 100644 (file)
@@ -1,3 +1,27 @@
+2013-12-19  Nick Diego Yamane  <nick.yamane@openbossa.org>
+
+        [CoordinatedGraphics] Regressions in WebView's contentScaleFactor/contentPosition
+        https://bugs.webkit.org/show_bug.cgi?id=125943
+
+        Reviewed by Noam Rosenthal.
+
+        When WebView::pageDidRequestScroll is called it is scaling position requested
+        to scroll before store it as contentPosition, that is not necessary since WebView
+        already stores the requested contentScaleFactor so it's able to do that internally
+        when needed, what simplifies the API and improves the readability of webview's code.
+        This patch reverts changes from https://bugs.webkit.org/show_bug.cgi?id=118548, which
+        was causing some regressions in contentScaleFactor/contentPosition related stuff.
+        Besides that WebView::pageDidRequestScroll calls viewClient callback with the wrong
+        position (different from the position stored in WebView).
+
+        * UIProcess/API/efl/EwkView.cpp:
+        (EwkView::scrollBy):
+        * UIProcess/CoordinatedGraphics/WebView.cpp:
+        (WebKit::WebView::transformToScene):
+        (WebKit::WebView::updateViewportSize):
+        (WebKit::WebView::pageDidRequestScroll):
+        * UIProcess/efl/PageViewportControllerClientEfl.cpp:
+        (WebKit::PageViewportControllerClientEfl::setViewportPosition):
 2013-12-18  Tim Horton  <timothy_horton@apple.com>
 
         WebKit2 View Gestures: Move WebProcess-side geometry collection into its own class
index c34bd57..57ae3a7 100644 (file)
@@ -1396,16 +1396,16 @@ void EwkView::didFindZoomableArea(const WKPoint& point, const WKRect& area)
 bool EwkView::scrollBy(const IntSize& offset)
 {
     WKPoint oldPosition = WKViewGetContentPosition(wkView());
-    FloatPoint newPosition(oldPosition.x + offset.width(), oldPosition.y + offset.height());
+    float contentScale = WKViewGetContentScaleFactor(wkView());
+
+    FloatPoint newPosition(oldPosition.x + offset.width() / contentScale, oldPosition.y + offset.height() / contentScale);
 
     // Update new position to the PageViewportController.
-    float contentScale = WKViewGetContentScaleFactor(wkView());
-    newPosition.scale(1 / contentScale, 1 / contentScale);
     newPosition = m_pageViewportController.boundContentsPositionAtScale(newPosition, contentScale);
     m_pageViewportController.didChangeContentsVisibility(newPosition, contentScale);
 
     // Update new position to the WKView.
-    WKPoint position = WKPointMake(newPosition.x() * contentScale, newPosition.y() * contentScale);
+    WKPoint position = WKPointMake(newPosition.x(), newPosition.y());
     WKViewSetContentPosition(wkView(), position);
 
     // If the page position has not changed, notify the caller using the return value.
index 386f76f..100fa39 100644 (file)
@@ -239,7 +239,7 @@ AffineTransform WebView::transformToScene() const
 {
     FloatPoint position = -m_contentPosition;
     float effectiveScale = m_contentScaleFactor * m_page->deviceScaleFactor();
-    position.scale(m_page->deviceScaleFactor(), m_page->deviceScaleFactor());
+    position.scale(effectiveScale, effectiveScale);
 
     TransformationMatrix transform = m_userViewportTransform;
     transform.translate(position.x(), position.y());
@@ -261,9 +261,7 @@ void WebView::updateViewportSize()
     if (CoordinatedDrawingAreaProxy* drawingArea = static_cast<CoordinatedDrawingAreaProxy*>(page()->drawingArea())) {
         // Web Process expects sizes in UI units, and not raw device units.
         drawingArea->setSize(roundedIntSize(dipSize()), IntSize(), IntSize());
-        FloatPoint position = contentPosition();
-        position.scale(1 / m_contentScaleFactor, 1 / m_contentScaleFactor);
-        FloatRect visibleContentsRect(position, visibleContentsSize());
+        FloatRect visibleContentsRect(contentPosition(), visibleContentsSize());
         visibleContentsRect.intersect(FloatRect(FloatPoint(), contentsSize()));
         drawingArea->setVisibleContentsRect(visibleContentsRect, FloatPoint());
     }
@@ -515,7 +513,6 @@ void WebView::didChangeViewportProperties(const WebCore::ViewportAttributes& att
 void WebView::pageDidRequestScroll(const IntPoint& position)
 {
     FloatPoint uiPosition(position);
-    uiPosition.scale(contentScaleFactor(), contentScaleFactor());
     setContentPosition(uiPosition);
 
     m_client.didChangeContentsPosition(this, position);
index 22a45b5..b2a6772 100644 (file)
@@ -53,10 +53,8 @@ void PageViewportControllerClientEfl::setViewportPosition(const WebCore::FloatPo
 {
     m_contentPosition = contentsPoint;
 
-    FloatPoint pos(contentsPoint);
     float scaleFactor = WKViewGetContentScaleFactor(m_view->wkView());
-    pos.scale(scaleFactor, scaleFactor);
-    WKViewSetContentPosition(m_view->wkView(), WKPointMake(pos.x(), pos.y()));
+    WKViewSetContentPosition(m_view->wkView(), WKPointMake(contentsPoint.x(), contentsPoint.y()));
 
     m_controller->didChangeContentsVisibility(m_contentPosition, scaleFactor);
 }