Bug 1456588 part 6. Change nsXULCommandDispatcher::GetRootFocusedContentAndWindow to return Element. r=enndeakin

This commit is contained in:
Boris Zbarsky 2018-04-26 10:37:47 -04:00
Родитель a3a6206b20
Коммит 86835e49c5
2 изменённых файлов: 13 добавлений и 8 удалений

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

@ -99,7 +99,7 @@ nsXULCommandDispatcher::GetWindowRoot()
return nullptr;
}
nsIContent*
Element*
nsXULCommandDispatcher::GetRootFocusedContentAndWindow(nsPIDOMWindowOuter** aWindow)
{
*aWindow = nullptr;
@ -126,22 +126,20 @@ nsXULCommandDispatcher::GetFocusedElement(Element** aElement)
*aElement = nullptr;
nsCOMPtr<nsPIDOMWindowOuter> focusedWindow;
nsIContent* focusedContent =
RefPtr<Element> focusedContent =
GetRootFocusedContentAndWindow(getter_AddRefs(focusedWindow));
if (focusedContent) {
CallQueryInterface(focusedContent, aElement);
// Make sure the caller can access the focused element.
nsINode* node = *aElement;
if (!node || !nsContentUtils::SubjectPrincipalOrSystemIfNativeCaller()->Subsumes(node->NodePrincipal())) {
if (!nsContentUtils::SubjectPrincipalOrSystemIfNativeCaller()->
Subsumes(focusedContent->NodePrincipal())) {
// XXX This might want to return null, but we use that return value
// to mean "there is no focused element," so to be clear, throw an
// exception.
NS_RELEASE(*aElement);
return NS_ERROR_DOM_SECURITY_ERR;
}
}
focusedContent.forget(aElement);
return NS_OK;
}

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

@ -23,6 +23,12 @@
class nsIDOMElement;
class nsPIWindowRoot;
namespace mozilla {
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla
class nsXULCommandDispatcher : public nsIDOMXULCommandDispatcher,
public nsSupportsWeakReference
{
@ -43,7 +49,8 @@ protected:
already_AddRefed<nsPIWindowRoot> GetWindowRoot();
nsIContent* GetRootFocusedContentAndWindow(nsPIDOMWindowOuter** aWindow);
mozilla::dom::Element*
GetRootFocusedContentAndWindow(nsPIDOMWindowOuter** aWindow);
nsCOMPtr<nsIDocument> mDocument;