Add APIs to set/get TextZoom
authorChanghyup Jwa <ch.jwa@samsung.com>
Tue, 28 Aug 2012 09:44:09 +0000 (18:44 +0900)
committerJongseok Yang <js45.yang@samsung.com>
Tue, 4 Sep 2012 07:24:59 +0000 (16:24 +0900)
[Title] Add APIs to set/get TextZoom
[Issue] N/A
[Problem] TextZoom was not supported.
[Cause] Not implemented.
[Solution] Add APIs to set/get TextZoom

Conflicts:

Source/WebKit2/Shared/WebPreferencesStore.h
Source/WebKit2/UIProcess/API/efl/tizen/Zoom.cpp

Change-Id: Iec36cc1b33113766fbdeb7de7e610600aa8588ff

Source/WTF/wtf/Platform.h
Source/WebKit2/Shared/WebPreferencesStore.h
Source/WebKit2/UIProcess/API/C/efl/WKPreferencesEfl.cpp
Source/WebKit2/UIProcess/API/C/efl/WKPreferencesEfl.h
Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp
Source/WebKit2/UIProcess/API/efl/ewk_setting.cpp
Source/WebKit2/UIProcess/API/efl/ewk_setting.h
Source/WebKit2/UIProcess/API/efl/tizen/Zoom.cpp

index 220235c..673821c 100644 (file)
 #define ENABLE_TIZEN_WEBKIT2_HIT_TEST 1 /* Yuni Jeong(yhnet.jung@samsung.com) : Hit Test API implementation for WK2 */
 #define ENABLE_TIZEN_WEBKIT2_PATCH_FOR_TC 1 /* Changhyup Jwa(ch.jwa@samsung.com) : Patchs to pass TC */
 #define ENABLE_TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION 1 /* Yuni Jeong(yhnet.jung@samsung.com) : Patchs to get text style for supporting email requirement */
+
+#if ENABLE(TIZEN_PREFERENCE)
+#define ENABLE_TIZEN_WEBKIT2_TEXT_ZOOM 1 /* Changhyup Jwa(ch.jwa@samsung.com) : Enable/Disable text zoom on user's pinch zoom */
+#endif
 #endif /* ENABLE(TIZEN_WEBKIT2) */
 
 /* When displaying menu list using menu icon, a additional scrollbar is displayed in the screen center
index ebb02f0..018bc6c 100755 (executable)
@@ -207,6 +207,7 @@ namespace WebKit {
     macro(EnableDefaultKeypad, defaultKeypadEnabled, Bool, bool, true) \
     macro(InteractiveFormValidationEnabled, interactiveFormValidationEnabled, Bool, bool, true) \
     macro(GeolocationEnabled, geolocationEnabled, Bool, bool, true) \
+    macro(TextZoomEnabled, textZoomEnabled, Bool, bool, false) \
     \
 
 #define FOR_EACH_WEBKIT_TIZEN_DOUBLE_PREFERENCE(macro) \
index 567f0c0..e487cfd 100755 (executable)
@@ -127,3 +127,18 @@ bool WKPreferencesGetGeolocationEnabled(WKPreferencesRef preferencesRef)
 #endif
 }
 
+void WKPreferencesSetTextZoomEnabled(WKPreferencesRef preferencesRef, bool enable)
+{
+#if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
+    toImpl(preferencesRef)->setTextZoomEnabled(enable);
+#endif
+}
+
+bool WKPreferencesGetTextZoomEnabled(WKPreferencesRef preferencesRef)
+{
+#if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
+    return toImpl(preferencesRef)->textZoomEnabled();
+#else
+    return false;
+#endif
+}
index 7ebb636..124f1ef 100755 (executable)
@@ -58,6 +58,12 @@ WK_EXPORT void WKPreferencesSetGeolocationEnabled(WKPreferencesRef preferencesRe
 WK_EXPORT bool WKPreferencesGetGeolocationEnabled(WKPreferencesRef preferencesRef);
 // #endif
 
+// #if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetTextZoomEnabled(WKPreferencesRef preferencesRef, bool);
+WK_EXPORT bool WKPreferencesGetTextZoomEnabled(WKPreferencesRef preferencesRef);
+// #endif
+
 #ifdef __cplusplus
 }
 #endif
index b4da54c..295a3c4 100755 (executable)
@@ -763,7 +763,9 @@ void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size)
     m_viewportConstraints.minimumScale = (float)viewSize().width() / size.width();
 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
     if (scaleFactor() == previousMinimumScale)
-        setVisibleContentRect(m_page->scrollPosition(), m_viewportConstraints.minimumScale, FloatPoint());
+        setVisibleContentRect(scrollPosition(), m_viewportConstraints.minimumScale, FloatPoint());
+    else
+        setVisibleContentRect(scrollPosition(), scaleFactor(), FloatPoint());
 #else
     if (m_requestedScaleFactor == previousMinimumScale)
         m_page->scalePage(m_viewportConstraints.minimumScale, scrollPosition());
@@ -1265,7 +1267,12 @@ void PageClientImpl::scaleImage(double scaleFactor, IntPoint scrollPosition, boo
 #endif
 
     // Adjust scaleFactor.
+#if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
+    if (!page()->pageGroup()->preferences()->textZoomEnabled())
+        scaleFactor = adjustScaleWithViewport(scaleFactor);
+#else
     scaleFactor = adjustScaleWithViewport(scaleFactor);
+#endif
 
     // Adjust scrollPosition not to exceed contents boundary.
     if (adjustToBoundary) {
index 2e27334..251f833 100755 (executable)
@@ -313,3 +313,20 @@ Eina_Bool ewk_setting_enable_geolocation_get(Ewk_Setting* ewkSetting)
 }
 #endif
 
+#if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
+Eina_Bool ewk_setting_enable_text_zoom_set(Ewk_Setting* ewkSetting, Eina_Bool enable)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(ewkSetting, false);
+
+    WKPreferencesSetTextZoomEnabled(ewkSetting->preferences.get(), enable);
+
+    return true;
+}
+
+Eina_Bool ewk_setting_enable_text_zoom_get(const Ewk_Setting* ewkSetting)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(ewkSetting, false);
+
+    return WKPreferencesGetTextZoomEnabled(ewkSetting->preferences.get());
+}
+#endif
index 1786e00..4cde601 100755 (executable)
@@ -349,6 +349,27 @@ EAPI Eina_Bool ewk_setting_enable_geolocation_set(Ewk_Setting* ewkSetting, Eina_
 EAPI Eina_Bool ewk_setting_enable_geolocation_get(Ewk_Setting* ewkSetting);
 //#endif
 
+// #if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
+/**
+ * Requests setting use of text zoom.
+ *
+ * @param setting setting object to text zoom
+ * @param enable to text zoom.
+ *
+ * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
+ */
+EAPI Eina_Bool ewk_setting_enable_text_zoom_set(Ewk_Setting* setting, Eina_Bool enable);
+
+/**
+ * Returns whether text zoom is enabled or not.
+ *
+ * @param setting setting object to text zoom
+ *
+ * @return @c EINA_TRUE if enable text zoom or @c EINA_FALSE.
+ */
+EAPI Eina_Bool ewk_setting_enable_text_zoom_get(const Ewk_Setting* setting);
+//#endif
+
 #ifdef __cplusplus
 }
 #endif
index 18b8754..b31101e 100644 (file)
 #include "PageClientImpl.h"
 #include "ewk_view_private.h"
 
+#if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
+#include "WebPageGroup.h"
+#include "WebPreferences.h"
+#endif
+
 using namespace WebCore;
 using namespace WebKit;
 
@@ -100,7 +105,13 @@ void Zoom::stop()
 void Zoom::update(const double zoom, const IntPoint& centerPoint)
 {
     PageClientImpl* pageClientImpl = ewkViewGetPageClient(m_viewWidget);
+#if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
+    double newScaleFactor = m_baseScaleFactor * zoom;
+    if (!pageClientImpl->page()->pageGroup()->preferences()->textZoomEnabled())
+        newScaleFactor = pageClientImpl->adjustScaleWithViewport(newScaleFactor);
+#else
     double newScaleFactor = pageClientImpl->adjustScaleWithViewport(m_baseScaleFactor * zoom);
+#endif
 
     if (fabs(newScaleFactor - m_newScaleFactor) > s_scaleFactorThreshold)
         m_newScaleFactor = newScaleFactor;
@@ -119,7 +130,17 @@ void Zoom::realStop()
     }
 
     PageClientImpl* pageClientImpl = ewkViewGetPageClient(m_viewWidget);
+
+#if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
+    if (pageClientImpl->page()->pageGroup()->preferences()->textZoomEnabled()) {
+        double textScaleFactor = pageClientImpl->adjustScaleWithViewport(pageClientImpl->page()->textZoomFactor() * (m_newScaleFactor / m_baseScaleFactor));
+        pageClientImpl->page()->scale(m_baseScaleFactor, m_baseScrollPosition);
+        pageClientImpl->page()->setTextZoomFactor(textScaleFactor);
+    } else
+        pageClientImpl->page()->scale(m_newScaleFactor, m_newScrollPosition);
+#else
     pageClientImpl->page()->scale(m_newScaleFactor, m_newScrollPosition);
+#endif
 
 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
     pageClientImpl->updateTextSelectionHandlesAndContextMenu(true);