Bug 773151: Convert nsCAutoString->nsAutoCString CLOSED TREE r=bsmedberg
[gecko.git] / parser / html / nsHtml5Atom.cpp
blobbb3e0bb4f71e33436ef296699fbb2644fb64f9ec
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);
11 if (buf) {
12 buf->AddRef();
13 mString = static_cast<PRUnichar*>(buf->Data());
15 else {
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),
24 "enough storage");
25 NS_ASSERTION(Equals(aString), "correct data");
28 nsHtml5Atom::~nsHtml5Atom()
30 nsStringBuffer::FromData(mString)->Release();
33 NS_IMETHODIMP_(nsrefcnt)
34 nsHtml5Atom::AddRef()
36 NS_NOTREACHED("Attempt to AddRef an nsHtml5Atom.");
37 return 2;
40 NS_IMETHODIMP_(nsrefcnt)
41 nsHtml5Atom::Release()
43 NS_NOTREACHED("Attempt to Release an nsHtml5Atom.");
44 return 1;
47 NS_IMETHODIMP
48 nsHtml5Atom::QueryInterface(REFNSIID aIID, void** aInstancePtr)
50 NS_NOTREACHED("Attempt to call QueryInterface an nsHtml5Atom.");
51 return NS_ERROR_UNEXPECTED;
54 NS_IMETHODIMP
55 nsHtml5Atom::ScriptableToString(nsAString& aBuf)
57 NS_NOTREACHED("Should not call ScriptableToString.");
58 return NS_ERROR_NOT_IMPLEMENTED;
61 NS_IMETHODIMP
62 nsHtml5Atom::ToUTF8String(nsACString& aReturn)
64 NS_NOTREACHED("Should not attempt to convert to an UTF-8 string.");
65 return NS_ERROR_NOT_IMPLEMENTED;
68 NS_IMETHODIMP_(bool)
69 nsHtml5Atom::IsStaticAtom()
71 return false;
74 NS_IMETHODIMP
75 nsHtml5Atom::ScriptableEquals(const nsAString& aString, bool* aResult)
77 NS_NOTREACHED("Should not call ScriptableEquals.");
78 return NS_ERROR_NOT_IMPLEMENTED;
81 NS_IMETHODIMP_(bool)
82 nsHtml5Atom::EqualsUTF8(const nsACString& aString)
84 NS_NOTREACHED("Should not attempt to compare with an UTF-8 string.");
85 return false;