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,12 +153,9 @@ function finishTestComparisons()
.QueryInterface(Ci.nsIMarkupDocumentViewer); .QueryInterface(Ci.nsIMarkupDocumentViewer);
contentViewer.fullZoom = 2; contentViewer.fullZoom = 2;
executeSoon(function() {
// check what zoom factor we're at, should be 2 // check what zoom factor we're at, should be 2
let zoom = let zoom = InspectorUI.highlighter.zoom;
InspectorUI.win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils)
.screenPixelsPerCSSPixel;
is(zoom, 2, "zoom is 2?"); is(zoom, 2, "zoom is 2?");
// simulate the zoomed dimensions of the div element // simulate the zoomed dimensions of the div element
@ -176,6 +173,7 @@ function finishTestComparisons()
doc = h1 = div = null; doc = h1 = div = null;
executeSoon(finishUp); executeSoon(finishUp);
});
} }
function finishUp() { function finishUp() {