1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/src/nsDOMSerializer.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,69 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsDOMSerializer_h_ 1.10 +#define nsDOMSerializer_h_ 1.11 + 1.12 +#include "nsIDOMSerializer.h" 1.13 +#include "nsWrapperCache.h" 1.14 +#include "mozilla/ErrorResult.h" 1.15 +#include "mozilla/dom/XMLSerializerBinding.h" 1.16 +#include "nsAutoPtr.h" 1.17 + 1.18 +class nsINode; 1.19 + 1.20 +class nsDOMSerializer MOZ_FINAL : public nsIDOMSerializer, 1.21 + public nsWrapperCache 1.22 +{ 1.23 +public: 1.24 + nsDOMSerializer(); 1.25 + virtual ~nsDOMSerializer(); 1.26 + 1.27 + NS_DECL_CYCLE_COLLECTING_ISUPPORTS 1.28 + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMSerializer) 1.29 + 1.30 + // nsIDOMSerializer 1.31 + NS_DECL_NSIDOMSERIALIZER 1.32 + 1.33 + // WebIDL API 1.34 + static already_AddRefed<nsDOMSerializer> 1.35 + Constructor(const mozilla::dom::GlobalObject& aOwner, 1.36 + mozilla::ErrorResult& rv) 1.37 + { 1.38 + nsRefPtr<nsDOMSerializer> domSerializer = new nsDOMSerializer(aOwner.GetAsSupports()); 1.39 + return domSerializer.forget(); 1.40 + } 1.41 + 1.42 + void 1.43 + SerializeToString(nsINode& aRoot, nsAString& aStr, 1.44 + mozilla::ErrorResult& rv); 1.45 + 1.46 + void 1.47 + SerializeToStream(nsINode& aRoot, nsIOutputStream* aStream, 1.48 + const nsAString& aCharset, mozilla::ErrorResult& rv); 1.49 + 1.50 + nsISupports* GetParentObject() const 1.51 + { 1.52 + return mOwner; 1.53 + } 1.54 + 1.55 + virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE 1.56 + { 1.57 + return mozilla::dom::XMLSerializerBinding::Wrap(aCx, this); 1.58 + } 1.59 + 1.60 +private: 1.61 + nsDOMSerializer(nsISupports* aOwner) : mOwner(aOwner) 1.62 + { 1.63 + MOZ_ASSERT(aOwner); 1.64 + SetIsDOMBinding(); 1.65 + } 1.66 + 1.67 + nsCOMPtr<nsISupports> mOwner; 1.68 +}; 1.69 + 1.70 + 1.71 +#endif 1.72 +