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

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

Issue 171773008: Rename childNodeCount() / childNode() methods for clarity (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Further renaming for consistency Created 6 years, 10 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 | Annotate | Revision Log
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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 499
500 // Rules of self-closure 500 // Rules of self-closure
501 // 1. No elements in HTML documents use the self-closing syntax. 501 // 1. No elements in HTML documents use the self-closing syntax.
502 // 2. Elements w/ children never self-close because they use a separate end tag. 502 // 2. Elements w/ children never self-close because they use a separate end tag.
503 // 3. HTML elements which do not have a "forbidden" end tag will close with a se parate end tag. 503 // 3. HTML elements which do not have a "forbidden" end tag will close with a se parate end tag.
504 // 4. Other elements self-close. 504 // 4. Other elements self-close.
505 bool MarkupAccumulator::shouldSelfClose(const Node& node) 505 bool MarkupAccumulator::shouldSelfClose(const Node& node)
506 { 506 {
507 if (node.document().isHTMLDocument()) 507 if (node.document().isHTMLDocument())
508 return false; 508 return false;
509 if (node.hasChildNodes()) 509 if (node.hasChildren())
510 return false; 510 return false;
511 if (node.isHTMLElement() && !elementCannotHaveEndTag(node)) 511 if (node.isHTMLElement() && !elementCannotHaveEndTag(node))
512 return false; 512 return false;
513 return true; 513 return true;
514 } 514 }
515 515
516 bool MarkupAccumulator::elementCannotHaveEndTag(const Node& node) 516 bool MarkupAccumulator::elementCannotHaveEndTag(const Node& node)
517 { 517 {
518 if (!node.isHTMLElement()) 518 if (!node.isHTMLElement())
519 return false; 519 return false;
520 520
521 // FIXME: ieForbidsInsertHTML may not be the right function to call here 521 // FIXME: ieForbidsInsertHTML may not be the right function to call here
522 // ieForbidsInsertHTML is used to disallow setting innerHTML/outerHTML 522 // ieForbidsInsertHTML is used to disallow setting innerHTML/outerHTML
523 // or createContextualFragment. It does not necessarily align with 523 // or createContextualFragment. It does not necessarily align with
524 // which elements should be serialized w/o end tags. 524 // which elements should be serialized w/o end tags.
525 return toHTMLElement(node).ieForbidsInsertHTML(); 525 return toHTMLElement(node).ieForbidsInsertHTML();
526 } 526 }
527 527
528 void MarkupAccumulator::appendEndMarkup(StringBuilder& result, const Node& node) 528 void MarkupAccumulator::appendEndMarkup(StringBuilder& result, const Node& node)
529 { 529 {
530 if (!node.isElementNode() || shouldSelfClose(node) || (!node.hasChildNodes() && elementCannotHaveEndTag(node))) 530 if (!node.isElementNode() || shouldSelfClose(node) || (!node.hasChildren() & & elementCannotHaveEndTag(node)))
531 return; 531 return;
532 532
533 result.appendLiteral("</"); 533 result.appendLiteral("</");
534 result.append(nodeNamePreservingCase(toElement(node))); 534 result.append(nodeNamePreservingCase(toElement(node)));
535 result.append('>'); 535 result.append('>');
536 } 536 }
537 537
538 } 538 }
OLDNEW
« no previous file with comments | « Source/core/editing/InsertParagraphSeparatorCommand.cpp ('k') | Source/core/editing/ReplaceSelectionCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698