Bug 1429656 - Implement ShadowRoot.activeElement

Tag #1375
This commit is contained in:
Matt A. Tobin 2020-06-13 08:23:21 -04:00 • committed by Roy Tam
commit 693a79ca08
14 changed files with 88 additions and 72 deletions

View file

@ -3031,20 +3031,9 @@ Element*
nsIDocument::GetActiveElement()
{
// Get the focused element.
if (nsCOMPtr<nsPIDOMWindowOuter> window = GetWindow()) {
nsCOMPtr<nsPIDOMWindowOuter> focusedWindow;
nsIContent* focusedContent =
nsFocusManager::GetFocusedDescendant(window, false,
getter_AddRefs(focusedWindow));
// be safe and make sure the element is from this document
if (focusedContent && focusedContent->OwnerDoc() == this) {
if (focusedContent->ChromeOnlyAccess()) {
focusedContent = focusedContent->FindFirstNonChromeOnlyAccessContent();
}
if (focusedContent) {
return focusedContent->AsElement();
}
}
Element* focusedElement = GetRetargetedFocusedElement();
if (focusedElement) {
return focusedElement;
}
// No focused element anywhere in this document. Try to get the BODY.