Chromium Code Reviews| 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 bool showRightArg = !right.isNull() && (right != top || showBottomArg); | |
| 302 if (showRightArg) { | |
| 300 result.appendLiteral(separator); | 303 result.appendLiteral(separator); |
| 301 result.append(right); | 304 result.append(right); |
| 302 } | 305 } |
| 303 if (!bottom.isNull()) { | 306 if (showBottomArg) { |
| 304 result.appendLiteral(separator); | 307 result.appendLiteral(separator); |
| 305 result.append(bottom); | 308 result.append(bottom); |
| 306 } | 309 } |
| 307 if (!left.isNull()) { | 310 if (showLeftArg) { |
| 308 result.appendLiteral(separator); | 311 result.appendLiteral(separator); |
| 309 result.append(left); | 312 result.append(left); |
| 310 } | 313 } |
| 311 | 314 |
| 312 if (!topLeftRadiusWidth.isNull() && !topLeftRadiusHeight.isNull()) { | 315 if (!topLeftRadiusWidth.isNull() && !topLeftRadiusHeight.isNull()) { |
| 313 result.appendLiteral(separator); | 316 bool showHorizontalBottomLeft = topRightRadiusWidth != bottomLeftRadiusW idth; |
| 314 result.appendLiteral(cornersSeparator); | 317 bool showHorizontalBottomRight = showHorizontalBottomLeft || (bottomRigh tRadiusWidth != topLeftRadiusWidth); |
| 315 result.appendLiteral(separator); | 318 bool showHorizontalTopRight = showHorizontalBottomRight || (topRightRadi usWidth != topLeftRadiusWidth); |
| 316 | 319 |
| 317 result.append(topLeftRadiusWidth); | 320 Vector<String> horizontalRadii; |
|
Bear Travis
2014/04/08 19:08:35
Would it be possible / worth it to factor out the
| |
| 318 result.appendLiteral(separator); | 321 horizontalRadii.append(topLeftRadiusWidth); |
| 319 result.append(topRightRadiusWidth); | 322 if (showHorizontalTopRight) |
| 320 result.appendLiteral(separator); | 323 horizontalRadii.append(topRightRadiusWidth); |
| 321 result.append(bottomRightRadiusWidth); | 324 if (showHorizontalBottomRight) |
| 322 result.appendLiteral(separator); | 325 horizontalRadii.append(bottomRightRadiusWidth); |
| 323 result.append(bottomLeftRadiusWidth); | 326 if (showHorizontalBottomLeft) |
| 327 horizontalRadii.append(bottomLeftRadiusWidth); | |
| 324 | 328 |
| 325 result.appendLiteral(separator); | 329 bool showVerticalBottomLeft = topRightRadiusHeight != bottomLeftRadiusHe ight; |
| 326 result.appendLiteral("/"); | 330 bool showVerticalBottomRight = showVerticalBottomLeft || (bottomRightRad iusHeight != topLeftRadiusHeight); |
| 327 result.appendLiteral(separator); | 331 bool showVerticalTopRight = showVerticalBottomRight || (topRightRadiusHe ight != topLeftRadiusHeight); |
| 328 | 332 |
| 329 result.append(topLeftRadiusHeight); | 333 Vector<String> verticalRadii; |
| 330 result.appendLiteral(separator); | 334 verticalRadii.append(topLeftRadiusHeight); |
| 331 result.append(topRightRadiusHeight); | 335 if (showVerticalTopRight) |
| 332 result.appendLiteral(separator); | 336 verticalRadii.append(topRightRadiusHeight); |
| 333 result.append(bottomRightRadiusHeight); | 337 if (showVerticalBottomRight) |
| 334 result.appendLiteral(separator); | 338 verticalRadii.append(bottomRightRadiusHeight); |
| 335 result.append(bottomLeftRadiusHeight); | 339 if (showVerticalBottomLeft) |
| 340 verticalRadii.append(bottomLeftRadiusHeight); | |
| 341 | |
| 342 if (!(horizontalRadii.size() == 1 && horizontalRadii[0] == "0px" && vert icalRadii[0] == "0px")) { | |
|
Bear Travis
2014/04/08 19:08:35
I think this also needs to check for verticalRadii
| |
| 343 result.appendLiteral(separator); | |
| 344 result.appendLiteral(cornersSeparator); | |
| 345 | |
| 346 for (size_t i = 0; i < horizontalRadii.size(); ++i) { | |
| 347 result.appendLiteral(separator); | |
| 348 result.append(horizontalRadii[i]); | |
| 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 |