Closed Bug 1241741 Opened 8 years ago Closed 8 years ago

Meta viewport tag does not work in mozbrowser in-process iframe

Categories

(Core :: Panning and Zooming, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

()

RESOLVED INCOMPLETE
Tracking Status
firefox48 --- unaffected
b2g-master --- affected

People

(Reporter: kershaw, Unassigned)

References

(Depends on 1 open bug)

Details

(Keywords: feature, Whiteboard: [gfx-noted][ft:conndevices])

We found that viewport tag is only working in oop iframe, but not in a mozbrowser iframe, which is in process.
According to Kan-Ru, the root cause maybe in [1]. nsPresContext::IsRootContentDocument should also check whether the document is in mozbrowser iframe.

[1] https://dxr.mozilla.org/mozilla-central/source/layout/base/nsPresContext.cpp#2878
Hi kats,

Could you please take a look at this issue?

Thanks.
Flags: needinfo?(bugmail.mozilla)
What's the context that you are running into this? In general supporting the meta-viewport tag requires supporting zooming on that document, and right now the APZ code doesn't support zooming on arbitrary documents. We only support zooming on root content documents, and even that doesn't work perfectly if there is other stuff outside that document in the same process. We are having issues with that in Fennec right now.
Flags: needinfo?(bugmail.mozilla)
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #2)
> What's the context that you are running into this? In general supporting the

We just let system app create a non-oop mozbrowser iframe and found the meta-viewport didn't work in this case.

> meta-viewport tag requires supporting zooming on that document, and right
> now the APZ code doesn't support zooming on arbitrary documents. We only
> support zooming on root content documents, and even that doesn't work
> perfectly if there is other stuff outside that document in the same process.
> We are having issues with that in Fennec right now.

I am not sure what does "root content document" exactly mean. I think a document in mozbrowser iframe should be a root content document, right?
(In reply to Kershaw Chang [:kershaw] from comment #3)
> (In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #2)
> > What's the context that you are running into this? In general supporting the
> 
> We just let system app create a non-oop mozbrowser iframe and found the
> meta-viewport didn't work in this case.

What is the end goal you're trying to achieve by doing this? Are you loading arbitrary web content into this iframe, or is it content that you control? If the former, that sounds like a security issue already. If the thing you need is support for initial-scale or the "zoom content to fit available space" behavior, then those both require zooming support from APZC and it will take a lot of work to do (we basically need to implement bug 990972). If you only need the CSS viewport sizing stuff, we can probably find a way to enable it for this case without also supporting zooming, but the results are probably not what you would expect. It would be better to just design your content so that it doesn't need a meta-viewport tag. 

> 
> > meta-viewport tag requires supporting zooming on that document, and right
> > now the APZ code doesn't support zooming on arbitrary documents. We only
> > support zooming on root content documents, and even that doesn't work
> > perfectly if there is other stuff outside that document in the same process.
> > We are having issues with that in Fennec right now.
> 
> I am not sure what does "root content document" exactly mean. I think a
> document in mozbrowser iframe should be a root content document, right?

That depends on what the parent is. If the parent is a content document, then the iframe can't be a root content document. I suspect that is what is happening here, because the system app lives inside a content document (which is actually a root content document).
Blocks: TV_P1
Whiteboard: [gfx-noted]
Whiteboard: [gfx-noted] → [gfx-noted][ft:conndevices]
ni kershaw for answering comment 4.
Flags: needinfo?(kechang)
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #4)
> (In reply to Kershaw Chang [:kershaw] from comment #3)
> > (In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #2)
> > > What's the context that you are running into this? In general supporting the
> > 
> > We just let system app create a non-oop mozbrowser iframe and found the
> > meta-viewport didn't work in this case.
> 
> What is the end goal you're trying to achieve by doing this? Are you loading
> arbitrary web content into this iframe, or is it content that you control?
> If the former, that sounds like a security issue already. If the thing you
> need is support for initial-scale or the "zoom content to fit available
> space" behavior, then those both require zooming support from APZC and it
> will take a lot of work to do (we basically need to implement bug 990972).
> If you only need the CSS viewport sizing stuff, we can probably find a way
> to enable it for this case without also supporting zooming, but the results
> are probably not what you would expect. It would be better to just design
> your content so that it doesn't need a meta-viewport tag. 
> 
The reason we let system app open a mozbrowser iframe is just for test purpose. We would like to test if meta-viewport flag would work for inprocess mozbrowser iframe.

I think the end goal is to let meta-viewport flag works for mozbrowser iframe no matter it's out of process or not. May I know what is the effort for fixing bug 990972?
Flags: needinfo?(kechang)
If it's just for test purposes then this is not going to be a priority at all. Regardless, it will take a high amount of effort (6months or more) to get it working if you want full support for viewport tags.
I am not sure if our partner really needs this function.

@Evelyn, could you provide some use cases that really need meta-viewport to work for inprocess mozbrowser iframe? Thanks.
Flags: needinfo?(ehung)
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #7)
> If it's just for test purposes then this is not going to be a priority at
> all. Regardless, it will take a high amount of effort (6months or more) to
> get it working if you want full support for viewport tags.

It's not a high priority, but we do have real cases that might run into this problem. For example, an ABC app uses "mozbrowser-iframe" to embed its abc.com website (for some reason), or a browser app loads arbitrary web content into its embedded iframes. 

The problem happens on in-process loading a content in mozbrowser-iframe. You can easily reproduce this issue on phone by modify this line to "false":

https://github.com/mozilla-b2g/gaia/blob/master/apps/system/js/browser_frame.js#L48
browser.setAttribute('remote', 'false');

and then use browser to load any site with viewport meta, you will see viewport doesn't work.

You can also reproduce it on b2g desktop because all content is running on a single process there.
Flags: needinfo?(ehung)
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.