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

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

Issue 114103005: Use StringBuilder::appendLiteral() when possible in MarkupAccumulator (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
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.cpp ('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 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved.
4 * Copyright (C) 2011 Igalia S.L. 4 * Copyright (C) 2011 Igalia S.L.
5 * Copyright (C) 2011 Motorola Mobility. All rights reserved. 5 * Copyright (C) 2011 Motorola Mobility. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 179
180 void StyledMarkupAccumulator::appendStyleNodeOpenTag(StringBuilder& out, StylePr opertySet* style, Document* document, bool isBlock) 180 void StyledMarkupAccumulator::appendStyleNodeOpenTag(StringBuilder& out, StylePr opertySet* style, Document* document, bool isBlock)
181 { 181 {
182 // wrappingStyleForSerialization should have removed -webkit-text-decoration s-in-effect 182 // wrappingStyleForSerialization should have removed -webkit-text-decoration s-in-effect
183 ASSERT(propertyMissingOrEqualToNone(style, CSSPropertyWebkitTextDecorationsI nEffect)); 183 ASSERT(propertyMissingOrEqualToNone(style, CSSPropertyWebkitTextDecorationsI nEffect));
184 if (isBlock) 184 if (isBlock)
185 out.appendLiteral("<div style=\""); 185 out.appendLiteral("<div style=\"");
186 else 186 else
187 out.appendLiteral("<span style=\""); 187 out.appendLiteral("<span style=\"");
188 appendAttributeValue(out, style->asText(), document->isHTMLDocument()); 188 appendAttributeValue(out, style->asText(), document->isHTMLDocument());
189 out.append('\"'); 189 out.appendLiteral("\">");
190 out.append('>');
191 } 190 }
192 191
193 const String& StyledMarkupAccumulator::styleNodeCloseTag(bool isBlock) 192 const String& StyledMarkupAccumulator::styleNodeCloseTag(bool isBlock)
194 { 193 {
195 DEFINE_STATIC_LOCAL(const String, divClose, ("</div>")); 194 DEFINE_STATIC_LOCAL(const String, divClose, ("</div>"));
196 DEFINE_STATIC_LOCAL(const String, styleSpanClose, ("</span>")); 195 DEFINE_STATIC_LOCAL(const String, styleSpanClose, ("</span>"));
197 return isBlock ? divClose : styleSpanClose; 196 return isBlock ? divClose : styleSpanClose;
198 } 197 }
199 198
200 String StyledMarkupAccumulator::takeResults() 199 String StyledMarkupAccumulator::takeResults()
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 if (!frame) 924 if (!frame)
926 return String(); 925 return String();
927 926
928 // FIXME: This is always "for interchange". Is that right? See the previous method. 927 // FIXME: This is always "for interchange". Is that right? See the previous method.
929 return frame->documentTypeString() + createMarkup(range, 0, AnnotateForInter change); 928 return frame->documentTypeString() + createMarkup(range, 0, AnnotateForInter change);
930 } 929 }
931 930
932 String urlToMarkup(const KURL& url, const String& title) 931 String urlToMarkup(const KURL& url, const String& title)
933 { 932 {
934 StringBuilder markup; 933 StringBuilder markup;
935 markup.append("<a href=\""); 934 markup.appendLiteral("<a href=\"");
936 markup.append(url.string()); 935 markup.append(url.string());
937 markup.append("\">"); 936 markup.appendLiteral("\">");
938 MarkupAccumulator::appendCharactersReplacingEntities(markup, title, 0, title .length(), EntityMaskInPCDATA); 937 MarkupAccumulator::appendCharactersReplacingEntities(markup, title, 0, title .length(), EntityMaskInPCDATA);
939 markup.append("</a>"); 938 markup.appendLiteral("</a>");
940 return markup.toString(); 939 return markup.toString();
941 } 940 }
942 941
943 PassRefPtr<DocumentFragment> createFragmentForInnerOuterHTML(const String& marku p, Element* contextElement, ParserContentPolicy parserContentPolicy, const char* method, ExceptionState& exceptionState) 942 PassRefPtr<DocumentFragment> createFragmentForInnerOuterHTML(const String& marku p, Element* contextElement, ParserContentPolicy parserContentPolicy, const char* method, ExceptionState& exceptionState)
944 { 943 {
945 Document& document = contextElement->hasTagName(templateTag) ? contextElemen t->document().ensureTemplateDocument() : contextElement->document(); 944 Document& document = contextElement->hasTagName(templateTag) ? contextElemen t->document().ensureTemplateDocument() : contextElement->document();
946 RefPtr<DocumentFragment> fragment = DocumentFragment::create(document); 945 RefPtr<DocumentFragment> fragment = DocumentFragment::create(document);
947 946
948 if (document.isHTMLDocument()) { 947 if (document.isHTMLDocument()) {
949 fragment->parseHTML(markup, contextElement, parserContentPolicy); 948 fragment->parseHTML(markup, contextElement, parserContentPolicy);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 return; 1079 return;
1081 1080
1082 RefPtr<Text> textNode = toText(node.get()); 1081 RefPtr<Text> textNode = toText(node.get());
1083 RefPtr<Text> textNext = toText(next); 1082 RefPtr<Text> textNext = toText(next);
1084 textNode->appendData(textNext->data()); 1083 textNode->appendData(textNext->data());
1085 if (textNext->parentNode()) // Might have been removed by mutation event. 1084 if (textNext->parentNode()) // Might have been removed by mutation event.
1086 textNext->remove(exceptionState); 1085 textNext->remove(exceptionState);
1087 } 1086 }
1088 1087
1089 } 1088 }
OLDNEW
« no previous file with comments | « Source/core/editing/MarkupAccumulator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698