зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1014113 - Refine and enable zoom for find in page. r=margaret
Defines a viewport factor around the highlighted word May need more testing (See bug 1015395) --HG-- extra : rebase_source : 81f45a18f8ca8c9a3787522805933a1f801efc00
This commit is contained in:
Родитель
58e6ae0f93
Коммит
6f4b98405d
|
@ -150,8 +150,21 @@ var FindHelper = {
|
|||
this._targetTab.sendViewportUpdate();
|
||||
}
|
||||
} else {
|
||||
// Disabled until bug 1014113 is fixed
|
||||
// ZoomHelper.zoomToRect(aData.rect);
|
||||
// Defines the space around the highlighted element as a factor of the element's size.
|
||||
const spacingFactor = 6;
|
||||
|
||||
// We replace the start of the zoom rect to keep the highlighted word in the middle.
|
||||
// We divide this offset by two to consider a spacing on each side of the rect.
|
||||
let x = aData.rect.x + (aData.rect.width * (1 - spacingFactor)) / 2;
|
||||
let y = aData.rect.y + (aData.rect.height * (1 - spacingFactor)) / 2;
|
||||
|
||||
let rect = new Rect(Math.max(x, 0),
|
||||
Math.max(y, 0),
|
||||
// we use a bigger viewport than just the highlighted word
|
||||
aData.rect.width * spacingFactor,
|
||||
aData.rect.height * spacingFactor);
|
||||
|
||||
ZoomHelper.zoomToRect(rect);
|
||||
this._viewportChanged = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,6 +123,11 @@ var ZoomHelper = {
|
|||
* if it is really tall.
|
||||
*/
|
||||
zoomToRect: function(aRect, aClickY = -1) {
|
||||
if(aRect.isEmpty()) {
|
||||
// Protect from empty or negative-sized rects & potentials NaN in following calculations
|
||||
return;
|
||||
}
|
||||
|
||||
let viewport = BrowserApp.selectedTab.getViewport();
|
||||
|
||||
let rect = {
|
||||
|
|
Загрузка…
Ссылка в новой задаче