OLD | NEW |
---|---|
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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 const String& topRightRadiusWidth, const String& topRightRadiusHeight, | 289 const String& topRightRadiusWidth, const String& topRightRadiusHeight, |
290 const String& bottomRightRadiusWidth, const String& bottomRightRadiusHeight, | 290 const String& bottomRightRadiusWidth, const String& bottomRightRadiusHeight, |
291 const String& bottomLeftRadiusWidth, const String& bottomLeftRadiusHeight) | 291 const String& bottomLeftRadiusWidth, const String& bottomLeftRadiusHeight) |
292 { | 292 { |
293 char opening[] = "inset("; | 293 char opening[] = "inset("; |
294 char separator[] = " "; | 294 char separator[] = " "; |
295 char cornersSeparator[] = "round"; | 295 char cornersSeparator[] = "round"; |
296 StringBuilder result; | 296 StringBuilder result; |
297 result.appendLiteral(opening); | 297 result.appendLiteral(opening); |
298 result.append(top); | 298 result.append(top); |
299 if (!right.isNull()) { | 299 bool showLeftArg = !left.isNull() && left != right; |
300 bool showBottomArg = !bottom.isNull() && (bottom != top || showLeftArg); | |
301 if (!right.isNull() && (right != top || showBottomArg)) { | |
Bear Travis
2014/04/07 21:59:13
Personally, I think this should be stored in a 'sh
| |
300 result.appendLiteral(separator); | 302 result.appendLiteral(separator); |
301 result.append(right); | 303 result.append(right); |
302 } | 304 } |
303 if (!bottom.isNull()) { | 305 if (showBottomArg) { |
304 result.appendLiteral(separator); | 306 result.appendLiteral(separator); |
305 result.append(bottom); | 307 result.append(bottom); |
306 } | 308 } |
307 if (!left.isNull()) { | 309 if (showLeftArg) { |
308 result.appendLiteral(separator); | 310 result.appendLiteral(separator); |
309 result.append(left); | 311 result.append(left); |
310 } | 312 } |
311 | 313 |
312 if (!topLeftRadiusWidth.isNull() && !topLeftRadiusHeight.isNull()) { | 314 if (!topLeftRadiusWidth.isNull() && !topLeftRadiusHeight.isNull()) { |
313 result.appendLiteral(separator); | 315 bool showHorizontalBottomLeft = topRightRadiusWidth != bottomLeftRadiusW idth; |
Bear Travis
2014/04/07 21:59:13
This logic seems like it could be factored out and
| |
314 result.appendLiteral(cornersSeparator); | 316 bool showHorizontalBottomRight = showHorizontalBottomLeft || (bottomRigh tRadiusWidth != topLeftRadiusWidth); |
315 result.appendLiteral(separator); | 317 bool showHorizontalTopRight = showHorizontalBottomRight || (topRightRadi usWidth != topLeftRadiusWidth); |
316 | 318 |
317 result.append(topLeftRadiusWidth); | 319 Vector<String> horizontalRadii; |
Bear Travis
2014/04/07 21:59:13
Would it be possible to get around always creating
| |
318 result.appendLiteral(separator); | 320 horizontalRadii.append(topLeftRadiusWidth); |
319 result.append(topRightRadiusWidth); | 321 if (showHorizontalTopRight) |
320 result.appendLiteral(separator); | 322 horizontalRadii.append(topRightRadiusWidth); |
321 result.append(bottomRightRadiusWidth); | 323 if (showHorizontalBottomRight) |
322 result.appendLiteral(separator); | 324 horizontalRadii.append(bottomRightRadiusWidth); |
323 result.append(bottomLeftRadiusWidth); | 325 if (showHorizontalBottomLeft) |
326 horizontalRadii.append(bottomLeftRadiusWidth); | |
324 | 327 |
325 result.appendLiteral(separator); | 328 if (horizontalRadii.size() > 1 || horizontalRadii[0] != "0px") { |
Bear Travis
2014/04/07 21:59:13
This would not appear to catch the case inset(10px
| |
326 result.appendLiteral("/"); | 329 bool showVerticalBottomLeft = topRightRadiusHeight != bottomLeftRadi usHeight; |
327 result.appendLiteral(separator); | 330 bool showVerticalBottomRight = showVerticalBottomLeft || (bottomRigh tRadiusHeight != topLeftRadiusHeight); |
331 bool showVerticalTopRight = showVerticalBottomRight || (topRightRadi usHeight != topLeftRadiusHeight); | |
328 | 332 |
329 result.append(topLeftRadiusHeight); | 333 result.appendLiteral(separator); |
330 result.appendLiteral(separator); | 334 result.appendLiteral(cornersSeparator); |
331 result.append(topRightRadiusHeight); | 335 |
332 result.appendLiteral(separator); | 336 Vector<String> verticalRadii; |
333 result.append(bottomRightRadiusHeight); | 337 verticalRadii.append(topLeftRadiusHeight); |
334 result.appendLiteral(separator); | 338 if (showVerticalTopRight) |
335 result.append(bottomLeftRadiusHeight); | 339 verticalRadii.append(topRightRadiusHeight); |
340 if (showVerticalBottomRight) | |
341 verticalRadii.append(bottomRightRadiusHeight); | |
342 if (showVerticalBottomLeft) | |
343 verticalRadii.append(bottomLeftRadiusHeight); | |
344 | |
345 for (size_t i = 0; i < horizontalRadii.size(); ++i) { | |
346 result.appendLiteral(separator); | |
347 result.append(horizontalRadii[i]); | |
348 } | |
349 | |
350 if (horizontalRadii != verticalRadii) { | |
351 result.appendLiteral(separator); | |
352 result.appendLiteral("/"); | |
353 | |
354 for (size_t i = 0; i < verticalRadii.size(); ++i) { | |
355 result.appendLiteral(separator); | |
356 result.append(verticalRadii[i]); | |
357 } | |
358 } | |
359 } | |
336 } | 360 } |
337 result.append(')'); | 361 result.append(')'); |
338 | 362 |
339 return result.toString(); | 363 return result.toString(); |
340 } | 364 } |
341 | 365 |
342 static inline void updateCornerRadiusWidthAndHeight(CSSPrimitiveValue* corner, S tring& width, String& height) | 366 static inline void updateCornerRadiusWidthAndHeight(CSSPrimitiveValue* corner, S tring& width, String& height) |
343 { | 367 { |
344 if (!corner) | 368 if (!corner) |
345 return; | 369 return; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 visitor->trace(m_left); | 428 visitor->trace(m_left); |
405 visitor->trace(m_topLeftRadius); | 429 visitor->trace(m_topLeftRadius); |
406 visitor->trace(m_topRightRadius); | 430 visitor->trace(m_topRightRadius); |
407 visitor->trace(m_bottomRightRadius); | 431 visitor->trace(m_bottomRightRadius); |
408 visitor->trace(m_bottomLeftRadius); | 432 visitor->trace(m_bottomLeftRadius); |
409 CSSBasicShape::trace(visitor); | 433 CSSBasicShape::trace(visitor); |
410 } | 434 } |
411 | 435 |
412 } // namespace WebCore | 436 } // namespace WebCore |
413 | 437 |
OLD | NEW |