⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 284725 in webkit


Ignore:
Timestamp:
Oct 22, 2021, 4:21:57 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Integer interpolation in animations should be rounded towards positive infinity, not away from zero.
https://bugs.webkit.org/show_bug.cgi?id=232013

Currently, interpolation of <integer> is rounding away from 0.
The interpolation's result should be rounded according to the spec,
https://drafts.csswg.org/css-values-4/#combine-integers, which is

"the result is converted to an <integer> by rounding
to the nearest integer, with values halfway between
adjacent integers rounded towards positive infinity."

LayoutTests/imported/w3c:

Patch by Joonghun Park <pjh0718@gmail.com> on 2021-10-22
Reviewed by Darin Adler.

  • web-platform-tests/css/css-values/integer_interpolation_round_half_towards_positive_infinity_order-expected.txt: Added.
  • web-platform-tests/css/css-values/integer_interpolation_round_half_towards_positive_infinity_order.html: Added.
  • web-platform-tests/css/css-values/integer_interpolation_round_half_towards_positive_infinity_z_index-expected.txt: Added.
  • web-platform-tests/css/css-values/integer_interpolation_round_half_towards_positive_infinity_z_index.html: Added.

Source/WebCore:

This patch also removes redundant static_cast<double>s
and potential overflow(e.g.'to' is the maximum integer and 'from' is
the minimum integer) from blend in AnimationUtilities.h.

Patch by Joonghun Park <pjh0718@gmail.com> on 2021-10-22
Reviewed by Darin Adler.

Tests: animations/animation-order-overflow.html

animations/animation-z-order-overflow.html
imported/w3c/web-platform-tests/css/css-values/integer_interpolation_round_half_towards_positive_infinity_order.html
imported/w3c/web-platform-tests/css/css-values/integer_interpolation_round_half_towards_positive_infinity_z_index.html

  • platform/animation/AnimationUtilities.h:

(WebCore::blend):

Source/WTF:

Patch by Joonghun Park <pjh0718@gmail.com> on 2021-10-22
Reviewed by Darin Adler.

  • wtf/MathExtras.h:

(roundTowardsPositiveInfinity):

LayoutTests:

This patch also removes redundant static_cast<double>s
and potential overflow(e.g.'to' is the maximum integer and 'from' is
the minimum integer) from blend in AnimationUtilities.h.

Patch by Joonghun Park <pjh0718@gmail.com> on 2021-10-22
Reviewed by Darin Adler.

  • animations/animation-order-overflow-expected.txt: Added.
  • animations/animation-order-overflow.html: Added.
  • animations/animation-z-order-overflow-expected.txt: Added.
  • animations/animation-z-order-overflow.html: Added.
