Commit b088955b authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Add SVGElement::Set/ClearAnimatedMotionTransform

Analog to Set/ClearAnimatedAttribute which removes the knowledge of
shadow trees/instances from SVGAnimateMotionElement.

Bug: 1017723
Change-Id: I28f15ef341b014a6406d4c5e0ae94868c663410a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2529115Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#826192}
parent 974eadac
......@@ -22,7 +22,6 @@
#include "third_party/blink/renderer/core/svg/svg_animate_motion_element.h"
#include "third_party/blink/renderer/core/dom/element_traversal.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/svg/animation/smil_animation_effect_parameters.h"
#include "third_party/blink/renderer/core/svg/animation/smil_animation_value.h"
#include "third_party/blink/renderer/core/svg/svg_mpath_element.h"
......@@ -164,12 +163,7 @@ SMILAnimationValue SVGAnimateMotionElement::CreateAnimationValue(
void SVGAnimateMotionElement::ClearAnimationValue() {
SVGElement* target_element = targetElement();
DCHECK(target_element);
AffineTransform* transform = target_element->AnimateMotionTransform();
DCHECK(transform);
transform->MakeIdentity();
if (LayoutObject* target_layout_object = target_element->GetLayoutObject())
InvalidateForAnimateMotionTransformChange(*target_layout_object);
target_element->ClearAnimatedMotionTransform();
}
bool SVGAnimateMotionElement::CalculateToAtEndOfDurationValue(
......@@ -249,28 +243,9 @@ void SVGAnimateMotionElement::CalculateAnimationValue(
void SVGAnimateMotionElement::ApplyResultsToTarget(
const SMILAnimationValue& animation_value) {
// We accumulate to the target element transform list so there is not much to
// do here.
SVGElement* target_element = targetElement();
DCHECK(target_element);
AffineTransform* target_transform = target_element->AnimateMotionTransform();
DCHECK(target_transform);
*target_transform = animation_value.motion_transform;
if (LayoutObject* target_layout_object = target_element->GetLayoutObject())
InvalidateForAnimateMotionTransformChange(*target_layout_object);
// ...except in case where we have additional instances in <use> trees.
const auto& instances = target_element->InstancesForElement();
for (SVGElement* shadow_tree_element : instances) {
DCHECK(shadow_tree_element);
AffineTransform* shadow_transform =
shadow_tree_element->AnimateMotionTransform();
DCHECK(shadow_transform);
shadow_transform->SetTransform(*target_transform);
if (LayoutObject* layout_object = shadow_tree_element->GetLayoutObject())
InvalidateForAnimateMotionTransformChange(*layout_object);
}
target_element->SetAnimatedMotionTransform(animation_value.motion_transform);
}
float SVGAnimateMotionElement::CalculateDistance(const String& from_string,
......@@ -292,12 +267,4 @@ void SVGAnimateMotionElement::UpdateAnimationMode() {
SVGAnimationElement::UpdateAnimationMode();
}
void SVGAnimateMotionElement::InvalidateForAnimateMotionTransformChange(
LayoutObject& object) {
object.SetNeedsTransformUpdate();
// The transform paint property relies on the SVG transform value.
object.SetNeedsPaintPropertyUpdate();
MarkForLayoutAndParentResourceInvalidation(object);
}
} // namespace blink
......@@ -63,8 +63,6 @@ class SVGAnimateMotionElement final : public SVGAnimationElement {
void UpdateAnimationMode() override;
void InvalidateForAnimateMotionTransformChange(LayoutObject& target);
// Note: we do not support percentage values for to/from coords as the spec
// implies we should (opera doesn't either)
FloatPoint from_point_;
......
......@@ -267,6 +267,25 @@ void SVGElement::ClearAnimatedAttribute(const QualifiedName& attribute) {
});
}
void SVGElement::SetAnimatedMotionTransform(
const AffineTransform& motion_transform) {
ForSelfAndInstances(this, [&motion_transform](SVGElement* element) {
AffineTransform* transform = element->AnimateMotionTransform();
DCHECK(transform);
*transform = motion_transform;
if (LayoutObject* layout_object = element->GetLayoutObject()) {
layout_object->SetNeedsTransformUpdate();
// The transform paint property relies on the SVG transform value.
layout_object->SetNeedsPaintPropertyUpdate();
MarkForLayoutAndParentResourceInvalidation(*layout_object);
}
});
}
void SVGElement::ClearAnimatedMotionTransform() {
SetAnimatedMotionTransform(AffineTransform());
}
bool SVGElement::HasNonCSSPropertyAnimations() const {
if (HasSVGRareData() && !SvgRareData()->WebAnimatedAttributes().IsEmpty())
return true;
......
......@@ -106,6 +106,8 @@ class CORE_EXPORT SVGElement : public Element {
void SetAnimatedAttribute(const QualifiedName&, SVGPropertyBase*);
void ClearAnimatedAttribute(const QualifiedName&);
void SetAnimatedMotionTransform(const AffineTransform&);
void ClearAnimatedMotionTransform();
bool HasNonCSSPropertyAnimations() const;
......
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