Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
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
19 {
20 public:
21 nsDOMSerializer();
22 virtual ~nsDOMSerializer();
24 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
25 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMSerializer)
27 // nsIDOMSerializer
28 NS_DECL_NSIDOMSERIALIZER
30 // WebIDL API
31 static already_AddRefed<nsDOMSerializer>
32 Constructor(const mozilla::dom::GlobalObject& aOwner,
33 mozilla::ErrorResult& rv)
34 {
35 nsRefPtr<nsDOMSerializer> domSerializer = new nsDOMSerializer(aOwner.GetAsSupports());
36 return domSerializer.forget();
37 }
39 void
40 SerializeToString(nsINode& aRoot, nsAString& aStr,
41 mozilla::ErrorResult& rv);
43 void
44 SerializeToStream(nsINode& aRoot, nsIOutputStream* aStream,
45 const nsAString& aCharset, mozilla::ErrorResult& rv);
47 nsISupports* GetParentObject() const
48 {
49 return mOwner;
50 }
52 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
53 {
54 return mozilla::dom::XMLSerializerBinding::Wrap(aCx, this);
55 }
57 private:
58 nsDOMSerializer(nsISupports* aOwner) : mOwner(aOwner)
59 {
60 MOZ_ASSERT(aOwner);
61 SetIsDOMBinding();
62 }
64 nsCOMPtr<nsISupports> mOwner;
65 };
68 #endif