Title: [121934] trunk/Source/WebKit2
- Revision
- 121934
- Author
- commit-qu...@webkit.org
- Date
- 2012-07-05 18:47:55 -0700 (Thu, 05 Jul 2012)
Log Message
[WK2][EFL] Ewk_View should provide API to set/get device pixel ratio
https://bugs.webkit.org/show_bug.cgi?id=90590
Patch by Christophe Dumez <christophe.du...@intel.com> on 2012-07-05
Reviewed by Kenneth Rohde Christiansen.
Add API to Ewk_View so retrieve and set the device
pixel ratio.
* UIProcess/API/efl/ewk_view.cpp:
(ewk_view_device_pixel_ratio_set):
(ewk_view_device_pixel_ratio_get):
* UIProcess/API/efl/ewk_view.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (121933 => 121934)
--- trunk/Source/WebKit2/ChangeLog 2012-07-06 01:27:35 UTC (rev 121933)
+++ trunk/Source/WebKit2/ChangeLog 2012-07-06 01:47:55 UTC (rev 121934)
@@ -1,3 +1,18 @@
+2012-07-05 Christophe Dumez <christophe.du...@intel.com>
+
+ [WK2][EFL] Ewk_View should provide API to set/get device pixel ratio
+ https://bugs.webkit.org/show_bug.cgi?id=90590
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Add API to Ewk_View so retrieve and set the device
+ pixel ratio.
+
+ * UIProcess/API/efl/ewk_view.cpp:
+ (ewk_view_device_pixel_ratio_set):
+ (ewk_view_device_pixel_ratio_get):
+ * UIProcess/API/efl/ewk_view.h:
+
2012-07-05 Anders Carlsson <ander...@apple.com>
Type-ahead doesn't work in options inside optgroups
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp (121933 => 121934)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp 2012-07-06 01:27:35 UTC (rev 121933)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp 2012-07-06 01:47:55 UTC (rev 121934)
@@ -603,6 +603,23 @@
return WKPageGetEstimatedProgress(toAPI(priv->pageClient->page()));
}
+Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
+
+ priv->pageClient->page()->setCustomDeviceScaleFactor(ratio);
+ return true;
+}
+
+float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 1);
+
+ return priv->pageClient->page()->deviceScaleFactor();
+}
+
/**
* @internal
* Reports load progress changed.
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h (121933 => 121934)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h 2012-07-06 01:27:35 UTC (rev 121933)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h 2012-07-06 01:47:55 UTC (rev 121934)
@@ -311,6 +311,54 @@
*/
EAPI Eina_Bool ewk_view_html_string_load(Evas_Object *o, const char *html, const char *baseUrl, const char *unreachableUrl);
+/**
+ * Queries the ratio between the CSS units and device pixels when the content is unscaled.
+ *
+ * When designing touch-friendly contents, knowing the approximated target size on a device
+ * is important for contents providers in order to get the intented layout and element
+ * sizes.
+ *
+ * As most first generation touch devices had a PPI of approximately 160, this became a
+ * de-facto value, when used in conjunction with the viewport meta tag.
+ *
+ * Devices with a higher PPI learning towards 240 or 320, applies a pre-scaling on all
+ * content, of either 1.5 or 2.0, not affecting the CSS scale or pinch zooming.
+ *
+ * This value can be set using this property and it is exposed to CSS media queries using
+ * the -webkit-device-pixel-ratio query.
+ *
+ * For instance, if you want to load an image without having it upscaled on a web view
+ * using a device pixel ratio of 2.0 it can be done by loading an image of say 100x100
+ * pixels but showing it at half the size.
+ *
+ * @media (-webkit-min-device-pixel-ratio: 1.5) {
+ * .icon {
+ * width: 50px;
+ * height: 50px;
+ * url: "/images/i...@2x.png"; // This is actually a 100x100 image
+ * }
+ * }
+ *
+ * If the above is used on a device with device pixel ratio of 1.5, it will be scaled
+ * down but still provide a better looking image.
+ *
+ * @param o view object to get device pixel ratio
+ *
+ * @return the ratio between the CSS units and device pixels.
+ */
+EAPI float ewk_view_device_pixel_ratio_get(const Evas_Object *o);
+
+/**
+ * Sets the ratio between the CSS units and device pixels when the content is unscaled.
+ *
+ * @param o view object to set device pixel ratio
+ *
+ * @return @c EINA_TRUE if the device pixel ratio was set, @c EINA_FALSE otherwise
+ *
+ * @see ewk_view_device_pixel_ratio_get()
+ */
+EAPI Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object *o, float ratio);
+
#ifdef __cplusplus
}
#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes