Backed out changeset 0ce8d073a16e (bug 256180)

This commit is contained in:
Sebastian Hengst 2017-09-28 11:30:33 +02:00
Родитель 4deddf3e9d
Коммит 5573e8270f
19 изменённых файлов: 208 добавлений и 6405 удалений

Просмотреть файл

@ -83,7 +83,6 @@ errNoSpaceBetweenPublicAndSystemIds=No space between the doctype public and syst
errNoSpaceBetweenDoctypePublicKeywordAndQuote=No space between the doctype “PUBLIC” keyword and the quote.
# Tree builder errors
errDeepTree=The document tree is too deep. The tree will be flattened to be 513 elements deep.
errStrayStartTag2=Stray start tag “%1$S”.
errStrayEndTag=Stray end tag “%1$S”.
errUnclosedElements=End tag “%1$S” seen, but there were open elements.

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -53,8 +53,6 @@ skip-if(isDebugBuild||Android||AddressSanitizer||(winWidget&&(!is64Bit))) == 256
# Debug builds have larger stack frames, so skipped.
# Making Android on aarch64 not crash is bug 1400811.
skip-if(isDebugBuild||(Android&&is64Bit)) == 256180-4.html 256180-4-ref.html
skip-if(isDebugBuild||(Android&&is64Bit)) == 256180-5.html 256180-5-ref.html
skip-if(isDebugBuild||(Android&&is64Bit)) == 256180-6.html 256180-6-ref.html
== 25888-1l.html 25888-1l-ref.html
!= 25888-1l.html 25888-1l-notref.html
== 25888-1r.html 25888-1r-ref.html

Просмотреть файл

