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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 for (unsigned int i = 0; i < length; i++) | 383 for (unsigned int i = 0; i < length; i++) |
384 appendAttribute(result, element, *element.attributeItem(i), namespac
es); | 384 appendAttribute(result, element, *element.attributeItem(i), namespac
es); |
385 } | 385 } |
386 | 386 |
387 // Give an opportunity to subclasses to add their own attributes. | 387 // Give an opportunity to subclasses to add their own attributes. |
388 appendCustomAttributes(result, element, namespaces); | 388 appendCustomAttributes(result, element, namespaces); |
389 | 389 |
390 appendCloseTag(result, element); | 390 appendCloseTag(result, element); |
391 } | 391 } |
392 | 392 |
| 393 static String nodeNamePreservingCase(const Element& element) |
| 394 { |
| 395 return element.tagQName().toString(); |
| 396 } |
| 397 |
393 void MarkupAccumulator::appendOpenTag(StringBuilder& result, const Element& elem
ent, Namespaces* namespaces) | 398 void MarkupAccumulator::appendOpenTag(StringBuilder& result, const Element& elem
ent, Namespaces* namespaces) |
394 { | 399 { |
395 result.append('<'); | 400 result.append('<'); |
396 result.append(element.nodeNamePreservingCase()); | 401 result.append(nodeNamePreservingCase(element)); |
397 if (!element.document().isHTMLDocument() && namespaces && shouldAddNamespace
Element(element)) | 402 if (!element.document().isHTMLDocument() && namespaces && shouldAddNamespace
Element(element)) |
398 appendNamespace(result, element.prefix(), element.namespaceURI(), *names
paces); | 403 appendNamespace(result, element.prefix(), element.namespaceURI(), *names
paces); |
399 } | 404 } |
400 | 405 |
401 void MarkupAccumulator::appendCloseTag(StringBuilder& result, const Element& ele
ment) | 406 void MarkupAccumulator::appendCloseTag(StringBuilder& result, const Element& ele
ment) |
402 { | 407 { |
403 if (shouldSelfClose(element)) { | 408 if (shouldSelfClose(element)) { |
404 if (element.isHTMLElement()) | 409 if (element.isHTMLElement()) |
405 result.append(' '); // XHTML 1.0 <-> HTML compatibility. | 410 result.append(' '); // XHTML 1.0 <-> HTML compatibility. |
406 result.append('/'); | 411 result.append('/'); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 // which elements should be serialized w/o end tags. | 524 // which elements should be serialized w/o end tags. |
520 return toHTMLElement(node).ieForbidsInsertHTML(); | 525 return toHTMLElement(node).ieForbidsInsertHTML(); |
521 } | 526 } |
522 | 527 |
523 void MarkupAccumulator::appendEndMarkup(StringBuilder& result, const Node& node) | 528 void MarkupAccumulator::appendEndMarkup(StringBuilder& result, const Node& node) |
524 { | 529 { |
525 if (!node.isElementNode() || shouldSelfClose(node) || (!node.hasChildNodes()
&& elementCannotHaveEndTag(node))) | 530 if (!node.isElementNode() || shouldSelfClose(node) || (!node.hasChildNodes()
&& elementCannotHaveEndTag(node))) |
526 return; | 531 return; |
527 | 532 |
528 result.appendLiteral("</"); | 533 result.appendLiteral("</"); |
529 result.append(toElement(node).nodeNamePreservingCase()); | 534 result.append(nodeNamePreservingCase(toElement(node))); |
530 result.append('>'); | 535 result.append('>'); |
531 } | 536 } |
532 | 537 |
533 } | 538 } |
OLD | NEW |