Bug 866461 - Fix constant viewport remeasuring on bing.com. r=mfinkle

Fix some cases where the viewport was remeasured when it was unnecessary that
was causing bing.com to get caught in re-measuring cycles.
This commit is contained in:
Chris Lord 2013-05-10 17:35:01 +01:00
Родитель 92d057b18c
Коммит 01a01172fc
1 изменённых файлов: 25 добавлений и 6 удалений

Просмотреть файл

@ -3055,12 +3055,25 @@ Tab.prototype = {
// within the screen size, so remeasure when the page size remains within
// the threshold of screen + margins, in case it's sizing itself relative
// to the viewport.
if (((Math.round(viewport.pageBottom - viewport.pageTop)
<= gScreenHeight + gViewportMargins.top + gViewportMargins.bottom)
!= this.viewportExcludesVerticalMargins) ||
((Math.round(viewport.pageRight - viewport.pageLeft)
<= gScreenWidth + gViewportMargins.left + gViewportMargins.right)
!= this.viewportExcludesHorizontalMargins)) {
let hasHorizontalMargins = gViewportMargins.left > 0 || gViewportMargins.right > 0;
let hasVerticalMargins = gViewportMargins.top > 0 || gViewportMargins.bottom > 0;
let pageHeightGreaterThanScreenHeight, pageWidthGreaterThanScreenWidth;
if (hasHorizontalMargins) {
pageWidthGreaterThanScreenWidth =
Math.round(viewport.pageRight - viewport.pageLeft)
> gScreenWidth + gViewportMargins.left + gViewportMargins.right;
}
if (hasVerticalMargins) {
pageHeightGreaterThanScreenHeight =
Math.round(viewport.pageBottom - viewport.pageTop)
> gScreenHeight + gViewportMargins.top + gViewportMargins.bottom;
}
if ((hasHorizontalMargins
&& (pageWidthGreaterThanScreenWidth != this.viewportExcludesHorizontalMargins)) ||
(hasVerticalMargins
&& (pageHeightGreaterThanScreenHeight != this.viewportExcludesVerticalMargins))) {
if (!this.viewportMeasureCallback) {
this.viewportMeasureCallback = setTimeout(function() {
this.viewportMeasureCallback = null;
@ -3074,6 +3087,12 @@ Tab.prototype = {
}
}.bind(this), kViewportRemeasureThrottle);
}
} else if (this.viewportMeasureCallback) {
// If the page changed size twice since we last measured the viewport and
// the latest size change reveals we don't need to remeasure, cancel any
// pending remeasure.
clearTimeout(this.viewportMeasureCallback);
this.viewportMeasureCallback = null;
}
}
},