mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 606925 - Get rid of the "in foreign content" insertion mode. Check the namespace of the current node instead. rs=jonas, a=blocking2.0-betaN.
This commit is contained in:
parent
6402200a37
commit
b91c3491b4
@ -43,8 +43,6 @@ public class StateSnapshot<T> implements TreeBuilderState<T> {
|
||||
|
||||
private final boolean framesetOk;
|
||||
|
||||
private final boolean inForeign;
|
||||
|
||||
private final boolean needToDropLF;
|
||||
|
||||
private final boolean quirks;
|
||||
@ -60,7 +58,7 @@ public class StateSnapshot<T> implements TreeBuilderState<T> {
|
||||
* @param mode
|
||||
*/
|
||||
StateSnapshot(StackNode<T>[] stack,
|
||||
StackNode<T>[] listOfActiveFormattingElements, T formPointer, T headPointer, T deepTreeSurrogateParent, int mode, int originalMode, boolean framesetOk, boolean inForeign, boolean needToDropLF, boolean quirks) {
|
||||
StackNode<T>[] listOfActiveFormattingElements, T formPointer, T headPointer, T deepTreeSurrogateParent, int mode, int originalMode, boolean framesetOk, boolean needToDropLF, boolean quirks) {
|
||||
this.stack = stack;
|
||||
this.listOfActiveFormattingElements = listOfActiveFormattingElements;
|
||||
this.formPointer = formPointer;
|
||||
@ -69,7 +67,6 @@ public class StateSnapshot<T> implements TreeBuilderState<T> {
|
||||
this.mode = mode;
|
||||
this.originalMode = originalMode;
|
||||
this.framesetOk = framesetOk;
|
||||
this.inForeign = inForeign;
|
||||
this.needToDropLF = needToDropLF;
|
||||
this.quirks = quirks;
|
||||
}
|
||||
@ -140,15 +137,6 @@ public class StateSnapshot<T> implements TreeBuilderState<T> {
|
||||
return framesetOk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the inForeign.
|
||||
*
|
||||
* @return the inForeign
|
||||
*/
|
||||
public boolean isInForeign() {
|
||||
return inForeign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the needToDropLF.
|
||||
*
|
||||
|
@ -352,8 +352,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
*/
|
||||
private boolean framesetOk = true;
|
||||
|
||||
private boolean inForeign = false;
|
||||
|
||||
protected Tokenizer tokenizer;
|
||||
|
||||
// [NOCPP[
|
||||
@ -552,14 +550,13 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
contextNode = null;
|
||||
} else {
|
||||
mode = INITIAL;
|
||||
inForeign = false;
|
||||
}
|
||||
}
|
||||
|
||||
public final void doctype(@Local String name, String publicIdentifier,
|
||||
String systemIdentifier, boolean forceQuirks) throws SAXException {
|
||||
needToDropLF = false;
|
||||
if (!inForeign) {
|
||||
if (!isInForeign()) {
|
||||
switch (mode) {
|
||||
case INITIAL:
|
||||
// [NOCPP[
|
||||
@ -792,7 +789,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
return;
|
||||
}
|
||||
// ]NOCPP]
|
||||
if (!inForeign) {
|
||||
if (!isInForeign()) {
|
||||
switch (mode) {
|
||||
case INITIAL:
|
||||
case BEFORE_HTML:
|
||||
@ -850,7 +847,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
case IN_BODY:
|
||||
case IN_CELL:
|
||||
case IN_CAPTION:
|
||||
if (!inForeign) {
|
||||
if (!isInForeign()) {
|
||||
reconstructTheActiveFormattingElements();
|
||||
}
|
||||
// fall through
|
||||
@ -909,7 +906,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
* Reconstruct the active formatting
|
||||
* elements, if any.
|
||||
*/
|
||||
if (!inForeign) {
|
||||
if (!isInForeign()) {
|
||||
flushCharacters();
|
||||
reconstructTheActiveFormattingElements();
|
||||
}
|
||||
@ -1105,7 +1102,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
* Reconstruct the active formatting
|
||||
* elements, if any.
|
||||
*/
|
||||
if (!inForeign) {
|
||||
if (!isInForeign()) {
|
||||
flushCharacters();
|
||||
reconstructTheActiveFormattingElements();
|
||||
}
|
||||
@ -1219,7 +1216,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
*/
|
||||
public void zeroOriginatingReplacementCharacter()
|
||||
throws SAXException {
|
||||
if (inForeign || mode == TEXT) {
|
||||
if (isInForeign() || mode == TEXT) {
|
||||
characters(REPLACEMENT_CHARACTER, 0, 1);
|
||||
}
|
||||
}
|
||||
@ -1227,7 +1224,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
public final void eof() throws SAXException {
|
||||
flushCharacters();
|
||||
eofloop: for (;;) {
|
||||
if (inForeign) {
|
||||
if (isInForeign()) {
|
||||
err("End of file in a foreign namespace context.");
|
||||
break eofloop;
|
||||
}
|
||||
@ -1433,19 +1430,13 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
|
||||
int eltPos;
|
||||
needToDropLF = false;
|
||||
boolean needsPostProcessing = false;
|
||||
starttagloop: for (;;) {
|
||||
int group = elementName.getGroup();
|
||||
@Local String name = elementName.name;
|
||||
if (inForeign) {
|
||||
if (isInForeign()) {
|
||||
StackNode<T> currentNode = stack[currentPtr];
|
||||
@NsUri String currNs = currentNode.ns;
|
||||
if (("http://www.w3.org/1999/xhtml" == currNs)
|
||||
|| currentNode.isHtmlIntegrationPoint()
|
||||
|| (currNs == "http://www.w3.org/1998/Math/MathML" && ((currentNode.getGroup() == MI_MO_MN_MS_MTEXT && group != MGLYPH_OR_MALIGNMARK) || (currentNode.getGroup() == ANNOTATION_XML && group == SVG)))) {
|
||||
needsPostProcessing = true;
|
||||
// fall through to non-foreign behavior
|
||||
} else {
|
||||
if (!(currentNode.isHtmlIntegrationPoint() || (currNs == "http://www.w3.org/1998/Math/MathML" && ((currentNode.getGroup() == MI_MO_MN_MS_MTEXT && group != MGLYPH_OR_MALIGNMARK) || (currentNode.getGroup() == ANNOTATION_XML && group == SVG))))) {
|
||||
switch (group) {
|
||||
case B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U:
|
||||
case DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU:
|
||||
@ -1470,9 +1461,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
while (!isSpecialParentInForeign(stack[currentPtr])) {
|
||||
pop();
|
||||
}
|
||||
if (!hasForeignInScope()) {
|
||||
inForeign = false;
|
||||
}
|
||||
continue starttagloop;
|
||||
case FONT:
|
||||
if (attributes.contains(AttributeName.COLOR)
|
||||
@ -1484,9 +1472,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
while (!isSpecialParentInForeign(stack[currentPtr])) {
|
||||
pop();
|
||||
}
|
||||
if (!hasForeignInScope()) {
|
||||
inForeign = false;
|
||||
}
|
||||
continue starttagloop;
|
||||
}
|
||||
// else fall thru
|
||||
@ -2263,7 +2248,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
} else {
|
||||
appendToCurrentNodeAndPushElementMayFosterMathML(
|
||||
elementName, attributes);
|
||||
inForeign = true;
|
||||
}
|
||||
attributes = null; // CPP
|
||||
break starttagloop;
|
||||
@ -2278,7 +2262,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
} else {
|
||||
appendToCurrentNodeAndPushElementMayFosterSVG(
|
||||
elementName, attributes);
|
||||
inForeign = true;
|
||||
}
|
||||
attributes = null; // CPP
|
||||
break starttagloop;
|
||||
@ -2893,15 +2876,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
// fails
|
||||
}
|
||||
}
|
||||
if (needsPostProcessing && inForeign && !hasForeignInScope()) {
|
||||
/*
|
||||
* If, after doing so, the insertion mode is still "in foreign
|
||||
* content", but there is no element in scope that has a namespace
|
||||
* other than the HTML namespace, switch the insertion mode to the
|
||||
* secondary insertion mode.
|
||||
*/
|
||||
inForeign = false;
|
||||
}
|
||||
if (errorHandler != null && selfClosing) {
|
||||
errNoCheck("Self-closing syntax (\u201C/>\u201D) used on a non-void HTML element. Ignoring the slash and treating as a start tag.");
|
||||
}
|
||||
@ -2912,15 +2886,9 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
|
||||
private boolean isSpecialParentInForeign(StackNode<T> stackNode) {
|
||||
@NsUri String ns = stackNode.ns;
|
||||
if ("http://www.w3.org/1999/xhtml" == ns) {
|
||||
return true;
|
||||
}
|
||||
if (ns == "http://www.w3.org/2000/svg") {
|
||||
return stackNode.getGroup() == FOREIGNOBJECT_OR_DESC
|
||||
|| stackNode.getGroup() == TITLE;
|
||||
}
|
||||
assert ns == "http://www.w3.org/1998/Math/MathML" : "Unexpected namespace.";
|
||||
return stackNode.getGroup() == MI_MO_MN_MS_MTEXT;
|
||||
return ("http://www.w3.org/1999/xhtml" == ns)
|
||||
|| (stackNode.isHtmlIntegrationPoint())
|
||||
|| (("http://www.w3.org/1998/Math/MathML" == ns) && (stackNode.getGroup() == MI_MO_MN_MS_MTEXT));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3124,9 +3092,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
int group = elementName.getGroup();
|
||||
@Local String name = elementName.name;
|
||||
endtagloop: for (;;) {
|
||||
assert !inForeign || currentPtr >= 0 : "In foreign without a root element?";
|
||||
if (inForeign
|
||||
&& stack[currentPtr].ns != "http://www.w3.org/1999/xhtml") {
|
||||
if (isInForeign()) {
|
||||
if (errorHandler != null && stack[currentPtr].name != name) {
|
||||
errNoCheck("End tag \u201C"
|
||||
+ name
|
||||
@ -3441,15 +3407,14 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
eltPos = findLastInButtonScope("p");
|
||||
if (eltPos == TreeBuilder.NOT_FOUND_ON_STACK) {
|
||||
err("No \u201Cp\u201D element in scope but a \u201Cp\u201D end tag seen.");
|
||||
// XXX inline this case
|
||||
if (inForeign) {
|
||||
// XXX Can the 'in foreign' case happen anymore?
|
||||
if (isInForeign()) {
|
||||
err("HTML start tag \u201C"
|
||||
+ name
|
||||
+ "\u201D in a foreign namespace context.");
|
||||
while (stack[currentPtr].ns != "http://www.w3.org/1999/xhtml") {
|
||||
pop();
|
||||
}
|
||||
inForeign = false;
|
||||
}
|
||||
appendVoidElementToCurrentMayFoster(
|
||||
elementName,
|
||||
@ -3536,14 +3501,13 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
break endtagloop;
|
||||
case BR:
|
||||
err("End tag \u201Cbr\u201D.");
|
||||
if (inForeign) {
|
||||
if (isInForeign()) {
|
||||
err("HTML start tag \u201C"
|
||||
+ name
|
||||
+ "\u201D in a foreign namespace context.");
|
||||
while (stack[currentPtr].ns != "http://www.w3.org/1999/xhtml") {
|
||||
pop();
|
||||
}
|
||||
inForeign = false;
|
||||
}
|
||||
reconstructTheActiveFormattingElements();
|
||||
appendVoidElementToCurrentMayFoster(
|
||||
@ -3871,15 +3835,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
break endtagloop;
|
||||
}
|
||||
} // endtagloop
|
||||
if (inForeign && !hasForeignInScope()) {
|
||||
/*
|
||||
* If, after doing so, the insertion mode is still "in foreign
|
||||
* content", but there is no element in scope that has a namespace
|
||||
* other than the HTML namespace, switch the insertion mode to the
|
||||
* secondary insertion mode.
|
||||
*/
|
||||
inForeign = false;
|
||||
}
|
||||
}
|
||||
|
||||
private int findLastInTableScopeOrRootTbodyTheadTfoot() {
|
||||
@ -3955,17 +3910,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
return TreeBuilder.NOT_FOUND_ON_STACK;
|
||||
}
|
||||
|
||||
private boolean hasForeignInScope() {
|
||||
for (int i = currentPtr; i > 0; i--) {
|
||||
if (stack[i].ns != "http://www.w3.org/1999/xhtml") {
|
||||
return true;
|
||||
} else if (stack[i].isScoping()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void generateImpliedEndTagsExceptFor(@Local String name)
|
||||
throws SAXException {
|
||||
for (;;) {
|
||||
@ -4124,7 +4068,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
}
|
||||
|
||||
private void resetTheInsertionMode() {
|
||||
inForeign = false;
|
||||
StackNode<T> node;
|
||||
@Local String name;
|
||||
@NsUri String ns;
|
||||
@ -4163,7 +4106,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
mode = IN_TABLE;
|
||||
return;
|
||||
} else if ("http://www.w3.org/1999/xhtml" != ns) {
|
||||
inForeign = true;
|
||||
mode = framesetOk ? FRAMESET_OK : IN_BODY;
|
||||
return;
|
||||
} else if ("head" == name) {
|
||||
@ -5239,8 +5181,12 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
/**
|
||||
* @see nu.validator.htmlparser.common.TokenHandler#cdataSectionAllowed()
|
||||
*/
|
||||
public boolean cdataSectionAllowed() throws SAXException {
|
||||
return inForeign && currentPtr >= 0
|
||||
@Inline public boolean cdataSectionAllowed() throws SAXException {
|
||||
return isInForeign();
|
||||
}
|
||||
|
||||
private boolean isInForeign() {
|
||||
return currentPtr >= 0
|
||||
&& stack[currentPtr].ns != "http://www.w3.org/1999/xhtml";
|
||||
}
|
||||
|
||||
@ -5407,7 +5353,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
stackCopy[i].retain();
|
||||
}
|
||||
}
|
||||
return new StateSnapshot<T>(stackCopy, listCopy, formPointer, headPointer, deepTreeSurrogateParent, mode, originalMode, framesetOk, inForeign, needToDropLF, quirks);
|
||||
return new StateSnapshot<T>(stackCopy, listCopy, formPointer, headPointer, deepTreeSurrogateParent, mode, originalMode, framesetOk, needToDropLF, quirks);
|
||||
}
|
||||
|
||||
public boolean snapshotMatches(TreeBuilderState<T> snapshot) {
|
||||
@ -5424,7 +5370,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
|| mode != snapshot.getMode()
|
||||
|| originalMode != snapshot.getOriginalMode()
|
||||
|| framesetOk != snapshot.isFramesetOk()
|
||||
|| inForeign != snapshot.isInForeign()
|
||||
|| needToDropLF != snapshot.isNeedToDropLF()
|
||||
|| quirks != snapshot.isQuirks()) { // maybe just assert quirks
|
||||
return false;
|
||||
@ -5508,7 +5453,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
mode = snapshot.getMode();
|
||||
originalMode = snapshot.getOriginalMode();
|
||||
framesetOk = snapshot.isFramesetOk();
|
||||
inForeign = snapshot.isInForeign();
|
||||
needToDropLF = snapshot.isNeedToDropLF();
|
||||
quirks = snapshot.isQuirks();
|
||||
}
|
||||
@ -5588,15 +5532,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
return framesetOk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the foreignFlag.
|
||||
*
|
||||
* @return the foreignFlag
|
||||
*/
|
||||
public boolean isInForeign() {
|
||||
return inForeign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the needToDropLF.
|
||||
*
|
||||
|
@ -66,8 +66,6 @@ class nsAHtml5TreeBuilderState {
|
||||
|
||||
virtual PRBool isFramesetOk() = 0;
|
||||
|
||||
virtual PRBool isInForeign() = 0;
|
||||
|
||||
virtual PRBool isNeedToDropLF() = 0;
|
||||
|
||||
virtual PRBool isQuirks() = 0;
|
||||
|
@ -59,7 +59,7 @@
|
||||
#include "nsHtml5StateSnapshot.h"
|
||||
|
||||
|
||||
nsHtml5StateSnapshot::nsHtml5StateSnapshot(jArray<nsHtml5StackNode*,PRInt32> stack, jArray<nsHtml5StackNode*,PRInt32> listOfActiveFormattingElements, nsIContent** formPointer, nsIContent** headPointer, nsIContent** deepTreeSurrogateParent, PRInt32 mode, PRInt32 originalMode, PRBool framesetOk, PRBool inForeign, PRBool needToDropLF, PRBool quirks)
|
||||
nsHtml5StateSnapshot::nsHtml5StateSnapshot(jArray<nsHtml5StackNode*,PRInt32> stack, jArray<nsHtml5StackNode*,PRInt32> listOfActiveFormattingElements, nsIContent** formPointer, nsIContent** headPointer, nsIContent** deepTreeSurrogateParent, PRInt32 mode, PRInt32 originalMode, PRBool framesetOk, PRBool needToDropLF, PRBool quirks)
|
||||
: stack(stack),
|
||||
listOfActiveFormattingElements(listOfActiveFormattingElements),
|
||||
formPointer(formPointer),
|
||||
@ -68,7 +68,6 @@ nsHtml5StateSnapshot::nsHtml5StateSnapshot(jArray<nsHtml5StackNode*,PRInt32> sta
|
||||
mode(mode),
|
||||
originalMode(originalMode),
|
||||
framesetOk(framesetOk),
|
||||
inForeign(inForeign),
|
||||
needToDropLF(needToDropLF),
|
||||
quirks(quirks)
|
||||
{
|
||||
@ -123,12 +122,6 @@ nsHtml5StateSnapshot::isFramesetOk()
|
||||
return framesetOk;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsHtml5StateSnapshot::isInForeign()
|
||||
{
|
||||
return inForeign;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsHtml5StateSnapshot::isNeedToDropLF()
|
||||
{
|
||||
|
@ -70,11 +70,10 @@ class nsHtml5StateSnapshot : public nsAHtml5TreeBuilderState
|
||||
PRInt32 mode;
|
||||
PRInt32 originalMode;
|
||||
PRBool framesetOk;
|
||||
PRBool inForeign;
|
||||
PRBool needToDropLF;
|
||||
PRBool quirks;
|
||||
public:
|
||||
nsHtml5StateSnapshot(jArray<nsHtml5StackNode*,PRInt32> stack, jArray<nsHtml5StackNode*,PRInt32> listOfActiveFormattingElements, nsIContent** formPointer, nsIContent** headPointer, nsIContent** deepTreeSurrogateParent, PRInt32 mode, PRInt32 originalMode, PRBool framesetOk, PRBool inForeign, PRBool needToDropLF, PRBool quirks);
|
||||
nsHtml5StateSnapshot(jArray<nsHtml5StackNode*,PRInt32> stack, jArray<nsHtml5StackNode*,PRInt32> listOfActiveFormattingElements, nsIContent** formPointer, nsIContent** headPointer, nsIContent** deepTreeSurrogateParent, PRInt32 mode, PRInt32 originalMode, PRBool framesetOk, PRBool needToDropLF, PRBool quirks);
|
||||
jArray<nsHtml5StackNode*,PRInt32> getStack();
|
||||
jArray<nsHtml5StackNode*,PRInt32> getListOfActiveFormattingElements();
|
||||
nsIContent** getFormPointer();
|
||||
@ -83,7 +82,6 @@ class nsHtml5StateSnapshot : public nsAHtml5TreeBuilderState
|
||||
PRInt32 getMode();
|
||||
PRInt32 getOriginalMode();
|
||||
PRBool isFramesetOk();
|
||||
PRBool isInForeign();
|
||||
PRBool isNeedToDropLF();
|
||||
PRBool isQuirks();
|
||||
PRInt32 getListOfActiveFormattingElementsLength();
|
||||
|
@ -111,7 +111,6 @@ nsHtml5TreeBuilder::startTokenization(nsHtml5Tokenizer* self)
|
||||
contextNode = nsnull;
|
||||
} else {
|
||||
mode = NS_HTML5TREE_BUILDER_INITIAL;
|
||||
inForeign = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,7 +118,7 @@ void
|
||||
nsHtml5TreeBuilder::doctype(nsIAtom* name, nsString* publicIdentifier, nsString* systemIdentifier, PRBool forceQuirks)
|
||||
{
|
||||
needToDropLF = PR_FALSE;
|
||||
if (!inForeign) {
|
||||
if (!isInForeign()) {
|
||||
switch(mode) {
|
||||
case NS_HTML5TREE_BUILDER_INITIAL: {
|
||||
nsString* emptyString = nsHtml5Portability::newEmptyString();
|
||||
@ -150,7 +149,7 @@ void
|
||||
nsHtml5TreeBuilder::comment(PRUnichar* buf, PRInt32 start, PRInt32 length)
|
||||
{
|
||||
needToDropLF = PR_FALSE;
|
||||
if (!inForeign) {
|
||||
if (!isInForeign()) {
|
||||
switch(mode) {
|
||||
case NS_HTML5TREE_BUILDER_INITIAL:
|
||||
case NS_HTML5TREE_BUILDER_BEFORE_HTML:
|
||||
@ -191,7 +190,7 @@ nsHtml5TreeBuilder::characters(const PRUnichar* buf, PRInt32 start, PRInt32 leng
|
||||
case NS_HTML5TREE_BUILDER_IN_BODY:
|
||||
case NS_HTML5TREE_BUILDER_IN_CELL:
|
||||
case NS_HTML5TREE_BUILDER_IN_CAPTION: {
|
||||
if (!inForeign) {
|
||||
if (!isInForeign()) {
|
||||
reconstructTheActiveFormattingElements();
|
||||
}
|
||||
}
|
||||
@ -237,7 +236,7 @@ nsHtml5TreeBuilder::characters(const PRUnichar* buf, PRInt32 start, PRInt32 leng
|
||||
accumulateCharacters(buf, start, i - start);
|
||||
start = i;
|
||||
}
|
||||
if (!inForeign) {
|
||||
if (!isInForeign()) {
|
||||
flushCharacters();
|
||||
reconstructTheActiveFormattingElements();
|
||||
}
|
||||
@ -339,7 +338,7 @@ nsHtml5TreeBuilder::characters(const PRUnichar* buf, PRInt32 start, PRInt32 leng
|
||||
accumulateCharacters(buf, start, i - start);
|
||||
start = i;
|
||||
}
|
||||
if (!inForeign) {
|
||||
if (!isInForeign()) {
|
||||
flushCharacters();
|
||||
reconstructTheActiveFormattingElements();
|
||||
}
|
||||
@ -424,7 +423,7 @@ nsHtml5TreeBuilder::characters(const PRUnichar* buf, PRInt32 start, PRInt32 leng
|
||||
void
|
||||
nsHtml5TreeBuilder::zeroOriginatingReplacementCharacter()
|
||||
{
|
||||
if (inForeign || mode == NS_HTML5TREE_BUILDER_TEXT) {
|
||||
if (isInForeign() || mode == NS_HTML5TREE_BUILDER_TEXT) {
|
||||
characters(REPLACEMENT_CHARACTER, 0, 1);
|
||||
}
|
||||
}
|
||||
@ -434,7 +433,7 @@ nsHtml5TreeBuilder::eof()
|
||||
{
|
||||
flushCharacters();
|
||||
for (; ; ) {
|
||||
if (inForeign) {
|
||||
if (isInForeign()) {
|
||||
|
||||
NS_HTML5_BREAK(eofloop);
|
||||
}
|
||||
@ -559,16 +558,13 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
|
||||
flushCharacters();
|
||||
PRInt32 eltPos;
|
||||
needToDropLF = PR_FALSE;
|
||||
PRBool needsPostProcessing = PR_FALSE;
|
||||
starttagloop: for (; ; ) {
|
||||
PRInt32 group = elementName->getGroup();
|
||||
nsIAtom* name = elementName->name;
|
||||
if (inForeign) {
|
||||
if (isInForeign()) {
|
||||
nsHtml5StackNode* currentNode = stack[currentPtr];
|
||||
PRInt32 currNs = currentNode->ns;
|
||||
if ((kNameSpaceID_XHTML == currNs) || currentNode->isHtmlIntegrationPoint() || (currNs == kNameSpaceID_MathML && ((currentNode->getGroup() == NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT && group != NS_HTML5TREE_BUILDER_MGLYPH_OR_MALIGNMARK) || (currentNode->getGroup() == NS_HTML5TREE_BUILDER_ANNOTATION_XML && group == NS_HTML5TREE_BUILDER_SVG)))) {
|
||||
needsPostProcessing = PR_TRUE;
|
||||
} else {
|
||||
if (!(currentNode->isHtmlIntegrationPoint() || (currNs == kNameSpaceID_MathML && ((currentNode->getGroup() == NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT && group != NS_HTML5TREE_BUILDER_MGLYPH_OR_MALIGNMARK) || (currentNode->getGroup() == NS_HTML5TREE_BUILDER_ANNOTATION_XML && group == NS_HTML5TREE_BUILDER_SVG))))) {
|
||||
switch(group) {
|
||||
case NS_HTML5TREE_BUILDER_B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U:
|
||||
case NS_HTML5TREE_BUILDER_DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU:
|
||||
@ -591,9 +587,6 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
|
||||
while (!isSpecialParentInForeign(stack[currentPtr])) {
|
||||
pop();
|
||||
}
|
||||
if (!hasForeignInScope()) {
|
||||
inForeign = PR_FALSE;
|
||||
}
|
||||
NS_HTML5_CONTINUE(starttagloop);
|
||||
}
|
||||
case NS_HTML5TREE_BUILDER_FONT: {
|
||||
@ -602,9 +595,6 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
|
||||
while (!isSpecialParentInForeign(stack[currentPtr])) {
|
||||
pop();
|
||||
}
|
||||
if (!hasForeignInScope()) {
|
||||
inForeign = PR_FALSE;
|
||||
}
|
||||
NS_HTML5_CONTINUE(starttagloop);
|
||||
}
|
||||
}
|
||||
@ -1250,7 +1240,6 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
|
||||
selfClosing = PR_FALSE;
|
||||
} else {
|
||||
appendToCurrentNodeAndPushElementMayFosterMathML(elementName, attributes);
|
||||
inForeign = PR_TRUE;
|
||||
}
|
||||
attributes = nsnull;
|
||||
NS_HTML5_BREAK(starttagloop);
|
||||
@ -1263,7 +1252,6 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
|
||||
selfClosing = PR_FALSE;
|
||||
} else {
|
||||
appendToCurrentNodeAndPushElementMayFosterSVG(elementName, attributes);
|
||||
inForeign = PR_TRUE;
|
||||
}
|
||||
attributes = nsnull;
|
||||
NS_HTML5_BREAK(starttagloop);
|
||||
@ -1792,9 +1780,6 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
|
||||
}
|
||||
}
|
||||
starttagloop_end: ;
|
||||
if (needsPostProcessing && inForeign && !hasForeignInScope()) {
|
||||
inForeign = PR_FALSE;
|
||||
}
|
||||
|
||||
if (attributes != nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES) {
|
||||
delete attributes;
|
||||
@ -1805,14 +1790,7 @@ PRBool
|
||||
nsHtml5TreeBuilder::isSpecialParentInForeign(nsHtml5StackNode* stackNode)
|
||||
{
|
||||
PRInt32 ns = stackNode->ns;
|
||||
if (kNameSpaceID_XHTML == ns) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
if (ns == kNameSpaceID_SVG) {
|
||||
return stackNode->getGroup() == NS_HTML5TREE_BUILDER_FOREIGNOBJECT_OR_DESC || stackNode->getGroup() == NS_HTML5TREE_BUILDER_TITLE;
|
||||
}
|
||||
|
||||
return stackNode->getGroup() == NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT;
|
||||
return (kNameSpaceID_XHTML == ns) || (stackNode->isHtmlIntegrationPoint()) || ((kNameSpaceID_MathML == ns) && (stackNode->getGroup() == NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT));
|
||||
}
|
||||
|
||||
nsString*
|
||||
@ -2045,8 +2023,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
|
||||
PRInt32 group = elementName->getGroup();
|
||||
nsIAtom* name = elementName->name;
|
||||
for (; ; ) {
|
||||
|
||||
if (inForeign && stack[currentPtr]->ns != kNameSpaceID_XHTML) {
|
||||
if (isInForeign()) {
|
||||
|
||||
eltPos = currentPtr;
|
||||
for (; ; ) {
|
||||
@ -2330,12 +2307,11 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
|
||||
eltPos = findLastInButtonScope(nsHtml5Atoms::p);
|
||||
if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
|
||||
|
||||
if (inForeign) {
|
||||
if (isInForeign()) {
|
||||
|
||||
while (stack[currentPtr]->ns != kNameSpaceID_XHTML) {
|
||||
pop();
|
||||
}
|
||||
inForeign = PR_FALSE;
|
||||
}
|
||||
appendVoidElementToCurrentMayFoster(elementName, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
|
||||
NS_HTML5_BREAK(endtagloop);
|
||||
@ -2396,12 +2372,11 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
|
||||
}
|
||||
case NS_HTML5TREE_BUILDER_BR: {
|
||||
|
||||
if (inForeign) {
|
||||
if (isInForeign()) {
|
||||
|
||||
while (stack[currentPtr]->ns != kNameSpaceID_XHTML) {
|
||||
pop();
|
||||
}
|
||||
inForeign = PR_FALSE;
|
||||
}
|
||||
reconstructTheActiveFormattingElements();
|
||||
appendVoidElementToCurrentMayFoster(elementName, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
|
||||
@ -2719,9 +2694,6 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
|
||||
}
|
||||
}
|
||||
endtagloop_end: ;
|
||||
if (inForeign && !hasForeignInScope()) {
|
||||
inForeign = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32
|
||||
@ -2811,19 +2783,6 @@ nsHtml5TreeBuilder::findLastInScopeHn()
|
||||
return NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsHtml5TreeBuilder::hasForeignInScope()
|
||||
{
|
||||
for (PRInt32 i = currentPtr; i > 0; i--) {
|
||||
if (stack[i]->ns != kNameSpaceID_XHTML) {
|
||||
return PR_TRUE;
|
||||
} else if (stack[i]->isScoping()) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::generateImpliedEndTagsExceptFor(nsIAtom* name)
|
||||
{
|
||||
@ -2974,7 +2933,6 @@ nsHtml5TreeBuilder::clearStackBackTo(PRInt32 eltPos)
|
||||
void
|
||||
nsHtml5TreeBuilder::resetTheInsertionMode()
|
||||
{
|
||||
inForeign = PR_FALSE;
|
||||
nsHtml5StackNode* node;
|
||||
nsIAtom* name;
|
||||
PRInt32 ns;
|
||||
@ -3013,7 +2971,6 @@ nsHtml5TreeBuilder::resetTheInsertionMode()
|
||||
mode = NS_HTML5TREE_BUILDER_IN_TABLE;
|
||||
return;
|
||||
} else if (kNameSpaceID_XHTML != ns) {
|
||||
inForeign = PR_TRUE;
|
||||
mode = framesetOk ? NS_HTML5TREE_BUILDER_FRAMESET_OK : NS_HTML5TREE_BUILDER_IN_BODY;
|
||||
return;
|
||||
} else if (nsHtml5Atoms::head == name) {
|
||||
@ -3746,9 +3703,9 @@ nsHtml5TreeBuilder::requestSuspension()
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsHtml5TreeBuilder::cdataSectionAllowed()
|
||||
nsHtml5TreeBuilder::isInForeign()
|
||||
{
|
||||
return inForeign && currentPtr >= 0 && stack[currentPtr]->ns != kNameSpaceID_XHTML;
|
||||
return currentPtr >= 0 && stack[currentPtr]->ns != kNameSpaceID_XHTML;
|
||||
}
|
||||
|
||||
void
|
||||
@ -3853,7 +3810,7 @@ nsHtml5TreeBuilder::newSnapshot()
|
||||
stackCopy[i]->retain();
|
||||
}
|
||||
}
|
||||
return new nsHtml5StateSnapshot(stackCopy, listCopy, formPointer, headPointer, deepTreeSurrogateParent, mode, originalMode, framesetOk, inForeign, needToDropLF, quirks);
|
||||
return new nsHtml5StateSnapshot(stackCopy, listCopy, formPointer, headPointer, deepTreeSurrogateParent, mode, originalMode, framesetOk, needToDropLF, quirks);
|
||||
}
|
||||
|
||||
PRBool
|
||||
@ -3863,7 +3820,7 @@ nsHtml5TreeBuilder::snapshotMatches(nsAHtml5TreeBuilderState* snapshot)
|
||||
PRInt32 stackLen = snapshot->getStackLength();
|
||||
jArray<nsHtml5StackNode*,PRInt32> listCopy = snapshot->getListOfActiveFormattingElements();
|
||||
PRInt32 listLen = snapshot->getListOfActiveFormattingElementsLength();
|
||||
if (stackLen != currentPtr + 1 || listLen != listPtr + 1 || formPointer != snapshot->getFormPointer() || headPointer != snapshot->getHeadPointer() || deepTreeSurrogateParent != snapshot->getDeepTreeSurrogateParent() || mode != snapshot->getMode() || originalMode != snapshot->getOriginalMode() || framesetOk != snapshot->isFramesetOk() || inForeign != snapshot->isInForeign() || needToDropLF != snapshot->isNeedToDropLF() || quirks != snapshot->isQuirks()) {
|
||||
if (stackLen != currentPtr + 1 || listLen != listPtr + 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 PR_FALSE;
|
||||
}
|
||||
for (PRInt32 i = listLen - 1; i >= 0; i--) {
|
||||
@ -3933,7 +3890,6 @@ nsHtml5TreeBuilder::loadState(nsAHtml5TreeBuilderState* snapshot, nsHtml5AtomTab
|
||||
mode = snapshot->getMode();
|
||||
originalMode = snapshot->getOriginalMode();
|
||||
framesetOk = snapshot->isFramesetOk();
|
||||
inForeign = snapshot->isInForeign();
|
||||
needToDropLF = snapshot->isNeedToDropLF();
|
||||
quirks = snapshot->isQuirks();
|
||||
}
|
||||
@ -3997,12 +3953,6 @@ nsHtml5TreeBuilder::isFramesetOk()
|
||||
return framesetOk;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsHtml5TreeBuilder::isInForeign()
|
||||
{
|
||||
return inForeign;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsHtml5TreeBuilder::isNeedToDropLF()
|
||||
{
|
||||
|
@ -74,7 +74,6 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
|
||||
PRInt32 mode;
|
||||
PRInt32 originalMode;
|
||||
PRBool framesetOk;
|
||||
PRBool inForeign;
|
||||
protected:
|
||||
nsHtml5Tokenizer* tokenizer;
|
||||
private:
|
||||
@ -121,7 +120,6 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
|
||||
PRInt32 findLastInScope(nsIAtom* name);
|
||||
PRInt32 findLastInListScope(nsIAtom* name);
|
||||
PRInt32 findLastInScopeHn();
|
||||
PRBool hasForeignInScope();
|
||||
void generateImpliedEndTagsExceptFor(nsIAtom* name);
|
||||
void generateImpliedEndTags();
|
||||
PRBool isSecondOnStackBody();
|
||||
@ -212,7 +210,14 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
|
||||
void elementPushed(PRInt32 ns, nsIAtom* name, nsIContent** node);
|
||||
void elementPopped(PRInt32 ns, nsIAtom* name, nsIContent** node);
|
||||
public:
|
||||
PRBool cdataSectionAllowed();
|
||||
inline PRBool cdataSectionAllowed()
|
||||
{
|
||||
return isInForeign();
|
||||
}
|
||||
|
||||
private:
|
||||
PRBool isInForeign();
|
||||
public:
|
||||
void setFragmentContext(nsIAtom* context, PRInt32 ns, nsIContent** node, PRBool quirks);
|
||||
protected:
|
||||
nsIContent** currentNode();
|
||||
@ -237,7 +242,6 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
|
||||
PRInt32 getMode();
|
||||
PRInt32 getOriginalMode();
|
||||
PRBool isFramesetOk();
|
||||
PRBool isInForeign();
|
||||
PRBool isNeedToDropLF();
|
||||
PRBool isQuirks();
|
||||
PRInt32 getListOfActiveFormattingElementsLength();
|
||||
|
@ -7,7 +7,6 @@
|
||||
var html5Exceptions = {
|
||||
"<!doctype html><keygen><frameset>" : true, // Bug 101019
|
||||
"<select><keygen>" : true, // Bug 101019
|
||||
"<math><mi><div><object><div><span></span></div></object></div></mi><mi>" : true, // Bug 606925
|
||||
"<plaintext>\u0000filler\u0000text\u0000" : true, // Bug 612527
|
||||
"<body><svg><foreignObject>\u0000filler\u0000text" : true, // Bug 612527
|
||||
"<svg>\u0000</svg><frameset>" : true, // Bug 612527
|
||||
|
Loading…
Reference in New Issue
Block a user