From ee3abb4e836d4832a5cb9e4ddd7ff45f42b95cf1 Mon Sep 17 00:00:00 2001 From: Henri Sivonen Date: Mon, 1 Oct 2012 11:52:32 +0300 Subject: [PATCH] Bug 503190 - Include assertions in the C++ translator output. r=smaug. --- parser/html/javasrc/ElementName.java | 4 -- parser/html/javasrc/HtmlAttributes.java | 25 ++++--- parser/html/javasrc/Tokenizer.java | 2 +- parser/html/javasrc/TreeBuilder.java | 23 +++---- parser/html/nsHtml5ElementName.cpp | 6 ++ parser/html/nsHtml5ElementName.h | 1 + parser/html/nsHtml5HtmlAttributes.cpp | 14 ++-- parser/html/nsHtml5StackNode.cpp | 4 +- parser/html/nsHtml5Tokenizer.cpp | 4 +- parser/html/nsHtml5TreeBuilder.cpp | 92 ++++++++++++------------- parser/html/nsHtml5TreeBuilder.h | 4 +- 11 files changed, 94 insertions(+), 85 deletions(-) diff --git a/parser/html/javasrc/ElementName.java b/parser/html/javasrc/ElementName.java index 3a29f448ed6f..c5a95e59578c 100644 --- a/parser/html/javasrc/ElementName.java +++ b/parser/html/javasrc/ElementName.java @@ -103,13 +103,9 @@ public final class ElementName return flags & GROUP_MASK; } - // [NOCPP[ - public boolean isCustom() { return (flags & CUSTOM) != 0; } - - // ]NOCPP] static ElementName elementNameByBuffer(@NoLength char[] buf, int offset, int length, Interner interner) { int hash = ElementName.bufToHash(buf, length); diff --git a/parser/html/javasrc/HtmlAttributes.java b/parser/html/javasrc/HtmlAttributes.java index 292effaeacca..b8112fd8b288 100644 --- a/parser/html/javasrc/HtmlAttributes.java +++ b/parser/html/javasrc/HtmlAttributes.java @@ -505,25 +505,32 @@ public final class HtmlAttributes implements Attributes { mode = AttributeName.SVG; } - public HtmlAttributes cloneAttributes(Interner interner) throws SAXException { - assert (length == 0 && xmlnsLength == 0) || mode == 0 || mode == 3; + public HtmlAttributes cloneAttributes(Interner interner) + throws SAXException { + assert (length == 0 + // [NOCPP[ + && xmlnsLength == 0 + // ]NOCPP] + ) + || mode == 0 || mode == 3; HtmlAttributes clone = new HtmlAttributes(0); for (int i = 0; i < length; i++) { - clone.addAttribute(names[i].cloneAttributeName(interner), Portability.newStringFromString(values[i]) - // [NOCPP[ - , XmlViolationPolicy.ALLOW - // ]NOCPP] + clone.addAttribute(names[i].cloneAttributeName(interner), + Portability.newStringFromString(values[i]) + // [NOCPP[ + , XmlViolationPolicy.ALLOW + // ]NOCPP] ); } // [NOCPP[ for (int i = 0; i < xmlnsLength; i++) { - clone.addAttribute(xmlnsNames[i], - xmlnsValues[i], XmlViolationPolicy.ALLOW); + clone.addAttribute(xmlnsNames[i], xmlnsValues[i], + XmlViolationPolicy.ALLOW); } // ]NOCPP] return clone; // XXX!!! } - + public boolean equalsAnother(HtmlAttributes other) { assert mode == 0 || mode == 3 : "Trying to compare attributes in foreign content."; int otherLength = other.getLength(); diff --git a/parser/html/javasrc/Tokenizer.java b/parser/html/javasrc/Tokenizer.java index 62468cbff025..2ca48e0f4116 100644 --- a/parser/html/javasrc/Tokenizer.java +++ b/parser/html/javasrc/Tokenizer.java @@ -4243,7 +4243,7 @@ public class Tokenizer implements Locator { break stateloop; } c = checkChar(buf, pos); - assert (index > 0); + assert index > 0; if (index < 6) { // SCRIPT_ARR.length char folded = c; if (c >= 'A' && c <= 'Z') { diff --git a/parser/html/javasrc/TreeBuilder.java b/parser/html/javasrc/TreeBuilder.java index 0487b988830f..8fb2b37459c7 100644 --- a/parser/html/javasrc/TreeBuilder.java +++ b/parser/html/javasrc/TreeBuilder.java @@ -798,10 +798,9 @@ public abstract class TreeBuilder implements TokenHandler, if (!"http://www.w3.org/TR/html4/strict.dtd".equals(systemIdentifier)) { warn("The doctype did not contain the system identifier prescribed by the HTML 4.01 specification. Expected \u201C\u201D."); } - } else { - if (!(publicIdentifier == null && systemIdentifier == null)) { - err("Legacy doctype. Expected e.g. \u201C\u201D."); - } + } else if (!((systemIdentifier == null || Portability.literalEqualsString( + "about:legacy-compat", systemIdentifier)) && publicIdentifier == null)) { + err("Legacy doctype. Expected e.g. \u201C\u201D."); } documentModeInternal( DocumentMode.STANDARDS_MODE, @@ -4182,12 +4181,12 @@ public abstract class TreeBuilder implements TokenHandler, } } - private boolean clearLastStackSlot() { + private boolean debugOnlyClearLastStackSlot() { stack[currentPtr] = null; return true; } - private boolean clearLastListSlot() { + private boolean debugOnlyClearLastListSlot() { listOfActiveFormattingElements[listPtr] = null; return true; } @@ -4250,7 +4249,7 @@ public abstract class TreeBuilder implements TokenHandler, fatal(); stack[pos].release(); System.arraycopy(stack, pos + 1, stack, pos, currentPtr - pos); - assert clearLastStackSlot(); + assert debugOnlyClearLastStackSlot(); currentPtr--; } } @@ -4278,14 +4277,14 @@ public abstract class TreeBuilder implements TokenHandler, assert listOfActiveFormattingElements[pos] != null; listOfActiveFormattingElements[pos].release(); if (pos == listPtr) { - assert clearLastListSlot(); + assert debugOnlyClearLastListSlot(); listPtr--; return; } assert pos < listPtr; System.arraycopy(listOfActiveFormattingElements, pos + 1, listOfActiveFormattingElements, pos, listPtr - pos); - assert clearLastListSlot(); + assert debugOnlyClearLastListSlot(); listPtr--; } @@ -4655,7 +4654,7 @@ public abstract class TreeBuilder implements TokenHandler, private void pop() throws SAXException { StackNode node = stack[currentPtr]; - assert clearLastStackSlot(); + assert debugOnlyClearLastStackSlot(); currentPtr--; elementPopped(node.ns, node.popName, node.node); node.release(); @@ -4663,14 +4662,14 @@ public abstract class TreeBuilder implements TokenHandler, private void silentPop() throws SAXException { StackNode node = stack[currentPtr]; - assert clearLastStackSlot(); + assert debugOnlyClearLastStackSlot(); currentPtr--; node.release(); } private void popOnEof() throws SAXException { StackNode node = stack[currentPtr]; - assert clearLastStackSlot(); + assert debugOnlyClearLastStackSlot(); currentPtr--; markMalformedIfScript(node.node); elementPopped(node.ns, node.popName, node.node); diff --git a/parser/html/nsHtml5ElementName.cpp b/parser/html/nsHtml5ElementName.cpp index 6665d6d3d648..376f9573c4f0 100644 --- a/parser/html/nsHtml5ElementName.cpp +++ b/parser/html/nsHtml5ElementName.cpp @@ -62,6 +62,12 @@ nsHtml5ElementName::getGroup() return flags & NS_HTML5ELEMENT_NAME_GROUP_MASK; } +bool +nsHtml5ElementName::isCustom() +{ + return (flags & NS_HTML5ELEMENT_NAME_CUSTOM); +} + nsHtml5ElementName* nsHtml5ElementName::elementNameByBuffer(PRUnichar* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner) { diff --git a/parser/html/nsHtml5ElementName.h b/parser/html/nsHtml5ElementName.h index b0a868a36492..12f3c805bb9a 100644 --- a/parser/html/nsHtml5ElementName.h +++ b/parser/html/nsHtml5ElementName.h @@ -68,6 +68,7 @@ class nsHtml5ElementName } int32_t getGroup(); + bool isCustom(); static nsHtml5ElementName* elementNameByBuffer(PRUnichar* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner); private: static int32_t bufToHash(PRUnichar* buf, int32_t len); diff --git a/parser/html/nsHtml5HtmlAttributes.cpp b/parser/html/nsHtml5HtmlAttributes.cpp index 222566af38a2..0b95bca5cd1a 100644 --- a/parser/html/nsHtml5HtmlAttributes.cpp +++ b/parser/html/nsHtml5HtmlAttributes.cpp @@ -104,35 +104,35 @@ nsHtml5HtmlAttributes::getLength() nsIAtom* nsHtml5HtmlAttributes::getLocalNameNoBoundsCheck(int32_t index) { - + MOZ_ASSERT(index < length && index >= 0, "Index out of bounds"); return names[index]->getLocal(mode); } int32_t nsHtml5HtmlAttributes::getURINoBoundsCheck(int32_t index) { - + MOZ_ASSERT(index < length && index >= 0, "Index out of bounds"); return names[index]->getUri(mode); } nsIAtom* nsHtml5HtmlAttributes::getPrefixNoBoundsCheck(int32_t index) { - + MOZ_ASSERT(index < length && index >= 0, "Index out of bounds"); return names[index]->getPrefix(mode); } nsString* nsHtml5HtmlAttributes::getValueNoBoundsCheck(int32_t index) { - + MOZ_ASSERT(index < length && index >= 0, "Index out of bounds"); return values[index]; } nsHtml5AttributeName* nsHtml5HtmlAttributes::getAttributeNameNoBoundsCheck(int32_t index) { - + MOZ_ASSERT(index < length && index >= 0, "Index out of bounds"); return names[index]; } @@ -208,7 +208,7 @@ nsHtml5HtmlAttributes::adjustForSvg() nsHtml5HtmlAttributes* nsHtml5HtmlAttributes::cloneAttributes(nsHtml5AtomTable* interner) { - + MOZ_ASSERT((!length) || !mode || mode == 3); nsHtml5HtmlAttributes* clone = new nsHtml5HtmlAttributes(0); for (int32_t i = 0; i < length; i++) { clone->addAttribute(names[i]->cloneAttributeName(interner), nsHtml5Portability::newStringFromString(values[i])); @@ -219,7 +219,7 @@ nsHtml5HtmlAttributes::cloneAttributes(nsHtml5AtomTable* interner) bool nsHtml5HtmlAttributes::equalsAnother(nsHtml5HtmlAttributes* other) { - + MOZ_ASSERT(!mode || mode == 3, "Trying to compare attributes in foreign content."); int32_t otherLength = other->getLength(); if (length != otherLength) { return false; diff --git a/parser/html/nsHtml5StackNode.cpp b/parser/html/nsHtml5StackNode.cpp index 97966a76d926..6077e5d9f13e 100644 --- a/parser/html/nsHtml5StackNode.cpp +++ b/parser/html/nsHtml5StackNode.cpp @@ -109,7 +109,7 @@ nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** refcount(1) { MOZ_COUNT_CTOR(nsHtml5StackNode); - + MOZ_ASSERT(!elementName->isCustom(), "Don't use this constructor for custom elements."); } @@ -123,7 +123,7 @@ nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** refcount(1) { MOZ_COUNT_CTOR(nsHtml5StackNode); - + MOZ_ASSERT(!elementName->isCustom(), "Don't use this constructor for custom elements."); } diff --git a/parser/html/nsHtml5Tokenizer.cpp b/parser/html/nsHtml5Tokenizer.cpp index bf4ffaa834a2..a431fbee5839 100644 --- a/parser/html/nsHtml5Tokenizer.cpp +++ b/parser/html/nsHtml5Tokenizer.cpp @@ -189,7 +189,7 @@ nsHtml5Tokenizer::endTagExpectationToArray() return; } default: { - + MOZ_ASSERT(false, "Bad end tag expectation."); return; } } @@ -2401,7 +2401,7 @@ nsHtml5Tokenizer::stateLoop(int32_t state, PRUnichar c, int32_t pos, PRUnichar* NS_HTML5_BREAK(stateloop); } c = checkChar(buf, pos); - + MOZ_ASSERT(index > 0); if (index < 6) { PRUnichar folded = c; if (c >= 'A' && c <= 'Z') { diff --git a/parser/html/nsHtml5TreeBuilder.cpp b/parser/html/nsHtml5TreeBuilder.cpp index 2e0f333e9650..df52ca5160af 100644 --- a/parser/html/nsHtml5TreeBuilder.cpp +++ b/parser/html/nsHtml5TreeBuilder.cpp @@ -489,7 +489,7 @@ nsHtml5TreeBuilder::eof() } case NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP: { if (!currentPtr) { - + MOZ_ASSERT(fragment); NS_HTML5_BREAK(eofloop); } else { popOnEof(); @@ -688,7 +688,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu case NS_HTML5TREE_BUILDER_TR: { eltPos = findLastOrRoot(NS_HTML5TREE_BUILDER_TR); if (!eltPos) { - + MOZ_ASSERT(fragment); errNoTableRowToClose(); NS_HTML5_BREAK(starttagloop); } @@ -743,7 +743,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu errTableSeenWhileTableOpen(); eltPos = findLastInTableScope(name); if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) { - + MOZ_ASSERT(fragment); NS_HTML5_BREAK(starttagloop); } generateImpliedEndTags(); @@ -854,7 +854,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu case NS_HTML5TREE_BUILDER_FRAMESET: { if (mode == NS_HTML5TREE_BUILDER_FRAMESET_OK) { if (!currentPtr || stack[1]->getGroup() != NS_HTML5TREE_BUILDER_BODY) { - + MOZ_ASSERT(fragment); errStrayStartTag(name); NS_HTML5_BREAK(starttagloop); } else { @@ -921,7 +921,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu } case NS_HTML5TREE_BUILDER_BODY: { if (!currentPtr || stack[1]->getGroup() != NS_HTML5TREE_BUILDER_BODY) { - + MOZ_ASSERT(fragment); errStrayStartTag(name); NS_HTML5_BREAK(starttagloop); } @@ -1438,7 +1438,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu } default: { if (!currentPtr) { - + MOZ_ASSERT(fragment); errGarbageInColgroup(); NS_HTML5_BREAK(starttagloop); } @@ -1458,7 +1458,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu errStartTagWithSelectOpen(name); eltPos = findLastInTableScope(nsHtml5Atoms::select); if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) { - + MOZ_ASSERT(fragment); NS_HTML5_BREAK(starttagloop); } while (currentPtr >= eltPos) { @@ -1504,7 +1504,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu errStartSelectWhereEndSelectExpected(); eltPos = findLastInTableScope(name); if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) { - + MOZ_ASSERT(fragment); errNoSelectInTableScope(); NS_HTML5_BREAK(starttagloop); } else { @@ -1521,7 +1521,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu errStartTagWithSelectOpen(name); eltPos = findLastInTableScope(nsHtml5Atoms::select); if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) { - + MOZ_ASSERT(fragment); NS_HTML5_BREAK(starttagloop); } while (currentPtr >= eltPos) { @@ -1790,7 +1790,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu } } case NS_HTML5TREE_BUILDER_TEXT: { - + MOZ_ASSERT(false); NS_HTML5_BREAK(starttagloop); } } @@ -2064,7 +2064,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName) case NS_HTML5TREE_BUILDER_TR: { eltPos = findLastOrRoot(NS_HTML5TREE_BUILDER_TR); if (!eltPos) { - + MOZ_ASSERT(fragment); errNoTableRowToClose(); NS_HTML5_BREAK(endtagloop); } @@ -2076,7 +2076,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName) case NS_HTML5TREE_BUILDER_TABLE: { eltPos = findLastOrRoot(NS_HTML5TREE_BUILDER_TR); if (!eltPos) { - + MOZ_ASSERT(fragment); errNoTableRowToClose(); NS_HTML5_BREAK(endtagloop); } @@ -2092,7 +2092,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName) } eltPos = findLastOrRoot(NS_HTML5TREE_BUILDER_TR); if (!eltPos) { - + MOZ_ASSERT(fragment); errNoTableRowToClose(); NS_HTML5_BREAK(endtagloop); } @@ -2130,7 +2130,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName) case NS_HTML5TREE_BUILDER_TABLE: { eltPos = findLastInTableScopeOrRootTbodyTheadTfoot(); if (!eltPos) { - + MOZ_ASSERT(fragment); errStrayEndTag(name); NS_HTML5_BREAK(endtagloop); } @@ -2158,7 +2158,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName) case NS_HTML5TREE_BUILDER_TABLE: { eltPos = findLast(nsHtml5Atoms::table); if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) { - + MOZ_ASSERT(fragment); errStrayEndTag(name); NS_HTML5_BREAK(endtagloop); } @@ -2279,11 +2279,11 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName) switch(group) { case NS_HTML5TREE_BUILDER_BODY: { if (!isSecondOnStackBody()) { - + MOZ_ASSERT(fragment); errStrayEndTag(name); NS_HTML5_BREAK(endtagloop); } - + MOZ_ASSERT(currentPtr >= 1); if (NS_UNLIKELY(mViewSource)) { for (int32_t i = 2; i <= currentPtr; i++) { switch(stack[i]->getGroup()) { @@ -2310,7 +2310,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName) } case NS_HTML5TREE_BUILDER_HTML: { if (!isSecondOnStackBody()) { - + MOZ_ASSERT(fragment); errStrayEndTag(name); NS_HTML5_BREAK(endtagloop); } @@ -2389,7 +2389,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName) NS_HTML5_BREAK(endtagloop); } generateImpliedEndTagsExceptFor(nsHtml5Atoms::p); - + MOZ_ASSERT(eltPos != NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK); if (!!NS_UNLIKELY(mViewSource) && eltPos != currentPtr) { errUnclosedElements(eltPos, name); } @@ -2537,7 +2537,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName) switch(group) { case NS_HTML5TREE_BUILDER_COLGROUP: { if (!currentPtr) { - + MOZ_ASSERT(fragment); errGarbageInColgroup(); NS_HTML5_BREAK(endtagloop); } @@ -2551,7 +2551,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName) } default: { if (!currentPtr) { - + MOZ_ASSERT(fragment); errGarbageInColgroup(); NS_HTML5_BREAK(endtagloop); } @@ -2572,7 +2572,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName) if (findLastInTableScope(name) != NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) { eltPos = findLastInTableScope(nsHtml5Atoms::select); if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) { - + MOZ_ASSERT(fragment); NS_HTML5_BREAK(endtagloop); } while (currentPtr >= eltPos) { @@ -2613,7 +2613,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName) case NS_HTML5TREE_BUILDER_SELECT: { eltPos = findLastInTableScope(nsHtml5Atoms::select); if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) { - + MOZ_ASSERT(fragment); errStrayEndTag(name); NS_HTML5_BREAK(endtagloop); } @@ -2651,7 +2651,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName) switch(group) { case NS_HTML5TREE_BUILDER_FRAMESET: { if (!currentPtr) { - + MOZ_ASSERT(fragment); errStrayEndTag(name); NS_HTML5_BREAK(endtagloop); } @@ -3113,14 +3113,14 @@ nsHtml5TreeBuilder::implicitlyCloseP() } bool -nsHtml5TreeBuilder::clearLastStackSlot() +nsHtml5TreeBuilder::debugOnlyClearLastStackSlot() { stack[currentPtr] = nullptr; return true; } bool -nsHtml5TreeBuilder::clearLastListSlot() +nsHtml5TreeBuilder::debugOnlyClearLastListSlot() { listOfActiveFormattingElements[listPtr] = nullptr; return true; @@ -3185,7 +3185,7 @@ nsHtml5TreeBuilder::removeFromStack(int32_t pos) stack[pos]->release(); nsHtml5ArrayCopy::arraycopy(stack, pos + 1, pos, currentPtr - pos); - + MOZ_ASSERT(debugOnlyClearLastStackSlot()); currentPtr--; } } @@ -3213,16 +3213,16 @@ nsHtml5TreeBuilder::removeFromStack(nsHtml5StackNode* node) void nsHtml5TreeBuilder::removeFromListOfActiveFormattingElements(int32_t pos) { - + MOZ_ASSERT(!!listOfActiveFormattingElements[pos]); listOfActiveFormattingElements[pos]->release(); if (pos == listPtr) { - + MOZ_ASSERT(debugOnlyClearLastListSlot()); listPtr--; return; } - + MOZ_ASSERT(pos < listPtr); nsHtml5ArrayCopy::arraycopy(listOfActiveFormattingElements, pos + 1, pos, listPtr - pos); - + MOZ_ASSERT(debugOnlyClearLastListSlot()); listPtr--; } @@ -3293,9 +3293,9 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag(nsIAtom* name) nsHtml5StackNode* node = stack[nodePos]; int32_t nodeListPos = findInListOfActiveFormattingElements(node); if (nodeListPos == -1) { - - - + MOZ_ASSERT(formattingEltStackPos < nodePos); + MOZ_ASSERT(bookmark < nodePos); + MOZ_ASSERT(furthestBlockPos > nodePos); removeFromStack(nodePos); furthestBlockPos--; continue; @@ -3306,8 +3306,8 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag(nsIAtom* name) if (nodePos == furthestBlockPos) { bookmark = nodeListPos + 1; } - - + MOZ_ASSERT(node == listOfActiveFormattingElements[nodeListPos]); + MOZ_ASSERT(node == stack[nodePos]); nsIContent** clone = createElement(kNameSpaceID_XHTML, node->name, node->attributes->cloneAttributes(nullptr)); nsHtml5StackNode* newNode = new nsHtml5StackNode(node->getFlags(), node->ns, node->name, clone, node->popName, node->attributes); node->dropAttributes(); @@ -3336,7 +3336,7 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag(nsIAtom* name) appendElement(clone, furthestBlock->node); removeFromListOfActiveFormattingElements(formattingEltListPos); insertIntoListOfActiveFormattingElements(formattingClone, bookmark); - + MOZ_ASSERT(formattingEltStackPos < furthestBlockPos); removeFromStack(formattingEltStackPos); insertIntoStack(formattingClone, furthestBlockPos); } @@ -3346,8 +3346,8 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag(nsIAtom* name) void nsHtml5TreeBuilder::insertIntoStack(nsHtml5StackNode* node, int32_t position) { - - + MOZ_ASSERT(currentPtr + 1 < stack.length); + MOZ_ASSERT(position <= currentPtr + 1); if (position == currentPtr + 1) { push(node); } else { @@ -3361,7 +3361,7 @@ void nsHtml5TreeBuilder::insertIntoListOfActiveFormattingElements(nsHtml5StackNode* formattingClone, int32_t bookmark) { formattingClone->retain(); - + MOZ_ASSERT(listPtr + 1 < listOfActiveFormattingElements.length); if (bookmark <= listPtr) { nsHtml5ArrayCopy::arraycopy(listOfActiveFormattingElements, bookmark, bookmark + 1, (listPtr - bookmark) + 1); } @@ -3458,9 +3458,9 @@ nsHtml5TreeBuilder::addAttributesToHtml(nsHtml5HtmlAttributes* attributes) void nsHtml5TreeBuilder::pushHeadPointerOntoStack() { - - - + MOZ_ASSERT(!!headPointer); + MOZ_ASSERT(!fragment); + MOZ_ASSERT(mode == NS_HTML5TREE_BUILDER_AFTER_HEAD); silentPush(new nsHtml5StackNode(nsHtml5ElementName::ELT_HEAD, headPointer)); } @@ -3535,7 +3535,7 @@ void nsHtml5TreeBuilder::pop() { nsHtml5StackNode* node = stack[currentPtr]; - + MOZ_ASSERT(debugOnlyClearLastStackSlot()); currentPtr--; elementPopped(node->ns, node->popName, node->node); node->release(); @@ -3545,7 +3545,7 @@ void nsHtml5TreeBuilder::silentPop() { nsHtml5StackNode* node = stack[currentPtr]; - + MOZ_ASSERT(debugOnlyClearLastStackSlot()); currentPtr--; node->release(); } @@ -3554,7 +3554,7 @@ void nsHtml5TreeBuilder::popOnEof() { nsHtml5StackNode* node = stack[currentPtr]; - + MOZ_ASSERT(debugOnlyClearLastStackSlot()); currentPtr--; markMalformedIfScript(node->node); elementPopped(node->ns, node->popName, node->node); diff --git a/parser/html/nsHtml5TreeBuilder.h b/parser/html/nsHtml5TreeBuilder.h index 29859b497a68..26e7944ed2f2 100644 --- a/parser/html/nsHtml5TreeBuilder.h +++ b/parser/html/nsHtml5TreeBuilder.h @@ -131,8 +131,8 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState void clearStackBackTo(int32_t eltPos); void resetTheInsertionMode(); void implicitlyCloseP(); - bool clearLastStackSlot(); - bool clearLastListSlot(); + bool debugOnlyClearLastStackSlot(); + bool debugOnlyClearLastListSlot(); void push(nsHtml5StackNode* node); void silentPush(nsHtml5StackNode* node); void append(nsHtml5StackNode* node);