Closed Bug 710126 Opened 13 years ago Closed 12 years ago

images wider than they are long can't be fully viewed

Categories

(Firefox for Android Graveyard :: General, defect, P3)

ARM
Android
defect

Tracking

(blocking-fennec1.0 -, fennec11+)

VERIFIED FIXED
Tracking Status
blocking-fennec1.0 --- -
fennec 11+ ---

People

(Reporter: akeybl, Assigned: kats)

References

Details

(Whiteboard: [MTD])

Attachments

(3 files, 1 obsolete file)

Web pages that are wider than they are long can't be viewed in full. This is especially an issue with images and presumably video.
See https://bug706667.bugzilla.mozilla.org/attachment.cgi?id=580811 on a phone in portrait mode. This may be specific to images, haven't tested elsewhere.
Whiteboard: [MTD]
Attached image fennec screenshot
Attached image browser screenshot
Attachment #581531 - Attachment mime type: text/plain → image/png
Attachment #581530 - Attachment mime type: text/plain → image/png
recommend a P2 fix.  this is a lousy user experience
OS: Linux → Android
Hardware: Other → ARM
Priority: -- → P3
tracking-fennec: --- → 11+
Is this still an issue in current builds?
(In reply to Martijn Wargers [:mw22] (QA - IRC nick: mw22) from comment #5)
> Is this still an issue in current builds?

Yes, as of 3 days ago this was still a problem with all images wider than they are long. Are you unable to reproduce or something?
Can you please try again with the latest build and if this occurs, can you place in the device you used?  This does not reproduce for us with the latest build.
(In reply to Naoki Hirata :nhirata from comment #7)
> Can you please try again with the latest build and if this occurs, can you
> place in the device you used?  This does not reproduce for us with the
> latest build.

Today's build (3/5).

1) Go to http://1.bp.blogspot.com/-j14W8K8Yvug/TbnWYj9gUQI/AAAAAAAADZM/sNgtfe4-c3M/s1600/beautiful-blue-bird-wallpaper+1+%25281%2529.jpg
2) Cannot zoom out to view full image because it is wider than it is long
blocking-fennec1.0: --- → ?
Summary: pages wider than they are long can't be fully viewed → images wider than they are long can't be fully viewed
blocking-fennec1.0: ? → -
Not fixing this for our 1.0 means we're OK with direct image viewing being functionally broken for presumably half of the images on the internet at release.
Attached patch Scale images to fit on load (obsolete) — Splinter Review
Assignee: nobody → bugmail.mozilla
Status: NEW → ASSIGNED
Attachment #608477 - Flags: review?(chrislord.net)
Comment on attachment 608477 [details] [diff] [review]
Scale images to fit on load

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

r+ with the comment below addressed.

