| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 ASSERT(toAnimatableUnknown(value)->toCSSValueID() == CSSValueAuto); | 92 ASSERT(toAnimatableUnknown(value)->toCSSValueID() == CSSValueAuto); |
| 93 return Length(Auto); | 93 return Length(Auto); |
| 94 } | 94 } |
| 95 | 95 |
| 96 template<typename T> T animatableValueClampTo(const AnimatableValue* value, T mi
n = defaultMinimumForClamp<T>(), T max = defaultMaximumForClamp<T>()) | 96 template<typename T> T animatableValueClampTo(const AnimatableValue* value, T mi
n = defaultMinimumForClamp<T>(), T max = defaultMaximumForClamp<T>()) |
| 97 { | 97 { |
| 98 static_assert(WTF::IsInteger<T>::value, "should use integral type T when rou
nding values"); | 98 static_assert(WTF::IsInteger<T>::value, "should use integral type T when rou
nding values"); |
| 99 return clampTo<T>(roundForImpreciseConversion<T>(toAnimatableDouble(value)->
toDouble()), min, max); | 99 return clampTo<T>(roundForImpreciseConversion<T>(toAnimatableDouble(value)->
toDouble()), min, max); |
| 100 } | 100 } |
| 101 | 101 |
| 102 template<typename T> T animatableLineWidthClamp(const AnimatableValue* value) |
| 103 { |
| 104 double doubleValue = toAnimatableDouble(value)->toDouble(); |
| 105 // This matches StyleBuilderConverter::convertLineWidth(). |
| 106 return (doubleValue > 0 && doubleValue < 1) ? 1 : animatableValueClampTo<T>(
value); |
| 107 } |
| 108 |
| 102 LengthBox animatableValueToLengthBox(const AnimatableValue* value, const StyleRe
solverState& state, ValueRange range = ValueRangeAll) | 109 LengthBox animatableValueToLengthBox(const AnimatableValue* value, const StyleRe
solverState& state, ValueRange range = ValueRangeAll) |
| 103 { | 110 { |
| 104 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value
); | 111 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value
); |
| 105 return LengthBox( | 112 return LengthBox( |
| 106 animatableValueToLength(animatableLengthBox->top(), state, range), | 113 animatableValueToLength(animatableLengthBox->top(), state, range), |
| 107 animatableValueToLength(animatableLengthBox->right(), state, range), | 114 animatableValueToLength(animatableLengthBox->right(), state, range), |
| 108 animatableValueToLength(animatableLengthBox->bottom(), state, range), | 115 animatableValueToLength(animatableLengthBox->bottom(), state, range), |
| 109 animatableValueToLength(animatableLengthBox->left(), state, range)); | 116 animatableValueToLength(animatableLengthBox->left(), state, range)); |
| 110 } | 117 } |
| 111 | 118 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 style->setBorderBottomColor(toAnimatableColor(value)->color()); | 315 style->setBorderBottomColor(toAnimatableColor(value)->color()); |
| 309 style->setVisitedLinkBorderBottomColor(toAnimatableColor(value)->visited
LinkColor()); | 316 style->setVisitedLinkBorderBottomColor(toAnimatableColor(value)->visited
LinkColor()); |
| 310 return; | 317 return; |
| 311 case CSSPropertyBorderBottomLeftRadius: | 318 case CSSPropertyBorderBottomLeftRadius: |
| 312 style->setBorderBottomLeftRadius(animatableValueToLengthSize(value, stat
e, ValueRangeNonNegative)); | 319 style->setBorderBottomLeftRadius(animatableValueToLengthSize(value, stat
e, ValueRangeNonNegative)); |
| 313 return; | 320 return; |
| 314 case CSSPropertyBorderBottomRightRadius: | 321 case CSSPropertyBorderBottomRightRadius: |
| 315 style->setBorderBottomRightRadius(animatableValueToLengthSize(value, sta
te, ValueRangeNonNegative)); | 322 style->setBorderBottomRightRadius(animatableValueToLengthSize(value, sta
te, ValueRangeNonNegative)); |
| 316 return; | 323 return; |
| 317 case CSSPropertyBorderBottomWidth: | 324 case CSSPropertyBorderBottomWidth: |
| 318 style->setBorderBottomWidth(animatableValueClampTo<unsigned>(value)); | 325 style->setBorderBottomWidth(animatableLineWidthClamp<unsigned>(value)); |
| 319 return; | 326 return; |
| 320 case CSSPropertyBorderImageOutset: | 327 case CSSPropertyBorderImageOutset: |
| 321 style->setBorderImageOutset(animatableValueToBorderImageLengthBox(value,
state)); | 328 style->setBorderImageOutset(animatableValueToBorderImageLengthBox(value,
state)); |
| 322 return; | 329 return; |
| 323 case CSSPropertyBorderImageSlice: | 330 case CSSPropertyBorderImageSlice: |
| 324 style->setBorderImageSlices(animatableValueToLengthBox(toAnimatableLengt
hBoxAndBool(value)->box(), state, ValueRangeNonNegative)); | 331 style->setBorderImageSlices(animatableValueToLengthBox(toAnimatableLengt
hBoxAndBool(value)->box(), state, ValueRangeNonNegative)); |
| 325 style->setBorderImageSlicesFill(toAnimatableLengthBoxAndBool(value)->fla
g()); | 332 style->setBorderImageSlicesFill(toAnimatableLengthBoxAndBool(value)->fla
g()); |
| 326 return; | 333 return; |
| 327 case CSSPropertyBorderImageSource: | 334 case CSSPropertyBorderImageSource: |
| 328 style->setBorderImageSource(state.styleImage(property, *toAnimatableImag
e(value)->toCSSValue())); | 335 style->setBorderImageSource(state.styleImage(property, *toAnimatableImag
e(value)->toCSSValue())); |
| 329 return; | 336 return; |
| 330 case CSSPropertyBorderImageWidth: | 337 case CSSPropertyBorderImageWidth: |
| 331 style->setBorderImageWidth(animatableValueToBorderImageLengthBox(value,
state)); | 338 style->setBorderImageWidth(animatableValueToBorderImageLengthBox(value,
state)); |
| 332 return; | 339 return; |
| 333 case CSSPropertyBorderLeftColor: | 340 case CSSPropertyBorderLeftColor: |
| 334 style->setBorderLeftColor(toAnimatableColor(value)->color()); | 341 style->setBorderLeftColor(toAnimatableColor(value)->color()); |
| 335 style->setVisitedLinkBorderLeftColor(toAnimatableColor(value)->visitedLi
nkColor()); | 342 style->setVisitedLinkBorderLeftColor(toAnimatableColor(value)->visitedLi
nkColor()); |
| 336 return; | 343 return; |
| 337 case CSSPropertyBorderLeftWidth: | 344 case CSSPropertyBorderLeftWidth: |
| 338 style->setBorderLeftWidth(animatableValueClampTo<unsigned>(value)); | 345 style->setBorderLeftWidth(animatableLineWidthClamp<unsigned>(value)); |
| 339 return; | 346 return; |
| 340 case CSSPropertyBorderRightColor: | 347 case CSSPropertyBorderRightColor: |
| 341 style->setBorderRightColor(toAnimatableColor(value)->color()); | 348 style->setBorderRightColor(toAnimatableColor(value)->color()); |
| 342 style->setVisitedLinkBorderRightColor(toAnimatableColor(value)->visitedL
inkColor()); | 349 style->setVisitedLinkBorderRightColor(toAnimatableColor(value)->visitedL
inkColor()); |
| 343 return; | 350 return; |
| 344 case CSSPropertyBorderRightWidth: | 351 case CSSPropertyBorderRightWidth: |
| 345 style->setBorderRightWidth(animatableValueClampTo<unsigned>(value)); | 352 style->setBorderRightWidth(animatableLineWidthClamp<unsigned>(value)); |
| 346 return; | 353 return; |
| 347 case CSSPropertyBorderTopColor: | 354 case CSSPropertyBorderTopColor: |
| 348 style->setBorderTopColor(toAnimatableColor(value)->color()); | 355 style->setBorderTopColor(toAnimatableColor(value)->color()); |
| 349 style->setVisitedLinkBorderTopColor(toAnimatableColor(value)->visitedLin
kColor()); | 356 style->setVisitedLinkBorderTopColor(toAnimatableColor(value)->visitedLin
kColor()); |
| 350 return; | 357 return; |
| 351 case CSSPropertyBorderTopLeftRadius: | 358 case CSSPropertyBorderTopLeftRadius: |
| 352 style->setBorderTopLeftRadius(animatableValueToLengthSize(value, state,
ValueRangeNonNegative)); | 359 style->setBorderTopLeftRadius(animatableValueToLengthSize(value, state,
ValueRangeNonNegative)); |
| 353 return; | 360 return; |
| 354 case CSSPropertyBorderTopRightRadius: | 361 case CSSPropertyBorderTopRightRadius: |
| 355 style->setBorderTopRightRadius(animatableValueToLengthSize(value, state,
ValueRangeNonNegative)); | 362 style->setBorderTopRightRadius(animatableValueToLengthSize(value, state,
ValueRangeNonNegative)); |
| 356 return; | 363 return; |
| 357 case CSSPropertyBorderTopWidth: | 364 case CSSPropertyBorderTopWidth: |
| 358 style->setBorderTopWidth(animatableValueClampTo<unsigned>(value)); | 365 style->setBorderTopWidth(animatableLineWidthClamp<unsigned>(value)); |
| 359 return; | 366 return; |
| 360 case CSSPropertyBottom: | 367 case CSSPropertyBottom: |
| 361 style->setBottom(animatableValueToLength(value, state)); | 368 style->setBottom(animatableValueToLength(value, state)); |
| 362 return; | 369 return; |
| 363 case CSSPropertyBoxShadow: | 370 case CSSPropertyBoxShadow: |
| 364 style->setBoxShadow(toAnimatableShadow(value)->shadowList()); | 371 style->setBoxShadow(toAnimatableShadow(value)->shadowList()); |
| 365 return; | 372 return; |
| 366 case CSSPropertyClip: | 373 case CSSPropertyClip: |
| 367 style->setClip(animatableValueToLengthBox(value, state)); | 374 style->setClip(animatableValueToLengthBox(value, state)); |
| 368 return; | 375 return; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 style->setOrphans(clampTo<unsigned short>(round(toAnimatableDouble(value
)->toDouble()), 1)); | 470 style->setOrphans(clampTo<unsigned short>(round(toAnimatableDouble(value
)->toDouble()), 1)); |
| 464 return; | 471 return; |
| 465 case CSSPropertyOutlineColor: | 472 case CSSPropertyOutlineColor: |
| 466 style->setOutlineColor(toAnimatableColor(value)->color()); | 473 style->setOutlineColor(toAnimatableColor(value)->color()); |
| 467 style->setVisitedLinkOutlineColor(toAnimatableColor(value)->visitedLinkC
olor()); | 474 style->setVisitedLinkOutlineColor(toAnimatableColor(value)->visitedLinkC
olor()); |
| 468 return; | 475 return; |
| 469 case CSSPropertyOutlineOffset: | 476 case CSSPropertyOutlineOffset: |
| 470 style->setOutlineOffset(animatableValueClampTo<int>(value)); | 477 style->setOutlineOffset(animatableValueClampTo<int>(value)); |
| 471 return; | 478 return; |
| 472 case CSSPropertyOutlineWidth: | 479 case CSSPropertyOutlineWidth: |
| 473 style->setOutlineWidth(animatableValueClampTo<unsigned short>(value)); | 480 style->setOutlineWidth(animatableLineWidthClamp<unsigned short>(value)); |
| 474 return; | 481 return; |
| 475 case CSSPropertyPaddingBottom: | 482 case CSSPropertyPaddingBottom: |
| 476 style->setPaddingBottom(animatableValueToLength(value, state, ValueRange
NonNegative)); | 483 style->setPaddingBottom(animatableValueToLength(value, state, ValueRange
NonNegative)); |
| 477 return; | 484 return; |
| 478 case CSSPropertyPaddingLeft: | 485 case CSSPropertyPaddingLeft: |
| 479 style->setPaddingLeft(animatableValueToLength(value, state, ValueRangeNo
nNegative)); | 486 style->setPaddingLeft(animatableValueToLength(value, state, ValueRangeNo
nNegative)); |
| 480 return; | 487 return; |
| 481 case CSSPropertyPaddingRight: | 488 case CSSPropertyPaddingRight: |
| 482 style->setPaddingRight(animatableValueToLength(value, state, ValueRangeN
onNegative)); | 489 style->setPaddingRight(animatableValueToLength(value, state, ValueRangeN
onNegative)); |
| 483 return; | 490 return; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 style->setColumnGap(clampTo(toAnimatableDouble(value)->toDouble(), 0)); | 551 style->setColumnGap(clampTo(toAnimatableDouble(value)->toDouble(), 0)); |
| 545 return; | 552 return; |
| 546 case CSSPropertyWebkitColumnRuleColor: | 553 case CSSPropertyWebkitColumnRuleColor: |
| 547 style->setColumnRuleColor(toAnimatableColor(value)->color()); | 554 style->setColumnRuleColor(toAnimatableColor(value)->color()); |
| 548 style->setVisitedLinkColumnRuleColor(toAnimatableColor(value)->visitedLi
nkColor()); | 555 style->setVisitedLinkColumnRuleColor(toAnimatableColor(value)->visitedLi
nkColor()); |
| 549 return; | 556 return; |
| 550 case CSSPropertyWebkitColumnWidth: | 557 case CSSPropertyWebkitColumnWidth: |
| 551 style->setColumnWidth(clampTo(toAnimatableDouble(value)->toDouble(), std
::numeric_limits<float>::epsilon())); | 558 style->setColumnWidth(clampTo(toAnimatableDouble(value)->toDouble(), std
::numeric_limits<float>::epsilon())); |
| 552 return; | 559 return; |
| 553 case CSSPropertyWebkitColumnRuleWidth: | 560 case CSSPropertyWebkitColumnRuleWidth: |
| 554 style->setColumnRuleWidth(clampTo<unsigned short>(toAnimatableDouble(val
ue)->toDouble())); | 561 style->setColumnRuleWidth(animatableLineWidthClamp<unsigned short>(value
)); |
| 555 return; | 562 return; |
| 556 case CSSPropertyWebkitFilter: | 563 case CSSPropertyWebkitFilter: |
| 557 style->setFilter(toAnimatableFilterOperations(value)->operations()); | 564 style->setFilter(toAnimatableFilterOperations(value)->operations()); |
| 558 return; | 565 return; |
| 559 case CSSPropertyBackdropFilter: | 566 case CSSPropertyBackdropFilter: |
| 560 style->setBackdropFilter(toAnimatableFilterOperations(value)->operations
()); | 567 style->setBackdropFilter(toAnimatableFilterOperations(value)->operations
()); |
| 561 return; | 568 return; |
| 562 case CSSPropertyWebkitMaskBoxImageOutset: | 569 case CSSPropertyWebkitMaskBoxImageOutset: |
| 563 style->setMaskBoxImageOutset(animatableValueToBorderImageLengthBox(value
, state)); | 570 style->setMaskBoxImageOutset(animatableValueToBorderImageLengthBox(value
, state)); |
| 564 return; | 571 return; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 case CSSPropertyRy: | 701 case CSSPropertyRy: |
| 695 style->setRy(animatableValueToLength(value, state, ValueRangeNonNegative
)); | 702 style->setRy(animatableValueToLength(value, state, ValueRangeNonNegative
)); |
| 696 return; | 703 return; |
| 697 | 704 |
| 698 default: | 705 default: |
| 699 ASSERT_NOT_REACHED(); | 706 ASSERT_NOT_REACHED(); |
| 700 } | 707 } |
| 701 } | 708 } |
| 702 | 709 |
| 703 } // namespace blink | 710 } // namespace blink |
| OLD | NEW |