Bug 681718 - Fix JS errors from text selection when long-tapping on local pages [r=mfinkle]

This commit is contained in:
Matt Brubeck 2011-08-24 12:38:40 -07:00
Родитель 33126066bd
Коммит 2c9c9acd1a
1 изменённых файлов: 7 добавлений и 1 удалений

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

@ -1365,7 +1365,7 @@ var SelectionHandler = {
elem = utils.elementFromPoint(x, y, true, false);
}
if (!elem)
return;
return {};
return { contentWindow: elem.ownerDocument.defaultView, offset: offset };
},
@ -1384,6 +1384,9 @@ var SelectionHandler = {
let x = json.x - scrollOffset.x;
let y = json.y - scrollOffset.y;
let { contentWindow: contentWindow, offset: offset } = this.getCurrentWindowAndOffset(x, y, scrollOffset);
if (!contentWindow)
return;
let currentDocShell = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShell);
// Remove any previous selected or created ranges. Tapping anywhere on a
@ -1498,6 +1501,9 @@ var SelectionHandler = {
this.cache.rect = this._extractFromRange(range, this.cache.offset).rect;
break;
case "Browser:SelectionMeasure": {
if (!this.contentWindow)
return;
let selection = this.contentWindow.getSelection();
let range = selection.getRangeAt(0).QueryInterface(Ci.nsIDOMNSRange);
if (!range)