From ca1a84cb93062f83cc5dd551e098b42b6833994d Mon Sep 17 00:00:00 2001 From: Moonchild Date: Thu, 12 Aug 2021 00:27:34 +0000 Subject: [PATCH] [DOM/NPAPI] Defer loading object when setting attribute. --- dom/html/HTMLObjectElement.cpp | 8 +++++++- dom/html/HTMLSharedObjectElement.cpp | 9 +++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/dom/html/HTMLObjectElement.cpp b/dom/html/HTMLObjectElement.cpp index e0e79b69a..a0d06a8c6 100644 --- a/dom/html/HTMLObjectElement.cpp +++ b/dom/html/HTMLObjectElement.cpp @@ -193,7 +193,13 @@ HTMLObjectElement::AfterMaybeChangeAttr(int32_t aNamespaceID, nsIAtom* aName, // attributes before inserting the node into the document. if (aNotify && IsInComposedDoc() && mIsDoneAddingChildren && aName == nsGkAtoms::data) { - return LoadObject(aNotify, true); + nsContentUtils::AddScriptRunner(NS_NewRunnableFunction( + [self = RefPtr(this), aNotify]() { + if (self->IsInComposedDoc()) { + self->LoadObject(aNotify, true); + } + })); + return NS_OK; } } diff --git a/dom/html/HTMLSharedObjectElement.cpp b/dom/html/HTMLSharedObjectElement.cpp index f0cf4c188..d7eec215a 100644 --- a/dom/html/HTMLSharedObjectElement.cpp +++ b/dom/html/HTMLSharedObjectElement.cpp @@ -177,8 +177,13 @@ HTMLSharedObjectElement::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() && mIsDoneAddingChildren) { - nsresult rv = LoadObject(aNotify, true); - NS_ENSURE_SUCCESS(rv, rv); + nsContentUtils::AddScriptRunner(NS_NewRunnableFunction( + [self = RefPtr(this), aNotify]() { + if (self->IsInComposedDoc()) { + self->LoadObject(aNotify, true); + } + })); + return NS_OK; } } }