Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/resolver/AnimatedStyleBuilder.cpp |
| diff --git a/third_party/WebKit/Source/core/css/resolver/AnimatedStyleBuilder.cpp b/third_party/WebKit/Source/core/css/resolver/AnimatedStyleBuilder.cpp |
| index c2b859e203f5d391d5d9b7224d54be87a9ddcc32..a44cfb7fbaae93d399d4eccf7ba81aa1075bff5c 100644 |
| --- a/third_party/WebKit/Source/core/css/resolver/AnimatedStyleBuilder.cpp |
| +++ b/third_party/WebKit/Source/core/css/resolver/AnimatedStyleBuilder.cpp |
| @@ -102,24 +102,28 @@ BorderImageLength animatableValueToBorderImageLength( |
| return Length(Auto); |
| } |
| +double animatableValueToPixels(const AnimatableValue* value, |
| + const StyleResolverState& state) { |
| + return toAnimatableLength(value) |
| + ->getLength(state.style()->effectiveZoom(), ValueRangeAll) |
| + .pixels(); |
| +} |
| + |
| template <typename T> |
| -T animatableValueClampTo(const AnimatableValue* value, |
| - T min = defaultMinimumForClamp<T>(), |
| - T max = defaultMaximumForClamp<T>()) { |
| +T roundedClampTo(double value, |
|
suzyh_UTC10 (ex-contributor)
2016/12/12 04:30:13
Is there any chance that the changes to function n
alancutter (OOO until 2018)
2016/12/13 02:36:34
Done.
|
| + T min = defaultMinimumForClamp<T>(), |
| + T max = defaultMaximumForClamp<T>()) { |
| static_assert(std::is_integral<T>::value, |
| "should use integral type T when rounding values"); |
| - return clampTo<T>( |
| - roundForImpreciseConversion<T>(toAnimatableDouble(value)->toDouble()), |
| - min, max); |
| + return clampTo<T>(roundForImpreciseConversion<T>(value), min, max); |
| } |
| template <typename T> |
| -T animatableLineWidthClamp(const AnimatableValue* value) { |
| - double doubleValue = toAnimatableDouble(value)->toDouble(); |
| +T animatableLineWidthClamp(const AnimatableValue* value, |
| + const StyleResolverState& state) { |
| + double lineWidth = animatableValueToPixels(value, state); |
| // This matches StyleBuilderConverter::convertLineWidth(). |
| - return (doubleValue > 0 && doubleValue < 1) |
| - ? 1 |
| - : animatableValueClampTo<T>(value); |
| + return (lineWidth > 0 && lineWidth < 1) ? 1 : roundedClampTo<T>(lineWidth); |
| } |
| LengthBox animatableValueToLengthBox(const AnimatableValue* value, |
| @@ -163,8 +167,7 @@ TransformOrigin animatableValueToTransformOrigin( |
| return TransformOrigin( |
| animatableValueToLength(animatableLengthPoint3D->x(), state), |
| animatableValueToLength(animatableLengthPoint3D->y(), state), |
| - clampTo<float>( |
| - toAnimatableDouble(animatableLengthPoint3D->z())->toDouble())); |
| + animatableValueToPixels(animatableLengthPoint3D->z(), state)); |
| } |
| LengthSize animatableValueToLengthSize(const AnimatableValue* value, |
| @@ -352,7 +355,8 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, |
| animatableValueToLengthSize(value, state, ValueRangeNonNegative)); |
| return; |
| case CSSPropertyBorderBottomWidth: |
| - style->setBorderBottomWidth(animatableLineWidthClamp<unsigned>(value)); |
| + style->setBorderBottomWidth( |
| + animatableLineWidthClamp<unsigned>(value, state)); |
| return; |
| case CSSPropertyBorderImageOutset: |
| style->setBorderImageOutset( |
| @@ -379,7 +383,8 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, |
| toAnimatableColor(value)->visitedLinkColor()); |
| return; |
| case CSSPropertyBorderLeftWidth: |
| - style->setBorderLeftWidth(animatableLineWidthClamp<unsigned>(value)); |
| + style->setBorderLeftWidth( |
| + animatableLineWidthClamp<unsigned>(value, state)); |
| return; |
| case CSSPropertyBorderRightColor: |
| style->setBorderRightColor(toAnimatableColor(value)->getColor()); |
| @@ -387,7 +392,8 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, |
| toAnimatableColor(value)->visitedLinkColor()); |
| return; |
| case CSSPropertyBorderRightWidth: |
| - style->setBorderRightWidth(animatableLineWidthClamp<unsigned>(value)); |
| + style->setBorderRightWidth( |
| + animatableLineWidthClamp<unsigned>(value, state)); |
| return; |
| case CSSPropertyBorderTopColor: |
| style->setBorderTopColor(toAnimatableColor(value)->getColor()); |
| @@ -403,7 +409,8 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, |
| animatableValueToLengthSize(value, state, ValueRangeNonNegative)); |
| return; |
| case CSSPropertyBorderTopWidth: |
| - style->setBorderTopWidth(animatableLineWidthClamp<unsigned>(value)); |
| + style->setBorderTopWidth( |
| + animatableLineWidthClamp<unsigned>(value, state)); |
| return; |
| case CSSPropertyBottom: |
| style->setBottom(animatableValueToLength(value, state)); |
| @@ -488,7 +495,7 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, |
| return; |
| case CSSPropertyLetterSpacing: |
| style->setLetterSpacing( |
| - clampTo<float>(toAnimatableDouble(value)->toDouble())); |
| + clampTo<float>(animatableValueToPixels(value, state))); |
| return; |
| case CSSPropertyMarginBottom: |
| style->setMarginBottom(animatableValueToLength(value, state)); |
| @@ -536,10 +543,12 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, |
| toAnimatableColor(value)->visitedLinkColor()); |
| return; |
| case CSSPropertyOutlineOffset: |
| - style->setOutlineOffset(animatableValueClampTo<int>(value)); |
| + style->setOutlineOffset( |
| + roundedClampTo<int>(animatableValueToPixels(value, state))); |
| return; |
| case CSSPropertyOutlineWidth: |
| - style->setOutlineWidth(animatableLineWidthClamp<unsigned short>(value)); |
| + style->setOutlineWidth( |
| + animatableLineWidthClamp<unsigned short>(value, state)); |
| return; |
| case CSSPropertyPaddingBottom: |
| style->setPaddingBottom( |
| @@ -612,12 +621,12 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, |
| style->setTop(animatableValueToLength(value, state)); |
| return; |
| case CSSPropertyWebkitBorderHorizontalSpacing: |
| - style->setHorizontalBorderSpacing( |
| - animatableValueClampTo<unsigned short>(value)); |
| + style->setHorizontalBorderSpacing(roundedClampTo<unsigned short>( |
| + animatableValueToPixels(value, state))); |
| return; |
| case CSSPropertyWebkitBorderVerticalSpacing: |
| - style->setVerticalBorderSpacing( |
| - animatableValueClampTo<unsigned short>(value)); |
| + style->setVerticalBorderSpacing(roundedClampTo<unsigned short>( |
| + animatableValueToPixels(value, state))); |
| return; |
| case CSSPropertyClipPath: |
| style->setClipPath( |
| @@ -628,7 +637,7 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, |
| round(toAnimatableDouble(value)->toDouble()), 1)); |
| return; |
| case CSSPropertyColumnGap: |
| - style->setColumnGap(clampTo(toAnimatableDouble(value)->toDouble(), 0)); |
| + style->setColumnGap(clampTo(animatableValueToPixels(value, state), 0)); |
| return; |
| case CSSPropertyColumnRuleColor: |
| style->setColumnRuleColor(toAnimatableColor(value)->getColor()); |
| @@ -636,12 +645,12 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, |
| toAnimatableColor(value)->visitedLinkColor()); |
| return; |
| case CSSPropertyColumnWidth: |
| - style->setColumnWidth(clampTo(toAnimatableDouble(value)->toDouble(), |
| + style->setColumnWidth(clampTo(animatableValueToPixels(value, state), |
| std::numeric_limits<float>::epsilon())); |
| return; |
| case CSSPropertyColumnRuleWidth: |
| style->setColumnRuleWidth( |
| - animatableLineWidthClamp<unsigned short>(value)); |
| + animatableLineWidthClamp<unsigned short>(value, state)); |
| return; |
| case CSSPropertyFilter: |
| style->setFilter(toAnimatableFilterOperations(value)->operations()); |
| @@ -687,8 +696,8 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, |
| return; |
| case CSSPropertyPerspective: |
| style->setPerspective( |
| - value->isDouble() |
| - ? clampTo<float>(toAnimatableDouble(value)->toDouble()) |
| + value->isLength() |
| + ? clampTo<float>(animatableValueToPixels(value, state)) |
| : 0); |
| return; |
| case CSSPropertyPerspectiveOrigin: |
| @@ -782,7 +791,7 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, |
| style->setTransformOriginY(animatableValueToLength(value, state)); |
| return; |
| case CSSPropertyWebkitTransformOriginZ: |
| - style->setTransformOriginZ(toAnimatableDouble(value)->toDouble()); |
| + style->setTransformOriginZ(animatableValueToPixels(value, state)); |
| return; |
| case CSSPropertyWidows: |
| style->setWidows( |
| @@ -794,7 +803,7 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, |
| return; |
| case CSSPropertyWordSpacing: |
| style->setWordSpacing( |
| - clampTo<float>(toAnimatableDouble(value)->toDouble())); |
| + clampTo<float>(animatableValueToPixels(value, state))); |
| return; |
| case CSSPropertyVerticalAlign: |
| style->setVerticalAlignLength(animatableValueToLength(value, state)); |