Bug 482921 part 3 - Highlight tree builder-level errors in View Source. r=Olli.Pettay.
This commit is contained in:
@@ -57,6 +57,7 @@ nsHtml5TreeBuilder::nsHtml5TreeBuilder(nsAHtml5TreeOpSink* aOpSink,
|
||||
, contextNode(nsnull)
|
||||
, formPointer(nsnull)
|
||||
, headPointer(nsnull)
|
||||
, mViewSource(nsnull)
|
||||
, mOpSink(aOpSink)
|
||||
, mHandles(new nsIContent*[NS_HTML5_TREE_BUILDER_HANDLE_ARRAY_LENGTH])
|
||||
, mHandlesUsed(0)
|
||||
@@ -707,3 +708,396 @@ nsHtml5TreeBuilder::documentMode(nsHtml5DocumentMode m)
|
||||
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
||||
treeOp->Init(m);
|
||||
}
|
||||
|
||||
// Error reporting
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::EnableViewSource(nsHtml5Highlighter* aHighlighter)
|
||||
{
|
||||
mViewSource = aHighlighter;
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errStrayStartTag(nsIAtom* aName)
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errStrayStartTag", aName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errStrayEndTag(nsIAtom* aName)
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errStrayEndTag", aName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errUnclosedElements(PRInt32 aIndex, nsIAtom* aName)
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errUnclosedElements", aName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errUnclosedElementsImplied(PRInt32 aIndex, nsIAtom* aName)
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errUnclosedElementsImplied",
|
||||
aName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errUnclosedElementsCell(PRInt32 aIndex)
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errUnclosedElementsCell");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errStrayDoctype()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errStrayDoctype");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errAlmostStandardsDoctype()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errAlmostStandardsDoctype");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errQuirkyDoctype()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errQuirkyDoctype");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errNonSpaceInTrailer()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errNonSpaceInTrailer");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errNonSpaceAfterFrameset()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errNonSpaceAfterFrameset");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errNonSpaceInFrameset()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errNonSpaceInFrameset");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errNonSpaceAfterBody()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errNonSpaceAfterBody");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errNonSpaceInColgroupInFragment()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errNonSpaceInColgroupInFragment");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errNonSpaceInNoscriptInHead()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errNonSpaceInNoscriptInHead");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errFooBetweenHeadAndBody(nsIAtom* aName)
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errFooBetweenHeadAndBody", aName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errStartTagWithoutDoctype()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errStartTagWithoutDoctype");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errNoSelectInTableScope()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errNoSelectInTableScope");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errStartSelectWhereEndSelectExpected()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun(
|
||||
"errStartSelectWhereEndSelectExpected");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errStartTagWithSelectOpen(nsIAtom* aName)
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errStartTagWithSelectOpen", aName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errBadStartTagInHead(nsIAtom* aName)
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errBadStartTagInHead", aName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errImage()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errImage");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errIsindex()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errIsindex");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errFooSeenWhenFooOpen(nsIAtom* aName)
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errFooSeenWhenFooOpen", aName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errHeadingWhenHeadingOpen()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errHeadingWhenHeadingOpen");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errFramesetStart()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errFramesetStart");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errNoCellToClose()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errNoCellToClose");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errStartTagInTable(nsIAtom* aName)
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errStartTagInTable", aName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errFormWhenFormOpen()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errFormWhenFormOpen");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errTableSeenWhileTableOpen()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errTableSeenWhileTableOpen");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errStartTagInTableBody(nsIAtom* aName)
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errStartTagInTableBody", aName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errEndTagSeenWithoutDoctype()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errEndTagSeenWithoutDoctype");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errEndTagAfterBody()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errEndTagAfterBody");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errEndTagSeenWithSelectOpen(nsIAtom* aName)
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errEndTagSeenWithSelectOpen",
|
||||
aName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errGarbageInColgroup()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errGarbageInColgroup");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errEndTagBr()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errEndTagBr");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errNoElementToCloseButEndTagSeen(nsIAtom* aName)
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun(
|
||||
"errNoElementToCloseButEndTagSeen", aName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errHtmlStartTagInForeignContext(nsIAtom* aName)
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errHtmlStartTagInForeignContext",
|
||||
aName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errTableClosedWhileCaptionOpen()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errTableClosedWhileCaptionOpen");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errNoTableRowToClose()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errNoTableRowToClose");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errNonSpaceInTable()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errNonSpaceInTable");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errUnclosedChildrenInRuby()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errUnclosedChildrenInRuby");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errStartTagSeenWithoutRuby(nsIAtom* aName)
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errStartTagSeenWithoutRuby",
|
||||
aName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errSelfClosing()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentSlash("errSelfClosing");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errNoCheckUnclosedElementsOnStack()
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun(
|
||||
"errNoCheckUnclosedElementsOnStack");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errEndTagDidNotMatchCurrentOpenElement(nsIAtom* aName,
|
||||
nsIAtom* aOther)
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun(
|
||||
"errEndTagDidNotMatchCurrentOpenElement", aName, aOther);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errEndTagViolatesNestingRules(nsIAtom* aName)
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errEndTagViolatesNestingRules", aName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::errEndWithUnclosedElements(nsIAtom* aName)
|
||||
{
|
||||
if (NS_UNLIKELY(mViewSource)) {
|
||||
mViewSource->AddErrorToCurrentRun("errEndWithUnclosedElements", aName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user