| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 122 } |
| 123 | 123 |
| 124 template <typename T> | 124 template <typename T> |
| 125 T animatableLineWidthClamp(const AnimatableValue* value, | 125 T animatableLineWidthClamp(const AnimatableValue* value, |
| 126 const StyleResolverState& state) { | 126 const StyleResolverState& state) { |
| 127 double lineWidth = animatableValueToPixels(value, state); | 127 double lineWidth = animatableValueToPixels(value, state); |
| 128 // This matches StyleBuilderConverter::convertLineWidth(). | 128 // This matches StyleBuilderConverter::convertLineWidth(). |
| 129 return (lineWidth > 0 && lineWidth < 1) ? 1 : roundedClampTo<T>(lineWidth); | 129 return (lineWidth > 0 && lineWidth < 1) ? 1 : roundedClampTo<T>(lineWidth); |
| 130 } | 130 } |
| 131 | 131 |
| 132 float animatableLineWidth(const AnimatableValue* value, |
| 133 const StyleResolverState& state) { |
| 134 double lineWidth = |
| 135 toAnimatableLength(value) |
| 136 ->getLength(state.style()->effectiveZoom(), ValueRangeNonNegative) |
| 137 .pixels(); |
| 138 // This matches StyleBuilderConverter::convertLineWidth(). |
| 139 return (lineWidth > 0 && lineWidth < 1) ? 1 : lineWidth; |
| 140 } |
| 141 |
| 132 LengthBox animatableValueToLengthBox(const AnimatableValue* value, | 142 LengthBox animatableValueToLengthBox(const AnimatableValue* value, |
| 133 const StyleResolverState& state, | 143 const StyleResolverState& state, |
| 134 ValueRange range = ValueRangeAll) { | 144 ValueRange range = ValueRangeAll) { |
| 135 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value); | 145 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value); |
| 136 return LengthBox( | 146 return LengthBox( |
| 137 animatableValueToLength(animatableLengthBox->top(), state, range), | 147 animatableValueToLength(animatableLengthBox->top(), state, range), |
| 138 animatableValueToLength(animatableLengthBox->right(), state, range), | 148 animatableValueToLength(animatableLengthBox->right(), state, range), |
| 139 animatableValueToLength(animatableLengthBox->bottom(), state, range), | 149 animatableValueToLength(animatableLengthBox->bottom(), state, range), |
| 140 animatableValueToLength(animatableLengthBox->left(), state, range)); | 150 animatableValueToLength(animatableLengthBox->left(), state, range)); |
| 141 } | 151 } |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 return; | 363 return; |
| 354 case CSSPropertyBorderBottomLeftRadius: | 364 case CSSPropertyBorderBottomLeftRadius: |
| 355 style->setBorderBottomLeftRadius( | 365 style->setBorderBottomLeftRadius( |
| 356 animatableValueToLengthSize(value, state, ValueRangeNonNegative)); | 366 animatableValueToLengthSize(value, state, ValueRangeNonNegative)); |
| 357 return; | 367 return; |
| 358 case CSSPropertyBorderBottomRightRadius: | 368 case CSSPropertyBorderBottomRightRadius: |
| 359 style->setBorderBottomRightRadius( | 369 style->setBorderBottomRightRadius( |
| 360 animatableValueToLengthSize(value, state, ValueRangeNonNegative)); | 370 animatableValueToLengthSize(value, state, ValueRangeNonNegative)); |
| 361 return; | 371 return; |
| 362 case CSSPropertyBorderBottomWidth: | 372 case CSSPropertyBorderBottomWidth: |
| 363 style->setBorderBottomWidth( | 373 style->setBorderBottomWidth(animatableLineWidth(value, state)); |
| 364 animatableLineWidthClamp<unsigned>(value, state)); | |
| 365 return; | 374 return; |
| 366 case CSSPropertyBorderImageOutset: | 375 case CSSPropertyBorderImageOutset: |
| 367 style->setBorderImageOutset( | 376 style->setBorderImageOutset( |
| 368 animatableValueToBorderImageLengthBox(value, state)); | 377 animatableValueToBorderImageLengthBox(value, state)); |
| 369 return; | 378 return; |
| 370 case CSSPropertyBorderImageSlice: | 379 case CSSPropertyBorderImageSlice: |
| 371 style->setBorderImageSlices( | 380 style->setBorderImageSlices( |
| 372 animatableValueToLengthBox(toAnimatableLengthBoxAndBool(value)->box(), | 381 animatableValueToLengthBox(toAnimatableLengthBoxAndBool(value)->box(), |
| 373 state, ValueRangeNonNegative)); | 382 state, ValueRangeNonNegative)); |
| 374 style->setBorderImageSlicesFill( | 383 style->setBorderImageSlicesFill( |
| 375 toAnimatableLengthBoxAndBool(value)->flag()); | 384 toAnimatableLengthBoxAndBool(value)->flag()); |
| 376 return; | 385 return; |
| 377 case CSSPropertyBorderImageSource: | 386 case CSSPropertyBorderImageSource: |
| 378 style->setBorderImageSource( | 387 style->setBorderImageSource( |
| 379 state.styleImage(property, *toAnimatableImage(value)->toCSSValue())); | 388 state.styleImage(property, *toAnimatableImage(value)->toCSSValue())); |
| 380 return; | 389 return; |
| 381 case CSSPropertyBorderImageWidth: | 390 case CSSPropertyBorderImageWidth: |
| 382 style->setBorderImageWidth( | 391 style->setBorderImageWidth( |
| 383 animatableValueToBorderImageLengthBox(value, state)); | 392 animatableValueToBorderImageLengthBox(value, state)); |
| 384 return; | 393 return; |
| 385 case CSSPropertyBorderLeftColor: | 394 case CSSPropertyBorderLeftColor: |
| 386 style->setBorderLeftColor(toAnimatableColor(value)->getColor()); | 395 style->setBorderLeftColor(toAnimatableColor(value)->getColor()); |
| 387 style->setVisitedLinkBorderLeftColor( | 396 style->setVisitedLinkBorderLeftColor( |
| 388 toAnimatableColor(value)->visitedLinkColor()); | 397 toAnimatableColor(value)->visitedLinkColor()); |
| 389 return; | 398 return; |
| 390 case CSSPropertyBorderLeftWidth: | 399 case CSSPropertyBorderLeftWidth: |
| 391 style->setBorderLeftWidth( | 400 style->setBorderLeftWidth(animatableLineWidth(value, state)); |
| 392 animatableLineWidthClamp<unsigned>(value, state)); | |
| 393 return; | 401 return; |
| 394 case CSSPropertyBorderRightColor: | 402 case CSSPropertyBorderRightColor: |
| 395 style->setBorderRightColor(toAnimatableColor(value)->getColor()); | 403 style->setBorderRightColor(toAnimatableColor(value)->getColor()); |
| 396 style->setVisitedLinkBorderRightColor( | 404 style->setVisitedLinkBorderRightColor( |
| 397 toAnimatableColor(value)->visitedLinkColor()); | 405 toAnimatableColor(value)->visitedLinkColor()); |
| 398 return; | 406 return; |
| 399 case CSSPropertyBorderRightWidth: | 407 case CSSPropertyBorderRightWidth: |
| 400 style->setBorderRightWidth( | 408 style->setBorderRightWidth(animatableLineWidth(value, state)); |
| 401 animatableLineWidthClamp<unsigned>(value, state)); | |
| 402 return; | 409 return; |
| 403 case CSSPropertyBorderTopColor: | 410 case CSSPropertyBorderTopColor: |
| 404 style->setBorderTopColor(toAnimatableColor(value)->getColor()); | 411 style->setBorderTopColor(toAnimatableColor(value)->getColor()); |
| 405 style->setVisitedLinkBorderTopColor( | 412 style->setVisitedLinkBorderTopColor( |
| 406 toAnimatableColor(value)->visitedLinkColor()); | 413 toAnimatableColor(value)->visitedLinkColor()); |
| 407 return; | 414 return; |
| 408 case CSSPropertyBorderTopLeftRadius: | 415 case CSSPropertyBorderTopLeftRadius: |
| 409 style->setBorderTopLeftRadius( | 416 style->setBorderTopLeftRadius( |
| 410 animatableValueToLengthSize(value, state, ValueRangeNonNegative)); | 417 animatableValueToLengthSize(value, state, ValueRangeNonNegative)); |
| 411 return; | 418 return; |
| 412 case CSSPropertyBorderTopRightRadius: | 419 case CSSPropertyBorderTopRightRadius: |
| 413 style->setBorderTopRightRadius( | 420 style->setBorderTopRightRadius( |
| 414 animatableValueToLengthSize(value, state, ValueRangeNonNegative)); | 421 animatableValueToLengthSize(value, state, ValueRangeNonNegative)); |
| 415 return; | 422 return; |
| 416 case CSSPropertyBorderTopWidth: | 423 case CSSPropertyBorderTopWidth: |
| 417 style->setBorderTopWidth( | 424 style->setBorderTopWidth(animatableLineWidth(value, state)); |
| 418 animatableLineWidthClamp<unsigned>(value, state)); | |
| 419 return; | 425 return; |
| 420 case CSSPropertyBottom: | 426 case CSSPropertyBottom: |
| 421 style->setBottom(animatableValueToLength(value, state)); | 427 style->setBottom(animatableValueToLength(value, state)); |
| 422 return; | 428 return; |
| 423 case CSSPropertyBoxShadow: | 429 case CSSPropertyBoxShadow: |
| 424 style->setBoxShadow(toAnimatableShadow(value)->getShadowList()); | 430 style->setBoxShadow(toAnimatableShadow(value)->getShadowList()); |
| 425 return; | 431 return; |
| 426 case CSSPropertyCaretColor: | 432 case CSSPropertyCaretColor: |
| 427 style->setCaretColor(toAnimatableColor(value)->getColor()); | 433 style->setCaretColor(toAnimatableColor(value)->getColor()); |
| 428 style->setVisitedLinkCaretColor( | 434 style->setVisitedLinkCaretColor( |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 style->setRy( | 857 style->setRy( |
| 852 animatableValueToLength(value, state, ValueRangeNonNegative)); | 858 animatableValueToLength(value, state, ValueRangeNonNegative)); |
| 853 return; | 859 return; |
| 854 | 860 |
| 855 default: | 861 default: |
| 856 ASSERT_NOT_REACHED(); | 862 ASSERT_NOT_REACHED(); |
| 857 } | 863 } |
| 858 } | 864 } |
| 859 | 865 |
| 860 } // namespace blink | 866 } // namespace blink |
| OLD | NEW |