Bug 483015 - Expose line numbers for <style> and <script> in the HTML5 parser

This commit is contained in:
Henri Sivonen 2009-06-08 16:29:54 +03:00
parent 2a38c0ddfc
commit f93baf7cb6
3 changed files with 13 additions and 5 deletions

View File

@ -372,6 +372,8 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
// XXX stop speculative script thread here
PRInt32 lineNumberSave = mTokenizer->getLineNumber();
// Maintain a reference to ourselves so we don't go away
// till we're completely done.
// XXX is this still necessary? -- hsivonen
@ -442,6 +444,7 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
}
// Scripting semantics require a forced tree builder flush here
mTreeBuilder->Flush();
mTokenizer->setLineNumber(lineNumberSave);
return NS_OK;
}

View File

@ -154,10 +154,10 @@ nsHtml5Tokenizer::contentModelElementToArray()
}
}
PRInt32
nsHtml5Tokenizer::getLineNumber()
void
nsHtml5Tokenizer::setLineNumber(PRInt32 line)
{
return line;
this->line = line;
}
nsHtml5HtmlAttributes*
@ -400,7 +400,7 @@ nsHtml5Tokenizer::start()
longStrBuf = jArray<PRUnichar,PRInt32>(1024);
longStrBufLen = 0;
stateSave = NS_HTML5TOKENIZER_DATA;
line = -1;
line = 1;
lastCR = PR_FALSE;
tokenHandler->startTokenization(this);
index = 0;

View File

@ -173,7 +173,12 @@ class nsHtml5Tokenizer
private:
void contentModelElementToArray();
public:
PRInt32 getLineNumber();
void setLineNumber(PRInt32 line);
inline PRInt32 getLineNumber()
{
return line;
}
nsHtml5HtmlAttributes* emptyAttributes();
private:
void clearStrBufAndAppendCurrentC(PRUnichar c);