mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
backout 79bf6ebacb09 for causing 1070072
This commit is contained in:
parent
e132000043
commit
debf1c8aa2
@ -78,7 +78,7 @@ var FindHelper = {
|
||||
}
|
||||
} else {
|
||||
// Disabled until bug 1014113 is fixed
|
||||
// ZoomHelper.zoomToRect(aData.rect);
|
||||
//ZoomHelper.zoomToRect(aData.rect, -1, false, true);
|
||||
this._viewportChanged = true;
|
||||
}
|
||||
}
|
||||
|
@ -81,16 +81,24 @@ var ZoomHelper = {
|
||||
*/
|
||||
zoomToElement: function(aElement, aClickY = -1, aCanZoomOut = true, aCanScrollHorizontally = true) {
|
||||
let rect = ElementTouchHelper.getBoundingContentRect(aElement);
|
||||
ZoomHelper.zoomToRect(rect, aClickY, aCanZoomOut, aCanScrollHorizontally, aElement);
|
||||
},
|
||||
|
||||
zoomToRect: function(aRect, aClickY = -1, aCanZoomOut = true, aCanScrollHorizontally = true, aElement) {
|
||||
const margin = 15;
|
||||
|
||||
if(!aRect.h || !aRect.w) {
|
||||
aRect.h = aRect.height;
|
||||
aRect.w = aRect.width;
|
||||
}
|
||||
|
||||
let viewport = BrowserApp.selectedTab.getViewport();
|
||||
rect = new Rect(aCanScrollHorizontally ? Math.max(viewport.cssPageLeft, rect.x - margin) : viewport.cssX,
|
||||
rect.y,
|
||||
aCanScrollHorizontally ? rect.w + 2 * margin : viewport.cssWidth,
|
||||
rect.h);
|
||||
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);
|
||||
// constrict the rect to the screen's right edge
|
||||
rect.width = Math.min(rect.width, viewport.cssPageRight - rect.x);
|
||||
bRect.width = Math.min(bRect.width, viewport.cssPageRight - bRect.x);
|
||||
|
||||
// if the rect is already taking up most of the visible area and is stretching the
|
||||
// width of the page, then we want to zoom out instead.
|
||||
@ -98,44 +106,37 @@ var ZoomHelper = {
|
||||
if (BrowserEventHandler.mReflozPref) {
|
||||
let zoomFactor = BrowserApp.selectedTab.getZoomToMinFontSize(aElement);
|
||||
|
||||
rect.width = zoomFactor <= 1.0 ? rect.width : gScreenWidth / zoomFactor;
|
||||
rect.height = zoomFactor <= 1.0 ? rect.height : rect.height / zoomFactor;
|
||||
if (zoomFactor == 1.0 || ZoomHelper.isRectZoomedIn(rect, viewport)) {
|
||||
bRect.width = zoomFactor <= 1.0 ? bRect.width : gScreenWidth / zoomFactor;
|
||||
bRect.height = zoomFactor <= 1.0 ? bRect.height : bRect.height / zoomFactor;
|
||||
if (zoomFactor == 1.0 || ZoomHelper.isRectZoomedIn(bRect, viewport)) {
|
||||
if (aCanZoomOut) {
|
||||
ZoomHelper.zoomOut();
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else if (ZoomHelper.isRectZoomedIn(rect, viewport)) {
|
||||
} else if (ZoomHelper.isRectZoomedIn(bRect, viewport)) {
|
||||
if (aCanZoomOut) {
|
||||
ZoomHelper.zoomOut();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ZoomHelper.zoomToRect(rect, aClickY);
|
||||
}
|
||||
},
|
||||
|
||||
/* Zoom to a specific part of the screen defined by a rect,
|
||||
* optionally keeping a particular part of it in view
|
||||
* if it is really tall.
|
||||
*/
|
||||
zoomToRect: function(aRect, aClickY = -1) {
|
||||
let rect = new Rect(aRect.x,
|
||||
aRect.y,
|
||||
aRect.width,
|
||||
Math.min(aRect.width * viewport.cssHeight / viewport.cssWidth, aRect.height));
|
||||
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);
|
||||
|
||||
if (aClickY >= 0) {
|
||||
// if the block we're zooming to is really tall, and we want to keep a particular
|
||||
// part of it in view, then adjust the y-coordinate of the target rect accordingly.
|
||||
// the 1.2 multiplier is just a little fuzz to compensate for aRect including horizontal
|
||||
// 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 ((aRect.height > rect.h) && (cssTapY > rect.y + (rect.h * 1.2))) {
|
||||
if ((bRect.height > rect.h) && (cssTapY > rect.y + (rect.h * 1.2))) {
|
||||
rect.y = cssTapY - (rect.h / 2);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user