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"
7 nsHtml5Atom::nsHtml5Atom(const nsAString
& aString
)
9 mLength
= aString
.Length();
10 nsStringBuffer
* buf
= nsStringBuffer::FromString(aString
);
13 mString
= static_cast<PRUnichar
*>(buf
->Data());
16 buf
= nsStringBuffer::Alloc((mLength
+ 1) * sizeof(PRUnichar
));
17 mString
= static_cast<PRUnichar
*>(buf
->Data());
18 CopyUnicodeTo(aString
, 0, mString
, mLength
);
19 mString
[mLength
] = PRUnichar(0);
22 NS_ASSERTION(mString
[mLength
] == PRUnichar(0), "null terminated");
23 NS_ASSERTION(buf
&& buf
->StorageSize() >= (mLength
+1) * sizeof(PRUnichar
),
25 NS_ASSERTION(Equals(aString
), "correct data");
28 nsHtml5Atom::~nsHtml5Atom()
30 nsStringBuffer::FromData(mString
)->Release();
33 NS_IMETHODIMP_(nsrefcnt
)
36 NS_NOTREACHED("Attempt to AddRef an nsHtml5Atom.");
40 NS_IMETHODIMP_(nsrefcnt
)
41 nsHtml5Atom::Release()
43 NS_NOTREACHED("Attempt to Release an nsHtml5Atom.");
48 nsHtml5Atom::QueryInterface(REFNSIID aIID
, void** aInstancePtr
)
50 NS_NOTREACHED("Attempt to call QueryInterface an nsHtml5Atom.");
51 return NS_ERROR_UNEXPECTED
;
55 nsHtml5Atom::ScriptableToString(nsAString
& aBuf
)
57 NS_NOTREACHED("Should not call ScriptableToString.");
58 return NS_ERROR_NOT_IMPLEMENTED
;
62 nsHtml5Atom::ToUTF8String(nsACString
& aReturn
)
64 NS_NOTREACHED("Should not attempt to convert to an UTF-8 string.");
65 return NS_ERROR_NOT_IMPLEMENTED
;
69 nsHtml5Atom::IsStaticAtom()
75 nsHtml5Atom::ScriptableEquals(const nsAString
& aString
, bool* aResult
)
77 NS_NOTREACHED("Should not call ScriptableEquals.");
78 return NS_ERROR_NOT_IMPLEMENTED
;
82 nsHtml5Atom::EqualsUTF8(const nsACString
& aString
)
84 NS_NOTREACHED("Should not attempt to compare with an UTF-8 string.");