| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 { | 70 { |
| 71 appendEndMarkup(m_markup, element); | 71 appendEndMarkup(m_markup, element); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void MarkupAccumulator::appendStartMarkup(StringBuilder& result, Node& node, Nam
espaces* namespaces) | 74 void MarkupAccumulator::appendStartMarkup(StringBuilder& result, Node& node, Nam
espaces* namespaces) |
| 75 { | 75 { |
| 76 switch (node.nodeType()) { | 76 switch (node.nodeType()) { |
| 77 case Node::TEXT_NODE: | 77 case Node::TEXT_NODE: |
| 78 appendText(result, toText(node)); | 78 appendText(result, toText(node)); |
| 79 break; | 79 break; |
| 80 case Node::COMMENT_NODE: | |
| 81 MarkupFormatter::appendComment(result, toComment(node).data()); | |
| 82 break; | |
| 83 case Node::DOCUMENT_NODE: | |
| 84 MarkupFormatter::appendXMLDeclaration(result, toDocument(node)); | |
| 85 break; | |
| 86 case Node::DOCUMENT_FRAGMENT_NODE: | |
| 87 break; | |
| 88 case Node::DOCUMENT_TYPE_NODE: | |
| 89 MarkupFormatter::appendDocumentType(result, toDocumentType(node)); | |
| 90 break; | |
| 91 case Node::PROCESSING_INSTRUCTION_NODE: | |
| 92 MarkupFormatter::appendProcessingInstruction(result, toProcessingInstruc
tion(node).target(), toProcessingInstruction(node).data()); | |
| 93 break; | |
| 94 case Node::ELEMENT_NODE: | 80 case Node::ELEMENT_NODE: |
| 95 appendElement(result, toElement(node), namespaces); | 81 appendElement(result, toElement(node), namespaces); |
| 96 break; | 82 break; |
| 97 case Node::CDATA_SECTION_NODE: | 83 default: |
| 98 MarkupFormatter::appendCDATASection(result, toCDATASection(node).data())
; | 84 m_formatter.appendStartMarkup(result, node, namespaces); |
| 99 break; | |
| 100 case Node::ATTRIBUTE_NODE: | |
| 101 ASSERT_NOT_REACHED(); | |
| 102 break; | 85 break; |
| 103 } | 86 } |
| 104 } | 87 } |
| 105 | 88 |
| 106 static bool elementCannotHaveEndTag(const Node& node) | 89 static bool elementCannotHaveEndTag(const Node& node) |
| 107 { | 90 { |
| 108 if (!node.isHTMLElement()) | 91 if (!node.isHTMLElement()) |
| 109 return false; | 92 return false; |
| 110 | 93 |
| 111 // FIXME: ieForbidsInsertHTML may not be the right function to call here | 94 // FIXME: ieForbidsInsertHTML may not be the right function to call here |
| 112 // ieForbidsInsertHTML is used to disallow setting innerHTML/outerHTML | 95 // ieForbidsInsertHTML is used to disallow setting innerHTML/outerHTML |
| 113 // or createContextualFragment. It does not necessarily align with | 96 // or createContextualFragment. It does not necessarily align with |
| 114 // which elements should be serialized w/o end tags. | 97 // which elements should be serialized w/o end tags. |
| 115 return toHTMLElement(node).ieForbidsInsertHTML(); | 98 return toHTMLElement(node).ieForbidsInsertHTML(); |
| 116 } | 99 } |
| 117 | 100 |
| 118 void MarkupAccumulator::appendEndMarkup(StringBuilder& result, const Element& el
ement) | 101 void MarkupAccumulator::appendEndMarkup(StringBuilder& result, const Element& el
ement) |
| 119 { | 102 { |
| 120 m_formatter.appendEndMarkup(result, element); | 103 m_formatter.appendEndMarkup(result, element); |
| 121 } | 104 } |
| 122 | 105 |
| 123 void MarkupAccumulator::concatenateMarkup(StringBuilder& result) const | |
| 124 { | |
| 125 result.append(m_markup); | |
| 126 } | |
| 127 | |
| 128 void MarkupAccumulator::appendCustomAttributes(StringBuilder&, const Element&, N
amespaces*) | 106 void MarkupAccumulator::appendCustomAttributes(StringBuilder&, const Element&, N
amespaces*) |
| 129 { | 107 { |
| 130 } | 108 } |
| 131 | 109 |
| 132 void MarkupAccumulator::appendText(StringBuilder& result, Text& text) | 110 void MarkupAccumulator::appendText(StringBuilder& result, Text& text) |
| 133 { | 111 { |
| 134 m_formatter.appendText(result, text); | 112 m_formatter.appendText(result, text); |
| 135 } | 113 } |
| 136 | 114 |
| 137 bool MarkupAccumulator::shouldIgnoreAttribute(const Attribute& attribute) | 115 bool MarkupAccumulator::shouldIgnoreAttribute(const Attribute& attribute) |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 namespaces = &namespaceHash; | 189 namespaces = &namespaceHash; |
| 212 } | 190 } |
| 213 | 191 |
| 214 serializeNodesWithNamespaces<Strategy>(accumulator, targetNode, childrenOnly
, namespaces); | 192 serializeNodesWithNamespaces<Strategy>(accumulator, targetNode, childrenOnly
, namespaces); |
| 215 return accumulator.toString(); | 193 return accumulator.toString(); |
| 216 } | 194 } |
| 217 | 195 |
| 218 template String serializeNodes<EditingStrategy>(MarkupAccumulator&, Node&, EChil
drenOnly); | 196 template String serializeNodes<EditingStrategy>(MarkupAccumulator&, Node&, EChil
drenOnly); |
| 219 | 197 |
| 220 } | 198 } |
| OLD | NEW |