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)
This commit is contained in:
shindli 2018-04-27 01:34:37 +03:00
parent 52916ae726
commit af700315a1
22 changed files with 201 additions and 209 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->GetFocusedElement(); nsIContent* focusedElm = domfm->GetFocusedContent();
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->GetFocusedElement(); nsIContent* focusedElm = DOMFocusManager->GetFocusedContent();
// 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->GetFocusedElement() == aContent; return fm && fm->GetFocusedContent() == aContent;
} }
bool bool

View File

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

View File

@ -9356,7 +9356,7 @@ public:
} }
// Don't steal focus from the user. // Don't steal focus from the user.
if (mTopWindow->GetFocusedElement()) { if (mTopWindow->GetFocusedNode()) {
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,
mFocusedElement, mFocusedContent,
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;
mFocusedElement = nullptr; mFocusedContent = 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 || !mFocusedElement) { if (!aContent || !mFocusedContent) {
return false; return false;
} }
return aContent == mFocusedElement; return aContent == mFocusedContent.get();
} }
// 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* currentElement = nullptr; Element* currentContent = nullptr;
nsPIDOMWindowOuter* window = aWindow; nsPIDOMWindowOuter* window = aWindow;
for (;;) { for (;;) {
*aFocusedWindow = window; *aFocusedWindow = window;
currentElement = window->GetFocusedElement(); currentContent = window->GetFocusedNode();
if (!currentElement || aSearchRange == eOnlyCurrentWindow) { if (!currentContent || aSearchRange == eOnlyCurrentWindow) {
break; break;
} }
window = GetContentWindow(currentElement); window = GetContentWindow(currentContent);
if (!window) { if (!window) {
break; break;
} }
@ -345,7 +345,7 @@ nsFocusManager::GetFocusedDescendant(nsPIDOMWindowOuter* aWindow,
NS_IF_ADDREF(*aFocusedWindow); NS_IF_ADDREF(*aFocusedWindow);
return currentElement; return currentContent;
} }
// static // static
@ -468,7 +468,7 @@ NS_IMETHODIMP nsFocusManager::SetFocusedWindow(mozIDOMWindowProxy* aWindowToFocu
// clear the focus. Otherwise, focus should already be in this frame, or // clear the focus. Otherwise, focus should already be in this frame, or
// already cleared. This ensures that focus will be in this frame and not // already cleared. This ensures that focus will be in this frame and not
// in a child. // in a child.
nsIContent* content = windowToFocus->GetFocusedElement(); nsIContent* content = windowToFocus->GetFocusedNode();
if (content) { if (content) {
if (nsCOMPtr<nsPIDOMWindowOuter> childWindow = GetContentWindow(content)) if (nsCOMPtr<nsPIDOMWindowOuter> childWindow = GetContentWindow(content))
ClearFocus(windowToFocus); ClearFocus(windowToFocus);
@ -487,8 +487,8 @@ NS_IMETHODIMP nsFocusManager::SetFocusedWindow(mozIDOMWindowProxy* aWindowToFocu
NS_IMETHODIMP NS_IMETHODIMP
nsFocusManager::GetFocusedElement(nsIDOMElement** aFocusedElement) nsFocusManager::GetFocusedElement(nsIDOMElement** aFocusedElement)
{ {
if (mFocusedElement) if (mFocusedContent)
CallQueryInterface(mFocusedElement, aFocusedElement); CallQueryInterface(mFocusedContent, 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", mFocusedElement.get()); LOGCONTENT(" Current Focus: %s", mFocusedContent.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
@ -625,7 +625,7 @@ nsFocusManager::ClearFocus(mozIDOMWindowProxy* aWindow)
} }
} }
else { else {
window->SetFocusedElement(nullptr); window->SetFocusedNode(nullptr);
} }
LOGFOCUS(("<<ClearFocus end>>")); LOGFOCUS(("<<ClearFocus end>>"));
@ -681,7 +681,7 @@ nsFocusManager::MoveCaretToFocus(mozIDOMWindowProxy* aWindow)
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
nsCOMPtr<nsPIDOMWindowOuter> window = nsPIDOMWindowOuter::From(aWindow); nsCOMPtr<nsPIDOMWindowOuter> window = nsPIDOMWindowOuter::From(aWindow);
nsCOMPtr<nsIContent> content = window->GetFocusedElement(); nsCOMPtr<nsIContent> content = window->GetFocusedNode();
if (content) if (content)
MoveCaretToFocus(presShell, 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 // if the content is currently focused in the window, or is an
// shadow-including inclusive ancestor of the currently focused element, // shadow-including inclusive ancestor of the currently focused element,
// reset the focus within that window. // reset the focus within that window.
nsIContent* content = window->GetFocusedElement(); nsIContent* content = window->GetFocusedNode();
if (content && nsContentUtils::ContentIsHostIncludingDescendantOf(content, aContent)) { if (content && nsContentUtils::ContentIsHostIncludingDescendantOf(content, aContent)) {
bool shouldShowFocusRing = window->ShouldShowFocusRing(); bool shouldShowFocusRing = window->ShouldShowFocusRing();
window->SetFocusedElement(nullptr); window->SetFocusedNode(nullptr);
// if this window is currently focused, clear the global focused // if this window is currently focused, clear the global focused
// element as well, but don't fire any events. // element as well, but don't fire any events.
if (window == mFocusedWindow) { if (window == mFocusedWindow) {
mFocusedElement = nullptr; mFocusedContent = 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.
RefPtr<Element> oldFocusedElement = mFocusedElement.forget(); nsCOMPtr<nsIContent> oldFocusedContent = mFocusedContent.forget();
nsCOMPtr<nsIDocShell> focusedDocShell = mFocusedWindow->GetDocShell(); nsCOMPtr<nsIDocShell> focusedDocShell = mFocusedWindow->GetDocShell();
nsCOMPtr<nsIPresShell> presShell = focusedDocShell->GetPresShell(); nsCOMPtr<nsIPresShell> presShell = focusedDocShell->GetPresShell();
if (oldFocusedElement && oldFocusedElement->IsInComposedDoc()) { if (oldFocusedContent && oldFocusedContent->IsInComposedDoc()) {
NotifyFocusStateChange(oldFocusedElement, NotifyFocusStateChange(oldFocusedContent,
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,
oldFocusedElement->GetComposedDoc(), oldFocusedContent->GetComposedDoc(),
oldFocusedElement, 1, false); oldFocusedContent, 1, false);
} }
} }
@ -1056,7 +1056,7 @@ nsFocusManager::WindowHidden(mozIDOMWindowProxy* aWindow)
dsti->GetParent(getter_AddRefs(parentDsti)); dsti->GetParent(getter_AddRefs(parentDsti));
if (parentDsti) { if (parentDsti) {
if (nsCOMPtr<nsPIDOMWindowOuter> parentWindow = parentDsti->GetWindow()) if (nsCOMPtr<nsPIDOMWindowOuter> parentWindow = parentDsti->GetWindow())
parentWindow->SetFocusedElement(nullptr); parentWindow->SetFocusedNode(nullptr);
} }
} }
@ -1227,19 +1227,18 @@ 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> elementToFocus = CheckIfFocusable(aNewContent, aFlags); RefPtr<Element> contentToFocus = CheckIfFocusable(aNewContent, aFlags);
if (!elementToFocus) { if (!contentToFocus)
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(elementToFocus); nsCOMPtr<nsPIDOMWindowOuter> subWindow = GetContentWindow(contentToFocus);
if (subWindow) { if (subWindow) {
elementToFocus = GetFocusedDescendant(subWindow, eIncludeAllDescendants, contentToFocus = 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.
@ -1247,17 +1246,14 @@ 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(elementToFocus); newWindow = GetCurrentWindow(contentToFocus);
}
// 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 || if (!newWindow || (newWindow == mFocusedWindow && contentToFocus == mFocusedContent))
(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
@ -1322,16 +1318,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 (elementToFocus && if (contentToFocus &&
nsContentUtils:: nsContentUtils::
GetRootDocument(elementToFocus->OwnerDoc())->GetFullscreenElement() && GetRootDocument(contentToFocus->OwnerDoc())->GetFullscreenElement() &&
nsContentUtils::HasPluginWithUncontrolledEventDispatch(elementToFocus)) { nsContentUtils::HasPluginWithUncontrolledEventDispatch(contentToFocus)) {
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("DOM"), NS_LITERAL_CSTRING("DOM"),
elementToFocus->OwnerDoc(), contentToFocus->OwnerDoc(),
nsContentUtils::eDOM_PROPERTIES, nsContentUtils::eDOM_PROPERTIES,
"FocusedWindowedPluginWhileFullscreen"); "FocusedWindowedPluginWhileFullscreen");
nsIDocument::AsyncExitFullscreen(elementToFocus->OwnerDoc()); nsIDocument::AsyncExitFullscreen(contentToFocus->OwnerDoc());
} }
#endif #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) // * 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 && mFocusedElement && !nsContentUtils::LegacyIsCallerNativeCode() && if (sendFocusEvent && mFocusedContent && !nsContentUtils::LegacyIsCallerNativeCode() &&
mFocusedElement->OwnerDoc() != aNewContent->OwnerDoc()) { mFocusedContent->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(mFocusedElement)); nsCOMPtr<nsIDOMNode> domNode(do_QueryInterface(mFocusedContent));
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
@ -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", 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", LOGFOCUS((" In Active Window: %d In Focused Window: %d SendFocus: %d",
isElementInActiveWindow, isElementInFocusedWindow, sendFocusEvent)); isElementInActiveWindow, isElementInFocusedWindow, sendFocusEvent));
if (sendFocusEvent) { if (sendFocusEvent) {
RefPtr<Element> oldFocusedElement = mFocusedElement; RefPtr<Element> oldFocusedContent = mFocusedContent;
// 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,
@ -1400,13 +1396,12 @@ 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,
elementToFocus)) { contentToFocus))
return; return;
}
} }
Focus(newWindow, elementToFocus, aFlags, !isElementInFocusedWindow, Focus(newWindow, contentToFocus, aFlags, !isElementInFocusedWindow,
aFocusChanged, false, aAdjustWidget, oldFocusedElement); aFocusChanged, false, aAdjustWidget, oldFocusedContent);
} }
else { else {
// otherwise, for inactive windows and when the caller cannot steal the // 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 // 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(elementToFocus, focusMethod); newWindow->SetFocusedNode(contentToFocus, 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, elementToFocus, aFlags); ScrollIntoView(presShell, contentToFocus, 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
@ -1537,7 +1532,7 @@ nsFocusManager::AdjustWindowFocus(nsPIDOMWindowOuter* aWindow,
break; break;
} }
window->SetFocusedElement(frameElement); window->SetFocusedNode(frameElement);
} }
} }
} }
@ -1584,22 +1579,22 @@ nsFocusManager::IsNonFocusableRoot(nsIContent* aContent)
} }
Element* Element*
nsFocusManager::CheckIfFocusable(Element* aElement, uint32_t aFlags) nsFocusManager::CheckIfFocusable(Element* aContent, uint32_t aFlags)
{ {
if (!aElement) if (!aContent)
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(aElement); RefPtr<Element> redirectedFocus = GetRedirectedFocus(aContent);
if (redirectedFocus) { if (redirectedFocus) {
return CheckIfFocusable(redirectedFocus, aFlags); return CheckIfFocusable(redirectedFocus, aFlags);
} }
nsCOMPtr<nsIDocument> doc = aElement->GetComposedDoc(); nsCOMPtr<nsIDocument> doc = aContent->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", aElement) LOGCONTENT("Cannot focus %s because content not in document", aContent)
return nullptr; return nullptr;
} }
@ -1614,44 +1609,44 @@ nsFocusManager::CheckIfFocusable(Element* aElement, 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 (aElement == doc->GetRootElement()) { if (aContent == doc->GetRootElement()) {
return nsContentUtils::IsUserFocusIgnored(aElement) ? nullptr : aElement; return nsContentUtils::IsUserFocusIgnored(aContent) ? nullptr : aContent;
} }
// 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", aElement) LOGCONTENT("Cannot focus %s while in print preview", aContent)
return nullptr; return nullptr;
} }
nsIFrame* frame = aElement->GetPrimaryFrame(); nsIFrame* frame = aContent->GetPrimaryFrame();
if (!frame) { if (!frame) {
LOGCONTENT("Cannot focus %s as it has no frame", aElement) LOGCONTENT("Cannot focus %s as it has no frame", aContent)
return nullptr; 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 // 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() &&
aElement->IsFocusable() ? aElement : nullptr; aContent->IsFocusable() ? aContent : 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(aElement); nsIDocument* subdoc = doc->GetSubDocumentFor(aContent);
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 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 bool
@ -1664,26 +1659,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> element = mFocusedElement; RefPtr<Element> content = mFocusedContent;
if (element) { if (content) {
if (!element->IsInComposedDoc()) { if (!content->IsInComposedDoc()) {
mFocusedElement = nullptr; mFocusedContent = nullptr;
return true; return true;
} }
if (element == mFirstBlurEvent) if (content == 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) {
mFocusedElement = nullptr; mFocusedContent = nullptr;
return true; return true;
} }
nsCOMPtr<nsIDocShell> docShell = window->GetDocShell(); nsCOMPtr<nsIDocShell> docShell = window->GetDocShell();
if (!docShell) { if (!docShell) {
mFocusedElement = nullptr; mFocusedContent = nullptr;
return true; return true;
} }
@ -1691,13 +1686,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) {
mFocusedElement = nullptr; mFocusedContent = nullptr;
return true; return true;
} }
bool clearFirstBlurEvent = false; bool clearFirstBlurEvent = false;
if (!mFirstBlurEvent) { if (!mFirstBlurEvent) {
mFirstBlurEvent = element; mFirstBlurEvent = content;
clearFirstBlurEvent = true; clearFirstBlurEvent = true;
} }
@ -1708,19 +1703,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.
mFocusedElement = nullptr; mFocusedContent = nullptr;
bool shouldShowFocusRing = window->ShouldShowFocusRing(); bool shouldShowFocusRing = window->ShouldShowFocusRing();
if (aWindowToClear) 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. // Don't fire blur event on the root content which isn't editable.
bool sendBlurEvent = bool sendBlurEvent =
element && element->IsInComposedDoc() && !IsNonFocusableRoot(element); content && content->IsInComposedDoc() && !IsNonFocusableRoot(content);
if (element) { if (content) {
if (sendBlurEvent) { if (sendBlurEvent) {
NotifyFocusStateChange(element, NotifyFocusStateChange(content,
aContentToFocus, aContentToFocus,
shouldShowFocusRing, shouldShowFocusRing,
false); false);
@ -1731,7 +1726,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 = element->GetPrimaryFrame(); nsIFrame* contentFrame = content->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()) {
@ -1757,7 +1752,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(element)) { if (TabParent* remote = TabParent::GetFrom(content)) {
remote->Deactivate(); remote->Deactivate();
LOGFOCUS(("Remote browser deactivated")); LOGFOCUS(("Remote browser deactivated"));
} }
@ -1772,7 +1767,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,
element->GetComposedDoc(), element, 1, content->GetComposedDoc(), content, 1,
false, false, aContentToFocus); false, false, aContentToFocus);
} }
@ -1788,13 +1783,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 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 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 ||
(mFocusedElement != nullptr && !aIsLeavingDocument)) { (mFocusedContent != nullptr && !aIsLeavingDocument)) {
result = false; result = false;
} }
else if (aIsLeavingDocument) { else if (aIsLeavingDocument) {
@ -1804,10 +1799,10 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear,
// state. Pass true because aAncestorWindowToFocus is thought to be // state. Pass true because aAncestorWindowToFocus is thought to be
// focused at this point. // focused at this point.
if (aAncestorWindowToFocus) if (aAncestorWindowToFocus)
aAncestorWindowToFocus->SetFocusedElement(nullptr, 0, true); aAncestorWindowToFocus->SetFocusedNode(nullptr, 0, true);
SetFocusedWindowInternal(nullptr); SetFocusedWindowInternal(nullptr);
mFocusedElement = nullptr; mFocusedContent = 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
@ -1839,7 +1834,7 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear,
void void
nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow,
Element* aElement, Element* aContent,
uint32_t aFlags, uint32_t aFlags,
bool aIsNewDocument, bool aIsNewDocument,
bool aFocusChanged, bool aFocusChanged,
@ -1852,7 +1847,7 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow,
if (!aWindow) if (!aWindow)
return; return;
if (aElement && (aElement == mFirstFocusEvent || aElement == mFirstBlurEvent)) if (aContent && (aContent == mFirstFocusEvent || aContent == 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
@ -1874,21 +1869,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(aElement, aFlags)) { if (CheckIfFocusable(aContent, aFlags)) {
aWindow->SetFocusedElement(aElement, focusMethod); aWindow->SetFocusedNode(aContent, focusMethod);
if (aFocusChanged) if (aFocusChanged)
ScrollIntoView(presShell, aElement, aFlags); ScrollIntoView(presShell, aContent, aFlags);
} }
return; return;
} }
bool clearFirstFocusEvent = false; bool clearFirstFocusEvent = false;
if (!mFirstFocusEvent) { if (!mFirstFocusEvent) {
mFirstFocusEvent = aElement; mFirstFocusEvent = aContent;
clearFirstFocusEvent = true; clearFirstFocusEvent = true;
} }
LOGCONTENT("Element %s has been focused", aElement); LOGCONTENT("Element %s has been focused", aContent);
if (MOZ_LOG_TEST(gFocusLog, LogLevel::Debug)) { if (MOZ_LOG_TEST(gFocusLog, LogLevel::Debug)) {
nsIDocument* docm = aWindow->GetExtantDoc(); nsIDocument* docm = aWindow->GetExtantDoc();
@ -1913,11 +1908,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) 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. // own widget and is either already focused or is about to be focused.
nsCOMPtr<nsIWidget> objectFrameWidget; nsCOMPtr<nsIWidget> objectFrameWidget;
if (aElement) { if (aContent) {
nsIFrame* contentFrame = aElement->GetPrimaryFrame(); nsIFrame* contentFrame = aContent->GetPrimaryFrame();
nsIObjectFrame* objectFrame = do_QueryFrame(contentFrame); nsIObjectFrame* objectFrame = do_QueryFrame(contentFrame);
if (objectFrame) if (objectFrame)
objectFrameWidget = objectFrame->GetWidget(); objectFrameWidget = objectFrame->GetWidget();
@ -1937,44 +1932,42 @@ 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 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. // 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(aElement, aFlags) && if (CheckIfFocusable(aContent, aFlags) &&
mFocusedWindow == aWindow && mFocusedElement == nullptr) { mFocusedWindow == aWindow && mFocusedContent == nullptr) {
mFocusedElement = aElement; mFocusedContent = aContent;
nsIContent* focusedNode = aWindow->GetFocusedElement(); nsIContent* focusedNode = aWindow->GetFocusedNode();
bool isRefocus = focusedNode && focusedNode->IsEqualNode(aElement); bool isRefocus = focusedNode && focusedNode->IsEqualNode(aContent);
aWindow->SetFocusedElement(aElement, focusMethod); aWindow->SetFocusedNode(aContent, focusMethod);
// if the focused element changed, scroll it into view // if the focused element changed, scroll it into view
if (aElement && aFocusChanged) { if (aContent && aFocusChanged) {
ScrollIntoView(presShell, aElement, aFlags); ScrollIntoView(presShell, aContent, aFlags);
} }
bool sendFocusEvent = bool sendFocusEvent =
aElement && aElement->IsInComposedDoc() && !IsNonFocusableRoot(aElement); aContent && aContent->IsInComposedDoc() && !IsNonFocusableRoot(aContent);
nsPresContext* presContext = presShell->GetPresContext(); nsPresContext* presContext = presShell->GetPresContext();
if (sendFocusEvent) { if (sendFocusEvent) {
NotifyFocusStateChange(aElement, NotifyFocusStateChange(aContent,
nullptr, nullptr,
aWindow->ShouldShowFocusRing(), aWindow->ShouldShowFocusRing(),
true); 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 // 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() == aElement->GetComposedDoc()) { if (presShell->GetDocument() == aContent->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(aElement)) { if (TabParent* remote = TabParent::GetFrom(aContent)) {
remote->Activate(); remote->Activate();
LOGFOCUS(("Remote browser activated")); LOGFOCUS(("Remote browser activated"));
} }
} }
IMEStateManager::OnChangeFocus(presContext, aElement, IMEStateManager::OnChangeFocus(presContext, aContent,
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
@ -2003,8 +1996,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,
aElement->GetComposedDoc(), aContent->GetComposedDoc(),
aElement, aFlags & FOCUSMETHOD_MASK, aContent, aFlags & FOCUSMETHOD_MASK,
aWindowRaised, isRefocus, aContentLostFocus); aWindowRaised, isRefocus, aContentLostFocus);
} else { } else {
IMEStateManager::OnChangeFocus(presContext, nullptr, 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 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 && mFocusedElement == nullptr && mFocusedWindow == aWindow && mFocusedContent == nullptr &&
!sTestMode) { !sTestMode) {
nsViewManager* vm = presShell->GetViewManager(); nsViewManager* vm = presShell->GetViewManager();
if (vm) { if (vm) {
@ -2030,8 +2023,8 @@ nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow,
} }
} }
if (!mFocusedElement) { if (!mFocusedContent) {
// When there is no focused element, IMEStateManager needs to adjust IME // When there is no focused content, 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,
@ -2048,9 +2041,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 (mFocusedElement == aElement) if (mFocusedContent == aContent)
UpdateCaret(aFocusChanged && !(aFlags & FLAG_BYMOUSE), aIsNewDocument, UpdateCaret(aFocusChanged && !(aFlags & FLAG_BYMOUSE), aIsNewDocument,
mFocusedElement); mFocusedContent);
if (clearFirstFocusEvent) if (clearFirstFocusEvent)
mFirstFocusEvent = nullptr; mFirstFocusEvent = nullptr;
@ -2116,7 +2109,7 @@ public:
NS_IMETHOD Run() override NS_IMETHOD Run() override
{ {
nsCOMPtr<nsIContent> originalWindowFocus = mOriginalFocusedWindow ? nsCOMPtr<nsIContent> originalWindowFocus = mOriginalFocusedWindow ?
mOriginalFocusedWindow->GetFocusedElement() : mOriginalFocusedWindow->GetFocusedNode() :
nullptr; nullptr;
// Blink does not check that focus is the same after blur, but WebKit does. // Blink does not check that focus is the same after blur, but WebKit does.
// Opt to follow Blink's behavior (see bug 687787). // Opt to follow Blink's behavior (see bug 687787).
@ -2239,7 +2232,7 @@ nsFocusManager::FireFocusOrBlurEvent(EventMessage aEventMessage,
nsCOMPtr<nsPIDOMWindowInner> targetWindow = do_QueryInterface(aTarget); nsCOMPtr<nsPIDOMWindowInner> targetWindow = do_QueryInterface(aTarget);
nsCOMPtr<nsIDocument> targetDocument = do_QueryInterface(aTarget); nsCOMPtr<nsIDocument> targetDocument = do_QueryInterface(aTarget);
nsCOMPtr<nsIContent> currentFocusedContent = currentWindow ? nsCOMPtr<nsIContent> currentFocusedContent = currentWindow ?
currentWindow->GetFocusedElement() : nullptr; currentWindow->GetFocusedNode() : nullptr;
bool dontDispatchEvent = bool dontDispatchEvent =
eventTargetDoc && nsContentUtils::IsUserFocusIgnored(eventTargetDoc); eventTargetDoc && nsContentUtils::IsUserFocusIgnored(eventTargetDoc);
@ -2360,7 +2353,7 @@ nsFocusManager::RaiseWindow(nsPIDOMWindowOuter* aWindow)
void void
nsFocusManager::UpdateCaretForCaretBrowsingMode() nsFocusManager::UpdateCaretForCaretBrowsingMode()
{ {
UpdateCaret(false, true, mFocusedElement); UpdateCaret(false, true, mFocusedContent);
} }
void void
@ -2694,7 +2687,7 @@ nsFocusManager::DetermineElementToMoveFocus(nsPIDOMWindowOuter* aWindow,
// then we are document-navigating backwards from chrome to the content // then we are document-navigating backwards from chrome to the content
// process, and we don't want to use this so that we start from the end // process, and we don't want to use this so that we start from the end
// of the document. // of the document.
startContent = aWindow->GetFocusedElement(); startContent = aWindow->GetFocusedNode();
} }
} }
@ -3021,13 +3014,13 @@ 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 element. // If the tree owner took the focus, blur the current content.
if (tookFocus) { if (tookFocus) {
nsCOMPtr<nsPIDOMWindowOuter> window = docShell->GetWindow(); nsCOMPtr<nsPIDOMWindowOuter> window = docShell->GetWindow();
if (window->GetFocusedElement() == mFocusedElement) if (window->GetFocusedNode() == mFocusedContent)
Blur(mFocusedWindow, nullptr, true, true); Blur(mFocusedWindow, nullptr, true, true);
else else
window->SetFocusedElement(nullptr); window->SetFocusedNode(nullptr);
return NS_OK; return NS_OK;
} }
@ -3964,7 +3957,7 @@ nsFocusManager::GetFocusInSelection(nsPIDOMWindowOuter* aWindow,
nsCOMPtr<nsIContent> testContent = aStartSelection; nsCOMPtr<nsIContent> testContent = aStartSelection;
nsCOMPtr<nsIContent> nextTestContent = aEndSelection; nsCOMPtr<nsIContent> nextTestContent = aEndSelection;
nsCOMPtr<nsIContent> currentFocus = aWindow->GetFocusedElement(); nsCOMPtr<nsIContent> currentFocus = aWindow->GetFocusedNode();
// We now have the correct start node in selectionContent! // We now have the correct start node in selectionContent!
// Search for focusable elements, starting with selectionContent // Search for focusable elements, starting with selectionContent
@ -4131,8 +4124,8 @@ nsFocusManager::MarkUncollectableForCCGeneration(uint32_t aGeneration)
sInstance->mWindowBeingLowered-> sInstance->mWindowBeingLowered->
MarkUncollectableForCCGeneration(aGeneration); MarkUncollectableForCCGeneration(aGeneration);
} }
if (sInstance->mFocusedElement) { if (sInstance->mFocusedContent) {
sInstance->mFocusedElement->OwnerDoc()-> sInstance->mFocusedContent->OwnerDoc()->
MarkUncollectableForCCGeneration(aGeneration); MarkUncollectableForCCGeneration(aGeneration);
} }
if (sInstance->mFirstBlurEvent) { if (sInstance->mFirstBlurEvent) {
@ -4157,7 +4150,7 @@ nsFocusManager::CanSkipFocus(nsIContent* aContent)
return false; return false;
} }
if (mFocusedElement == aContent) { if (mFocusedContent == aContent) {
return true; return true;
} }
@ -4172,7 +4165,7 @@ nsFocusManager::CanSkipFocus(nsIContent* aContent)
root ? root->GetWindow() : nullptr; root ? root->GetWindow() : nullptr;
if (mActiveWindow != newRootWindow) { if (mActiveWindow != newRootWindow) {
nsPIDOMWindowOuter* outerWindow = aContent->OwnerDoc()->GetWindow(); nsPIDOMWindowOuter* outerWindow = aContent->OwnerDoc()->GetWindow();
if (outerWindow && outerWindow->GetFocusedElement() == aContent) { if (outerWindow && outerWindow->GetFocusedNode() == 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* GetFocusedElement() { return mFocusedElement; } mozilla::dom::Element* GetFocusedContent() { return mFocusedContent; }
/** /**
* 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 (mFocusedElement == aElement) { if (mFocusedContent == 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> mFocusedElement; RefPtr<mozilla::dom::Element> mFocusedContent;
// 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

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

View File

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

View File

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

View File

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

View File

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

View File

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

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->GetFocusedElement() : nullptr; nsIContent* focusedContent = fm ? fm->GetFocusedContent() : 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

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

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->GetFocusedElement()); mContentFocused = (content == fm->GetFocusedContent());
} }
// Register for widget-focus events on the window root. // Register for widget-focus events on the window root.

View File

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

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->GetFocusedElement(); nsIContent* content = fm->GetFocusedContent();
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->GetFocusedElement(); nsIContent* focusedContent = fm->GetFocusedContent();
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->GetFocusedElement(); nsIContent* focusedContent = fm->GetFocusedContent();
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);
Element* focusedElement = fm->GetFocusedElement(); nsIContent* content = fm->GetFocusedContent();
if (!focusedElement) { if (!content || !content->IsElement()) {
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->GetFocusedElement(); nsCOMPtr<nsIContent> focusedContent = fm->GetFocusedContent();
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->GetFocusedElement(); nsIContent* focusedContent = fm->GetFocusedContent();
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->GetFocusedElement() == GetContent()) { if (!fm || fm->GetFocusedContent() == 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->GetFocusedElement(); nsCOMPtr<nsIContent> focusedContent = fm->GetFocusedContent();
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->GetFocusedElement(); nsCOMPtr<nsIContent> focusedContent = fm->GetFocusedContent();
if (focusedContent == node) { if (focusedContent == node) {
MaybeStartControllingInput(HTMLInputElement::FromNode(node)); MaybeStartControllingInput(HTMLInputElement::FromNode(node));
} }