Bug 990259 - Double-tap zoom does not work when text reflow is enabled. r=margaret.leibovic

Fix regression introduced in 958111
This commit is contained in:
Robin Ricard 2014-04-07 15:37:00 +02:00
parent 22d2b7e0fc
commit fcd12f6783
2 changed files with 19 additions and 17 deletions

View File

@ -77,7 +77,7 @@ var FindHelper = {
this._targetTab.sendViewportUpdate();
}
} else {
ZoomHelper.zoomToRect(aData.rect, -1, false, true);
ZoomHelper.zoomToRect(aData.rect);
this._viewportChanged = true;
}
}

View File

@ -81,22 +81,19 @@ var ZoomHelper = {
*/
zoomToElement: function(aElement, aClickY = -1, aCanZoomOut = true, aCanScrollHorizontally = true) {
let rect = ElementTouchHelper.getBoundingContentRect(aElement);
ZoomHelper.zoomToRect(rect, aClickY, aCanZoomOut, aCanScrollHorizontally);
},
zoomToRect: function(aRect, aClickY = -1, aCanZoomOut = true, aCanScrollHorizontally = true) {
const margin = 15;
if(!aRect.h || !aRect.w) {
aRect.h = aRect.height;
aRect.w = aRect.width;
if(!rect.h || !rect.w) {
rect.h = rect.height;
rect.w = rect.width;
}
let viewport = BrowserApp.selectedTab.getViewport();
let bRect = new Rect(aCanScrollHorizontally ? Math.max(viewport.cssPageLeft, aRect.x - margin) : viewport.cssX,
aRect.y,
aCanScrollHorizontally ? aRect.w + 2 * margin : viewport.cssWidth,
aRect.h);
let bRect = new Rect(aCanScrollHorizontally ? Math.max(viewport.cssPageLeft, rect.x - margin) : viewport.cssX,
rect.y,
aCanScrollHorizontally ? rect.w + 2 * margin : viewport.cssWidth,
rect.h);
// constrict the rect to the screen's right edge
bRect.width = Math.min(bRect.width, viewport.cssPageRight - bRect.x);
@ -120,13 +117,18 @@ var ZoomHelper = {
return;
}
ZoomHelper.zoomToRect(bRect, aClickY);
},
zoomToRect: function(aRect, aClickY = -1) {
let viewport = BrowserApp.selectedTab.getViewport();
let rect = {};
rect.type = "Browser:ZoomToRect";
rect.x = bRect.x;
rect.y = bRect.y;
rect.w = bRect.width;
rect.h = Math.min(bRect.width * viewport.cssHeight / viewport.cssWidth, bRect.height);
rect.x = aRect.x;
rect.y = aRect.y;
rect.w = aRect.width;
rect.h = Math.min(aRect.width * viewport.cssHeight / viewport.cssWidth, aRect.height);
if (aClickY >= 0) {
// if the block we're zooming to is really tall, and we want to keep a particular
@ -134,7 +136,7 @@ var ZoomHelper = {
// the 1.2 multiplier is just a little fuzz to compensate for bRect including horizontal
// margins but not vertical ones.
let cssTapY = viewport.cssY + aClickY;
if ((bRect.height > rect.h) && (cssTapY > rect.y + (rect.h * 1.2))) {
if ((aRect.height > rect.h) && (cssTapY > rect.y + (rect.h * 1.2))) {
rect.y = cssTapY - (rect.h / 2);
}
}
@ -145,4 +147,4 @@ var ZoomHelper = {
sendMessageToJava(rect);
},
};
};