Bug 301357: Simplify context menu selection code, patch by Martijn Wargers <martijn.martijn@gmail.com>, r=mconnor

This commit is contained in:
gavin%gavinsharp.com 2005-08-24 22:15:53 +00:00
Родитель 33db3e9263
Коммит 2741b2d6df
1 изменённых файлов: 1 добавлений и 17 удалений

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

@ -4697,23 +4697,7 @@ nsContextMenu.prototype = {
// Returns true if anything is selected.
isContentSelection : function() {
var focusedWindow = document.commandDispatcher.focusedWindow;
var selection = focusedWindow.getSelection();
if (selection.rangeCount == 0) {
return false;
}
var rangeFragment = selection.getRangeAt(0).cloneContents();
if (rangeFragment.childNodes.length == 0) {
return false;
}
// The selection object may also report an empty text node if there is no selection.
var node = rangeFragment.childNodes[0];
if (rangeFragment.childNodes.length == 1 &&
node.nodeType == node.TEXT_NODE &&
node.nodeValue.length == 0) {
return false;
}
return true;
return !document.commandDispatcher.focusedWindow.getSelection().isCollapsed;
},
searchSelected : function( charlen ) {