Bug 1878753 - Fix focus gets incorrectly cleared by PresShell::FixUpFocus if the focus is on area element r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D200950
This commit is contained in:
Sean Feng
2024-02-08 16:35:02 +00:00
parent fa3e7164c7
commit faf28dc59b
4 changed files with 52 additions and 8 deletions

View File

@@ -13,6 +13,7 @@
#include "mozilla/dom/ElementBinding.h"
#include "mozilla/dom/LargestContentfulPaint.h"
#include "mozilla/dom/PerformanceMainThread.h"
#include "mozilla/dom/HTMLAreaElement.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/Attributes.h"
#include "mozilla/AutoRestore.h"
@@ -1483,6 +1484,14 @@ bool PresShell::FixUpFocus() {
return false;
}
// If focus target is an area element with one or more shapes that are
// focusable areas.
if (auto* area = HTMLAreaElement::FromNode(currentFocus)) {
if (nsFocusManager::IsAreaElementFocusable(*area)) {
return false;
}
}
nsIFrame* f = currentFocus->GetPrimaryFrame();
if (f && f->IsFocusable()) {
return false;