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 michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsDOMSerializer_h_ michael@0: #define nsDOMSerializer_h_ michael@0: michael@0: #include "nsIDOMSerializer.h" michael@0: #include "nsWrapperCache.h" michael@0: #include "mozilla/ErrorResult.h" michael@0: #include "mozilla/dom/XMLSerializerBinding.h" michael@0: #include "nsAutoPtr.h" michael@0: michael@0: class nsINode; michael@0: michael@0: class nsDOMSerializer MOZ_FINAL : public nsIDOMSerializer, michael@0: public nsWrapperCache michael@0: { michael@0: public: michael@0: nsDOMSerializer(); michael@0: virtual ~nsDOMSerializer(); michael@0: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMSerializer) michael@0: michael@0: // nsIDOMSerializer michael@0: NS_DECL_NSIDOMSERIALIZER michael@0: michael@0: // WebIDL API michael@0: static already_AddRefed michael@0: Constructor(const mozilla::dom::GlobalObject& aOwner, michael@0: mozilla::ErrorResult& rv) michael@0: { michael@0: nsRefPtr domSerializer = new nsDOMSerializer(aOwner.GetAsSupports()); michael@0: return domSerializer.forget(); michael@0: } michael@0: michael@0: void michael@0: SerializeToString(nsINode& aRoot, nsAString& aStr, michael@0: mozilla::ErrorResult& rv); michael@0: michael@0: void michael@0: SerializeToStream(nsINode& aRoot, nsIOutputStream* aStream, michael@0: const nsAString& aCharset, mozilla::ErrorResult& rv); michael@0: michael@0: nsISupports* GetParentObject() const michael@0: { michael@0: return mOwner; michael@0: } michael@0: michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE michael@0: { michael@0: return mozilla::dom::XMLSerializerBinding::Wrap(aCx, this); michael@0: } michael@0: michael@0: private: michael@0: nsDOMSerializer(nsISupports* aOwner) : mOwner(aOwner) michael@0: { michael@0: MOZ_ASSERT(aOwner); michael@0: SetIsDOMBinding(); michael@0: } michael@0: michael@0: nsCOMPtr mOwner; michael@0: }; michael@0: michael@0: michael@0: #endif michael@0: