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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 // Non-breaking space needs to be escaped in innerHTML for compatibility rea
son. See http://trac.webkit.org/changeset/32879 | 51 // Non-breaking space needs to be escaped in innerHTML for compatibility rea
son. See http://trac.webkit.org/changeset/32879 |
52 // However, we cannot do this in a XML document because it does not have the
entity reference defined (See the bug 19215). | 52 // However, we cannot do this in a XML document because it does not have the
entity reference defined (See the bug 19215). |
53 EntityMaskInCDATA = 0, | 53 EntityMaskInCDATA = 0, |
54 EntityMaskInPCDATA = EntityAmp | EntityLt | EntityGt, | 54 EntityMaskInPCDATA = EntityAmp | EntityLt | EntityGt, |
55 EntityMaskInHTMLPCDATA = EntityMaskInPCDATA | EntityNbsp, | 55 EntityMaskInHTMLPCDATA = EntityMaskInPCDATA | EntityNbsp, |
56 EntityMaskInAttributeValue = EntityAmp | EntityQuot | EntityLt | EntityGt, | 56 EntityMaskInAttributeValue = EntityAmp | EntityQuot | EntityLt | EntityGt, |
57 EntityMaskInHTMLAttributeValue = EntityAmp | EntityQuot | EntityNbsp, | 57 EntityMaskInHTMLAttributeValue = EntityAmp | EntityQuot | EntityNbsp, |
58 }; | 58 }; |
59 | 59 |
| 60 enum SerializationType { |
| 61 AsOwnerDocument, |
| 62 ForcedXML |
| 63 }; |
| 64 |
60 class MarkupAccumulator { | 65 class MarkupAccumulator { |
61 WTF_MAKE_NONCOPYABLE(MarkupAccumulator); | 66 WTF_MAKE_NONCOPYABLE(MarkupAccumulator); |
62 | 67 |
63 public: | 68 public: |
64 MarkupAccumulator(Vector<Node*>*, EAbsoluteURLs, const Range* = 0); | 69 MarkupAccumulator(Vector<Node*>*, EAbsoluteURLs, const Range* = 0, Serializa
tionType = AsOwnerDocument); |
65 virtual ~MarkupAccumulator(); | 70 virtual ~MarkupAccumulator(); |
66 | 71 |
67 String serializeNodes(Node& targetNode, EChildrenOnly, Vector<QualifiedName>
* tagNamesToSkip = 0); | 72 String serializeNodes(Node& targetNode, EChildrenOnly, Vector<QualifiedName>
* tagNamesToSkip = 0); |
68 | 73 |
69 static void appendComment(StringBuilder&, const String&); | 74 static void appendComment(StringBuilder&, const String&); |
70 | 75 |
71 static void appendCharactersReplacingEntities(StringBuilder&, const String&,
unsigned, unsigned, EntityMask); | 76 static void appendCharactersReplacingEntities(StringBuilder&, const String&,
unsigned, unsigned, EntityMask); |
72 | 77 |
73 protected: | 78 protected: |
74 void appendString(const String&); | 79 void appendString(const String&); |
(...skipping 22 matching lines...) Expand all Loading... |
97 bool elementCannotHaveEndTag(const Node&); | 102 bool elementCannotHaveEndTag(const Node&); |
98 void appendEndMarkup(StringBuilder&, const Node&); | 103 void appendEndMarkup(StringBuilder&, const Node&); |
99 | 104 |
100 Vector<Node*>* const m_nodes; | 105 Vector<Node*>* const m_nodes; |
101 const Range* const m_range; | 106 const Range* const m_range; |
102 | 107 |
103 private: | 108 private: |
104 String resolveURLIfNeeded(const Element&, const String&) const; | 109 String resolveURLIfNeeded(const Element&, const String&) const; |
105 void appendQuotedURLAttributeValue(StringBuilder&, const Element&, const Att
ribute&); | 110 void appendQuotedURLAttributeValue(StringBuilder&, const Element&, const Att
ribute&); |
106 void serializeNodesWithNamespaces(Node& targetNode, EChildrenOnly, const Nam
espaces*, Vector<QualifiedName>* tagNamesToSkip); | 111 void serializeNodesWithNamespaces(Node& targetNode, EChildrenOnly, const Nam
espaces*, Vector<QualifiedName>* tagNamesToSkip); |
| 112 bool serializeAsHTMLDocument(const Node&) const; |
107 | 113 |
108 StringBuilder m_markup; | 114 StringBuilder m_markup; |
109 const EAbsoluteURLs m_resolveURLsMethod; | 115 const EAbsoluteURLs m_resolveURLsMethod; |
| 116 SerializationType m_serializationType; |
110 }; | 117 }; |
111 | 118 |
112 } | 119 } |
113 | 120 |
114 #endif | 121 #endif |
OLD | NEW |