From af700315a1615aa6b8f4acba3913f9eb5128d118 Mon Sep 17 00:00:00 2001 From: shindli Date: Fri, 27 Apr 2018 01:34:37 +0300 Subject: [PATCH] Backed out 2 changesets (bug 1457155, bug 1457156) for B failures in builds/worker/workspace/build/src/dom/html/HTMLObjectElement.cpp on a CLOSED TREE Backed out changeset 8b2a6b54336c (bug 1457155) Backed out changeset 4e267d999797 (bug 1457156) --- accessible/base/FocusManager.cpp | 4 +- dom/base/nsContentUtils.cpp | 2 +- dom/base/nsDOMWindowUtils.cpp | 2 +- dom/base/nsDocument.cpp | 2 +- dom/base/nsFocusManager.cpp | 267 +++++++++--------- dom/base/nsFocusManager.h | 6 +- dom/base/nsGlobalWindowInner.cpp | 34 +-- dom/base/nsGlobalWindowInner.h | 6 +- dom/base/nsGlobalWindowOuter.cpp | 25 +- dom/base/nsGlobalWindowOuter.h | 6 +- dom/base/nsPIDOMWindow.h | 20 +- dom/base/nsPIDOMWindowInlines.h | 8 +- dom/events/EventStateManager.cpp | 2 +- dom/html/nsGenericHTMLElement.cpp | 2 +- dom/plugins/base/nsPluginInstanceOwner.cpp | 2 +- dom/xul/nsXULElement.cpp | 2 +- editor/libeditor/EditorBase.cpp | 2 +- editor/libeditor/EditorEventListener.cpp | 8 +- editor/libeditor/HTMLEditor.cpp | 2 +- layout/base/AccessibleCaretManager.cpp | 2 +- layout/forms/nsComboboxControlFrame.cpp | 2 +- .../satchel/nsFormFillController.cpp | 4 +- 22 files changed, 201 insertions(+), 209 deletions(-) diff --git a/accessible/base/FocusManager.cpp b/accessible/base/FocusManager.cpp index 6d697636e054..e61ef5cfe4eb 100644 --- a/accessible/base/FocusManager.cpp +++ b/accessible/base/FocusManager.cpp @@ -199,7 +199,7 @@ FocusManager::ActiveItemChanged(Accessible* aItem, bool aCheckIfActive) if (!mActiveItem && XRE_IsParentProcess()) { nsFocusManager* domfm = nsFocusManager::GetFocusManager(); if (domfm) { - nsIContent* focusedElm = domfm->GetFocusedElement(); + nsIContent* focusedElm = domfm->GetFocusedContent(); if (EventStateManager::IsRemoteTarget(focusedElm)) { dom::TabParent* tab = dom::TabParent::GetFrom(focusedElm); if (tab) { @@ -399,7 +399,7 @@ nsINode* FocusManager::FocusedDOMNode() const { nsFocusManager* DOMFocusManager = nsFocusManager::GetFocusManager(); - nsIContent* focusedElm = DOMFocusManager->GetFocusedElement(); + nsIContent* focusedElm = DOMFocusManager->GetFocusedContent(); // No focus on remote target elements like xul:browser having DOM focus and // residing in chrome process because it means an element in content process diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index f832e05c314d..d24cfab41684 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -6700,7 +6700,7 @@ nsContentUtils::IsFocusedContent(const nsIContent* aContent) { nsFocusManager* fm = nsFocusManager::GetFocusManager(); - return fm && fm->GetFocusedElement() == aContent; + return fm && fm->GetFocusedContent() == aContent; } bool diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index c9fe6429851c..3bba458c327f 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -2646,7 +2646,7 @@ nsDOMWindowUtils::ZoomToFocusedInput() return NS_OK; } - nsIContent* content = fm->GetFocusedElement(); + nsIContent* content = fm->GetFocusedContent(); if (!content) { return NS_OK; } diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 15ee72700d9f..d69e9269fc6e 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -9356,7 +9356,7 @@ public: } // Don't steal focus from the user. - if (mTopWindow->GetFocusedElement()) { + if (mTopWindow->GetFocusedNode()) { return NS_OK; } diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index e56ee424988b..b2b7af112ad6 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -166,7 +166,7 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsFocusManager) NS_IMPL_CYCLE_COLLECTION(nsFocusManager, mActiveWindow, mFocusedWindow, - mFocusedElement, + mFocusedContent, mFirstBlurEvent, mFirstFocusEvent, mWindowBeingLowered, @@ -259,7 +259,7 @@ nsFocusManager::Observe(nsISupports *aSubject, } else if (!nsCRT::strcmp(aTopic, "xpcom-shutdown")) { mActiveWindow = nullptr; mFocusedWindow = nullptr; - mFocusedElement = nullptr; + mFocusedContent = nullptr; mFirstBlurEvent = nullptr; mFirstFocusEvent = nullptr; mWindowBeingLowered = nullptr; @@ -287,10 +287,10 @@ GetContentWindow(nsIContent* aContent) bool nsFocusManager::IsFocused(nsIContent* aContent) { - if (!aContent || !mFocusedElement) { + if (!aContent || !mFocusedContent) { return false; } - return aContent == mFocusedElement; + return aContent == mFocusedContent.get(); } // get the current window for the given content node @@ -311,16 +311,16 @@ nsFocusManager::GetFocusedDescendant(nsPIDOMWindowOuter* aWindow, *aFocusedWindow = nullptr; - Element* currentElement = nullptr; + Element* currentContent = nullptr; nsPIDOMWindowOuter* window = aWindow; for (;;) { *aFocusedWindow = window; - currentElement = window->GetFocusedElement(); - if (!currentElement || aSearchRange == eOnlyCurrentWindow) { + currentContent = window->GetFocusedNode(); + if (!currentContent || aSearchRange == eOnlyCurrentWindow) { break; } - window = GetContentWindow(currentElement); + window = GetContentWindow(currentContent); if (!window) { break; } @@ -345,7 +345,7 @@ nsFocusManager::GetFocusedDescendant(nsPIDOMWindowOuter* aWindow, NS_IF_ADDREF(*aFocusedWindow); - return currentElement; + return currentContent; } // static @@ -468,7 +468,7 @@ NS_IMETHODIMP nsFocusManager::SetFocusedWindow(mozIDOMWindowProxy* aWindowToFocu // 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 // in a child. - nsIContent* content = windowToFocus->GetFocusedElement(); + nsIContent* content = windowToFocus->GetFocusedNode(); if (content) { if (nsCOMPtr childWindow = GetContentWindow(content)) ClearFocus(windowToFocus); @@ -487,8 +487,8 @@ NS_IMETHODIMP nsFocusManager::SetFocusedWindow(mozIDOMWindowProxy* aWindowToFocu NS_IMETHODIMP nsFocusManager::GetFocusedElement(nsIDOMElement** aFocusedElement) { - if (mFocusedElement) - CallQueryInterface(mFocusedElement, aFocusedElement); + if (mFocusedContent) + CallQueryInterface(mFocusedContent, aFocusedElement); else *aFocusedElement = nullptr; return NS_OK; @@ -554,7 +554,7 @@ nsFocusManager::MoveFocus(mozIDOMWindowProxy* aWindow, Element* aStartElement, } } - LOGCONTENT(" Current Focus: %s", mFocusedElement.get()); + LOGCONTENT(" Current Focus: %s", mFocusedContent.get()); // use FLAG_BYMOVEFOCUS when switching focus with MoveFocus unless one of // the other focus methods is already set, or we're just moving to the root @@ -625,7 +625,7 @@ nsFocusManager::ClearFocus(mozIDOMWindowProxy* aWindow) } } else { - window->SetFocusedElement(nullptr); + window->SetFocusedNode(nullptr); } LOGFOCUS(("<>")); @@ -681,7 +681,7 @@ nsFocusManager::MoveCaretToFocus(mozIDOMWindowProxy* aWindow) NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); nsCOMPtr window = nsPIDOMWindowOuter::From(aWindow); - nsCOMPtr content = window->GetFocusedElement(); + nsCOMPtr content = window->GetFocusedNode(); if (content) MoveCaretToFocus(presShell, content); } @@ -851,15 +851,15 @@ nsFocusManager::ContentRemoved(nsIDocument* aDocument, nsIContent* aContent) // if the content is currently focused in the window, or is an // shadow-including inclusive ancestor of the currently focused element, // reset the focus within that window. - nsIContent* content = window->GetFocusedElement(); + nsIContent* content = window->GetFocusedNode(); if (content && nsContentUtils::ContentIsHostIncludingDescendantOf(content, aContent)) { bool shouldShowFocusRing = window->ShouldShowFocusRing(); - window->SetFocusedElement(nullptr); + window->SetFocusedNode(nullptr); // if this window is currently focused, clear the global focused // element as well, but don't fire any events. if (window == mFocusedWindow) { - mFocusedElement = nullptr; + mFocusedContent = nullptr; } else { // Check if the node that was focused is an iframe or similar by looking // if it has a subdocument. This would indicate that this focused iframe @@ -993,13 +993,13 @@ nsFocusManager::WindowHidden(mozIDOMWindowProxy* aWindow) // window, or an ancestor of the focused window. Either way, the focus is no // longer valid, so it needs to be updated. - RefPtr oldFocusedElement = mFocusedElement.forget(); + nsCOMPtr oldFocusedContent = mFocusedContent.forget(); nsCOMPtr focusedDocShell = mFocusedWindow->GetDocShell(); nsCOMPtr presShell = focusedDocShell->GetPresShell(); - if (oldFocusedElement && oldFocusedElement->IsInComposedDoc()) { - NotifyFocusStateChange(oldFocusedElement, + if (oldFocusedContent && oldFocusedContent->IsInComposedDoc()) { + NotifyFocusStateChange(oldFocusedContent, nullptr, mFocusedWindow->ShouldShowFocusRing(), false); @@ -1007,8 +1007,8 @@ nsFocusManager::WindowHidden(mozIDOMWindowProxy* aWindow) if (presShell) { SendFocusOrBlurEvent(eBlur, presShell, - oldFocusedElement->GetComposedDoc(), - oldFocusedElement, 1, false); + oldFocusedContent->GetComposedDoc(), + oldFocusedContent, 1, false); } } @@ -1056,7 +1056,7 @@ nsFocusManager::WindowHidden(mozIDOMWindowProxy* aWindow) dsti->GetParent(getter_AddRefs(parentDsti)); if (parentDsti) { if (nsCOMPtr parentWindow = parentDsti->GetWindow()) - parentWindow->SetFocusedElement(nullptr); + parentWindow->SetFocusedNode(nullptr); } } @@ -1227,19 +1227,18 @@ nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags, bool aFocusChanged, bool aAdjustWidget) { // if the element is not focusable, just return and leave the focus as is - RefPtr elementToFocus = CheckIfFocusable(aNewContent, aFlags); - if (!elementToFocus) { + RefPtr contentToFocus = CheckIfFocusable(aNewContent, aFlags); + if (!contentToFocus) return; - } // check if the element to focus is a frame (iframe) containing a child // document. Frames are never directly focused; instead focusing a frame // means focus what is inside the frame. To do this, the descendant content // within the frame is retrieved and that will be focused instead. nsCOMPtr newWindow; - nsCOMPtr subWindow = GetContentWindow(elementToFocus); + nsCOMPtr subWindow = GetContentWindow(contentToFocus); if (subWindow) { - elementToFocus = GetFocusedDescendant(subWindow, eIncludeAllDescendants, + contentToFocus = GetFocusedDescendant(subWindow, eIncludeAllDescendants, getter_AddRefs(newWindow)); // since a window is being refocused, clear aFocusChanged so that the // caret position isn't updated. @@ -1247,17 +1246,14 @@ nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags, } // unless it was set above, retrieve the window for the element to focus - if (!newWindow) { - newWindow = GetCurrentWindow(elementToFocus); - } + if (!newWindow) + newWindow = GetCurrentWindow(contentToFocus); // if the element is already focused, just return. Note that this happens // after the frame check above so that we compare the element that will be // focused rather than the frame it is in. - if (!newWindow || - (newWindow == mFocusedWindow && elementToFocus == mFocusedElement)) { + if (!newWindow || (newWindow == mFocusedWindow && contentToFocus == mFocusedContent)) return; - } // don't allow focus to be placed in docshells or descendants of docshells // that are being destroyed. Also, ensure that the page hasn't been @@ -1322,16 +1318,16 @@ nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags, // key input if a windowed plugin is focused, so just exit fullscreen // to guard against phishing. #ifndef XP_MACOSX - if (elementToFocus && + if (contentToFocus && nsContentUtils:: - GetRootDocument(elementToFocus->OwnerDoc())->GetFullscreenElement() && - nsContentUtils::HasPluginWithUncontrolledEventDispatch(elementToFocus)) { + GetRootDocument(contentToFocus->OwnerDoc())->GetFullscreenElement() && + nsContentUtils::HasPluginWithUncontrolledEventDispatch(contentToFocus)) { nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM"), - elementToFocus->OwnerDoc(), + contentToFocus->OwnerDoc(), nsContentUtils::eDOM_PROPERTIES, "FocusedWindowedPluginWhileFullscreen"); - nsIDocument::AsyncExitFullscreen(elementToFocus->OwnerDoc()); + nsIDocument::AsyncExitFullscreen(contentToFocus->OwnerDoc()); } #endif @@ -1351,12 +1347,12 @@ nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags, // * isn't called by trusted event (i.e., called by untrusted event or by js) // * the focus is moved to another document's element // we need to check the permission. - if (sendFocusEvent && mFocusedElement && !nsContentUtils::LegacyIsCallerNativeCode() && - mFocusedElement->OwnerDoc() != aNewContent->OwnerDoc()) { + if (sendFocusEvent && mFocusedContent && !nsContentUtils::LegacyIsCallerNativeCode() && + mFocusedContent->OwnerDoc() != aNewContent->OwnerDoc()) { // If the caller cannot access the current focused node, the caller should // not be able to steal focus from it. E.g., When the current focused node // is in chrome, any web contents should not be able to steal the focus. - nsCOMPtr domNode(do_QueryInterface(mFocusedElement)); + nsCOMPtr domNode(do_QueryInterface(mFocusedContent)); sendFocusEvent = nsContentUtils::CanCallerAccess(domNode); if (!sendFocusEvent && mMouseButtonEventHandlingDocument) { // However, while mouse button event is handling, the handling document's @@ -1366,14 +1362,14 @@ nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags, } } - LOGCONTENT("Shift Focus: %s", elementToFocus.get()); + LOGCONTENT("Shift Focus: %s", contentToFocus.get()); LOGFOCUS((" Flags: %x Current Window: %p New Window: %p Current Element: %p", - aFlags, mFocusedWindow.get(), newWindow.get(), mFocusedElement.get())); + aFlags, mFocusedWindow.get(), newWindow.get(), mFocusedContent.get())); LOGFOCUS((" In Active Window: %d In Focused Window: %d SendFocus: %d", isElementInActiveWindow, isElementInFocusedWindow, sendFocusEvent)); if (sendFocusEvent) { - RefPtr oldFocusedElement = mFocusedElement; + RefPtr oldFocusedContent = mFocusedContent; // return if blurring fails or the focus changes during the blur if (mFocusedWindow) { // if the focus is being moved to another element in the same document, @@ -1400,13 +1396,12 @@ nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags, if (!Blur(currentIsSameOrAncestor ? mFocusedWindow.get() : nullptr, commonAncestor, !isElementInFocusedWindow, aAdjustWidget, - elementToFocus)) { + contentToFocus)) return; - } } - Focus(newWindow, elementToFocus, aFlags, !isElementInFocusedWindow, - aFocusChanged, false, aAdjustWidget, oldFocusedElement); + Focus(newWindow, contentToFocus, aFlags, !isElementInFocusedWindow, + aFocusChanged, false, aAdjustWidget, oldFocusedContent); } else { // otherwise, for inactive windows and when the caller cannot steal the @@ -1417,13 +1412,13 @@ nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags, // set the focus node and method as needed uint32_t focusMethod = aFocusChanged ? aFlags & FOCUSMETHODANDRING_MASK : newWindow->GetFocusMethod() | (aFlags & FLAG_SHOWRING); - newWindow->SetFocusedElement(elementToFocus, focusMethod); + newWindow->SetFocusedNode(contentToFocus, focusMethod); if (aFocusChanged) { nsCOMPtr docShell = newWindow->GetDocShell(); nsCOMPtr presShell = docShell->GetPresShell(); if (presShell && presShell->DidInitialize()) - ScrollIntoView(presShell, elementToFocus, aFlags); + ScrollIntoView(presShell, contentToFocus, aFlags); } // update the commands even when inactive so that the attributes for that @@ -1537,7 +1532,7 @@ nsFocusManager::AdjustWindowFocus(nsPIDOMWindowOuter* aWindow, break; } - window->SetFocusedElement(frameElement); + window->SetFocusedNode(frameElement); } } } @@ -1584,22 +1579,22 @@ nsFocusManager::IsNonFocusableRoot(nsIContent* aContent) } Element* -nsFocusManager::CheckIfFocusable(Element* aElement, uint32_t aFlags) +nsFocusManager::CheckIfFocusable(Element* aContent, uint32_t aFlags) { - if (!aElement) + if (!aContent) return nullptr; // this is a special case for some XUL elements or input number, where an // anonymous child is actually focusable and not the element itself. - RefPtr redirectedFocus = GetRedirectedFocus(aElement); + RefPtr redirectedFocus = GetRedirectedFocus(aContent); if (redirectedFocus) { return CheckIfFocusable(redirectedFocus, aFlags); } - nsCOMPtr doc = aElement->GetComposedDoc(); + nsCOMPtr doc = aContent->GetComposedDoc(); // can't focus elements that are not in documents if (!doc) { - LOGCONTENT("Cannot focus %s because content not in document", aElement) + LOGCONTENT("Cannot focus %s because content not in document", aContent) return nullptr; } @@ -1614,44 +1609,44 @@ nsFocusManager::CheckIfFocusable(Element* aElement, uint32_t aFlags) // the root content can always be focused, // except in userfocusignored context. - if (aElement == doc->GetRootElement()) { - return nsContentUtils::IsUserFocusIgnored(aElement) ? nullptr : aElement; + if (aContent == doc->GetRootElement()) { + return nsContentUtils::IsUserFocusIgnored(aContent) ? nullptr : aContent; } // cannot focus content in print preview mode. Only the root can be focused. nsPresContext* presContext = shell->GetPresContext(); if (presContext && presContext->Type() == nsPresContext::eContext_PrintPreview) { - LOGCONTENT("Cannot focus %s while in print preview", aElement) + LOGCONTENT("Cannot focus %s while in print preview", aContent) return nullptr; } - nsIFrame* frame = aElement->GetPrimaryFrame(); + nsIFrame* frame = aContent->GetPrimaryFrame(); if (!frame) { - LOGCONTENT("Cannot focus %s as it has no frame", aElement) + LOGCONTENT("Cannot focus %s as it has no frame", aContent) return nullptr; } - if (aElement->IsHTMLElement(nsGkAtoms::area)) { + if (aContent->IsHTMLElement(nsGkAtoms::area)) { // HTML areas do not have their own frame, and the img frame we get from // GetPrimaryFrame() is not relevant as to whether it is focusable or // not, so we have to do all the relevant checks manually for them. return frame->IsVisibleConsideringAncestors() && - aElement->IsFocusable() ? aElement : nullptr; + aContent->IsFocusable() ? aContent : nullptr; } // if this is a child frame content node, check if it is visible and // call the content node's IsFocusable method instead of the frame's // IsFocusable method. This skips checking the style system and ensures that // offscreen browsers can still be focused. - nsIDocument* subdoc = doc->GetSubDocumentFor(aElement); + nsIDocument* subdoc = doc->GetSubDocumentFor(aContent); if (subdoc && IsWindowVisible(subdoc->GetWindow())) { const nsStyleUserInterface* ui = frame->StyleUserInterface(); int32_t tabIndex = (ui->mUserFocus == StyleUserFocus::Ignore || ui->mUserFocus == StyleUserFocus::None) ? -1 : 0; - return aElement->IsFocusable(&tabIndex, aFlags & FLAG_BYMOUSE) ? aElement : nullptr; + return aContent->IsFocusable(&tabIndex, aFlags & FLAG_BYMOUSE) ? aContent : nullptr; } - return frame->IsFocusable(nullptr, aFlags & FLAG_BYMOUSE) ? aElement : nullptr; + return frame->IsFocusable(nullptr, aFlags & FLAG_BYMOUSE) ? aContent : nullptr; } bool @@ -1664,26 +1659,26 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear, LOGFOCUS(("<>")); // hold a reference to the focused content, which may be null - RefPtr element = mFocusedElement; - if (element) { - if (!element->IsInComposedDoc()) { - mFocusedElement = nullptr; + RefPtr content = mFocusedContent; + if (content) { + if (!content->IsInComposedDoc()) { + mFocusedContent = nullptr; return true; } - if (element == mFirstBlurEvent) + if (content == mFirstBlurEvent) return true; } // hold a reference to the focused window nsCOMPtr window = mFocusedWindow; if (!window) { - mFocusedElement = nullptr; + mFocusedContent = nullptr; return true; } nsCOMPtr docShell = window->GetDocShell(); if (!docShell) { - mFocusedElement = nullptr; + mFocusedContent = nullptr; return true; } @@ -1691,13 +1686,13 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear, // the document to be destroyed. nsCOMPtr presShell = docShell->GetPresShell(); if (!presShell) { - mFocusedElement = nullptr; + mFocusedContent = nullptr; return true; } bool clearFirstBlurEvent = false; if (!mFirstBlurEvent) { - mFirstBlurEvent = element; + mFirstBlurEvent = content; clearFirstBlurEvent = true; } @@ -1708,19 +1703,19 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear, // now adjust the actual focus, by clearing the fields in the focus manager // and in the window. - mFocusedElement = nullptr; + mFocusedContent = nullptr; bool shouldShowFocusRing = window->ShouldShowFocusRing(); if (aWindowToClear) - aWindowToClear->SetFocusedElement(nullptr); + aWindowToClear->SetFocusedNode(nullptr); - LOGCONTENT("Element %s has been blurred", element.get()); + LOGCONTENT("Element %s has been blurred", content.get()); // Don't fire blur event on the root content which isn't editable. bool sendBlurEvent = - element && element->IsInComposedDoc() && !IsNonFocusableRoot(element); - if (element) { + content && content->IsInComposedDoc() && !IsNonFocusableRoot(content); + if (content) { if (sendBlurEvent) { - NotifyFocusStateChange(element, + NotifyFocusStateChange(content, aContentToFocus, shouldShowFocusRing, false); @@ -1731,7 +1726,7 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear, // But don't do this if we are blurring due to the window being lowered, // otherwise, the parent window can get raised again. if (mActiveWindow) { - nsIFrame* contentFrame = element->GetPrimaryFrame(); + nsIFrame* contentFrame = content->GetPrimaryFrame(); nsIObjectFrame* objectFrame = do_QueryFrame(contentFrame); if (aAdjustWidgets && objectFrame && !sTestMode) { if (XRE_IsContentProcess()) { @@ -1757,7 +1752,7 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear, } // if the object being blurred is a remote browser, deactivate remote content - if (TabParent* remote = TabParent::GetFrom(element)) { + if (TabParent* remote = TabParent::GetFrom(content)) { remote->Deactivate(); LOGFOCUS(("Remote browser deactivated")); } @@ -1772,7 +1767,7 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear, window->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0); SendFocusOrBlurEvent(eBlur, presShell, - element->GetComposedDoc(), element, 1, + content->GetComposedDoc(), content, 1, false, false, aContentToFocus); } @@ -1788,13 +1783,13 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear, } // at this point, it is expected that this window will be still be - // focused, but the focused element will be null, as it was cleared before + // focused, but the focused content will be null, as it was cleared before // the event. If this isn't the case, then something else was focused during // the blur event above and we should just return. However, if // aIsLeavingDocument is set, a new document is desired, so make sure to // blur the document and window. if (mFocusedWindow != window || - (mFocusedElement != nullptr && !aIsLeavingDocument)) { + (mFocusedContent != nullptr && !aIsLeavingDocument)) { result = false; } else if (aIsLeavingDocument) { @@ -1804,10 +1799,10 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear, // state. Pass true because aAncestorWindowToFocus is thought to be // focused at this point. if (aAncestorWindowToFocus) - aAncestorWindowToFocus->SetFocusedElement(nullptr, 0, true); + aAncestorWindowToFocus->SetFocusedNode(nullptr, 0, true); SetFocusedWindowInternal(nullptr); - mFocusedElement = nullptr; + mFocusedContent = nullptr; // pass 1 for the focus method when calling SendFocusOrBlurEvent just so // that the check is made for suppressed documents. Check to ensure that @@ -1839,7 +1834,7 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear, void nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, - Element* aElement, + Element* aContent, uint32_t aFlags, bool aIsNewDocument, bool aFocusChanged, @@ -1852,7 +1847,7 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, if (!aWindow) return; - if (aElement && (aElement == mFirstFocusEvent || aElement == mFirstBlurEvent)) + if (aContent && (aContent == mFirstFocusEvent || aContent == mFirstBlurEvent)) return; // Keep a reference to the presShell since dispatching the DOM event may @@ -1874,21 +1869,21 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, if (!IsWindowVisible(aWindow)) { // 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 - if (CheckIfFocusable(aElement, aFlags)) { - aWindow->SetFocusedElement(aElement, focusMethod); + if (CheckIfFocusable(aContent, aFlags)) { + aWindow->SetFocusedNode(aContent, focusMethod); if (aFocusChanged) - ScrollIntoView(presShell, aElement, aFlags); + ScrollIntoView(presShell, aContent, aFlags); } return; } bool clearFirstFocusEvent = false; if (!mFirstFocusEvent) { - mFirstFocusEvent = aElement; + mFirstFocusEvent = aContent; clearFirstFocusEvent = true; } - LOGCONTENT("Element %s has been focused", aElement); + LOGCONTENT("Element %s has been focused", aContent); if (MOZ_LOG_TEST(gFocusLog, LogLevel::Debug)) { nsIDocument* docm = aWindow->GetExtantDoc(); @@ -1913,11 +1908,11 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, SetFocusedWindowInternal(aWindow); // Update the system focus by focusing the root widget. But avoid this - // if 1) aAdjustWidgets is false or 2) aElement is a plugin that has its + // if 1) aAdjustWidgets is false or 2) aContent is a plugin that has its // own widget and is either already focused or is about to be focused. nsCOMPtr objectFrameWidget; - if (aElement) { - nsIFrame* contentFrame = aElement->GetPrimaryFrame(); + if (aContent) { + nsIFrame* contentFrame = aContent->GetPrimaryFrame(); nsIObjectFrame* objectFrame = do_QueryFrame(contentFrame); if (objectFrame) objectFrameWidget = objectFrame->GetWidget(); @@ -1937,44 +1932,42 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, if (aIsNewDocument) { nsIDocument* doc = aWindow->GetExtantDoc(); // The focus change should be notified to IMEStateManager from here if - // the focused element is a designMode editor since any content won't + // the focused content is a designMode editor since any content won't // receive focus event. if (doc && doc->HasFlag(NODE_IS_EDITABLE)) { IMEStateManager::OnChangeFocus(presShell->GetPresContext(), nullptr, GetFocusMoveActionCause(aFlags)); } - if (doc) { + if (doc) SendFocusOrBlurEvent(eFocus, presShell, doc, doc, aFlags & FOCUSMETHOD_MASK, aWindowRaised); - } - if (mFocusedWindow == aWindow && mFocusedElement == nullptr) { + if (mFocusedWindow == aWindow && mFocusedContent == nullptr) SendFocusOrBlurEvent(eFocus, presShell, doc, aWindow->GetCurrentInnerWindow(), aFlags & FOCUSMETHOD_MASK, aWindowRaised); - } } // check to ensure that the element is still focusable, and that nothing // else was focused during the events above. - if (CheckIfFocusable(aElement, aFlags) && - mFocusedWindow == aWindow && mFocusedElement == nullptr) { - mFocusedElement = aElement; + if (CheckIfFocusable(aContent, aFlags) && + mFocusedWindow == aWindow && mFocusedContent == nullptr) { + mFocusedContent = aContent; - nsIContent* focusedNode = aWindow->GetFocusedElement(); - bool isRefocus = focusedNode && focusedNode->IsEqualNode(aElement); + nsIContent* focusedNode = aWindow->GetFocusedNode(); + bool isRefocus = focusedNode && focusedNode->IsEqualNode(aContent); - aWindow->SetFocusedElement(aElement, focusMethod); + aWindow->SetFocusedNode(aContent, focusMethod); // if the focused element changed, scroll it into view - if (aElement && aFocusChanged) { - ScrollIntoView(presShell, aElement, aFlags); + if (aContent && aFocusChanged) { + ScrollIntoView(presShell, aContent, aFlags); } bool sendFocusEvent = - aElement && aElement->IsInComposedDoc() && !IsNonFocusableRoot(aElement); + aContent && aContent->IsInComposedDoc() && !IsNonFocusableRoot(aContent); nsPresContext* presContext = presShell->GetPresContext(); if (sendFocusEvent) { - NotifyFocusStateChange(aElement, + NotifyFocusStateChange(aContent, nullptr, aWindow->ShouldShowFocusRing(), true); @@ -1982,18 +1975,18 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, // if this is an object/plug-in/remote browser, focus its widget. Note that we might // no longer be in the same document, due to the events we fired above when // aIsNewDocument. - if (presShell->GetDocument() == aElement->GetComposedDoc()) { + if (presShell->GetDocument() == aContent->GetComposedDoc()) { if (aAdjustWidgets && objectFrameWidget && !sTestMode) objectFrameWidget->SetFocus(false); // if the object being focused is a remote browser, activate remote content - if (TabParent* remote = TabParent::GetFrom(aElement)) { + if (TabParent* remote = TabParent::GetFrom(aContent)) { remote->Activate(); LOGFOCUS(("Remote browser activated")); } } - IMEStateManager::OnChangeFocus(presContext, aElement, + IMEStateManager::OnChangeFocus(presContext, aContent, GetFocusMoveActionCause(aFlags)); // as long as this focus wasn't because a window was raised, update the @@ -2003,8 +1996,8 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, aWindow->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0); SendFocusOrBlurEvent(eFocus, presShell, - aElement->GetComposedDoc(), - aElement, aFlags & FOCUSMETHOD_MASK, + aContent->GetComposedDoc(), + aContent, aFlags & FOCUSMETHOD_MASK, aWindowRaised, isRefocus, aContentLostFocus); } else { IMEStateManager::OnChangeFocus(presContext, nullptr, @@ -2019,7 +2012,7 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, // the plugin not to be focusable, update the system focus by focusing // the root widget. if (aAdjustWidgets && objectFrameWidget && - mFocusedWindow == aWindow && mFocusedElement == nullptr && + mFocusedWindow == aWindow && mFocusedContent == nullptr && !sTestMode) { nsViewManager* vm = presShell->GetViewManager(); if (vm) { @@ -2030,8 +2023,8 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, } } - if (!mFocusedElement) { - // When there is no focused element, IMEStateManager needs to adjust IME + if (!mFocusedContent) { + // When there is no focused content, IMEStateManager needs to adjust IME // enabled state with the document. nsPresContext* presContext = presShell->GetPresContext(); IMEStateManager::OnChangeFocus(presContext, nullptr, @@ -2048,9 +2041,9 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, // needed. If this is a different document than was focused before, also // update the caret's visibility. If this is the same document, the caret // visibility should be the same as before so there is no need to update it. - if (mFocusedElement == aElement) + if (mFocusedContent == aContent) UpdateCaret(aFocusChanged && !(aFlags & FLAG_BYMOUSE), aIsNewDocument, - mFocusedElement); + mFocusedContent); if (clearFirstFocusEvent) mFirstFocusEvent = nullptr; @@ -2116,7 +2109,7 @@ public: NS_IMETHOD Run() override { nsCOMPtr originalWindowFocus = mOriginalFocusedWindow ? - mOriginalFocusedWindow->GetFocusedElement() : + mOriginalFocusedWindow->GetFocusedNode() : nullptr; // Blink does not check that focus is the same after blur, but WebKit does. // Opt to follow Blink's behavior (see bug 687787). @@ -2239,7 +2232,7 @@ nsFocusManager::FireFocusOrBlurEvent(EventMessage aEventMessage, nsCOMPtr targetWindow = do_QueryInterface(aTarget); nsCOMPtr targetDocument = do_QueryInterface(aTarget); nsCOMPtr currentFocusedContent = currentWindow ? - currentWindow->GetFocusedElement() : nullptr; + currentWindow->GetFocusedNode() : nullptr; bool dontDispatchEvent = eventTargetDoc && nsContentUtils::IsUserFocusIgnored(eventTargetDoc); @@ -2360,7 +2353,7 @@ nsFocusManager::RaiseWindow(nsPIDOMWindowOuter* aWindow) void nsFocusManager::UpdateCaretForCaretBrowsingMode() { - UpdateCaret(false, true, mFocusedElement); + UpdateCaret(false, true, mFocusedContent); } void @@ -2694,7 +2687,7 @@ nsFocusManager::DetermineElementToMoveFocus(nsPIDOMWindowOuter* aWindow, // 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 // of the document. - startContent = aWindow->GetFocusedElement(); + startContent = aWindow->GetFocusedNode(); } } @@ -3021,13 +3014,13 @@ nsFocusManager::DetermineElementToMoveFocus(nsPIDOMWindowOuter* aWindow, // embedder or parent process that it should take the focus. bool tookFocus; docShell->TabToTreeOwner(forward, forDocumentNavigation, &tookFocus); - // If the tree owner took the focus, blur the current element. + // If the tree owner took the focus, blur the current content. if (tookFocus) { nsCOMPtr window = docShell->GetWindow(); - if (window->GetFocusedElement() == mFocusedElement) + if (window->GetFocusedNode() == mFocusedContent) Blur(mFocusedWindow, nullptr, true, true); else - window->SetFocusedElement(nullptr); + window->SetFocusedNode(nullptr); return NS_OK; } @@ -3964,7 +3957,7 @@ nsFocusManager::GetFocusInSelection(nsPIDOMWindowOuter* aWindow, nsCOMPtr testContent = aStartSelection; nsCOMPtr nextTestContent = aEndSelection; - nsCOMPtr currentFocus = aWindow->GetFocusedElement(); + nsCOMPtr currentFocus = aWindow->GetFocusedNode(); // We now have the correct start node in selectionContent! // Search for focusable elements, starting with selectionContent @@ -4131,8 +4124,8 @@ nsFocusManager::MarkUncollectableForCCGeneration(uint32_t aGeneration) sInstance->mWindowBeingLowered-> MarkUncollectableForCCGeneration(aGeneration); } - if (sInstance->mFocusedElement) { - sInstance->mFocusedElement->OwnerDoc()-> + if (sInstance->mFocusedContent) { + sInstance->mFocusedContent->OwnerDoc()-> MarkUncollectableForCCGeneration(aGeneration); } if (sInstance->mFirstBlurEvent) { @@ -4157,7 +4150,7 @@ nsFocusManager::CanSkipFocus(nsIContent* aContent) return false; } - if (mFocusedElement == aContent) { + if (mFocusedContent == aContent) { return true; } @@ -4172,7 +4165,7 @@ nsFocusManager::CanSkipFocus(nsIContent* aContent) root ? root->GetWindow() : nullptr; if (mActiveWindow != newRootWindow) { nsPIDOMWindowOuter* outerWindow = aContent->OwnerDoc()->GetWindow(); - if (outerWindow && outerWindow->GetFocusedElement() == aContent) { + if (outerWindow && outerWindow->GetFocusedNode() == aContent) { return true; } } diff --git a/dom/base/nsFocusManager.h b/dom/base/nsFocusManager.h index f57c8b714462..69daed16a18f 100644 --- a/dom/base/nsFocusManager.h +++ b/dom/base/nsFocusManager.h @@ -67,7 +67,7 @@ public: * raw Element pointer (instead of having AddRef-ed nsIDOMElement * pointer filled in to an out-parameter). */ - mozilla::dom::Element* GetFocusedElement() { return mFocusedElement; } + mozilla::dom::Element* GetFocusedContent() { return mFocusedContent; } /** * Returns true if aContent currently has focus. @@ -102,7 +102,7 @@ public: void NeedsFlushBeforeEventHandling(mozilla::dom::Element* aElement) { - if (mFocusedElement == aElement) { + if (mFocusedContent == aElement) { mEventHandlingNeedsFlush = true; } } @@ -645,7 +645,7 @@ private: // the currently focused content, which is always inside mFocusedWindow. This // is a cached copy of the mFocusedWindow's current content. This may be null // if no content is focused. - RefPtr mFocusedElement; + RefPtr mFocusedContent; // these fields store a content node temporarily while it is being focused // or blurred to ensure that a recursive call doesn't refire the same event. diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index 719c6c64031b..95235f05b406 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -1219,7 +1219,7 @@ nsGlobalWindowInner::FreeInnerObjects() } // Remove our reference to the document and the document principal. - mFocusedElement = nullptr; + mFocusedNode = nullptr; if (mApplicationCache) { static_cast(mApplicationCache.get())->Disconnect(); @@ -1451,7 +1451,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindowInner) // Traverse stuff from nsPIDOMWindow NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeEventHandler) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParentTarget) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFocusedElement) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFocusedNode) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMenubar) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mToolbar) @@ -1539,7 +1539,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindowInner) // Unlink stuff from nsPIDOMWindow NS_IMPL_CYCLE_COLLECTION_UNLINK(mChromeEventHandler) NS_IMPL_CYCLE_COLLECTION_UNLINK(mParentTarget) - NS_IMPL_CYCLE_COLLECTION_UNLINK(mFocusedElement) + NS_IMPL_CYCLE_COLLECTION_UNLINK(mFocusedNode) NS_IMPL_CYCLE_COLLECTION_UNLINK(mMenubar) NS_IMPL_CYCLE_COLLECTION_UNLINK(mToolbar) @@ -1700,7 +1700,7 @@ nsGlobalWindowInner::InnerSetNewDocument(JSContext* aCx, nsIDocument* aDocument) mDoc = aDocument; ClearDocumentDependentSlots(aCx); - mFocusedElement = nullptr; + mFocusedNode = nullptr; mLocalStorage = nullptr; mSessionStorage = nullptr; @@ -4652,28 +4652,28 @@ static bool ShouldShowFocusRingIfFocusedByMouse(nsIContent* aNode) } void -nsGlobalWindowInner::SetFocusedElement(Element* aElement, - uint32_t aFocusMethod, - bool aNeedsFocus) +nsGlobalWindowInner::SetFocusedNode(Element* aNode, + uint32_t aFocusMethod, + bool aNeedsFocus) { - if (aElement && aElement->GetComposedDoc() != mDoc) { + if (aNode && aNode->GetComposedDoc() != mDoc) { NS_WARNING("Trying to set focus to a node from a wrong document"); return; } if (IsDying()) { - NS_ASSERTION(!aElement, "Trying to focus cleaned up window!"); - aElement = nullptr; + NS_ASSERTION(!aNode, "Trying to focus cleaned up window!"); + aNode = nullptr; aNeedsFocus = false; } - if (mFocusedElement != aElement) { - UpdateCanvasFocus(false, aElement); - mFocusedElement = aElement; + if (mFocusedNode != aNode) { + UpdateCanvasFocus(false, aNode); + mFocusedNode = aNode; mFocusMethod = aFocusMethod & FOCUSMETHOD_MASK; mShowFocusRingForContent = false; } - if (mFocusedElement) { + if (mFocusedNode) { // if a node was focused by a keypress, turn on focus rings for the // window. if (mFocusMethod & nsIFocusManager::FLAG_BYKEY) { @@ -4685,7 +4685,7 @@ nsGlobalWindowInner::SetFocusedElement(Element* aElement, // are only visible on some elements. #ifndef XP_WIN !(mFocusMethod & nsIFocusManager::FLAG_BYMOUSE) || - ShouldShowFocusRingIfFocusedByMouse(aElement) || + ShouldShowFocusRingIfFocusedByMouse(aNode) || #endif aFocusMethod & nsIFocusManager::FLAG_SHOWRING) { mShowFocusRingForContent = true; @@ -4725,7 +4725,7 @@ nsGlobalWindowInner::TakeFocus(bool aFocus, uint32_t aFocusMethod) if (mHasFocus != aFocus) { mHasFocus = aFocus; - UpdateCanvasFocus(true, mFocusedElement); + UpdateCanvasFocus(true, mFocusedNode); } // 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(); if (rootElement) { if ((mHasFocus || aFocusChanged) && - (mFocusedElement == rootElement || aNewContent == rootElement)) { + (mFocusedNode == rootElement || aNewContent == rootElement)) { nsIFrame* frame = rootElement->GetPrimaryFrame(); if (frame) { frame = frame->GetParent(); diff --git a/dom/base/nsGlobalWindowInner.h b/dom/base/nsGlobalWindowInner.h index 3760fab596b2..a39170042486 100644 --- a/dom/base/nsGlobalWindowInner.h +++ b/dom/base/nsGlobalWindowInner.h @@ -1197,9 +1197,9 @@ public: bool IsInModalState(); - virtual void SetFocusedElement(mozilla::dom::Element* aElement, - uint32_t aFocusMethod = 0, - bool aNeedsFocus = false) override; + virtual void SetFocusedNode(mozilla::dom::Element* aNode, + uint32_t aFocusMethod = 0, + bool aNeedsFocus = false) override; virtual uint32_t GetFocusMethod() override; diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index 9127e7ddd9d0..116c20f1ea61 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -6626,12 +6626,11 @@ nsGlobalWindowOuter::SetChromeEventHandler(EventTarget* aChromeEventHandler) } void -nsGlobalWindowOuter::SetFocusedElement(Element* aElement, - uint32_t aFocusMethod, - bool aNeedsFocus) +nsGlobalWindowOuter::SetFocusedNode(Element* aNode, + uint32_t aFocusMethod, + bool aNeedsFocus) { - FORWARD_TO_INNER_VOID(SetFocusedElement, - (aElement, aFocusMethod, aNeedsFocus)); + FORWARD_TO_INNER_VOID(SetFocusedNode, (aNode, aFocusMethod, aNeedsFocus)); } uint32_t @@ -6678,13 +6677,13 @@ nsGlobalWindowOuter::SetKeyboardIndicators(UIStateChangeType aShowAccelerators, bool newShouldShowFocusRing = ShouldShowFocusRing(); if (mInnerWindow && nsGlobalWindowInner::Cast(mInnerWindow)->mHasFocus && - mInnerWindow->mFocusedElement && + mInnerWindow->mFocusedNode && oldShouldShowFocusRing != newShouldShowFocusRing) { // Update focusedNode's state. if (newShouldShowFocusRing) { - mInnerWindow->mFocusedElement->AddStates(NS_EVENT_STATE_FOCUSRING); + mInnerWindow->mFocusedNode->AddStates(NS_EVENT_STATE_FOCUSRING); } else { - mInnerWindow->mFocusedElement->RemoveStates(NS_EVENT_STATE_FOCUSRING); + mInnerWindow->mFocusedNode->RemoveStates(NS_EVENT_STATE_FOCUSRING); } } } @@ -7259,14 +7258,14 @@ nsGlobalWindowOuter::RestoreWindowState(nsISupports *aState) // 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. - Element* focusedElement = inner->GetFocusedElement(); - if (nsContentUtils::ContentIsLink(focusedElement)) { + Element* focusedNode = inner->GetFocusedNode(); + if (nsContentUtils::ContentIsLink(focusedNode)) { nsIFocusManager* fm = nsFocusManager::GetFocusManager(); if (fm) { // XXXbz Do we need the stack strong ref here? - RefPtr kungFuDeathGrip(focusedElement); - fm->SetFocus(kungFuDeathGrip, nsIFocusManager::FLAG_NOSCROLL | - nsIFocusManager::FLAG_SHOWRING); + RefPtr focusedElement = focusedNode; + fm->SetFocus(focusedElement, nsIFocusManager::FLAG_NOSCROLL | + nsIFocusManager::FLAG_SHOWRING); } } diff --git a/dom/base/nsGlobalWindowOuter.h b/dom/base/nsGlobalWindowOuter.h index 59b213da226a..11909a5446ec 100644 --- a/dom/base/nsGlobalWindowOuter.h +++ b/dom/base/nsGlobalWindowOuter.h @@ -979,9 +979,9 @@ public: nsIntSize DevToCSSIntPixels(nsIntSize px); nsIntSize CSSToDevIntPixels(nsIntSize px); - virtual void SetFocusedElement(mozilla::dom::Element* aElement, - uint32_t aFocusMethod = 0, - bool aNeedsFocus = false) override; + virtual void SetFocusedNode(mozilla::dom::Element* aNode, + uint32_t aFocusMethod = 0, + bool aNeedsFocus = false) override; virtual uint32_t GetFocusMethod() override; diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h index bf91d12d3646..34f94fb3f6f2 100644 --- a/dom/base/nsPIDOMWindow.h +++ b/dom/base/nsPIDOMWindow.h @@ -484,10 +484,10 @@ public: * DO NOT CALL EITHER OF THESE METHODS DIRECTLY. USE THE FOCUS MANAGER * INSTEAD. */ - inline mozilla::dom::Element* GetFocusedElement() const; - virtual void SetFocusedElement(mozilla::dom::Element* aElement, - uint32_t aFocusMethod = 0, - bool aNeedsFocus = false) = 0; + inline mozilla::dom::Element* GetFocusedNode() const; + virtual void SetFocusedNode(mozilla::dom::Element* aNode, + uint32_t aFocusMethod = 0, + bool aNeedsFocus = false) = 0; /** * Retrieves the method that was used to focus the current node. @@ -658,9 +658,9 @@ protected: // Our inner window's outer window. nsCOMPtr 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. - RefPtr mFocusedElement; + RefPtr mFocusedNode; // The AudioContexts created for the current document, if any. nsTArray mAudioContexts; // Weak @@ -973,10 +973,10 @@ public: * DO NOT CALL EITHER OF THESE METHODS DIRECTLY. USE THE FOCUS MANAGER * INSTEAD. */ - inline mozilla::dom::Element* GetFocusedElement() const; - virtual void SetFocusedElement(mozilla::dom::Element* aElement, - uint32_t aFocusMethod = 0, - bool aNeedsFocus = false) = 0; + inline mozilla::dom::Element* GetFocusedNode() const; + virtual void SetFocusedNode(mozilla::dom::Element* aNode, + uint32_t aFocusMethod = 0, + bool aNeedsFocus = false) = 0; /** * Retrieves the method that was used to focus the current node. diff --git a/dom/base/nsPIDOMWindowInlines.h b/dom/base/nsPIDOMWindowInlines.h index 413b4aea7372..6d3fad8f2d25 100644 --- a/dom/base/nsPIDOMWindowInlines.h +++ b/dom/base/nsPIDOMWindowInlines.h @@ -90,13 +90,13 @@ nsPIDOMWindowInner::GetDocShell() const } mozilla::dom::Element* -nsPIDOMWindowOuter::GetFocusedElement() const +nsPIDOMWindowOuter::GetFocusedNode() const { - return mInnerWindow ? mInnerWindow->GetFocusedElement() : nullptr; + return mInnerWindow ? mInnerWindow->GetFocusedNode() : nullptr; } mozilla::dom::Element* -nsPIDOMWindowInner::GetFocusedElement() const +nsPIDOMWindowInner::GetFocusedNode() const { - return mFocusedElement; + return mFocusedNode; } diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index f84da5c2b0eb..b5546d54287e 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -5589,7 +5589,7 @@ EventStateManager::DoContentCommandEvent(WidgetContentCommandEvent* aEvent) switch (aEvent->mMessage) { case eContentCommandPasteTransferable: { nsFocusManager* fm = nsFocusManager::GetFocusManager(); - nsIContent* focusedContent = fm ? fm->GetFocusedElement() : nullptr; + nsIContent* focusedContent = fm ? fm->GetFocusedContent() : nullptr; RefPtr remote = TabParent::GetFrom(focusedContent); if (remote) { NS_ENSURE_TRUE(remote->Manager()->IsContentParent(), NS_ERROR_FAILURE); diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index 75391e88f0a3..e83e54be96c4 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -2570,7 +2570,7 @@ nsGenericHTMLElement::PerformAccesskey(bool aKeyCausesActivation, // Return true if the element became the current focus within its window. nsPIDOMWindowOuter* window = OwnerDoc()->GetWindow(); - focused = (window && window->GetFocusedElement()); + focused = (window && window->GetFocusedNode()); } if (aKeyCausesActivation) { diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index 4fd07897045a..2982f530e82e 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -3297,7 +3297,7 @@ void nsPluginInstanceOwner::SetFrame(nsPluginFrame *aFrame) nsFocusManager* fm = nsFocusManager::GetFocusManager(); const nsIContent* content = aFrame->GetContent(); if (fm && content) { - mContentFocused = (content == fm->GetFocusedElement()); + mContentFocused = (content == fm->GetFocusedContent()); } // Register for widget-focus events on the window root. diff --git a/dom/xul/nsXULElement.cpp b/dom/xul/nsXULElement.cpp index 60b7052c4c07..398ed8d26801 100644 --- a/dom/xul/nsXULElement.cpp +++ b/dom/xul/nsXULElement.cpp @@ -598,7 +598,7 @@ nsXULElement::PerformAccesskey(bool aKeyCausesActivation, // Return true if the element became focused. nsPIDOMWindowOuter* window = OwnerDoc()->GetWindow(); - focused = (window && window->GetFocusedElement()); + focused = (window && window->GetFocusedNode()); } } } diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp index fbebe2d146e6..dbaf21fb3298 100644 --- a/editor/libeditor/EditorBase.cpp +++ b/editor/libeditor/EditorBase.cpp @@ -4958,7 +4958,7 @@ EditorBase::GetFocusedContent() nsFocusManager* fm = nsFocusManager::GetFocusManager(); NS_ENSURE_TRUE(fm, nullptr); - nsIContent* content = fm->GetFocusedElement(); + nsIContent* content = fm->GetFocusedContent(); MOZ_ASSERT((content == piTarget) == SameCOMIdentity(content, piTarget)); return (content == piTarget) ? content : nullptr; diff --git a/editor/libeditor/EditorEventListener.cpp b/editor/libeditor/EditorEventListener.cpp index 1295fa4c0953..643bb0f79a61 100644 --- a/editor/libeditor/EditorEventListener.cpp +++ b/editor/libeditor/EditorEventListener.cpp @@ -218,7 +218,7 @@ EditorEventListener::Disconnect() nsFocusManager* fm = nsFocusManager::GetFocusManager(); if (fm) { - nsIContent* focusedContent = fm->GetFocusedElement(); + nsIContent* focusedContent = fm->GetFocusedContent(); mozilla::dom::Element* root = mEditorBase->GetRoot(); if (focusedContent && root && nsContentUtils::ContentIsDescendantOf(focusedContent, root)) { @@ -1105,7 +1105,7 @@ EditorEventListener::Focus(InternalFocusEvent* aFocusEvent) nsFocusManager* fm = nsFocusManager::GetFocusManager(); NS_ENSURE_TRUE(fm, NS_OK); - nsIContent* focusedContent = fm->GetFocusedElement(); + nsIContent* focusedContent = fm->GetFocusedContent(); if (!focusedContent) { return NS_OK; } @@ -1147,8 +1147,8 @@ EditorEventListener::Blur(InternalFocusEvent* aBlurEvent) nsFocusManager* fm = nsFocusManager::GetFocusManager(); NS_ENSURE_TRUE(fm, NS_OK); - Element* focusedElement = fm->GetFocusedElement(); - if (!focusedElement) { + nsIContent* content = fm->GetFocusedContent(); + if (!content || !content->IsElement()) { RefPtr editorBase(mEditorBase); editorBase->FinalizeSelection(); } diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp index 0f8901102f5e..7e6b83849a1b 100644 --- a/editor/libeditor/HTMLEditor.cpp +++ b/editor/libeditor/HTMLEditor.cpp @@ -4788,7 +4788,7 @@ HTMLEditor::GetFocusedContent() nsFocusManager* fm = nsFocusManager::GetFocusManager(); NS_ENSURE_TRUE(fm, nullptr); - nsCOMPtr focusedContent = fm->GetFocusedElement(); + nsCOMPtr focusedContent = fm->GetFocusedContent(); nsCOMPtr document = GetDocument(); if (NS_WARN_IF(!document)) { diff --git a/layout/base/AccessibleCaretManager.cpp b/layout/base/AccessibleCaretManager.cpp index 53bb1b136f23..839b8204c8d9 100644 --- a/layout/base/AccessibleCaretManager.cpp +++ b/layout/base/AccessibleCaretManager.cpp @@ -769,7 +769,7 @@ AccessibleCaretManager::GetFrameSelection() const nsFocusManager* fm = nsFocusManager::GetFocusManager(); MOZ_ASSERT(fm); - nsIContent* focusedContent = fm->GetFocusedElement(); + nsIContent* focusedContent = fm->GetFocusedContent(); if (!focusedContent) { // For non-editable content return mPresShell->FrameSelection(); diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 9489749acfa7..cee756a8a479 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -955,7 +955,7 @@ nsComboboxControlFrame::ShowDropDown(bool aDoDropDown) if (!mDroppedDown && aDoDropDown) { nsFocusManager* fm = nsFocusManager::GetFocusManager(); - if (!fm || fm->GetFocusedElement() == GetContent()) { + if (!fm || fm->GetFocusedContent() == GetContent()) { DropDownPositionState state = AbsolutelyPositionDropDown(); if (state == eDropDownPositionFinal) { ShowList(aDoDropDown); // might destroy us diff --git a/toolkit/components/satchel/nsFormFillController.cpp b/toolkit/components/satchel/nsFormFillController.cpp index adb5119fab69..e930c018f3fd 100644 --- a/toolkit/components/satchel/nsFormFillController.cpp +++ b/toolkit/components/satchel/nsFormFillController.cpp @@ -307,7 +307,7 @@ nsFormFillController::MarkAsLoginManagerField(nsIDOMHTMLInputElement *aInput) nsFocusManager *fm = nsFocusManager::GetFocusManager(); if (fm) { - nsCOMPtr focusedContent = fm->GetFocusedElement(); + nsCOMPtr focusedContent = fm->GetFocusedContent(); if (focusedContent == node) { if (!mFocusedInput) { MaybeStartControllingInput(HTMLInputElement::FromNode(node)); @@ -347,7 +347,7 @@ nsFormFillController::MarkAsAutofillField(nsIDOMHTMLInputElement *aInput) nsFocusManager *fm = nsFocusManager::GetFocusManager(); if (fm) { - nsCOMPtr focusedContent = fm->GetFocusedElement(); + nsCOMPtr focusedContent = fm->GetFocusedContent(); if (focusedContent == node) { MaybeStartControllingInput(HTMLInputElement::FromNode(node)); }