Bug 1666184 - Defer loading object when setting attribute; r=nika a=pascalc

Differential Revision: https://phabricator.services.mozilla.com/D116819
This commit is contained in:
Edgar Chen 2021-07-14 14:46:12 +00:00
parent 6c2757cba8
commit 9d021e6dbd
2 changed files with 16 additions and 3 deletions

View File

@ -128,8 +128,14 @@ nsresult HTMLEmbedElement::AfterMaybeChangeAttr(int32_t aNamespaceID,
// a document, just in case that the caller wants to set additional
// attributes before inserting the node into the document.
if (aNotify && IsInComposedDoc() && !BlockEmbedOrObjectContentLoading()) {
nsresult rv = LoadObject(aNotify, true);
NS_ENSURE_SUCCESS(rv, rv);
nsContentUtils::AddScriptRunner(NS_NewRunnableFunction(
"HTMLEmbedElement::LoadObject",
[self = RefPtr<HTMLEmbedElement>(this), aNotify]() {
if (self->IsInComposedDoc()) {
self->LoadObject(aNotify, true);
}
}));
return NS_OK;
}
}
}

View File

@ -145,7 +145,14 @@ nsresult HTMLObjectElement::AfterMaybeChangeAttr(int32_t aNamespaceID,
// attributes before inserting the node into the document.
if (aNotify && IsInComposedDoc() && mIsDoneAddingChildren &&
aName == nsGkAtoms::data && !BlockEmbedOrObjectContentLoading()) {
return LoadObject(aNotify, true);
nsContentUtils::AddScriptRunner(NS_NewRunnableFunction(
"HTMLObjectElement::LoadObject",
[self = RefPtr<HTMLObjectElement>(this), aNotify]() {
if (self->IsInComposedDoc()) {
self->LoadObject(aNotify, true);
}
}));
return NS_OK;
}
}