Bug 1457155. Rename various focus manager variables to make it clearer that they're Elements. r=mccr8

This commit is contained in:
Boris Zbarsky
2018-04-26 15:28:31 -04:00
parent e501fdf1fd
commit 6fb00d932f
14 changed files with 141 additions and 138 deletions

View File

@@ -199,7 +199,7 @@ FocusManager::ActiveItemChanged(Accessible* aItem, bool aCheckIfActive)
if (!mActiveItem && XRE_IsParentProcess()) { if (!mActiveItem && XRE_IsParentProcess()) {
nsFocusManager* domfm = nsFocusManager::GetFocusManager(); nsFocusManager* domfm = nsFocusManager::GetFocusManager();
if (domfm) { if (domfm) {
nsIContent* focusedElm = domfm->GetFocusedContent(); nsIContent* focusedElm = domfm->GetFocusedElement();
if (EventStateManager::IsRemoteTarget(focusedElm)) { if (EventStateManager::IsRemoteTarget(focusedElm)) {
dom::TabParent* tab = dom::TabParent::GetFrom(focusedElm); dom::TabParent* tab = dom::TabParent::GetFrom(focusedElm);
if (tab) { if (tab) {
@@ -399,7 +399,7 @@ nsINode*
FocusManager::FocusedDOMNode() const FocusManager::FocusedDOMNode() const
{ {
nsFocusManager* DOMFocusManager = nsFocusManager::GetFocusManager(); nsFocusManager* DOMFocusManager = nsFocusManager::GetFocusManager();
nsIContent* focusedElm = DOMFocusManager->GetFocusedContent(); nsIContent* focusedElm = DOMFocusManager->GetFocusedElement();
// No focus on remote target elements like xul:browser having DOM focus and // 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 // residing in chrome process because it means an element in content process

View File

@@ -6700,7 +6700,7 @@ nsContentUtils::IsFocusedContent(const nsIContent* aContent)
{ {
nsFocusManager* fm = nsFocusManager::GetFocusManager(); nsFocusManager* fm = nsFocusManager::GetFocusManager();
return fm && fm->GetFocusedContent() == aContent; return fm && fm->GetFocusedElement() == aContent;
} }
bool bool

View File

@@ -2646,7 +2646,7 @@ nsDOMWindowUtils::ZoomToFocusedInput()
return NS_OK; return NS_OK;
} }
nsIContent* content = fm->GetFocusedContent(); nsIContent* content = fm->GetFocusedElement();
if (!content) { if (!content) {
return NS_OK; return NS_OK;
} }

View File

@@ -166,7 +166,7 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsFocusManager)
NS_IMPL_CYCLE_COLLECTION(nsFocusManager, NS_IMPL_CYCLE_COLLECTION(nsFocusManager,
mActiveWindow, mActiveWindow,
mFocusedWindow, mFocusedWindow,
mFocusedContent, mFocusedElement,
mFirstBlurEvent, mFirstBlurEvent,
mFirstFocusEvent, mFirstFocusEvent,
mWindowBeingLowered, mWindowBeingLowered,
@@ -259,7 +259,7 @@ nsFocusManager::Observe(nsISupports *aSubject,
} else if (!nsCRT::strcmp(aTopic, "xpcom-shutdown")) { } else if (!nsCRT::strcmp(aTopic, "xpcom-shutdown")) {
mActiveWindow = nullptr; mActiveWindow = nullptr;
mFocusedWindow = nullptr; mFocusedWindow = nullptr;
mFocusedContent = nullptr; mFocusedElement = nullptr;
mFirstBlurEvent = nullptr; mFirstBlurEvent = nullptr;
mFirstFocusEvent = nullptr; mFirstFocusEvent = nullptr;
mWindowBeingLowered = nullptr; mWindowBeingLowered = nullptr;
@@ -287,10 +287,10 @@ GetContentWindow(nsIContent* aContent)
bool bool
nsFocusManager::IsFocused(nsIContent* aContent) nsFocusManager::IsFocused(nsIContent* aContent)
{ {
if (!aContent || !mFocusedContent) { if (!aContent || !mFocusedElement) {
return false; return false;
} }
return aContent == mFocusedContent.get(); return aContent == mFocusedElement;
} }
// get the current window for the given content node // get the current window for the given content node
@@ -311,16 +311,16 @@ nsFocusManager::GetFocusedDescendant(nsPIDOMWindowOuter* aWindow,
*aFocusedWindow = nullptr; *aFocusedWindow = nullptr;
Element* currentContent = nullptr; Element* currentElement = nullptr;
nsPIDOMWindowOuter* window = aWindow; nsPIDOMWindowOuter* window = aWindow;
for (;;) { for (;;) {
*aFocusedWindow = window; *aFocusedWindow = window;
currentContent = window->GetFocusedElement(); currentElement = window->GetFocusedElement();
if (!currentContent || aSearchRange == eOnlyCurrentWindow) { if (!currentElement || aSearchRange == eOnlyCurrentWindow) {
break; break;
} }
window = GetContentWindow(currentContent); window = GetContentWindow(currentElement);
if (!window) { if (!window) {
break; break;
} }
@@ -345,7 +345,7 @@ nsFocusManager::GetFocusedDescendant(nsPIDOMWindowOuter* aWindow,
NS_IF_ADDREF(*aFocusedWindow); NS_IF_ADDREF(*aFocusedWindow);
return currentContent; return currentElement;
} }
// static // static
@@ -487,8 +487,8 @@ NS_IMETHODIMP nsFocusManager::SetFocusedWindow(mozIDOMWindowProxy* aWindowToFocu
NS_IMETHODIMP NS_IMETHODIMP
nsFocusManager::GetFocusedElement(nsIDOMElement** aFocusedElement) nsFocusManager::GetFocusedElement(nsIDOMElement** aFocusedElement)
{ {
if (mFocusedContent) if (mFocusedElement)
CallQueryInterface(mFocusedContent, aFocusedElement); CallQueryInterface(mFocusedElement, aFocusedElement);
else else
*aFocusedElement = nullptr; *aFocusedElement = nullptr;
return NS_OK; return NS_OK;
@@ -554,7 +554,7 @@ nsFocusManager::MoveFocus(mozIDOMWindowProxy* aWindow, Element* aStartElement,
} }
} }
LOGCONTENT(" Current Focus: %s", mFocusedContent.get()); LOGCONTENT(" Current Focus: %s", mFocusedElement.get());
// use FLAG_BYMOVEFOCUS when switching focus with MoveFocus unless one of // 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 // the other focus methods is already set, or we're just moving to the root
@@ -859,7 +859,7 @@ nsFocusManager::ContentRemoved(nsIDocument* aDocument, nsIContent* aContent)
// 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.
if (window == mFocusedWindow) { if (window == mFocusedWindow) {
mFocusedContent = nullptr; mFocusedElement = nullptr;
} else { } else {
// Check if the node that was focused is an iframe or similar by looking // 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 // 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 // window, or an ancestor of the focused window. Either way, the focus is no
// longer valid, so it needs to be updated. // longer valid, so it needs to be updated.
nsCOMPtr<nsIContent> oldFocusedContent = mFocusedContent.forget(); RefPtr<Element> oldFocusedElement = mFocusedElement.forget();
nsCOMPtr<nsIDocShell> focusedDocShell = mFocusedWindow->GetDocShell(); nsCOMPtr<nsIDocShell> focusedDocShell = mFocusedWindow->GetDocShell();
nsCOMPtr<nsIPresShell> presShell = focusedDocShell->GetPresShell(); nsCOMPtr<nsIPresShell> presShell = focusedDocShell->GetPresShell();
if (oldFocusedContent && oldFocusedContent->IsInComposedDoc()) { if (oldFocusedElement && oldFocusedElement->IsInComposedDoc()) {
NotifyFocusStateChange(oldFocusedContent, NotifyFocusStateChange(oldFocusedElement,
nullptr, nullptr,
mFocusedWindow->ShouldShowFocusRing(), mFocusedWindow->ShouldShowFocusRing(),
false); false);
@@ -1007,8 +1007,8 @@ nsFocusManager::WindowHidden(mozIDOMWindowProxy* aWindow)
if (presShell) { if (presShell) {
SendFocusOrBlurEvent(eBlur, presShell, SendFocusOrBlurEvent(eBlur, presShell,
oldFocusedContent->GetComposedDoc(), oldFocusedElement->GetComposedDoc(),
oldFocusedContent, 1, false); oldFocusedElement, 1, false);
} }
} }
@@ -1227,18 +1227,19 @@ nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags,
bool aFocusChanged, bool aAdjustWidget) bool aFocusChanged, bool aAdjustWidget)
{ {
// if the element is not focusable, just return and leave the focus as is // if the element is not focusable, just return and leave the focus as is
RefPtr<Element> contentToFocus = CheckIfFocusable(aNewContent, aFlags); RefPtr<Element> elementToFocus = CheckIfFocusable(aNewContent, aFlags);
if (!contentToFocus) if (!elementToFocus) {
return; return;
}
// check if the element to focus is a frame (iframe) containing a child // check if the element to focus is a frame (iframe) containing a child
// document. Frames are never directly focused; instead focusing a frame // document. Frames are never directly focused; instead focusing a frame
// means focus what is inside the frame. To do this, the descendant content // means focus what is inside the frame. To do this, the descendant content
// within the frame is retrieved and that will be focused instead. // within the frame is retrieved and that will be focused instead.
nsCOMPtr<nsPIDOMWindowOuter> newWindow; nsCOMPtr<nsPIDOMWindowOuter> newWindow;
nsCOMPtr<nsPIDOMWindowOuter> subWindow = GetContentWindow(contentToFocus); nsCOMPtr<nsPIDOMWindowOuter> subWindow = GetContentWindow(elementToFocus);
if (subWindow) { if (subWindow) {
contentToFocus = GetFocusedDescendant(subWindow, eIncludeAllDescendants, elementToFocus = GetFocusedDescendant(subWindow, eIncludeAllDescendants,
getter_AddRefs(newWindow)); getter_AddRefs(newWindow));
// since a window is being refocused, clear aFocusChanged so that the // since a window is being refocused, clear aFocusChanged so that the
// caret position isn't updated. // caret position isn't updated.
@@ -1246,14 +1247,17 @@ nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags,
} }
// unless it was set above, retrieve the window for the element to focus // unless it was set above, retrieve the window for the element to focus
if (!newWindow) if (!newWindow) {
newWindow = GetCurrentWindow(contentToFocus); newWindow = GetCurrentWindow(elementToFocus);
}
// if the element is already focused, just return. Note that this happens // 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 // after the frame check above so that we compare the element that will be
// focused rather than the frame it is in. // focused rather than the frame it is in.
if (!newWindow || (newWindow == mFocusedWindow && contentToFocus == mFocusedContent)) if (!newWindow ||
(newWindow == mFocusedWindow && elementToFocus == mFocusedElement)) {
return; return;
}
// don't allow focus to be placed in docshells or descendants of docshells // 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 // that are being destroyed. Also, ensure that the page hasn't been
@@ -1318,16 +1322,16 @@ nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags,
// key input if a windowed plugin is focused, so just exit fullscreen // key input if a windowed plugin is focused, so just exit fullscreen
// to guard against phishing. // to guard against phishing.
#ifndef XP_MACOSX #ifndef XP_MACOSX
if (contentToFocus && if (elementToFocus &&
nsContentUtils:: nsContentUtils::
GetRootDocument(contentToFocus->OwnerDoc())->GetFullscreenElement() && GetRootDocument(elementToFocus->OwnerDoc())->GetFullscreenElement() &&
nsContentUtils::HasPluginWithUncontrolledEventDispatch(contentToFocus)) { nsContentUtils::HasPluginWithUncontrolledEventDispatch(elementToFocus)) {
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("DOM"), NS_LITERAL_CSTRING("DOM"),
contentToFocus->OwnerDoc(), elementToFocus->OwnerDoc(),
nsContentUtils::eDOM_PROPERTIES, nsContentUtils::eDOM_PROPERTIES,
"FocusedWindowedPluginWhileFullscreen"); "FocusedWindowedPluginWhileFullscreen");
nsIDocument::AsyncExitFullscreen(contentToFocus->OwnerDoc()); nsIDocument::AsyncExitFullscreen(elementToFocus->OwnerDoc());
} }
#endif #endif
@@ -1347,12 +1351,12 @@ nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags,
// * isn't called by trusted event (i.e., called by untrusted event or by js) // * isn't called by trusted event (i.e., called by untrusted event or by js)
// * the focus is moved to another document's element // * the focus is moved to another document's element
// we need to check the permission. // we need to check the permission.
if (sendFocusEvent && mFocusedContent && !nsContentUtils::LegacyIsCallerNativeCode() && if (sendFocusEvent && mFocusedElement && !nsContentUtils::LegacyIsCallerNativeCode() &&
mFocusedContent->OwnerDoc() != aNewContent->OwnerDoc()) { mFocusedElement->OwnerDoc() != aNewContent->OwnerDoc()) {
// If the caller cannot access the current focused node, the caller should // 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 // 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. // is in chrome, any web contents should not be able to steal the focus.
nsCOMPtr<nsIDOMNode> domNode(do_QueryInterface(mFocusedContent)); nsCOMPtr<nsIDOMNode> domNode(do_QueryInterface(mFocusedElement));
sendFocusEvent = nsContentUtils::CanCallerAccess(domNode); sendFocusEvent = nsContentUtils::CanCallerAccess(domNode);
if (!sendFocusEvent && mMouseButtonEventHandlingDocument) { if (!sendFocusEvent && mMouseButtonEventHandlingDocument) {
// However, while mouse button event is handling, the handling document's // However, while mouse button event is handling, the handling document's
@@ -1362,14 +1366,14 @@ nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags,
} }
} }
LOGCONTENT("Shift Focus: %s", contentToFocus.get()); LOGCONTENT("Shift Focus: %s", elementToFocus.get());
LOGFOCUS((" Flags: %x Current Window: %p New Window: %p Current Element: %p", LOGFOCUS((" Flags: %x Current Window: %p New Window: %p Current Element: %p",
aFlags, mFocusedWindow.get(), newWindow.get(), mFocusedContent.get())); aFlags, mFocusedWindow.get(), newWindow.get(), mFocusedElement.get()));
LOGFOCUS((" In Active Window: %d In Focused Window: %d SendFocus: %d", LOGFOCUS((" In Active Window: %d In Focused Window: %d SendFocus: %d",
isElementInActiveWindow, isElementInFocusedWindow, sendFocusEvent)); isElementInActiveWindow, isElementInFocusedWindow, sendFocusEvent));
if (sendFocusEvent) { if (sendFocusEvent) {
RefPtr<Element> oldFocusedContent = mFocusedContent; RefPtr<Element> oldFocusedElement = mFocusedElement;
// return if blurring fails or the focus changes during the blur // return if blurring fails or the focus changes during the blur
if (mFocusedWindow) { if (mFocusedWindow) {
// if the focus is being moved to another element in the same document, // if the focus is being moved to another element in the same document,
@@ -1396,12 +1400,13 @@ nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags,
if (!Blur(currentIsSameOrAncestor ? mFocusedWindow.get() : nullptr, if (!Blur(currentIsSameOrAncestor ? mFocusedWindow.get() : nullptr,
commonAncestor, !isElementInFocusedWindow, aAdjustWidget, commonAncestor, !isElementInFocusedWindow, aAdjustWidget,
contentToFocus)) elementToFocus)) {
return; return;
} }
}
Focus(newWindow, contentToFocus, aFlags, !isElementInFocusedWindow, Focus(newWindow, elementToFocus, aFlags, !isElementInFocusedWindow,
aFocusChanged, false, aAdjustWidget, oldFocusedContent); aFocusChanged, false, aAdjustWidget, oldFocusedElement);
} }
else { else {
// otherwise, for inactive windows and when the caller cannot steal the // otherwise, for inactive windows and when the caller cannot steal the
@@ -1412,13 +1417,13 @@ 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->SetFocusedElement(contentToFocus, focusMethod); newWindow->SetFocusedElement(elementToFocus, focusMethod);
if (aFocusChanged) { if (aFocusChanged) {
nsCOMPtr<nsIDocShell> docShell = newWindow->GetDocShell(); nsCOMPtr<nsIDocShell> docShell = newWindow->GetDocShell();
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell(); nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
if (presShell && presShell->DidInitialize()) if (presShell && presShell->DidInitialize())
ScrollIntoView(presShell, contentToFocus, aFlags); ScrollIntoView(presShell, elementToFocus, aFlags);
} }
// update the commands even when inactive so that the attributes for that // update the commands even when inactive so that the attributes for that
@@ -1579,22 +1584,22 @@ nsFocusManager::IsNonFocusableRoot(nsIContent* aContent)
} }
Element* Element*
nsFocusManager::CheckIfFocusable(Element* aContent, uint32_t aFlags) nsFocusManager::CheckIfFocusable(Element* aElement, uint32_t aFlags)
{ {
if (!aContent) if (!aElement)
return nullptr; return nullptr;
// this is a special case for some XUL elements or input number, where an // this is a special case for some XUL elements or input number, where an
// anonymous child is actually focusable and not the element itself. // anonymous child is actually focusable and not the element itself.
RefPtr<Element> redirectedFocus = GetRedirectedFocus(aContent); RefPtr<Element> redirectedFocus = GetRedirectedFocus(aElement);
if (redirectedFocus) { if (redirectedFocus) {
return CheckIfFocusable(redirectedFocus, aFlags); return CheckIfFocusable(redirectedFocus, aFlags);
} }
nsCOMPtr<nsIDocument> doc = aContent->GetComposedDoc(); nsCOMPtr<nsIDocument> doc = aElement->GetComposedDoc();
// can't focus elements that are not in documents // can't focus elements that are not in documents
if (!doc) { if (!doc) {
LOGCONTENT("Cannot focus %s because content not in document", aContent) LOGCONTENT("Cannot focus %s because content not in document", aElement)
return nullptr; return nullptr;
} }
@@ -1609,44 +1614,44 @@ nsFocusManager::CheckIfFocusable(Element* aContent, uint32_t aFlags)
// the root content can always be focused, // the root content can always be focused,
// except in userfocusignored context. // except in userfocusignored context.
if (aContent == doc->GetRootElement()) { if (aElement == doc->GetRootElement()) {
return nsContentUtils::IsUserFocusIgnored(aContent) ? nullptr : aContent; return nsContentUtils::IsUserFocusIgnored(aElement) ? nullptr : aElement;
} }
// cannot focus content in print preview mode. Only the root can be focused. // cannot focus content in print preview mode. Only the root can be focused.
nsPresContext* presContext = shell->GetPresContext(); nsPresContext* presContext = shell->GetPresContext();
if (presContext && presContext->Type() == nsPresContext::eContext_PrintPreview) { if (presContext && presContext->Type() == nsPresContext::eContext_PrintPreview) {
LOGCONTENT("Cannot focus %s while in print preview", aContent) LOGCONTENT("Cannot focus %s while in print preview", aElement)
return nullptr; return nullptr;
} }
nsIFrame* frame = aContent->GetPrimaryFrame(); nsIFrame* frame = aElement->GetPrimaryFrame();
if (!frame) { if (!frame) {
LOGCONTENT("Cannot focus %s as it has no frame", aContent) LOGCONTENT("Cannot focus %s as it has no frame", aElement)
return nullptr; return nullptr;
} }
if (aContent->IsHTMLElement(nsGkAtoms::area)) { if (aElement->IsHTMLElement(nsGkAtoms::area)) {
// HTML areas do not have their own frame, and the img frame we get from // 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 // GetPrimaryFrame() is not relevant as to whether it is focusable or
// not, so we have to do all the relevant checks manually for them. // not, so we have to do all the relevant checks manually for them.
return frame->IsVisibleConsideringAncestors() && return frame->IsVisibleConsideringAncestors() &&
aContent->IsFocusable() ? aContent : nullptr; aElement->IsFocusable() ? aElement : nullptr;
} }
// if this is a child frame content node, check if it is visible and // 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 // call the content node's IsFocusable method instead of the frame's
// IsFocusable method. This skips checking the style system and ensures that // IsFocusable method. This skips checking the style system and ensures that
// offscreen browsers can still be focused. // offscreen browsers can still be focused.
nsIDocument* subdoc = doc->GetSubDocumentFor(aContent); nsIDocument* subdoc = doc->GetSubDocumentFor(aElement);
if (subdoc && IsWindowVisible(subdoc->GetWindow())) { if (subdoc && IsWindowVisible(subdoc->GetWindow())) {
const nsStyleUserInterface* ui = frame->StyleUserInterface(); const nsStyleUserInterface* ui = frame->StyleUserInterface();
int32_t tabIndex = (ui->mUserFocus == StyleUserFocus::Ignore || int32_t tabIndex = (ui->mUserFocus == StyleUserFocus::Ignore ||
ui->mUserFocus == StyleUserFocus::None) ? -1 : 0; ui->mUserFocus == StyleUserFocus::None) ? -1 : 0;
return aContent->IsFocusable(&tabIndex, aFlags & FLAG_BYMOUSE) ? aContent : nullptr; return aElement->IsFocusable(&tabIndex, aFlags & FLAG_BYMOUSE) ? aElement : nullptr;
} }
return frame->IsFocusable(nullptr, aFlags & FLAG_BYMOUSE) ? aContent : nullptr; return frame->IsFocusable(nullptr, aFlags & FLAG_BYMOUSE) ? aElement : nullptr;
} }
bool bool
@@ -1659,26 +1664,26 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear,
LOGFOCUS(("<<Blur begin>>")); LOGFOCUS(("<<Blur begin>>"));
// hold a reference to the focused content, which may be null // hold a reference to the focused content, which may be null
RefPtr<Element> content = mFocusedContent; RefPtr<Element> element = mFocusedElement;
if (content) { if (element) {
if (!content->IsInComposedDoc()) { if (!element->IsInComposedDoc()) {
mFocusedContent = nullptr; mFocusedElement = nullptr;
return true; return true;
} }
if (content == mFirstBlurEvent) if (element == mFirstBlurEvent)
return true; return true;
} }
// hold a reference to the focused window // hold a reference to the focused window
nsCOMPtr<nsPIDOMWindowOuter> window = mFocusedWindow; nsCOMPtr<nsPIDOMWindowOuter> window = mFocusedWindow;
if (!window) { if (!window) {
mFocusedContent = nullptr; mFocusedElement = nullptr;
return true; return true;
} }
nsCOMPtr<nsIDocShell> docShell = window->GetDocShell(); nsCOMPtr<nsIDocShell> docShell = window->GetDocShell();
if (!docShell) { if (!docShell) {
mFocusedContent = nullptr; mFocusedElement = nullptr;
return true; return true;
} }
@@ -1686,13 +1691,13 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear,
// the document to be destroyed. // the document to be destroyed.
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell(); nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
if (!presShell) { if (!presShell) {
mFocusedContent = nullptr; mFocusedElement = nullptr;
return true; return true;
} }
bool clearFirstBlurEvent = false; bool clearFirstBlurEvent = false;
if (!mFirstBlurEvent) { if (!mFirstBlurEvent) {
mFirstBlurEvent = content; mFirstBlurEvent = element;
clearFirstBlurEvent = true; clearFirstBlurEvent = true;
} }
@@ -1703,19 +1708,19 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear,
// now adjust the actual focus, by clearing the fields in the focus manager // now adjust the actual focus, by clearing the fields in the focus manager
// and in the window. // and in the window.
mFocusedContent = nullptr; mFocusedElement = nullptr;
bool shouldShowFocusRing = window->ShouldShowFocusRing(); bool shouldShowFocusRing = window->ShouldShowFocusRing();
if (aWindowToClear) if (aWindowToClear)
aWindowToClear->SetFocusedElement(nullptr); aWindowToClear->SetFocusedElement(nullptr);
LOGCONTENT("Element %s has been blurred", content.get()); LOGCONTENT("Element %s has been blurred", element.get());
// Don't fire blur event on the root content which isn't editable. // Don't fire blur event on the root content which isn't editable.
bool sendBlurEvent = bool sendBlurEvent =
content && content->IsInComposedDoc() && !IsNonFocusableRoot(content); element && element->IsInComposedDoc() && !IsNonFocusableRoot(element);
if (content) { if (element) {
if (sendBlurEvent) { if (sendBlurEvent) {
NotifyFocusStateChange(content, NotifyFocusStateChange(element,
aContentToFocus, aContentToFocus,
shouldShowFocusRing, shouldShowFocusRing,
false); false);
@@ -1726,7 +1731,7 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear,
// But don't do this if we are blurring due to the window being lowered, // But don't do this if we are blurring due to the window being lowered,
// otherwise, the parent window can get raised again. // otherwise, the parent window can get raised again.
if (mActiveWindow) { if (mActiveWindow) {
nsIFrame* contentFrame = content->GetPrimaryFrame(); nsIFrame* contentFrame = element->GetPrimaryFrame();
nsIObjectFrame* objectFrame = do_QueryFrame(contentFrame); nsIObjectFrame* objectFrame = do_QueryFrame(contentFrame);
if (aAdjustWidgets && objectFrame && !sTestMode) { if (aAdjustWidgets && objectFrame && !sTestMode) {
if (XRE_IsContentProcess()) { if (XRE_IsContentProcess()) {
@@ -1752,7 +1757,7 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear,
} }
// if the object being blurred is a remote browser, deactivate remote content // if the object being blurred is a remote browser, deactivate remote content
if (TabParent* remote = TabParent::GetFrom(content)) { if (TabParent* remote = TabParent::GetFrom(element)) {
remote->Deactivate(); remote->Deactivate();
LOGFOCUS(("Remote browser deactivated")); LOGFOCUS(("Remote browser deactivated"));
} }
@@ -1767,7 +1772,7 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear,
window->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0); window->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0);
SendFocusOrBlurEvent(eBlur, presShell, SendFocusOrBlurEvent(eBlur, presShell,
content->GetComposedDoc(), content, 1, element->GetComposedDoc(), element, 1,
false, false, aContentToFocus); false, false, aContentToFocus);
} }
@@ -1783,13 +1788,13 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear,
} }
// at this point, it is expected that this window will be still be // at this point, it is expected that this window will be still be
// focused, but the focused content will be null, as it was cleared before // focused, but the focused element will be null, as it was cleared before
// the event. If this isn't the case, then something else was focused during // 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 // the blur event above and we should just return. However, if
// aIsLeavingDocument is set, a new document is desired, so make sure to // aIsLeavingDocument is set, a new document is desired, so make sure to
// blur the document and window. // blur the document and window.
if (mFocusedWindow != window || if (mFocusedWindow != window ||
(mFocusedContent != nullptr && !aIsLeavingDocument)) { (mFocusedElement != nullptr && !aIsLeavingDocument)) {
result = false; result = false;
} }
else if (aIsLeavingDocument) { else if (aIsLeavingDocument) {
@@ -1802,7 +1807,7 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear,
aAncestorWindowToFocus->SetFocusedElement(nullptr, 0, true); aAncestorWindowToFocus->SetFocusedElement(nullptr, 0, true);
SetFocusedWindowInternal(nullptr); SetFocusedWindowInternal(nullptr);
mFocusedContent = nullptr; mFocusedElement = nullptr;
// pass 1 for the focus method when calling SendFocusOrBlurEvent just so // pass 1 for the focus method when calling SendFocusOrBlurEvent just so
// that the check is made for suppressed documents. Check to ensure that // that the check is made for suppressed documents. Check to ensure that
@@ -1834,7 +1839,7 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear,
void void
nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow,
Element* aContent, Element* aElement,
uint32_t aFlags, uint32_t aFlags,
bool aIsNewDocument, bool aIsNewDocument,
bool aFocusChanged, bool aFocusChanged,
@@ -1847,7 +1852,7 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow,
if (!aWindow) if (!aWindow)
return; return;
if (aContent && (aContent == mFirstFocusEvent || aContent == mFirstBlurEvent)) if (aElement && (aElement == mFirstFocusEvent || aElement == mFirstBlurEvent))
return; return;
// Keep a reference to the presShell since dispatching the DOM event may // Keep a reference to the presShell since dispatching the DOM event may
@@ -1869,21 +1874,21 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow,
if (!IsWindowVisible(aWindow)) { if (!IsWindowVisible(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(aElement, aFlags)) {
aWindow->SetFocusedElement(aContent, focusMethod); aWindow->SetFocusedElement(aElement, focusMethod);
if (aFocusChanged) if (aFocusChanged)
ScrollIntoView(presShell, aContent, aFlags); ScrollIntoView(presShell, aElement, aFlags);
} }
return; return;
} }
bool clearFirstFocusEvent = false; bool clearFirstFocusEvent = false;
if (!mFirstFocusEvent) { if (!mFirstFocusEvent) {
mFirstFocusEvent = aContent; mFirstFocusEvent = aElement;
clearFirstFocusEvent = true; clearFirstFocusEvent = true;
} }
LOGCONTENT("Element %s has been focused", aContent); LOGCONTENT("Element %s has been focused", aElement);
if (MOZ_LOG_TEST(gFocusLog, LogLevel::Debug)) { if (MOZ_LOG_TEST(gFocusLog, LogLevel::Debug)) {
nsIDocument* docm = aWindow->GetExtantDoc(); nsIDocument* docm = aWindow->GetExtantDoc();
@@ -1908,11 +1913,11 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow,
SetFocusedWindowInternal(aWindow); SetFocusedWindowInternal(aWindow);
// Update the system focus by focusing the root widget. But avoid this // Update the system focus by focusing the root widget. But avoid this
// if 1) aAdjustWidgets is false or 2) aContent is a plugin that has its // if 1) aAdjustWidgets is false or 2) aElement is a plugin that has its
// own widget and is either already focused or is about to be focused. // own widget and is either already focused or is about to be focused.
nsCOMPtr<nsIWidget> objectFrameWidget; nsCOMPtr<nsIWidget> objectFrameWidget;
if (aContent) { if (aElement) {
nsIFrame* contentFrame = aContent->GetPrimaryFrame(); nsIFrame* contentFrame = aElement->GetPrimaryFrame();
nsIObjectFrame* objectFrame = do_QueryFrame(contentFrame); nsIObjectFrame* objectFrame = do_QueryFrame(contentFrame);
if (objectFrame) if (objectFrame)
objectFrameWidget = objectFrame->GetWidget(); objectFrameWidget = objectFrame->GetWidget();
@@ -1932,42 +1937,44 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow,
if (aIsNewDocument) { if (aIsNewDocument) {
nsIDocument* doc = aWindow->GetExtantDoc(); nsIDocument* doc = aWindow->GetExtantDoc();
// The focus change should be notified to IMEStateManager from here if // The focus change should be notified to IMEStateManager from here if
// the focused content is a designMode editor since any content won't // the focused element is a designMode editor since any content won't
// receive focus event. // receive focus event.
if (doc && doc->HasFlag(NODE_IS_EDITABLE)) { if (doc && doc->HasFlag(NODE_IS_EDITABLE)) {
IMEStateManager::OnChangeFocus(presShell->GetPresContext(), nullptr, IMEStateManager::OnChangeFocus(presShell->GetPresContext(), nullptr,
GetFocusMoveActionCause(aFlags)); GetFocusMoveActionCause(aFlags));
} }
if (doc) if (doc) {
SendFocusOrBlurEvent(eFocus, presShell, doc, SendFocusOrBlurEvent(eFocus, presShell, doc,
doc, aFlags & FOCUSMETHOD_MASK, aWindowRaised); doc, aFlags & FOCUSMETHOD_MASK, aWindowRaised);
if (mFocusedWindow == aWindow && mFocusedContent == nullptr) }
if (mFocusedWindow == aWindow && mFocusedElement == nullptr) {
SendFocusOrBlurEvent(eFocus, presShell, doc, SendFocusOrBlurEvent(eFocus, presShell, doc,
aWindow->GetCurrentInnerWindow(), aWindow->GetCurrentInnerWindow(),
aFlags & FOCUSMETHOD_MASK, aWindowRaised); aFlags & FOCUSMETHOD_MASK, aWindowRaised);
} }
}
// check to ensure that the element is still focusable, and that nothing // check to ensure that the element is still focusable, and that nothing
// else was focused during the events above. // else was focused during the events above.
if (CheckIfFocusable(aContent, aFlags) && if (CheckIfFocusable(aElement, aFlags) &&
mFocusedWindow == aWindow && mFocusedContent == nullptr) { mFocusedWindow == aWindow && mFocusedElement == nullptr) {
mFocusedContent = aContent; mFocusedElement = aElement;
nsIContent* focusedNode = aWindow->GetFocusedElement(); nsIContent* focusedNode = aWindow->GetFocusedElement();
bool isRefocus = focusedNode && focusedNode->IsEqualNode(aContent); bool isRefocus = focusedNode && focusedNode->IsEqualNode(aElement);
aWindow->SetFocusedElement(aContent, focusMethod); aWindow->SetFocusedElement(aElement, focusMethod);
// if the focused element changed, scroll it into view // if the focused element changed, scroll it into view
if (aContent && aFocusChanged) { if (aElement && aFocusChanged) {
ScrollIntoView(presShell, aContent, aFlags); ScrollIntoView(presShell, aElement, aFlags);
} }
bool sendFocusEvent = bool sendFocusEvent =
aContent && aContent->IsInComposedDoc() && !IsNonFocusableRoot(aContent); aElement && aElement->IsInComposedDoc() && !IsNonFocusableRoot(aElement);
nsPresContext* presContext = presShell->GetPresContext(); nsPresContext* presContext = presShell->GetPresContext();
if (sendFocusEvent) { if (sendFocusEvent) {
NotifyFocusStateChange(aContent, NotifyFocusStateChange(aElement,
nullptr, nullptr,
aWindow->ShouldShowFocusRing(), aWindow->ShouldShowFocusRing(),
true); true);
@@ -1975,18 +1982,18 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow,
// if this is an object/plug-in/remote browser, focus its widget. Note that we might // 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 // no longer be in the same document, due to the events we fired above when
// aIsNewDocument. // aIsNewDocument.
if (presShell->GetDocument() == aContent->GetComposedDoc()) { if (presShell->GetDocument() == aElement->GetComposedDoc()) {
if (aAdjustWidgets && objectFrameWidget && !sTestMode) if (aAdjustWidgets && objectFrameWidget && !sTestMode)
objectFrameWidget->SetFocus(false); objectFrameWidget->SetFocus(false);
// if the object being focused is a remote browser, activate remote content // if the object being focused is a remote browser, activate remote content
if (TabParent* remote = TabParent::GetFrom(aContent)) { if (TabParent* remote = TabParent::GetFrom(aElement)) {
remote->Activate(); remote->Activate();
LOGFOCUS(("Remote browser activated")); LOGFOCUS(("Remote browser activated"));
} }
} }
IMEStateManager::OnChangeFocus(presContext, aContent, IMEStateManager::OnChangeFocus(presContext, aElement,
GetFocusMoveActionCause(aFlags)); GetFocusMoveActionCause(aFlags));
// as long as this focus wasn't because a window was raised, update the // as long as this focus wasn't because a window was raised, update the
@@ -1996,8 +2003,8 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow,
aWindow->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0); aWindow->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0);
SendFocusOrBlurEvent(eFocus, presShell, SendFocusOrBlurEvent(eFocus, presShell,
aContent->GetComposedDoc(), aElement->GetComposedDoc(),
aContent, aFlags & FOCUSMETHOD_MASK, aElement, aFlags & FOCUSMETHOD_MASK,
aWindowRaised, isRefocus, aContentLostFocus); aWindowRaised, isRefocus, aContentLostFocus);
} else { } else {
IMEStateManager::OnChangeFocus(presContext, nullptr, IMEStateManager::OnChangeFocus(presContext, nullptr,
@@ -2012,7 +2019,7 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow,
// the plugin not to be focusable, update the system focus by focusing // the plugin not to be focusable, update the system focus by focusing
// the root widget. // the root widget.
if (aAdjustWidgets && objectFrameWidget && if (aAdjustWidgets && objectFrameWidget &&
mFocusedWindow == aWindow && mFocusedContent == nullptr && mFocusedWindow == aWindow && mFocusedElement == nullptr &&
!sTestMode) { !sTestMode) {
nsViewManager* vm = presShell->GetViewManager(); nsViewManager* vm = presShell->GetViewManager();
if (vm) { if (vm) {
@@ -2023,8 +2030,8 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow,
} }
} }
if (!mFocusedContent) { if (!mFocusedElement) {
// When there is no focused content, IMEStateManager needs to adjust IME // When there is no focused element, IMEStateManager needs to adjust IME
// enabled state with the document. // enabled state with the document.
nsPresContext* presContext = presShell->GetPresContext(); nsPresContext* presContext = presShell->GetPresContext();
IMEStateManager::OnChangeFocus(presContext, nullptr, IMEStateManager::OnChangeFocus(presContext, nullptr,
@@ -2041,9 +2048,9 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow,
// needed. If this is a different document than was focused before, also // 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 // 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. // visibility should be the same as before so there is no need to update it.
if (mFocusedContent == aContent) if (mFocusedElement == aElement)
UpdateCaret(aFocusChanged && !(aFlags & FLAG_BYMOUSE), aIsNewDocument, UpdateCaret(aFocusChanged && !(aFlags & FLAG_BYMOUSE), aIsNewDocument,
mFocusedContent); mFocusedElement);
if (clearFirstFocusEvent) if (clearFirstFocusEvent)
mFirstFocusEvent = nullptr; mFirstFocusEvent = nullptr;
@@ -2353,7 +2360,7 @@ nsFocusManager::RaiseWindow(nsPIDOMWindowOuter* aWindow)
void void
nsFocusManager::UpdateCaretForCaretBrowsingMode() nsFocusManager::UpdateCaretForCaretBrowsingMode()
{ {
UpdateCaret(false, true, mFocusedContent); UpdateCaret(false, true, mFocusedElement);
} }
void void
@@ -3014,10 +3021,10 @@ nsFocusManager::DetermineElementToMoveFocus(nsPIDOMWindowOuter* aWindow,
// embedder or parent process that it should take the focus. // embedder or parent process that it should take the focus.
bool tookFocus; bool tookFocus;
docShell->TabToTreeOwner(forward, forDocumentNavigation, &tookFocus); docShell->TabToTreeOwner(forward, forDocumentNavigation, &tookFocus);
// If the tree owner took the focus, blur the current content. // If the tree owner took the focus, blur the current element.
if (tookFocus) { if (tookFocus) {
nsCOMPtr<nsPIDOMWindowOuter> window = docShell->GetWindow(); nsCOMPtr<nsPIDOMWindowOuter> window = docShell->GetWindow();
if (window->GetFocusedElement() == mFocusedContent) if (window->GetFocusedElement() == mFocusedElement)
Blur(mFocusedWindow, nullptr, true, true); Blur(mFocusedWindow, nullptr, true, true);
else else
window->SetFocusedElement(nullptr); window->SetFocusedElement(nullptr);
@@ -4124,8 +4131,8 @@ nsFocusManager::MarkUncollectableForCCGeneration(uint32_t aGeneration)
sInstance->mWindowBeingLowered-> sInstance->mWindowBeingLowered->
MarkUncollectableForCCGeneration(aGeneration); MarkUncollectableForCCGeneration(aGeneration);
} }
if (sInstance->mFocusedContent) { if (sInstance->mFocusedElement) {
sInstance->mFocusedContent->OwnerDoc()-> sInstance->mFocusedElement->OwnerDoc()->
MarkUncollectableForCCGeneration(aGeneration); MarkUncollectableForCCGeneration(aGeneration);
} }
if (sInstance->mFirstBlurEvent) { if (sInstance->mFirstBlurEvent) {
@@ -4150,7 +4157,7 @@ nsFocusManager::CanSkipFocus(nsIContent* aContent)
return false; return false;
} }
if (mFocusedContent == aContent) { if (mFocusedElement == aContent) {
return true; return true;
} }

View File

@@ -67,7 +67,7 @@ public:
* raw Element pointer (instead of having AddRef-ed nsIDOMElement * raw Element pointer (instead of having AddRef-ed nsIDOMElement
* pointer filled in to an out-parameter). * pointer filled in to an out-parameter).
*/ */
mozilla::dom::Element* GetFocusedContent() { return mFocusedContent; } mozilla::dom::Element* GetFocusedElement() { return mFocusedElement; }
/** /**
* Returns true if aContent currently has focus. * Returns true if aContent currently has focus.
@@ -102,7 +102,7 @@ public:
void NeedsFlushBeforeEventHandling(mozilla::dom::Element* aElement) void NeedsFlushBeforeEventHandling(mozilla::dom::Element* aElement)
{ {
if (mFocusedContent == aElement) { if (mFocusedElement == aElement) {
mEventHandlingNeedsFlush = true; mEventHandlingNeedsFlush = true;
} }
} }
@@ -645,7 +645,7 @@ private:
// the currently focused content, which is always inside mFocusedWindow. This // the currently focused content, which is always inside mFocusedWindow. This
// is a cached copy of the mFocusedWindow's current content. This may be null // is a cached copy of the mFocusedWindow's current content. This may be null
// if no content is focused. // if no content is focused.
RefPtr<mozilla::dom::Element> mFocusedContent; RefPtr<mozilla::dom::Element> mFocusedElement;
// these fields store a content node temporarily while it is being focused // 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. // or blurred to ensure that a recursive call doesn't refire the same event.

View File

@@ -5589,7 +5589,7 @@ EventStateManager::DoContentCommandEvent(WidgetContentCommandEvent* aEvent)
switch (aEvent->mMessage) { switch (aEvent->mMessage) {
case eContentCommandPasteTransferable: { case eContentCommandPasteTransferable: {
nsFocusManager* fm = nsFocusManager::GetFocusManager(); nsFocusManager* fm = nsFocusManager::GetFocusManager();
nsIContent* focusedContent = fm ? fm->GetFocusedContent() : nullptr; nsIContent* focusedContent = fm ? fm->GetFocusedElement() : nullptr;
RefPtr<TabParent> remote = TabParent::GetFrom(focusedContent); RefPtr<TabParent> remote = TabParent::GetFrom(focusedContent);
if (remote) { if (remote) {
NS_ENSURE_TRUE(remote->Manager()->IsContentParent(), NS_ERROR_FAILURE); NS_ENSURE_TRUE(remote->Manager()->IsContentParent(), NS_ERROR_FAILURE);

View File

@@ -192,12 +192,8 @@ HTMLObjectElement::HandlePluginInstantiated(Element* aElement)
// to initiate a call to nsIWidget::SetPluginFocused(true). Otherwise // to initiate a call to nsIWidget::SetPluginFocused(true). Otherwise
// keyboard input won't work in a click-to-play plugin until aElement // keyboard input won't work in a click-to-play plugin until aElement
// loses focus and regains it. // loses focus and regains it.
nsIContent* focusedContent = nullptr;
nsFocusManager *fm = nsFocusManager::GetFocusManager(); nsFocusManager *fm = nsFocusManager::GetFocusManager();
if (fm) { if (fm && fm->GetFocusedElement() == aElement) {
focusedContent = fm->GetFocusedContent();
}
if (SameCOMIdentity(focusedContent, aElement)) {
OnFocusBlurPlugin(aElement, true); OnFocusBlurPlugin(aElement, true);
} }
} }

View File

@@ -3297,7 +3297,7 @@ void nsPluginInstanceOwner::SetFrame(nsPluginFrame *aFrame)
nsFocusManager* fm = nsFocusManager::GetFocusManager(); nsFocusManager* fm = nsFocusManager::GetFocusManager();
const nsIContent* content = aFrame->GetContent(); const nsIContent* content = aFrame->GetContent();
if (fm && content) { if (fm && content) {
mContentFocused = (content == fm->GetFocusedContent()); mContentFocused = (content == fm->GetFocusedElement());
} }
// Register for widget-focus events on the window root. // Register for widget-focus events on the window root.

View File

@@ -4958,7 +4958,7 @@ EditorBase::GetFocusedContent()
nsFocusManager* fm = nsFocusManager::GetFocusManager(); nsFocusManager* fm = nsFocusManager::GetFocusManager();
NS_ENSURE_TRUE(fm, nullptr); NS_ENSURE_TRUE(fm, nullptr);
nsIContent* content = fm->GetFocusedContent(); nsIContent* content = fm->GetFocusedElement();
MOZ_ASSERT((content == piTarget) == SameCOMIdentity(content, piTarget)); MOZ_ASSERT((content == piTarget) == SameCOMIdentity(content, piTarget));
return (content == piTarget) ? content : nullptr; return (content == piTarget) ? content : nullptr;

View File

@@ -218,7 +218,7 @@ EditorEventListener::Disconnect()
nsFocusManager* fm = nsFocusManager::GetFocusManager(); nsFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm) { if (fm) {
nsIContent* focusedContent = fm->GetFocusedContent(); nsIContent* focusedContent = fm->GetFocusedElement();
mozilla::dom::Element* root = mEditorBase->GetRoot(); mozilla::dom::Element* root = mEditorBase->GetRoot();
if (focusedContent && root && if (focusedContent && root &&
nsContentUtils::ContentIsDescendantOf(focusedContent, root)) { nsContentUtils::ContentIsDescendantOf(focusedContent, root)) {
@@ -1105,7 +1105,7 @@ EditorEventListener::Focus(InternalFocusEvent* aFocusEvent)
nsFocusManager* fm = nsFocusManager::GetFocusManager(); nsFocusManager* fm = nsFocusManager::GetFocusManager();
NS_ENSURE_TRUE(fm, NS_OK); NS_ENSURE_TRUE(fm, NS_OK);
nsIContent* focusedContent = fm->GetFocusedContent(); nsIContent* focusedContent = fm->GetFocusedElement();
if (!focusedContent) { if (!focusedContent) {
return NS_OK; return NS_OK;
} }
@@ -1147,8 +1147,8 @@ EditorEventListener::Blur(InternalFocusEvent* aBlurEvent)
nsFocusManager* fm = nsFocusManager::GetFocusManager(); nsFocusManager* fm = nsFocusManager::GetFocusManager();
NS_ENSURE_TRUE(fm, NS_OK); NS_ENSURE_TRUE(fm, NS_OK);
nsIContent* content = fm->GetFocusedContent(); Element* focusedElement = fm->GetFocusedElement();
if (!content || !content->IsElement()) { if (!focusedElement) {
RefPtr<EditorBase> editorBase(mEditorBase); RefPtr<EditorBase> editorBase(mEditorBase);
editorBase->FinalizeSelection(); editorBase->FinalizeSelection();
} }

View File

@@ -4788,7 +4788,7 @@ HTMLEditor::GetFocusedContent()
nsFocusManager* fm = nsFocusManager::GetFocusManager(); nsFocusManager* fm = nsFocusManager::GetFocusManager();
NS_ENSURE_TRUE(fm, nullptr); NS_ENSURE_TRUE(fm, nullptr);
nsCOMPtr<nsIContent> focusedContent = fm->GetFocusedContent(); nsCOMPtr<nsIContent> focusedContent = fm->GetFocusedElement();
nsCOMPtr<nsIDocument> document = GetDocument(); nsCOMPtr<nsIDocument> document = GetDocument();
if (NS_WARN_IF(!document)) { if (NS_WARN_IF(!document)) {

View File

@@ -769,7 +769,7 @@ AccessibleCaretManager::GetFrameSelection() const
nsFocusManager* fm = nsFocusManager::GetFocusManager(); nsFocusManager* fm = nsFocusManager::GetFocusManager();
MOZ_ASSERT(fm); MOZ_ASSERT(fm);
nsIContent* focusedContent = fm->GetFocusedContent(); nsIContent* focusedContent = fm->GetFocusedElement();
if (!focusedContent) { if (!focusedContent) {
// For non-editable content // For non-editable content
return mPresShell->FrameSelection(); return mPresShell->FrameSelection();

View File

@@ -955,7 +955,7 @@ nsComboboxControlFrame::ShowDropDown(bool aDoDropDown)
if (!mDroppedDown && aDoDropDown) { if (!mDroppedDown && aDoDropDown) {
nsFocusManager* fm = nsFocusManager::GetFocusManager(); nsFocusManager* fm = nsFocusManager::GetFocusManager();
if (!fm || fm->GetFocusedContent() == GetContent()) { if (!fm || fm->GetFocusedElement() == GetContent()) {
DropDownPositionState state = AbsolutelyPositionDropDown(); DropDownPositionState state = AbsolutelyPositionDropDown();
if (state == eDropDownPositionFinal) { if (state == eDropDownPositionFinal) {
ShowList(aDoDropDown); // might destroy us ShowList(aDoDropDown); // might destroy us

View File

@@ -307,7 +307,7 @@ nsFormFillController::MarkAsLoginManagerField(nsIDOMHTMLInputElement *aInput)
nsFocusManager *fm = nsFocusManager::GetFocusManager(); nsFocusManager *fm = nsFocusManager::GetFocusManager();
if (fm) { if (fm) {
nsCOMPtr<nsIContent> focusedContent = fm->GetFocusedContent(); nsCOMPtr<nsIContent> focusedContent = fm->GetFocusedElement();
if (focusedContent == node) { if (focusedContent == node) {
if (!mFocusedInput) { if (!mFocusedInput) {
MaybeStartControllingInput(HTMLInputElement::FromNode(node)); MaybeStartControllingInput(HTMLInputElement::FromNode(node));
@@ -347,7 +347,7 @@ nsFormFillController::MarkAsAutofillField(nsIDOMHTMLInputElement *aInput)
nsFocusManager *fm = nsFocusManager::GetFocusManager(); nsFocusManager *fm = nsFocusManager::GetFocusManager();
if (fm) { if (fm) {
nsCOMPtr<nsIContent> focusedContent = fm->GetFocusedContent(); nsCOMPtr<nsIContent> focusedContent = fm->GetFocusedElement();
if (focusedContent == node) { if (focusedContent == node) {
MaybeStartControllingInput(HTMLInputElement::FromNode(node)); MaybeStartControllingInput(HTMLInputElement::FromNode(node));
} }