author | Margaret Leibovic <margaret.leibovic@gmail.com> |
Fri, 19 Sep 2014 12:19:19 -0700 | |
changeset 206266 | 43bc9236ea468d1b9386970037f4d9ec96878f24 |
parent 206265 | 0a4ce94e4658cd937e94ad3f15e3eda25f58eeea |
child 206267 | a85324dfc960d9394bb751515584f37933823e49 |
child 206288 | dca3955efe70afc240cc71287e531ab3e16a5688 |
push id | 27519 |
push user | kwierso@gmail.com |
push date | Fri, 19 Sep 2014 23:56:39 +0000 |
treeherder | mozilla-central@a85324dfc960 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
bugs | 1070072 |
milestone | 35.0a1 |
backs out | 79bf6ebacb09d14111055dddc445330da32e1517 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
mobile/android/chrome/content/FindHelper.js | file | annotate | diff | comparison | revisions | |
mobile/android/chrome/content/ZoomHelper.js | file | annotate | diff | comparison | revisions |
--- a/mobile/android/chrome/content/FindHelper.js +++ b/mobile/android/chrome/content/FindHelper.js @@ -73,13 +73,13 @@ var FindHelper = { Cu.reportError("Warning: selected tab changed during find!"); // fall through and restore viewport on the initial tab anyway } this._targetTab.setViewport(JSON.parse(this._initialViewport)); this._targetTab.sendViewportUpdate(); } } else { // Disabled until bug 1014113 is fixed - // ZoomHelper.zoomToRect(aData.rect); + //ZoomHelper.zoomToRect(aData.rect, -1, false, true); this._viewportChanged = true; } } };
--- a/mobile/android/chrome/content/ZoomHelper.js +++ b/mobile/android/chrome/content/ZoomHelper.js @@ -76,71 +76,72 @@ var ZoomHelper = { dw > minDifference && dw < maxDifference); }, /* Zoom to an element, optionally keeping a particular part of it * in view if it is really tall. */ 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. if (aElement) { 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); } } if (rect.w > viewport.cssWidth || rect.h > viewport.cssHeight) { BrowserEventHandler.resetMaxLineBoxWidth(); }