Bug 689939 - Infobar disappears when node fills top and bottom of screen during page zoom in highlighter; r=rcampbell

This commit is contained in:
Paul Rouget 2011-12-07 16:20:36 +01:00
Родитель 2f9304936d
Коммит 5073fb620d
2 изменённых файлов: 33 добавлений и 29 удалений

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

@ -160,6 +160,7 @@ Highlighter.prototype = {
this.transitionDisabler = null; this.transitionDisabler = null;
this.computeZoomFactor();
this.handleResize(); this.handleResize();
}, },
@ -441,16 +442,10 @@ Highlighter.prototype = {
return this._highlighting; // same rectangle return this._highlighting; // same rectangle
} }
// get page zoom factor, if any
let zoom =
this.win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils)
.screenPixelsPerCSSPixel;
// adjust rect for zoom scaling // adjust rect for zoom scaling
let aRectScaled = {}; let aRectScaled = {};
for (let prop in aRect) { for (let prop in aRect) {
aRectScaled[prop] = aRect[prop] * zoom; aRectScaled[prop] = aRect[prop] * this.zoom;
} }
if (aRectScaled.left >= 0 && aRectScaled.top >= 0 && if (aRectScaled.left >= 0 && aRectScaled.top >= 0 &&
@ -545,7 +540,7 @@ Highlighter.prototype = {
if (rect.top < this.nodeInfo.barHeight) { if (rect.top < this.nodeInfo.barHeight) {
// No. Can we move the toolbar under the node? // No. Can we move the toolbar under the node?
if (rect.top + rect.height + if (rect.top + rect.height +
this.nodeInfo.barHeight > this.win.innerHeight) { this.nodeInfo.barHeight > winHeight) {
// No. Let's move it inside. // No. Let's move it inside.
this.nodeInfo.container.style.top = rect.top + "px"; this.nodeInfo.container.style.top = rect.top + "px";
this.nodeInfo.container.setAttribute("position", "overlap"); this.nodeInfo.container.setAttribute("position", "overlap");
@ -569,8 +564,8 @@ Highlighter.prototype = {
left = 0; left = 0;
this.nodeInfo.container.setAttribute("hide-arrow", "true"); this.nodeInfo.container.setAttribute("hide-arrow", "true");
} else { } else {
if (left + barWidth > this.win.innerWidth) { if (left + barWidth > winWidth) {
left = this.win.innerWidth - barWidth; left = winWidth - barWidth;
this.nodeInfo.container.setAttribute("hide-arrow", "true"); this.nodeInfo.container.setAttribute("hide-arrow", "true");
} else { } else {
this.nodeInfo.container.removeAttribute("hide-arrow"); this.nodeInfo.container.removeAttribute("hide-arrow");
@ -653,6 +648,16 @@ Highlighter.prototype = {
return !INSPECTOR_INVISIBLE_ELEMENTS[nodeName]; return !INSPECTOR_INVISIBLE_ELEMENTS[nodeName];
}, },
/**
* Store page zoom factor.
*/
computeZoomFactor: function Highlighter_computeZoomFactor() {
this.zoom =
this.win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils)
.screenPixelsPerCSSPixel;
},
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
//// Event Handling //// Event Handling
@ -691,6 +696,7 @@ Highlighter.prototype = {
this.handleMouseMove(aEvent); this.handleMouseMove(aEvent);
break; break;
case "resize": case "resize":
this.computeZoomFactor();
this.brieflyDisableTransitions(); this.brieflyDisableTransitions();
this.handleResize(aEvent); this.handleResize(aEvent);
break; break;

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

@ -153,29 +153,27 @@ function finishTestComparisons()
.QueryInterface(Ci.nsIMarkupDocumentViewer); .QueryInterface(Ci.nsIMarkupDocumentViewer);
contentViewer.fullZoom = 2; contentViewer.fullZoom = 2;
// check what zoom factor we're at, should be 2 executeSoon(function() {
let zoom = // check what zoom factor we're at, should be 2
InspectorUI.win.QueryInterface(Components.interfaces.nsIInterfaceRequestor) let zoom = InspectorUI.highlighter.zoom;
.getInterface(Components.interfaces.nsIDOMWindowUtils) is(zoom, 2, "zoom is 2?");
.screenPixelsPerCSSPixel;
is(zoom, 2, "zoom is 2?"); // simulate the zoomed dimensions of the div element
let divDims = div.getBoundingClientRect();
let divWidth = divDims.width * zoom;
let divHeight = divDims.height * zoom;
// simulate the zoomed dimensions of the div element // now zoomed, get new dimensions of transparent veil box over element
let divDims = div.getBoundingClientRect(); let veilBoxDims = InspectorUI.highlighter.veilTransparentBox.getBoundingClientRect();
let divWidth = divDims.width * zoom; let veilBoxWidth = veilBoxDims.width;
let divHeight = divDims.height * zoom; let veilBoxHeight = veilBoxDims.height;
// now zoomed, get new dimensions of transparent veil box over element is(veilBoxWidth, divWidth, "transparent veil box width matches width of element (2x zoom)");
let veilBoxDims = InspectorUI.highlighter.veilTransparentBox.getBoundingClientRect(); is(veilBoxHeight, divHeight, "transparent veil box height matches width of element (2x zoom)");
let veilBoxWidth = veilBoxDims.width;
let veilBoxHeight = veilBoxDims.height;
is(veilBoxWidth, divWidth, "transparent veil box width matches width of element (2x zoom)"); doc = h1 = div = null;
is(veilBoxHeight, divHeight, "transparent veil box height matches width of element (2x zoom)"); executeSoon(finishUp);
});
doc = h1 = div = null;
executeSoon(finishUp);
} }
function finishUp() { function finishUp() {