Bug 1506133 - More HTML parser cleanup post bug 1392185. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D11480
This commit is contained in:
@@ -66,10 +66,6 @@ public final class Portability {
|
||||
return string.toCharArray();
|
||||
}
|
||||
|
||||
public static @Local String newLocalFromLocal(@Local String local, Interner interner) {
|
||||
return local;
|
||||
}
|
||||
|
||||
// Deallocation methods
|
||||
|
||||
public static void releaseString(String str) {
|
||||
|
||||
@@ -6859,13 +6859,7 @@ public class Tokenizer implements Locator {
|
||||
seenDigits = other.seenDigits;
|
||||
endTag = other.endTag;
|
||||
shouldSuspend = false;
|
||||
|
||||
if (other.doctypeName == null) {
|
||||
doctypeName = null;
|
||||
} else {
|
||||
doctypeName = Portability.newLocalFromLocal(other.doctypeName,
|
||||
interner);
|
||||
}
|
||||
doctypeName = other.doctypeName;
|
||||
|
||||
Portability.releaseString(systemIdentifier);
|
||||
if (other.systemIdentifier == null) {
|
||||
@@ -6890,7 +6884,7 @@ public class Tokenizer implements Locator {
|
||||
// In the C++ case, the atoms in the other tokenizer are from a
|
||||
// different tokenizer-scoped atom table. Therefore, we have to
|
||||
// obtain the correspoding atom from our own atom table.
|
||||
nonInternedTagName.setNameForNonInterned(Portability.newLocalFromLocal(other.tagName.getName(), interner)
|
||||
nonInternedTagName.setNameForNonInterned(other.tagName.getName()
|
||||
// CPPONLY: , other.tagName.isCustom()
|
||||
);
|
||||
tagName = nonInternedTagName;
|
||||
@@ -6907,7 +6901,7 @@ public class Tokenizer implements Locator {
|
||||
// CPPONLY: // In the C++ case, the atoms in the other tokenizer are from a
|
||||
// CPPONLY: // different tokenizer-scoped atom table. Therefore, we have to
|
||||
// CPPONLY: // obtain the correspoding atom from our own atom table.
|
||||
// CPPONLY: nonInternedAttributeName.setNameForNonInterned(Portability.newLocalFromLocal(other.attributeName.getLocal(AttributeName.HTML), interner));
|
||||
// CPPONLY: nonInternedAttributeName.setNameForNonInterned(other.attributeName.getLocal(AttributeName.HTML));
|
||||
// CPPONLY: attributeName = nonInternedAttributeName;
|
||||
// CPPONLY: }
|
||||
|
||||
@@ -6915,7 +6909,7 @@ public class Tokenizer implements Locator {
|
||||
if (other.attributes == null) {
|
||||
attributes = null;
|
||||
} else {
|
||||
attributes = other.attributes.cloneAttributes(interner);
|
||||
attributes = other.attributes.cloneAttributes();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7151,8 +7145,9 @@ public class Tokenizer implements Locator {
|
||||
|
||||
void destructor() {
|
||||
Portability.delete(nonInternedTagName);
|
||||
// CPPONLY: Portability.delete(nonInternedAttributeName);
|
||||
nonInternedTagName = null;
|
||||
// CPPONLY: Portability.delete(nonInternedAttributeName);
|
||||
// CPPONLY: nonInternedAttributeName = null;
|
||||
// The translator will write refcount tracing stuff here
|
||||
Portability.delete(attributes);
|
||||
attributes = null;
|
||||
|
||||
@@ -4786,7 +4786,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), commonAncestor.node
|
||||
node.name, node.attributes.cloneAttributes(), commonAncestor.node
|
||||
// CPPONLY: , htmlCreator(node.getHtmlCreator())
|
||||
);
|
||||
StackNode<T> newNode = createStackNode(node.getFlags(), node.ns,
|
||||
@@ -4818,7 +4818,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
}
|
||||
T clone = createElement("http://www.w3.org/1999/xhtml",
|
||||
formattingElt.name,
|
||||
formattingElt.attributes.cloneAttributes(null), furthestBlock.node
|
||||
formattingElt.attributes.cloneAttributes(), furthestBlock.node
|
||||
// CPPONLY: , htmlCreator(formattingElt.getHtmlCreator())
|
||||
);
|
||||
StackNode<T> formattingClone = createStackNode(
|
||||
@@ -5005,12 +5005,12 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
T clone;
|
||||
if (currentNode.isFosterParenting()) {
|
||||
clone = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", entry.name,
|
||||
entry.attributes.cloneAttributes(null)
|
||||
entry.attributes.cloneAttributes()
|
||||
// CPPONLY: , htmlCreator(entry.getHtmlCreator())
|
||||
);
|
||||
} else {
|
||||
clone = createElement("http://www.w3.org/1999/xhtml", entry.name,
|
||||
entry.attributes.cloneAttributes(null), currentNode.node
|
||||
entry.attributes.cloneAttributes(), currentNode.node
|
||||
// CPPONLY: , htmlCreator(entry.getHtmlCreator())
|
||||
);
|
||||
appendElement(clone, currentNode.node);
|
||||
@@ -5424,7 +5424,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
|
||||
HtmlAttributes clone = attributes.cloneAttributes(null);
|
||||
HtmlAttributes clone = attributes.cloneAttributes();
|
||||
// Attributes must not be read after calling createElement, because
|
||||
// createElement may delete attributes in C++.
|
||||
T elt;
|
||||
@@ -6130,7 +6130,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
StackNode<T> newNode = new StackNode<T>(-1);
|
||||
newNode.setValues(node.getFlags(), node.ns,
|
||||
node.name, node.node, node.popName,
|
||||
node.attributes.cloneAttributes(null)
|
||||
node.attributes.cloneAttributes()
|
||||
// CPPONLY: , node.getHtmlCreator()
|
||||
// [NOCPP[
|
||||
, node.getLocator()
|
||||
@@ -6217,7 +6217,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked") public void loadState(
|
||||
TreeBuilderState<T> snapshot, Interner interner)
|
||||
TreeBuilderState<T> snapshot)
|
||||
throws SAXException {
|
||||
// CPPONLY: mCurrentHtmlScriptIsAsyncOrDefer = false;
|
||||
StackNode<T>[] stackCopy = snapshot.getStack();
|
||||
@@ -6254,9 +6254,9 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
StackNode<T> node = listCopy[i];
|
||||
if (node != null) {
|
||||
StackNode<T> newNode = createStackNode(node.getFlags(), node.ns,
|
||||
Portability.newLocalFromLocal(node.name, interner), node.node,
|
||||
Portability.newLocalFromLocal(node.popName, interner),
|
||||
node.attributes.cloneAttributes(null)
|
||||
node.name, node.node,
|
||||
node.popName,
|
||||
node.attributes.cloneAttributes()
|
||||
// CPPONLY: , node.getHtmlCreator()
|
||||
// [NOCPP[
|
||||
, node.getLocator()
|
||||
@@ -6272,8 +6272,8 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
int listIndex = findInArray(node, listCopy);
|
||||
if (listIndex == -1) {
|
||||
StackNode<T> newNode = createStackNode(node.getFlags(), node.ns,
|
||||
Portability.newLocalFromLocal(node.name, interner), node.node,
|
||||
Portability.newLocalFromLocal(node.popName, interner),
|
||||
node.name, node.node,
|
||||
node.popName,
|
||||
null
|
||||
// CPPONLY: , node.getHtmlCreator()
|
||||
// [NOCPP[
|
||||
|
||||
@@ -57,26 +57,12 @@ public:
|
||||
|
||||
inline void ReleaseValue() { mValue.Release(); }
|
||||
|
||||
inline nsHtml5AttributeEntry Clone(nsHtml5AtomTable* aInterner)
|
||||
inline nsHtml5AttributeEntry Clone()
|
||||
{
|
||||
// Copy the memory
|
||||
nsHtml5AttributeEntry clone(*this);
|
||||
// Increment refcount for value
|
||||
clone.mValue = this->mValue.Clone();
|
||||
if (aInterner) {
|
||||
// Now if we have an interner, we'll need to rewrite non-static atoms.
|
||||
// Only the local names may be non-static, in which case all three
|
||||
// are the same.
|
||||
nsAtom* local = GetLocal(0);
|
||||
if (!local->IsStatic()) {
|
||||
nsAutoString str;
|
||||
local->ToString(str);
|
||||
nsAtom* local = aInterner->GetAtom(str);
|
||||
clone.mLocals[0] = local;
|
||||
clone.mLocals[1] = local;
|
||||
clone.mLocals[2] = local;
|
||||
}
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,6 @@ private:
|
||||
static int32_t* XLINK_NS;
|
||||
public:
|
||||
static nsStaticAtom** ALL_NO_PREFIX;
|
||||
|
||||
private:
|
||||
static nsStaticAtom** XMLNS_PREFIX;
|
||||
static nsStaticAtom** XLINK_PREFIX;
|
||||
@@ -72,7 +71,6 @@ private:
|
||||
static RefPtr<nsAtom>* SVG_DIFFERENT(nsAtom* name, nsAtom* camel);
|
||||
static RefPtr<nsAtom>* MATH_DIFFERENT(nsAtom* name, nsAtom* camel);
|
||||
static RefPtr<nsAtom>* COLONIFIED_LOCAL(nsAtom* name, nsAtom* suffix);
|
||||
|
||||
public:
|
||||
static RefPtr<nsAtom>* SAME_LOCAL(nsAtom* name);
|
||||
inline static int32_t levelOrderBinarySearch(jArray<int32_t, int32_t> data,
|
||||
|
||||
@@ -200,13 +200,13 @@ nsHtml5HtmlAttributes::adjustForSvg()
|
||||
}
|
||||
|
||||
nsHtml5HtmlAttributes*
|
||||
nsHtml5HtmlAttributes::cloneAttributes(nsHtml5AtomTable* aInterner)
|
||||
nsHtml5HtmlAttributes::cloneAttributes()
|
||||
{
|
||||
MOZ_ASSERT(mStorage.IsEmpty() || !mMode);
|
||||
nsHtml5HtmlAttributes* clone =
|
||||
new nsHtml5HtmlAttributes(nsHtml5AttributeName::HTML);
|
||||
for (nsHtml5AttributeEntry& entry : mStorage) {
|
||||
clone->AddEntry(entry.Clone(aInterner));
|
||||
clone->AddEntry(entry.Clone());
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
bool contains(nsHtml5AttributeName* aName);
|
||||
void adjustForMath();
|
||||
void adjustForSvg();
|
||||
nsHtml5HtmlAttributes* cloneAttributes(nsHtml5AtomTable* aInterner);
|
||||
nsHtml5HtmlAttributes* cloneAttributes();
|
||||
bool equalsAnother(nsHtml5HtmlAttributes* aOther);
|
||||
static void initializeStatics();
|
||||
static void releaseStatics();
|
||||
|
||||
@@ -478,7 +478,7 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
|
||||
mDocWriteSpeculativeTokenizer->start();
|
||||
}
|
||||
mDocWriteSpeculativeTokenizer->resetToDataState();
|
||||
mDocWriteSpeculativeTreeBuilder->loadState(mTreeBuilder, &mAtomTable);
|
||||
mDocWriteSpeculativeTreeBuilder->loadState(mTreeBuilder);
|
||||
mDocWriteSpeculativeLastWasCR = false;
|
||||
}
|
||||
|
||||
@@ -752,7 +752,7 @@ nsHtml5Parser::InitializeDocWriteParserState(nsAHtml5TreeBuilderState* aState,
|
||||
{
|
||||
mTokenizer->resetToDataState();
|
||||
mTokenizer->setLineNumber(aLine);
|
||||
mTreeBuilder->loadState(aState, &mAtomTable);
|
||||
mTreeBuilder->loadState(aState);
|
||||
mLastWasCR = false;
|
||||
mReturnToStreamParserPermitted = true;
|
||||
}
|
||||
|
||||
@@ -17,14 +17,6 @@ nsHtml5Portability::newLocalNameFromBuffer(char16_t* buf,
|
||||
return interner->GetAtom(nsDependentSubstring(buf, buf + length));
|
||||
}
|
||||
|
||||
nsAtom*
|
||||
nsHtml5Portability::newLocalFromLocal(nsAtom* local,
|
||||
nsHtml5AtomTable* interner)
|
||||
{
|
||||
// FIXME(emilio): This function should be removed.
|
||||
return local;
|
||||
}
|
||||
|
||||
static bool
|
||||
ContainsWhiteSpace(mozilla::Span<char16_t> aSpan)
|
||||
{
|
||||
|
||||
@@ -69,7 +69,6 @@ public:
|
||||
static nsHtml5String newStringFromString(nsHtml5String string);
|
||||
static jArray<char16_t, int32_t> newCharArrayFromLocal(nsAtom* local);
|
||||
static jArray<char16_t, int32_t> newCharArrayFromString(nsHtml5String string);
|
||||
static nsAtom* newLocalFromLocal(nsAtom* local, nsHtml5AtomTable* interner);
|
||||
static bool localEqualsBuffer(nsAtom* local, char16_t* buf, int32_t length);
|
||||
static bool lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString(
|
||||
const char* lowerCaseLiteral,
|
||||
|
||||
@@ -1685,7 +1685,7 @@ nsHtml5StreamParser::ContinueAfterScripts(nsHtml5Tokenizer* aTokenizer,
|
||||
// Copy state over
|
||||
mLastWasCR = aLastWasCR;
|
||||
mTokenizer->loadState(aTokenizer);
|
||||
mTreeBuilder->loadState(aTreeBuilder, &mAtomTable);
|
||||
mTreeBuilder->loadState(aTreeBuilder);
|
||||
} else {
|
||||
// We've got a successful speculation and at least a moment ago it was
|
||||
// the current speculation
|
||||
|
||||
@@ -4793,12 +4793,7 @@ nsHtml5Tokenizer::loadState(nsHtml5Tokenizer* other)
|
||||
seenDigits = other->seenDigits;
|
||||
endTag = other->endTag;
|
||||
shouldSuspend = false;
|
||||
if (!other->doctypeName) {
|
||||
doctypeName = nullptr;
|
||||
} else {
|
||||
doctypeName =
|
||||
nsHtml5Portability::newLocalFromLocal(other->doctypeName, interner);
|
||||
}
|
||||
doctypeName = other->doctypeName;
|
||||
systemIdentifier.Release();
|
||||
if (!other->systemIdentifier) {
|
||||
systemIdentifier = nullptr;
|
||||
@@ -4819,9 +4814,7 @@ nsHtml5Tokenizer::loadState(nsHtml5Tokenizer* other)
|
||||
} else if (other->tagName->isInterned()) {
|
||||
tagName = other->tagName;
|
||||
} else {
|
||||
nonInternedTagName->setNameForNonInterned(
|
||||
nsHtml5Portability::newLocalFromLocal(other->tagName->getName(),
|
||||
interner),
|
||||
nonInternedTagName->setNameForNonInterned(other->tagName->getName(),
|
||||
other->tagName->isCustom());
|
||||
tagName = nonInternedTagName;
|
||||
}
|
||||
@@ -4831,15 +4824,14 @@ nsHtml5Tokenizer::loadState(nsHtml5Tokenizer* other)
|
||||
attributeName = other->attributeName;
|
||||
} else {
|
||||
nonInternedAttributeName->setNameForNonInterned(
|
||||
nsHtml5Portability::newLocalFromLocal(
|
||||
other->attributeName->getLocal(nsHtml5AttributeName::HTML), interner));
|
||||
other->attributeName->getLocal(nsHtml5AttributeName::HTML));
|
||||
attributeName = nonInternedAttributeName;
|
||||
}
|
||||
delete attributes;
|
||||
if (!other->attributes) {
|
||||
attributes = nullptr;
|
||||
} else {
|
||||
attributes = other->attributes->cloneAttributes(interner);
|
||||
attributes = other->attributes->cloneAttributes();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4864,8 +4856,9 @@ nsHtml5Tokenizer::~nsHtml5Tokenizer()
|
||||
{
|
||||
MOZ_COUNT_DTOR(nsHtml5Tokenizer);
|
||||
delete nonInternedTagName;
|
||||
delete nonInternedAttributeName;
|
||||
nonInternedTagName = nullptr;
|
||||
delete nonInternedAttributeName;
|
||||
nonInternedAttributeName = nullptr;
|
||||
delete attributes;
|
||||
attributes = nullptr;
|
||||
}
|
||||
|
||||
@@ -3883,7 +3883,7 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag(nsAtom* name)
|
||||
nsIContentHandle* clone =
|
||||
createElement(kNameSpaceID_XHTML,
|
||||
node->name,
|
||||
node->attributes->cloneAttributes(nullptr),
|
||||
node->attributes->cloneAttributes(),
|
||||
commonAncestor->node,
|
||||
htmlCreator(node->getHtmlCreator()));
|
||||
nsHtml5StackNode* newNode = createStackNode(node->getFlags(),
|
||||
@@ -3915,7 +3915,7 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag(nsAtom* name)
|
||||
nsIContentHandle* clone =
|
||||
createElement(kNameSpaceID_XHTML,
|
||||
formattingElt->name,
|
||||
formattingElt->attributes->cloneAttributes(nullptr),
|
||||
formattingElt->attributes->cloneAttributes(),
|
||||
furthestBlock->node,
|
||||
htmlCreator(formattingElt->getHtmlCreator()));
|
||||
nsHtml5StackNode* formattingClone =
|
||||
@@ -4101,12 +4101,12 @@ nsHtml5TreeBuilder::reconstructTheActiveFormattingElements()
|
||||
clone = createAndInsertFosterParentedElement(
|
||||
kNameSpaceID_XHTML,
|
||||
entry->name,
|
||||
entry->attributes->cloneAttributes(nullptr),
|
||||
entry->attributes->cloneAttributes(),
|
||||
htmlCreator(entry->getHtmlCreator()));
|
||||
} else {
|
||||
clone = createElement(kNameSpaceID_XHTML,
|
||||
entry->name,
|
||||
entry->attributes->cloneAttributes(nullptr),
|
||||
entry->attributes->cloneAttributes(),
|
||||
currentNode->node,
|
||||
htmlCreator(entry->getHtmlCreator()));
|
||||
appendElement(clone, currentNode->node);
|
||||
@@ -4391,7 +4391,7 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushFormattingElementMayFoster(
|
||||
nsHtml5ElementName* elementName,
|
||||
nsHtml5HtmlAttributes* attributes)
|
||||
{
|
||||
nsHtml5HtmlAttributes* clone = attributes->cloneAttributes(nullptr);
|
||||
nsHtml5HtmlAttributes* clone = attributes->cloneAttributes();
|
||||
nsIContentHandle* elt;
|
||||
nsHtml5StackNode* current = stack[currentPtr];
|
||||
if (current->isFosterParenting()) {
|
||||
@@ -4835,7 +4835,7 @@ nsHtml5TreeBuilder::newSnapshot()
|
||||
node->name,
|
||||
node->node,
|
||||
node->popName,
|
||||
node->attributes->cloneAttributes(nullptr),
|
||||
node->attributes->cloneAttributes(),
|
||||
node->getHtmlCreator());
|
||||
listCopy[i] = newNode;
|
||||
} else {
|
||||
@@ -4926,8 +4926,7 @@ nsHtml5TreeBuilder::snapshotMatches(nsAHtml5TreeBuilderState* snapshot)
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::loadState(nsAHtml5TreeBuilderState* snapshot,
|
||||
nsHtml5AtomTable* interner)
|
||||
nsHtml5TreeBuilder::loadState(nsAHtml5TreeBuilderState* snapshot)
|
||||
{
|
||||
mCurrentHtmlScriptIsAsyncOrDefer = false;
|
||||
jArray<nsHtml5StackNode*, int32_t> stackCopy = snapshot->getStack();
|
||||
@@ -4963,13 +4962,13 @@ nsHtml5TreeBuilder::loadState(nsAHtml5TreeBuilderState* snapshot,
|
||||
for (int32_t i = 0; i < listLen; i++) {
|
||||
nsHtml5StackNode* node = listCopy[i];
|
||||
if (node) {
|
||||
nsHtml5StackNode* newNode = createStackNode(
|
||||
node->getFlags(),
|
||||
nsHtml5StackNode* newNode =
|
||||
createStackNode(node->getFlags(),
|
||||
node->ns,
|
||||
nsHtml5Portability::newLocalFromLocal(node->name, interner),
|
||||
node->name,
|
||||
node->node,
|
||||
nsHtml5Portability::newLocalFromLocal(node->popName, interner),
|
||||
node->attributes->cloneAttributes(nullptr),
|
||||
node->popName,
|
||||
node->attributes->cloneAttributes(),
|
||||
node->getHtmlCreator());
|
||||
listOfActiveFormattingElements[i] = newNode;
|
||||
} else {
|
||||
@@ -4980,12 +4979,11 @@ nsHtml5TreeBuilder::loadState(nsAHtml5TreeBuilderState* snapshot,
|
||||
nsHtml5StackNode* node = stackCopy[i];
|
||||
int32_t listIndex = findInArray(node, listCopy);
|
||||
if (listIndex == -1) {
|
||||
nsHtml5StackNode* newNode = createStackNode(
|
||||
node->getFlags(),
|
||||
nsHtml5StackNode* newNode = createStackNode(node->getFlags(),
|
||||
node->ns,
|
||||
nsHtml5Portability::newLocalFromLocal(node->name, interner),
|
||||
node->name,
|
||||
node->node,
|
||||
nsHtml5Portability::newLocalFromLocal(node->popName, interner),
|
||||
node->popName,
|
||||
nullptr,
|
||||
node->getHtmlCreator());
|
||||
stack[i] = newNode;
|
||||
|
||||
@@ -592,9 +592,7 @@ private:
|
||||
public:
|
||||
nsAHtml5TreeBuilderState* newSnapshot();
|
||||
bool snapshotMatches(nsAHtml5TreeBuilderState* snapshot);
|
||||
void loadState(nsAHtml5TreeBuilderState* snapshot,
|
||||
nsHtml5AtomTable* interner);
|
||||
|
||||
void loadState(nsAHtml5TreeBuilderState* snapshot);
|
||||
private:
|
||||
int32_t findInArray(nsHtml5StackNode* node,
|
||||
jArray<nsHtml5StackNode*, int32_t> arr);
|
||||
|
||||
Reference in New Issue
Block a user