Bug 710297 - Send page size updates to Java more often during load. r=Cwiiis

This commit is contained in:
Kartikaya Gupta 2011-12-27 00:57:27 -05:00
parent 954005ec2a
commit 5c2043444b

View File

@ -1338,12 +1338,8 @@ Tab.prototype = {
this._viewport.x = Math.round(this._viewport.x * this._viewport.zoom);
this._viewport.y = Math.round(this._viewport.y * this._viewport.zoom);
/*
* Don't alter the page size until we hit DOMContentLoaded, because this causes the page size
* to jump around wildly during page load.
*/
let doc = this.browser.contentDocument;
if (doc != null && doc.readyState === 'complete') {
if (doc != null) {
let pageWidth = this._viewport.width, pageHeight = this._viewport.height;
let body = doc.body || { scrollWidth: pageWidth, scrollHeight: pageHeight };
let html = doc.documentElement || { scrollWidth: pageWidth, scrollHeight: pageHeight };
@ -1351,8 +1347,18 @@ Tab.prototype = {
pageHeight = Math.max(body.scrollHeight, html.scrollHeight);
/* Transform the page width and height based on the zoom factor. */
this._viewport.pageWidth = Math.round(pageWidth * this._viewport.zoom);
this._viewport.pageHeight = Math.round(pageHeight * this._viewport.zoom);
pageWidth = Math.round(pageWidth * this._viewport.zoom);
pageHeight = Math.round(pageHeight * this._viewport.zoom);
/*
* Avoid sending page sizes of less than screen size before we hit DOMContentLoaded, because
* this causes the page size to jump around wildly during page load. After the page is loaded,
* send updates regardless of page size; we'll zoom to fit the content as needed.
*/
if (doc.readyState === 'complete' || (pageWidth >= gScreenWidth && pageHeight >= gScreenHeight)) {
this._viewport.pageWidth = pageWidth;
this._viewport.pageHeight = pageHeight;
}
}
return this._viewport;