Bug 738641 - Account for rounding errors when reporting page size from JS to Java. r=Cwiiis a=android-only

This commit is contained in:
Kartikaya Gupta 2012-04-30 15:50:50 -04:00
parent 1c4c90c1ae
commit 34ea328f22

View File

@ -1934,8 +1934,13 @@ Tab.prototype = {
* Avoid sending page sizes of less than screen size before we hit DOMContentLoaded, because * 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, * 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. * send updates regardless of page size; we'll zoom to fit the content as needed.
*
* Also, we need to compare the page size returned from getPageSize (in CSS pixels) to the floored
* screen size in CSS pixels because the page size returned from getPageSize may also be floored.
*/ */
if (doc.readyState === 'complete' || (pageWidth >= gScreenWidth && pageHeight >= gScreenHeight)) { let pageLargerThanScreen = (cssPageWidth >= Math.floor(viewport.cssWidth))
&& (cssPageHeight >= Math.floor(viewport.cssHeight));
if (doc.readyState === 'complete' || pageLargerThanScreen) {
viewport.cssPageWidth = cssPageWidth; viewport.cssPageWidth = cssPageWidth;
viewport.cssPageHeight = cssPageHeight; viewport.cssPageHeight = cssPageHeight;
viewport.pageWidth = pageWidth; viewport.pageWidth = pageWidth;