::: mobile/android/chrome/content/browser.js
@@ +2220,5 @@
>            // and then use the metadata to figure out how it needs to be updated
>            ViewportHandler.updateMetadata(this);
>  
> +          // for images, scale to fit width
> +          if (contentDocument instanceof ImageDocument) {

Might be nice to stick the above this.setResolution into an else clause here, so that they don't ever accidentally get re-ordered... Also, the tab's viewport meta-data will be out of date after this call (as ViewportHandler.updateMetadata(this) is called above), is this intentional?
Attachment #608477 - Flags: review?(chrislord.net) → review+
(In reply to Chris Lord [:cwiiis] from comment #12)
> Might be nice to stick the above this.setResolution into an else clause
> here, so that they don't ever accidentally get re-ordered... Also, the tab's
> viewport meta-data will be out of date after this call (as
> ViewportHandler.updateMetadata(this) is called above), is this intentional?

Are you referring to the setResolution that's above the updateMetadata call? The order of calls here is important, yes, and I think needs to be done in exactly the way I wrote it. First we reset the zoom to "default". Then we run updateMetadata, which figures out the right CSS viewport and *scales* the zoom to match. Note that it doesn't clobber the default zoom, but uses it as a factor in the calculation of the new zoom, so setting the "default" zoom must be done beforehand. (Note that updateMetadata gets called from other places as well so we have to do that scaling relative to the existing zoom instead of just coming up with some absolute zoom).

Finally, after setting the CSS viewport (which affects page size), we can figure out what zoom we need to make image-pages fit based on the new page size. Does that make sense?

I think the only real bit of redundancy with my patch as written is that the updateMetadata call (at the end of updateViewportSize) sets a resolution and sends a viewport update that is immediately clobbered by the new code I added. However this is only the case for image documents. (Actually, now that I'm looking at the whole code path, the sendViewportUpdate() I had you leave in this before-first-paint handler is not needed because the updateMetadata will do that anyway. I can move it into the image document if-condition if you prefer).
(In reply to Kartikaya Gupta (:kats) from comment #13)
> (In reply to Chris Lord [:cwiiis] from comment #12)
> > Might be nice to stick the above this.setResolution into an else clause
> > here, so that they don't ever accidentally get re-ordered... Also, the tab's
> > viewport meta-data will be out of date after this call (as
> > ViewportHandler.updateMetadata(this) is called above), is this intentional?
> 
> Are you referring to the setResolution that's above the updateMetadata call?
> The order of calls here is important, yes, and I think needs to be done in
> exactly the way I wrote it. First we reset the zoom to "default". Then we
> run updateMetadata, which figures out the right CSS viewport and *scales*
> the zoom to match. Note that it doesn't clobber the default zoom, but uses
> it as a factor in the calculation of the new zoom, so setting the "default"
> zoom must be done beforehand. (Note that updateMetadata gets called from
> other places as well so we have to do that scaling relative to the existing
> zoom instead of just coming up with some absolute zoom).
> 
> Finally, after setting the CSS viewport (which affects page size), we can
> figure out what zoom we need to make image-pages fit based on the new page
> size. Does that make sense?
> 
> I think the only real bit of redundancy with my patch as written is that the
> updateMetadata call (at the end of updateViewportSize) sets a resolution and
> sends a viewport update that is immediately clobbered by the new code I
> added. However this is only the case for image documents. (Actually, now
> that I'm looking at the whole code path, the sendViewportUpdate() I had you
> leave in this before-first-paint handler is not needed because the
> updateMetadata will do that anyway. I can move it into the image document
> if-condition if you prefer).

I think moving it to the if-condition and adding a comment in said block explaining this would be good.
Updated comments and moved the sendViewportUpdate into the if block. Re-requesting review (please be as harsh as you like, I want to make sure this code is understandable and correct...)
Attachment #608477 - Attachment is obsolete: true
Attachment #608703 - Flags: review?(chrislord.net)
Comment on attachment 608703 [details] [diff] [review]
Scale images to fit on load (v2)

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

Comments read well to me, r+, but comment below may be something to consider.

::: mobile/android/chrome/content/browser.js
@@ +2232,5 @@
> +          // the MozScrolledAreaChanged event. If that didn't happen, the updateMetadata
> +          // call above does so at the end of the updateViewportSize function. As long
> +          // as that is happening, we don't need to do it again here.
> +
> +          if (contentDocument instanceof ImageDocument) {

Out of interest, do we want to do something similar for SVGDocument too? And videos? Maybe it'd be better to do a !(contentDocument instanceof HTMLDocument) instead?
Attachment #608703 - Flags: review?(chrislord.net) → review+
(In reply to Chris Lord [:cwiiis] from comment #16)
> Out of interest, do we want to do something similar for SVGDocument too? And
> videos? Maybe it'd be better to do a !(contentDocument instanceof
> HTMLDocument) instead?

Unfortunately we can't just do !(contentDocument instanceof HTMLDocument) because all ImageDocuments are also HTMLDocuments. But yeah, it makes sense to do this for SVGDocument as well. I don't know what video ends up as, will try to find out.
So it appears that the VideoDocument and MediaDocument interfaces are not exposed to JS, so we can't really do the same for those types. SVGs are already fit to width because gecko rescales SVG images to fit in the CSS viewport if needed, and bug 712065 took care of making sure it shows up ok (I verified that it still works in latest code). So while it is kind of annoying that we can't do this consistently across all non-HTML document types, I think is the best we can do for now.

https://hg.mozilla.org/integration/mozilla-inbound/rev/aa32e30bab34
Target Milestone: --- → Firefox 14
(In reply to Kartikaya Gupta (:kats) from comment #18)
> So it appears that the VideoDocument and MediaDocument interfaces are not
> exposed to JS, so we can't really do the same for those types.

You can use "if (contentDocument.mozSyntheticDocument)" to check for all of those types (see bug 719271 for example).
https://hg.mozilla.org/mozilla-central/rev/aa32e30bab34
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Verified fixed in today's build on the Samsung Galaxy Nexus.
Status: RESOLVED → VERIFIED
Target Milestone: Firefox 14 → ---
Blocks: 742207
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: