Commit 024cfdf6 authored by Stephen McGruer's avatar Stephen McGruer Committed by Commit Bot

Inline CompareOffsets and disallow null offsets

As pointed out by jbroman@ during a review, null offsets will violate
the requirements of std::sort. Luckily CompareOffsets is only ever used
where offsets will be non-null, so enforce that in the code. Also since
it is used exactly once, just inline it.

Bug: 791086
Change-Id: I9df7f1201fdc3024a727c62bfd7e917791de12b6
Reviewed-on: https://chromium-review.googlesource.com/905100
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534804}
parent 08ddbcb0
......@@ -35,11 +35,4 @@ void Keyframe::AddKeyframePropertiesToV8Object(
}
}
bool Keyframe::CompareOffsets(const scoped_refptr<Keyframe>& a,
const scoped_refptr<Keyframe>& b) {
if (!a->Offset() || !b->Offset())
return false;
return a->CheckedOffset() < b->CheckedOffset();
}
} // namespace blink
......@@ -186,10 +186,6 @@ class CORE_EXPORT Keyframe : public RefCounted<Keyframe> {
EffectModel::CompositeOperation effect_composite,
double offset) const = 0;
// Comparator function for sorting Keyframes based on their offsets.
static bool CompareOffsets(const scoped_refptr<Keyframe>&,
const scoped_refptr<Keyframe>&);
protected:
Keyframe()
: offset_(), composite_(), easing_(LinearTimingFunction::Shared()) {}
......
......@@ -148,8 +148,11 @@ StringKeyframeEffectModel* CreateKeyframeEffectModel(
}
// Merge duplicate keyframes.
std::stable_sort(keyframes.begin(), keyframes.end(),
Keyframe::CompareOffsets);
std::stable_sort(
keyframes.begin(), keyframes.end(),
[](const scoped_refptr<Keyframe>& a, const scoped_refptr<Keyframe>& b) {
return a->CheckedOffset() < b->CheckedOffset();
});
size_t target_index = 0;
for (size_t i = 1; i < keyframes.size(); i++) {
if (keyframes[i]->CheckedOffset() ==
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment