| 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 13 matching lines...) Expand all Loading... |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/editing/MarkupAccumulator.h" | 28 #include "core/editing/MarkupAccumulator.h" |
| 29 | 29 |
| 30 #include "core/HTMLNames.h" | 30 #include "core/HTMLNames.h" |
| 31 #include "core/XLinkNames.h" | 31 #include "core/XLinkNames.h" |
| 32 #include "core/XMLNSNames.h" | 32 #include "core/XMLNSNames.h" |
| 33 #include "core/XMLNames.h" | 33 #include "core/XMLNames.h" |
| 34 #include "core/dom/CDATASection.h" | |
| 35 #include "core/dom/Comment.h" | 34 #include "core/dom/Comment.h" |
| 36 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
| 37 #include "core/dom/DocumentFragment.h" | 36 #include "core/dom/DocumentFragment.h" |
| 38 #include "core/dom/DocumentType.h" | 37 #include "core/dom/DocumentType.h" |
| 39 #include "core/dom/ProcessingInstruction.h" | 38 #include "core/dom/ProcessingInstruction.h" |
| 39 #include "core/dom/Text.h" |
| 40 #include "core/editing/Editor.h" | 40 #include "core/editing/Editor.h" |
| 41 #include "core/html/HTMLElement.h" | 41 #include "core/html/HTMLElement.h" |
| 42 #include "core/html/HTMLTemplateElement.h" | 42 #include "core/html/HTMLTemplateElement.h" |
| 43 #include "platform/weborigin/KURL.h" | 43 #include "platform/weborigin/KURL.h" |
| 44 #include "wtf/unicode/CharacterNames.h" | 44 #include "wtf/unicode/CharacterNames.h" |
| 45 | 45 |
| 46 namespace blink { | 46 namespace blink { |
| 47 | 47 |
| 48 using namespace HTMLNames; | 48 using namespace HTMLNames; |
| 49 | 49 |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 | 464 |
| 465 if (element.isURLAttribute(attribute)) { | 465 if (element.isURLAttribute(attribute)) { |
| 466 appendQuotedURLAttributeValue(result, element, attribute); | 466 appendQuotedURLAttributeValue(result, element, attribute); |
| 467 } else { | 467 } else { |
| 468 result.append('"'); | 468 result.append('"'); |
| 469 appendAttributeValue(result, attribute.value(), documentIsHTML); | 469 appendAttributeValue(result, attribute.value(), documentIsHTML); |
| 470 result.append('"'); | 470 result.append('"'); |
| 471 } | 471 } |
| 472 } | 472 } |
| 473 | 473 |
| 474 void MarkupAccumulator::appendCDATASection(StringBuilder& result, const String&
section) | |
| 475 { | |
| 476 // FIXME: CDATA content is not escaped, but XMLSerializer (and possibly othe
r callers) should raise an exception if it includes "]]>". | |
| 477 result.appendLiteral("<![CDATA["); | |
| 478 result.append(section); | |
| 479 result.appendLiteral("]]>"); | |
| 480 } | |
| 481 | |
| 482 void MarkupAccumulator::appendStartMarkup(StringBuilder& result, Node& node, Nam
espaces* namespaces) | 474 void MarkupAccumulator::appendStartMarkup(StringBuilder& result, Node& node, Nam
espaces* namespaces) |
| 483 { | 475 { |
| 484 switch (node.nodeType()) { | 476 switch (node.nodeType()) { |
| 485 case Node::TEXT_NODE: | 477 case Node::TEXT_NODE: |
| 486 appendText(result, toText(node)); | 478 appendText(result, toText(node)); |
| 487 break; | 479 break; |
| 488 case Node::COMMENT_NODE: | 480 case Node::COMMENT_NODE: |
| 489 appendComment(result, toComment(node).data()); | 481 appendComment(result, toComment(node).data()); |
| 490 break; | 482 break; |
| 491 case Node::DOCUMENT_NODE: | 483 case Node::DOCUMENT_NODE: |
| 492 appendXMLDeclaration(result, toDocument(node)); | 484 appendXMLDeclaration(result, toDocument(node)); |
| 493 break; | 485 break; |
| 494 case Node::DOCUMENT_FRAGMENT_NODE: | 486 case Node::DOCUMENT_FRAGMENT_NODE: |
| 495 break; | 487 break; |
| 496 case Node::DOCUMENT_TYPE_NODE: | 488 case Node::DOCUMENT_TYPE_NODE: |
| 497 appendDocumentType(result, toDocumentType(node)); | 489 appendDocumentType(result, toDocumentType(node)); |
| 498 break; | 490 break; |
| 499 case Node::PROCESSING_INSTRUCTION_NODE: | 491 case Node::PROCESSING_INSTRUCTION_NODE: |
| 500 appendProcessingInstruction(result, toProcessingInstruction(node).target
(), toProcessingInstruction(node).data()); | 492 appendProcessingInstruction(result, toProcessingInstruction(node).target
(), toProcessingInstruction(node).data()); |
| 501 break; | 493 break; |
| 502 case Node::ELEMENT_NODE: | 494 case Node::ELEMENT_NODE: |
| 503 appendElement(result, toElement(node), namespaces); | 495 appendElement(result, toElement(node), namespaces); |
| 504 break; | 496 break; |
| 505 case Node::CDATA_SECTION_NODE: | |
| 506 appendCDATASection(result, toCDATASection(node).data()); | |
| 507 break; | |
| 508 case Node::ATTRIBUTE_NODE: | 497 case Node::ATTRIBUTE_NODE: |
| 509 ASSERT_NOT_REACHED(); | 498 ASSERT_NOT_REACHED(); |
| 510 break; | 499 break; |
| 511 } | 500 } |
| 512 } | 501 } |
| 513 | 502 |
| 514 // Rules of self-closure | 503 // Rules of self-closure |
| 515 // 1. No elements in HTML documents use the self-closing syntax. | 504 // 1. No elements in HTML documents use the self-closing syntax. |
| 516 // 2. Elements w/ children never self-close because they use a separate end tag. | 505 // 2. Elements w/ children never self-close because they use a separate end tag. |
| 517 // 3. HTML elements which do not have a "forbidden" end tag will close with a se
parate end tag. | 506 // 3. HTML elements which do not have a "forbidden" end tag will close with a se
parate end tag. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 } | 539 } |
| 551 | 540 |
| 552 bool MarkupAccumulator::serializeAsHTMLDocument(const Node& node) const | 541 bool MarkupAccumulator::serializeAsHTMLDocument(const Node& node) const |
| 553 { | 542 { |
| 554 if (m_serializationType == ForcedXML) | 543 if (m_serializationType == ForcedXML) |
| 555 return false; | 544 return false; |
| 556 return node.document().isHTMLDocument(); | 545 return node.document().isHTMLDocument(); |
| 557 } | 546 } |
| 558 | 547 |
| 559 } | 548 } |
| OLD | NEW |