diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index de0648173720..9877b1875222 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -1388,8 +1388,7 @@ var NativeWindow = { 0, null); rootElement.ownerDocument.defaultView.addEventListener("contextmenu", this, false); rootElement.dispatchEvent(event); - } else { - // Otherwise, let the selection handler take over + } else if (SelectionHandler.canSelect(rootElement)) { SelectionHandler.startSelection(rootElement, aX, aY); } }, @@ -1643,6 +1642,14 @@ var SelectionHandler = { this._ignoreCollapsedSelection = false; }, + /** Returns true if the provided element can be selected in text selection, false otherwise. */ + canSelect: function sh_canSelect(aElement) { + return !(aElement instanceof Ci.nsIDOMHTMLButtonElement || + aElement instanceof Ci.nsIDOMHTMLEmbedElement || + aElement instanceof Ci.nsIDOMHTMLImageElement || + aElement instanceof Ci.nsIDOMHTMLMediaElement); + }, + // aX/aY are in top-level window browser coordinates startSelection: function sh_startSelection(aElement, aX, aY) { // Clear out any existing selection