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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSBasicShapeValues.cpp

Issue 2017053003: Remove StringBuilder::appendLiteral. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase. Created 4 years, 6 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) 2011 Adobe Systems Incorporated. All rights reserved. 2 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above 8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following 9 * copyright notice, this list of conditions and the following
10 * disclaimer. 10 * disclaimer.
(...skipping 25 matching lines...) Expand all
36 36
37 using namespace WTF; 37 using namespace WTF;
38 38
39 namespace blink { 39 namespace blink {
40 40
41 static String buildCircleString(const String& radius, const String& centerX, con st String& centerY) 41 static String buildCircleString(const String& radius, const String& centerX, con st String& centerY)
42 { 42 {
43 char at[] = "at"; 43 char at[] = "at";
44 char separator[] = " "; 44 char separator[] = " ";
45 StringBuilder result; 45 StringBuilder result;
46 result.appendLiteral("circle("); 46 result.append("circle(");
47 if (!radius.isNull()) 47 if (!radius.isNull())
48 result.append(radius); 48 result.append(radius);
49 49
50 if (!centerX.isNull() || !centerY.isNull()) { 50 if (!centerX.isNull() || !centerY.isNull()) {
51 if (!radius.isNull()) 51 if (!radius.isNull())
52 result.appendLiteral(separator); 52 result.append(separator);
53 result.append(at); 53 result.append(at);
54 result.appendLiteral(separator); 54 result.append(separator);
55 result.append(centerX); 55 result.append(centerX);
56 result.appendLiteral(separator); 56 result.append(separator);
57 result.append(centerY); 57 result.append(centerY);
58 } 58 }
59 result.append(')'); 59 result.append(')');
60 return result.toString(); 60 return result.toString();
61 } 61 }
62 62
63 static String serializePositionOffset(const CSSValuePair& offset, const CSSValue Pair& other) 63 static String serializePositionOffset(const CSSValuePair& offset, const CSSValue Pair& other)
64 { 64 {
65 if ((toCSSPrimitiveValue(offset.first()).getValueID() == CSSValueLeft && toC SSPrimitiveValue(other.first()).getValueID() == CSSValueTop) 65 if ((toCSSPrimitiveValue(offset.first()).getValueID() == CSSValueLeft && toC SSPrimitiveValue(other.first()).getValueID() == CSSValueTop)
66 || (toCSSPrimitiveValue(offset.first()).getValueID() == CSSValueTop && t oCSSPrimitiveValue(other.first()).getValueID() == CSSValueLeft)) 66 || (toCSSPrimitiveValue(offset.first()).getValueID() == CSSValueTop && t oCSSPrimitiveValue(other.first()).getValueID() == CSSValueLeft))
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 visitor->trace(m_centerY); 129 visitor->trace(m_centerY);
130 visitor->trace(m_radius); 130 visitor->trace(m_radius);
131 CSSValue::traceAfterDispatch(visitor); 131 CSSValue::traceAfterDispatch(visitor);
132 } 132 }
133 133
134 static String buildEllipseString(const String& radiusX, const String& radiusY, c onst String& centerX, const String& centerY) 134 static String buildEllipseString(const String& radiusX, const String& radiusY, c onst String& centerX, const String& centerY)
135 { 135 {
136 char at[] = "at"; 136 char at[] = "at";
137 char separator[] = " "; 137 char separator[] = " ";
138 StringBuilder result; 138 StringBuilder result;
139 result.appendLiteral("ellipse("); 139 result.append("ellipse(");
140 bool needsSeparator = false; 140 bool needsSeparator = false;
141 if (!radiusX.isNull()) { 141 if (!radiusX.isNull()) {
142 result.append(radiusX); 142 result.append(radiusX);
143 needsSeparator = true; 143 needsSeparator = true;
144 } 144 }
145 if (!radiusY.isNull()) { 145 if (!radiusY.isNull()) {
146 if (needsSeparator) 146 if (needsSeparator)
147 result.appendLiteral(separator); 147 result.append(separator);
148 result.append(radiusY); 148 result.append(radiusY);
149 needsSeparator = true; 149 needsSeparator = true;
150 } 150 }
151 151
152 if (!centerX.isNull() || !centerY.isNull()) { 152 if (!centerX.isNull() || !centerY.isNull()) {
153 if (needsSeparator) 153 if (needsSeparator)
154 result.appendLiteral(separator); 154 result.append(separator);
155 result.appendLiteral(at); 155 result.append(at);
156 result.appendLiteral(separator); 156 result.append(separator);
157 result.append(centerX); 157 result.append(centerX);
158 result.appendLiteral(separator); 158 result.append(separator);
159 result.append(centerY); 159 result.append(centerY);
160 } 160 }
161 result.append(')'); 161 result.append(')');
162 return result.toString(); 162 return result.toString();
163 } 163 }
164 164
165 String CSSBasicShapeEllipseValue::customCSSText() const 165 String CSSBasicShapeEllipseValue::customCSSText() const
166 { 166 {
167 CSSValuePair* normalizedCX = buildSerializablePositionOffset(m_centerX, CSSV alueLeft); 167 CSSValuePair* normalizedCX = buildSerializablePositionOffset(m_centerX, CSSV alueLeft);
168 CSSValuePair* normalizedCY = buildSerializablePositionOffset(m_centerY, CSSV alueTop); 168 CSSValuePair* normalizedCY = buildSerializablePositionOffset(m_centerY, CSSV alueTop);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 size_t length = sizeof(evenOddOpening) - 1; 218 size_t length = sizeof(evenOddOpening) - 1;
219 for (size_t i = 0; i < points.size(); i += 2) { 219 for (size_t i = 0; i < points.size(); i += 2) {
220 if (i) 220 if (i)
221 length += (sizeof(commaSeparator) - 1); 221 length += (sizeof(commaSeparator) - 1);
222 // add length of two strings, plus one for the space separator. 222 // add length of two strings, plus one for the space separator.
223 length += points[i].length() + 1 + points[i + 1].length(); 223 length += points[i].length() + 1 + points[i + 1].length();
224 } 224 }
225 result.reserveCapacity(length); 225 result.reserveCapacity(length);
226 226
227 if (windRule == RULE_EVENODD) 227 if (windRule == RULE_EVENODD)
228 result.appendLiteral(evenOddOpening); 228 result.append(evenOddOpening);
229 else 229 else
230 result.appendLiteral(nonZeroOpening); 230 result.append(nonZeroOpening);
231 231
232 for (size_t i = 0; i < points.size(); i += 2) { 232 for (size_t i = 0; i < points.size(); i += 2) {
233 if (i) 233 if (i)
234 result.appendLiteral(commaSeparator); 234 result.append(commaSeparator);
235 result.append(points[i]); 235 result.append(points[i]);
236 result.append(' '); 236 result.append(' ');
237 result.append(points[i + 1]); 237 result.append(points[i + 1]);
238 } 238 }
239 239
240 result.append(')'); 240 result.append(')');
241 return result.toString(); 241 return result.toString();
242 } 242 }
243 243
244 String CSSBasicShapePolygonValue::customCSSText() const 244 String CSSBasicShapePolygonValue::customCSSText() const
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 static String buildInsetString(const String& top, const String& right, const Str ing& bottom, const String& left, 283 static String buildInsetString(const String& top, const String& right, const Str ing& bottom, const String& left,
284 const String& topLeftRadiusWidth, const String& topLeftRadiusHeight, 284 const String& topLeftRadiusWidth, const String& topLeftRadiusHeight,
285 const String& topRightRadiusWidth, const String& topRightRadiusHeight, 285 const String& topRightRadiusWidth, const String& topRightRadiusHeight,
286 const String& bottomRightRadiusWidth, const String& bottomRightRadiusHeight, 286 const String& bottomRightRadiusWidth, const String& bottomRightRadiusHeight,
287 const String& bottomLeftRadiusWidth, const String& bottomLeftRadiusHeight) 287 const String& bottomLeftRadiusWidth, const String& bottomLeftRadiusHeight)
288 { 288 {
289 char opening[] = "inset("; 289 char opening[] = "inset(";
290 char separator[] = " "; 290 char separator[] = " ";
291 char cornersSeparator[] = "round"; 291 char cornersSeparator[] = "round";
292 StringBuilder result; 292 StringBuilder result;
293 result.appendLiteral(opening); 293 result.append(opening);
294 result.append(top); 294 result.append(top);
295 bool showLeftArg = !left.isNull() && left != right; 295 bool showLeftArg = !left.isNull() && left != right;
296 bool showBottomArg = !bottom.isNull() && (bottom != top || showLeftArg); 296 bool showBottomArg = !bottom.isNull() && (bottom != top || showLeftArg);
297 bool showRightArg = !right.isNull() && (right != top || showBottomArg); 297 bool showRightArg = !right.isNull() && (right != top || showBottomArg);
298 if (showRightArg) { 298 if (showRightArg) {
299 result.appendLiteral(separator); 299 result.append(separator);
300 result.append(right); 300 result.append(right);
301 } 301 }
302 if (showBottomArg) { 302 if (showBottomArg) {
303 result.appendLiteral(separator); 303 result.append(separator);
304 result.append(bottom); 304 result.append(bottom);
305 } 305 }
306 if (showLeftArg) { 306 if (showLeftArg) {
307 result.appendLiteral(separator); 307 result.append(separator);
308 result.append(left); 308 result.append(left);
309 } 309 }
310 310
311 if (!topLeftRadiusWidth.isNull() && !topLeftRadiusHeight.isNull()) { 311 if (!topLeftRadiusWidth.isNull() && !topLeftRadiusHeight.isNull()) {
312 Vector<String> horizontalRadii; 312 Vector<String> horizontalRadii;
313 bool areDefaultCornerRadii = buildInsetRadii(horizontalRadii, topLeftRad iusWidth, topRightRadiusWidth, bottomRightRadiusWidth, bottomLeftRadiusWidth); 313 bool areDefaultCornerRadii = buildInsetRadii(horizontalRadii, topLeftRad iusWidth, topRightRadiusWidth, bottomRightRadiusWidth, bottomLeftRadiusWidth);
314 314
315 Vector<String> verticalRadii; 315 Vector<String> verticalRadii;
316 areDefaultCornerRadii &= buildInsetRadii(verticalRadii, topLeftRadiusHei ght, topRightRadiusHeight, bottomRightRadiusHeight, bottomLeftRadiusHeight); 316 areDefaultCornerRadii &= buildInsetRadii(verticalRadii, topLeftRadiusHei ght, topRightRadiusHeight, bottomRightRadiusHeight, bottomLeftRadiusHeight);
317 317
318 if (!areDefaultCornerRadii) { 318 if (!areDefaultCornerRadii) {
319 result.appendLiteral(separator); 319 result.append(separator);
320 result.appendLiteral(cornersSeparator); 320 result.append(cornersSeparator);
321 321
322 for (size_t i = 0; i < horizontalRadii.size(); ++i) { 322 for (size_t i = 0; i < horizontalRadii.size(); ++i) {
323 result.appendLiteral(separator); 323 result.append(separator);
324 result.append(horizontalRadii[i]); 324 result.append(horizontalRadii[i]);
325 } 325 }
326 if (horizontalRadii != verticalRadii) { 326 if (horizontalRadii != verticalRadii) {
327 result.appendLiteral(separator); 327 result.append(separator);
328 result.appendLiteral("/"); 328 result.append("/");
329 329
330 for (size_t i = 0; i < verticalRadii.size(); ++i) { 330 for (size_t i = 0; i < verticalRadii.size(); ++i) {
331 result.appendLiteral(separator); 331 result.append(separator);
332 result.append(verticalRadii[i]); 332 result.append(verticalRadii[i]);
333 } 333 }
334 } 334 }
335 } 335 }
336 } 336 }
337 result.append(')'); 337 result.append(')');
338 338
339 return result.toString(); 339 return result.toString();
340 } 340 }
341 341
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 visitor->trace(m_left); 398 visitor->trace(m_left);
399 visitor->trace(m_topLeftRadius); 399 visitor->trace(m_topLeftRadius);
400 visitor->trace(m_topRightRadius); 400 visitor->trace(m_topRightRadius);
401 visitor->trace(m_bottomRightRadius); 401 visitor->trace(m_bottomRightRadius);
402 visitor->trace(m_bottomLeftRadius); 402 visitor->trace(m_bottomLeftRadius);
403 CSSValue::traceAfterDispatch(visitor); 403 CSSValue::traceAfterDispatch(visitor);
404 } 404 }
405 405
406 } // namespace blink 406 } // namespace blink
407 407
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698