Location:
trunk
Files:
8 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r284724 r284725  
     12021-10-22  Joonghun Park  <pjh0718@gmail.com>
     2
     3        Integer interpolation in animations should be rounded towards positive infinity, not away from zero.
     4        https://bugs.webkit.org/show_bug.cgi?id=232013
     5
     6        Currently, interpolation of <integer> is rounding away from 0.
     7        The interpolation's result should be rounded according to the spec,
     8        https://drafts.csswg.org/css-values-4/#combine-integers, which is
     9
     10        "the result is converted to an <integer> by rounding
     11        to the nearest integer, with values halfway between
     12        adjacent integers rounded towards positive infinity."
     13
     14        This patch also removes redundant static_cast<double>s
     15        and potential overflow(e.g.'to' is the maximum integer and 'from' is
     16        the minimum integer) from blend in AnimationUtilities.h.
     17
     18        Reviewed by Darin Adler.
     19
     20        * animations/animation-order-overflow-expected.txt: Added.
     21        * animations/animation-order-overflow.html: Added.
     22        * animations/animation-z-order-overflow-expected.txt: Added.
     23        * animations/animation-z-order-overflow.html: Added.
     24
    1252021-10-22  Chris Dumez  <cdumez@apple.com>
    226
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r284724 r284725  
     12021-10-22  Joonghun Park  <pjh0718@gmail.com>
     2
     3        Integer interpolation in animations should be rounded towards positive infinity, not away from zero.
     4        https://bugs.webkit.org/show_bug.cgi?id=232013
     5
     6        Currently, interpolation of <integer> is rounding away from 0.
     7        The interpolation's result should be rounded according to the spec,
     8        https://drafts.csswg.org/css-values-4/#combine-integers, which is
     9
     10        "the result is converted to an <integer> by rounding
     11        to the nearest integer, with values halfway between
     12        adjacent integers rounded towards positive infinity."
     13
     14        Reviewed by Darin Adler.
     15
     16        * web-platform-tests/css/css-values/integer_interpolation_round_half_towards_positive_infinity_order-expected.txt: Added.
     17        * web-platform-tests/css/css-values/integer_interpolation_round_half_towards_positive_infinity_order.html: Added.
     18        * web-platform-tests/css/css-values/integer_interpolation_round_half_towards_positive_infinity_z_index-expected.txt: Added.
     19        * web-platform-tests/css/css-values/integer_interpolation_round_half_towards_positive_infinity_z_index.html: Added.
     20
    1212021-10-22  Chris Dumez  <cdumez@apple.com>
    222
  • trunk/Source/WTF/ChangeLog

    r284673 r284725  
     12021-10-22  Joonghun Park  <pjh0718@gmail.com>
     2
     3        Integer interpolation in animations should be rounded towards positive infinity, not away from zero.
     4        https://bugs.webkit.org/show_bug.cgi?id=232013
     5
     6        Currently, interpolation of <integer> is rounding away from 0.
     7        The interpolation's result should be rounded according to the spec,
     8        https://drafts.csswg.org/css-values-4/#combine-integers, which is
     9
     10        "the result is converted to an <integer> by rounding
     11        to the nearest integer, with values halfway between
     12        adjacent integers rounded towards positive infinity."
     13
     14        Reviewed by Darin Adler.
     15
     16        * wtf/MathExtras.h:
     17        (roundTowardsPositiveInfinity):
     18
    1192021-10-22  Pablo Correa Gómez  <ablocorrea@hotmail.com>
    220
  • trunk/Source/WTF/wtf/MathExtras.h

    r279193 r284725  
    137137constexpr inline float grad2rad(float g) { return deg2rad(grad2deg(g)); }
    138138
     139inline double roundTowardsPositiveInfinity(double value) { return std::floor(value + 0.5); }
     140inline float roundTowardsPositiveInfinity(float value) { return std::floor(value + 0.5f); }
     141
    139142// std::numeric_limits<T>::min() returns the smallest positive value for floating point types
    140143template<typename T> constexpr T defaultMinimumForClamp() { return std::numeric_limits<T>::min(); }
  • trunk/Source/WebCore/ChangeLog

    r284718 r284725  
     12021-10-22  Joonghun Park  <pjh0718@gmail.com>
     2
     3        Integer interpolation in animations should be rounded towards positive infinity, not away from zero.
     4        https://bugs.webkit.org/show_bug.cgi?id=232013
     5
     6        Currently, interpolation of <integer> is rounding away from 0.
     7        The interpolation's result should be rounded according to the spec,
     8        https://drafts.csswg.org/css-values-4/#combine-integers, which is
     9
     10        "the result is converted to an <integer> by rounding
     11        to the nearest integer, with values halfway between
     12        adjacent integers rounded towards positive infinity."
     13
     14        This patch also removes redundant static_cast<double>s
     15        and potential overflow(e.g.'to' is the maximum integer and 'from' is
     16        the minimum integer) from blend in AnimationUtilities.h.
     17
     18        Reviewed by Darin Adler.
     19
     20        Tests: animations/animation-order-overflow.html
     21               animations/animation-z-order-overflow.html
     22               imported/w3c/web-platform-tests/css/css-values/integer_interpolation_round_half_towards_positive_infinity_order.html
     23               imported/w3c/web-platform-tests/css/css-values/integer_interpolation_round_half_towards_positive_infinity_z_index.html
     24
     25        * platform/animation/AnimationUtilities.h:
     26        (WebCore::blend):
     27
    1282021-10-22  Kiet Ho  <tho22@apple.com>
    229
  • trunk/Source/WebCore/platform/animation/AnimationUtilities.h

    r284600 r284725  
    4646
    4747inline int blend(int from, int to, const BlendingContext& context)
    48 { 
    49     return static_cast<int>(lround(static_cast<double>(from) + static_cast<double>(to - from) * context.progress));
     48{
     49    return static_cast<int>(roundTowardsPositiveInfinity(from + (static_cast<double>(to) - from) * context.progress));
    5050}
    5151
    5252inline unsigned blend(unsigned from, unsigned to, const BlendingContext& context)
    5353{
    54     return static_cast<unsigned>(lround(to > from ? static_cast<double>(from) + static_cast<double>(to - from) * context.progress : static_cast<double>(from) - static_cast<double>(from - to) * context.progress));
     54    return static_cast<unsigned>(lround(to > from ? from + (static_cast<double>(to) - from) * context.progress : from - (static_cast<double>(from) - to) * context.progress));
    5555}
    5656
Note: See TracChangeset for help on using the changeset viewer.