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
Родитель f90c630c44
Коммит 7d8500d645
1 изменённых файлов: 6 добавлений и 8 удалений

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

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