зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 2e7615b554ee (bug 1355441) for crashing at nsHtml5TreeBuilder::getUnusedStackNode() intermittent failures
This commit is contained in:
Родитель
93aa78bfde
Коммит
cdb9631de8
|
@ -28,27 +28,24 @@ import nu.validator.htmlparser.annotation.Local;
|
|||
import nu.validator.htmlparser.annotation.NsUri;
|
||||
|
||||
final class StackNode<T> {
|
||||
// Index where this stack node is stored in the tree builder's list of stack nodes.
|
||||
final int idxInTreeBuilder;
|
||||
final int flags;
|
||||
|
||||
int flags;
|
||||
final @Local String name;
|
||||
|
||||
@Local String name;
|
||||
final @Local String popName;
|
||||
|
||||
@Local String popName;
|
||||
final @NsUri String ns;
|
||||
|
||||
@NsUri String ns;
|
||||
|
||||
T node;
|
||||
final T node;
|
||||
|
||||
// Only used on the list of formatting elements
|
||||
HtmlAttributes attributes;
|
||||
|
||||
private int refcount = 0;
|
||||
private int refcount = 1;
|
||||
|
||||
// [NOCPP[
|
||||
|
||||
private TaintableLocatorImpl locator;
|
||||
private final TaintableLocatorImpl locator;
|
||||
|
||||
public TaintableLocatorImpl getLocator() {
|
||||
return locator;
|
||||
|
@ -88,14 +85,9 @@ final class StackNode<T> {
|
|||
|
||||
// ]NOCPP]
|
||||
|
||||
StackNode(int idxInTreeBuilder) {
|
||||
this.idxInTreeBuilder = idxInTreeBuilder;
|
||||
this.refcount = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for copying. This doesn't take another <code>StackNode</code>
|
||||
* because in C++ the caller is responsible for reobtaining the local names
|
||||
* Constructor for copying. This doesn't take another <code>StackNode</code>
|
||||
* because in C++ the caller is reponsible for reobtaining the local names
|
||||
* from another interner.
|
||||
*
|
||||
* @param flags
|
||||
|
@ -105,13 +97,12 @@ final class StackNode<T> {
|
|||
* @param popName
|
||||
* @param attributes
|
||||
*/
|
||||
void setValues(int flags, @NsUri String ns, @Local String name, T node,
|
||||
StackNode(int flags, @NsUri String ns, @Local String name, T node,
|
||||
@Local String popName, HtmlAttributes attributes
|
||||
// [NOCPP[
|
||||
, TaintableLocatorImpl locator
|
||||
// ]NOCPP]
|
||||
) {
|
||||
assert isUnused();
|
||||
this.flags = flags;
|
||||
this.name = name;
|
||||
this.popName = popName;
|
||||
|
@ -130,12 +121,11 @@ final class StackNode<T> {
|
|||
* @param elementName
|
||||
* @param node
|
||||
*/
|
||||
void setValues(ElementName elementName, T node
|
||||
StackNode(ElementName elementName, T node
|
||||
// [NOCPP[
|
||||
, TaintableLocatorImpl locator
|
||||
// ]NOCPP]
|
||||
) {
|
||||
assert isUnused();
|
||||
this.flags = elementName.getFlags();
|
||||
this.name = elementName.getName();
|
||||
this.popName = elementName.getName();
|
||||
|
@ -150,18 +140,17 @@ final class StackNode<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Setter for HTML formatting elements.
|
||||
* Constructor for HTML formatting elements.
|
||||
*
|
||||
* @param elementName
|
||||
* @param node
|
||||
* @param attributes
|
||||
*/
|
||||
void setValues(ElementName elementName, T node, HtmlAttributes attributes
|
||||
StackNode(ElementName elementName, T node, HtmlAttributes attributes
|
||||
// [NOCPP[
|
||||
, TaintableLocatorImpl locator
|
||||
// ]NOCPP]
|
||||
) {
|
||||
assert isUnused();
|
||||
this.flags = elementName.getFlags();
|
||||
this.name = elementName.getName();
|
||||
this.popName = elementName.getName();
|
||||
|
@ -176,18 +165,17 @@ final class StackNode<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* The common-case HTML setter.
|
||||
* The common-case HTML constructor.
|
||||
*
|
||||
* @param elementName
|
||||
* @param node
|
||||
* @param popName
|
||||
*/
|
||||
void setValues(ElementName elementName, T node, @Local String popName
|
||||
StackNode(ElementName elementName, T node, @Local String popName
|
||||
// [NOCPP[
|
||||
, TaintableLocatorImpl locator
|
||||
// ]NOCPP]
|
||||
) {
|
||||
assert isUnused();
|
||||
this.flags = elementName.getFlags();
|
||||
this.name = elementName.getName();
|
||||
this.popName = popName;
|
||||
|
@ -201,8 +189,8 @@ final class StackNode<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Setter for SVG elements. Note that the order of the arguments is
|
||||
* what distinguishes this from the HTML setter. This is ugly, but
|
||||
* Constructor for SVG elements. Note that the order of the arguments is
|
||||
* what distinguishes this from the HTML constructor. This is ugly, but
|
||||
* AFAICT the least disruptive way to make this work with Java's generics
|
||||
* and without unnecessary branches. :-(
|
||||
*
|
||||
|
@ -210,12 +198,11 @@ final class StackNode<T> {
|
|||
* @param popName
|
||||
* @param node
|
||||
*/
|
||||
void setValues(ElementName elementName, @Local String popName, T node
|
||||
StackNode(ElementName elementName, @Local String popName, T node
|
||||
// [NOCPP[
|
||||
, TaintableLocatorImpl locator
|
||||
// ]NOCPP]
|
||||
) {
|
||||
assert isUnused();
|
||||
this.flags = prepareSvgFlags(elementName.getFlags());
|
||||
this.name = elementName.getName();
|
||||
this.popName = popName;
|
||||
|
@ -229,20 +216,19 @@ final class StackNode<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Setter for MathML.
|
||||
* Constructor for MathML.
|
||||
*
|
||||
* @param elementName
|
||||
* @param node
|
||||
* @param popName
|
||||
* @param markAsIntegrationPoint
|
||||
*/
|
||||
void setValues(ElementName elementName, T node, @Local String popName,
|
||||
StackNode(ElementName elementName, T node, @Local String popName,
|
||||
boolean markAsIntegrationPoint
|
||||
// [NOCPP[
|
||||
, TaintableLocatorImpl locator
|
||||
// ]NOCPP]
|
||||
) {
|
||||
assert isUnused();
|
||||
this.flags = prepareMathFlags(elementName.getFlags(),
|
||||
markAsIntegrationPoint);
|
||||
this.name = elementName.getName();
|
||||
|
@ -279,7 +265,7 @@ final class StackNode<T> {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unused") private void destructor() {
|
||||
// The translator adds refcount debug code here.
|
||||
Portability.delete(attributes);
|
||||
}
|
||||
|
||||
public void dropAttributes() {
|
||||
|
@ -300,16 +286,10 @@ final class StackNode<T> {
|
|||
refcount++;
|
||||
}
|
||||
|
||||
public void release(TreeBuilder<T> owningTreeBuilder) {
|
||||
public void release() {
|
||||
refcount--;
|
||||
assert refcount >= 0;
|
||||
if (refcount == 0) {
|
||||
Portability.delete(attributes);
|
||||
owningTreeBuilder.notifyUnusedStackNode(idxInTreeBuilder);
|
||||
Portability.delete(this);
|
||||
}
|
||||
}
|
||||
|
||||
boolean isUnused() {
|
||||
return refcount == 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,6 @@ import nu.validator.htmlparser.annotation.Auto;
|
|||
|
||||
public class StateSnapshot<T> implements TreeBuilderState<T> {
|
||||
|
||||
private final TreeBuilder<T> treeBuilder;
|
||||
|
||||
private final @Auto StackNode<T>[] stack;
|
||||
|
||||
private final @Auto StackNode<T>[] listOfActiveFormattingElements;
|
||||
|
@ -64,11 +62,10 @@ public class StateSnapshot<T> implements TreeBuilderState<T> {
|
|||
* @param needToDropLF
|
||||
* @param quirks
|
||||
*/
|
||||
StateSnapshot(TreeBuilder<T> treeBuilder, StackNode<T>[] stack,
|
||||
StateSnapshot(StackNode<T>[] stack,
|
||||
StackNode<T>[] listOfActiveFormattingElements, int[] templateModeStack, T formPointer,
|
||||
T headPointer, T deepTreeSurrogateParent, int mode, int originalMode,
|
||||
boolean framesetOk, boolean needToDropLF, boolean quirks) {
|
||||
this.treeBuilder = treeBuilder;
|
||||
this.stack = stack;
|
||||
this.listOfActiveFormattingElements = listOfActiveFormattingElements;
|
||||
this.templateModeStack = templateModeStack;
|
||||
|
@ -196,11 +193,11 @@ public class StateSnapshot<T> implements TreeBuilderState<T> {
|
|||
|
||||
@SuppressWarnings("unused") private void destructor() {
|
||||
for (int i = 0; i < stack.length; i++) {
|
||||
stack[i].release(treeBuilder);
|
||||
stack[i].release();
|
||||
}
|
||||
for (int i = 0; i < listOfActiveFormattingElements.length; i++) {
|
||||
if (listOfActiveFormattingElements[i] != null) {
|
||||
listOfActiveFormattingElements[i].release(treeBuilder);
|
||||
listOfActiveFormattingElements[i].release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -425,15 +425,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
*/
|
||||
private int templateModePtr = -1;
|
||||
|
||||
private @Auto StackNode<T>[] stackNodes;
|
||||
|
||||
/**
|
||||
* Index of the earliest possible unused or empty element in stackNodes.
|
||||
*/
|
||||
private int stackNodesIdx = -1;
|
||||
|
||||
private int numStackNodes = 0;
|
||||
|
||||
private @Auto StackNode<T>[] stack;
|
||||
|
||||
private int currentPtr = -1;
|
||||
|
@ -592,15 +583,12 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
|
||||
@SuppressWarnings("unchecked") public final void startTokenization(Tokenizer self) throws SAXException {
|
||||
tokenizer = self;
|
||||
stackNodes = new StackNode[64];
|
||||
stack = new StackNode[64];
|
||||
templateModeStack = new int[64];
|
||||
listOfActiveFormattingElements = new StackNode[64];
|
||||
needToDropLF = false;
|
||||
originalMode = INITIAL;
|
||||
templateModePtr = -1;
|
||||
stackNodesIdx = 0;
|
||||
numStackNodes = 0;
|
||||
currentPtr = -1;
|
||||
listPtr = -1;
|
||||
formPointer = null;
|
||||
|
@ -643,7 +631,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
elementName = ElementName.FOREIGNOBJECT;
|
||||
}
|
||||
// This is the SVG variant of the StackNode constructor.
|
||||
StackNode<T> node = createStackNode(elementName,
|
||||
StackNode<T> node = new StackNode<T>(elementName,
|
||||
elementName.getCamelCaseName(), elt
|
||||
// [NOCPP[
|
||||
, errorHandler == null ? null
|
||||
|
@ -674,7 +662,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
// is resolved.
|
||||
}
|
||||
// This is the MathML variant of the StackNode constructor.
|
||||
StackNode<T> node = createStackNode(elementName, elt,
|
||||
StackNode<T> node = new StackNode<T>(elementName, elt,
|
||||
elementName.getName(), false
|
||||
// [NOCPP[
|
||||
, errorHandler == null ? null
|
||||
|
@ -689,7 +677,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
// ends up being allowed as HTML frameset in the fragment case.
|
||||
mode = FRAMESET_OK;
|
||||
} else { // html
|
||||
StackNode<T> node = createStackNode(ElementName.HTML, elt
|
||||
StackNode<T> node = new StackNode<T>(ElementName.HTML, elt
|
||||
// [NOCPP[
|
||||
, errorHandler == null ? null
|
||||
: new TaintableLocatorImpl(tokenizer)
|
||||
|
@ -732,7 +720,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
// CPPONLY: T elt = createElement("http://www.w3.org/2000/svg",
|
||||
// CPPONLY: "svg",
|
||||
// CPPONLY: tokenizer.emptyAttributes(), null);
|
||||
// CPPONLY: StackNode<T> node = createStackNode(ElementName.SVG,
|
||||
// CPPONLY: StackNode<T> node = new StackNode<T>(ElementName.SVG,
|
||||
// CPPONLY: "svg",
|
||||
// CPPONLY: elt);
|
||||
// CPPONLY: currentPtr++;
|
||||
|
@ -1635,7 +1623,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
templateModeStack = null;
|
||||
if (stack != null) {
|
||||
while (currentPtr > -1) {
|
||||
stack[currentPtr].release(this);
|
||||
stack[currentPtr].release();
|
||||
currentPtr--;
|
||||
}
|
||||
stack = null;
|
||||
|
@ -1643,21 +1631,12 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
if (listOfActiveFormattingElements != null) {
|
||||
while (listPtr > -1) {
|
||||
if (listOfActiveFormattingElements[listPtr] != null) {
|
||||
listOfActiveFormattingElements[listPtr].release(this);
|
||||
listOfActiveFormattingElements[listPtr].release();
|
||||
}
|
||||
listPtr--;
|
||||
}
|
||||
listOfActiveFormattingElements = null;
|
||||
}
|
||||
if (stackNodes != null) {
|
||||
for (int i = 0; i < numStackNodes; i++) {
|
||||
assert stackNodes[i].isUnused();
|
||||
Portability.delete(stackNodes[i]);
|
||||
}
|
||||
numStackNodes = 0;
|
||||
stackNodesIdx = 0;
|
||||
stackNodes = null;
|
||||
}
|
||||
// [NOCPP[
|
||||
idLocations.clear();
|
||||
// ]NOCPP]
|
||||
|
@ -2239,7 +2218,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
if (activeAPos != -1) {
|
||||
removeFromListOfActiveFormattingElements(activeAPos);
|
||||
}
|
||||
activeA.release(this);
|
||||
activeA.release();
|
||||
}
|
||||
reconstructTheActiveFormattingElements();
|
||||
appendToCurrentNodeAndPushFormattingElementMayFoster(
|
||||
|
@ -4636,7 +4615,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
--listPtr;
|
||||
return;
|
||||
}
|
||||
listOfActiveFormattingElements[listPtr].release(this);
|
||||
listOfActiveFormattingElements[listPtr].release();
|
||||
--listPtr;
|
||||
}
|
||||
}
|
||||
|
@ -4651,7 +4630,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
pop();
|
||||
} else {
|
||||
fatal();
|
||||
stack[pos].release(this);
|
||||
stack[pos].release();
|
||||
System.arraycopy(stack, pos + 1, stack, pos, currentPtr - pos);
|
||||
assert debugOnlyClearLastStackSlot();
|
||||
currentPtr--;
|
||||
|
@ -4671,7 +4650,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
return;
|
||||
}
|
||||
fatal();
|
||||
node.release(this);
|
||||
node.release();
|
||||
System.arraycopy(stack, pos + 1, stack, pos, currentPtr - pos);
|
||||
currentPtr--;
|
||||
}
|
||||
|
@ -4679,7 +4658,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
|
||||
private void removeFromListOfActiveFormattingElements(int pos) {
|
||||
assert listOfActiveFormattingElements[pos] != null;
|
||||
listOfActiveFormattingElements[pos].release(this);
|
||||
listOfActiveFormattingElements[pos].release();
|
||||
if (pos == listPtr) {
|
||||
assert debugOnlyClearLastListSlot();
|
||||
listPtr--;
|
||||
|
@ -4825,7 +4804,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
assert node == stack[nodePos];
|
||||
T clone = createElement("http://www.w3.org/1999/xhtml",
|
||||
node.name, node.attributes.cloneAttributes(null), commonAncestor.node);
|
||||
StackNode<T> newNode = createStackNode(node.getFlags(), node.ns,
|
||||
StackNode<T> newNode = new StackNode<T>(node.getFlags(), node.ns,
|
||||
node.name, clone, node.popName, node.attributes
|
||||
// [NOCPP[
|
||||
, node.getLocator()
|
||||
|
@ -4835,8 +4814,8 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
stack[nodePos] = newNode;
|
||||
newNode.retain(); // retain for list
|
||||
listOfActiveFormattingElements[nodeListPos] = newNode;
|
||||
node.release(this); // release from stack
|
||||
node.release(this); // release from list
|
||||
node.release(); // release from stack
|
||||
node.release(); // release from list
|
||||
node = newNode;
|
||||
// } XXX AAA CHANGE
|
||||
detachFromParent(lastNode.node);
|
||||
|
@ -4854,7 +4833,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
T clone = createElement("http://www.w3.org/1999/xhtml",
|
||||
formattingElt.name,
|
||||
formattingElt.attributes.cloneAttributes(null), furthestBlock.node);
|
||||
StackNode<T> formattingClone = createStackNode(
|
||||
StackNode<T> formattingClone = new StackNode<T>(
|
||||
formattingElt.getFlags(), formattingElt.ns,
|
||||
formattingElt.name, clone, formattingElt.popName,
|
||||
formattingElt.attributes
|
||||
|
@ -4997,7 +4976,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
assert headPointer != null;
|
||||
assert mode == AFTER_HEAD;
|
||||
fatal();
|
||||
silentPush(createStackNode(ElementName.HEAD, headPointer
|
||||
silentPush(new StackNode<T>(ElementName.HEAD, headPointer
|
||||
// [NOCPP[
|
||||
, errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
|
||||
// ]NOCPP]
|
||||
|
@ -5044,7 +5023,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
appendElement(clone, currentNode.node);
|
||||
}
|
||||
|
||||
StackNode<T> entryClone = createStackNode(entry.getFlags(),
|
||||
StackNode<T> entryClone = new StackNode<T>(entry.getFlags(),
|
||||
entry.ns, entry.name, clone, entry.popName,
|
||||
entry.attributes
|
||||
// [NOCPP[
|
||||
|
@ -5058,132 +5037,11 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
// stack takes ownership of the local variable
|
||||
listOfActiveFormattingElements[entryPos] = entryClone;
|
||||
// overwriting the old entry on the list, so release & retain
|
||||
entry.release(this);
|
||||
entry.release();
|
||||
entryClone.retain();
|
||||
}
|
||||
}
|
||||
|
||||
void notifyUnusedStackNode(int idxInStackNodes) {
|
||||
// stackNodesIdx is the earliest possible index of a stack node that might be unused,
|
||||
// so update the index if necessary.
|
||||
if (idxInStackNodes < stackNodesIdx) {
|
||||
stackNodesIdx = idxInStackNodes;
|
||||
}
|
||||
}
|
||||
|
||||
private StackNode<T> getUnusedStackNode() {
|
||||
// Search for an unused stack node.
|
||||
while (stackNodesIdx < numStackNodes) {
|
||||
if (stackNodes[stackNodesIdx].isUnused()) {
|
||||
return stackNodes[stackNodesIdx++];
|
||||
}
|
||||
stackNodesIdx++;
|
||||
}
|
||||
|
||||
if (stackNodesIdx < stackNodes.length) {
|
||||
// No unused stack nodes, but there is still space in the storage array.
|
||||
stackNodes[stackNodesIdx] = new StackNode<T>(stackNodesIdx);
|
||||
numStackNodes++;
|
||||
return stackNodes[stackNodesIdx++];
|
||||
}
|
||||
|
||||
// Could not find an unused stack node and storage array is full.
|
||||
StackNode<T>[] newStack = new StackNode[stackNodes.length + 64];
|
||||
System.arraycopy(stackNodes, 0, newStack, 0, stackNodes.length);
|
||||
stackNodes = newStack;
|
||||
|
||||
// Create a new stack node and return it.
|
||||
stackNodes[stackNodesIdx] = new StackNode<T>(stackNodesIdx);
|
||||
numStackNodes++;
|
||||
return stackNodes[stackNodesIdx++];
|
||||
}
|
||||
|
||||
private StackNode<T> createStackNode(int flags, @NsUri String ns, @Local String name, T node,
|
||||
@Local String popName, HtmlAttributes attributes
|
||||
// [NOCPP[
|
||||
, TaintableLocatorImpl locator
|
||||
// ]NOCPP]
|
||||
) {
|
||||
StackNode<T> instance = getUnusedStackNode();
|
||||
instance.setValues(flags, ns, name, node, popName, attributes
|
||||
// [NOCPP[
|
||||
, locator
|
||||
// ]NOCPP]
|
||||
);
|
||||
return instance;
|
||||
}
|
||||
|
||||
private StackNode<T> createStackNode(ElementName elementName, T node
|
||||
// [NOCPP[
|
||||
, TaintableLocatorImpl locator
|
||||
// ]NOCPP]
|
||||
) {
|
||||
StackNode<T> instance = getUnusedStackNode();
|
||||
instance.setValues(elementName, node
|
||||
// [NOCPP[
|
||||
, locator
|
||||
// ]NOCPP]
|
||||
);
|
||||
return instance;
|
||||
}
|
||||
|
||||
private StackNode<T> createStackNode(ElementName elementName, T node, HtmlAttributes attributes
|
||||
// [NOCPP[
|
||||
, TaintableLocatorImpl locator
|
||||
// ]NOCPP]
|
||||
) {
|
||||
StackNode<T> instance = getUnusedStackNode();
|
||||
instance.setValues(elementName, node, attributes
|
||||
// [NOCPP[
|
||||
, locator
|
||||
// ]NOCPP]
|
||||
);
|
||||
return instance;
|
||||
}
|
||||
|
||||
private StackNode<T> createStackNode(ElementName elementName, T node, @Local String popName
|
||||
// [NOCPP[
|
||||
, TaintableLocatorImpl locator
|
||||
// ]NOCPP]
|
||||
) {
|
||||
StackNode<T> instance = getUnusedStackNode();
|
||||
instance.setValues(elementName, node, popName
|
||||
// [NOCPP[
|
||||
, locator
|
||||
// ]NOCPP]
|
||||
);
|
||||
return instance;
|
||||
}
|
||||
|
||||
private StackNode<T> createStackNode(ElementName elementName, @Local String popName, T node
|
||||
// [NOCPP[
|
||||
, TaintableLocatorImpl locator
|
||||
// ]NOCPP]
|
||||
) {
|
||||
StackNode<T> instance = getUnusedStackNode();
|
||||
instance.setValues(elementName, popName, node
|
||||
// [NOCPP[
|
||||
, locator
|
||||
// ]NOCPP]
|
||||
);
|
||||
return instance;
|
||||
}
|
||||
|
||||
private StackNode<T> createStackNode(ElementName elementName, T node, @Local String popName,
|
||||
boolean markAsIntegrationPoint
|
||||
// [NOCPP[
|
||||
, TaintableLocatorImpl locator
|
||||
// ]NOCPP]
|
||||
) {
|
||||
StackNode<T> instance = getUnusedStackNode();
|
||||
instance.setValues(elementName, node, popName, markAsIntegrationPoint
|
||||
// [NOCPP[
|
||||
, locator
|
||||
// ]NOCPP]
|
||||
);
|
||||
return instance;
|
||||
}
|
||||
|
||||
private void insertIntoFosterParent(T child) throws SAXException {
|
||||
int tablePos = findLastOrRoot(TreeBuilder.TABLE);
|
||||
int templatePos = findLastOrRoot(TreeBuilder.TEMPLATE);
|
||||
|
@ -5235,14 +5093,14 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
assert debugOnlyClearLastStackSlot();
|
||||
currentPtr--;
|
||||
elementPopped(node.ns, node.popName, node.node);
|
||||
node.release(this);
|
||||
node.release();
|
||||
}
|
||||
|
||||
private void silentPop() throws SAXException {
|
||||
StackNode<T> node = stack[currentPtr];
|
||||
assert debugOnlyClearLastStackSlot();
|
||||
currentPtr--;
|
||||
node.release(this);
|
||||
node.release();
|
||||
}
|
||||
|
||||
private void popOnEof() throws SAXException {
|
||||
|
@ -5251,7 +5109,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
currentPtr--;
|
||||
markMalformedIfScript(node.node);
|
||||
elementPopped(node.ns, node.popName, node.node);
|
||||
node.release(this);
|
||||
node.release();
|
||||
}
|
||||
|
||||
// [NOCPP[
|
||||
|
@ -5353,7 +5211,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
|
||||
// ]NOCPP]
|
||||
T elt = createHtmlElementSetAsRoot(attributes);
|
||||
StackNode<T> node = createStackNode(ElementName.HTML,
|
||||
StackNode<T> node = new StackNode<T>(ElementName.HTML,
|
||||
elt
|
||||
// [NOCPP[
|
||||
, errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
|
||||
|
@ -5375,7 +5233,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
T elt = createElement("http://www.w3.org/1999/xhtml", "head", attributes, currentNode);
|
||||
appendElement(elt, currentNode);
|
||||
headPointer = elt;
|
||||
StackNode<T> node = createStackNode(ElementName.HEAD,
|
||||
StackNode<T> node = new StackNode<T>(ElementName.HEAD,
|
||||
elt
|
||||
// [NOCPP[
|
||||
, errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
|
||||
|
@ -5414,7 +5272,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
formPointer = elt;
|
||||
}
|
||||
|
||||
StackNode<T> node = createStackNode(ElementName.FORM,
|
||||
StackNode<T> node = new StackNode<T>(ElementName.FORM,
|
||||
elt
|
||||
// [NOCPP[
|
||||
, errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
|
||||
|
@ -5442,7 +5300,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
elt = createElement("http://www.w3.org/1999/xhtml", elementName.getName(), attributes, current.node);
|
||||
appendElement(elt, current.node);
|
||||
}
|
||||
StackNode<T> node = createStackNode(elementName, elt, clone
|
||||
StackNode<T> node = new StackNode<T>(elementName, elt, clone
|
||||
// [NOCPP[
|
||||
, errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
|
||||
// ]NOCPP]
|
||||
|
@ -5465,7 +5323,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
if (ElementName.TEMPLATE == elementName) {
|
||||
elt = getDocumentFragmentForTemplate(elt);
|
||||
}
|
||||
StackNode<T> node = createStackNode(elementName, elt
|
||||
StackNode<T> node = new StackNode<T>(elementName, elt
|
||||
// [NOCPP[
|
||||
, errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
|
||||
// ]NOCPP]
|
||||
|
@ -5492,7 +5350,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes, current.node);
|
||||
appendElement(elt, current.node);
|
||||
}
|
||||
StackNode<T> node = createStackNode(elementName, elt, popName
|
||||
StackNode<T> node = new StackNode<T>(elementName, elt, popName
|
||||
// [NOCPP[
|
||||
, errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
|
||||
// ]NOCPP]
|
||||
|
@ -5526,7 +5384,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
elt = createElement("http://www.w3.org/1998/Math/MathML", popName, attributes, current.node);
|
||||
appendElement(elt, current.node);
|
||||
}
|
||||
StackNode<T> node = createStackNode(elementName, elt, popName,
|
||||
StackNode<T> node = new StackNode<T>(elementName, elt, popName,
|
||||
markAsHtmlIntegrationPoint
|
||||
// [NOCPP[
|
||||
, errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
|
||||
|
@ -5575,7 +5433,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
elt = createElement("http://www.w3.org/2000/svg", popName, attributes, current.node);
|
||||
appendElement(elt, current.node);
|
||||
}
|
||||
StackNode<T> node = createStackNode(elementName, popName, elt
|
||||
StackNode<T> node = new StackNode<T>(elementName, popName, elt
|
||||
// [NOCPP[
|
||||
, errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
|
||||
// ]NOCPP]
|
||||
|
@ -5602,7 +5460,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
attributes, formOwner, current.node);
|
||||
appendElement(elt, current.node);
|
||||
}
|
||||
StackNode<T> node = createStackNode(elementName, elt
|
||||
StackNode<T> node = new StackNode<T>(elementName, elt
|
||||
// [NOCPP[
|
||||
, errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
|
||||
// ]NOCPP]
|
||||
|
@ -6085,7 +5943,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
for (int i = 0; i < listCopy.length; i++) {
|
||||
StackNode<T> node = listOfActiveFormattingElements[i];
|
||||
if (node != null) {
|
||||
StackNode<T> newNode = createStackNode(node.getFlags(), node.ns,
|
||||
StackNode<T> newNode = new StackNode<T>(node.getFlags(), node.ns,
|
||||
node.name, node.node, node.popName,
|
||||
node.attributes.cloneAttributes(null)
|
||||
// [NOCPP[
|
||||
|
@ -6102,7 +5960,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
StackNode<T> node = stack[i];
|
||||
int listIndex = findInListOfActiveFormattingElements(node);
|
||||
if (listIndex == -1) {
|
||||
StackNode<T> newNode = createStackNode(node.getFlags(), node.ns,
|
||||
StackNode<T> newNode = new StackNode<T>(node.getFlags(), node.ns,
|
||||
node.name, node.node, node.popName,
|
||||
null
|
||||
// [NOCPP[
|
||||
|
@ -6118,7 +5976,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
int[] templateModeStackCopy = new int[templateModePtr + 1];
|
||||
System.arraycopy(templateModeStack, 0, templateModeStackCopy, 0,
|
||||
templateModeStackCopy.length);
|
||||
return new StateSnapshot<T>(this, stackCopy, listCopy, templateModeStackCopy, formPointer,
|
||||
return new StateSnapshot<T>(stackCopy, listCopy, templateModeStackCopy, formPointer,
|
||||
headPointer, deepTreeSurrogateParent, mode, originalMode, framesetOk,
|
||||
needToDropLF, quirks);
|
||||
}
|
||||
|
@ -6182,7 +6040,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
|
||||
for (int i = 0; i <= listPtr; i++) {
|
||||
if (listOfActiveFormattingElements[i] != null) {
|
||||
listOfActiveFormattingElements[i].release(this);
|
||||
listOfActiveFormattingElements[i].release();
|
||||
}
|
||||
}
|
||||
if (listOfActiveFormattingElements.length < listLen) {
|
||||
|
@ -6191,7 +6049,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
listPtr = listLen - 1;
|
||||
|
||||
for (int i = 0; i <= currentPtr; i++) {
|
||||
stack[i].release(this);
|
||||
stack[i].release();
|
||||
}
|
||||
if (stack.length < stackLen) {
|
||||
stack = new StackNode[stackLen];
|
||||
|
@ -6206,7 +6064,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
for (int i = 0; i < listLen; i++) {
|
||||
StackNode<T> node = listCopy[i];
|
||||
if (node != null) {
|
||||
StackNode<T> newNode = createStackNode(node.getFlags(), node.ns,
|
||||
StackNode<T> newNode = new StackNode<T>(node.getFlags(), node.ns,
|
||||
Portability.newLocalFromLocal(node.name, interner), node.node,
|
||||
Portability.newLocalFromLocal(node.popName, interner),
|
||||
node.attributes.cloneAttributes(null)
|
||||
|
@ -6223,7 +6081,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
StackNode<T> node = stackCopy[i];
|
||||
int listIndex = findInArray(node, listCopy);
|
||||
if (listIndex == -1) {
|
||||
StackNode<T> newNode = createStackNode(node.getFlags(), node.ns,
|
||||
StackNode<T> newNode = new StackNode<T>(node.getFlags(), node.ns,
|
||||
Portability.newLocalFromLocal(node.name, interner), node.node,
|
||||
Portability.newLocalFromLocal(node.popName, interner),
|
||||
null
|
||||
|
|
|
@ -86,101 +86,90 @@ nsHtml5StackNode::isHtmlIntegrationPoint()
|
|||
}
|
||||
|
||||
|
||||
nsHtml5StackNode::nsHtml5StackNode(int32_t idxInTreeBuilder)
|
||||
: idxInTreeBuilder(idxInTreeBuilder),
|
||||
refcount(0)
|
||||
nsHtml5StackNode::nsHtml5StackNode(int32_t flags, int32_t ns, nsIAtom* name, nsIContentHandle* node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes)
|
||||
: flags(flags),
|
||||
name(name),
|
||||
popName(popName),
|
||||
ns(ns),
|
||||
node(node),
|
||||
attributes(attributes),
|
||||
refcount(1)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsHtml5StackNode);
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5StackNode::setValues(int32_t flags, int32_t ns, nsIAtom* name, nsIContentHandle* node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes)
|
||||
{
|
||||
MOZ_ASSERT(isUnused());
|
||||
this->flags = flags;
|
||||
this->name = name;
|
||||
this->popName = popName;
|
||||
this->ns = ns;
|
||||
this->node = node;
|
||||
this->attributes = attributes;
|
||||
this->refcount = 1;
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
|
||||
nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName,
|
||||
nsIContentHandle* node)
|
||||
: flags(elementName->getFlags())
|
||||
, name(elementName->getName())
|
||||
, popName(elementName->getName())
|
||||
, ns(kNameSpaceID_XHTML)
|
||||
, node(node)
|
||||
, attributes(nullptr)
|
||||
, refcount(1)
|
||||
{
|
||||
MOZ_ASSERT(isUnused());
|
||||
this->flags = elementName->getFlags();
|
||||
this->name = elementName->getName();
|
||||
this->popName = elementName->getName();
|
||||
this->ns = kNameSpaceID_XHTML;
|
||||
this->node = node;
|
||||
this->attributes = nullptr;
|
||||
this->refcount = 1;
|
||||
MOZ_ASSERT(elementName->isInterned(), "Don't use this constructor for custom elements.");
|
||||
MOZ_COUNT_CTOR(nsHtml5StackNode);
|
||||
MOZ_ASSERT(elementName->isInterned(),
|
||||
"Don't use this constructor for custom elements.");
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
|
||||
nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName,
|
||||
nsIContentHandle* node,
|
||||
nsHtml5HtmlAttributes* attributes)
|
||||
: flags(elementName->getFlags())
|
||||
, name(elementName->getName())
|
||||
, popName(elementName->getName())
|
||||
, ns(kNameSpaceID_XHTML)
|
||||
, node(node)
|
||||
, attributes(attributes)
|
||||
, refcount(1)
|
||||
{
|
||||
MOZ_ASSERT(isUnused());
|
||||
this->flags = elementName->getFlags();
|
||||
this->name = elementName->getName();
|
||||
this->popName = elementName->getName();
|
||||
this->ns = kNameSpaceID_XHTML;
|
||||
this->node = node;
|
||||
this->attributes = attributes;
|
||||
this->refcount = 1;
|
||||
MOZ_ASSERT(elementName->isInterned(), "Don't use this constructor for custom elements.");
|
||||
MOZ_COUNT_CTOR(nsHtml5StackNode);
|
||||
MOZ_ASSERT(elementName->isInterned(),
|
||||
"Don't use this constructor for custom elements.");
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
|
||||
nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName,
|
||||
nsIContentHandle* node,
|
||||
nsIAtom* popName)
|
||||
: flags(elementName->getFlags())
|
||||
, name(elementName->getName())
|
||||
, popName(popName)
|
||||
, ns(kNameSpaceID_XHTML)
|
||||
, node(node)
|
||||
, attributes(nullptr)
|
||||
, refcount(1)
|
||||
{
|
||||
MOZ_ASSERT(isUnused());
|
||||
this->flags = elementName->getFlags();
|
||||
this->name = elementName->getName();
|
||||
this->popName = popName;
|
||||
this->ns = kNameSpaceID_XHTML;
|
||||
this->node = node;
|
||||
this->attributes = nullptr;
|
||||
this->refcount = 1;
|
||||
MOZ_COUNT_CTOR(nsHtml5StackNode);
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
|
||||
nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName,
|
||||
nsIAtom* popName,
|
||||
nsIContentHandle* node)
|
||||
: flags(prepareSvgFlags(elementName->getFlags()))
|
||||
, name(elementName->getName())
|
||||
, popName(popName)
|
||||
, ns(kNameSpaceID_SVG)
|
||||
, node(node)
|
||||
, attributes(nullptr)
|
||||
, refcount(1)
|
||||
{
|
||||
MOZ_ASSERT(isUnused());
|
||||
this->flags = prepareSvgFlags(elementName->getFlags());
|
||||
this->name = elementName->getName();
|
||||
this->popName = popName;
|
||||
this->ns = kNameSpaceID_SVG;
|
||||
this->node = node;
|
||||
this->attributes = nullptr;
|
||||
this->refcount = 1;
|
||||
MOZ_COUNT_CTOR(nsHtml5StackNode);
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
|
||||
nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName,
|
||||
nsIContentHandle* node,
|
||||
nsIAtom* popName,
|
||||
bool markAsIntegrationPoint)
|
||||
: flags(prepareMathFlags(elementName->getFlags(), markAsIntegrationPoint))
|
||||
, name(elementName->getName())
|
||||
, popName(popName)
|
||||
, ns(kNameSpaceID_MathML)
|
||||
, node(node)
|
||||
, attributes(nullptr)
|
||||
, refcount(1)
|
||||
{
|
||||
MOZ_ASSERT(isUnused());
|
||||
this->flags = prepareMathFlags(elementName->getFlags(), markAsIntegrationPoint);
|
||||
this->name = elementName->getName();
|
||||
this->popName = popName;
|
||||
this->ns = kNameSpaceID_MathML;
|
||||
this->node = node;
|
||||
this->attributes = nullptr;
|
||||
this->refcount = 1;
|
||||
MOZ_COUNT_CTOR(nsHtml5StackNode);
|
||||
}
|
||||
|
||||
int32_t
|
||||
|
@ -215,6 +204,7 @@ nsHtml5StackNode::prepareMathFlags(int32_t flags, bool markAsIntegrationPoint)
|
|||
nsHtml5StackNode::~nsHtml5StackNode()
|
||||
{
|
||||
MOZ_COUNT_DTOR(nsHtml5StackNode);
|
||||
delete attributes;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -230,22 +220,14 @@ nsHtml5StackNode::retain()
|
|||
}
|
||||
|
||||
void
|
||||
nsHtml5StackNode::release(nsHtml5TreeBuilder* owningTreeBuilder)
|
||||
nsHtml5StackNode::release()
|
||||
{
|
||||
refcount--;
|
||||
MOZ_ASSERT(refcount >= 0);
|
||||
if (!refcount) {
|
||||
delete attributes;
|
||||
owningTreeBuilder->notifyUnusedStackNode(idxInTreeBuilder);
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
nsHtml5StackNode::isUnused()
|
||||
{
|
||||
return !refcount;
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5StackNode::initializeStatics()
|
||||
{
|
||||
|
|
|
@ -60,7 +60,6 @@ class nsHtml5Portability;
|
|||
class nsHtml5StackNode
|
||||
{
|
||||
public:
|
||||
int32_t idxInTreeBuilder;
|
||||
int32_t flags;
|
||||
nsIAtom* name;
|
||||
nsIAtom* popName;
|
||||
|
@ -80,13 +79,12 @@ class nsHtml5StackNode
|
|||
bool isSpecial();
|
||||
bool isFosterParenting();
|
||||
bool isHtmlIntegrationPoint();
|
||||
explicit nsHtml5StackNode(int32_t idxInTreeBuilder);
|
||||
void setValues(int32_t flags, int32_t ns, nsIAtom* name, nsIContentHandle* node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes);
|
||||
void setValues(nsHtml5ElementName* elementName, nsIContentHandle* node);
|
||||
void setValues(nsHtml5ElementName* elementName, nsIContentHandle* node, nsHtml5HtmlAttributes* attributes);
|
||||
void setValues(nsHtml5ElementName* elementName, nsIContentHandle* node, nsIAtom* popName);
|
||||
void setValues(nsHtml5ElementName* elementName, nsIAtom* popName, nsIContentHandle* node);
|
||||
void setValues(nsHtml5ElementName* elementName, nsIContentHandle* node, nsIAtom* popName, bool markAsIntegrationPoint);
|
||||
nsHtml5StackNode(int32_t flags, int32_t ns, nsIAtom* name, nsIContentHandle* node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes);
|
||||
nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node);
|
||||
nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsHtml5HtmlAttributes* attributes);
|
||||
nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsIAtom* popName);
|
||||
nsHtml5StackNode(nsHtml5ElementName* elementName, nsIAtom* popName, nsIContentHandle* node);
|
||||
nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsIAtom* popName, bool markAsIntegrationPoint);
|
||||
private:
|
||||
static int32_t prepareSvgFlags(int32_t flags);
|
||||
static int32_t prepareMathFlags(int32_t flags, bool markAsIntegrationPoint);
|
||||
|
@ -94,8 +92,7 @@ class nsHtml5StackNode
|
|||
~nsHtml5StackNode();
|
||||
void dropAttributes();
|
||||
void retain();
|
||||
void release(nsHtml5TreeBuilder* owningTreeBuilder);
|
||||
bool isUnused();
|
||||
void release();
|
||||
static void initializeStatics();
|
||||
static void releaseStatics();
|
||||
};
|
||||
|
|
|
@ -55,9 +55,8 @@
|
|||
#include "nsHtml5StateSnapshot.h"
|
||||
|
||||
|
||||
nsHtml5StateSnapshot::nsHtml5StateSnapshot(nsHtml5TreeBuilder* treeBuilder, jArray<nsHtml5StackNode*,int32_t> stack, jArray<nsHtml5StackNode*,int32_t> listOfActiveFormattingElements, jArray<int32_t,int32_t> templateModeStack, nsIContentHandle* formPointer, nsIContentHandle* headPointer, nsIContentHandle* deepTreeSurrogateParent, int32_t mode, int32_t originalMode, bool framesetOk, bool needToDropLF, bool quirks)
|
||||
: treeBuilder(treeBuilder),
|
||||
stack(stack),
|
||||
nsHtml5StateSnapshot::nsHtml5StateSnapshot(jArray<nsHtml5StackNode*,int32_t> stack, jArray<nsHtml5StackNode*,int32_t> listOfActiveFormattingElements, jArray<int32_t,int32_t> templateModeStack, nsIContentHandle* formPointer, nsIContentHandle* headPointer, nsIContentHandle* deepTreeSurrogateParent, int32_t mode, int32_t originalMode, bool framesetOk, bool needToDropLF, bool quirks)
|
||||
: stack(stack),
|
||||
listOfActiveFormattingElements(listOfActiveFormattingElements),
|
||||
templateModeStack(templateModeStack),
|
||||
formPointer(formPointer),
|
||||
|
@ -161,11 +160,11 @@ nsHtml5StateSnapshot::~nsHtml5StateSnapshot()
|
|||
{
|
||||
MOZ_COUNT_DTOR(nsHtml5StateSnapshot);
|
||||
for (int32_t i = 0; i < stack.length; i++) {
|
||||
stack[i]->release(treeBuilder);
|
||||
stack[i]->release();
|
||||
}
|
||||
for (int32_t i = 0; i < listOfActiveFormattingElements.length; i++) {
|
||||
if (listOfActiveFormattingElements[i]) {
|
||||
listOfActiveFormattingElements[i]->release(treeBuilder);
|
||||
listOfActiveFormattingElements[i]->release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,6 @@ class nsHtml5Portability;
|
|||
class nsHtml5StateSnapshot : public nsAHtml5TreeBuilderState
|
||||
{
|
||||
private:
|
||||
nsHtml5TreeBuilder* treeBuilder;
|
||||
autoJArray<nsHtml5StackNode*,int32_t> stack;
|
||||
autoJArray<nsHtml5StackNode*,int32_t> listOfActiveFormattingElements;
|
||||
autoJArray<int32_t,int32_t> templateModeStack;
|
||||
|
@ -71,7 +70,7 @@ class nsHtml5StateSnapshot : public nsAHtml5TreeBuilderState
|
|||
bool needToDropLF;
|
||||
bool quirks;
|
||||
public:
|
||||
nsHtml5StateSnapshot(nsHtml5TreeBuilder* treeBuilder, jArray<nsHtml5StackNode*,int32_t> stack, jArray<nsHtml5StackNode*,int32_t> listOfActiveFormattingElements, jArray<int32_t,int32_t> templateModeStack, nsIContentHandle* formPointer, nsIContentHandle* headPointer, nsIContentHandle* deepTreeSurrogateParent, int32_t mode, int32_t originalMode, bool framesetOk, bool needToDropLF, bool quirks);
|
||||
nsHtml5StateSnapshot(jArray<nsHtml5StackNode*,int32_t> stack, jArray<nsHtml5StackNode*,int32_t> listOfActiveFormattingElements, jArray<int32_t,int32_t> templateModeStack, nsIContentHandle* formPointer, nsIContentHandle* headPointer, nsIContentHandle* deepTreeSurrogateParent, int32_t mode, int32_t originalMode, bool framesetOk, bool needToDropLF, bool quirks);
|
||||
jArray<nsHtml5StackNode*,int32_t> getStack();
|
||||
jArray<int32_t,int32_t> getTemplateModeStack();
|
||||
jArray<nsHtml5StackNode*,int32_t> getListOfActiveFormattingElements();
|
||||
|
|
|
@ -220,9 +220,6 @@ nsHtml5StreamParser::nsHtml5StreamParser(nsHtml5TreeOpExecutor* aExecutor,
|
|||
nsHtml5StreamParser::~nsHtml5StreamParser()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
// mSpeculations may contain StateSnapshot holding StackNodes that we
|
||||
// want to free when the tokenizer ends, so clear the speculations first.
|
||||
mSpeculations.Clear();
|
||||
mTokenizer->end();
|
||||
#ifdef DEBUG
|
||||
{
|
||||
|
|
|
@ -74,15 +74,12 @@ void
|
|||
nsHtml5TreeBuilder::startTokenization(nsHtml5Tokenizer* self)
|
||||
{
|
||||
tokenizer = self;
|
||||
stackNodes = jArray<nsHtml5StackNode*,int32_t>::newJArray(64);
|
||||
stack = jArray<nsHtml5StackNode*,int32_t>::newJArray(64);
|
||||
templateModeStack = jArray<int32_t,int32_t>::newJArray(64);
|
||||
listOfActiveFormattingElements = jArray<nsHtml5StackNode*,int32_t>::newJArray(64);
|
||||
needToDropLF = false;
|
||||
originalMode = INITIAL;
|
||||
templateModePtr = -1;
|
||||
stackNodesIdx = 0;
|
||||
numStackNodes = 0;
|
||||
currentPtr = -1;
|
||||
listPtr = -1;
|
||||
formPointer = nullptr;
|
||||
|
@ -106,7 +103,7 @@ nsHtml5TreeBuilder::startTokenization(nsHtml5Tokenizer* self)
|
|||
elementName = nsHtml5ElementName::ELT_FOREIGNOBJECT;
|
||||
}
|
||||
nsHtml5StackNode* node =
|
||||
createStackNode(elementName, elementName->getCamelCaseName(), elt);
|
||||
new nsHtml5StackNode(elementName, elementName->getCamelCaseName(), elt);
|
||||
currentPtr++;
|
||||
stack[currentPtr] = node;
|
||||
tokenizer->setStateAndEndTagExpectation(nsHtml5Tokenizer::DATA,
|
||||
|
@ -122,14 +119,14 @@ nsHtml5TreeBuilder::startTokenization(nsHtml5Tokenizer* self)
|
|||
elementName = nsHtml5ElementName::ELT_ANNOTATION_XML;
|
||||
}
|
||||
nsHtml5StackNode* node =
|
||||
createStackNode(elementName, elt, elementName->getName(), false);
|
||||
new nsHtml5StackNode(elementName, elt, elementName->getName(), false);
|
||||
currentPtr++;
|
||||
stack[currentPtr] = node;
|
||||
tokenizer->setStateAndEndTagExpectation(nsHtml5Tokenizer::DATA,
|
||||
contextName);
|
||||
mode = FRAMESET_OK;
|
||||
} else {
|
||||
nsHtml5StackNode* node = createStackNode(nsHtml5ElementName::ELT_HTML, elt);
|
||||
nsHtml5StackNode* node = new nsHtml5StackNode(nsHtml5ElementName::ELT_HTML, elt);
|
||||
currentPtr++;
|
||||
stack[currentPtr] = node;
|
||||
if (nsGkAtoms::_template == contextName) {
|
||||
|
@ -170,7 +167,7 @@ nsHtml5TreeBuilder::startTokenization(nsHtml5Tokenizer* self)
|
|||
tokenizer->emptyAttributes(),
|
||||
nullptr);
|
||||
nsHtml5StackNode* node =
|
||||
createStackNode(nsHtml5ElementName::ELT_SVG, nsGkAtoms::svg, elt);
|
||||
new nsHtml5StackNode(nsHtml5ElementName::ELT_SVG, nsGkAtoms::svg, elt);
|
||||
currentPtr++;
|
||||
stack[currentPtr] = node;
|
||||
}
|
||||
|
@ -611,7 +608,7 @@ nsHtml5TreeBuilder::endTokenization()
|
|||
templateModeStack = nullptr;
|
||||
if (stack) {
|
||||
while (currentPtr > -1) {
|
||||
stack[currentPtr]->release(this);
|
||||
stack[currentPtr]->release();
|
||||
currentPtr--;
|
||||
}
|
||||
stack = nullptr;
|
||||
|
@ -619,21 +616,12 @@ nsHtml5TreeBuilder::endTokenization()
|
|||
if (listOfActiveFormattingElements) {
|
||||
while (listPtr > -1) {
|
||||
if (listOfActiveFormattingElements[listPtr]) {
|
||||
listOfActiveFormattingElements[listPtr]->release(this);
|
||||
listOfActiveFormattingElements[listPtr]->release();
|
||||
}
|
||||
listPtr--;
|
||||
}
|
||||
listOfActiveFormattingElements = nullptr;
|
||||
}
|
||||
if (stackNodes) {
|
||||
for (int32_t i = 0; i < numStackNodes; i++) {
|
||||
MOZ_ASSERT(stackNodes[i]->isUnused());
|
||||
delete stackNodes[i];
|
||||
}
|
||||
numStackNodes = 0;
|
||||
stackNodesIdx = 0;
|
||||
stackNodes = nullptr;
|
||||
}
|
||||
charBuffer = nullptr;
|
||||
end();
|
||||
}
|
||||
|
@ -1193,7 +1181,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
|
|||
if (activeAPos != -1) {
|
||||
removeFromListOfActiveFormattingElements(activeAPos);
|
||||
}
|
||||
activeA->release(this);
|
||||
activeA->release();
|
||||
}
|
||||
reconstructTheActiveFormattingElements();
|
||||
appendToCurrentNodeAndPushFormattingElementMayFoster(elementName, attributes);
|
||||
|
@ -3603,7 +3591,7 @@ nsHtml5TreeBuilder::clearTheListOfActiveFormattingElementsUpToTheLastMarker()
|
|||
--listPtr;
|
||||
return;
|
||||
}
|
||||
listOfActiveFormattingElements[listPtr]->release(this);
|
||||
listOfActiveFormattingElements[listPtr]->release();
|
||||
--listPtr;
|
||||
}
|
||||
}
|
||||
|
@ -3615,7 +3603,7 @@ nsHtml5TreeBuilder::removeFromStack(int32_t pos)
|
|||
pop();
|
||||
} else {
|
||||
|
||||
stack[pos]->release(this);
|
||||
stack[pos]->release();
|
||||
nsHtml5ArrayCopy::arraycopy(stack, pos + 1, pos, currentPtr - pos);
|
||||
MOZ_ASSERT(debugOnlyClearLastStackSlot());
|
||||
currentPtr--;
|
||||
|
@ -3636,7 +3624,7 @@ nsHtml5TreeBuilder::removeFromStack(nsHtml5StackNode* node)
|
|||
return;
|
||||
}
|
||||
|
||||
node->release(this);
|
||||
node->release();
|
||||
nsHtml5ArrayCopy::arraycopy(stack, pos + 1, pos, currentPtr - pos);
|
||||
currentPtr--;
|
||||
}
|
||||
|
@ -3646,7 +3634,7 @@ void
|
|||
nsHtml5TreeBuilder::removeFromListOfActiveFormattingElements(int32_t pos)
|
||||
{
|
||||
MOZ_ASSERT(!!listOfActiveFormattingElements[pos]);
|
||||
listOfActiveFormattingElements[pos]->release(this);
|
||||
listOfActiveFormattingElements[pos]->release();
|
||||
if (pos == listPtr) {
|
||||
MOZ_ASSERT(debugOnlyClearLastListSlot());
|
||||
listPtr--;
|
||||
|
@ -3758,13 +3746,13 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag(nsIAtom* name)
|
|||
MOZ_ASSERT(node == listOfActiveFormattingElements[nodeListPos]);
|
||||
MOZ_ASSERT(node == stack[nodePos]);
|
||||
nsIContentHandle* clone = createElement(kNameSpaceID_XHTML, node->name, node->attributes->cloneAttributes(nullptr), commonAncestor->node);
|
||||
nsHtml5StackNode* newNode = createStackNode(node->getFlags(), node->ns, node->name, clone, node->popName, node->attributes);
|
||||
nsHtml5StackNode* newNode = new nsHtml5StackNode(node->getFlags(), node->ns, node->name, clone, node->popName, node->attributes);
|
||||
node->dropAttributes();
|
||||
stack[nodePos] = newNode;
|
||||
newNode->retain();
|
||||
listOfActiveFormattingElements[nodeListPos] = newNode;
|
||||
node->release(this);
|
||||
node->release(this);
|
||||
node->release();
|
||||
node->release();
|
||||
node = newNode;
|
||||
detachFromParent(lastNode->node);
|
||||
appendElement(lastNode->node, node->node);
|
||||
|
@ -3779,7 +3767,7 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag(nsIAtom* name)
|
|||
appendElement(lastNode->node, commonAncestor->node);
|
||||
}
|
||||
nsIContentHandle* clone = createElement(kNameSpaceID_XHTML, formattingElt->name, formattingElt->attributes->cloneAttributes(nullptr), furthestBlock->node);
|
||||
nsHtml5StackNode* formattingClone = createStackNode(formattingElt->getFlags(), formattingElt->ns, formattingElt->name, clone, formattingElt->popName, formattingElt->attributes);
|
||||
nsHtml5StackNode* formattingClone = new nsHtml5StackNode(formattingElt->getFlags(), formattingElt->ns, formattingElt->name, clone, formattingElt->popName, formattingElt->attributes);
|
||||
formattingElt->dropAttributes();
|
||||
appendChildrenToNewParent(furthestBlock->node, clone);
|
||||
appendElement(clone, furthestBlock->node);
|
||||
|
@ -3910,7 +3898,7 @@ nsHtml5TreeBuilder::pushHeadPointerOntoStack()
|
|||
MOZ_ASSERT(!!headPointer);
|
||||
MOZ_ASSERT(mode == AFTER_HEAD);
|
||||
|
||||
silentPush(createStackNode(nsHtml5ElementName::ELT_HEAD, headPointer));
|
||||
silentPush(new nsHtml5StackNode(nsHtml5ElementName::ELT_HEAD, headPointer));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3947,93 +3935,15 @@ nsHtml5TreeBuilder::reconstructTheActiveFormattingElements()
|
|||
clone = createElement(kNameSpaceID_XHTML, entry->name, entry->attributes->cloneAttributes(nullptr), currentNode->node);
|
||||
appendElement(clone, currentNode->node);
|
||||
}
|
||||
nsHtml5StackNode* entryClone = createStackNode(entry->getFlags(), entry->ns, entry->name, clone, entry->popName, entry->attributes);
|
||||
nsHtml5StackNode* entryClone = new nsHtml5StackNode(entry->getFlags(), entry->ns, entry->name, clone, entry->popName, entry->attributes);
|
||||
entry->dropAttributes();
|
||||
push(entryClone);
|
||||
listOfActiveFormattingElements[entryPos] = entryClone;
|
||||
entry->release(this);
|
||||
entry->release();
|
||||
entryClone->retain();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::notifyUnusedStackNode(int32_t idxInStackNodes)
|
||||
{
|
||||
if (idxInStackNodes < stackNodesIdx) {
|
||||
stackNodesIdx = idxInStackNodes;
|
||||
}
|
||||
}
|
||||
|
||||
nsHtml5StackNode*
|
||||
nsHtml5TreeBuilder::getUnusedStackNode()
|
||||
{
|
||||
while (stackNodesIdx < numStackNodes) {
|
||||
if (stackNodes[stackNodesIdx]->isUnused()) {
|
||||
return stackNodes[stackNodesIdx++];
|
||||
}
|
||||
stackNodesIdx++;
|
||||
}
|
||||
if (stackNodesIdx < stackNodes.length) {
|
||||
stackNodes[stackNodesIdx] = new nsHtml5StackNode(stackNodesIdx);
|
||||
numStackNodes++;
|
||||
return stackNodes[stackNodesIdx++];
|
||||
}
|
||||
jArray<nsHtml5StackNode*,int32_t> newStack = jArray<nsHtml5StackNode*,int32_t>::newJArray(stackNodes.length + 64);
|
||||
nsHtml5ArrayCopy::arraycopy(stackNodes, newStack, stackNodes.length);
|
||||
stackNodes = newStack;
|
||||
stackNodes[stackNodesIdx] = new nsHtml5StackNode(stackNodesIdx);
|
||||
numStackNodes++;
|
||||
return stackNodes[stackNodesIdx++];
|
||||
}
|
||||
|
||||
nsHtml5StackNode*
|
||||
nsHtml5TreeBuilder::createStackNode(int32_t flags, int32_t ns, nsIAtom* name, nsIContentHandle* node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes)
|
||||
{
|
||||
nsHtml5StackNode* instance = getUnusedStackNode();
|
||||
instance->setValues(flags, ns, name, node, popName, attributes);
|
||||
return instance;
|
||||
}
|
||||
|
||||
nsHtml5StackNode*
|
||||
nsHtml5TreeBuilder::createStackNode(nsHtml5ElementName* elementName, nsIContentHandle* node)
|
||||
{
|
||||
nsHtml5StackNode* instance = getUnusedStackNode();
|
||||
instance->setValues(elementName, node);
|
||||
return instance;
|
||||
}
|
||||
|
||||
nsHtml5StackNode*
|
||||
nsHtml5TreeBuilder::createStackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsHtml5HtmlAttributes* attributes)
|
||||
{
|
||||
nsHtml5StackNode* instance = getUnusedStackNode();
|
||||
instance->setValues(elementName, node, attributes);
|
||||
return instance;
|
||||
}
|
||||
|
||||
nsHtml5StackNode*
|
||||
nsHtml5TreeBuilder::createStackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsIAtom* popName)
|
||||
{
|
||||
nsHtml5StackNode* instance = getUnusedStackNode();
|
||||
instance->setValues(elementName, node, popName);
|
||||
return instance;
|
||||
}
|
||||
|
||||
nsHtml5StackNode*
|
||||
nsHtml5TreeBuilder::createStackNode(nsHtml5ElementName* elementName, nsIAtom* popName, nsIContentHandle* node)
|
||||
{
|
||||
nsHtml5StackNode* instance = getUnusedStackNode();
|
||||
instance->setValues(elementName, popName, node);
|
||||
return instance;
|
||||
}
|
||||
|
||||
nsHtml5StackNode*
|
||||
nsHtml5TreeBuilder::createStackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsIAtom* popName, bool markAsIntegrationPoint)
|
||||
{
|
||||
nsHtml5StackNode* instance = getUnusedStackNode();
|
||||
instance->setValues(elementName, node, popName, markAsIntegrationPoint);
|
||||
return instance;
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::insertIntoFosterParent(nsIContentHandle* child)
|
||||
{
|
||||
|
@ -4091,7 +4001,7 @@ nsHtml5TreeBuilder::pop()
|
|||
MOZ_ASSERT(debugOnlyClearLastStackSlot());
|
||||
currentPtr--;
|
||||
elementPopped(node->ns, node->popName, node->node);
|
||||
node->release(this);
|
||||
node->release();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -4100,7 +4010,7 @@ nsHtml5TreeBuilder::silentPop()
|
|||
nsHtml5StackNode* node = stack[currentPtr];
|
||||
MOZ_ASSERT(debugOnlyClearLastStackSlot());
|
||||
currentPtr--;
|
||||
node->release(this);
|
||||
node->release();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -4111,14 +4021,14 @@ nsHtml5TreeBuilder::popOnEof()
|
|||
currentPtr--;
|
||||
markMalformedIfScript(node->node);
|
||||
elementPopped(node->ns, node->popName, node->node);
|
||||
node->release(this);
|
||||
node->release();
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::appendHtmlElementToDocumentAndPush(nsHtml5HtmlAttributes* attributes)
|
||||
{
|
||||
nsIContentHandle* elt = createHtmlElementSetAsRoot(attributes);
|
||||
nsHtml5StackNode* node = createStackNode(nsHtml5ElementName::ELT_HTML, elt);
|
||||
nsHtml5StackNode* node = new nsHtml5StackNode(nsHtml5ElementName::ELT_HTML, elt);
|
||||
push(node);
|
||||
}
|
||||
|
||||
|
@ -4136,7 +4046,7 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushHeadElement(nsHtml5HtmlAttributes*
|
|||
createElement(kNameSpaceID_XHTML, nsGkAtoms::head, attributes, currentNode);
|
||||
appendElement(elt, currentNode);
|
||||
headPointer = elt;
|
||||
nsHtml5StackNode* node = createStackNode(nsHtml5ElementName::ELT_HEAD, elt);
|
||||
nsHtml5StackNode* node = new nsHtml5StackNode(nsHtml5ElementName::ELT_HEAD, elt);
|
||||
push(node);
|
||||
}
|
||||
|
||||
|
@ -4169,7 +4079,7 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushFormElementMayFoster(nsHtml5HtmlAt
|
|||
if (!isTemplateContents()) {
|
||||
formPointer = elt;
|
||||
}
|
||||
nsHtml5StackNode* node = createStackNode(nsHtml5ElementName::ELT_FORM, elt);
|
||||
nsHtml5StackNode* node = new nsHtml5StackNode(nsHtml5ElementName::ELT_FORM, elt);
|
||||
push(node);
|
||||
}
|
||||
|
||||
|
@ -4188,7 +4098,7 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushFormattingElementMayFoster(nsHtml5
|
|||
kNameSpaceID_XHTML, elementName->getName(), attributes, current->node);
|
||||
appendElement(elt, current->node);
|
||||
}
|
||||
nsHtml5StackNode* node = createStackNode(elementName, elt, clone);
|
||||
nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elt, clone);
|
||||
push(node);
|
||||
append(node);
|
||||
node->retain();
|
||||
|
@ -4204,7 +4114,7 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushElement(nsHtml5ElementName* elemen
|
|||
if (nsHtml5ElementName::ELT_TEMPLATE == elementName) {
|
||||
elt = getDocumentFragmentForTemplate(elt);
|
||||
}
|
||||
nsHtml5StackNode* node = createStackNode(elementName, elt);
|
||||
nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elt);
|
||||
push(node);
|
||||
}
|
||||
|
||||
|
@ -4221,7 +4131,7 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementNam
|
|||
elt = createElement(kNameSpaceID_XHTML, popName, attributes, current->node);
|
||||
appendElement(elt, current->node);
|
||||
}
|
||||
nsHtml5StackNode* node = createStackNode(elementName, elt, popName);
|
||||
nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elt, popName);
|
||||
push(node);
|
||||
}
|
||||
|
||||
|
@ -4242,7 +4152,7 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterMathML(nsHtml5Elem
|
|||
elt = createElement(kNameSpaceID_MathML, popName, attributes, current->node);
|
||||
appendElement(elt, current->node);
|
||||
}
|
||||
nsHtml5StackNode* node = createStackNode(elementName, elt, popName, markAsHtmlIntegrationPoint);
|
||||
nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elt, popName, markAsHtmlIntegrationPoint);
|
||||
push(node);
|
||||
}
|
||||
|
||||
|
@ -4270,7 +4180,7 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterSVG(nsHtml5Element
|
|||
elt = createElement(kNameSpaceID_SVG, popName, attributes, current->node);
|
||||
appendElement(elt, current->node);
|
||||
}
|
||||
nsHtml5StackNode* node = createStackNode(elementName, popName, elt);
|
||||
nsHtml5StackNode* node = new nsHtml5StackNode(elementName, popName, elt);
|
||||
push(node);
|
||||
}
|
||||
|
||||
|
@ -4292,7 +4202,7 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementNam
|
|||
current->node);
|
||||
appendElement(elt, current->node);
|
||||
}
|
||||
nsHtml5StackNode* node = createStackNode(elementName, elt);
|
||||
nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elt);
|
||||
push(node);
|
||||
}
|
||||
|
||||
|
@ -4498,7 +4408,7 @@ nsHtml5TreeBuilder::newSnapshot()
|
|||
for (int32_t i = 0; i < listCopy.length; i++) {
|
||||
nsHtml5StackNode* node = listOfActiveFormattingElements[i];
|
||||
if (node) {
|
||||
nsHtml5StackNode* newNode = createStackNode(node->getFlags(), node->ns, node->name, node->node, node->popName, node->attributes->cloneAttributes(nullptr));
|
||||
nsHtml5StackNode* newNode = new nsHtml5StackNode(node->getFlags(), node->ns, node->name, node->node, node->popName, node->attributes->cloneAttributes(nullptr));
|
||||
listCopy[i] = newNode;
|
||||
} else {
|
||||
listCopy[i] = nullptr;
|
||||
|
@ -4509,7 +4419,7 @@ nsHtml5TreeBuilder::newSnapshot()
|
|||
nsHtml5StackNode* node = stack[i];
|
||||
int32_t listIndex = findInListOfActiveFormattingElements(node);
|
||||
if (listIndex == -1) {
|
||||
nsHtml5StackNode* newNode = createStackNode(node->getFlags(), node->ns, node->name, node->node, node->popName, nullptr);
|
||||
nsHtml5StackNode* newNode = new nsHtml5StackNode(node->getFlags(), node->ns, node->name, node->node, node->popName, nullptr);
|
||||
stackCopy[i] = newNode;
|
||||
} else {
|
||||
stackCopy[i] = listCopy[listIndex];
|
||||
|
@ -4518,7 +4428,7 @@ nsHtml5TreeBuilder::newSnapshot()
|
|||
}
|
||||
jArray<int32_t,int32_t> templateModeStackCopy = jArray<int32_t,int32_t>::newJArray(templateModePtr + 1);
|
||||
nsHtml5ArrayCopy::arraycopy(templateModeStack, templateModeStackCopy, templateModeStackCopy.length);
|
||||
return new nsHtml5StateSnapshot(this, stackCopy, listCopy, templateModeStackCopy, formPointer, headPointer, deepTreeSurrogateParent, mode, originalMode, framesetOk, needToDropLF, quirks);
|
||||
return new nsHtml5StateSnapshot(stackCopy, listCopy, templateModeStackCopy, formPointer, headPointer, deepTreeSurrogateParent, mode, originalMode, framesetOk, needToDropLF, quirks);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -4567,7 +4477,7 @@ nsHtml5TreeBuilder::loadState(nsAHtml5TreeBuilderState* snapshot, nsHtml5AtomTab
|
|||
int32_t templateModeStackLen = snapshot->getTemplateModeStackLength();
|
||||
for (int32_t i = 0; i <= listPtr; i++) {
|
||||
if (listOfActiveFormattingElements[i]) {
|
||||
listOfActiveFormattingElements[i]->release(this);
|
||||
listOfActiveFormattingElements[i]->release();
|
||||
}
|
||||
}
|
||||
if (listOfActiveFormattingElements.length < listLen) {
|
||||
|
@ -4575,7 +4485,7 @@ nsHtml5TreeBuilder::loadState(nsAHtml5TreeBuilderState* snapshot, nsHtml5AtomTab
|
|||
}
|
||||
listPtr = listLen - 1;
|
||||
for (int32_t i = 0; i <= currentPtr; i++) {
|
||||
stack[i]->release(this);
|
||||
stack[i]->release();
|
||||
}
|
||||
if (stack.length < stackLen) {
|
||||
stack = jArray<nsHtml5StackNode*,int32_t>::newJArray(stackLen);
|
||||
|
@ -4588,7 +4498,7 @@ nsHtml5TreeBuilder::loadState(nsAHtml5TreeBuilderState* snapshot, nsHtml5AtomTab
|
|||
for (int32_t i = 0; i < listLen; i++) {
|
||||
nsHtml5StackNode* node = listCopy[i];
|
||||
if (node) {
|
||||
nsHtml5StackNode* newNode = createStackNode(node->getFlags(), node->ns, nsHtml5Portability::newLocalFromLocal(node->name, interner), node->node, nsHtml5Portability::newLocalFromLocal(node->popName, interner), node->attributes->cloneAttributes(nullptr));
|
||||
nsHtml5StackNode* newNode = new nsHtml5StackNode(node->getFlags(), node->ns, nsHtml5Portability::newLocalFromLocal(node->name, interner), node->node, nsHtml5Portability::newLocalFromLocal(node->popName, interner), node->attributes->cloneAttributes(nullptr));
|
||||
listOfActiveFormattingElements[i] = newNode;
|
||||
} else {
|
||||
listOfActiveFormattingElements[i] = nullptr;
|
||||
|
@ -4598,7 +4508,7 @@ nsHtml5TreeBuilder::loadState(nsAHtml5TreeBuilderState* snapshot, nsHtml5AtomTab
|
|||
nsHtml5StackNode* node = stackCopy[i];
|
||||
int32_t listIndex = findInArray(node, listCopy);
|
||||
if (listIndex == -1) {
|
||||
nsHtml5StackNode* newNode = createStackNode(node->getFlags(), node->ns, nsHtml5Portability::newLocalFromLocal(node->name, interner), node->node, nsHtml5Portability::newLocalFromLocal(node->popName, interner), nullptr);
|
||||
nsHtml5StackNode* newNode = new nsHtml5StackNode(node->getFlags(), node->ns, nsHtml5Portability::newLocalFromLocal(node->name, interner), node->node, nsHtml5Portability::newLocalFromLocal(node->popName, interner), nullptr);
|
||||
stack[i] = newNode;
|
||||
} else {
|
||||
stack[i] = listOfActiveFormattingElements[listIndex];
|
||||
|
|
|
@ -301,9 +301,6 @@ 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;
|
||||
|
@ -404,16 +401,6 @@ 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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче