Bug 775372 - Fix exceptions in _cancelTapHighlight when the highlight element is from a dead window [r=margaret]

This commit is contained in:
Matt Brubeck 2012-07-27 16:03:18 -07:00
parent 7a2dbdcf4c
commit 780d66b2f3

View File

@ -3477,6 +3477,10 @@ var BrowserEventHandler = {
_doTapHighlight: function _doTapHighlight(aElement) {
this._cancelTapHighlight();
this._highlightTimeout = setTimeout(function(self) {
// If aElement is from a dead window, defaultView will be null.
if (!aElement.ownerDocument.defaultView)
return;
DOMUtils.setContentState(aElement, kStateActive);
self._highlightElement = aElement;
}, kTapHighlightDelay, this);
@ -3491,13 +3495,19 @@ var BrowserEventHandler = {
if (!this._highlightElement)
return;
let ownerDocument = this._highlightElement.ownerDocument;
this._highlightElement = null;
// If _highlightElement is from a dead window, defaultView will be null.
if (!ownerDocument.defaultView)
return;
// If the active element is in a sub-frame, we need to make that frame's document
// active to remove the element's active state.
if (this._highlightElement.ownerDocument != BrowserApp.selectedBrowser.contentWindow.document)
DOMUtils.setContentState(this._highlightElement.ownerDocument.documentElement, kStateActive);
if (ownerDocument != BrowserApp.selectedBrowser.contentWindow.document)
DOMUtils.setContentState(ownerDocument.documentElement, kStateActive);
DOMUtils.setContentState(BrowserApp.selectedBrowser.contentWindow.document.documentElement, kStateActive);
this._highlightElement = null;
},
_updateLastPosition: function(x, y, dx, dy) {