Skip to content

Commit

Permalink
Bug 616421 - Better distinguish invalid mOpCode values in nsHtml5Tree…
Browse files Browse the repository at this point in the history
…Operation::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.
  • Loading branch information
nnethercote committed Jun 2, 2016
1 parent 63b407b commit 9f7d75c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
45 changes: 24 additions & 21 deletions parser/html/nsHtml5TreeOperation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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: {
Expand Down
2 changes: 0 additions & 2 deletions parser/html/nsHtml5TreeOperation.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ enum eHtml5TreeOperation {
eTreeOpAddViewSourceBase,
eTreeOpAddError,
eTreeOpAddLineNumberId,
eTreeOpAddErrorAtom,
eTreeOpAddErrorTwoAtoms,
eTreeOpStartLayout
};

Expand Down

0 comments on commit 9f7d75c

Please sign in to comment.