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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 || attribute.namespaceURI() == XLinkNames::xlinkNamespaceURI | 419 || attribute.namespaceURI() == XLinkNames::xlinkNamespaceURI |
420 || attribute.namespaceURI() == XMLNSNames::xmlnsNamespaceURI; | 420 || attribute.namespaceURI() == XMLNSNames::xmlnsNamespaceURI; |
421 } | 421 } |
422 | 422 |
423 void MarkupAccumulator::appendAttribute(StringBuilder& result, const Element& el
ement, const Attribute& attribute, Namespaces* namespaces) | 423 void MarkupAccumulator::appendAttribute(StringBuilder& result, const Element& el
ement, const Attribute& attribute, Namespaces* namespaces) |
424 { | 424 { |
425 bool documentIsHTML = element.document().isHTMLDocument(); | 425 bool documentIsHTML = element.document().isHTMLDocument(); |
426 | 426 |
427 result.append(' '); | 427 result.append(' '); |
428 | 428 |
429 if (documentIsHTML && !attributeIsInSerializedNamespace(attribute)) | 429 QualifiedName prefixedName = attribute.name(); |
| 430 if (documentIsHTML && !attributeIsInSerializedNamespace(attribute)) { |
430 result.append(attribute.name().localName()); | 431 result.append(attribute.name().localName()); |
431 else { | 432 } else { |
432 QualifiedName prefixedName = attribute.name(); | |
433 if (attribute.namespaceURI() == XLinkNames::xlinkNamespaceURI) { | 433 if (attribute.namespaceURI() == XLinkNames::xlinkNamespaceURI) { |
434 if (!attribute.prefix()) | 434 if (!attribute.prefix()) |
435 prefixedName.setPrefix(xlinkAtom); | 435 prefixedName.setPrefix(xlinkAtom); |
436 } else if (attribute.namespaceURI() == XMLNames::xmlNamespaceURI) { | 436 } else if (attribute.namespaceURI() == XMLNames::xmlNamespaceURI) { |
437 if (!attribute.prefix()) | 437 if (!attribute.prefix()) |
438 prefixedName.setPrefix(xmlAtom); | 438 prefixedName.setPrefix(xmlAtom); |
439 } else if (attribute.namespaceURI() == XMLNSNames::xmlnsNamespaceURI) { | 439 } else if (attribute.namespaceURI() == XMLNSNames::xmlnsNamespaceURI) { |
440 if (attribute.name() != XMLNSNames::xmlnsAttr && !attribute.prefix()
) | 440 if (attribute.name() != XMLNSNames::xmlnsAttr && !attribute.prefix()
) |
441 prefixedName.setPrefix(xmlnsAtom); | 441 prefixedName.setPrefix(xmlnsAtom); |
442 } | 442 } |
443 result.append(prefixedName.toString()); | 443 result.append(prefixedName.toString()); |
444 } | 444 } |
445 | 445 |
446 result.append('='); | 446 result.append('='); |
447 | 447 |
448 if (element.isURLAttribute(attribute)) | 448 if (element.isURLAttribute(attribute)) { |
449 appendQuotedURLAttributeValue(result, element, attribute); | 449 appendQuotedURLAttributeValue(result, element, attribute); |
450 else { | 450 } else { |
451 result.append('"'); | 451 result.append('"'); |
452 appendAttributeValue(result, attribute.value(), documentIsHTML); | 452 appendAttributeValue(result, attribute.value(), documentIsHTML); |
453 result.append('"'); | 453 result.append('"'); |
454 } | 454 } |
455 | 455 |
456 if (!documentIsHTML && namespaces && shouldAddNamespaceAttribute(attribute,
*namespaces)) | 456 if (!documentIsHTML && namespaces && shouldAddNamespaceAttribute(attribute,
*namespaces)) |
457 appendNamespace(result, attribute.prefix(), attribute.namespaceURI(), *n
amespaces); | 457 appendNamespace(result, prefixedName.prefix(), prefixedName.namespaceURI
(), *namespaces); |
458 } | 458 } |
459 | 459 |
460 void MarkupAccumulator::appendCDATASection(StringBuilder& result, const String&
section) | 460 void MarkupAccumulator::appendCDATASection(StringBuilder& result, const String&
section) |
461 { | 461 { |
462 // FIXME: CDATA content is not escaped, but XMLSerializer (and possibly othe
r callers) should raise an exception if it includes "]]>". | 462 // FIXME: CDATA content is not escaped, but XMLSerializer (and possibly othe
r callers) should raise an exception if it includes "]]>". |
463 result.appendLiteral("<![CDATA["); | 463 result.appendLiteral("<![CDATA["); |
464 result.append(section); | 464 result.append(section); |
465 result.appendLiteral("]]>"); | 465 result.appendLiteral("]]>"); |
466 } | 466 } |
467 | 467 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 { | 529 { |
530 if (!node.isElementNode() || shouldSelfClose(node) || (!node.hasChildNodes()
&& elementCannotHaveEndTag(node))) | 530 if (!node.isElementNode() || shouldSelfClose(node) || (!node.hasChildNodes()
&& elementCannotHaveEndTag(node))) |
531 return; | 531 return; |
532 | 532 |
533 result.appendLiteral("</"); | 533 result.appendLiteral("</"); |
534 result.append(nodeNamePreservingCase(toElement(node))); | 534 result.append(nodeNamePreservingCase(toElement(node))); |
535 result.append('>'); | 535 result.append('>'); |
536 } | 536 } |
537 | 537 |
538 } | 538 } |
OLD | NEW |