Web view scale not changing

Web view scale not changing

BY 29 Mar 2017 Native Application Development

Hi All,

I have a webview of size 300×250 which loads url from web say http://www.google.com

I’m trying to scale the webview so that the page fits properly based on the frame of webview, however when applying the scale, it seems to be unchanged.

Could anyone point out what could be wrong in the following code?

/* WebView */

    Evas_Object *evas = evas_object_evas_get(ad->win);
    web_view = ewk_view_add(evas);
    evas_object_move(web_view, 50, 50);
    evas_object_resize(web_view, 300, 250);
    evas_object_show(web_view);

    ewk_view_url_set(web_view, "http://www.google.com");

    web_view_apply_scale(0.5);

static void web_view_apply_scale (float scale_factor)
{

    float currentScaleFactor = ewk_view_scale_get(web_view);

    if((currentScaleFactor == -1) || (scale_factor == currentScaleFactor)) {
        // do nothing, undefined scale factor or scale factor equals current scale factor
    } else {

        // apply scale
        Eina_Bool success = ewk_view_scale_set(web_view, scale_factor, 0, 0);
        if(success) {
            dlog_print(DLOG_INFO, LOG_TAG, "web view scale success, current scale: %f", ewk_view_scale_get(web_view));
        } else {
            dlog_print(DLOG_INFO, LOG_TAG, "web view scale failure, current scale: %f", ewk_view_scale_get(web_view));
        }
    }
}

 

Console always prints:

03-29 15:11:29.146 : INFO / websample ( 3670 : 3670 ) : web view scale success, current scale: 1.000000

I tried changing the scale by adding a callback to web view loading finished but there it prints scale as 0.36 when setting scale as 0.5. Visually there is no change noticeable.

Is the issue because im passing 0,0 for the position to apply scale at? I don’t know how to scale the webview from the webview’s center point without user interaction.

Any help would be great.

Written by