Bug 616421 - Better distinguish invalid mOpCode values in nsHtml5TreeOperation::Perform. r=hsivonen.

This patch:

- Removes eTreeOpAddError{Atom,TwoAtoms}, which are unused.

- Adds a MOZ_CRASHing case for eTreeOpUninitialized.

- Reorders the cases in the switch to match the enum declaration order, which
  makes it easier to see that all opcodes are now covered.
This commit is contained in:
Nicholas Nethercote
2016-06-02 17:49:44 +10:00
parent ad4efc69fd
commit e7de4ef9fc
2 changed files with 24 additions and 23 deletions

View File

@@ -640,6 +640,9 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
nsIContent** aScriptElement)
{
switch(mOpCode) {
case eTreeOpUninitialized: {
MOZ_CRASH("eTreeOpUninitialized");
}
case eTreeOpAppend: {
nsIContent* node = *(mOne.node);
nsIContent* parent = *(mTwo.node);
@@ -670,6 +673,10 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
nsHtml5HtmlAttributes* attributes = mTwo.attributes;
return AddAttributes(node, attributes, aBuilder);
}
case eTreeOpDocumentMode: {
aBuilder->SetDocumentMode(mOne.mode);
return NS_OK;
}
case eTreeOpCreateElementNetwork:
case eTreeOpCreateElementNotNetwork: {
nsIContent** target = mOne.node;
@@ -818,14 +825,6 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
aBuilder->DidBuildModel(false); // this causes a notifications flush anyway
return NS_OK;
}
case eTreeOpStartLayout: {
aBuilder->StartLayout(); // this causes a notification flush anyway
return NS_OK;
}
case eTreeOpDocumentMode: {
aBuilder->SetDocumentMode(mOne.mode);
return NS_OK;
}
case eTreeOpSetStyleLineNumber: {
nsIContent* node = *(mOne.node);
nsCOMPtr<nsIStyleSheetLinkingElement> ssle = do_QueryInterface(node);
@@ -869,14 +868,6 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
}
return NS_OK;
}
case eTreeOpAddLineNumberId: {
nsIContent* node = *(mOne.node);
int32_t lineNumber = mFour.integer;
nsAutoString val(NS_LITERAL_STRING("line"));
val.AppendInt(lineNumber);
node->SetAttr(kNameSpaceID_None, nsGkAtoms::id, val, true);
return NS_OK;
}
case eTreeOpAddViewSourceHref: {
nsIContent* node = *mOne.node;
char16_t* buffer = mTwo.unicharPtr;
@@ -932,6 +923,13 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
node->SetAttr(kNameSpaceID_None, nsGkAtoms::href, utf16, true);
return rv;
}
case eTreeOpAddViewSourceBase: {
char16_t* buffer = mTwo.unicharPtr;
int32_t length = mFour.integer;
nsDependentString baseUrl(buffer, length);
aBuilder->AddBase(baseUrl);
return NS_OK;
}
case eTreeOpAddError: {
nsIContent* node = *(mOne.node);
char* msgId = mTwo.charPtr;
@@ -980,11 +978,16 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
}
return rv;
}
case eTreeOpAddViewSourceBase: {
char16_t* buffer = mTwo.unicharPtr;
int32_t length = mFour.integer;
nsDependentString baseUrl(buffer, length);
aBuilder->AddBase(baseUrl);
case eTreeOpAddLineNumberId: {
nsIContent* node = *(mOne.node);
int32_t lineNumber = mFour.integer;
nsAutoString val(NS_LITERAL_STRING("line"));
val.AppendInt(lineNumber);
node->SetAttr(kNameSpaceID_None, nsGkAtoms::id, val, true);
return NS_OK;
}
case eTreeOpStartLayout: {
aBuilder->StartLayout(); // this causes a notification flush anyway
return NS_OK;
}
default: {