1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "nsHtml5Atom.h"
8 nsHtml5Atom::nsHtml5Atom(const nsAString
& aString
)
10 mLength
= aString
.Length();
11 nsRefPtr
<nsStringBuffer
> buf
= nsStringBuffer::FromString(aString
);
13 mString
= static_cast<PRUnichar
*>(buf
->Data());
15 buf
= nsStringBuffer::Alloc((mLength
+ 1) * sizeof(PRUnichar
));
16 mString
= static_cast<PRUnichar
*>(buf
->Data());
17 CopyUnicodeTo(aString
, 0, mString
, mLength
);
18 mString
[mLength
] = PRUnichar(0);
21 NS_ASSERTION(mString
[mLength
] == PRUnichar(0), "null terminated");
22 NS_ASSERTION(buf
&& buf
->StorageSize() >= (mLength
+1) * sizeof(PRUnichar
),
24 NS_ASSERTION(Equals(aString
), "correct data");
26 // Take ownership of buffer
30 nsHtml5Atom::~nsHtml5Atom()
32 nsStringBuffer::FromData(mString
)->Release();
35 NS_IMETHODIMP_(nsrefcnt
)
38 NS_NOTREACHED("Attempt to AddRef an nsHtml5Atom.");
42 NS_IMETHODIMP_(nsrefcnt
)
43 nsHtml5Atom::Release()
45 NS_NOTREACHED("Attempt to Release an nsHtml5Atom.");
50 nsHtml5Atom::QueryInterface(REFNSIID aIID
, void** aInstancePtr
)
52 NS_NOTREACHED("Attempt to call QueryInterface an nsHtml5Atom.");
53 return NS_ERROR_UNEXPECTED
;
57 nsHtml5Atom::ScriptableToString(nsAString
& aBuf
)
59 NS_NOTREACHED("Should not call ScriptableToString.");
60 return NS_ERROR_NOT_IMPLEMENTED
;
64 nsHtml5Atom::ToUTF8String(nsACString
& aReturn
)
66 NS_NOTREACHED("Should not attempt to convert to an UTF-8 string.");
67 return NS_ERROR_NOT_IMPLEMENTED
;
71 nsHtml5Atom::IsStaticAtom()
77 nsHtml5Atom::ScriptableEquals(const nsAString
& aString
, bool* aResult
)
79 NS_NOTREACHED("Should not call ScriptableEquals.");
80 return NS_ERROR_NOT_IMPLEMENTED
;
84 nsHtml5Atom::EqualsUTF8(const nsACString
& aString
)
86 NS_NOTREACHED("Should not attempt to compare with an UTF-8 string.");