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

Document SVGAnimationElement::CheckAnimationParameters()

And its companion SVGAnimationElement::CalculateValuesAnimation().

Bug: 998526
Change-Id: I3895dc070d319f1cefa489e061a598b18a88cf98
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1871509
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708119}
parent 6357f0f2
......@@ -522,19 +522,27 @@ bool SVGAnimationElement::CalculateValuesAnimation() {
if (values_.IsEmpty())
return false;
CalcMode calc_mode = GetCalcMode();
// For 'values' animations, there should be exactly as many 'keyTimes' as
// 'values'.
if (calc_mode != kCalcModePaced &&
FastHasAttribute(svg_names::kKeyTimesAttr) &&
!FastHasAttribute(svg_names::kKeyPointsAttr) &&
FastHasAttribute(svg_names::kKeyTimesAttr) &&
values_.size() != KeyTimes().size())
return false;
// If 'keyTimes' is specified its last value should be 1 (and the first 0)
// unless 'calcMode' is 'discrete'.
if (calc_mode != kCalcModeDiscrete && !KeyTimes().IsEmpty() &&
KeyTimes().back() != 1)
return false;
// If 'calcMode' is 'spline', there should be one less spline than there are
// 'keyPoints' or 'values'.
if (calc_mode == kCalcModeSpline) {
if ((key_splines_.IsEmpty() || key_splines_.size() != values_.size() - 1) &&
key_splines_.size() != key_points_.size() - 1)
return false;
}
// If 'keyPoints' is specified it should have the same amount of points as
// 'keyTimes', and at least two points.
if (FastHasAttribute(svg_names::kKeyPointsAttr) &&
(KeyTimes().size() < 2 || KeyTimes().size() != key_points_.size()))
return false;
......@@ -554,12 +562,16 @@ bool SVGAnimationElement::CheckAnimationParameters() {
return false;
// These validations are appropriate for all animation modes.
// If 'keyPoints' is specified it should have the same amount of points as
// 'keyTimes'.
if (FastHasAttribute(svg_names::kKeyPointsAttr) &&
KeyTimes().size() != key_points_.size())
return false;
CalcMode calc_mode = GetCalcMode();
if (calc_mode == kCalcModeSpline) {
// If 'calcMode' is 'spline', there should be one less spline than there
// are 'keyTimes' or 'keyPoints' - or 'values' if it is used.
if (key_splines_.IsEmpty() ||
(FastHasAttribute(svg_names::kKeyPointsAttr) &&
key_splines_.size() != key_points_.size() - 1) ||
......@@ -570,13 +582,17 @@ bool SVGAnimationElement::CheckAnimationParameters() {
return false;
}
if ((animation_mode == kFromToAnimation ||
animation_mode == kFromByAnimation || animation_mode == kToAnimation ||
animation_mode == kByAnimation) &&
(FastHasAttribute(svg_names::kKeyTimesAttr) &&
FastHasAttribute(svg_names::kKeyPointsAttr) &&
(KeyTimes().size() < 2 || KeyTimes().size() != key_points_.size())))
return false;
if (animation_mode == kFromToAnimation ||
animation_mode == kFromByAnimation || animation_mode == kToAnimation ||
animation_mode == kByAnimation) {
if (FastHasAttribute(svg_names::kKeyTimesAttr)) {
// If 'keyPoints' is specified it should have the same amount of points
// as 'keyTimes', and at least two points.
if (FastHasAttribute(svg_names::kKeyPointsAttr) &&
(KeyTimes().size() < 2 || KeyTimes().size() != key_points_.size()))
return false;
}
}
const String& from = FromValue();
const String& to = ToValue();
const String& by = ByValue();
......@@ -595,10 +611,14 @@ bool SVGAnimationElement::CheckAnimationParameters() {
if (animation_mode == kValuesAnimation)
return CalculateValuesAnimation();
if (animation_mode == kPathAnimation) {
return calc_mode == kCalcModePaced ||
!(FastHasAttribute(svg_names::kKeyPointsAttr) &&
(KeyTimes().size() < 2 ||
KeyTimes().size() != key_points_.size()));
if (calc_mode == kCalcModePaced)
return true;
// If 'keyPoints' is specified it should have the same amount of points as
// 'keyTimes', and at least two points.
if (FastHasAttribute(svg_names::kKeyPointsAttr) &&
(KeyTimes().size() < 2 || KeyTimes().size() != key_points_.size()))
return false;
return true;
}
return false;
}
......
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