Right now we rely on various element widths to do constraints while panning, and we're calling getBoundingClientRect() pretty much every time to handle window resizes. We should be caching these widths and using a resize handler to invalidate, to avoid unnecessary gets. Window resizing in general could be improved (e.g. making sure not to redraw instead of stretch the canvas when resizing).
Created attachment 352200 [details] [diff] [review] patch The part of this patch that's actually relevant to this bug: -cache canvas rect in canvasDimensions Other cleanup: -clean out CanvasBrowser constructor (don't set things that are set in prototype just below) -simplify _effectiveCanvasDimensions using map() -comment out/remove _effectiveViewportDimensions and ensureElementIsVisible since they're broken -fix strict warning in viewportHandler ("doesn't always return a value") -get rid of _canvasPageOffset since it's always [0, 0] -get rid of _drawOffset since it's now equivalent to _pageOffset -comment out "avoiding dumb paint" since that's annoying -make _pageOffset a getter rather than a function
Created attachment 352343 [details] [diff] [review] patch Huh, I could have sworn I attached this update, which takes advantage of the rect cache in _clientToContentCoords as well.
Stuart rightfully points out that caching left/top is not a winning strategy! Fixed: https://hg.mozilla.org/mobile-browser/rev/3b1727f1a2ad
verified FIXED on build: Mozilla/5.0 (Macintosh; U; Intel Mac OSX 10.5; en-US; rv:1.9.2a2pre) Gecko/20090808 Fennec/1.0b3pre