Changeset 259630 in webkit


Ignore:
Timestamp:
Apr 7, 2020 1:25:59 AM (4 years ago)
Author:
Doug Kelly
Message:

Add release asserts to KeyframeEffectStack::ensureEffectsAreSorted()
https://bugs.webkit.org/show_bug.cgi?id=210084
<rdar://problem/61359275>

Reviewed by Ryosuke Niwa.

To ensure any potential problems in KeyframeEffectStack::ensureEffectsAreSorted() are found closer to the
root cause, add several RELEASE_ASSERTs throughout this function (and its associated comparison function).
This should guard against null pointers/null WeakPtrs, as well as other state problems which would be
unexpected for the comparison function used by std::sort.

No new tests; this only adds additional asserts, so there is no change to functionality, and this code is
covered by existing tests.

  • animation/KeyframeEffectStack.cpp:

(WebCore::KeyframeEffectStack::ensureEffectsAreSorted):

  • animation/WebAnimationUtilities.cpp:

(WebCore::compareAnimationsByCompositeOrder):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r259629 r259630  
     12020-04-07  Doug Kelly  <dougk@apple.com>
     2
     3        Add release asserts to KeyframeEffectStack::ensureEffectsAreSorted()
     4        https://bugs.webkit.org/show_bug.cgi?id=210084
     5        <rdar://problem/61359275>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        To ensure any potential problems in KeyframeEffectStack::ensureEffectsAreSorted() are found closer to the
     10        root cause, add several RELEASE_ASSERTs throughout this function (and its associated comparison function).
     11        This should guard against null pointers/null WeakPtrs, as well as other state problems which would be
     12        unexpected for the comparison function used by std::sort.
     13
     14        No new tests; this only adds additional asserts, so there is no change to functionality, and this code is
     15        covered by existing tests.
     16
     17        * animation/KeyframeEffectStack.cpp:
     18        (WebCore::KeyframeEffectStack::ensureEffectsAreSorted):
     19        * animation/WebAnimationUtilities.cpp:
     20        (WebCore::compareAnimationsByCompositeOrder):
     21
    1222020-04-07  Rob Buis  <rbuis@igalia.com>
    223
  • trunk/Source/WebCore/animation/KeyframeEffectStack.cpp

    r258913 r259630  
    8181
    8282    std::sort(m_effects.begin(), m_effects.end(), [&](auto& lhs, auto& rhs) {
     83        RELEASE_ASSERT(lhs.get());
     84        RELEASE_ASSERT(rhs.get());
     85       
    8386        auto* lhsAnimation = lhs->animation();
    8487        auto* rhsAnimation = rhs->animation();
    8588
    86         ASSERT(lhsAnimation);
    87         ASSERT(rhsAnimation);
     89        RELEASE_ASSERT(lhsAnimation);
     90        RELEASE_ASSERT(rhsAnimation);
    8891
    8992        return compareAnimationsByCompositeOrder(*lhsAnimation, *rhsAnimation, m_cssAnimationList.get());
  • trunk/Source/WebCore/animation/WebAnimationUtilities.cpp

    r259538 r259630  
    8585
    8686        // We should have found either of those CSS animations in the CSS animations list.
    87         ASSERT_NOT_REACHED();
     87        RELEASE_ASSERT_NOT_REACHED();
    8888    }
    8989
    9090    // JS-originated animations sort last based on their position in the global animation list.
    9191    // https://drafts.csswg.org/web-animations-1/#animation-composite-order
     92    RELEASE_ASSERT(lhsAnimation.globalPosition() != rhsAnimation.globalPosition() || &lhsAnimation == &rhsAnimation);
    9293    return lhsAnimation.globalPosition() < rhsAnimation.globalPosition();
    9394}
Note: See TracChangeset for help on using the changeset viewer.