mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-26 00:57:30 +09:00
Bug 1299363 - Part 1: Implement construction stack.
Tag UXP Issue #1344
This commit is contained in:
parent
34dd7065f5
commit
c34486aaa0
2 changed files with 30 additions and 13 deletions
|
|
@ -106,6 +106,8 @@ private:
|
||||||
virtual ~CustomElementData() {}
|
virtual ~CustomElementData() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define ALEADY_CONSTRUCTED_MARKER nullptr
|
||||||
|
|
||||||
// The required information for a custom element as defined in:
|
// The required information for a custom element as defined in:
|
||||||
// https://html.spec.whatwg.org/multipage/scripting.html#custom-element-definition
|
// https://html.spec.whatwg.org/multipage/scripting.html#custom-element-definition
|
||||||
struct CustomElementDefinition
|
struct CustomElementDefinition
|
||||||
|
|
@ -132,8 +134,8 @@ struct CustomElementDefinition
|
||||||
// The lifecycle callbacks to call for this custom element.
|
// The lifecycle callbacks to call for this custom element.
|
||||||
UniquePtr<mozilla::dom::LifecycleCallbacks> mCallbacks;
|
UniquePtr<mozilla::dom::LifecycleCallbacks> mCallbacks;
|
||||||
|
|
||||||
// A construction stack.
|
// A construction stack. Use nullptr to represent an "already constructed marker".
|
||||||
// TODO: Bug 1287348 - Implement construction stack for upgrading an element
|
nsTArray<RefPtr<nsGenericHTMLElement>> mConstructionStack;
|
||||||
|
|
||||||
// The document custom element order.
|
// The document custom element order.
|
||||||
uint32_t mDocOrder;
|
uint32_t mDocOrder;
|
||||||
|
|
|
||||||
|
|
@ -3539,20 +3539,35 @@ CreateHTMLElement(const GlobalObject& aGlobal, const JS::CallArgs& aCallArgs,
|
||||||
|
|
||||||
// Step 6 and Step 7 are in the code output by CGClassConstructor.
|
// Step 6 and Step 7 are in the code output by CGClassConstructor.
|
||||||
// Step 8.
|
// Step 8.
|
||||||
// Construction stack will be implemented in bug 1287348. So we always run
|
nsTArray<RefPtr<nsGenericHTMLElement>>& constructionStack =
|
||||||
// "construction stack is empty" case for now.
|
definition->mConstructionStack;
|
||||||
RefPtr<nsGenericHTMLElement> element;
|
if (constructionStack.IsEmpty()) {
|
||||||
if (tag == eHTMLTag_userdefined) {
|
RefPtr<nsGenericHTMLElement> newElement;
|
||||||
// Autonomous custom element.
|
if (tag == eHTMLTag_userdefined) {
|
||||||
element = NS_NewHTMLElement(nodeInfo.forget());
|
// Autonomous custom element.
|
||||||
} else {
|
newElement = NS_NewHTMLElement(nodeInfo.forget());
|
||||||
// Customized built-in element.
|
} else {
|
||||||
element = CreateHTMLElement(tag, nodeInfo.forget(), NOT_FROM_PARSER);
|
// Customized built-in element.
|
||||||
|
newElement = CreateHTMLElement(tag, nodeInfo.forget(), NOT_FROM_PARSER);
|
||||||
|
}
|
||||||
|
|
||||||
|
newElement->SetCustomElementData(
|
||||||
|
new CustomElementData(definition->mType, CustomElementData::State::eCustom));
|
||||||
|
|
||||||
|
return newElement.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
element->SetCustomElementData(
|
// Step 9.
|
||||||
new CustomElementData(definition->mType, CustomElementData::State::eCustom));
|
RefPtr<nsGenericHTMLElement>& element = constructionStack.LastElement();
|
||||||
|
|
||||||
|
// Step 10.
|
||||||
|
if (element == ALEADY_CONSTRUCTED_MARKER) {
|
||||||
|
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 11 is in the code output by CGClassConstructor.
|
||||||
|
// Step 12 and Step 13.
|
||||||
return element.forget();
|
return element.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue