Commit ee784aad authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Make PriorityCompare a SMILAnimationSandwich detail

The ordering required in SMILTimeContainer::ApplyAnimationValues isn't
really the full-blown ordering used for sandwiches - using only the
"document order index" should be sufficient (although arguably still not
correct).

Bug: 998526
Change-Id: I293b9e55824c2b683b5991e7da3266958eb94e67
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1840991Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#703073}
parent f49a863d
...@@ -31,6 +31,25 @@ ...@@ -31,6 +31,25 @@
namespace blink { namespace blink {
namespace {
struct PriorityCompare {
PriorityCompare(SMILTime elapsed) : elapsed_(elapsed) {}
bool operator()(const Member<SVGSMILElement>& a,
const Member<SVGSMILElement>& b) {
// FIXME: This should also consider possible timing relations between the
// elements.
SMILTime a_begin = a->BeginTimeForPrioritization(elapsed_);
SMILTime b_begin = b->BeginTimeForPrioritization(elapsed_);
if (a_begin == b_begin)
return a->DocumentOrderIndex() < b->DocumentOrderIndex();
return a_begin < b_begin;
}
SMILTime elapsed_;
};
} // namespace
SMILAnimationSandwich::SMILAnimationSandwich() = default; SMILAnimationSandwich::SMILAnimationSandwich() = default;
void SMILAnimationSandwich::Schedule(SVGSMILElement* animation) { void SMILAnimationSandwich::Schedule(SVGSMILElement* animation) {
......
...@@ -33,21 +33,6 @@ ...@@ -33,21 +33,6 @@
namespace blink { namespace blink {
struct PriorityCompare {
PriorityCompare(SMILTime elapsed) : elapsed_(elapsed) {}
bool operator()(const Member<SVGSMILElement>& a,
const Member<SVGSMILElement>& b) {
// FIXME: This should also consider possible timing relations between the
// elements.
SMILTime a_begin = a->BeginTimeForPrioritization(elapsed_);
SMILTime b_begin = b->BeginTimeForPrioritization(elapsed_);
if (a_begin == b_begin)
return a->DocumentOrderIndex() < b->DocumentOrderIndex();
return a_begin < b_begin;
}
SMILTime elapsed_;
};
// This class implements/helps with implementing the "sandwich model" from SMIL. // This class implements/helps with implementing the "sandwich model" from SMIL.
// https://www.w3.org/TR/SMIL3/smil-animation.html#animationNS-AnimationSandwichModel // https://www.w3.org/TR/SMIL3/smil-animation.html#animationNS-AnimationSandwichModel
// //
......
...@@ -524,8 +524,13 @@ void SMILTimeContainer::ApplyAnimationValues(SMILTime elapsed) { ...@@ -524,8 +524,13 @@ void SMILTimeContainer::ApplyAnimationValues(SMILTime elapsed) {
// Everything bellow handles "discard" elements. // Everything bellow handles "discard" elements.
UseCounter::Count(&GetDocument(), WebFeature::kSVGSMILAnimationAppliedEffect); UseCounter::Count(&GetDocument(), WebFeature::kSVGSMILAnimationAppliedEffect);
std::sort(animations_to_apply.begin(), animations_to_apply.end(), // Sort by location in the document. (Should be based on the target rather
PriorityCompare(elapsed)); // than the timed element, but often enough they will order the same.)
std::sort(
animations_to_apply.begin(), animations_to_apply.end(),
[](const Member<SVGSMILElement>& a, const Member<SVGSMILElement>& b) {
return a->DocumentOrderIndex() < b->DocumentOrderIndex();
});
for (const auto& timed_element : animations_to_apply) { for (const auto& timed_element : animations_to_apply) {
if (timed_element->isConnected() && timed_element->IsSVGDiscardElement()) { if (timed_element->isConnected() && timed_element->IsSVGDiscardElement()) {
......
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