ported mozilla upstream change: Bug 1355441 - Reuse StackNode in TreeBuilder to avoid malloc. r=hsivonen.

This commit is contained in:
Roy Tam 2019-06-29 07:35:34 +08:00
commit b7a35ab2cd
8 changed files with 578 additions and 177 deletions

View file

@ -88,6 +88,9 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
nsIContentHandle* contextNode;
autoJArray<int32_t,int32_t> templateModeStack;
int32_t templateModePtr;
autoJArray<nsHtml5StackNode*, int32_t> stackNodes;
int32_t stackNodesIdx;
int32_t numStackNodes;
autoJArray<nsHtml5StackNode*,int32_t> stack;
int32_t currentPtr;
autoJArray<nsHtml5StackNode*,int32_t> listOfActiveFormattingElements;
@ -187,6 +190,33 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
void addAttributesToHtml(nsHtml5HtmlAttributes* attributes);
void pushHeadPointerOntoStack();
void reconstructTheActiveFormattingElements();
public:
void notifyUnusedStackNode(int32_t idxInStackNodes);
private:
nsHtml5StackNode* getUnusedStackNode();
nsHtml5StackNode* createStackNode(int32_t flags,
int32_t ns,
nsIAtom* name,
nsIContentHandle* node,
nsIAtom* popName,
nsHtml5HtmlAttributes* attributes);
nsHtml5StackNode* createStackNode(nsHtml5ElementName* elementName,
nsIContentHandle* node);
nsHtml5StackNode* createStackNode(nsHtml5ElementName* elementName,
nsIContentHandle* node,
nsHtml5HtmlAttributes* attributes);
nsHtml5StackNode* createStackNode(nsHtml5ElementName* elementName,
nsIContentHandle* node,
nsIAtom* popName);
nsHtml5StackNode* createStackNode(nsHtml5ElementName* elementName,
nsIAtom* popName,
nsIContentHandle* node);
nsHtml5StackNode* createStackNode(nsHtml5ElementName* elementName,
nsIContentHandle* node,
nsIAtom* popName,
bool markAsIntegrationPoint);
void insertIntoFosterParent(nsIContentHandle* child);
nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes);
nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);