Bug 777450 - Part 1: Clean up general context menu code. r=wesj

This commit is contained in:
Michael Comella 2012-08-16 17:35:20 -04:00
parent 9037e4a2d2
commit 6fe8ff3f82

View File

@ -1361,19 +1361,17 @@ var NativeWindow = {
if (!rootElement)
rootElement = ElementTouchHelper.anyElementFromPoint(BrowserApp.selectedBrowser.contentWindow, aX, aY)
this.menuitems = null;
this.menuitems = {};
let menuitemsSet = false;
let element = rootElement;
if (!element)
return;
while (element) {
for each (let item in this.items) {
// since we'll have to spin through this for each element, check that
// it is not already in the list
if ((!this.menuitems || !this.menuitems[item.id]) && item.matches(element, aX, aY)) {
if (!this.menuitems)
this.menuitems = {};
if (!this.menuitems[item.id] && item.matches(element)) {
this.menuitems[item.id] = item;
menuitemsSet = true;
}
}
@ -1383,7 +1381,7 @@ var NativeWindow = {
}
// only send the contextmenu event to content if we are planning to show a context menu (i.e. not on every long tap)
if (this.menuitems) {
if (menuitemsSet) {
let event = rootElement.ownerDocument.createEvent("MouseEvent");
event.initMouseEvent("contextmenu", true, true, content,
0, aX, aY, aX, aY, false, false, false, false,
@ -2188,7 +2186,7 @@ Tab.prototype = {
}
};
sendMessageToJava(message);
dump("Handled load error: " + e)
dump("Handled load error: " + e);
}
}
},