Index: Source/core/editing/MarkupAccumulator.cpp |
diff --git a/Source/core/editing/MarkupAccumulator.cpp b/Source/core/editing/MarkupAccumulator.cpp |
index 61bbb2d84f7a077daba417dc6e3dba8dc75af9e2..5949967302c9cc5125345238e865461aa62d8f4d 100644 |
--- a/Source/core/editing/MarkupAccumulator.cpp |
+++ b/Source/core/editing/MarkupAccumulator.cpp |
@@ -107,17 +107,17 @@ MarkupAccumulator::~MarkupAccumulator() |
{ |
} |
-String MarkupAccumulator::serializeNodes(Node* targetNode, EChildrenOnly childrenOnly, Vector<QualifiedName>* tagNamesToSkip) |
+String MarkupAccumulator::serializeNodes(Node& targetNode, EChildrenOnly childrenOnly, Vector<QualifiedName>* tagNamesToSkip) |
{ |
serializeNodesWithNamespaces(targetNode, childrenOnly, 0, tagNamesToSkip); |
return m_markup.toString(); |
} |
-void MarkupAccumulator::serializeNodesWithNamespaces(Node* targetNode, EChildrenOnly childrenOnly, const Namespaces* namespaces, Vector<QualifiedName>* tagNamesToSkip) |
+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))) |
+ if (targetNode.hasTagName(tagNamesToSkip->at(i))) |
return; |
} |
} |
@@ -129,25 +129,25 @@ void MarkupAccumulator::serializeNodesWithNamespaces(Node* targetNode, EChildren |
if (!childrenOnly) |
appendStartTag(targetNode, &namespaceHash); |
- if (!(targetNode->document().isHTMLDocument() && elementCannotHaveEndTag(targetNode))) { |
- Node* current = targetNode->hasTagName(templateTag) ? toHTMLTemplateElement(targetNode)->content()->firstChild() : targetNode->firstChild(); |
+ if (!(targetNode.document().isHTMLDocument() && elementCannotHaveEndTag(targetNode))) { |
+ Node* current = targetNode.hasTagName(templateTag) ? toHTMLTemplateElement(targetNode).content()->firstChild() : targetNode.firstChild(); |
for ( ; current; current = current->nextSibling()) |
- serializeNodesWithNamespaces(current, IncludeNode, &namespaceHash, tagNamesToSkip); |
+ serializeNodesWithNamespaces(*current, IncludeNode, &namespaceHash, tagNamesToSkip); |
} |
if (!childrenOnly) |
appendEndTag(targetNode); |
} |
-String MarkupAccumulator::resolveURLIfNeeded(const Element* element, const String& urlString) const |
+String MarkupAccumulator::resolveURLIfNeeded(const Element& element, const String& urlString) const |
{ |
switch (m_resolveURLsMethod) { |
case ResolveAllURLs: |
- return element->document().completeURL(urlString).string(); |
+ return element.document().completeURL(urlString).string(); |
case ResolveNonLocalURLs: |
- if (!element->document().url().isLocalFile()) |
- return element->document().completeURL(urlString).string(); |
+ if (!element.document().url().isLocalFile()) |
+ return element.document().completeURL(urlString).string(); |
break; |
case DoNotResolveURLs: |
@@ -161,14 +161,14 @@ void MarkupAccumulator::appendString(const String& string) |
m_markup.append(string); |
} |
-void MarkupAccumulator::appendStartTag(Node* node, Namespaces* namespaces) |
+void MarkupAccumulator::appendStartTag(Node& node, Namespaces* namespaces) |
{ |
appendStartMarkup(m_markup, node, namespaces); |
if (m_nodes) |
- m_nodes->append(node); |
+ m_nodes->append(&node); |
} |
-void MarkupAccumulator::appendEndTag(Node* node) |
+void MarkupAccumulator::appendEndTag(const Node& node) |
{ |
appendEndMarkup(m_markup, node); |
} |
@@ -192,13 +192,13 @@ void MarkupAccumulator::appendAttributeValue(StringBuilder& result, const String |
documentIsHTML ? EntityMaskInHTMLAttributeValue : EntityMaskInAttributeValue); |
} |
-void MarkupAccumulator::appendCustomAttributes(StringBuilder&, Element*, Namespaces*) |
+void MarkupAccumulator::appendCustomAttributes(StringBuilder&, const Element&, Namespaces*) |
{ |
} |
-void MarkupAccumulator::appendQuotedURLAttributeValue(StringBuilder& result, const Element* element, const Attribute& attribute) |
+void MarkupAccumulator::appendQuotedURLAttributeValue(StringBuilder& result, const Element& element, const Attribute& attribute) |
{ |
- ASSERT(element->isURLAttribute(attribute)); |
+ ASSERT(element.isURLAttribute(attribute)); |
const String resolvedURLString = resolveURLIfNeeded(element, attribute.value()); |
UChar quoteChar = '"'; |
String strippedURLString = resolvedURLString.stripWhiteSpace(); |
@@ -222,15 +222,15 @@ void MarkupAccumulator::appendQuotedURLAttributeValue(StringBuilder& result, con |
result.append(quoteChar); |
} |
-bool MarkupAccumulator::shouldAddNamespaceElement(const Element* element) |
+bool MarkupAccumulator::shouldAddNamespaceElement(const Element& element) |
{ |
// Don't add namespace attribute if it is already defined for this elem. |
- const AtomicString& prefix = element->prefix(); |
+ const AtomicString& prefix = element.prefix(); |
if (prefix.isEmpty()) |
- return !element->hasAttribute(xmlnsAtom); |
+ return !element.hasAttribute(xmlnsAtom); |
DEFINE_STATIC_LOCAL(String, xmlnsWithColon, ("xmlns:")); |
- return !element->hasAttribute(xmlnsWithColon + prefix); |
+ return !element.hasAttribute(xmlnsWithColon + prefix); |
} |
bool MarkupAccumulator::shouldAddNamespaceAttribute(const Attribute& attribute, Namespaces& namespaces) |
@@ -273,23 +273,23 @@ void MarkupAccumulator::appendNamespace(StringBuilder& result, const AtomicStrin |
} |
} |
-EntityMask MarkupAccumulator::entityMaskForText(Text* text) const |
+EntityMask MarkupAccumulator::entityMaskForText(const Text& text) const |
{ |
- if (!text->document().isHTMLDocument()) |
+ if (!text.document().isHTMLDocument()) |
return EntityMaskInPCDATA; |
const QualifiedName* parentName = 0; |
- if (text->parentElement()) |
- parentName = &(text->parentElement())->tagQName(); |
+ if (text.parentElement()) |
+ parentName = &(text.parentElement())->tagQName(); |
if (parentName && (*parentName == scriptTag || *parentName == styleTag || *parentName == xmpTag)) |
return EntityMaskInCDATA; |
return EntityMaskInHTMLPCDATA; |
} |
-void MarkupAccumulator::appendText(StringBuilder& result, Text* text) |
+void MarkupAccumulator::appendText(StringBuilder& result, Text& text) |
{ |
- const String& str = text->data(); |
+ const String& str = text.data(); |
unsigned length = str.length(); |
unsigned start = 0; |
@@ -312,21 +312,21 @@ void MarkupAccumulator::appendComment(StringBuilder& result, const String& comme |
result.appendLiteral("-->"); |
} |
-void MarkupAccumulator::appendXMLDeclaration(StringBuilder& result, const Document* document) |
+void MarkupAccumulator::appendXMLDeclaration(StringBuilder& result, const Document& document) |
{ |
- if (!document->hasXMLDeclaration()) |
+ if (!document.hasXMLDeclaration()) |
return; |
result.appendLiteral("<?xml version=\""); |
- result.append(document->xmlVersion()); |
- const String& encoding = document->xmlEncoding(); |
+ result.append(document.xmlVersion()); |
+ const String& encoding = document.xmlEncoding(); |
if (!encoding.isEmpty()) { |
result.appendLiteral("\" encoding=\""); |
result.append(encoding); |
} |
- if (document->xmlStandaloneStatus() != Document::StandaloneUnspecified) { |
+ if (document.xmlStandaloneStatus() != Document::StandaloneUnspecified) { |
result.appendLiteral("\" standalone=\""); |
- if (document->xmlStandalone()) |
+ if (document.xmlStandalone()) |
result.appendLiteral("yes"); |
else |
result.appendLiteral("no"); |
@@ -335,30 +335,30 @@ void MarkupAccumulator::appendXMLDeclaration(StringBuilder& result, const Docume |
result.appendLiteral("\"?>"); |
} |
-void MarkupAccumulator::appendDocumentType(StringBuilder& result, const DocumentType* n) |
+void MarkupAccumulator::appendDocumentType(StringBuilder& result, const DocumentType& n) |
{ |
- if (n->name().isEmpty()) |
+ if (n.name().isEmpty()) |
return; |
result.appendLiteral("<!DOCTYPE "); |
- result.append(n->name()); |
- if (!n->publicId().isEmpty()) { |
+ result.append(n.name()); |
+ if (!n.publicId().isEmpty()) { |
result.appendLiteral(" PUBLIC \""); |
- result.append(n->publicId()); |
+ result.append(n.publicId()); |
result.append('"'); |
- if (!n->systemId().isEmpty()) { |
+ if (!n.systemId().isEmpty()) { |
result.appendLiteral(" \""); |
- result.append(n->systemId()); |
+ result.append(n.systemId()); |
result.append('"'); |
} |
- } else if (!n->systemId().isEmpty()) { |
+ } else if (!n.systemId().isEmpty()) { |
result.appendLiteral(" SYSTEM \""); |
- result.append(n->systemId()); |
+ result.append(n.systemId()); |
result.append('"'); |
} |
- if (!n->internalSubset().isEmpty()) { |
+ if (!n.internalSubset().isEmpty()) { |
result.appendLiteral(" ["); |
- result.append(n->internalSubset()); |
+ result.append(n.internalSubset()); |
result.append(']'); |
} |
result.append('>'); |
@@ -374,14 +374,14 @@ void MarkupAccumulator::appendProcessingInstruction(StringBuilder& result, const |
result.appendLiteral("?>"); |
} |
-void MarkupAccumulator::appendElement(StringBuilder& result, Element* element, Namespaces* namespaces) |
+void MarkupAccumulator::appendElement(StringBuilder& result, Element& element, Namespaces* namespaces) |
{ |
appendOpenTag(result, element, namespaces); |
- if (element->hasAttributes()) { |
- unsigned length = element->attributeCount(); |
+ if (element.hasAttributes()) { |
+ unsigned length = element.attributeCount(); |
for (unsigned int i = 0; i < length; i++) |
- appendAttribute(result, element, *element->attributeItem(i), namespaces); |
+ appendAttribute(result, element, *element.attributeItem(i), namespaces); |
} |
// Give an opportunity to subclasses to add their own attributes. |
@@ -390,18 +390,18 @@ void MarkupAccumulator::appendElement(StringBuilder& result, Element* element, N |
appendCloseTag(result, element); |
} |
-void MarkupAccumulator::appendOpenTag(StringBuilder& result, Element* element, Namespaces* namespaces) |
+void MarkupAccumulator::appendOpenTag(StringBuilder& result, const Element& element, Namespaces* namespaces) |
{ |
result.append('<'); |
- result.append(element->nodeNamePreservingCase()); |
- if (!element->document().isHTMLDocument() && namespaces && shouldAddNamespaceElement(element)) |
- appendNamespace(result, element->prefix(), element->namespaceURI(), *namespaces); |
+ result.append(element.nodeNamePreservingCase()); |
+ if (!element.document().isHTMLDocument() && namespaces && shouldAddNamespaceElement(element)) |
+ appendNamespace(result, element.prefix(), element.namespaceURI(), *namespaces); |
} |
-void MarkupAccumulator::appendCloseTag(StringBuilder& result, Element* element) |
+void MarkupAccumulator::appendCloseTag(StringBuilder& result, const Element& element) |
{ |
if (shouldSelfClose(element)) { |
- if (element->isHTMLElement()) |
+ if (element.isHTMLElement()) |
result.append(' '); // XHTML 1.0 <-> HTML compatibility. |
result.append('/'); |
} |
@@ -415,9 +415,9 @@ static inline bool attributeIsInSerializedNamespace(const Attribute& attribute) |
|| attribute.namespaceURI() == XMLNSNames::xmlnsNamespaceURI; |
} |
-void MarkupAccumulator::appendAttribute(StringBuilder& result, Element* element, const Attribute& attribute, Namespaces* namespaces) |
+void MarkupAccumulator::appendAttribute(StringBuilder& result, const Element& element, const Attribute& attribute, Namespaces* namespaces) |
{ |
- bool documentIsHTML = element->document().isHTMLDocument(); |
+ bool documentIsHTML = element.document().isHTMLDocument(); |
result.append(' '); |
@@ -440,7 +440,7 @@ void MarkupAccumulator::appendAttribute(StringBuilder& result, Element* element, |
result.append('='); |
- if (element->isURLAttribute(attribute)) |
+ if (element.isURLAttribute(attribute)) |
appendQuotedURLAttributeValue(result, element, attribute); |
else { |
result.append('"'); |
@@ -460,14 +460,14 @@ void MarkupAccumulator::appendCDATASection(StringBuilder& result, const String& |
result.appendLiteral("]]>"); |
} |
-void MarkupAccumulator::appendStartMarkup(StringBuilder& result, const Node* node, Namespaces* namespaces) |
+void MarkupAccumulator::appendStartMarkup(StringBuilder& result, Node& node, Namespaces* namespaces) |
{ |
- switch (node->nodeType()) { |
+ switch (node.nodeType()) { |
case Node::TEXT_NODE: |
- appendText(result, toText(const_cast<Node*>(node))); |
+ appendText(result, toText(node)); |
break; |
case Node::COMMENT_NODE: |
- appendComment(result, toComment(node)->data()); |
+ appendComment(result, toComment(node).data()); |
break; |
case Node::DOCUMENT_NODE: |
appendXMLDeclaration(result, toDocument(node)); |
@@ -478,13 +478,13 @@ void MarkupAccumulator::appendStartMarkup(StringBuilder& result, const Node* nod |
appendDocumentType(result, toDocumentType(node)); |
break; |
case Node::PROCESSING_INSTRUCTION_NODE: |
- appendProcessingInstruction(result, toProcessingInstruction(node)->target(), toProcessingInstruction(node)->data()); |
+ appendProcessingInstruction(result, toProcessingInstruction(node).target(), toProcessingInstruction(node).data()); |
break; |
case Node::ELEMENT_NODE: |
- appendElement(result, toElement(const_cast<Node*>(node)), namespaces); |
+ appendElement(result, toElement(node), namespaces); |
break; |
case Node::CDATA_SECTION_NODE: |
- appendCDATASection(result, toCDATASection(node)->data()); |
+ appendCDATASection(result, toCDATASection(node).data()); |
break; |
case Node::ATTRIBUTE_NODE: |
ASSERT_NOT_REACHED(); |
@@ -497,36 +497,36 @@ void MarkupAccumulator::appendStartMarkup(StringBuilder& result, const Node* nod |
// 2. Elements w/ children never self-close because they use a separate end tag. |
// 3. HTML elements which do not have a "forbidden" end tag will close with a separate end tag. |
// 4. Other elements self-close. |
-bool MarkupAccumulator::shouldSelfClose(const Node* node) |
+bool MarkupAccumulator::shouldSelfClose(const Node& node) |
{ |
- if (node->document().isHTMLDocument()) |
+ if (node.document().isHTMLDocument()) |
return false; |
- if (node->hasChildNodes()) |
+ if (node.hasChildNodes()) |
return false; |
- if (node->isHTMLElement() && !elementCannotHaveEndTag(node)) |
+ if (node.isHTMLElement() && !elementCannotHaveEndTag(node)) |
return false; |
return true; |
} |
-bool MarkupAccumulator::elementCannotHaveEndTag(const Node* node) |
+bool MarkupAccumulator::elementCannotHaveEndTag(const Node& node) |
{ |
- if (!node->isHTMLElement()) |
+ if (!node.isHTMLElement()) |
return false; |
// FIXME: ieForbidsInsertHTML may not be the right function to call here |
// ieForbidsInsertHTML is used to disallow setting innerHTML/outerHTML |
// or createContextualFragment. It does not necessarily align with |
// which elements should be serialized w/o end tags. |
- return toHTMLElement(node)->ieForbidsInsertHTML(); |
+ return toHTMLElement(node).ieForbidsInsertHTML(); |
} |
-void MarkupAccumulator::appendEndMarkup(StringBuilder& result, const Node* node) |
+void MarkupAccumulator::appendEndMarkup(StringBuilder& result, const Node& node) |
{ |
- if (!node->isElementNode() || shouldSelfClose(node) || (!node->hasChildNodes() && elementCannotHaveEndTag(node))) |
+ if (!node.isElementNode() || shouldSelfClose(node) || (!node.hasChildNodes() && elementCannotHaveEndTag(node))) |
return; |
result.appendLiteral("</"); |
- result.append(toElement(node)->nodeNamePreservingCase()); |
+ result.append(toElement(node).nodeNamePreservingCase()); |
result.append('>'); |
} |