diff --git a/parser/html/moz.build b/parser/html/moz.build
index 138f96170..84327332c 100644
--- a/parser/html/moz.build
+++ b/parser/html/moz.build
@@ -39,6 +39,7 @@ EXPORTS += [
'nsHtml5SpeculativeLoad.h',
'nsHtml5StreamListener.h',
'nsHtml5StreamParser.h',
+ 'nsHtml5String.h',
'nsHtml5StringParser.h',
'nsHtml5SVGLoadDispatcher.h',
'nsHtml5TreeOperation.h',
@@ -78,6 +79,7 @@ UNIFIED_SOURCES += [
'nsHtml5StateSnapshot.cpp',
'nsHtml5StreamListener.cpp',
'nsHtml5StreamParser.cpp',
+ 'nsHtml5String.cpp',
'nsHtml5StringParser.cpp',
'nsHtml5SVGLoadDispatcher.cpp',
'nsHtml5Tokenizer.cpp',
diff --git a/parser/html/nsHtml5ArrayCopy.h b/parser/html/nsHtml5ArrayCopy.h
index 78ed65568..594a801ab 100644
--- a/parser/html/nsHtml5ArrayCopy.h
+++ b/parser/html/nsHtml5ArrayCopy.h
@@ -51,10 +51,11 @@ class nsHtml5ArrayCopy {
memcpy(target, source, size_t(length) * sizeof(int32_t));
}
- static inline void
- arraycopy(nsString** source, nsString** target, int32_t length)
+ static inline void arraycopy(nsHtml5String* source,
+ nsHtml5String* target,
+ int32_t length)
{
- memcpy(target, source, size_t(length) * sizeof(nsString*));
+ memcpy(target, source, size_t(length) * sizeof(nsHtml5String));
}
static inline void
diff --git a/parser/html/nsHtml5AttributeName.cpp b/parser/html/nsHtml5AttributeName.cpp
index fc7745adc..dc546c111 100644
--- a/parser/html/nsHtml5AttributeName.cpp
+++ b/parser/html/nsHtml5AttributeName.cpp
@@ -29,7 +29,7 @@
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
-#include "nsString.h"
+#include "nsHtml5String.h"
#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
diff --git a/parser/html/nsHtml5AttributeName.h b/parser/html/nsHtml5AttributeName.h
index 748dcf3c9..d0b93341b 100644
--- a/parser/html/nsHtml5AttributeName.h
+++ b/parser/html/nsHtml5AttributeName.h
@@ -30,7 +30,7 @@
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
-#include "nsString.h"
+#include "nsHtml5String.h"
#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
diff --git a/parser/html/nsHtml5ElementName.cpp b/parser/html/nsHtml5ElementName.cpp
index bc3970526..348d21412 100644
--- a/parser/html/nsHtml5ElementName.cpp
+++ b/parser/html/nsHtml5ElementName.cpp
@@ -29,7 +29,7 @@
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
-#include "nsString.h"
+#include "nsHtml5String.h"
#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
diff --git a/parser/html/nsHtml5ElementName.h b/parser/html/nsHtml5ElementName.h
index b4df323a6..b5f0e4b9b 100644
--- a/parser/html/nsHtml5ElementName.h
+++ b/parser/html/nsHtml5ElementName.h
@@ -30,7 +30,7 @@
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
-#include "nsString.h"
+#include "nsHtml5String.h"
#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
diff --git a/parser/html/nsHtml5Highlighter.cpp b/parser/html/nsHtml5Highlighter.cpp
index aa147b344..4bde4a1fd 100644
--- a/parser/html/nsHtml5Highlighter.cpp
+++ b/parser/html/nsHtml5Highlighter.cpp
@@ -89,7 +89,7 @@ nsHtml5Highlighter::Start(const nsAutoString& aTitle)
if (length > INT32_MAX) {
length = INT32_MAX;
}
- AppendCharacters(aTitle.get(), 0, (int32_t)length);
+ AppendCharacters(aTitle.BeginReading(), 0, (int32_t)length);
Pop(); // title
Push(nsGkAtoms::link, nsHtml5ViewSourceUtils::NewLinkAttributes());
@@ -103,7 +103,7 @@ nsHtml5Highlighter::Start(const nsAutoString& aTitle)
Push(nsGkAtoms::body, nsHtml5ViewSourceUtils::NewBodyAttributes());
nsHtml5HtmlAttributes* preAttrs = new nsHtml5HtmlAttributes(0);
- nsString* preId = new nsString(NS_LITERAL_STRING("line1"));
+ nsHtml5String preId = nsHtml5Portability::newStringFromLiteral("line1");
preAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, preId);
Push(nsGkAtoms::pre, preAttrs);
@@ -616,7 +616,7 @@ nsHtml5Highlighter::FlushOps()
void
nsHtml5Highlighter::MaybeLinkifyAttributeValue(nsHtml5AttributeName* aName,
- nsString* aValue)
+ nsHtml5String aValue)
{
if (!(nsHtml5AttributeName::ATTR_HREF == aName ||
nsHtml5AttributeName::ATTR_SRC == aName ||
@@ -628,7 +628,7 @@ nsHtml5Highlighter::MaybeLinkifyAttributeValue(nsHtml5AttributeName* aName,
nsHtml5AttributeName::ATTR_DEFINITIONURL == aName)) {
return;
}
- AddViewSourceHref(*aValue);
+ AddViewSourceHref(aValue);
}
void
@@ -715,10 +715,10 @@ nsHtml5Highlighter::AddClass(const char16_t* aClass)
}
void
-nsHtml5Highlighter::AddViewSourceHref(const nsString& aValue)
+nsHtml5Highlighter::AddViewSourceHref(nsHtml5String aValue)
{
char16_t* bufferCopy = new char16_t[aValue.Length() + 1];
- memcpy(bufferCopy, aValue.get(), aValue.Length() * sizeof(char16_t));
+ aValue.CopyToBuffer(bufferCopy);
bufferCopy[aValue.Length()] = 0;
mOpQueue.AppendElement()->Init(eTreeOpAddViewSourceHref,
@@ -728,14 +728,14 @@ nsHtml5Highlighter::AddViewSourceHref(const nsString& aValue)
}
void
-nsHtml5Highlighter::AddBase(const nsString& aValue)
+nsHtml5Highlighter::AddBase(nsHtml5String aValue)
{
if(mSeenBase) {
return;
}
mSeenBase = true;
char16_t* bufferCopy = new char16_t[aValue.Length() + 1];
- memcpy(bufferCopy, aValue.get(), aValue.Length() * sizeof(char16_t));
+ aValue.CopyToBuffer(bufferCopy);
bufferCopy[aValue.Length()] = 0;
mOpQueue.AppendElement()->Init(eTreeOpAddViewSourceBase,
diff --git a/parser/html/nsHtml5Highlighter.h b/parser/html/nsHtml5Highlighter.h
index e9474869e..366f11582 100644
--- a/parser/html/nsHtml5Highlighter.h
+++ b/parser/html/nsHtml5Highlighter.h
@@ -78,7 +78,7 @@ class nsHtml5Highlighter
* @param aValue the value of the attribute
*/
void MaybeLinkifyAttributeValue(nsHtml5AttributeName* aName,
- nsString* aValue);
+ nsHtml5String aValue);
/**
* Inform the highlighter that the tokenizer successfully completed a
@@ -147,7 +147,7 @@ class nsHtml5Highlighter
*
* @param aValue the base URL to add
*/
- void AddBase(const nsString& aValue);
+ void AddBase(nsHtml5String aValue);
private:
@@ -272,7 +272,7 @@ class nsHtml5Highlighter
*
* @param aValue the (potentially relative) URL to link to
*/
- void AddViewSourceHref(const nsString& aValue);
+ void AddViewSourceHref(nsHtml5String aValue);
/**
* The state we are transitioning away from.
diff --git a/parser/html/nsHtml5HtmlAttributes.cpp b/parser/html/nsHtml5HtmlAttributes.cpp
index 62b112fb9..e364019e6 100644
--- a/parser/html/nsHtml5HtmlAttributes.cpp
+++ b/parser/html/nsHtml5HtmlAttributes.cpp
@@ -30,7 +30,7 @@
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
-#include "nsString.h"
+#include "nsHtml5String.h"
#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
@@ -61,7 +61,7 @@ nsHtml5HtmlAttributes::nsHtml5HtmlAttributes(int32_t mode)
: mode(mode),
length(0),
names(jArray::newJArray(5)),
- values(jArray::newJArray(5))
+ values(jArray::newJArray(5))
{
MOZ_COUNT_CTOR(nsHtml5HtmlAttributes);
}
@@ -84,7 +84,7 @@ nsHtml5HtmlAttributes::getIndex(nsHtml5AttributeName* name)
return -1;
}
-nsString*
+nsHtml5String
nsHtml5HtmlAttributes::getValue(nsHtml5AttributeName* name)
{
int32_t index = getIndex(name);
@@ -122,7 +122,7 @@ nsHtml5HtmlAttributes::getPrefixNoBoundsCheck(int32_t index)
return names[index]->getPrefix(mode);
}
-nsString*
+nsHtml5String
nsHtml5HtmlAttributes::getValueNoBoundsCheck(int32_t index)
{
MOZ_ASSERT(index < length && index >= 0, "Index out of bounds");
@@ -137,14 +137,14 @@ nsHtml5HtmlAttributes::getAttributeNameNoBoundsCheck(int32_t index)
}
void
-nsHtml5HtmlAttributes::addAttribute(nsHtml5AttributeName* name, nsString* value)
+nsHtml5HtmlAttributes::addAttribute(nsHtml5AttributeName* name, nsHtml5String value)
{
if (names.length == length) {
int32_t newLen = length << 1;
jArray newNames = jArray::newJArray(newLen);
nsHtml5ArrayCopy::arraycopy(names, newNames, names.length);
names = newNames;
- jArray newValues = jArray::newJArray(newLen);
+ jArray newValues = jArray::newJArray(newLen);
nsHtml5ArrayCopy::arraycopy(values, newValues, values.length);
values = newValues;
}
@@ -159,7 +159,7 @@ nsHtml5HtmlAttributes::clear(int32_t m)
for (int32_t i = 0; i < length; i++) {
names[i]->release();
names[i] = nullptr;
- nsHtml5Portability::releaseString(values[i]);
+ values[i].Release();
values[i] = nullptr;
}
length = 0;
@@ -169,7 +169,7 @@ nsHtml5HtmlAttributes::clear(int32_t m)
void
nsHtml5HtmlAttributes::releaseValue(int32_t i)
{
- nsHtml5Portability::releaseString(values[i]);
+ values[i].Release();
}
void
diff --git a/parser/html/nsHtml5HtmlAttributes.h b/parser/html/nsHtml5HtmlAttributes.h
index 5ec0f1fca..0b9c0a4d8 100644
--- a/parser/html/nsHtml5HtmlAttributes.h
+++ b/parser/html/nsHtml5HtmlAttributes.h
@@ -31,7 +31,7 @@
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
-#include "nsString.h"
+#include "nsHtml5String.h"
#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
@@ -64,19 +64,19 @@ class nsHtml5HtmlAttributes
int32_t mode;
int32_t length;
autoJArray names;
- autoJArray values;
+ autoJArray values;
public:
explicit nsHtml5HtmlAttributes(int32_t mode);
~nsHtml5HtmlAttributes();
int32_t getIndex(nsHtml5AttributeName* name);
- nsString* getValue(nsHtml5AttributeName* name);
+ nsHtml5String getValue(nsHtml5AttributeName* name);
int32_t getLength();
nsIAtom* getLocalNameNoBoundsCheck(int32_t index);
int32_t getURINoBoundsCheck(int32_t index);
nsIAtom* getPrefixNoBoundsCheck(int32_t index);
- nsString* getValueNoBoundsCheck(int32_t index);
+ nsHtml5String getValueNoBoundsCheck(int32_t index);
nsHtml5AttributeName* getAttributeNameNoBoundsCheck(int32_t index);
- void addAttribute(nsHtml5AttributeName* name, nsString* value);
+ void addAttribute(nsHtml5AttributeName* name, nsHtml5String value);
void clear(int32_t m);
void releaseValue(int32_t i);
void clearWithoutReleasingContents();
diff --git a/parser/html/nsHtml5MetaScanner.cpp b/parser/html/nsHtml5MetaScanner.cpp
index d39eacd9b..24f17b02b 100644
--- a/parser/html/nsHtml5MetaScanner.cpp
+++ b/parser/html/nsHtml5MetaScanner.cpp
@@ -30,7 +30,7 @@
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
-#include "nsString.h"
+#include "nsHtml5String.h"
#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
@@ -86,8 +86,8 @@ nsHtml5MetaScanner::nsHtml5MetaScanner(nsHtml5TreeBuilder* tb)
nsHtml5MetaScanner::~nsHtml5MetaScanner()
{
MOZ_COUNT_DTOR(nsHtml5MetaScanner);
- nsHtml5Portability::releaseString(content);
- nsHtml5Portability::releaseString(charset);
+ content.Release();
+ charset.Release();
}
void
@@ -771,9 +771,9 @@ bool
nsHtml5MetaScanner::handleTag()
{
bool stop = handleTagInner();
- nsHtml5Portability::releaseString(content);
+ content.Release();
content = nullptr;
- nsHtml5Portability::releaseString(charset);
+ charset.Release();
charset = nullptr;
httpEquivState = NS_HTML5META_SCANNER_HTTP_EQUIV_NOT_SEEN;
return stop;
@@ -786,12 +786,13 @@ nsHtml5MetaScanner::handleTagInner()
return true;
}
if (!!content && httpEquivState == NS_HTML5META_SCANNER_HTTP_EQUIV_CONTENT_TYPE) {
- nsString* extract = nsHtml5TreeBuilder::extractCharsetFromContent(content, treeBuilder);
+ nsHtml5String extract =
+ nsHtml5TreeBuilder::extractCharsetFromContent(content, treeBuilder);
if (!extract) {
return false;
}
bool success = tryCharset(extract);
- nsHtml5Portability::releaseString(extract);
+ extract.Release();
return success;
}
return false;
diff --git a/parser/html/nsHtml5MetaScanner.h b/parser/html/nsHtml5MetaScanner.h
index 4e0ad7647..a4d308147 100644
--- a/parser/html/nsHtml5MetaScanner.h
+++ b/parser/html/nsHtml5MetaScanner.h
@@ -31,7 +31,7 @@
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
-#include "nsString.h"
+#include "nsHtml5String.h"
#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
@@ -76,8 +76,8 @@ class nsHtml5MetaScanner
private:
int32_t strBufLen;
autoJArray strBuf;
- nsString* content;
- nsString* charset;
+ nsHtml5String content;
+ nsHtml5String charset;
int32_t httpEquivState;
nsHtml5TreeBuilder* treeBuilder;
public:
@@ -100,7 +100,7 @@ class nsHtml5MetaScanner
bool handleTag();
bool handleTagInner();
protected:
- bool tryCharset(nsString* encoding);
+ bool tryCharset(nsHtml5String encoding);
public:
static void initializeStatics();
static void releaseStatics();
diff --git a/parser/html/nsHtml5MetaScannerCppSupplement.h b/parser/html/nsHtml5MetaScannerCppSupplement.h
index 5e7033777..9d2496361 100644
--- a/parser/html/nsHtml5MetaScannerCppSupplement.h
+++ b/parser/html/nsHtml5MetaScannerCppSupplement.h
@@ -19,13 +19,15 @@ nsHtml5MetaScanner::sniff(nsHtml5ByteReadable* bytes, nsACString& charset)
}
bool
-nsHtml5MetaScanner::tryCharset(nsString* charset)
+nsHtml5MetaScanner::tryCharset(nsHtml5String charset)
{
// This code needs to stay in sync with
// nsHtml5StreamParser::internalEncodingDeclaration. Unfortunately, the
// trickery with member fields here leads to some copy-paste reuse. :-(
nsAutoCString label;
- CopyUTF16toUTF8(*charset, label);
+ nsString charset16; // Not Auto, because using it to hold nsStringBuffer*
+ charset.ToString(charset16);
+ CopyUTF16toUTF8(charset16, label);
nsAutoCString encoding;
if (!EncodingUtils::FindEncodingForLabel(label, encoding)) {
return false;
diff --git a/parser/html/nsHtml5PlainTextUtils.cpp b/parser/html/nsHtml5PlainTextUtils.cpp
index acb8ba47d..eb7e3d766 100644
--- a/parser/html/nsHtml5PlainTextUtils.cpp
+++ b/parser/html/nsHtml5PlainTextUtils.cpp
@@ -5,21 +5,24 @@
#include "nsHtml5PlainTextUtils.h"
#include "nsHtml5AttributeName.h"
+#include "nsHtml5Portability.h"
#include "nsIServiceManager.h"
#include "nsIStringBundle.h"
#include "mozilla/Preferences.h"
+#include "nsHtml5String.h"
// static
nsHtml5HtmlAttributes*
nsHtml5PlainTextUtils::NewLinkAttributes()
{
nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0);
- nsString* rel = new nsString(NS_LITERAL_STRING("alternate stylesheet"));
+ nsHtml5String rel =
+ nsHtml5Portability::newStringFromLiteral("alternate stylesheet");
linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_REL, rel);
- nsString* type = new nsString(NS_LITERAL_STRING("text/css"));
+ nsHtml5String type = nsHtml5Portability::newStringFromLiteral("text/css");
linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TYPE, type);
- nsString* href = new nsString(
- NS_LITERAL_STRING("resource://gre-resources/plaintext.css"));
+ nsHtml5String href = nsHtml5Portability::newStringFromLiteral(
+ "resource://gre-resources/plaintext.css");
linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href);
nsresult rv;
@@ -34,7 +37,7 @@ nsHtml5PlainTextUtils::NewLinkAttributes()
bundle->GetStringFromName(MOZ_UTF16("plainText.wordWrap"), getter_Copies(title));
}
- nsString* titleCopy = new nsString(title);
- linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TITLE, titleCopy);
+ linkAttrs->addAttribute(
+ nsHtml5AttributeName::ATTR_TITLE, nsHtml5String::FromString(title));
return linkAttrs;
}
diff --git a/parser/html/nsHtml5Portability.cpp b/parser/html/nsHtml5Portability.cpp
index 36c7e758a..72f0d9ec5 100644
--- a/parser/html/nsHtml5Portability.cpp
+++ b/parser/html/nsHtml5Portability.cpp
@@ -16,37 +16,31 @@ nsHtml5Portability::newLocalNameFromBuffer(char16_t* buf, int32_t offset, int32_
return interner->GetAtom(nsDependentSubstring(buf, buf + length));
}
-nsString*
-nsHtml5Portability::newStringFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5TreeBuilder* treeBuilder)
+nsHtml5String
+nsHtml5Portability::newStringFromBuffer(char16_t* buf,
+ int32_t offset,
+ int32_t length,
+ nsHtml5TreeBuilder* treeBuilder)
{
- nsString* str = new nsString();
- bool succeeded = str->Append(buf + offset, length, mozilla::fallible);
- if (!succeeded) {
- str->Assign(char16_t(0xFFFD));
- treeBuilder->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY);
- }
- return str;
+ return nsHtml5String::FromBuffer(buf + offset, length, treeBuilder);
}
-nsString*
+nsHtml5String
nsHtml5Portability::newEmptyString()
{
- return new nsString();
+ return nsHtml5String::EmptyString();
}
-nsString*
+nsHtml5String
nsHtml5Portability::newStringFromLiteral(const char* literal)
{
- nsString* str = new nsString();
- str->AssignASCII(literal);
- return str;
+ return nsHtml5String::FromLiteral(literal);
}
-nsString*
-nsHtml5Portability::newStringFromString(nsString* string) {
- nsString* newStr = new nsString();
- newStr->Assign(*string);
- return newStr;
+nsHtml5String
+nsHtml5Portability::newStringFromString(nsHtml5String string)
+{
+ return string.Clone();
}
jArray
@@ -60,12 +54,14 @@ nsHtml5Portability::newCharArrayFromLocal(nsIAtom* local)
return arr;
}
-jArray
-nsHtml5Portability::newCharArrayFromString(nsString* string)
+jArray
+nsHtml5Portability::newCharArrayFromString(nsHtml5String string)
{
- int32_t len = string->Length();
+ MOZ_RELEASE_ASSERT(string);
+ uint32_t len = string.Length();
+ MOZ_RELEASE_ASSERT(len < INT32_MAX);
jArray arr = jArray::newJArray(len);
- memcpy(arr, string->BeginReading(), len * sizeof(char16_t));
+ string.CopyToBuffer(arr);
return arr;
}
@@ -82,12 +78,6 @@ nsHtml5Portability::newLocalFromLocal(nsIAtom* local, nsHtml5AtomTable* interner
return local;
}
-void
-nsHtml5Portability::releaseString(nsString* str)
-{
- delete str;
-}
-
bool
nsHtml5Portability::localEqualsBuffer(nsIAtom* local, char16_t* buf, int32_t offset, int32_t length)
{
@@ -95,55 +85,32 @@ nsHtml5Portability::localEqualsBuffer(nsIAtom* local, char16_t* buf, int32_t off
}
bool
-nsHtml5Portability::lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString(const char* lowerCaseLiteral, nsString* string)
+nsHtml5Portability::lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString(
+ const char* lowerCaseLiteral,
+ nsHtml5String string)
{
- if (!string) {
- return false;
- }
- const char* litPtr = lowerCaseLiteral;
- const char16_t* strPtr = string->BeginReading();
- const char16_t* end = string->EndReading();
- char16_t litChar;
- while ((litChar = *litPtr)) {
- NS_ASSERTION(!(litChar >= 'A' && litChar <= 'Z'), "Literal isn't in lower case.");
- if (strPtr == end) {
- return false;
- }
- char16_t strChar = *strPtr;
- if (strChar >= 'A' && strChar <= 'Z') {
- strChar += 0x20;
- }
- if (litChar != strChar) {
- return false;
- }
- ++litPtr;
- ++strPtr;
- }
- return true;
+ return string.LowerCaseStartsWithASCII(lowerCaseLiteral);
}
bool
-nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString(const char* lowerCaseLiteral, nsString* string)
+nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString(
+ const char* lowerCaseLiteral,
+ nsHtml5String string)
{
- if (!string) {
- return false;
- }
- return string->LowerCaseEqualsASCII(lowerCaseLiteral);
+ return string.LowerCaseEqualsASCII(lowerCaseLiteral);
}
bool
-nsHtml5Portability::literalEqualsString(const char* literal, nsString* string)
+nsHtml5Portability::literalEqualsString(const char* literal,
+ nsHtml5String string)
{
- if (!string) {
- return false;
- }
- return string->EqualsASCII(literal);
+ return string.EqualsASCII(literal);
}
bool
-nsHtml5Portability::stringEqualsString(nsString* one, nsString* other)
+nsHtml5Portability::stringEqualsString(nsHtml5String one, nsHtml5String other)
{
- return one->Equals(*other);
+ return one.Equals(other);
}
void
diff --git a/parser/html/nsHtml5Portability.h b/parser/html/nsHtml5Portability.h
index bd85ccbdb..a3214dd2f 100644
--- a/parser/html/nsHtml5Portability.h
+++ b/parser/html/nsHtml5Portability.h
@@ -30,7 +30,7 @@
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
-#include "nsString.h"
+#include "nsHtml5String.h"
#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
@@ -59,19 +59,26 @@ class nsHtml5Portability
{
public:
static nsIAtom* newLocalNameFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner);
- static nsString* newStringFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5TreeBuilder* treeBuilder);
- static nsString* newEmptyString();
- static nsString* newStringFromLiteral(const char* literal);
- static nsString* newStringFromString(nsString* string);
+ static nsHtml5String newStringFromBuffer(char16_t* buf,
+ int32_t offset,
+ int32_t length,
+ nsHtml5TreeBuilder* treeBuilder);
+ static nsHtml5String newEmptyString();
+ static nsHtml5String newStringFromLiteral(const char* literal);
+ static nsHtml5String newStringFromString(nsHtml5String string);
static jArray newCharArrayFromLocal(nsIAtom* local);
- static jArray newCharArrayFromString(nsString* string);
+ static jArray newCharArrayFromString(
+ nsHtml5String string);
static nsIAtom* newLocalFromLocal(nsIAtom* local, nsHtml5AtomTable* interner);
- static void releaseString(nsString* str);
static bool localEqualsBuffer(nsIAtom* local, char16_t* buf, int32_t offset, int32_t length);
- static bool lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString(const char* lowerCaseLiteral, nsString* string);
- static bool lowerCaseLiteralEqualsIgnoreAsciiCaseString(const char* lowerCaseLiteral, nsString* string);
- static bool literalEqualsString(const char* literal, nsString* string);
- static bool stringEqualsString(nsString* one, nsString* other);
+ static bool lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString(
+ const char* lowerCaseLiteral,
+ nsHtml5String string);
+ static bool lowerCaseLiteralEqualsIgnoreAsciiCaseString(
+ const char* lowerCaseLiteral,
+ nsHtml5String string);
+ static bool literalEqualsString(const char* literal, nsHtml5String string);
+ static bool stringEqualsString(nsHtml5String one, nsHtml5String other);
static void initializeStatics();
static void releaseStatics();
};
diff --git a/parser/html/nsHtml5SpeculativeLoad.h b/parser/html/nsHtml5SpeculativeLoad.h
index 57dcc2697..92ef70319 100644
--- a/parser/html/nsHtml5SpeculativeLoad.h
+++ b/parser/html/nsHtml5SpeculativeLoad.h
@@ -34,45 +34,57 @@ class nsHtml5SpeculativeLoad {
nsHtml5SpeculativeLoad();
~nsHtml5SpeculativeLoad();
- inline void InitBase(const nsAString& aUrl)
+ inline void InitBase(nsHtml5String aUrl)
{
NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
"Trying to reinitialize a speculative load!");
mOpCode = eSpeculativeLoadBase;
- mUrl.Assign(aUrl);
+ aUrl.ToString(mUrl);
}
- inline void InitMetaCSP(const nsAString& aCSP) {
+ inline void InitMetaCSP(nsHtml5String aCSP)
+ {
NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
"Trying to reinitialize a speculative load!");
mOpCode = eSpeculativeLoadCSP;
+ nsString csp; // Not Auto, because using it to hold nsStringBuffer*
+ aCSP.ToString(csp);
mMetaCSP.Assign(
- nsContentUtils::TrimWhitespace(aCSP));
+ nsContentUtils::TrimWhitespace(csp));
}
- inline void InitMetaReferrerPolicy(const nsAString& aReferrerPolicy) {
+ inline void InitMetaReferrerPolicy(nsHtml5String aReferrerPolicy)
+ {
NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
"Trying to reinitialize a speculative load!");
mOpCode = eSpeculativeLoadMetaReferrer;
+ nsString
+ referrerPolicy; // Not Auto, because using it to hold nsStringBuffer*
+ aReferrerPolicy.ToString(referrerPolicy);
mReferrerPolicy.Assign(
- nsContentUtils::TrimWhitespace(aReferrerPolicy));
+ nsContentUtils::TrimWhitespace(
+ referrerPolicy));
}
- inline void InitImage(const nsAString& aUrl,
- const nsAString& aCrossOrigin,
- const nsAString& aReferrerPolicy,
- const nsAString& aSrcset,
- const nsAString& aSizes)
+ inline void InitImage(nsHtml5String aUrl,
+ nsHtml5String aCrossOrigin,
+ nsHtml5String aReferrerPolicy,
+ nsHtml5String aSrcset,
+ nsHtml5String aSizes)
{
NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
"Trying to reinitialize a speculative load!");
mOpCode = eSpeculativeLoadImage;
- mUrl.Assign(aUrl);
- mCrossOrigin.Assign(aCrossOrigin);
+ aUrl.ToString(mUrl);
+ aCrossOrigin.ToString(mCrossOrigin);
+ nsString
+ referrerPolicy; // Not Auto, because using it to hold nsStringBuffer*
+ aReferrerPolicy.ToString(referrerPolicy);
mReferrerPolicy.Assign(
- nsContentUtils::TrimWhitespace(aReferrerPolicy));
- mSrcset.Assign(aSrcset);
- mSizes.Assign(aSizes);
+ nsContentUtils::TrimWhitespace(
+ referrerPolicy));
+ aSrcset.ToString(mSrcset);
+ aSizes.ToString(mSizes);
}
//