@ -1,22 +1,22 @@
/*
* Copyright (c) 2009-2010 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
@ -37,10 +37,12 @@ public class StateSnapshot<T> implements TreeBuilderState<T> {
private final T headPointer;
private final T deepTreeSurrogateParent;
private final int mode;
private final int originalMode;
private final boolean framesetOk;
private final boolean needToDropLF;
@ -53,6 +55,7 @@ public class StateSnapshot<T> implements TreeBuilderState<T> {
* @param templateModeStack
* @param formPointer
* @param headPointer
* @param deepTreeSurrogateParent
* @param mode
* @param originalMode
* @param framesetOk
@ -61,20 +64,21 @@ public class StateSnapshot<T> implements TreeBuilderState<T> {
*/
StateSnapshot(StackNode<T>[] stack,
StackNode<T>[] listOfActiveFormattingElements, int[] templateModeStack, T formPointer,
T headPointer, int mode, int originalMode,
T headPointer, T deepTreeSurrogateParent, int mode, int originalMode,
boolean framesetOk, boolean needToDropLF, boolean quirks) {
this.stack = stack;
this.listOfActiveFormattingElements = listOfActiveFormattingElements;
this.templateModeStack = templateModeStack;
this.formPointer = formPointer;
this.headPointer = headPointer;
this.deepTreeSurrogateParent = deepTreeSurrogateParent;
this.mode = mode;
this.originalMode = originalMode;
this.framesetOk = framesetOk;
this.needToDropLF = needToDropLF;
this.quirks = quirks;
}
/**
* @see nu.validator.htmlparser.impl.TreeBuilderState#getStack()
*/
@ -105,16 +109,25 @@ public class StateSnapshot<T> implements TreeBuilderState<T> {
/**
* Returns the headPointer.
*
*
* @return the headPointer
*/
public T getHeadPointer() {
return headPointer;
}
/**
* Returns the deepTreeSurrogateParent.
*
* @return the deepTreeSurrogateParent
*/
public T getDeepTreeSurrogateParent() {
return deepTreeSurrogateParent;
}
/**
* Returns the mode.
*
*
* @return the mode
*/
public int getMode() {
@ -123,7 +136,7 @@ public class StateSnapshot<T> implements TreeBuilderState<T> {
/**
* Returns the originalMode.
*
*
* @return the originalMode
*/
public int getOriginalMode() {
@ -132,7 +145,7 @@ public class StateSnapshot<T> implements TreeBuilderState<T> {
/**
* Returns the framesetOk.
*
*
* @return the framesetOk
*/
public boolean isFramesetOk() {
@ -141,7 +154,7 @@ public class StateSnapshot<T> implements TreeBuilderState<T> {
/**
* Returns the needToDropLF.
*
*
* @return the needToDropLF
*/
public boolean isNeedToDropLF() {
@ -150,13 +163,13 @@ public class StateSnapshot<T> implements TreeBuilderState<T> {
/**
* Returns the quirks.
*
*
* @return the quirks
*/
public boolean isQuirks() {
return quirks;
}
/**
* @see nu.validator.htmlparser.impl.TreeBuilderState#getListOfActiveFormattingElementsLength()
*/

Просмотреть файл

@ -444,6 +444,11 @@ public abstract class TreeBuilder<T> implements TokenHandler,
private T headPointer;
/**
* Used to work around Gecko limitations. Not used in Java.
*/
private T deepTreeSurrogateParent;
protected @Auto char[] charBuffer;
protected int charBufferLen = 0;
@ -610,6 +615,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
listPtr = -1;
formPointer = null;
headPointer = null;
deepTreeSurrogateParent = null;
// [NOCPP[
html4 = false;
idLocations.clear();
@ -1636,6 +1642,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
public final void endTokenization() throws SAXException {
formPointer = null;
headPointer = null;
deepTreeSurrogateParent = null;
templateModeStack = null;
if (stack != null) {
while (currentPtr > -1) {
@ -4711,11 +4718,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
removeFromListOfActiveFormattingElements(formattingEltListPos);
return true;
}
// commonAncestor is used for running the algorithm and
// insertionCommonAncestor is used for the actual insertions to
// keep them depth-limited.
StackNode<T> commonAncestor = stack[formattingEltStackPos - 1]; // weak ref
T insertionCommonAncestor = nodeFromStackWithBlinkCompat(formattingEltStackPos - 1); // weak ref
StackNode<T> furthestBlock = stack[furthestBlockPos]; // weak ref
// detachFromParent(furthestBlock.node); XXX AAA CHANGE
int bookmark = formattingEltListPos;
@ -4763,7 +4766,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
assert node == listOfActiveFormattingElements[nodeListPos];
assert node == stack[nodePos];
T clone = createElement("http://www.w3.org/1999/xhtml",
node.name, node.attributes.cloneAttributes(null), insertionCommonAncestor
node.name, node.attributes.cloneAttributes(null), commonAncestor.node
// CPPONLY: , htmlCreator(node.getHtmlCreator())
);
StackNode<T> newNode = createStackNode(node.getFlags(), node.ns,
@ -4782,18 +4785,16 @@ public abstract class TreeBuilder<T> implements TokenHandler,
node = newNode;
// } XXX AAA CHANGE
detachFromParent(lastNode.node);
appendElement(lastNode.node, nodeFromStackWithBlinkCompat(nodePos));
appendElement(lastNode.node, node.node);
lastNode = node;
}
// If we insert into a foster parent, for simplicity, we insert
// accoding to the spec without Blink's depth limit.
if (commonAncestor.isFosterParenting()) {
fatal();
detachFromParent(lastNode.node);
insertIntoFosterParent(lastNode.node);
} else {
detachFromParent(lastNode.node);
appendElement(lastNode.node, insertionCommonAncestor);
appendElement(lastNode.node, commonAncestor.node);
}
T clone = createElement("http://www.w3.org/1999/xhtml",
formattingElt.name,
@ -4979,21 +4980,20 @@ public abstract class TreeBuilder<T> implements TokenHandler,
while (entryPos < listPtr) {
entryPos++;
StackNode<T> entry = listOfActiveFormattingElements[entryPos];
StackNode<T> current = stack[currentPtr];
StackNode<T> currentNode = stack[currentPtr];
T clone;
if (current.isFosterParenting()) {
if (currentNode.isFosterParenting()) {
clone = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", entry.name,
entry.attributes.cloneAttributes(null)
// CPPONLY: , htmlCreator(entry.getHtmlCreator())
);
} else {
T currentNode = nodeFromStackWithBlinkCompat(currentPtr);
clone = createElement("http://www.w3.org/1999/xhtml", entry.name,
entry.attributes.cloneAttributes(null), currentNode
entry.attributes.cloneAttributes(null), currentNode.node
// CPPONLY: , htmlCreator(entry.getHtmlCreator())
);
appendElement(clone, currentNode);
appendElement(clone, currentNode.node);
}
StackNode<T> entryClone = createStackNode(entry.getFlags(),
@ -5336,7 +5336,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// [NOCPP[
checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
// ]NOCPP]
T currentNode = nodeFromStackWithBlinkCompat(currentPtr);
T currentNode = stack[currentPtr].node;
T elt = createElement("http://www.w3.org/1999/xhtml", "head", attributes, currentNode
/*
* head uses NS_NewHTMLSharedElement creator
@ -5378,11 +5378,10 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// CPPONLY: , htmlCreator(NS_NewHTMLFormElement)
);
} else {
T currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement("http://www.w3.org/1999/xhtml", "form", attributes, currentNode
elt = createElement("http://www.w3.org/1999/xhtml", "form", attributes, current.node
// CPPONLY: , htmlCreator(NS_NewHTMLFormElement)
);
appendElement(elt, currentNode);
appendElement(elt, current.node);
}
if (!isTemplateContents()) {
@ -5416,11 +5415,10 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
} else {
T currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement("http://www.w3.org/1999/xhtml", elementName.getName(), attributes, currentNode
elt = createElement("http://www.w3.org/1999/xhtml", elementName.getName(), attributes, current.node
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
appendElement(elt, currentNode);
appendElement(elt, current.node);
}
StackNode<T> node = createStackNode(elementName, elt, clone
// [NOCPP[
@ -5439,7 +5437,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
// ]NOCPP]
// This method can't be called for custom elements
T currentNode = nodeFromStackWithBlinkCompat(currentPtr);
T currentNode = stack[currentPtr].node;
T elt = createElement("http://www.w3.org/1999/xhtml", elementName.getName(), attributes, currentNode
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
@ -5473,11 +5471,10 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
} else {
T currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes, currentNode
elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes, current.node
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
appendElement(elt, currentNode);
appendElement(elt, current.node);
}
StackNode<T> node = createStackNode(elementName, elt, popName
// [NOCPP[
@ -5512,11 +5509,10 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// CPPONLY: , htmlCreator(null)
);
} else {
T currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement("http://www.w3.org/1998/Math/MathML", popName, attributes, currentNode
elt = createElement("http://www.w3.org/1998/Math/MathML", popName, attributes, current.node
// CPPONLY: , htmlCreator(null)
);
appendElement(elt, currentNode);
appendElement(elt, current.node);
}
StackNode<T> node = createStackNode(elementName, elt, popName,
markAsHtmlIntegrationPoint
@ -5566,11 +5562,10 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// CPPONLY: , svgCreator(elementName.getSvgCreator())
);
} else {
T currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement("http://www.w3.org/2000/svg", popName, attributes, currentNode
elt = createElement("http://www.w3.org/2000/svg", popName, attributes, current.node
// CPPONLY: , svgCreator(elementName.getSvgCreator())
);
appendElement(elt, currentNode);
appendElement(elt, current.node);
}
StackNode<T> node = createStackNode(elementName, popName, elt
// [NOCPP[
@ -5597,12 +5592,11 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
} else {
T currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement("http://www.w3.org/1999/xhtml", elementName.getName(),
attributes, formOwner, currentNode
attributes, formOwner, current.node
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
appendElement(elt, currentNode);
appendElement(elt, current.node);
}
StackNode<T> node = createStackNode(elementName, elt
// [NOCPP[
@ -5629,12 +5623,11 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
} else {
T currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement("http://www.w3.org/1999/xhtml", name,
attributes, formOwner, currentNode
attributes, formOwner, current.node
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
appendElement(elt, currentNode);
appendElement(elt, current.node);
}
elementPushed("http://www.w3.org/1999/xhtml", name, elt);
elementPopped("http://www.w3.org/1999/xhtml", name, elt);
@ -5658,11 +5651,10 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
} else {
T currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes, currentNode
elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes, current.node
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
appendElement(elt, currentNode);
appendElement(elt, current.node);
}
elementPushed("http://www.w3.org/1999/xhtml", popName, elt);
elementPopped("http://www.w3.org/1999/xhtml", popName, elt);
@ -5686,11 +5678,10 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// CPPONLY: , svgCreator(elementName.getSvgCreator())
);
} else {
T currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement("http://www.w3.org/2000/svg", popName, attributes, currentNode
elt = createElement("http://www.w3.org/2000/svg", popName, attributes, current.node
// CPPONLY: , svgCreator(elementName.getSvgCreator())
);
appendElement(elt, currentNode);
appendElement(elt, current.node);
}
elementPushed("http://www.w3.org/2000/svg", popName, elt);
elementPopped("http://www.w3.org/2000/svg", popName, elt);
@ -5714,11 +5705,10 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// CPPONLY: , htmlCreator(null)
);
} else {
T currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement("http://www.w3.org/1998/Math/MathML", popName, attributes, currentNode
elt = createElement("http://www.w3.org/1998/Math/MathML", popName, attributes, current.node
// CPPONLY: , htmlCreator(null)
);
appendElement(elt, currentNode);
appendElement(elt, current.node);
}
elementPushed("http://www.w3.org/1998/Math/MathML", popName, elt);
elementPopped("http://www.w3.org/1998/Math/MathML", popName, elt);
@ -5729,7 +5719,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
// ]NOCPP]
// Can't be called for custom elements
T currentNode = nodeFromStackWithBlinkCompat(currentPtr);
T currentNode = stack[currentPtr].node;
T elt = createElement("http://www.w3.org/1999/xhtml", "input", attributes,
form == null || fragment || isTemplateContents() ? null : form, currentNode
// CPPONLY: , htmlCreator(NS_NewHTMLInputElement)
@ -5743,7 +5733,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// [NOCPP[
checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
// ]NOCPP]
T currentNode = nodeFromStackWithBlinkCompat(currentPtr);
T currentNode = stack[currentPtr].node;
T elt = createElement("http://www.w3.org/1999/xhtml", "form",
attributes, currentNode
// CPPONLY: , htmlCreator(NS_NewHTMLFormElement)
@ -6155,7 +6145,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
System.arraycopy(templateModeStack, 0, templateModeStackCopy, 0,
templateModeStackCopy.length);
return new StateSnapshot<T>(stackCopy, listCopy, templateModeStackCopy, formPointer,
headPointer, mode, originalMode, framesetOk,
headPointer, deepTreeSurrogateParent, mode, originalMode, framesetOk,
needToDropLF, quirks);
}
@ -6172,6 +6162,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|| templateModeStackLen != templateModePtr + 1
|| formPointer != snapshot.getFormPointer()
|| headPointer != snapshot.getHeadPointer()
|| deepTreeSurrogateParent != snapshot.getDeepTreeSurrogateParent()
|| mode != snapshot.getMode()
|| originalMode != snapshot.getOriginalMode()
|| framesetOk != snapshot.isFramesetOk()
@ -6277,6 +6268,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
System.arraycopy(templateModeStackCopy, 0, templateModeStack, 0, templateModeStackLen);
formPointer = snapshot.getFormPointer();
headPointer = snapshot.getHeadPointer();
deepTreeSurrogateParent = snapshot.getDeepTreeSurrogateParent();
mode = snapshot.getMode();
originalMode = snapshot.getOriginalMode();
framesetOk = snapshot.isFramesetOk();
@ -6293,33 +6285,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
return -1;
}
/**
* Returns <code>stack[stackPos].node</code> if <code>stackPos</code> is
* smaller than Blink's magic limit or the node at Blink's magic limit
* otherwise.
*
* In order to get Blink-compatible handling of excessive deeply-nested
* markup, this method must be used to obtain the node that is used as the
* parent node of an insertion.
*
* Blink's magic number is 512, but our counting is off by one compared to
* Blink's way of counting, so in order to get the same
* externally-observable outcome, we use 511 as our magic number.
*
* @param stackPos the stack position to attempt to read
* @return node at the position capped to Blink's magic number
* @throws SAXException
*/
private T nodeFromStackWithBlinkCompat(int stackPos) throws SAXException {
// Magic number if off by one relative to Blink's magic number, but the
// outcome is the same, because the counting is different by one.
if (stackPos > 511) {
errDeepTree();
return stack[511].node;
}
return stack[stackPos].node;
}
/**
* @see nu.validator.htmlparser.impl.TreeBuilderState#getFormPointer()
*/
@ -6336,6 +6301,15 @@ public abstract class TreeBuilder<T> implements TokenHandler,
return headPointer;
}
/**
* Returns the deepTreeSurrogateParent.
*
* @return the deepTreeSurrogateParent
*/
public T getDeepTreeSurrogateParent() {
return deepTreeSurrogateParent;
}
/**
* @see nu.validator.htmlparser.impl.TreeBuilderState#getListOfActiveFormattingElements()
*/
@ -6423,16 +6397,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
return templateModePtr + 1;
}
/**
* Complains about an over-deep tree. Theoretically this should just be
* a warning, but in practice authors should take this as an error.
*
* @throws SAXException
*/
private void errDeepTree() throws SAXException {
err("The document tree is more than 513 elements deep, which causes Firefox and Chrome flatten the tree.");
}
/**
* Reports a stray start tag.
* @param name the name of the stray tag

Просмотреть файл

@ -31,6 +31,8 @@ class nsAHtml5TreeBuilderState {
virtual nsIContentHandle* getHeadPointer() = 0;
virtual nsIContentHandle* getDeepTreeSurrogateParent() = 0;
virtual int32_t getMode() = 0;
virtual int32_t getOriginalMode() = 0;

Просмотреть файл

@ -1,22 +1,22 @@
/*
* Copyright (c) 2009-2010 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
@ -54,27 +54,19 @@
#include "nsHtml5StateSnapshot.h"
nsHtml5StateSnapshot::nsHtml5StateSnapshot(
jArray<nsHtml5StackNode*, int32_t> stack,
jArray<nsHtml5StackNode*, int32_t> listOfActiveFormattingElements,
jArray<int32_t, int32_t> templateModeStack,
nsIContentHandle* formPointer,
nsIContentHandle* headPointer,
int32_t mode,
int32_t originalMode,
bool framesetOk,
bool needToDropLF,
bool quirks)
: stack(stack)
, listOfActiveFormattingElements(listOfActiveFormattingElements)
, templateModeStack(templateModeStack)
, formPointer(formPointer)
, headPointer(headPointer)
, mode(mode)
, originalMode(originalMode)
, framesetOk(framesetOk)
, needToDropLF(needToDropLF)
, quirks(quirks)
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),
headPointer(headPointer),
deepTreeSurrogateParent(deepTreeSurrogateParent),
mode(mode),
originalMode(originalMode),
framesetOk(framesetOk),
needToDropLF(needToDropLF),
quirks(quirks)
{
MOZ_COUNT_CTOR(nsHtml5StateSnapshot);
}
@ -109,6 +101,12 @@ nsHtml5StateSnapshot::getHeadPointer()
return headPointer;
}
nsIContentHandle*
nsHtml5StateSnapshot::getDeepTreeSurrogateParent()
{
return deepTreeSurrogateParent;
}
int32_t
nsHtml5StateSnapshot::getMode()
{

Просмотреть файл

@ -1,22 +1,22 @@
/*
* Copyright (c) 2009-2010 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
@ -63,28 +63,20 @@ class nsHtml5StateSnapshot : public nsAHtml5TreeBuilderState
autoJArray<int32_t,int32_t> templateModeStack;
nsIContentHandle* formPointer;
nsIContentHandle* headPointer;
nsIContentHandle* deepTreeSurrogateParent;
int32_t mode;
int32_t originalMode;
bool framesetOk;
bool needToDropLF;
bool quirks;
public:
nsHtml5StateSnapshot(
jArray<nsHtml5StackNode*, int32_t> stack,
jArray<nsHtml5StackNode*, int32_t> listOfActiveFormattingElements,
jArray<int32_t, int32_t> templateModeStack,
nsIContentHandle* formPointer,
nsIContentHandle* headPointer,
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();
nsIContentHandle* getFormPointer();
nsIContentHandle* getHeadPointer();
nsIContentHandle* getDeepTreeSurrogateParent();
int32_t getMode();
int32_t getOriginalMode();
bool isFramesetOk();

Просмотреть файл

@ -87,6 +87,7 @@ nsHtml5TreeBuilder::startTokenization(nsHtml5Tokenizer* self)
listPtr = -1;
formPointer = nullptr;
headPointer = nullptr;
deepTreeSurrogateParent = nullptr;
start(fragment);
charBufferLen = 0;
charBuffer = nullptr;
@ -608,6 +609,7 @@ nsHtml5TreeBuilder::endTokenization()
{
formPointer = nullptr;
headPointer = nullptr;
deepTreeSurrogateParent = nullptr;
templateModeStack = nullptr;
if (stack) {
while (currentPtr > -1) {
@ -3673,8 +3675,6 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag(nsIAtom* name)
return true;
}
nsHtml5StackNode* commonAncestor = stack[formattingEltStackPos - 1];
nsIContentHandle* insertionCommonAncestor =
nodeFromStackWithBlinkCompat(formattingEltStackPos - 1);
nsHtml5StackNode* furthestBlock = stack[furthestBlockPos];
int32_t bookmark = formattingEltListPos;
int32_t nodePos = furthestBlockPos;
@ -3715,7 +3715,7 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag(nsIAtom* name)
createElement(kNameSpaceID_XHTML,
node->name,
node->attributes->cloneAttributes(nullptr),
insertionCommonAncestor,
commonAncestor->node,
htmlCreator(node->getHtmlCreator()));
nsHtml5StackNode* newNode = createStackNode(node->getFlags(),
node->ns,
@ -3732,7 +3732,7 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag(nsIAtom* name)
node->release(this);
node = newNode;
detachFromParent(lastNode->node);
appendElement(lastNode->node, nodeFromStackWithBlinkCompat(nodePos));
appendElement(lastNode->node, node->node);
lastNode = node;
}
if (commonAncestor->isFosterParenting()) {
@ -3741,7 +3741,7 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag(nsIAtom* name)
insertIntoFosterParent(lastNode->node);
} else {
detachFromParent(lastNode->node);
appendElement(lastNode->node, insertionCommonAncestor);
appendElement(lastNode->node, commonAncestor->node);
}
nsIContentHandle* clone =
createElement(kNameSpaceID_XHTML,
@ -3916,22 +3916,21 @@ nsHtml5TreeBuilder::reconstructTheActiveFormattingElements()
while (entryPos < listPtr) {
entryPos++;
nsHtml5StackNode* entry = listOfActiveFormattingElements[entryPos];
nsHtml5StackNode* current = stack[currentPtr];
nsHtml5StackNode* currentNode = stack[currentPtr];
nsIContentHandle* clone;
if (current->isFosterParenting()) {
if (currentNode->isFosterParenting()) {
clone = createAndInsertFosterParentedElement(
kNameSpaceID_XHTML,
entry->name,
entry->attributes->cloneAttributes(nullptr),
htmlCreator(entry->getHtmlCreator()));
} else {
nsIContentHandle* currentNode = nodeFromStackWithBlinkCompat(currentPtr);
clone = createElement(kNameSpaceID_XHTML,
entry->name,
entry->attributes->cloneAttributes(nullptr),
currentNode,
currentNode->node,
htmlCreator(entry->getHtmlCreator()));
appendElement(clone, currentNode);
appendElement(clone, currentNode->node);
}
nsHtml5StackNode* entryClone = createStackNode(entry->getFlags(),
entry->ns,
@ -4153,7 +4152,7 @@ nsHtml5TreeBuilder::appendHtmlElementToDocumentAndPush()
void
nsHtml5TreeBuilder::appendToCurrentNodeAndPushHeadElement(nsHtml5HtmlAttributes* attributes)
{
nsIContentHandle* currentNode = nodeFromStackWithBlinkCompat(currentPtr);
nsIContentHandle* currentNode = stack[currentPtr]->node;
nsIContentHandle* elt = createElement(kNameSpaceID_XHTML,
nsGkAtoms::head,
attributes,
@ -4190,13 +4189,12 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushFormElementMayFoster(nsHtml5HtmlAt
attributes,
htmlCreator(NS_NewHTMLFormElement));
} else {
nsIContentHandle* currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement(kNameSpaceID_XHTML,
nsGkAtoms::form,
attributes,
currentNode,
current->node,
htmlCreator(NS_NewHTMLFormElement));
appendElement(elt, currentNode);
appendElement(elt, current->node);
}
if (!isTemplateContents()) {
formPointer = elt;
@ -4219,13 +4217,12 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushFormattingElementMayFoster(nsHtml5
attributes,
htmlCreator(elementName->getHtmlCreator()));
} else {
nsIContentHandle* currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement(kNameSpaceID_XHTML,
elementName->getName(),
attributes,
currentNode,
current->node,
htmlCreator(elementName->getHtmlCreator()));
appendElement(elt, currentNode);
appendElement(elt, current->node);
}
nsHtml5StackNode* node = createStackNode(elementName, elt, clone);
push(node);
@ -4236,7 +4233,7 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushFormattingElementMayFoster(nsHtml5
void
nsHtml5TreeBuilder::appendToCurrentNodeAndPushElement(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
{
nsIContentHandle* currentNode = nodeFromStackWithBlinkCompat(currentPtr);
nsIContentHandle* currentNode = stack[currentPtr]->node;
nsIContentHandle* elt =
createElement(kNameSpaceID_XHTML,
elementName->getName(),
@ -4265,13 +4262,12 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementNam
attributes,
htmlCreator(elementName->getHtmlCreator()));
} else {
nsIContentHandle* currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement(kNameSpaceID_XHTML,
popName,
attributes,
currentNode,
current->node,
htmlCreator(elementName->getHtmlCreator()));
appendElement(elt, currentNode);
appendElement(elt, current->node);
}
nsHtml5StackNode* node = createStackNode(elementName, elt, popName);
push(node);
@ -4292,13 +4288,12 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterMathML(nsHtml5Elem
elt = createAndInsertFosterParentedElement(
kNameSpaceID_MathML, popName, attributes, htmlCreator(nullptr));
} else {
nsIContentHandle* currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement(kNameSpaceID_MathML,
popName,
attributes,
currentNode,
current->node,
htmlCreator(nullptr));
appendElement(elt, currentNode);
appendElement(elt, current->node);
}
nsHtml5StackNode* node =
createStackNode(elementName, elt, popName, markAsHtmlIntegrationPoint);
@ -4330,13 +4325,12 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterSVG(nsHtml5Element
attributes,
svgCreator(elementName->getSvgCreator()));
} else {
nsIContentHandle* currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement(kNameSpaceID_SVG,
popName,
attributes,
currentNode,
current->node,
svgCreator(elementName->getSvgCreator()));
appendElement(elt, currentNode);
appendElement(elt, current->node);
}
nsHtml5StackNode* node = createStackNode(elementName, popName, elt);
push(node);
@ -4357,14 +4351,13 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementNam
formOwner,
htmlCreator(elementName->getHtmlCreator()));
} else {
nsIContentHandle* currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement(kNameSpaceID_XHTML,
elementName->getName(),
attributes,
formOwner,
currentNode,
current->node,
htmlCreator(elementName->getHtmlCreator()));
appendElement(elt, currentNode);
appendElement(elt, current->node);
}
nsHtml5StackNode* node = createStackNode(elementName, elt);
push(node);
@ -4389,14 +4382,13 @@ nsHtml5TreeBuilder::appendVoidElementToCurrentMayFoster(
formOwner,
htmlCreator(elementName->getHtmlCreator()));
} else {
nsIContentHandle* currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement(kNameSpaceID_XHTML,
name,
attributes,
formOwner,
currentNode,
current->node,
htmlCreator(elementName->getHtmlCreator()));
appendElement(elt, currentNode);
appendElement(elt, current->node);
}
elementPushed(kNameSpaceID_XHTML, name, elt);
elementPopped(kNameSpaceID_XHTML, name, elt);
@ -4416,13 +4408,12 @@ nsHtml5TreeBuilder::appendVoidElementToCurrentMayFoster(nsHtml5ElementName* elem
attributes,
htmlCreator(elementName->getHtmlCreator()));
} else {
nsIContentHandle* currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement(kNameSpaceID_XHTML,
popName,
attributes,
currentNode,
current->node,
htmlCreator(elementName->getHtmlCreator()));
appendElement(elt, currentNode);
appendElement(elt, current->node);
}
elementPushed(kNameSpaceID_XHTML, popName, elt);
elementPopped(kNameSpaceID_XHTML, popName, elt);
@ -4442,13 +4433,12 @@ nsHtml5TreeBuilder::appendVoidElementToCurrentMayFosterSVG(nsHtml5ElementName* e
attributes,
svgCreator(elementName->getSvgCreator()));
} else {
nsIContentHandle* currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement(kNameSpaceID_SVG,
popName,
attributes,
currentNode,
current->node,
svgCreator(elementName->getSvgCreator()));
appendElement(elt, currentNode);
appendElement(elt, current->node);
}
elementPushed(kNameSpaceID_SVG, popName, elt);
elementPopped(kNameSpaceID_SVG, popName, elt);
@ -4465,13 +4455,12 @@ nsHtml5TreeBuilder::appendVoidElementToCurrentMayFosterMathML(nsHtml5ElementName
elt = createAndInsertFosterParentedElement(
kNameSpaceID_MathML, popName, attributes, htmlCreator(nullptr));
} else {
nsIContentHandle* currentNode = nodeFromStackWithBlinkCompat(currentPtr);
elt = createElement(kNameSpaceID_MathML,
popName,
attributes,
currentNode,
current->node,
htmlCreator(nullptr));
appendElement(elt, currentNode);
appendElement(elt, current->node);
}
elementPushed(kNameSpaceID_MathML, popName, elt);
elementPopped(kNameSpaceID_MathML, popName, elt);
@ -4481,7 +4470,7 @@ void
nsHtml5TreeBuilder::appendVoidInputToCurrent(nsHtml5HtmlAttributes* attributes,
nsIContentHandle* form)
{
nsIContentHandle* currentNode = nodeFromStackWithBlinkCompat(currentPtr);
nsIContentHandle* currentNode = stack[currentPtr]->node;
nsIContentHandle* elt =
createElement(kNameSpaceID_XHTML,
nsGkAtoms::input,
@ -4497,7 +4486,7 @@ nsHtml5TreeBuilder::appendVoidInputToCurrent(nsHtml5HtmlAttributes* attributes,
void
nsHtml5TreeBuilder::appendVoidFormToCurrent(nsHtml5HtmlAttributes* attributes)
{
nsIContentHandle* currentNode = nodeFromStackWithBlinkCompat(currentPtr);
nsIContentHandle* currentNode = stack[currentPtr]->node;
nsIContentHandle* elt = createElement(kNameSpaceID_XHTML,
nsGkAtoms::form,
attributes,
@ -4655,16 +4644,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(stackCopy,
listCopy,
templateModeStackCopy,
formPointer,
headPointer,
mode,
originalMode,
framesetOk,
needToDropLF,
quirks);
return new nsHtml5StateSnapshot(stackCopy, listCopy, templateModeStackCopy, formPointer, headPointer, deepTreeSurrogateParent, mode, originalMode, framesetOk, needToDropLF, quirks);
}
bool
@ -4676,15 +4656,7 @@ nsHtml5TreeBuilder::snapshotMatches(nsAHtml5TreeBuilderState* snapshot)
int32_t listLen = snapshot->getListOfActiveFormattingElementsLength();
jArray<int32_t,int32_t> templateModeStackCopy = snapshot->getTemplateModeStack();
int32_t templateModeStackLen = snapshot->getTemplateModeStackLength();
if (stackLen != currentPtr + 1 || listLen != listPtr + 1 ||
templateModeStackLen != templateModePtr + 1 ||
formPointer != snapshot->getFormPointer() ||
headPointer != snapshot->getHeadPointer() ||
mode != snapshot->getMode() ||
originalMode != snapshot->getOriginalMode() ||
framesetOk != snapshot->isFramesetOk() ||
needToDropLF != snapshot->isNeedToDropLF() ||
quirks != snapshot->isQuirks()) {
if (stackLen != currentPtr + 1 || listLen != listPtr + 1 || templateModeStackLen != templateModePtr + 1 || formPointer != snapshot->getFormPointer() || headPointer != snapshot->getHeadPointer() || deepTreeSurrogateParent != snapshot->getDeepTreeSurrogateParent() || mode != snapshot->getMode() || originalMode != snapshot->getOriginalMode() || framesetOk != snapshot->isFramesetOk() || needToDropLF != snapshot->isNeedToDropLF() || quirks != snapshot->isQuirks()) {
return false;
}
for (int32_t i = listLen - 1; i >= 0; i--) {
@ -4776,6 +4748,7 @@ nsHtml5TreeBuilder::loadState(nsAHtml5TreeBuilderState* snapshot, nsHtml5AtomTab
nsHtml5ArrayCopy::arraycopy(templateModeStackCopy, templateModeStack, templateModeStackLen);
formPointer = snapshot->getFormPointer();
headPointer = snapshot->getHeadPointer();
deepTreeSurrogateParent = snapshot->getDeepTreeSurrogateParent();
mode = snapshot->getMode();
originalMode = snapshot->getOriginalMode();
framesetOk = snapshot->isFramesetOk();
@ -4794,28 +4767,24 @@ nsHtml5TreeBuilder::findInArray(nsHtml5StackNode* node, jArray<nsHtml5StackNode*
return -1;
}
nsIContentHandle*
nsHtml5TreeBuilder::nodeFromStackWithBlinkCompat(int32_t stackPos)
{
if (stackPos > 511) {
errDeepTree();
return stack[511]->node;
}
return stack[stackPos]->node;
}
nsIContentHandle*
nsIContentHandle*
nsHtml5TreeBuilder::getFormPointer()
{
return formPointer;
}
nsIContentHandle*
nsIContentHandle*
nsHtml5TreeBuilder::getHeadPointer()
{
return headPointer;
}
nsIContentHandle*
nsHtml5TreeBuilder::getDeepTreeSurrogateParent()
{
return deepTreeSurrogateParent;
}
jArray<nsHtml5StackNode*,int32_t>
nsHtml5TreeBuilder::getListOfActiveFormattingElements()
{

Просмотреть файл

@ -308,6 +308,7 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
int32_t listPtr;
nsIContentHandle* formPointer;
nsIContentHandle* headPointer;
nsIContentHandle* deepTreeSurrogateParent;
protected:
autoJArray<char16_t,int32_t> charBuffer;
int32_t charBufferLen;
@ -550,10 +551,10 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
void loadState(nsAHtml5TreeBuilderState* snapshot, nsHtml5AtomTable* interner);
private:
int32_t findInArray(nsHtml5StackNode* node, jArray<nsHtml5StackNode*,int32_t> arr);
nsIContentHandle* nodeFromStackWithBlinkCompat(int32_t stackPos);
public:
nsIContentHandle* getFormPointer();
nsIContentHandle* getHeadPointer();
nsIContentHandle* getDeepTreeSurrogateParent();
jArray<nsHtml5StackNode*,int32_t> getListOfActiveFormattingElements();
jArray<nsHtml5StackNode*,int32_t> getStack();
jArray<int32_t,int32_t> getTemplateModeStack();

Просмотреть файл

@ -7,6 +7,7 @@
#include "nsError.h"
#include "nsIPresShell.h"
#include "nsNodeUtils.h"
#include "nsIFrame.h"
#include "mozilla/Likely.h"
#include "mozilla/UniquePtr.h"
@ -483,6 +484,10 @@ nsHtml5TreeBuilder::appendElement(nsIContentHandle* aChild, nsIContentHandle* aP
{
NS_PRECONDITION(aChild, "Null child");
NS_PRECONDITION(aParent, "Null parent");
if (deepTreeSurrogateParent) {
return;
}
if (mBuilder) {
nsresult rv = nsHtml5TreeOperation::Append(static_cast<nsIContent*>(aChild),
static_cast<nsIContent*>(aParent),
@ -589,11 +594,12 @@ nsHtml5TreeBuilder::appendCharacters(nsIContentHandle* aParent, char16_t* aBuffe
MOZ_ASSERT(!aStart, "aStart must always be zero.");
if (mBuilder) {
nsresult rv =
nsHtml5TreeOperation::AppendText(aBuffer, // XXX aStart always ignored???
aLength,
static_cast<nsIContent*>(aParent),
mBuilder);
nsresult rv = nsHtml5TreeOperation::AppendText(
aBuffer, // XXX aStart always ignored???
aLength,
static_cast<nsIContent*>(deepTreeSurrogateParent ?
deepTreeSurrogateParent : aParent),
mBuilder);
if (NS_FAILED(rv)) {
MarkAsBrokenAndRequestSuspension(rv);
}
@ -613,7 +619,8 @@ nsHtml5TreeBuilder::appendCharacters(nsIContentHandle* aParent, char16_t* aBuffe
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
treeOp->Init(eTreeOpAppendText, bufferCopy, aLength, aParent);
treeOp->Init(eTreeOpAppendText, bufferCopy, aLength,
deepTreeSurrogateParent ? deepTreeSurrogateParent : aParent);
}
void
@ -623,6 +630,10 @@ nsHtml5TreeBuilder::appendComment(nsIContentHandle* aParent, char16_t* aBuffer,
NS_PRECONDITION(aParent, "Null parent");
MOZ_ASSERT(!aStart, "aStart must always be zero.");
if (deepTreeSurrogateParent) {
return;
}
if (mBuilder) {
nsresult rv = nsHtml5TreeOperation::AppendComment(
static_cast<nsIContent*>(aParent),
@ -732,6 +743,7 @@ void
nsHtml5TreeBuilder::start(bool fragment)
{
mCurrentHtmlScriptIsAsyncOrDefer = false;
deepTreeSurrogateParent = nullptr;
#ifdef DEBUG
mActive = true;
#endif
@ -798,6 +810,13 @@ nsHtml5TreeBuilder::elementPushed(int32_t aNamespace, nsIAtom* aName, nsIContent
* table elements shouldn't be used as surrogate parents for user experience
* reasons.
*/
if (!deepTreeSurrogateParent && currentPtr >= MAX_REFLOW_DEPTH &&
!(aName == nsGkAtoms::script || aName == nsGkAtoms::table ||
aName == nsGkAtoms::thead || aName == nsGkAtoms::tfoot ||
aName == nsGkAtoms::tbody || aName == nsGkAtoms::tr ||
aName == nsGkAtoms::colgroup || aName == nsGkAtoms::style)) {
deepTreeSurrogateParent = aElement;
}
if (aNamespace != kNameSpaceID_XHTML) {
return;
}
@ -843,6 +862,9 @@ nsHtml5TreeBuilder::elementPopped(int32_t aNamespace, nsIAtom* aName, nsIContent
NS_ASSERTION(aNamespace == kNameSpaceID_XHTML || aNamespace == kNameSpaceID_SVG || aNamespace == kNameSpaceID_MathML, "Element isn't HTML, SVG or MathML!");
NS_ASSERTION(aName, "Element doesn't have local name!");
NS_ASSERTION(aElement, "No element!");
if (deepTreeSurrogateParent && currentPtr <= MAX_REFLOW_DEPTH) {
deepTreeSurrogateParent = nullptr;
}
if (aNamespace == kNameSpaceID_MathML) {
return;
}
@ -1290,18 +1312,6 @@ nsHtml5TreeBuilder::EnableViewSource(nsHtml5Highlighter* aHighlighter)
mViewSource = aHighlighter;
}
void
nsHtml5TreeBuilder::errDeepTree()
{
if (MOZ_UNLIKELY(mViewSource)) {
mViewSource->AddErrorToCurrentRun("errDeepTree");
} else if (!mBuilder) {
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
MOZ_ASSERT(treeOp, "Tree op allocation failed.");
treeOp->InitDeepTree(tokenizer->getLineNumber());
}
}
void
nsHtml5TreeBuilder::errStrayStartTag(nsIAtom* aName)
{

Просмотреть файл

@ -145,9 +145,6 @@
void EnableViewSource(nsHtml5Highlighter* aHighlighter);
void
errDeepTree();
void errStrayStartTag(nsIAtom* aName);
void errStrayEndTag(nsIAtom* aName);

Просмотреть файл

@ -65,13 +65,12 @@ nsHtml5TreeOpExecutor::nsHtml5TreeOpExecutor()
, mSuppressEOF(false)
, mReadingFromStage(false)
, mStreamParser(nullptr)
, mPreloadedURLs(23) // Mean # of preloadable resources per page on dmoz
, mPreloadedURLs(23) // Mean # of preloadable resources per page on dmoz
, mSpeculationReferrerPolicy(mozilla::net::RP_Unset)
, mStarted(false)
, mRunFlushLoopOnStack(false)
, mCallContinueInterruptedParsingIfEnabled(false)
, mAlreadyComplainedAboutCharset(false)
, mAlreadyComplainedAboutDeepTree(false)
{
}
@ -816,25 +815,6 @@ nsHtml5TreeOpExecutor::ComplainAboutBogusProtocolCharset(nsIDocument* aDoc)
"EncProtocolUnsupported");
}
void
nsHtml5TreeOpExecutor::MaybeComplainAboutDeepTree(uint32_t aLineNumber)
{
if (mAlreadyComplainedAboutDeepTree) {
return;
}
mAlreadyComplainedAboutDeepTree = true;
nsContentUtils::ReportToConsole(nsIScriptError::errorFlag,
NS_LITERAL_CSTRING("HTML parser"),
mDocument,
nsContentUtils::eHTMLPARSER_PROPERTIES,
"errDeepTree",
nullptr,
0,
nullptr,
EmptyString(),
aLineNumber);
}
nsHtml5Parser*
nsHtml5TreeOpExecutor::GetParser()
{

Просмотреть файл

@ -92,12 +92,6 @@ class nsHtml5TreeOpExecutor final : public nsHtml5DocumentBuilder,
*/
bool mAlreadyComplainedAboutCharset;
/**
* Whether this executor has already complained about the tree being too
* deep.
*/
bool mAlreadyComplainedAboutDeepTree;
public:
nsHtml5TreeOpExecutor();
@ -202,8 +196,6 @@ class nsHtml5TreeOpExecutor final : public nsHtml5DocumentBuilder,
void ComplainAboutBogusProtocolCharset(nsIDocument* aDoc);
void MaybeComplainAboutDeepTree(uint32_t aLineNumber);
bool IsComplete()
{
return !mParser;

Просмотреть файл

@ -1011,11 +1011,6 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
aBuilder->MaybeComplainAboutCharset(msgId, error, (uint32_t)lineNumber);
return NS_OK;
}
case eTreeOpMaybeComplainAboutDeepTree: {
int32_t lineNumber = mOne.integer;
aBuilder->MaybeComplainAboutDeepTree((uint32_t)lineNumber);
return NS_OK;
}
case eTreeOpAddClass: {
nsIContent* node = *(mOne.node);
char16_t* str = mTwo.unicharPtr;

Просмотреть файл

@ -59,7 +59,6 @@ enum eHtml5TreeOperation
eTreeOpSetScriptLineNumberAndFreeze,
eTreeOpSvgLoad,
eTreeOpMaybeComplainAboutCharset,
eTreeOpMaybeComplainAboutDeepTree,
eTreeOpAddClass,
eTreeOpAddViewSourceHref,
eTreeOpAddViewSourceBase,
@ -466,14 +465,6 @@ class nsHtml5TreeOperation final {
mThree.integer = aLineNumber;
}
inline void InitDeepTree(int32_t aLineNumber)
{
MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
mOpCode = eTreeOpMaybeComplainAboutDeepTree;
mOne.integer = aLineNumber;
}
inline void Init(eHtml5TreeOperation aOpCode, const nsAString& aString)
{
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,