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

Side by Side Diff: third_party/WebKit/Source/core/editing/serializers/MarkupFormatter.cpp

Issue 2804943002: Avoid duplicate functions/code in core/editing: endTag (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
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 19 matching lines...) Expand all
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" 34 #include "core/dom/CDATASection.h"
35 #include "core/dom/Comment.h" 35 #include "core/dom/Comment.h"
36 #include "core/dom/Document.h" 36 #include "core/dom/Document.h"
37 #include "core/dom/DocumentFragment.h" 37 #include "core/dom/DocumentFragment.h"
38 #include "core/dom/DocumentType.h" 38 #include "core/dom/DocumentType.h"
39 #include "core/dom/ProcessingInstruction.h" 39 #include "core/dom/ProcessingInstruction.h"
40 #include "core/editing/EditingUtilities.h"
40 #include "core/editing/Editor.h" 41 #include "core/editing/Editor.h"
41 #include "core/html/HTMLElement.h" 42 #include "core/html/HTMLElement.h"
42 #include "core/html/HTMLTemplateElement.h" 43 #include "core/html/HTMLTemplateElement.h"
43 #include "platform/weborigin/KURL.h" 44 #include "platform/weborigin/KURL.h"
44 #include "wtf/text/CharacterNames.h" 45 #include "wtf/text/CharacterNames.h"
45 46
46 namespace blink { 47 namespace blink {
47 48
48 using namespace HTMLNames; 49 using namespace HTMLNames;
49 50
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 break; 172 break;
172 case Node::kCdataSectionNode: 173 case Node::kCdataSectionNode:
173 appendCDATASection(result, toCDATASection(node).data()); 174 appendCDATASection(result, toCDATASection(node).data());
174 break; 175 break;
175 case Node::kAttributeNode: 176 case Node::kAttributeNode:
176 NOTREACHED(); 177 NOTREACHED();
177 break; 178 break;
178 } 179 }
179 } 180 }
180 181
181 static bool elementCannotHaveEndTag(const Node& node) {
182 if (!node.isHTMLElement())
183 return false;
184
185 return !toHTMLElement(node).shouldSerializeEndTag();
186 }
187
188 void MarkupFormatter::appendEndMarkup(StringBuilder& result, 182 void MarkupFormatter::appendEndMarkup(StringBuilder& result,
189 const Element& element) { 183 const Element& element) {
190 if (shouldSelfClose(element) || 184 if (shouldSelfClose(element) ||
191 (!element.hasChildren() && elementCannotHaveEndTag(element))) 185 (!element.hasChildren() && elementCannotHaveEndTag(element)))
192 return; 186 return;
193 187
194 result.append("</"); 188 result.append("</");
195 result.append(element.tagQName().toString()); 189 result.append(element.tagQName().toString());
196 result.append('>'); 190 result.append('>');
197 } 191 }
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 return true; 498 return true;
505 } 499 }
506 500
507 bool MarkupFormatter::serializeAsHTMLDocument(const Node& node) const { 501 bool MarkupFormatter::serializeAsHTMLDocument(const Node& node) const {
508 if (m_serializationType == SerializationType::ForcedXML) 502 if (m_serializationType == SerializationType::ForcedXML)
509 return false; 503 return false;
510 return node.document().isHTMLDocument(); 504 return node.document().isHTMLDocument();
511 } 505 }
512 506
513 } // namespace blink 507 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698