Bumping gaia.json for 8 gaia revision(s) a=gaia-bump
[gecko.git] / dom / base / nsDOMSerializer.h
blobb8459593829101cb84be58aa140f6399dc3b87ee
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsDOMSerializer_h_
7 #define nsDOMSerializer_h_
9 #include "nsIDOMSerializer.h"
10 #include "nsWrapperCache.h"
11 #include "mozilla/ErrorResult.h"
12 #include "mozilla/dom/XMLSerializerBinding.h"
13 #include "nsAutoPtr.h"
15 class nsINode;
17 class nsDOMSerializer MOZ_FINAL : public nsIDOMSerializer,
18 public nsWrapperCache
20 public:
21 nsDOMSerializer();
23 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
24 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMSerializer)
26 // nsIDOMSerializer
27 NS_DECL_NSIDOMSERIALIZER
29 // WebIDL API
30 static already_AddRefed<nsDOMSerializer>
31 Constructor(const mozilla::dom::GlobalObject& aOwner,
32 mozilla::ErrorResult& rv)
34 nsRefPtr<nsDOMSerializer> domSerializer = new nsDOMSerializer(aOwner.GetAsSupports());
35 return domSerializer.forget();
38 void
39 SerializeToString(nsINode& aRoot, nsAString& aStr,
40 mozilla::ErrorResult& rv);
42 void
43 SerializeToStream(nsINode& aRoot, nsIOutputStream* aStream,
44 const nsAString& aCharset, mozilla::ErrorResult& rv);
46 nsISupports* GetParentObject() const
48 return mOwner;
51 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
53 return mozilla::dom::XMLSerializerBinding::Wrap(aCx, this);
56 private:
57 virtual ~nsDOMSerializer();
59 explicit nsDOMSerializer(nsISupports* aOwner) : mOwner(aOwner)
61 MOZ_ASSERT(aOwner);
64 nsCOMPtr<nsISupports> mOwner;
68 #endif