| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 enum class SerializationType { | 60 enum class SerializationType { |
| 61 AsOwnerDocument, | 61 AsOwnerDocument, |
| 62 ForcedXML | 62 ForcedXML |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 class MarkupFormatter final { | 65 class MarkupFormatter final { |
| 66 WTF_MAKE_NONCOPYABLE(MarkupFormatter); | 66 WTF_MAKE_NONCOPYABLE(MarkupFormatter); |
| 67 STACK_ALLOCATED(); | 67 STACK_ALLOCATED(); |
| 68 public: | 68 public: |
| 69 static void appendAttributeValue(StringBuilder&, const String&, bool); |
| 70 static void appendCDATASection(StringBuilder&, const String&); |
| 71 static void appendCharactersReplacingEntities(StringBuilder&, const String&,
unsigned, unsigned, EntityMask); |
| 69 static void appendComment(StringBuilder&, const String&); | 72 static void appendComment(StringBuilder&, const String&); |
| 70 static void appendCharactersReplacingEntities(StringBuilder&, const String&,
unsigned, unsigned, EntityMask); | 73 static void appendDocumentType(StringBuilder&, const DocumentType&); |
| 74 static void appendNamespace(StringBuilder&, const AtomicString& prefix, cons
t AtomicString& namespaceURI, Namespaces&); |
| 75 static void appendProcessingInstruction(StringBuilder&, const String& target
, const String& data); |
| 76 static void appendXMLDeclaration(StringBuilder&, const Document&); |
| 71 static size_t totalLength(const Vector<String>&); | 77 static size_t totalLength(const Vector<String>&); |
| 72 | 78 |
| 73 MarkupFormatter(EAbsoluteURLs, SerializationType = SerializationType::AsOwne
rDocument); | 79 MarkupFormatter(EAbsoluteURLs, SerializationType = SerializationType::AsOwne
rDocument); |
| 74 ~MarkupFormatter(); | 80 ~MarkupFormatter(); |
| 75 | 81 |
| 76 void appendEndMarkup(StringBuilder&, const Element&); | 82 void appendEndMarkup(StringBuilder&, const Element&); |
| 77 | 83 |
| 78 bool serializeAsHTMLDocument(const Node&) const; | 84 bool serializeAsHTMLDocument(const Node&) const; |
| 79 | 85 |
| 80 void appendAttributeValue(StringBuilder&, const String&, bool); | |
| 81 | |
| 82 void appendNamespace(StringBuilder&, const AtomicString& prefix, const Atomi
cString& namespaceURI, Namespaces&); | |
| 83 void appendText(StringBuilder&, Text&); | 86 void appendText(StringBuilder&, Text&); |
| 84 void appendXMLDeclaration(StringBuilder&, const Document&); | |
| 85 void appendDocumentType(StringBuilder&, const DocumentType&); | |
| 86 void appendProcessingInstruction(StringBuilder&, const String& target, const
String& data); | |
| 87 void appendOpenTag(StringBuilder&, const Element&, Namespaces*); | 87 void appendOpenTag(StringBuilder&, const Element&, Namespaces*); |
| 88 void appendCloseTag(StringBuilder&, const Element&); | 88 void appendCloseTag(StringBuilder&, const Element&); |
| 89 void appendAttribute(StringBuilder&, const Element&, const Attribute&, Names
paces*); | 89 void appendAttribute(StringBuilder&, const Element&, const Attribute&, Names
paces*); |
| 90 void appendCDATASection(StringBuilder&, const String&); | |
| 91 | 90 |
| 92 bool shouldAddNamespaceElement(const Element&, Namespaces&) const; | 91 bool shouldAddNamespaceElement(const Element&, Namespaces&) const; |
| 93 bool shouldAddNamespaceAttribute(const Attribute&, const Element&) const; | 92 bool shouldAddNamespaceAttribute(const Attribute&, const Element&) const; |
| 94 EntityMask entityMaskForText(const Text&) const; | 93 EntityMask entityMaskForText(const Text&) const; |
| 95 bool shouldSelfClose(const Element&) const; | 94 bool shouldSelfClose(const Element&) const; |
| 96 | 95 |
| 97 private: | 96 private: |
| 98 String resolveURLIfNeeded(const Element&, const String&) const; | 97 String resolveURLIfNeeded(const Element&, const String&) const; |
| 99 void appendQuotedURLAttributeValue(StringBuilder&, const Element&, const Att
ribute&); | 98 void appendQuotedURLAttributeValue(StringBuilder&, const Element&, const Att
ribute&); |
| 100 | 99 |
| 101 const EAbsoluteURLs m_resolveURLsMethod; | 100 const EAbsoluteURLs m_resolveURLsMethod; |
| 102 SerializationType m_serializationType; | 101 SerializationType m_serializationType; |
| 103 }; | 102 }; |
| 104 | 103 |
| 105 } | 104 } |
| 106 | 105 |
| 107 #endif | 106 #endif |
| OLD | NEW |