Bug 1457156. Rename nsPIDOMWindow::mFocusedNode to reflect that it's an Element now. r=mccr8

This commit is contained in:
Boris Zbarsky 2018-04-26 15:28:30 -04:00
Родитель d46ebbf915
Коммит cb54ece0d5
10 изменённых файлов: 74 добавлений и 73 удалений

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

@ -9356,7 +9356,7 @@ public:
} }
// Don't steal focus from the user. // Don't steal focus from the user.
if (mTopWindow->GetFocusedNode()) { if (mTopWindow->GetFocusedElement()) {
return NS_OK; return NS_OK;
} }

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

@ -315,7 +315,7 @@ nsFocusManager::GetFocusedDescendant(nsPIDOMWindowOuter* aWindow,
nsPIDOMWindowOuter* window = aWindow; nsPIDOMWindowOuter* window = aWindow;
for (;;) { for (;;) {
*aFocusedWindow = window; *aFocusedWindow = window;
currentContent = window->GetFocusedNode(); currentContent = window->GetFocusedElement();
if (!currentContent || aSearchRange == eOnlyCurrentWindow) { if (!currentContent || aSearchRange == eOnlyCurrentWindow) {
break; break;
} }
@ -468,7 +468,7 @@ NS_IMETHODIMP nsFocusManager::SetFocusedWindow(mozIDOMWindowProxy* aWindowToFocu
// clear the focus. Otherwise, focus should already be in this frame, or // clear the focus. Otherwise, focus should already be in this frame, or
// already cleared. This ensures that focus will be in this frame and not // already cleared. This ensures that focus will be in this frame and not
// in a child. // in a child.
nsIContent* content = windowToFocus->GetFocusedNode(); nsIContent* content = windowToFocus->GetFocusedElement();
if (content) { if (content) {
if (nsCOMPtr<nsPIDOMWindowOuter> childWindow = GetContentWindow(content)) if (nsCOMPtr<nsPIDOMWindowOuter> childWindow = GetContentWindow(content))
ClearFocus(windowToFocus); ClearFocus(windowToFocus);
@ -625,7 +625,7 @@ nsFocusManager::ClearFocus(mozIDOMWindowProxy* aWindow)
} }
} }
else { else {
window->SetFocusedNode(nullptr); window->SetFocusedElement(nullptr);
} }
LOGFOCUS(("<<ClearFocus end>>")); LOGFOCUS(("<<ClearFocus end>>"));
@ -681,7 +681,7 @@ nsFocusManager::MoveCaretToFocus(mozIDOMWindowProxy* aWindow)
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
nsCOMPtr<nsPIDOMWindowOuter> window = nsPIDOMWindowOuter::From(aWindow); nsCOMPtr<nsPIDOMWindowOuter> window = nsPIDOMWindowOuter::From(aWindow);
nsCOMPtr<nsIContent> content = window->GetFocusedNode(); nsCOMPtr<nsIContent> content = window->GetFocusedElement();
if (content) if (content)
MoveCaretToFocus(presShell, content); MoveCaretToFocus(presShell, content);
} }
@ -851,10 +851,10 @@ nsFocusManager::ContentRemoved(nsIDocument* aDocument, nsIContent* aContent)
// if the content is currently focused in the window, or is an // if the content is currently focused in the window, or is an
// shadow-including inclusive ancestor of the currently focused element, // shadow-including inclusive ancestor of the currently focused element,
// reset the focus within that window. // reset the focus within that window.
nsIContent* content = window->GetFocusedNode(); nsIContent* content = window->GetFocusedElement();
if (content && nsContentUtils::ContentIsHostIncludingDescendantOf(content, aContent)) { if (content && nsContentUtils::ContentIsHostIncludingDescendantOf(content, aContent)) {
bool shouldShowFocusRing = window->ShouldShowFocusRing(); bool shouldShowFocusRing = window->ShouldShowFocusRing();
window->SetFocusedNode(nullptr); window->SetFocusedElement(nullptr);
// if this window is currently focused, clear the global focused // if this window is currently focused, clear the global focused
// element as well, but don't fire any events. // element as well, but don't fire any events.
@ -1056,7 +1056,7 @@ nsFocusManager::WindowHidden(mozIDOMWindowProxy* aWindow)
dsti->GetParent(getter_AddRefs(parentDsti)); dsti->GetParent(getter_AddRefs(parentDsti));
if (parentDsti) { if (parentDsti) {
if (nsCOMPtr<nsPIDOMWindowOuter> parentWindow = parentDsti->GetWindow()) if (nsCOMPtr<nsPIDOMWindowOuter> parentWindow = parentDsti->GetWindow())
parentWindow->SetFocusedNode(nullptr); parentWindow->SetFocusedElement(nullptr);
} }
} }
@ -1412,7 +1412,7 @@ nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags,
// set the focus node and method as needed // set the focus node and method as needed
uint32_t focusMethod = aFocusChanged ? aFlags & FOCUSMETHODANDRING_MASK : uint32_t focusMethod = aFocusChanged ? aFlags & FOCUSMETHODANDRING_MASK :
newWindow->GetFocusMethod() | (aFlags & FLAG_SHOWRING); newWindow->GetFocusMethod() | (aFlags & FLAG_SHOWRING);
newWindow->SetFocusedNode(contentToFocus, focusMethod); newWindow->SetFocusedElement(contentToFocus, focusMethod);
if (aFocusChanged) { if (aFocusChanged) {
nsCOMPtr<nsIDocShell> docShell = newWindow->GetDocShell(); nsCOMPtr<nsIDocShell> docShell = newWindow->GetDocShell();
@ -1532,7 +1532,7 @@ nsFocusManager::AdjustWindowFocus(nsPIDOMWindowOuter* aWindow,
break; break;
} }
window->SetFocusedNode(frameElement); window->SetFocusedElement(frameElement);
} }
} }
} }
@ -1706,7 +1706,7 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear,
mFocusedContent = nullptr; mFocusedContent = nullptr;
bool shouldShowFocusRing = window->ShouldShowFocusRing(); bool shouldShowFocusRing = window->ShouldShowFocusRing();
if (aWindowToClear) if (aWindowToClear)
aWindowToClear->SetFocusedNode(nullptr); aWindowToClear->SetFocusedElement(nullptr);
LOGCONTENT("Element %s has been blurred", content.get()); LOGCONTENT("Element %s has been blurred", content.get());
@ -1799,7 +1799,7 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear,
// state. Pass true because aAncestorWindowToFocus is thought to be // state. Pass true because aAncestorWindowToFocus is thought to be
// focused at this point. // focused at this point.
if (aAncestorWindowToFocus) if (aAncestorWindowToFocus)
aAncestorWindowToFocus->SetFocusedNode(nullptr, 0, true); aAncestorWindowToFocus->SetFocusedElement(nullptr, 0, true);
SetFocusedWindowInternal(nullptr); SetFocusedWindowInternal(nullptr);
mFocusedContent = nullptr; mFocusedContent = nullptr;
@ -1870,7 +1870,7 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow,
// if the window isn't visible, for instance because it is a hidden tab, // if the window isn't visible, for instance because it is a hidden tab,
// update the current focus and scroll it into view but don't do anything else // update the current focus and scroll it into view but don't do anything else
if (CheckIfFocusable(aContent, aFlags)) { if (CheckIfFocusable(aContent, aFlags)) {
aWindow->SetFocusedNode(aContent, focusMethod); aWindow->SetFocusedElement(aContent, focusMethod);
if (aFocusChanged) if (aFocusChanged)
ScrollIntoView(presShell, aContent, aFlags); ScrollIntoView(presShell, aContent, aFlags);
} }
@ -1953,10 +1953,10 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow,
mFocusedWindow == aWindow && mFocusedContent == nullptr) { mFocusedWindow == aWindow && mFocusedContent == nullptr) {
mFocusedContent = aContent; mFocusedContent = aContent;
nsIContent* focusedNode = aWindow->GetFocusedNode(); nsIContent* focusedNode = aWindow->GetFocusedElement();
bool isRefocus = focusedNode && focusedNode->IsEqualNode(aContent); bool isRefocus = focusedNode && focusedNode->IsEqualNode(aContent);
aWindow->SetFocusedNode(aContent, focusMethod); aWindow->SetFocusedElement(aContent, focusMethod);
// if the focused element changed, scroll it into view // if the focused element changed, scroll it into view
if (aContent && aFocusChanged) { if (aContent && aFocusChanged) {
@ -2109,7 +2109,7 @@ public:
NS_IMETHOD Run() override NS_IMETHOD Run() override
{ {
nsCOMPtr<nsIContent> originalWindowFocus = mOriginalFocusedWindow ? nsCOMPtr<nsIContent> originalWindowFocus = mOriginalFocusedWindow ?
mOriginalFocusedWindow->GetFocusedNode() : mOriginalFocusedWindow->GetFocusedElement() :
nullptr; nullptr;
// Blink does not check that focus is the same after blur, but WebKit does. // Blink does not check that focus is the same after blur, but WebKit does.
// Opt to follow Blink's behavior (see bug 687787). // Opt to follow Blink's behavior (see bug 687787).
@ -2232,7 +2232,7 @@ nsFocusManager::FireFocusOrBlurEvent(EventMessage aEventMessage,
nsCOMPtr<nsPIDOMWindowInner> targetWindow = do_QueryInterface(aTarget); nsCOMPtr<nsPIDOMWindowInner> targetWindow = do_QueryInterface(aTarget);
nsCOMPtr<nsIDocument> targetDocument = do_QueryInterface(aTarget); nsCOMPtr<nsIDocument> targetDocument = do_QueryInterface(aTarget);
nsCOMPtr<nsIContent> currentFocusedContent = currentWindow ? nsCOMPtr<nsIContent> currentFocusedContent = currentWindow ?
currentWindow->GetFocusedNode() : nullptr; currentWindow->GetFocusedElement() : nullptr;
bool dontDispatchEvent = bool dontDispatchEvent =
eventTargetDoc && nsContentUtils::IsUserFocusIgnored(eventTargetDoc); eventTargetDoc && nsContentUtils::IsUserFocusIgnored(eventTargetDoc);
@ -2687,7 +2687,7 @@ nsFocusManager::DetermineElementToMoveFocus(nsPIDOMWindowOuter* aWindow,
// then we are document-navigating backwards from chrome to the content // then we are document-navigating backwards from chrome to the content
// process, and we don't want to use this so that we start from the end // process, and we don't want to use this so that we start from the end
// of the document. // of the document.
startContent = aWindow->GetFocusedNode(); startContent = aWindow->GetFocusedElement();
} }
} }
@ -3017,10 +3017,10 @@ nsFocusManager::DetermineElementToMoveFocus(nsPIDOMWindowOuter* aWindow,
// If the tree owner took the focus, blur the current content. // If the tree owner took the focus, blur the current content.
if (tookFocus) { if (tookFocus) {
nsCOMPtr<nsPIDOMWindowOuter> window = docShell->GetWindow(); nsCOMPtr<nsPIDOMWindowOuter> window = docShell->GetWindow();
if (window->GetFocusedNode() == mFocusedContent) if (window->GetFocusedElement() == mFocusedContent)
Blur(mFocusedWindow, nullptr, true, true); Blur(mFocusedWindow, nullptr, true, true);
else else
window->SetFocusedNode(nullptr); window->SetFocusedElement(nullptr);
return NS_OK; return NS_OK;
} }
@ -3957,7 +3957,7 @@ nsFocusManager::GetFocusInSelection(nsPIDOMWindowOuter* aWindow,
nsCOMPtr<nsIContent> testContent = aStartSelection; nsCOMPtr<nsIContent> testContent = aStartSelection;
nsCOMPtr<nsIContent> nextTestContent = aEndSelection; nsCOMPtr<nsIContent> nextTestContent = aEndSelection;
nsCOMPtr<nsIContent> currentFocus = aWindow->GetFocusedNode(); nsCOMPtr<nsIContent> currentFocus = aWindow->GetFocusedElement();
// We now have the correct start node in selectionContent! // We now have the correct start node in selectionContent!
// Search for focusable elements, starting with selectionContent // Search for focusable elements, starting with selectionContent
@ -4165,7 +4165,7 @@ nsFocusManager::CanSkipFocus(nsIContent* aContent)
root ? root->GetWindow() : nullptr; root ? root->GetWindow() : nullptr;
if (mActiveWindow != newRootWindow) { if (mActiveWindow != newRootWindow) {
nsPIDOMWindowOuter* outerWindow = aContent->OwnerDoc()->GetWindow(); nsPIDOMWindowOuter* outerWindow = aContent->OwnerDoc()->GetWindow();
if (outerWindow && outerWindow->GetFocusedNode() == aContent) { if (outerWindow && outerWindow->GetFocusedElement() == aContent) {
return true; return true;
} }
} }

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

@ -1219,7 +1219,7 @@ nsGlobalWindowInner::FreeInnerObjects()
} }
// Remove our reference to the document and the document principal. // Remove our reference to the document and the document principal.
mFocusedNode = nullptr; mFocusedElement = nullptr;
if (mApplicationCache) { if (mApplicationCache) {
static_cast<nsDOMOfflineResourceList*>(mApplicationCache.get())->Disconnect(); static_cast<nsDOMOfflineResourceList*>(mApplicationCache.get())->Disconnect();
@ -1451,7 +1451,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindowInner)
// Traverse stuff from nsPIDOMWindow // Traverse stuff from nsPIDOMWindow
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeEventHandler) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeEventHandler)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParentTarget) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParentTarget)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFocusedNode) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFocusedElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMenubar) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMenubar)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mToolbar) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mToolbar)
@ -1539,7 +1539,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindowInner)
// Unlink stuff from nsPIDOMWindow // Unlink stuff from nsPIDOMWindow
NS_IMPL_CYCLE_COLLECTION_UNLINK(mChromeEventHandler) NS_IMPL_CYCLE_COLLECTION_UNLINK(mChromeEventHandler)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mParentTarget) NS_IMPL_CYCLE_COLLECTION_UNLINK(mParentTarget)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFocusedNode) NS_IMPL_CYCLE_COLLECTION_UNLINK(mFocusedElement)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMenubar) NS_IMPL_CYCLE_COLLECTION_UNLINK(mMenubar)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mToolbar) NS_IMPL_CYCLE_COLLECTION_UNLINK(mToolbar)
@ -1700,7 +1700,7 @@ nsGlobalWindowInner::InnerSetNewDocument(JSContext* aCx, nsIDocument* aDocument)
mDoc = aDocument; mDoc = aDocument;
ClearDocumentDependentSlots(aCx); ClearDocumentDependentSlots(aCx);
mFocusedNode = nullptr; mFocusedElement = nullptr;
mLocalStorage = nullptr; mLocalStorage = nullptr;
mSessionStorage = nullptr; mSessionStorage = nullptr;
@ -4652,28 +4652,28 @@ static bool ShouldShowFocusRingIfFocusedByMouse(nsIContent* aNode)
} }
void void
nsGlobalWindowInner::SetFocusedNode(Element* aNode, nsGlobalWindowInner::SetFocusedElement(Element* aElement,
uint32_t aFocusMethod, uint32_t aFocusMethod,
bool aNeedsFocus) bool aNeedsFocus)
{ {
if (aNode && aNode->GetComposedDoc() != mDoc) { if (aElement && aElement->GetComposedDoc() != mDoc) {
NS_WARNING("Trying to set focus to a node from a wrong document"); NS_WARNING("Trying to set focus to a node from a wrong document");
return; return;
} }
if (IsDying()) { if (IsDying()) {
NS_ASSERTION(!aNode, "Trying to focus cleaned up window!"); NS_ASSERTION(!aElement, "Trying to focus cleaned up window!");
aNode = nullptr; aElement = nullptr;
aNeedsFocus = false; aNeedsFocus = false;
} }
if (mFocusedNode != aNode) { if (mFocusedElement != aElement) {
UpdateCanvasFocus(false, aNode); UpdateCanvasFocus(false, aElement);
mFocusedNode = aNode; mFocusedElement = aElement;
mFocusMethod = aFocusMethod & FOCUSMETHOD_MASK; mFocusMethod = aFocusMethod & FOCUSMETHOD_MASK;
mShowFocusRingForContent = false; mShowFocusRingForContent = false;
} }
if (mFocusedNode) { if (mFocusedElement) {
// if a node was focused by a keypress, turn on focus rings for the // if a node was focused by a keypress, turn on focus rings for the
// window. // window.
if (mFocusMethod & nsIFocusManager::FLAG_BYKEY) { if (mFocusMethod & nsIFocusManager::FLAG_BYKEY) {
@ -4685,7 +4685,7 @@ nsGlobalWindowInner::SetFocusedNode(Element* aNode,
// are only visible on some elements. // are only visible on some elements.
#ifndef XP_WIN #ifndef XP_WIN
!(mFocusMethod & nsIFocusManager::FLAG_BYMOUSE) || !(mFocusMethod & nsIFocusManager::FLAG_BYMOUSE) ||
ShouldShowFocusRingIfFocusedByMouse(aNode) || ShouldShowFocusRingIfFocusedByMouse(aElement) ||
#endif #endif
aFocusMethod & nsIFocusManager::FLAG_SHOWRING) { aFocusMethod & nsIFocusManager::FLAG_SHOWRING) {
mShowFocusRingForContent = true; mShowFocusRingForContent = true;
@ -4725,7 +4725,7 @@ nsGlobalWindowInner::TakeFocus(bool aFocus, uint32_t aFocusMethod)
if (mHasFocus != aFocus) { if (mHasFocus != aFocus) {
mHasFocus = aFocus; mHasFocus = aFocus;
UpdateCanvasFocus(true, mFocusedNode); UpdateCanvasFocus(true, mFocusedElement);
} }
// if mNeedsFocus is true, then the document has not yet received a // if mNeedsFocus is true, then the document has not yet received a
@ -4941,7 +4941,7 @@ nsGlobalWindowInner::UpdateCanvasFocus(bool aFocusChanged, nsIContent* aNewConte
Element *rootElement = mDoc->GetRootElement(); Element *rootElement = mDoc->GetRootElement();
if (rootElement) { if (rootElement) {
if ((mHasFocus || aFocusChanged) && if ((mHasFocus || aFocusChanged) &&
(mFocusedNode == rootElement || aNewContent == rootElement)) { (mFocusedElement == rootElement || aNewContent == rootElement)) {
nsIFrame* frame = rootElement->GetPrimaryFrame(); nsIFrame* frame = rootElement->GetPrimaryFrame();
if (frame) { if (frame) {
frame = frame->GetParent(); frame = frame->GetParent();

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

@ -1197,9 +1197,9 @@ public:
bool IsInModalState(); bool IsInModalState();
virtual void SetFocusedNode(mozilla::dom::Element* aNode, virtual void SetFocusedElement(mozilla::dom::Element* aElement,
uint32_t aFocusMethod = 0, uint32_t aFocusMethod = 0,
bool aNeedsFocus = false) override; bool aNeedsFocus = false) override;
virtual uint32_t GetFocusMethod() override; virtual uint32_t GetFocusMethod() override;

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

@ -6626,11 +6626,12 @@ nsGlobalWindowOuter::SetChromeEventHandler(EventTarget* aChromeEventHandler)
} }
void void
nsGlobalWindowOuter::SetFocusedNode(Element* aNode, nsGlobalWindowOuter::SetFocusedElement(Element* aElement,
uint32_t aFocusMethod, uint32_t aFocusMethod,
bool aNeedsFocus) bool aNeedsFocus)
{ {
FORWARD_TO_INNER_VOID(SetFocusedNode, (aNode, aFocusMethod, aNeedsFocus)); FORWARD_TO_INNER_VOID(SetFocusedElement,
(aElement, aFocusMethod, aNeedsFocus));
} }
uint32_t uint32_t
@ -6677,13 +6678,13 @@ nsGlobalWindowOuter::SetKeyboardIndicators(UIStateChangeType aShowAccelerators,
bool newShouldShowFocusRing = ShouldShowFocusRing(); bool newShouldShowFocusRing = ShouldShowFocusRing();
if (mInnerWindow && nsGlobalWindowInner::Cast(mInnerWindow)->mHasFocus && if (mInnerWindow && nsGlobalWindowInner::Cast(mInnerWindow)->mHasFocus &&
mInnerWindow->mFocusedNode && mInnerWindow->mFocusedElement &&
oldShouldShowFocusRing != newShouldShowFocusRing) { oldShouldShowFocusRing != newShouldShowFocusRing) {
// Update focusedNode's state. // Update focusedNode's state.
if (newShouldShowFocusRing) { if (newShouldShowFocusRing) {
mInnerWindow->mFocusedNode->AddStates(NS_EVENT_STATE_FOCUSRING); mInnerWindow->mFocusedElement->AddStates(NS_EVENT_STATE_FOCUSRING);
} else { } else {
mInnerWindow->mFocusedNode->RemoveStates(NS_EVENT_STATE_FOCUSRING); mInnerWindow->mFocusedElement->RemoveStates(NS_EVENT_STATE_FOCUSRING);
} }
} }
} }
@ -7258,14 +7259,14 @@ nsGlobalWindowOuter::RestoreWindowState(nsISupports *aState)
// if a link is focused, refocus with the FLAG_SHOWRING flag set. This makes // if a link is focused, refocus with the FLAG_SHOWRING flag set. This makes
// it easy to tell which link was last clicked when going back a page. // it easy to tell which link was last clicked when going back a page.
Element* focusedNode = inner->GetFocusedNode(); Element* focusedElement = inner->GetFocusedElement();
if (nsContentUtils::ContentIsLink(focusedNode)) { if (nsContentUtils::ContentIsLink(focusedElement)) {
nsIFocusManager* fm = nsFocusManager::GetFocusManager(); nsIFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm) { if (fm) {
// XXXbz Do we need the stack strong ref here? // XXXbz Do we need the stack strong ref here?
RefPtr<Element> focusedElement = focusedNode; RefPtr<Element> kungFuDeathGrip(focusedElement);
fm->SetFocus(focusedElement, nsIFocusManager::FLAG_NOSCROLL | fm->SetFocus(kungFuDeathGrip, nsIFocusManager::FLAG_NOSCROLL |
nsIFocusManager::FLAG_SHOWRING); nsIFocusManager::FLAG_SHOWRING);
} }
} }

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

@ -979,9 +979,9 @@ public:
nsIntSize DevToCSSIntPixels(nsIntSize px); nsIntSize DevToCSSIntPixels(nsIntSize px);
nsIntSize CSSToDevIntPixels(nsIntSize px); nsIntSize CSSToDevIntPixels(nsIntSize px);
virtual void SetFocusedNode(mozilla::dom::Element* aNode, virtual void SetFocusedElement(mozilla::dom::Element* aElement,
uint32_t aFocusMethod = 0, uint32_t aFocusMethod = 0,
bool aNeedsFocus = false) override; bool aNeedsFocus = false) override;
virtual uint32_t GetFocusMethod() override; virtual uint32_t GetFocusMethod() override;

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

@ -484,10 +484,10 @@ public:
* DO NOT CALL EITHER OF THESE METHODS DIRECTLY. USE THE FOCUS MANAGER * DO NOT CALL EITHER OF THESE METHODS DIRECTLY. USE THE FOCUS MANAGER
* INSTEAD. * INSTEAD.
*/ */
inline mozilla::dom::Element* GetFocusedNode() const; inline mozilla::dom::Element* GetFocusedElement() const;
virtual void SetFocusedNode(mozilla::dom::Element* aNode, virtual void SetFocusedElement(mozilla::dom::Element* aElement,
uint32_t aFocusMethod = 0, uint32_t aFocusMethod = 0,
bool aNeedsFocus = false) = 0; bool aNeedsFocus = false) = 0;
/** /**
* Retrieves the method that was used to focus the current node. * Retrieves the method that was used to focus the current node.
@ -658,9 +658,9 @@ protected:
// Our inner window's outer window. // Our inner window's outer window.
nsCOMPtr<nsPIDOMWindowOuter> mOuterWindow; nsCOMPtr<nsPIDOMWindowOuter> mOuterWindow;
// the element within the document that is currently focused when this // The element within the document that is currently focused when this
// window is active. // window is active.
RefPtr<mozilla::dom::Element> mFocusedNode; RefPtr<mozilla::dom::Element> mFocusedElement;
// The AudioContexts created for the current document, if any. // The AudioContexts created for the current document, if any.
nsTArray<mozilla::dom::AudioContext*> mAudioContexts; // Weak nsTArray<mozilla::dom::AudioContext*> mAudioContexts; // Weak
@ -973,10 +973,10 @@ public:
* DO NOT CALL EITHER OF THESE METHODS DIRECTLY. USE THE FOCUS MANAGER * DO NOT CALL EITHER OF THESE METHODS DIRECTLY. USE THE FOCUS MANAGER
* INSTEAD. * INSTEAD.
*/ */
inline mozilla::dom::Element* GetFocusedNode() const; inline mozilla::dom::Element* GetFocusedElement() const;
virtual void SetFocusedNode(mozilla::dom::Element* aNode, virtual void SetFocusedElement(mozilla::dom::Element* aElement,
uint32_t aFocusMethod = 0, uint32_t aFocusMethod = 0,
bool aNeedsFocus = false) = 0; bool aNeedsFocus = false) = 0;
/** /**
* Retrieves the method that was used to focus the current node. * Retrieves the method that was used to focus the current node.

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

@ -90,13 +90,13 @@ nsPIDOMWindowInner::GetDocShell() const
} }
mozilla::dom::Element* mozilla::dom::Element*
nsPIDOMWindowOuter::GetFocusedNode() const nsPIDOMWindowOuter::GetFocusedElement() const
{ {
return mInnerWindow ? mInnerWindow->GetFocusedNode() : nullptr; return mInnerWindow ? mInnerWindow->GetFocusedElement() : nullptr;
} }
mozilla::dom::Element* mozilla::dom::Element*
nsPIDOMWindowInner::GetFocusedNode() const nsPIDOMWindowInner::GetFocusedElement() const
{ {
return mFocusedNode; return mFocusedElement;
} }

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

@ -2570,7 +2570,7 @@ nsGenericHTMLElement::PerformAccesskey(bool aKeyCausesActivation,
// Return true if the element became the current focus within its window. // Return true if the element became the current focus within its window.
nsPIDOMWindowOuter* window = OwnerDoc()->GetWindow(); nsPIDOMWindowOuter* window = OwnerDoc()->GetWindow();
focused = (window && window->GetFocusedNode()); focused = (window && window->GetFocusedElement());
} }
if (aKeyCausesActivation) { if (aKeyCausesActivation) {

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

@ -598,7 +598,7 @@ nsXULElement::PerformAccesskey(bool aKeyCausesActivation,
// Return true if the element became focused. // Return true if the element became focused.
nsPIDOMWindowOuter* window = OwnerDoc()->GetWindow(); nsPIDOMWindowOuter* window = OwnerDoc()->GetWindow();
focused = (window && window->GetFocusedNode()); focused = (window && window->GetFocusedElement());
} }
} }
} }