From 7d8500d645a341e5838667c18f9c6d7b670f8b31 Mon Sep 17 00:00:00 2001 From: Michael Comella Date: Thu, 16 Aug 2012 17:35:20 -0400 Subject: [PATCH] Bug 777450 - Part 1: Clean up general context menu code. r=wesj --- mobile/android/chrome/content/browser.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index 8c16242cecfb..de0648173720 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -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); } } },