From 6876219da35069bd9e90a848c1abdf7a0b8356fa Mon Sep 17 00:00:00 2001 From: Changhyup Jwa Date: Wed, 5 Jun 2013 18:31:09 +0900 Subject: [PATCH] Enable auto fitting setting value initially [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 | 2 ++ .../WebKit2/UIProcess/API/efl/PageClientImpl.cpp | 22 +++++++++++++--------- Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp | 11 ++--------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Source/WebKit2/Shared/WebPreferencesStore.h b/Source/WebKit2/Shared/WebPreferencesStore.h index c6a6600..4bdd4e5 100755 --- a/Source/WebKit2/Shared/WebPreferencesStore.h +++ b/Source/WebKit2/Shared/WebPreferencesStore.h @@ -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 diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp index ad113e8..4592938 100755 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp @@ -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() diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp index cbb798d..69cc659 100755 --- a/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp @@ -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) -- 2.7.4