1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 /* 8 * nsIContentSerializer implementation that can be used with an 9 * nsIDocumentEncoder to convert an HTML (not XHTML!) DOM to an HTML 10 * string that could be parsed into more or less the original DOM. 11 */ 12 13 #ifndef nsHTMLContentSerializer_h__ 14 #define nsHTMLContentSerializer_h__ 15 16 #include "mozilla/Attributes.h" 17 #include "nsXHTMLContentSerializer.h" 18 #include "nsString.h" 19 20 class nsAtom; 21 22 class nsHTMLContentSerializer final : public nsXHTMLContentSerializer { 23 public: 24 nsHTMLContentSerializer(); 25 virtual ~nsHTMLContentSerializer(); 26 27 NS_IMETHOD AppendElementStart( 28 mozilla::dom::Element* aElement, 29 mozilla::dom::Element* aOriginalElement) override; 30 31 NS_IMETHOD AppendElementEnd(mozilla::dom::Element* aElement, 32 mozilla::dom::Element* aOriginalElement) override; 33 34 NS_IMETHOD AppendDocumentStart(mozilla::dom::Document* aDocument) override; 35 36 protected: 37 MOZ_MUST_USE 38 virtual bool SerializeHTMLAttributes(mozilla::dom::Element* aContent, 39 mozilla::dom::Element* aOriginalElement, 40 nsAString& aTagPrefix, 41 const nsAString& aTagNamespaceURI, 42 nsAtom* aTagName, int32_t aNamespace, 43 nsAString& aStr); 44 45 MOZ_MUST_USE 46 virtual bool AppendAndTranslateEntities(const nsAString& aStr, 47 nsAString& aOutputStr) override; 48 }; 49 50 nsresult NS_NewHTMLContentSerializer(nsIContentSerializer** aSerializer); 51 52 #endif 53