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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 296 |
297 result.append('='); | 297 result.append('='); |
298 result.append('"'); | 298 result.append('"'); |
299 appendAttributeValue(result, namespaceURI, false); | 299 appendAttributeValue(result, namespaceURI, false); |
300 result.append('"'); | 300 result.append('"'); |
301 } | 301 } |
302 } | 302 } |
303 | 303 |
304 EntityMask MarkupAccumulator::entityMaskForText(Text* text) const | 304 EntityMask MarkupAccumulator::entityMaskForText(Text* text) const |
305 { | 305 { |
| 306 if (!text->document().isHTMLDocument()) |
| 307 return EntityMaskInPCDATA; |
| 308 |
306 const QualifiedName* parentName = 0; | 309 const QualifiedName* parentName = 0; |
307 if (text->parentElement()) | 310 if (text->parentElement()) |
308 parentName = &(text->parentElement())->tagQName(); | 311 parentName = &(text->parentElement())->tagQName(); |
309 | 312 |
310 if (parentName && (*parentName == scriptTag || *parentName == styleTag || *p
arentName == xmpTag)) | 313 if (parentName && (*parentName == scriptTag || *parentName == styleTag || *p
arentName == xmpTag)) |
311 return EntityMaskInCDATA; | 314 return EntityMaskInCDATA; |
312 | 315 return EntityMaskInHTMLPCDATA; |
313 return text->document().isHTMLDocument() ? EntityMaskInHTMLPCDATA : EntityMa
skInPCDATA; | |
314 } | 316 } |
315 | 317 |
316 void MarkupAccumulator::appendText(StringBuilder& result, Text* text) | 318 void MarkupAccumulator::appendText(StringBuilder& result, Text* text) |
317 { | 319 { |
318 appendNodeValue(result, text, m_range, entityMaskForText(text)); | 320 appendNodeValue(result, text, m_range, entityMaskForText(text)); |
319 } | 321 } |
320 | 322 |
321 void MarkupAccumulator::appendComment(StringBuilder& result, const String& comme
nt) | 323 void MarkupAccumulator::appendComment(StringBuilder& result, const String& comme
nt) |
322 { | 324 { |
323 // FIXME: Comment content is not escaped, but XMLSerializer (and possibly ot
her callers) should raise an exception if it includes "-->". | 325 // FIXME: Comment content is not escaped, but XMLSerializer (and possibly ot
her callers) should raise an exception if it includes "-->". |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 if (!node->isElementNode() || shouldSelfClose(node) || (!node->hasChildNodes
() && elementCannotHaveEndTag(node))) | 548 if (!node->isElementNode() || shouldSelfClose(node) || (!node->hasChildNodes
() && elementCannotHaveEndTag(node))) |
547 return; | 549 return; |
548 | 550 |
549 result.append('<'); | 551 result.append('<'); |
550 result.append('/'); | 552 result.append('/'); |
551 result.append(toElement(node)->nodeNamePreservingCase()); | 553 result.append(toElement(node)->nodeNamePreservingCase()); |
552 result.append('>'); | 554 result.append('>'); |
553 } | 555 } |
554 | 556 |
555 } | 557 } |
OLD | NEW |