void MarkupAccumulator::serializeNodesWithNamespaces(Node& targetNode, EChildrenOnly childrenOnly, const Namespaces* namespaces, Vector<QualifiedName>* tagNamesToSkip) { if (tagNamesToSkip) { for (size_t i = 0; i < tagNamesToSkip->size(); ++i) { if (targetNode.hasTagName(tagNamesToSkip->at(i))) return; } } Namespaces namespaceHash; if (namespaces) namespaceHash = *namespaces; if (!childrenOnly) appendStartTag(targetNode, &namespaceHash); if (!(serializeAsHTMLDocument(targetNode) && elementCannotHaveEndTag(targetNode))) { Node* current = isHTMLTemplateElement(targetNode) ? toHTMLTemplateElement(targetNode).content()->firstChild() : targetNode.firstChild(); for ( ; current; current = current->nextSibling()) serializeNodesWithNamespaces(*current, IncludeNode, &namespaceHash, tagNamesToSkip); } if (!childrenOnly) appendEndTag(targetNode); }
void MarkupAccumulator::serializeNodesWithNamespaces(Node* targetNode, Node* nodeToSkip, EChildrenOnly childrenOnly, const Namespaces* namespaces, Vector<QualifiedName>* tagNamesToSkip) { if (targetNode == nodeToSkip) return; if (tagNamesToSkip) { for (size_t i = 0; i < tagNamesToSkip->size(); ++i) { if (targetNode->hasTagName(tagNamesToSkip->at(i))) return; } } Namespaces namespaceHash; if (namespaces) namespaceHash = *namespaces; if (!childrenOnly) appendStartTag(targetNode, &namespaceHash); if (!(targetNode->document()->isHTMLDocument() && elementCannotHaveEndTag(targetNode))) { #if ENABLE(TEMPLATE_ELEMENT) Node* current = targetNode->hasTagName(templateTag) ? toHTMLTemplateElement(targetNode)->content()->firstChild() : targetNode->firstChild(); #else Node* current = targetNode->firstChild(); #endif for ( ; current; current = current->nextSibling()) serializeNodesWithNamespaces(current, nodeToSkip, IncludeNode, &namespaceHash, tagNamesToSkip); } if (!childrenOnly) appendEndTag(targetNode); }
String MarkupAccumulator::serializeNodes(Node* node, Node* nodeToSkip, EChildrenOnly childrenOnly) { StringBuilder out; serializeNodesWithNamespaces(node, nodeToSkip, childrenOnly, 0); out.reserveCapacity(length()); concatenateMarkup(out); return out.toString(); }
String MarkupAccumulator::serializeNodes(Node& targetNode, EChildrenOnly childrenOnly, Vector<QualifiedName>* tagNamesToSkip) { Namespaces* namespaces = 0; Namespaces namespaceHash; if (!serializeAsHTMLDocument(targetNode)) { // Add pre-bound namespaces for XML fragments. namespaceHash.set(xmlAtom, XMLNames::xmlNamespaceURI); namespaces = &namespaceHash; } serializeNodesWithNamespaces(targetNode, childrenOnly, namespaces, tagNamesToSkip); return m_markup.toString(); }
void MarkupAccumulator::serializeNodesWithNamespaces(Node* node, Node* nodeToSkip, EChildrenOnly childrenOnly, const Namespaces* namespaces) { if (node == nodeToSkip) return; Namespaces namespaceHash; if (namespaces) namespaceHash = *namespaces; if (!childrenOnly) appendStartTag(node, &namespaceHash); if (!(node->document()->isHTMLDocument() && elementCannotHaveEndTag(node))) { for (Node* current = node->firstChild(); current; current = current->nextSibling()) serializeNodesWithNamespaces(current, nodeToSkip, IncludeNode, &namespaceHash); } if (!childrenOnly) appendEndTag(node); }
void MarkupAccumulator::serializeNodesWithNamespaces(Node& targetNode, Node* nodeToSkip, EChildrenOnly childrenOnly, const Namespaces* namespaces, Vector<QualifiedName>* tagNamesToSkip) { if (&targetNode == nodeToSkip) return; if (tagNamesToSkip && targetNode.isElementNode()) { for (size_t i = 0; i < tagNamesToSkip->size(); ++i) { if (targetNode.hasTagName(tagNamesToSkip->at(i))) return; } } Namespaces namespaceHash; if (namespaces) namespaceHash = *namespaces; else if (inXMLFragmentSerialization()) { // Make sure xml prefix and namespace are always known to uphold the constraints listed at http://www.w3.org/TR/xml-names11/#xmlReserved. namespaceHash.set(xmlAtom.impl(), XMLNames::xmlNamespaceURI.impl()); namespaceHash.set(XMLNames::xmlNamespaceURI.impl(), xmlAtom.impl()); } if (!childrenOnly) appendStartTag(targetNode, &namespaceHash); if (!(targetNode.document().isHTMLDocument() && elementCannotHaveEndTag(targetNode))) { #if ENABLE(TEMPLATE_ELEMENT) Node* current = targetNode.hasTagName(templateTag) ? toHTMLTemplateElement(targetNode).content()->firstChild() : targetNode.firstChild(); #else Node* current = targetNode.firstChild(); #endif for ( ; current; current = current->nextSibling()) serializeNodesWithNamespaces(*current, nodeToSkip, IncludeNode, &namespaceHash, tagNamesToSkip); } if (!childrenOnly) appendEndTag(targetNode); }
String MarkupAccumulator::serializeNodes(Node& targetNode, Node* nodeToSkip, EChildrenOnly childrenOnly, Vector<QualifiedName>* tagNamesToSkip) { serializeNodesWithNamespaces(targetNode, nodeToSkip, childrenOnly, 0, tagNamesToSkip); return m_markup.toString(); }
String MarkupAccumulator::serializeNodes(Node* targetNode, Node* nodeToSkip, EChildrenOnly childrenOnly) { serializeNodesWithNamespaces(targetNode, nodeToSkip, childrenOnly, 0); return m_markup.toString(); }