зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1456588 part 6. Change nsXULCommandDispatcher::GetRootFocusedContentAndWindow to return Element. r=enndeakin
This commit is contained in:
Родитель
a3a6206b20
Коммит
86835e49c5
|
@ -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;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче