| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights
reserved. |
| 3 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. | 3 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 , m_range(range) | 102 , m_range(range) |
| 103 , m_resolveURLsMethod(resolveUrlsMethod) | 103 , m_resolveURLsMethod(resolveUrlsMethod) |
| 104 , m_serializationType(serializationType) | 104 , m_serializationType(serializationType) |
| 105 { | 105 { |
| 106 } | 106 } |
| 107 | 107 |
| 108 MarkupAccumulator::~MarkupAccumulator() | 108 MarkupAccumulator::~MarkupAccumulator() |
| 109 { | 109 { |
| 110 } | 110 } |
| 111 | 111 |
| 112 String MarkupAccumulator::serializeNodes(Node& targetNode, EChildrenOnly childre
nOnly, Vector<QualifiedName>* tagNamesToSkip) | 112 String MarkupAccumulator::serializeNodes(Node& targetNode, EChildrenOnly childre
nOnly) |
| 113 { | 113 { |
| 114 Namespaces* namespaces = nullptr; | 114 Namespaces* namespaces = nullptr; |
| 115 Namespaces namespaceHash; | 115 Namespaces namespaceHash; |
| 116 if (!serializeAsHTMLDocument(targetNode)) { | 116 if (!serializeAsHTMLDocument(targetNode)) { |
| 117 // Add pre-bound namespaces for XML fragments. | 117 // Add pre-bound namespaces for XML fragments. |
| 118 namespaceHash.set(xmlAtom, XMLNames::xmlNamespaceURI); | 118 namespaceHash.set(xmlAtom, XMLNames::xmlNamespaceURI); |
| 119 namespaces = &namespaceHash; | 119 namespaces = &namespaceHash; |
| 120 } | 120 } |
| 121 | 121 |
| 122 serializeNodesWithNamespaces(targetNode, childrenOnly, namespaces, tagNamesT
oSkip); | 122 serializeNodesWithNamespaces(targetNode, childrenOnly, namespaces); |
| 123 return m_markup.toString(); | 123 return m_markup.toString(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void MarkupAccumulator::serializeNodesWithNamespaces(Node& targetNode, EChildren
Only childrenOnly, const Namespaces* namespaces, Vector<QualifiedName>* tagNames
ToSkip) | 126 void MarkupAccumulator::serializeNodesWithNamespaces(Node& targetNode, EChildren
Only childrenOnly, const Namespaces* namespaces) |
| 127 { | 127 { |
| 128 if (tagNamesToSkip && targetNode.isElementNode()) { | |
| 129 for (const auto& tag : *tagNamesToSkip) { | |
| 130 if (toElement(targetNode).hasTagName(tag)) | |
| 131 return; | |
| 132 } | |
| 133 } | |
| 134 | |
| 135 Namespaces namespaceHash; | 128 Namespaces namespaceHash; |
| 136 if (namespaces) | 129 if (namespaces) |
| 137 namespaceHash = *namespaces; | 130 namespaceHash = *namespaces; |
| 138 | 131 |
| 139 if (!childrenOnly) | 132 if (!childrenOnly) |
| 140 appendStartTag(targetNode, &namespaceHash); | 133 appendStartTag(targetNode, &namespaceHash); |
| 141 | 134 |
| 142 if (!(serializeAsHTMLDocument(targetNode) && elementCannotHaveEndTag(targetN
ode))) { | 135 if (!(serializeAsHTMLDocument(targetNode) && elementCannotHaveEndTag(targetN
ode))) { |
| 143 Node* current = isHTMLTemplateElement(targetNode) ? toHTMLTemplateElemen
t(targetNode).content()->firstChild() : targetNode.firstChild(); | 136 Node* current = isHTMLTemplateElement(targetNode) ? toHTMLTemplateElemen
t(targetNode).content()->firstChild() : targetNode.firstChild(); |
| 144 for ( ; current; current = current->nextSibling()) | 137 for ( ; current; current = current->nextSibling()) |
| 145 serializeNodesWithNamespaces(*current, IncludeNode, &namespaceHash,
tagNamesToSkip); | 138 serializeNodesWithNamespaces(*current, IncludeNode, &namespaceHash); |
| 146 } | 139 } |
| 147 | 140 |
| 148 if (!childrenOnly && targetNode.isElementNode()) | 141 if (!childrenOnly && targetNode.isElementNode()) |
| 149 appendEndTag(toElement(targetNode)); | 142 appendEndTag(toElement(targetNode)); |
| 150 } | 143 } |
| 151 | 144 |
| 152 String MarkupAccumulator::resolveURLIfNeeded(const Element& element, const Strin
g& urlString) const | 145 String MarkupAccumulator::resolveURLIfNeeded(const Element& element, const Strin
g& urlString) const |
| 153 { | 146 { |
| 154 switch (m_resolveURLsMethod) { | 147 switch (m_resolveURLsMethod) { |
| 155 case ResolveAllURLs: | 148 case ResolveAllURLs: |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 } | 550 } |
| 558 | 551 |
| 559 bool MarkupAccumulator::serializeAsHTMLDocument(const Node& node) const | 552 bool MarkupAccumulator::serializeAsHTMLDocument(const Node& node) const |
| 560 { | 553 { |
| 561 if (m_serializationType == ForcedXML) | 554 if (m_serializationType == ForcedXML) |
| 562 return false; | 555 return false; |
| 563 return node.document().isHTMLDocument(); | 556 return node.document().isHTMLDocument(); |
| 564 } | 557 } |
| 565 | 558 |
| 566 } | 559 } |
| OLD | NEW |