Bug 712130 - Simplify focus stealing prevention for autofocus. r=bz

Remove redundant check already implied by earlier condition: If the focus
manager's focused content is in our document, all parent windows including the
root window must have their focused node set to non-null.

MozReview-Commit-ID: CryGb6mfczK

--HG--
extra : rebase_source : c16e73b159be0fd82da624ab971f6b026eb01ae6
This commit is contained in:
decltype 2018-01-12 00:17:58 +01:00
Родитель 222776c45b
Коммит 8224ce038d
1 изменённых файлов: 3 добавлений и 16 удалений

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

@ -9982,27 +9982,14 @@ public:
NS_IMETHOD Run() override
{
nsFocusManager* fm = nsFocusManager::GetFocusManager();
if (!fm) {
return NS_ERROR_NULL_POINTER;
}
nsIDocument* document = mElement->OwnerDoc();
// Don't steal focus from the user.
if (mRootWindow->GetFocusedNode()) {
return NS_OK;
}
// If something is focused in the same document, ignore autofocus.
if (!fm->GetFocusedContent() ||
fm->GetFocusedContent()->OwnerDoc() != document) {
mozilla::ErrorResult rv;
mElement->Focus(rv);
return rv.StealNSResult();
}
return NS_OK;
mozilla::ErrorResult rv;
mElement->Focus(rv);
return rv.StealNSResult();
}
private:
nsCOMPtr<Element> mElement;