forked from mirrors/gecko-dev
Bug 1891934 - [popover] Handling focus naviagtion when invoker is not focusable. r=smaug
At popover navigation bug 1856539, we left the case that when invoker is not focusable to its default behaviour. At https://github.com/web-platform-tests/wpt/pull/45391, it is suggested that we should another element next to the invoker to focus. Differential Revision: https://phabricator.services.mozilla.com/D207693
This commit is contained in:
parent
e95677bb53
commit
44f3e9c4c2
2 changed files with 20 additions and 12 deletions
|
|
@ -4303,20 +4303,22 @@ nsresult nsFocusManager::GetNextTabbableContent(
|
||||||
|
|
||||||
// Stepping out popover scope.
|
// Stepping out popover scope.
|
||||||
// For forward, search for the next tabbable content after invoker.
|
// For forward, search for the next tabbable content after invoker.
|
||||||
// For backward, we should get back to the invoker.
|
// For backward, we should get back to the invoker if the invoker is
|
||||||
|
// focusable. Otherwise search for the next tabbable content after
|
||||||
|
// invoker.
|
||||||
if (oldTopLevelScopeOwner &&
|
if (oldTopLevelScopeOwner &&
|
||||||
IsOpenPopoverWithInvoker(oldTopLevelScopeOwner) &&
|
IsOpenPopoverWithInvoker(oldTopLevelScopeOwner) &&
|
||||||
currentTopLevelScopeOwner != oldTopLevelScopeOwner) {
|
currentTopLevelScopeOwner != oldTopLevelScopeOwner) {
|
||||||
if (auto* popover = Element::FromNode(oldTopLevelScopeOwner)) {
|
if (auto* popover = Element::FromNode(oldTopLevelScopeOwner)) {
|
||||||
RefPtr<nsIContent> invokerContent =
|
RefPtr<nsIContent> invokerContent =
|
||||||
popover->GetPopoverData()->GetInvoker()->AsContent();
|
popover->GetPopoverData()->GetInvoker()->AsContent();
|
||||||
|
RefPtr<nsIContent> rootElement = invokerContent;
|
||||||
|
if (auto* doc = invokerContent->GetComposedDoc()) {
|
||||||
|
rootElement = doc->GetRootElement();
|
||||||
|
}
|
||||||
if (aForward) {
|
if (aForward) {
|
||||||
nsIFrame* frame = invokerContent->GetPrimaryFrame();
|
nsIFrame* frame = invokerContent->GetPrimaryFrame();
|
||||||
int32_t tabIndex = frame->IsFocusable().mTabIndex;
|
int32_t tabIndex = frame->IsFocusable().mTabIndex;
|
||||||
RefPtr<nsIContent> rootElement = invokerContent;
|
|
||||||
if (auto* doc = invokerContent->GetComposedDoc()) {
|
|
||||||
rootElement = doc->GetRootElement();
|
|
||||||
}
|
|
||||||
if (tabIndex >= 0 &&
|
if (tabIndex >= 0 &&
|
||||||
(aIgnoreTabIndex || aCurrentTabIndex == tabIndex)) {
|
(aIgnoreTabIndex || aCurrentTabIndex == tabIndex)) {
|
||||||
nsresult rv = GetNextTabbableContent(
|
nsresult rv = GetNextTabbableContent(
|
||||||
|
|
@ -4327,12 +4329,19 @@ nsresult nsFocusManager::GetNextTabbableContent(
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (invokerContent &&
|
} else if (invokerContent) {
|
||||||
invokerContent->IsFocusableWithoutStyle()) {
|
nsIFrame* frame = invokerContent->GetPrimaryFrame();
|
||||||
// FIXME(emilio): The check above should probably use
|
if (frame && frame->IsFocusable()) {
|
||||||
// nsIFrame::IsFocusable, not IsFocusableWithoutStyle.
|
invokerContent.forget(aResultContent);
|
||||||
invokerContent.forget(aResultContent);
|
return NS_OK;
|
||||||
return NS_OK;
|
}
|
||||||
|
nsresult rv = GetNextTabbableContent(
|
||||||
|
aPresShell, rootElement, aOriginalStartContent, invokerContent,
|
||||||
|
false, 0, true, false, aNavigateByKey, true,
|
||||||
|
aReachedToEndForDocumentNavigation, aResultContent);
|
||||||
|
if (NS_SUCCEEDED(rv) && *aResultContent) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
expected:
|
expected:
|
||||||
if (os == "win") and not debug and (processor == "x86_64"): [FAIL, PASS, TIMEOUT]
|
if (os == "win") and not debug and (processor == "x86_64"): [FAIL, PASS, TIMEOUT]
|
||||||
if (os == "mac") and not debug: [FAIL, PASS, TIMEOUT]
|
if (os == "mac") and not debug: [FAIL, PASS, TIMEOUT]
|
||||||
FAIL
|
|
||||||
|
|
||||||
[Circular reference tab navigation]
|
[Circular reference tab navigation]
|
||||||
expected:
|
expected:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue