Closed Bug 932690 Opened 6 years ago Closed 6 years ago

[GeckoView]Can't disable the zoom in/out in html

Categories

(Firefox for Android :: General, defect)

x86
macOS
defect
Not set

Tracking

()

RESOLVED FIXED
Firefox 28

People

(Reporter: pengjianqing, Assigned: wesj)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36

Steps to reproduce:

I want to disable the zoom in/out feature in GeckoView, but it doesn't work.

About the user-scalable,I add it to the html:
 <meta name="viewport" content="width=device-width, user-scalable=no, maximum-scale=1">
But it still can zooming in GeckoView.
Also I test it in the Fennec with the link:https://addons.mozilla.org/en-us/android/,it works,but in GeckoView,it doesn't
So maybe the Fennec Browser has something else to handle it,but the single GeckoView not.
Blocks: geckoview
For me adding following lines to head works:

<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi" />
<meta name="HandheldFriendly" content="true" />
Really? I will do some test.

(In reply to Michal Lower from comment #1)
> For me adding following lines to head works:
> 
> <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0,
> minimum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi" />
> <meta name="HandheldFriendly" content="true" />
Test with following html page, but doesn't work. Is there any meta tag I need to add? Thanks!

<!doctype html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi" />
        <meta name="HandheldFriendly" content="true" />
    </head>
    <body>
       test zoom in/out
    </body>
</html>
Sorry for the misleading info. 
I've done some more investigation and it turns out that I have working code from game development framework called Construct2 (http://scirra.com) but it doesn't rely on proper viewport implementation. Instead the whole page is wrapped inside <div> element that has fixed width and height properties that are detected at runtime using Javascript. So this bug exists but there is a way around.
Do you also want to use the GeckoView to replace the system default WebView?Because of the consistent user experience across different Android version and devices.

(In reply to Michal Lower from comment #4)
> Sorry for the misleading info. 
> I've done some more investigation and it turns out that I have working code
> from game development framework called Construct2 (http://scirra.com) but it
> doesn't rely on proper viewport implementation. Instead the whole page is
> wrapped inside <div> element that has fixed width and height properties that
> are detected at runtime using Javascript. So this bug exists but there is a
> way around.
Same issue for me, user-scalable=no doesn't disable zoom feature at all in Geckoview, even it's working with FF mobile.
As a (horrible) workaround:

- Remove Java class "geckoview_library/libs/geckobrowser.jar!/org/mozilla/gecko/ZoomConstraints.class"

- Write your own ZoomConstraints.java in your projet (don't forget to put it in org.mozilla.gecko package):

package org.mozilla.gecko;

import org.json.JSONException;
import org.json.JSONObject;

public final class ZoomConstraints {

    private final boolean mAllowZoom;
    private final float mDefaultZoom;
    private final float mMinZoom;
    private final float mMaxZoom;

    public ZoomConstraints(boolean allowZoom) {
        // Never allow zoom
        // mAllowZoom = allowZoom;
        mDefaultZoom = 0.0f;
        mMinZoom = 0.0f;
        mMaxZoom = 0.0f;
    }

    ZoomConstraints(JSONObject message) throws JSONException {
        // Never allow zoom
        // mAllowZoom = message.getBoolean("allowZoom");
        mDefaultZoom = (float)message.getDouble("defaultZoom");
        mMinZoom = (float)message.getDouble("minZoom");
        mMaxZoom = (float)message.getDouble("maxZoom");
    }

    public final boolean getAllowZoom() {
        return mAllowZoom;
    }

    public final float getDefaultZoom() {
        return mDefaultZoom;
    }

    public final float getMinZoom() {
        return mMinZoom;
    }

    public final float getMaxZoom() {
        return mMaxZoom;
    }
}
Wes - What does GeckoView need to hook up to get this working?
Assignee: nobody → wjohnston
We need to move these metaviewport message handling out of GeckoApp and into the Tab likely:

http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/GeckoApp.java#586
Attached patch Patch v1Splinter Review
Something like this. I moved the message handling into LayerView. Not happy that these have to know about each other, but not really sure we have other options. LayerView is as close as we can get to common ground between GeckoApp and GeckoView I think...
Attachment #825508 - Flags: review?(bugmail.mozilla)
Since we actually use GeckoView in Fennec, can we just move this to GeckoView? (no duplication. straight move)
Comment on attachment 825508 [details] [diff] [review]
Patch v1

Review of attachment 825508 [details] [diff] [review]:
-----------------------------------------------------------------

I'm fine with this. It doesn't introduce new dependencies that aren't already there (LayerRenderer.java in the gfx/ code also registers itself as a Tab listener). I would advise you to run this through try first though, these kinds of changes tend to tickle race conditions.
Attachment #825508 - Flags: review?(bugmail.mozilla) → review+
https://hg.mozilla.org/mozilla-central/rev/7c64f27e4494
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 28

This still seems to be an Issue in 74.

Have this in HTML:
<meta name="viewport" content="minimal-ui, width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

and .forceUserScalableEnabled(false) on GeckoRuntimeSettings.Builder()

It is still possible to zoom.

Found out it happens in combination with .viewportMode(GeckoSessionSettings.VIEWPORT_MODE_DESKTOP) .
If removed, it works.

You need to log in before you can comment on or make changes to this bug.