michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsAttrValueOrString.h" michael@0: michael@0: const nsAString& michael@0: nsAttrValueOrString::String() const michael@0: { michael@0: if (mStringPtr) { michael@0: return *mStringPtr; michael@0: } michael@0: michael@0: if (mAttrValue->Type() == nsAttrValue::eString) { michael@0: mCheapString = mAttrValue->GetStringValue(); michael@0: mStringPtr = &mCheapString; michael@0: return *mStringPtr; michael@0: } michael@0: michael@0: mAttrValue->ToString(mCheapString); michael@0: mStringPtr = &mCheapString; michael@0: return *mStringPtr; michael@0: }