Skip to content

Commit

Permalink
[1.10] Issue 5136: use "backdrag" attribute for quickinfobox
Browse files Browse the repository at this point in the history
  • Loading branch information
nightwing committed Feb 5, 2012
1 parent 61d64ba commit c1e97f9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 90 deletions.
6 changes: 2 additions & 4 deletions extension/content/firebug/firebugOverlay.xul
Expand Up @@ -22,10 +22,8 @@
<tooltip id="fbTooltip" class="fbURLMenuItem"
onpopupshowing="return Firebug.chrome.onTooltipShowing(event);"/>

<panel id="fbQuickInfoPanel" width="210" noautohide="true" noautofocus="true"
onmousedown="Firebug.Inspector.quickInfoBoxHandler(event);"
onmouseover="Firebug.Inspector.quickInfoBoxHandler(event);"
onmouseout="Firebug.Inspector.quickInfoBoxHandler(event);">
<panel id="fbQuickInfoPanel" width="210" noautofocus="true"
ignorekeys="true" backdrag="true">
<vbox></vbox>
</panel>

Expand Down
109 changes: 23 additions & 86 deletions extension/content/firebug/html/inspector.js
Expand Up @@ -783,8 +783,11 @@ Firebug.Inspector = Obj.extend(Firebug.Module,
this.highlightObject(null);
this.defaultHighlighter = value ? getHighlighter("boxModel") : getHighlighter("frame");
}
else if(name == "showQuickInfoBox")
else if (name == "showQuickInfoBox")
{
if (quickInfoBox.boxEnabled && !value)
quickInfoBox.hide();

quickInfoBox.boxEnabled = value;
}
},
Expand Down Expand Up @@ -821,23 +824,10 @@ Firebug.Inspector = Obj.extend(Firebug.Module,
*/
hideQuickInfoBox: function()
{
var qiBox = Firebug.chrome.$('fbQuickInfoPanel');

if (qiBox.state==="open")
quickInfoBox.hide();
quickInfoBox.hide();

this.inspectNode(null);
},

/**
* Pass all quick info box events to quickInfoBox.handleEvent() for handling.
* @param {Event} event Event to handle
*/
quickInfoBoxHandler: function(event)
{
quickInfoBox.handleEvent(event);
}

});

// ********************************************************************************************* //
Expand Down Expand Up @@ -1061,8 +1051,6 @@ var quickInfoBox =
dragging: false,
storedX: null,
storedY: null,
prevX: null,
prevY: null,

show: function(element)
{
Expand All @@ -1083,11 +1071,19 @@ var quickInfoBox =

if (qiBox.state==="closed")
{
qiBox.hidePopup();

this.storedX = this.storedX || Firefox.getElementById('content').tabContainer.boxObject.screenX + 5;
this.storedY = this.storedY || Firefox.getElementById('content').tabContainer.boxObject.screenY + 35;

// Dynamically set noautohide to avoid mozilla bug 545265.
if (!this.noautohideAdded)
{
this.noautohideAdded = true;
qiBox.addEventListener("popupshowing", function runOnce()
{
qiBox.removeEventListener("popupshowing", runOnce, false);
qiBox.setAttribute("noautohide", true);
}, false);
}
qiBox.openPopupAtScreen(this.storedX, this.storedY, false);
}

Expand Down Expand Up @@ -1117,75 +1113,16 @@ var quickInfoBox =
hide: function()
{
// if mouse is over panel defer hiding to mouseout to not cause flickering
if (this.mouseover || this.dragging)
{
this.needsToHide = true;
return;
}

var qiBox = Firebug.chrome.$('fbQuickInfoPanel');
this.prevX = null;
this.prevY = null;
this.needsToHide = false;
qiBox.hidePopup();
},
if (qiBox.state==="closed")
return;

handleEvent: function(event)
{
switch (event.type)
{
case "mousemove":
if(!this.dragging)
return;
if (qiBox.mozMatchesSelector(":hover"))
return;

var diffX, diffY,
boxX = this.qiBox.screenX,
boxY = this.qiBox.screenY,
x = event.screenX,
y = event.screenY;

diffX = x - this.prevX;
diffY = y - this.prevY;

this.qiBox.moveTo(boxX + diffX, boxY + diffY);

this.prevX = x;
this.prevY = y;
this.storedX = boxX;
this.storedY = boxY;
break;
case "mousedown":
this.qiPanel = Firebug.chrome.$('fbQuickInfoPanel');
this.qiBox = this.qiPanel.boxObject;
Events.addEventListener(this.qiPanel, "mousemove", this, true);
Events.addEventListener(this.qiPanel, "mouseup", this, true);
this.dragging = true;
this.prevX = event.screenX;
this.prevY = event.screenY;
break;
case "mouseup":
Events.removeEventListener(this.qiPanel, "mousemove", this, true);
Events.removeEventListener(this.qiPanel, "mouseup", this, true);
this.qiPanel = this.qiBox = null;
this.prevX = this.prevY = null;
this.dragging = false;
break;
// this is a hack to find when mouse enters and leaves panel
// it requires that #fbQuickInfoPanel have border
case "mouseover":
if(this.dragging)
return;
this.mouseover = true;
break;
case "mouseout":
if(this.dragging)
return;
this.mouseover = false;
// if hiding was defered because mouse was over panel hide it
if (this.needsToHide && event.target.nodeName == 'panel')
this.hide();
break;
}
this.storedX = qiBox.boxObject.screenX;
this.storedY = qiBox.boxObject.screenY;
qiBox.hidePopup();
},

addRows: function(domBase, vbox, attribs, computedStyle)
Expand Down Expand Up @@ -1218,7 +1155,7 @@ var quickInfoBox =
lab.setAttribute("class", "fbQuickInfoName");
lab.setAttribute("value", attribs[i]);
hbox.appendChild(lab);
desc = document.createElement("description");
desc = document.createElement("label");
desc.setAttribute("class", "fbQuickInfoValue");
desc.appendChild(document.createTextNode(": " + value));
hbox.appendChild(desc);
Expand Down

0 comments on commit c1e97f9

Please sign in to comment.