| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 result.append(quoteChar); | 215 result.append(quoteChar); |
| 216 return; | 216 return; |
| 217 } | 217 } |
| 218 | 218 |
| 219 // FIXME: This does not fully match other browsers. Firefox percent-escapes
non-ASCII characters for innerHTML. | 219 // FIXME: This does not fully match other browsers. Firefox percent-escapes
non-ASCII characters for innerHTML. |
| 220 result.append(quoteChar); | 220 result.append(quoteChar); |
| 221 appendAttributeValue(result, resolvedURLString, false); | 221 appendAttributeValue(result, resolvedURLString, false); |
| 222 result.append(quoteChar); | 222 result.append(quoteChar); |
| 223 } | 223 } |
| 224 | 224 |
| 225 bool MarkupAccumulator::shouldAddNamespaceElement(const Element& element) | 225 bool MarkupAccumulator::shouldAddNamespaceElement(const Element& element, Namesp
aces& namespaces) |
| 226 { | 226 { |
| 227 // Don't add namespace attribute if it is already defined for this elem. | 227 // Don't add namespace attribute if it is already defined for this elem. |
| 228 const AtomicString& prefix = element.prefix(); | 228 const AtomicString& prefix = element.prefix(); |
| 229 if (prefix.isEmpty()) | 229 if (prefix.isEmpty()) { |
| 230 return !element.hasAttribute(xmlnsAtom); | 230 if (element.hasAttribute(xmlnsAtom)) { |
| 231 namespaces.set(emptyAtom.impl(), element.namespaceURI().impl()); |
| 232 return false; |
| 233 } |
| 234 return true; |
| 235 } |
| 231 | 236 |
| 232 DEFINE_STATIC_LOCAL(String, xmlnsWithColon, ("xmlns:")); | 237 DEFINE_STATIC_LOCAL(String, xmlnsWithColon, ("xmlns:")); |
| 233 return !element.hasAttribute(xmlnsWithColon + prefix); | 238 return !element.hasAttribute(xmlnsWithColon + prefix); |
| 234 } | 239 } |
| 235 | 240 |
| 236 bool MarkupAccumulator::shouldAddNamespaceAttribute(const Attribute& attribute,
Namespaces& namespaces) | 241 bool MarkupAccumulator::shouldAddNamespaceAttribute(const Attribute& attribute,
Namespaces& namespaces) |
| 237 { | 242 { |
| 238 // Don't add namespace attributes twice | 243 // Don't add namespace attributes twice |
| 239 if (attribute.name() == XMLNSNames::xmlnsAttr) { | 244 if (attribute.name() == XMLNSNames::xmlnsAttr) { |
| 240 namespaces.set(emptyAtom.impl(), attribute.value().impl()); | 245 namespaces.set(emptyAtom.impl(), attribute.value().impl()); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 397 |
| 393 static String nodeNamePreservingCase(const Element& element) | 398 static String nodeNamePreservingCase(const Element& element) |
| 394 { | 399 { |
| 395 return element.tagQName().toString(); | 400 return element.tagQName().toString(); |
| 396 } | 401 } |
| 397 | 402 |
| 398 void MarkupAccumulator::appendOpenTag(StringBuilder& result, const Element& elem
ent, Namespaces* namespaces) | 403 void MarkupAccumulator::appendOpenTag(StringBuilder& result, const Element& elem
ent, Namespaces* namespaces) |
| 399 { | 404 { |
| 400 result.append('<'); | 405 result.append('<'); |
| 401 result.append(nodeNamePreservingCase(element)); | 406 result.append(nodeNamePreservingCase(element)); |
| 402 if (!element.document().isHTMLDocument() && namespaces && shouldAddNamespace
Element(element)) | 407 if (!element.document().isHTMLDocument() && namespaces && shouldAddNamespace
Element(element, *namespaces)) |
| 403 appendNamespace(result, element.prefix(), element.namespaceURI(), *names
paces); | 408 appendNamespace(result, element.prefix(), element.namespaceURI(), *names
paces); |
| 404 } | 409 } |
| 405 | 410 |
| 406 void MarkupAccumulator::appendCloseTag(StringBuilder& result, const Element& ele
ment) | 411 void MarkupAccumulator::appendCloseTag(StringBuilder& result, const Element& ele
ment) |
| 407 { | 412 { |
| 408 if (shouldSelfClose(element)) { | 413 if (shouldSelfClose(element)) { |
| 409 if (element.isHTMLElement()) | 414 if (element.isHTMLElement()) |
| 410 result.append(' '); // XHTML 1.0 <-> HTML compatibility. | 415 result.append(' '); // XHTML 1.0 <-> HTML compatibility. |
| 411 result.append('/'); | 416 result.append('/'); |
| 412 } | 417 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 { | 534 { |
| 530 if (!node.isElementNode() || shouldSelfClose(node) || (!node.hasChildren() &
& elementCannotHaveEndTag(node))) | 535 if (!node.isElementNode() || shouldSelfClose(node) || (!node.hasChildren() &
& elementCannotHaveEndTag(node))) |
| 531 return; | 536 return; |
| 532 | 537 |
| 533 result.appendLiteral("</"); | 538 result.appendLiteral("</"); |
| 534 result.append(nodeNamePreservingCase(toElement(node))); | 539 result.append(nodeNamePreservingCase(toElement(node))); |
| 535 result.append('>'); | 540 result.append('>'); |
| 536 } | 541 } |
| 537 | 542 |
| 538 } | 543 } |
| OLD | NEW |