Bug 524526: Zooming sometimes zooms to incorrect positions [r=mark.finkle]

This commit is contained in:
Benjamin Stover 2009-10-29 18:55:56 -04:00
Родитель 94aef83b41
Коммит 77b7d0f07c
2 изменённых файлов: 34 добавлений и 8 удалений

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

@ -279,7 +279,6 @@ BrowserView.prototype = {
setViewportDimensions: function setViewportDimensions(width, height, causedByZoom) {
let bvs = this._browserViewportState;
if (!bvs)
return;
@ -298,12 +297,10 @@ BrowserView.prototype = {
setZoomLevel: function setZoomLevel(zl) {
let bvs = this._browserViewportState;
if (!bvs)
return;
let newZL = BrowserView.Util.clampZoomLevel(zl);
if (newZL != bvs.zoomLevel) {
let browserW = this.viewportToBrowser(bvs.viewportRect.right);
let browserH = this.viewportToBrowser(bvs.viewportRect.bottom);
@ -311,7 +308,7 @@ BrowserView.prototype = {
this.setViewportDimensions(this.browserToViewport(browserW),
this.browserToViewport(browserH),
true);
this.zoomChanged = true;
bvs.zoomChanged = true;
}
},
@ -352,11 +349,13 @@ BrowserView.prototype = {
commitBatchOperation: function commitBatchOperation() {
let bops = this._batchOps;
if (bops.length == 0)
return;
let opState = bops.pop();
// XXX If stack is not empty, this just assigns opState variables to the next one
// on top. Why then have a stack of these booleans?
this._viewportChanged(opState.viewportSizeChanged, opState.dirtyAll);
this.resumeRendering();
},
@ -658,6 +657,20 @@ BrowserView.prototype = {
BrowserView.Util.resizeContainerToViewport(this._container, bvs.viewportRect);
},
/**
* Force any pending viewport changes to occur. Batch operations will still be on the
* stack so commitBatchOperation is still necessary afterwards.
*/
forceViewportChange: function forceViewportChange() {
let bops = this._batchOps;
if (bops.length > 0) {
let opState = bops[bops.length - 1];
this._applyViewportChanges(opState.viewportSizeChanged, opState.dirtyAll);
opState.viewportSizeChanged = false;
opState.dirtyAll = false;
}
},
// -----------------------------------------------------------
// Private instance methods
//
@ -676,6 +689,10 @@ BrowserView.prototype = {
return;
}
this._applyViewportChanges(viewportSizeChanged, dirtyAll);
},
_applyViewportChanges: function _applyViewportChanges(viewportSizeChanged, dirtyAll) {
let bvs = this._browserViewportState;
if (bvs) {
BrowserView.Util.resizeContainerToViewport(this._container, bvs.viewportRect);

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

@ -407,10 +407,14 @@ var Browser = {
// Tell the UI to resize the browser controls before calling updateSize
BrowserUI.sizeControls(w, h);
bv.zoomToPage();
Browser.hideSidebars();
// zoomChanged gets set to true, but user did not change zooming
bv._browserViewportState.zoomChanged = false;
// hidesidebars calls bv.onAfterVisibleMove();
Browser.hideSidebars();
bv.commitBatchOperation();
}
@ -1030,9 +1034,11 @@ var Browser = {
Browser.hideSidebars();
Browser.hideTitlebar();
bv.setZoomLevel(zoomLevel);
bv.forceViewportChange(); // ensure container is resized for scrollTo
Browser.forceChromeReflow();
Browser.contentScrollboxScroller.scrollTo(scrollX, scrollY);
bv.onAfterVisibleMove();
bv.renderNow();
bv.renderNow(); // during loading, make sure new zoom level is rendered
bv.commitOffscreenOperation();
},
@ -2449,6 +2455,9 @@ Tab.prototype = {
// Only fit page if user hasn't started zooming around and this is a page that
// isn't being restored.
bv.zoomToPage();
// zoomChanged gets set to true, but user did not change zooming
this._browserViewportState.zoomChanged = false;
}
}