diff --git a/mobile/chrome/content/CanvasBrowser.js b/mobile/chrome/content/CanvasBrowser.js index 3091ab444d3..c2d4c7989dc 100644 --- a/mobile/chrome/content/CanvasBrowser.js +++ b/mobile/chrome/content/CanvasBrowser.js @@ -54,13 +54,16 @@ CanvasBrowser.prototype = { _screenY: 0, get canvasDimensions() { - return [this.canvasRect.width, this.canvasRect.height]; + if (!this._canvasRect) { + let canvasRect = this._canvas.getBoundingClientRect(); + this._canvasRect = { + width: canvasRect.width, + height: canvasRect.height + } + } + return [this._canvasRect.width, this._canvasRect.height]; }, - get canvasRect() { - return this._canvas.getBoundingClientRect(); - }, - get _effectiveCanvasDimensions() { return this.canvasDimensions.map(this._screenToPage, this); }, @@ -429,8 +432,9 @@ CanvasBrowser.prototype = { // Need to adjust for the deckbrowser not being at 0,0 // (e.g. due to other browser UI) - let clickOffsetX = this._screenToPage(aClientX - this.canvasRect.left) + this._pageX; - let clickOffsetY = this._screenToPage(aClientY - this.canvasRect.top) + this._pageY; + let canvasRect = this._canvas.getBoundingClientRect(); + let clickOffsetX = this._screenToPage(aClientX - canvasRect.left) + this._pageX; + let clickOffsetY = this._screenToPage(aClientY - canvasRect.top) + this._pageY; // Take scroll offset into account to return coordinates relative to the viewport let cwin = this._browser.contentWindow;