iframe element with 100% does not fit screen

1,294 views
Skip to first unread message

hengzhi wu

unread,
Jun 17, 2015, 10:50:48 PM6/17/15
to android-w...@chromium.org, bo...@google.com
Hi, All
    Please look at iframepercent.html and iframeregview.html, the width of iframe is "100%" which corresponding to default content width: 980px.
    If the device resolution is 1280*800, then scale factor(minimumScale) is 1280 / 980 = 1.3061, please look at the following code.
    In third_party/WebKit/Source/core/page/PageScaleConstraints.cpp:
void PageScaleConstraints::fitToContentsWidth(float contentsWidth, int viewWidthNotIncludingScrollbars)
{
   
if (!contentsWidth || !viewWidthNotIncludingScrollbars)
       
return;


   
// Clamp the minimum scale so that the viewport can't exceed the document
   
// width.
   
minimumScale = std::max(minimumScale, viewWidthNotIncludingScrollbars / contentsWidth);


    clampAll
();
}

     From above code, minimumScale is 1.3061, so the page does not fit screen even with setUseWideViewPort(true), setLoadWithOverviewMode(true), setInitialScale(70).
  Is there any document to explain this behavior? or it's a bug?
  Thanks.
iframepercent.html
iframepxview.html
iframeregview.html

hengzhi wu

unread,
Jun 28, 2015, 9:34:56 PM6/28/15
to android-w...@chromium.org, bo...@google.com
@Bo

    Could you give some advises? thanks.

在 2015年6月18日星期四 UTC+8上午10:50:48,hengzhi wu写道:

Bo Liu

unread,
Jul 6, 2015, 4:02:02 PM7/6/15
to hengzhi wu, android-webview-dev, Mikhail Naganov
+mnaganov

--
You received this message because you are subscribed to the Google Groups "android-webview-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-webview...@chromium.org.
To post to this group, send email to android-w...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/android-webview-dev/011d209e-f891-4d55-ac36-d83a9ccab7eb%40chromium.org.

Mikhail Naganov

unread,
Jul 6, 2015, 9:35:03 PM7/6/15
to Bo Liu, hengzhi wu, android-webview-dev
Hello,

What are the dimensions of 't-library-bg8.jpg' that these pages load?

Also, why do you need 'setInitialScale(70)'? I wouldn't recommend use this method at all, as it doesn't take into account screen density. Using <meta name="viewport"> tag is preferred.

hengzhi wu

unread,
Jul 12, 2015, 6:08:27 AM7/12/15
to android-w...@chromium.org, chm...@gmail.com, bo...@chromium.org, mnag...@chromium.org
Hi, mnaganov

The dimensions for 't-library-bg8.jpg' is 1920 * 1080, please look at the attachment.
For iframeregview.html, <meta name="viewport" content="width=device-width"> or <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> was used, but the page was also not fit to the screen.
Using the meta viewport value width=device-width instructs the page to match the screen's width in device independent pixels. This allows the page to reflow content to match different screen sizes.


Thanks.

在 2015年7月7日星期二 UTC+8上午9:35:03,Mikhail Naganov写道:
t-library-bg8.jpg

Mikhail Naganov

unread,
Jul 13, 2015, 8:43:47 PM7/13/15
to hengzhi wu, android-w...@chromium.org, Bo Liu
Sorry for more questions, but what is the view configuration of your WebView, I mean the values of android:layout_width and android:layout_height from the layout xml file?
Also, what WebView version do you use (System > Apps > All > Android System WebView), what is your Android version, and what is your targetSdkLevel in AndroidManifest.xml?

The issue you are seeing may be related to this bug: http://crbug.com/492464, but that depends on the answers to the questions above.

hengzhi wu

unread,
Jul 16, 2015, 10:44:35 PM7/16/15
to android-w...@chromium.org, bo...@chromium.org, chm...@gmail.com, mnag...@chromium.org
Hi, mnaganov

    Sorry for later response.
    Please look at the attachment. There are some comments in java file.
    I have tried to install the apk on android 4.1, 4.2, 5.0, the display does not fit screen.
    I have also built the android_webview_apk, the display does not fit screen and the setting is same as the attachment.

Thanks.

在 2015年7月14日星期二 UTC+8上午8:43:47,Mikhail Naganov写道:
android-webview-sample-app.zip

hengzhi wu

unread,
Aug 27, 2015, 9:20:58 PM8/27/15
to android-webview-dev, bo...@chromium.org, chm...@gmail.com, mnag...@chromium.org
Hi, Mnganov

    Any update? Thanks.

在 2015年7月17日星期五 UTC+8上午10:44:35,hengzhi wu写道:
+mnaganov

To unsubscribe from this group and stop receiving emails from it, send an email to android-webview-dev+unsub...@chromium.org.
To post to this group, send email to android-w...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "android-webview-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-webview-dev+unsub...@chromium.org.

To post to this group, send email to android-w...@chromium.org.

Mikhail Naganov

unread,
Aug 28, 2015, 8:14:35 PM8/28/15
to hengzhi wu, android-webview-dev, Bo Liu
Is there any specific need for you to use <iframe> in order to insert an image?

I don't have a real device at hand, but I tried opening your pages on desktop Chrome in mobile emulation mode (https://developer.chrome.com/devtools/docs/device-mode), emulating Nexus 10, and the image is scaled to fit screen if I replace in your iframepercent.html <iframe> with <img>, that is:

<iframe src="t-library-bg8.jpg" width="100%" height="100%" frameborder="0"></iframe>

with:

<img src="t-library-bg8.jpg" width="100%" height="100%">

I don't think your issue is anyhow specific to WebView. When you turn on WideViewPort and LoadWithOverviewMode, WebView behaves almost identical to Chrome for Android (and mobile emulation in DevTools can reproduce that even on desktop). 

Hi, Mnganov

+mnaganov

To unsubscribe from this group and stop receiving emails from it, send an email to android-webview...@chromium.org.
To post to this group, send email to android-w...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "android-webview-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-webview...@chromium.org.

To post to this group, send email to android-w...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "android-webview-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-webview...@chromium.org.
To post to this group, send email to android-w...@chromium.org.
Reply all
Reply to author
Forward
0 new messages