Bug 1815913 - Init nsImageMap more eagerly r=emilio

Since we are initializing nsImageMap lazily, it's possible for area elements
stays non-focusable when autofocus code tries to focus it. So to fix
this, we need to ensure nsImageMap is initialized early enough.

Differential Revision: https://phabricator.services.mozilla.com/D168166
This commit is contained in:
Sean Feng 2023-02-13 15:52:40 +00:00
Родитель 346632d092
Коммит 8f0d50d3c1
2 изменённых файлов: 7 добавлений и 3 удалений

Просмотреть файл

@ -44,9 +44,10 @@ inline bool nsIContent::IsInChromeDocument() const {
inline void nsIContent::SetPrimaryFrame(nsIFrame* aFrame) {
MOZ_ASSERT(IsInUncomposedDoc() || IsInShadowTree(), "This will end badly!");
// FIXME bug 749326
NS_ASSERTION(!aFrame || !mPrimaryFrame || aFrame == mPrimaryFrame,
"Losing track of existing primary frame");
// <area> is known to trigger this, see bug 749326 and bug 135040.
MOZ_ASSERT(IsHTMLElement(nsGkAtoms::area) || !aFrame || !mPrimaryFrame ||
aFrame == mPrimaryFrame,
"Losing track of existing primary frame");
if (aFrame) {
MOZ_ASSERT(!aFrame->IsPlaceholderFrame());

Просмотреть файл

@ -513,6 +513,9 @@ void nsImageFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
mListener = new nsImageListener(this);
GetImageMap(); // Ensure to init the image map asap. This is important to
// make <area> elements focusable.
if (!gIconLoad) {
LoadIcons(PresContext());
}