mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 07:18:39 +09:00
Bug 1378079 - Part 3: Complete the steps related to custom elements in "create an element for a token".
With fixup for missing header due to unified builds. Tag UXP Issue #1344
This commit is contained in:
parent
ed18cbb741
commit
5d26d32825
8 changed files with 203 additions and 141 deletions
|
|
@ -255,7 +255,8 @@ DoCustomElementCreate(Element** aElement, nsIDocument* aDoc, nsIAtom* aLocalName
|
|||
|
||||
nsresult
|
||||
NS_NewHTMLElement(Element** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
||||
FromParser aFromParser, const nsAString* aIs)
|
||||
FromParser aFromParser, const nsAString* aIs,
|
||||
mozilla::dom::CustomElementDefinition* aDefinition)
|
||||
{
|
||||
*aResult = nullptr;
|
||||
|
||||
|
|
@ -276,8 +277,8 @@ NS_NewHTMLElement(Element** aResult, already_AddRefed<mozilla::dom::NodeInfo>&&
|
|||
// We only handle the "synchronous custom elements flag is set" now.
|
||||
// For the unset case (e.g. cloning a node), see bug 1319342 for that.
|
||||
// Step 4.
|
||||
CustomElementDefinition* definition = nullptr;
|
||||
if (CustomElementRegistry::IsCustomElementEnabled()) {
|
||||
CustomElementDefinition* definition = aDefinition;
|
||||
if (!definition && CustomElementRegistry::IsCustomElementEnabled()) {
|
||||
definition =
|
||||
nsContentUtils::LookupCustomElementDefinition(nodeInfo->GetDocument(),
|
||||
nodeInfo->LocalName(),
|
||||
|
|
@ -302,9 +303,20 @@ NS_NewHTMLElement(Element** aResult, already_AddRefed<mozilla::dom::NodeInfo>&&
|
|||
bool synchronousCustomElements = aFromParser != dom::FROM_PARSER_FRAGMENT ||
|
||||
aFromParser == dom::NOT_FROM_PARSER;
|
||||
// Per discussion in https://github.com/w3c/webcomponents/issues/635,
|
||||
// use entry global in those places that are called from JS APIs.
|
||||
nsIGlobalObject* global = GetEntryGlobal();
|
||||
MOZ_ASSERT(global);
|
||||
// use entry global in those places that are called from JS APIs and use the
|
||||
// node document's global object if it is called from parser.
|
||||
nsIGlobalObject* global;
|
||||
if (aFromParser == dom::NOT_FROM_PARSER) {
|
||||
global = GetEntryGlobal();
|
||||
} else {
|
||||
global = nodeInfo->GetDocument()->GetScopeObject();
|
||||
}
|
||||
if (!global) {
|
||||
// In browser chrome code, one may have access to a document which doesn't
|
||||
// have scope object anymore.
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
AutoEntryScript aes(global, "create custom elements");
|
||||
JSContext* cx = aes.cx();
|
||||
ErrorResult rv;
|
||||
|
|
@ -344,6 +356,7 @@ NS_NewHTMLElement(Element** aResult, already_AddRefed<mozilla::dom::NodeInfo>&&
|
|||
|
||||
// Step 6.2.
|
||||
NS_IF_ADDREF(*aResult = NS_NewHTMLElement(nodeInfo.forget(), aFromParser));
|
||||
(*aResult)->SetCustomElementData(new CustomElementData(definition->mType));
|
||||
nsContentUtils::EnqueueUpgradeReaction(*aResult, definition);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue