Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: Source/core/editing/MarkupAccumulator.cpp

Issue 135443003: Remove MarkupAccumulator::appendNodeValue() method (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@using_namespace_header
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/editing/MarkupAccumulator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 result.append(quoteChar); 215 result.append(quoteChar);
216 return; 216 return;
217 } 217 }
218 218
219 // FIXME: This does not fully match other browsers. Firefox percent-escapes non-ASCII characters for innerHTML. 219 // FIXME: This does not fully match other browsers. Firefox percent-escapes non-ASCII characters for innerHTML.
220 result.append(quoteChar); 220 result.append(quoteChar);
221 appendAttributeValue(result, resolvedURLString, false); 221 appendAttributeValue(result, resolvedURLString, false);
222 result.append(quoteChar); 222 result.append(quoteChar);
223 } 223 }
224 224
225 void MarkupAccumulator::appendNodeValue(StringBuilder& result, const Node* node, const Range* range, EntityMask entityMask)
226 {
227 const String str = node->nodeValue();
228 unsigned length = str.length();
229 unsigned start = 0;
230
231 if (range) {
232 if (node == range->endContainer())
233 length = range->endOffset();
234 if (node == range->startContainer()) {
235 start = range->startOffset();
236 length -= start;
237 }
238 }
239
240 appendCharactersReplacingEntities(result, str, start, length, entityMask);
241 }
242
243 bool MarkupAccumulator::shouldAddNamespaceElement(const Element* element) 225 bool MarkupAccumulator::shouldAddNamespaceElement(const Element* element)
244 { 226 {
245 // Don't add namespace attribute if it is already defined for this elem. 227 // Don't add namespace attribute if it is already defined for this elem.
246 const AtomicString& prefix = element->prefix(); 228 const AtomicString& prefix = element->prefix();
247 if (prefix.isEmpty()) 229 if (prefix.isEmpty())
248 return !element->hasAttribute(xmlnsAtom); 230 return !element->hasAttribute(xmlnsAtom);
249 231
250 DEFINE_STATIC_LOCAL(String, xmlnsWithColon, ("xmlns:")); 232 DEFINE_STATIC_LOCAL(String, xmlnsWithColon, ("xmlns:"));
251 return !element->hasAttribute(xmlnsWithColon + prefix); 233 return !element->hasAttribute(xmlnsWithColon + prefix);
252 } 234 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 if (text->parentElement()) 282 if (text->parentElement())
301 parentName = &(text->parentElement())->tagQName(); 283 parentName = &(text->parentElement())->tagQName();
302 284
303 if (parentName && (*parentName == scriptTag || *parentName == styleTag || *p arentName == xmpTag)) 285 if (parentName && (*parentName == scriptTag || *parentName == styleTag || *p arentName == xmpTag))
304 return EntityMaskInCDATA; 286 return EntityMaskInCDATA;
305 return EntityMaskInHTMLPCDATA; 287 return EntityMaskInHTMLPCDATA;
306 } 288 }
307 289
308 void MarkupAccumulator::appendText(StringBuilder& result, Text* text) 290 void MarkupAccumulator::appendText(StringBuilder& result, Text* text)
309 { 291 {
310 appendNodeValue(result, text, m_range, entityMaskForText(text)); 292 const String& str = text->data();
293 unsigned length = str.length();
294 unsigned start = 0;
295
296 if (m_range) {
297 if (text == m_range->endContainer())
298 length = m_range->endOffset();
299 if (text == m_range->startContainer()) {
300 start = m_range->startOffset();
301 length -= start;
302 }
303 }
304 appendCharactersReplacingEntities(result, str, start, length, entityMaskForT ext(text));
311 } 305 }
312 306
313 void MarkupAccumulator::appendComment(StringBuilder& result, const String& comme nt) 307 void MarkupAccumulator::appendComment(StringBuilder& result, const String& comme nt)
314 { 308 {
315 // FIXME: Comment content is not escaped, but XMLSerializer (and possibly ot her callers) should raise an exception if it includes "-->". 309 // FIXME: Comment content is not escaped, but XMLSerializer (and possibly ot her callers) should raise an exception if it includes "-->".
316 result.appendLiteral("<!--"); 310 result.appendLiteral("<!--");
317 result.append(comment); 311 result.append(comment);
318 result.appendLiteral("-->"); 312 result.appendLiteral("-->");
319 } 313 }
320 314
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 { 524 {
531 if (!node->isElementNode() || shouldSelfClose(node) || (!node->hasChildNodes () && elementCannotHaveEndTag(node))) 525 if (!node->isElementNode() || shouldSelfClose(node) || (!node->hasChildNodes () && elementCannotHaveEndTag(node)))
532 return; 526 return;
533 527
534 result.appendLiteral("</"); 528 result.appendLiteral("</");
535 result.append(toElement(node)->nodeNamePreservingCase()); 529 result.append(toElement(node)->nodeNamePreservingCase());
536 result.append('>'); 530 result.append('>');
537 } 531 }
538 532
539 } 533 }
OLDNEW
« no previous file with comments | « Source/core/editing/MarkupAccumulator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698