Enable auto fitting setting value initially
authorChanghyup Jwa <ch.jwa@samsung.com>
Wed, 5 Jun 2013 09:31:09 +0000 (18:31 +0900)
committerGerrit Code Review <gerrit2@kim11>
Wed, 12 Jun 2013 11:26:01 +0000 (20:26 +0900)
[Title] Enable auto fitting setting value initially
[Issue#] N/A (OSP WebViewer issue report)
[Problem] No way to disable scroll bar right after ewk_view_add()
[Cause] Initially auto fitting is disabled. Plus, disabling this is impossible
        because setting cannot be changed before ewk_view_add()
[Solution] Initially enable auto fitting setting value

Change-Id: I851864a48a71633d4bd52b2471926962c96541e5

Source/WebKit2/Shared/WebPreferencesStore.h
Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp
Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp

index c6a6600..4bdd4e5 100755 (executable)
@@ -211,6 +211,7 @@ namespace WebKit {
     macro(TextZoomEnabled, textZoomEnabled, Bool, bool, false) \
     macro(StyleScopedEnabled, styleScopedEnabled, Bool, bool, true) \
     macro(LinkMagnifierEnabled, linkMagnifierEnabled, Bool, bool, false) \
+    macro(AutoFittingEnabled, autoFittingEnabled, Bool, bool, true) \
     \
 
 #else
@@ -226,6 +227,7 @@ namespace WebKit {
     macro(TextZoomEnabled, textZoomEnabled, Bool, bool, false) \
     macro(StyleScopedEnabled, styleScopedEnabled, Bool, bool, true) \
     macro(LinkMagnifierEnabled, linkMagnifierEnabled, Bool, bool, false) \
+    macro(AutoFittingEnabled, autoFittingEnabled, Bool, bool, true) \
     \
 
 #endif
index ad113e8..4592938 100755 (executable)
@@ -94,7 +94,7 @@ PageClientImpl::PageClientImpl(EwkViewImpl* viewImpl)
     , m_viewportFitsToContent(false)
 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
     , m_visibleContentRect(IntRect())
-    , m_scaleFactor(1.0f)
+    , m_scaleFactor(0)
     , m_hasSuspendedContent(false)
 #endif
 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
@@ -159,23 +159,20 @@ PageClientImpl::ViewportConstraints PageClientImpl::computeViewportConstraints(c
     constraints.layoutSize = attributes.layoutSize;
     constraints.contentsDefinedInitialScale = (ViewportArguments::ValueAuto != attributes.initialScale);
 
-    double defaultViewLevel = m_viewImpl->page()->pageGroup()->preferences()->defaultViewLevel();
-    // If defaultViewLevel is 1, "Default View" is set as "Readable"
-    // if not, "Default View" is set as "Fit to width"
-    if (defaultViewLevel) {
+    bool autoFittingEnabled = m_viewImpl->page()->pageGroup()->preferences()->autoFittingEnabled();
+    if (autoFittingEnabled)
+        constraints.initialScale = attributes.minimumScale * attributes.devicePixelRatio;
+    else {
         // if content doesn't set initial scale value, set readable scale factor
         // if not, set initial scale factor of viewport attribute
         if (attributes.initialScale == ViewportArguments::ValueAuto)
             constraints.initialScale = m_viewImpl->page()->deviceScaleFactor();
         else
             constraints.initialScale = attributes.initialScale * attributes.devicePixelRatio;
-    } else {
-        // Minimize initial scale factor
-        constraints.initialScale = attributes.minimumScale * attributes.devicePixelRatio;
     }
 
     // adjust scale with both minimum and maximum scale factor
-    constraints.initialScale = clampTo(constraints.initialScale, constraints.minimumScale, constraints.maximumScale);
+    constraints.initialScale = adjustScaleWithViewport(constraints.initialScale);
 
     return constraints;
 }
@@ -370,6 +367,13 @@ void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttribut
     double scaleRatioBeforeRotation = m_scaleFactor / m_viewportConstraints.minimumScale;
     m_viewportConstraints = computeViewportConstraints(attributes);
 
+    // Initially, m_scaleFactor is not decided yet.
+    // So, we should update visible content rect at here.
+    if (!m_scaleFactor) {
+        setVisibleContentRect(m_visibleContentRect, m_viewportConstraints.initialScale);
+        return;
+    }
+
     // if content is reloaded, contents size will not be changed
     // so, we need to calculate minimum scale here.
     // if content size is changed later, minimum scale will be re-calculated on didChangeContentsSize()
index cbb798d..69cc659 100755 (executable)
@@ -185,10 +185,7 @@ Eina_Bool ewk_settings_auto_fitting_set(Ewk_Settings* settings, Eina_Bool enable
 {
     EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false);
 
-    if (enable)
-        settings->preferences()->setDefaultViewLevel(0);
-    else
-        settings->preferences()->setDefaultViewLevel(1);
+    settings->preferences()->setAutoFittingEnabled(enable);
 
     return true;
 }
@@ -197,11 +194,7 @@ Eina_Bool ewk_settings_auto_fitting_get(const Ewk_Settings* settings)
 {
     EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false);
 
-    double level = settings->preferences()->defaultViewLevel();
-    if (level == 0)
-        return true;
-    else
-        return false;
+    return settings->preferences()->autoFittingEnabled();
 }
 
 Eina_Bool ewk_settings_font_default_size_set(Ewk_Settings* settings, int size)