The Life Unwired with Ben Combee (unwiredben) wrote,
The Life Unwired with Ben Combee
unwiredben

Panning in Mozilla Fennec and IFRAMEs

On the desktop, scrolling a page involves changing the page's scroll position.  This uses OS-widgets like scrollbars -- the OS will copy part of the page to the new position on screen and ask the browser to draw the part that's exposed.

On Fennec, we instead have an off-screen browser instance.  We ask it to render parts of the page into a large canvas element that we reposition as the user drags.  This canvas is larger than the visible area, so usually a pan won't show areas beyond the canvas.  When the pan is over, we reposition things and redraw so the next pan can proceed as normal.

This has been the source of a lot of bugs.  It's been fairly easy through kinetic scrolling and zooming to get the browser into a situation where it didn't fix up the canvas properly or start drawing again, letting the checkerboard or gray background show through.  In severe cases, you can get the whole screen to be checkerboard, which effectively hangs the browser as you can't pan back to any of the controls.

Recently, one of our summer interns, Roy, has been working with Stuart on a new system to deal with these problems called the Tile Cache.  Rather than have one giant canvas, we now have a lot of smaller canvases that we draw into as needed.  Tiles can be moved around by the cache so there's always a cloud of them around the ones visible on screen.  It seems to make panning a lot faster, but it's required a lot of changes to input handling code and user interface code, so it's not yet landed in our main Fennec development trunk.

While this has been happening, I've been working on a patch to support panning of IFRAME and FRAMESET content.  Unfortunately, IFRAME panning is going to be a bit slower than page panning, as we effectively just change the scroll position of the embedded frame, which then causes a lot of the page to be invalidated and redrawn.  There are some more complicated techniques that could be explorer for avoiding the whole-area invalidation, but they probably won't be done for the 1.0 release.

To get IFRAME panning to work, when you start a drag, we have to dig into the page content and see if your finger has touched a frame element on the screen.  If so, we scroll that element based on the finger movement.  If you get to the edge, we then move its parent; this is needed to prevent you getting into a situation where you can't pan over to the controls because you zoomed into a IFRAME's area.  One popular site where the whole page is an IFRAME is Google Mail, so without the overflow movement, it would be easy to get stuck.

With luck and a lot of code reviews, all of this should land in time for the third beta of Fennec for the Maemo platform.  I think it wll be a much better Fennec experience, and with IFRAME scrolling, we'll do something the other mobile browsers like Safari on the iPhone don't support.
Tags: mozilla
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 5 comments