OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. | 4 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 479 |
480 EntityMask MarkupFormatter::entityMaskForText(const Text& text) const { | 480 EntityMask MarkupFormatter::entityMaskForText(const Text& text) const { |
481 if (!serializeAsHTMLDocument(text)) | 481 if (!serializeAsHTMLDocument(text)) |
482 return EntityMaskInPCDATA; | 482 return EntityMaskInPCDATA; |
483 | 483 |
484 // TODO(hajimehoshi): We need to switch EditingStrategy. | 484 // TODO(hajimehoshi): We need to switch EditingStrategy. |
485 const QualifiedName* parentName = nullptr; | 485 const QualifiedName* parentName = nullptr; |
486 if (text.parentElement()) | 486 if (text.parentElement()) |
487 parentName = &(text.parentElement())->tagQName(); | 487 parentName = &(text.parentElement())->tagQName(); |
488 | 488 |
489 if (parentName && (*parentName == scriptTag || *parentName == styleTag || | 489 if (parentName && |
490 *parentName == xmpTag)) | 490 (*parentName == scriptTag || *parentName == styleTag || |
| 491 *parentName == xmpTag)) |
491 return EntityMaskInCDATA; | 492 return EntityMaskInCDATA; |
492 return EntityMaskInHTMLPCDATA; | 493 return EntityMaskInHTMLPCDATA; |
493 } | 494 } |
494 | 495 |
495 // Rules of self-closure | 496 // Rules of self-closure |
496 // 1. No elements in HTML documents use the self-closing syntax. | 497 // 1. No elements in HTML documents use the self-closing syntax. |
497 // 2. Elements w/ children never self-close because they use a separate end tag. | 498 // 2. Elements w/ children never self-close because they use a separate end tag. |
498 // 3. HTML elements which do not have a "forbidden" end tag will close with a | 499 // 3. HTML elements which do not have a "forbidden" end tag will close with a |
499 // separate end tag. | 500 // separate end tag. |
500 // 4. Other elements self-close. | 501 // 4. Other elements self-close. |
501 bool MarkupFormatter::shouldSelfClose(const Element& element) const { | 502 bool MarkupFormatter::shouldSelfClose(const Element& element) const { |
502 if (serializeAsHTMLDocument(element)) | 503 if (serializeAsHTMLDocument(element)) |
503 return false; | 504 return false; |
504 if (element.hasChildren()) | 505 if (element.hasChildren()) |
505 return false; | 506 return false; |
506 if (element.isHTMLElement() && !elementCannotHaveEndTag(element)) | 507 if (element.isHTMLElement() && !elementCannotHaveEndTag(element)) |
507 return false; | 508 return false; |
508 return true; | 509 return true; |
509 } | 510 } |
510 | 511 |
511 bool MarkupFormatter::serializeAsHTMLDocument(const Node& node) const { | 512 bool MarkupFormatter::serializeAsHTMLDocument(const Node& node) const { |
512 if (m_serializationType == SerializationType::ForcedXML) | 513 if (m_serializationType == SerializationType::ForcedXML) |
513 return false; | 514 return false; |
514 return node.document().isHTMLDocument(); | 515 return node.document().isHTMLDocument(); |
515 } | 516 } |
516 | 517 |
517 } // namespace blink | 518 } // namespace blink |
OLD | NEW |