Use EwkView's variables instead of drawingScaleFactor and drawingScrollPosition.
authorEunmi Lee <eunmi15.lee@samsung.com>
Thu, 21 Mar 2013 06:13:03 +0000 (15:13 +0900)
committerEunmi Lee <eunmi15.lee@samsung.com>
Tue, 26 Mar 2013 07:47:08 +0000 (16:47 +0900)
[Title] Use EwkView's variables instead of drawingScaleFactor and drawingScrollPosition.
[Issue#] N/A
[Problem] Refactoring.
[Cause] The drawing variables and EwkView's variables have same role.
        So, I've unified them to use only EwkView's variables.
[Solution] Remove drawingScaleFactor and drawingScrollPosition and refactoring codes.

Change-Id: I5f8105b486c0e1212f76877daed0535552c8b8e9

Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp
Source/WebKit2/UIProcess/API/efl/PageClientImpl.h

index c424c77..519bcdc 100644 (file)
@@ -91,8 +91,6 @@ PageClientImpl::PageClientImpl(WebContext* context, WebPageGroup* pageGroup, Eva
 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
     , m_visibleContentRect(IntRect())
     , m_scaleFactor(1.0f)
-    , m_drawingScrollPosition(IntPoint())
-    , m_drawingScaleFactor(1.0f)
     , m_hasSuspendedContent(false)
 #endif
 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
@@ -983,6 +981,17 @@ void PageClientImpl::updateFormNavigation(int length, int offset)
 }
 
 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
+// Before rendering, scale factor and scroll position is different from m_viewImpl.
+float PageClientImpl::scaleFactor()
+{
+    return m_pageDidRendered ? m_viewImpl->scaleFactor() : (m_restoredScaleFactor ? m_restoredScaleFactor : m_viewportConstraints.initialScale);
+}
+
+const IntPoint PageClientImpl::scrollPosition()
+{
+    return m_pageDidRendered ? m_viewImpl->scrollPosition() : (m_restoredScaleFactor ? m_restoredScrollPosition : IntPoint());
+}
+
 IntRect PageClientImpl::adjustVisibleContentRect(IntRect visibleContentRect, float targetScale)
 {
     IntSize contentsSize = page()->contentsSize();
@@ -1012,8 +1021,16 @@ void PageClientImpl::setVisibleContentRect(const IntRect& newRect, float newScal
 
     // update both drawing scale factor and scroll position after page is rendered
     if (m_pageDidRendered) {
-        m_drawingScaleFactor = m_scaleFactor;
-        m_drawingScrollPosition = m_visibleContentRect.location();
+        if (!m_hasSuspendedContent) {
+            // FIXME: We have to update EwkViewImpl's scale and position here because we use them to draw contents.
+            // PageViewport's values are updated when resuming content in the webkit opensource,
+            // but we have to update viewImpl's values here to sync with PageClient's values.
+            // However, We should not update them when hasSuspendedContent is true in order to maintain last values.
+            // The values will be updated when resuming content.
+            // Below codes should be refactored when PageViewportController codes are merged into Tizen.
+            m_viewImpl->setScaleFactor(m_scaleFactor);
+            m_viewImpl->setScrollPosition(m_visibleContentRect.location());
+        }
     }
 
     // enclosingIntRect produces inconsistent width and height when scale factor is not 1.
@@ -1024,7 +1041,7 @@ void PageClientImpl::setVisibleContentRect(const IntRect& newRect, float newScal
                                                       ceilf(m_visibleContentRect.height() / m_scaleFactor));
     if (!drawingArea())
         return;
-    drawingArea()->setVisibleContentsRect(mapToContentsVisibleContentRect, newScale, trajectory, FloatPoint(m_drawingScrollPosition));
+    drawingArea()->setVisibleContentsRect(mapToContentsVisibleContentRect, newScale, trajectory, FloatPoint(m_viewImpl->scrollPosition()));
 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
     // FIXME: We need to calculate exact visibleRect size here instead of mapToContentsVisibleContentRect.
     drawingArea()->setVisibleContentsRectForScrollingContentsLayers(mapToContentsVisibleContentRect);
@@ -1062,17 +1079,6 @@ void PageClientImpl::drawContents()
 
 void PageClientImpl::drawContents(BackingStore::PlatformGraphicsContext context)
 {
-    if (!m_hasSuspendedContent) {
-        // FIXME: We have to update EwkViewImpl's scale and position here because we use them to draw contents.
-        // PageViewport's values are updated when resuming content in the webkit opensource,
-        // but we have to update viewImpl's values here to sync with PageClient's values.
-        // However, We should not update them when hasSuspendedContent is true in order to maintain last values.
-        // The values will be updated when resuming content.
-        // Below codes should be refactored when PageViewportController codes are merged into Tizen.
-        m_viewImpl->setScaleFactor(m_drawingScaleFactor);
-        m_viewImpl->setScrollPosition(m_drawingScrollPosition);
-    }
-
     cairo_save(context);
     const cairo_matrix_t matrix = cairo_matrix_t(m_viewImpl->transformToView());
     cairo_transform(context, &matrix);
@@ -1135,17 +1141,14 @@ void PageClientImpl::suspendContent()
 
 void PageClientImpl::resumeContent()
 {
-    // FIXME: Update viewImpl's values after resuming content.
-    // Actually PageViewport's values are updated when resuming content in the webkit opensource,
-    // but we have to update viewImpl's values here(Tizen) to sync with PageClient's values.
-    // The concept is that the values of EwkViewImpl and PageClient can be different during suspending
-    // content and they become same when content is resumed.
-    m_viewImpl->setScaleFactor(m_drawingScaleFactor);
-    m_viewImpl->setScrollPosition(m_drawingScrollPosition);
-
     if (!m_hasSuspendedContent)
         return;
 
+    // FIXME: Update visibleContentRect with m_viewImpl after resuming content.
+    // The concept is that the values of EwkViewImpl and PageClient can be different
+    // during suspending content and they become same when content is resumed.
+    // Below codes should be refactored when PageViewportController codes are merged into Tizen.
+    setVisibleContentRect(IntRect(m_viewImpl->scrollPosition(), m_visibleContentRect.size()), m_viewImpl->scaleFactor());
     m_hasSuspendedContent = false;
 }
 
@@ -1200,11 +1203,11 @@ void PageClientImpl::updateScrollbar()
 
     if (m_horizontalScrollbar) {
         m_horizontalScrollbar->setProportion(viewSize().width(), scaledContentsSize.width());
-        m_horizontalScrollbar->setPosition(m_drawingScrollPosition.x());
+        m_horizontalScrollbar->setPosition(m_viewImpl->scrollPosition().x());
     }
     if (m_verticalScrollbar) {
         m_verticalScrollbar->setProportion(viewSize().height(), scaledContentsSize.height());
-        m_verticalScrollbar->setPosition(m_drawingScrollPosition.y());
+        m_verticalScrollbar->setPosition(m_viewImpl->scrollPosition().y());
     }
 }
 
@@ -1677,17 +1680,6 @@ void PageClientEvasGL::drawContents()
     IntRect clipRect;
     IntSize ewkViewSize = viewSize();
 
-    if (!m_hasSuspendedContent) {
-        // FIXME: We have to update EwkViewImpl's scale and position here because we use them to draw contents.
-        // PageViewport's values are updated when resuming content in the webkit opensource,
-        // but we have to update viewImpl's values here to sync with PageClient's values.
-        // However, We should not update them when hasSuspendedContent is true in order to maintain last values.
-        // The values will be updated when resuming content.
-        // Below codes should be refactored when PageViewportController codes are merged into Tizen.
-        m_viewImpl->setScaleFactor(m_drawingScaleFactor);
-        m_viewImpl->setScrollPosition(m_drawingScrollPosition);
-    }
-
 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
     Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewWidget));
     m_angle = ecore_evas_rotation_get(ee);
index bc6e456..d17e6bb 100644 (file)
@@ -143,9 +143,8 @@ public:
 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
     DrawingAreaProxy* drawingArea() const { return m_page->drawingArea(); }
 #endif
-    // Before rendering, scale factor and scroll position is different from m_drawingScaleFactor and m_drawingScrollPosition
-    float scaleFactor() { return m_pageDidRendered ? m_drawingScaleFactor : (m_restoredScaleFactor ? m_restoredScaleFactor : m_viewportConstraints.initialScale); }
-    WebCore::IntPoint scrollPosition() { return m_pageDidRendered ? m_drawingScrollPosition : (m_restoredScaleFactor ? m_restoredScrollPosition : WebCore::IntPoint()); }
+    float scaleFactor();
+    const WebCore::IntPoint scrollPosition();
     WebCore::IntRect adjustVisibleContentRect(WebCore::IntRect, float);
     void setVisibleContentRect(const WebCore::IntRect&, float newScale, const WebCore::FloatPoint& trajectory = WebCore::FloatPoint());
     TIZEN_VIRTUAL void displayViewport();
@@ -407,10 +406,6 @@ protected:
     WebCore::IntRect m_visibleContentRect;
     float m_scaleFactor;
 
-    // below drawing values should be updated after page did rendered
-    WebCore::IntPoint m_drawingScrollPosition;
-    float m_drawingScaleFactor;
-
     // FIXME: The concept of suspending content comes from webkit opensource's PageViewportController,
     // so below code should be replaced when PageViewportController codes are merged.
     // Please do not use below codes. They are only for scaling contents.