summaryrefslogtreecommitdiff
path: root/parser/html/nsHtml5Highlighter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'parser/html/nsHtml5Highlighter.cpp')
-rw-r--r--parser/html/nsHtml5Highlighter.cpp48
1 files changed, 25 insertions, 23 deletions
diff --git a/parser/html/nsHtml5Highlighter.cpp b/parser/html/nsHtml5Highlighter.cpp
index 1f39abe39..9ddfadd17 100644
--- a/parser/html/nsHtml5Highlighter.cpp
+++ b/parser/html/nsHtml5Highlighter.cpp
@@ -17,32 +17,32 @@ using namespace mozilla;
// the size of 16 tokens on cnn.com.
#define NS_HTML5_HIGHLIGHTER_PRE_BREAK_THRESHOLD 1300
-PRUnichar nsHtml5Highlighter::sComment[] =
+char16_t nsHtml5Highlighter::sComment[] =
{ 'c', 'o', 'm', 'm', 'e', 'n', 't', 0 };
-PRUnichar nsHtml5Highlighter::sCdata[] =
+char16_t nsHtml5Highlighter::sCdata[] =
{ 'c', 'd', 'a', 't', 'a', 0 };
-PRUnichar nsHtml5Highlighter::sEntity[] =
+char16_t nsHtml5Highlighter::sEntity[] =
{ 'e', 'n', 't', 'i', 't', 'y', 0 };
-PRUnichar nsHtml5Highlighter::sEndTag[] =
+char16_t nsHtml5Highlighter::sEndTag[] =
{ 'e', 'n', 'd', '-', 't', 'a', 'g', 0 };
-PRUnichar nsHtml5Highlighter::sStartTag[] =
+char16_t nsHtml5Highlighter::sStartTag[] =
{ 's', 't', 'a', 'r', 't', '-', 't', 'a', 'g', 0 };
-PRUnichar nsHtml5Highlighter::sAttributeName[] =
+char16_t nsHtml5Highlighter::sAttributeName[] =
{ 'a', 't', 't', 'r', 'i', 'b', 'u', 't', 'e', '-', 'n', 'a', 'm', 'e', 0 };
-PRUnichar nsHtml5Highlighter::sAttributeValue[] =
+char16_t nsHtml5Highlighter::sAttributeValue[] =
{ 'a', 't', 't', 'r', 'i', 'b', 'u', 't', 'e', '-',
'v', 'a', 'l', 'u', 'e', 0 };
-PRUnichar nsHtml5Highlighter::sDoctype[] =
+char16_t nsHtml5Highlighter::sDoctype[] =
{ 'd', 'o', 'c', 't', 'y', 'p', 'e', 0 };
-PRUnichar nsHtml5Highlighter::sPi[] =
+char16_t nsHtml5Highlighter::sPi[] =
{ 'p', 'i', 0 };
nsHtml5Highlighter::nsHtml5Highlighter(nsAHtml5TreeOpSink* aOpSink)
@@ -79,7 +79,7 @@ nsHtml5Highlighter::Start(const nsAutoString& aTitle)
mOpQueue.AppendElement()->Init(STANDARDS_MODE);
- nsIContent** root = CreateElement(nsHtml5Atoms::html, nullptr);
+ nsIContent** root = CreateElement(nsHtml5Atoms::html, nullptr, nullptr);
mOpQueue.AppendElement()->Init(eTreeOpAppendToDocument, root);
mStack.AppendElement(root);
@@ -497,7 +497,7 @@ nsHtml5Highlighter::StartSpan()
}
void
-nsHtml5Highlighter::StartSpan(const PRUnichar* aClass)
+nsHtml5Highlighter::StartSpan(const char16_t* aClass)
{
StartSpan();
AddClass(aClass);
@@ -558,10 +558,10 @@ void
nsHtml5Highlighter::FlushChars()
{
if (mCStart < mPos) {
- PRUnichar* buf = mBuffer->getBuffer();
+ char16_t* buf = mBuffer->getBuffer();
int32_t i = mCStart;
while (i < mPos) {
- PRUnichar c = buf[i];
+ char16_t c = buf[i];
switch (c) {
case '\r':
// The input this code sees has been normalized so that there are
@@ -655,7 +655,8 @@ nsHtml5Highlighter::AllocateContentHandle()
nsIContent**
nsHtml5Highlighter::CreateElement(nsIAtom* aName,
- nsHtml5HtmlAttributes* aAttributes)
+ nsHtml5HtmlAttributes* aAttributes,
+ nsIContent** aIntendedParent)
{
NS_PRECONDITION(aName, "Got null name.");
nsIContent** content = AllocateContentHandle();
@@ -663,6 +664,7 @@ nsHtml5Highlighter::CreateElement(nsIAtom* aName,
aName,
aAttributes,
content,
+ aIntendedParent,
true);
return content;
}
@@ -679,7 +681,7 @@ nsHtml5Highlighter::Push(nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes)
{
NS_PRECONDITION(mStack.Length() >= 1, "Pushing without root.");
- nsIContent** elt = CreateElement(aName, aAttributes); // Don't inline below!
+ nsIContent** elt = CreateElement(aName, aAttributes, CurrentNode()); // Don't inline below!
mOpQueue.AppendElement()->Init(eTreeOpAppend, elt, CurrentNode());
mStack.AppendElement(elt);
}
@@ -692,14 +694,14 @@ nsHtml5Highlighter::Pop()
}
void
-nsHtml5Highlighter::AppendCharacters(const PRUnichar* aBuffer,
+nsHtml5Highlighter::AppendCharacters(const char16_t* aBuffer,
int32_t aStart,
int32_t aLength)
{
NS_PRECONDITION(aBuffer, "Null buffer");
- PRUnichar* bufferCopy = new PRUnichar[aLength];
- memcpy(bufferCopy, aBuffer + aStart, aLength * sizeof(PRUnichar));
+ char16_t* bufferCopy = new char16_t[aLength];
+ memcpy(bufferCopy, aBuffer + aStart, aLength * sizeof(char16_t));
mOpQueue.AppendElement()->Init(eTreeOpAppendText,
bufferCopy,
@@ -709,7 +711,7 @@ nsHtml5Highlighter::AppendCharacters(const PRUnichar* aBuffer,
void
-nsHtml5Highlighter::AddClass(const PRUnichar* aClass)
+nsHtml5Highlighter::AddClass(const char16_t* aClass)
{
if (!mSyntaxHighlight) {
return;
@@ -720,8 +722,8 @@ nsHtml5Highlighter::AddClass(const PRUnichar* aClass)
void
nsHtml5Highlighter::AddViewSourceHref(const nsString& aValue)
{
- PRUnichar* bufferCopy = new PRUnichar[aValue.Length() + 1];
- memcpy(bufferCopy, aValue.get(), aValue.Length() * sizeof(PRUnichar));
+ char16_t* bufferCopy = new char16_t[aValue.Length() + 1];
+ memcpy(bufferCopy, aValue.get(), aValue.Length() * sizeof(char16_t));
bufferCopy[aValue.Length()] = 0;
mOpQueue.AppendElement()->Init(eTreeOpAddViewSourceHref,
@@ -737,8 +739,8 @@ nsHtml5Highlighter::AddBase(const nsString& aValue)
return;
}
mSeenBase = true;
- PRUnichar* bufferCopy = new PRUnichar[aValue.Length() + 1];
- memcpy(bufferCopy, aValue.get(), aValue.Length() * sizeof(PRUnichar));
+ char16_t* bufferCopy = new char16_t[aValue.Length() + 1];
+ memcpy(bufferCopy, aValue.get(), aValue.Length() * sizeof(char16_t));
bufferCopy[aValue.Length()] = 0;
mOpQueue.AppendElement()->Init(eTreeOpAddViewSourceBase,