mirror of
https://github.com/roytam1/UXP.git
synced 2026-05-26 14:54:25 +00:00
Issue #2388 - Part 4: Align focus behavior more with Blink/Gecko
This commit is contained in:
@@ -6415,19 +6415,16 @@ Selection::NotifySelectionListeners()
|
||||
MOZ_ASSERT(!newEditingHost->IsInNativeAnonymousSubtree());
|
||||
nsCOMPtr<nsIDOMElement> domElementToFocus =
|
||||
do_QueryInterface(newEditingHost->AsDOMNode());
|
||||
// Note that don't steal focus from focused window if the window doesn't
|
||||
// have focus.
|
||||
fm->SetFocus(domElementToFocus, nsIFocusManager::FLAG_NOSWITCHFRAME);
|
||||
}
|
||||
// Otherwise, if current focused element is an editing host, it should
|
||||
// be blurred if there is no common editing host of the selected ranges.
|
||||
else if (!newEditingHost && focusedElement &&
|
||||
focusedElement == focusedElement->GetEditingHost()) {
|
||||
IgnoredErrorResult err;
|
||||
focusedElement->Blur(err);
|
||||
NS_WARNING_ASSERTION(!err.Failed(),
|
||||
"Failed to blur focused element");
|
||||
// Note that don't steal focus from focused window if the window
|
||||
// doesn't have focus. Additionally, when an element gets focus,
|
||||
// we usually scroll to the element, but in this case we shouldn't
|
||||
// do that because Blink&Gecko don't do this.
|
||||
fm->SetFocus(domElementToFocus, nsIFocusManager::FLAG_NOSWITCHFRAME |
|
||||
nsIFocusManager::FLAG_NOSCROLL);
|
||||
}
|
||||
// Otherwise, we shouldn't move focus since Blink&Gecko don't move
|
||||
// focus; only the selection range is updated. This is a bit weird but
|
||||
// it is what it is and we should act the same for parity.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user