Truly independent web browser
LibWeb: Implement the begin attribute and SVG animation DOM methods
Andreas Klingc70822430b41
diff --git a/Libraries/LibWeb/SVG/AttributeNames.h b/Libraries/LibWeb/SVG/AttributeNames.hindex f26181f2e0a..683254de3f9 100644--- a/Libraries/LibWeb/SVG/AttributeNames.h+++ b/Libraries/LibWeb/SVG/AttributeNames.h@@ -18,6 +18,7 @@ namespace Web::SVG::AttributeNames {__ENUMERATE_SVG_ATTRIBUTE(azimuth, "azimuth") \__ENUMERATE_SVG_ATTRIBUTE(baseFrequency, "baseFrequency") \__ENUMERATE_SVG_ATTRIBUTE(baseProfile, "baseProfile") \+ __ENUMERATE_SVG_ATTRIBUTE(begin, "begin") \__ENUMERATE_SVG_ATTRIBUTE(bias, "bias") \__ENUMERATE_SVG_ATTRIBUTE(calcMode, "calcMode") \__ENUMERATE_SVG_ATTRIBUTE(class_, "class") \@@ -94,6 +95,7 @@ namespace Web::SVG::AttributeNames {__ENUMERATE_SVG_ATTRIBUTE(repeatDur, "repeatDur") \__ENUMERATE_SVG_ATTRIBUTE(requiredExtensions, "requiredExtensions") \__ENUMERATE_SVG_ATTRIBUTE(requiredFeatures, "requiredFeatures") \+ __ENUMERATE_SVG_ATTRIBUTE(restart, "restart") \__ENUMERATE_SVG_ATTRIBUTE(result, "result") \__ENUMERATE_SVG_ATTRIBUTE(rotate, "rotate") \__ENUMERATE_SVG_ATTRIBUTE(rx, "rx") \diff --git a/Libraries/LibWeb/SVG/SMILAnimation.cpp b/Libraries/LibWeb/SVG/SMILAnimation.cppindex e9dff957588..71f5729188c 100644--- a/Libraries/LibWeb/SVG/SMILAnimation.cpp+++ b/Libraries/LibWeb/SVG/SMILAnimation.cpp@@ -13,16 +13,17 @@ namespace Web::SVG {GC_DEFINE_ALLOCATOR(SMILAnimation);-GC::Ref<SMILAnimation> SMILAnimation::create(SVGAnimationElement& animation_element, SMILTimeContainer& time_container)+GC::Ref<SMILAnimation> SMILAnimation::create(SVGAnimationElement& animation_element, SMILTimeContainer& time_container, double begin_time){auto& environment = animation_element.document().relevant_settings_object();- return GC::Heap::the().allocate<SMILAnimation>(environment, animation_element, time_container);+ return GC::Heap::the().allocate<SMILAnimation>(environment, animation_element, time_container, begin_time);}-SMILAnimation::SMILAnimation(HTML::EnvironmentSettingsObject& environment, SVGAnimationElement& animation_element, SMILTimeContainer& time_container)+SMILAnimation::SMILAnimation(HTML::EnvironmentSettingsObject& environment, SVGAnimationElement& animation_element, SMILTimeContainer& time_container, double begin_time): Animations::Animation(environment), m_animation_element(animation_element), m_time_container(time_container)+ , m_begin_time(begin_time){}@@ -41,8 +42,12 @@ int SMILAnimation::class_specific_composite_order(GC::Ref<Animations::Animation>// ...// If two animations share no time dependency relationship (e.g., neither is defined relative to the other, even// indirectly) the element that appears first in the document has lower priority.- // NB: Every animation begins at the same moment for now, so only their document order sets them apart.- auto const& other_element = as<SMILAnimation>(*other).animation_element();+ auto const& other_animation = as<SMILAnimation>(*other);+ if (m_begin_time != other_animation.m_begin_time)+ return m_begin_time < other_animation.m_begin_time ? -1 : 1;+ // NB: Begin times only come from offsets and DOM method calls for now, so no animation is defined relative to+ // another.+ auto const& other_element = other_animation.animation_element();if (m_animation_element.ptr() == &other_element)return 0;return m_animation_element->is_before(other_element) ? -1 : 1;diff --git a/Libraries/LibWeb/SVG/SMILAnimation.h b/Libraries/LibWeb/SVG/SMILAnimation.hindex d4753be5a1b..52f4c681ed5 100644--- a/Libraries/LibWeb/SVG/SMILAnimation.h+++ b/Libraries/LibWeb/SVG/SMILAnimation.h@@ -16,7 +16,7 @@ class SMILAnimation final : public Animations::Animation {GC_DECLARE_ALLOCATOR(SMILAnimation);public:- static GC::Ref<SMILAnimation> create(SVGAnimationElement&, SMILTimeContainer&);+ static GC::Ref<SMILAnimation> create(SVGAnimationElement&, SMILTimeContainer&, double begin_time);SVGAnimationElement& animation_element() const { return m_animation_element; }@@ -27,12 +27,13 @@ public:virtual int class_specific_composite_order(GC::Ref<Animations::Animation> other) const override;private:- SMILAnimation(HTML::EnvironmentSettingsObject&, SVGAnimationElement&, SMILTimeContainer&);+ SMILAnimation(HTML::EnvironmentSettingsObject&, SVGAnimationElement&, SMILTimeContainer&, double begin_time);virtual void visit_edges(Cell::Visitor&) override;GC::Ref<SVGAnimationElement> m_animation_element;GC::Ref<SMILTimeContainer> m_time_container;+ double m_begin_time { 0 };};}diff --git a/Libraries/LibWeb/SVG/SVGAnimationElement.cpp b/Libraries/LibWeb/SVG/SVGAnimationElement.cppindex b40accec343..eb383d9744f 100644--- a/Libraries/LibWeb/SVG/SVGAnimationElement.cpp+++ b/Libraries/LibWeb/SVG/SVGAnimationElement.cpp@@ -55,7 +55,7 @@ void SVGAnimationElement::moved_from(IsSubtreeRoot is_subtree_root, GC::Ptr<Nodevoid SVGAnimationElement::attribute_changed(Utf16FlyString const& name, Optional<Utf16String> const& old_value, Optional<Utf16String> const& value, Optional<Utf16FlyString> const& namespace_){Base::attribute_changed(name, old_value, value, namespace_);- if (first_is_one_of(name, AttributeNames::attributeName, AttributeNames::dur, AttributeNames::fill, AttributeNames::repeatCount) && !namespace_.has_value())+ if (first_is_one_of(name, AttributeNames::attributeName, AttributeNames::begin, AttributeNames::dur, AttributeNames::fill, AttributeNames::repeatCount) && !namespace_.has_value())update_animation();}@@ -151,6 +151,104 @@ Bindings::FillMode SVGAnimationElement::fill_mode() constreturn Bindings::FillMode::None;}+// https://svgwg.org/specs/animations/#RestartAttribute+SVGAnimationElement::Restart SVGAnimationElement::restart() const+{+ // NB: SMIL Animation ignores a value with any error in its syntax, which leaves the default value of always.+ auto restart = get_attribute(AttributeNames::restart);+ if (restart == "whenNotActive"sv)+ return Restart::WhenNotActive;+ if (restart == "never"sv)+ return Restart::Never;+ return Restart::Always;+}++// https://svgwg.org/specs/animations/#BeginValueListSyntax+static Optional<double> parse_offset_value_in_milliseconds(Utf16View value)+{+ // offset-value ::= ( S? "+" | "-" S? )? ( Clock-value )+ auto sign = 1.;+ if (value.starts_with(u"+"sv) || value.starts_with(u"-"sv)) {+ if (value.starts_with(u"-"sv))+ sign = -1.;+ value = value.substring_view(1).trim_ascii_whitespace(TrimMode::Left);+ }+ auto clock_value = parse_clock_value_in_milliseconds(value);+ if (!clock_value.has_value())+ return {};+ return sign * *clock_value;+}++// https://svgwg.org/specs/animations/#BeginAttribute+Optional<double> SVGAnimationElement::begin_time_from_begin_attribute() const+{+ // NB: The initial value is 0s.+ auto begin = get_attribute(AttributeNames::begin);+ if (!begin.has_value())+ return 0;++ // The attribute value is a semicolon separated list of values.+ // The interpretation of a list of begin times is detailed in SMIL Animation's section on "Evaluation of begin and+ // end time lists".+ // offset-value+ // For SVG, the implicit syncbase begin is defined to be relative to the document begin.+ // "indefinite"+ // The begin of the animation will be determined by a "beginElement()" method call or a hyperlink targeted to+ // the element.+ // NB: The current interval begins at the earliest of the offset values, and without any, it has no begin time.+ // FIXME: Begin a new interval at each of the later offset values.+ // FIXME: Support the syncbase, event, repeat, accessKey and wallclock-sync values.+ Optional<double> earliest_begin_time;+ begin->utf16_view().for_each_split_view(';', SplitBehavior::KeepEmpty, [&](Utf16View item) {+ auto begin_time = parse_offset_value_in_milliseconds(item.trim_ascii_whitespace());+ if (begin_time.has_value() && (!earliest_begin_time.has_value() || *begin_time < *earliest_begin_time))+ earliest_begin_time = begin_time;+ return IterationDecision::Continue;+ });+ return earliest_begin_time;+}++// https://www.w3.org/TR/smil-animation/#Timing-EvaluationOfBeginEndTimeLists+Optional<double> SVGAnimationElement::interval_begin_time() const+{+ // NB: An instance time that a DOM method created replaces the begin times of the begin attribute, as it was only+ // kept if it begins the current interval.+ if (m_begin_instance_time_from_dom.has_value())+ return m_begin_instance_time_from_dom;+ return begin_time_from_begin_attribute();+}++// https://www.w3.org/TR/smil-animation/#Timing-EvaluationOfBeginEndTimeLists+Optional<double> SVGAnimationElement::interval_end_time() const+{+ // NB: An end time before the begin time of the interval does not end it.+ // FIXME: Support the end attribute.+ auto begin_time = interval_begin_time();+ if (!begin_time.has_value() || !m_end_instance_time_from_dom.has_value() || *m_end_instance_time_from_dom < *begin_time)+ return {};+ return m_end_instance_time_from_dom;+}++bool SVGAnimationElement::is_active_at(double time) const+{+ auto begin_time = interval_begin_time();+ if (!begin_time.has_value() || time < *begin_time)+ return false;+ auto active_end = *begin_time + simple_duration() * repeat_count();+ if (auto end_time = interval_end_time(); end_time.has_value())+ active_end = min(active_end, *end_time);+ return time < active_end;+}++double SVGAnimationElement::current_presentation_time()+{+ // NB: Like SVGSVGElement.getCurrentTime(), the time is 0 until the timeline has begun.+ auto time_container = this->time_container();+ if (!time_container || !time_container->has_begun())+ return 0;+ return time_container->current_time_in_milliseconds();+}+Animations::BaseKeyframe SVGAnimationElement::keyframe(double offset, CSS::PropertyID property_id, CSS::StyleValue const& value){Animations::BaseKeyframe keyframe;@@ -186,15 +284,38 @@ void SVGAnimationElement::update_animation()auto keyframes = this->keyframes(*target, *property_id);if (keyframes.is_empty())return;+ auto begin_time = interval_begin_time();+ if (!begin_time.has_value())+ return;- // FIXME: Resolve the interval to play from the begin and end attributes, and the other timing attributes.+ // NB: The animation's current time is kept equal to the time of the timeline of the SVG document fragment, so the+ // interval begins after a delay of its begin time.+ // FIXME: Resolve the interval from the other timing attributes.// FIXME: A running animation requests a rendering update on every frame, even when its output cannot change, as// with an indefinite one. This keeps the rendering loop running for as long as such an animation is active.- auto effect = MUST(Animations::KeyframeEffect::create_from_processed_keyframes(target, move(keyframes), simple_duration()));- effect->set_iteration_count(repeat_count());- effect->set_fill_mode(fill_mode());+ Animations::KeyframeEffect::Options options;+ auto simple_duration = this->simple_duration();+ auto repeat_count = this->repeat_count();+ options.timing.delay = *begin_time;+ options.timing.duration = simple_duration;+ options.timing.iterations = repeat_count;+ options.timing.fill = fill_mode();++ // NB: An end time cuts the active duration short. With an indefinite simple duration, the animation holds the+ // value at its start for the active duration that remains.+ if (auto end_time = interval_end_time(); end_time.has_value()) {+ auto active_duration = *end_time - *begin_time;+ if (isinf(simple_duration)) {+ options.timing.duration = active_duration;+ options.timing.iterations = 1;+ options.timing.easing = "linear(0, 0)"_utf16;+ } else {+ options.timing.iterations = min(repeat_count, active_duration / simple_duration);+ }+ }+ auto effect = MUST(Animations::KeyframeEffect::create_from_processed_keyframes(target, move(keyframes), options));- auto animation = SMILAnimation::create(*this, *time_container);+ auto animation = SMILAnimation::create(*this, *time_container, *begin_time);animation->set_timeline(document().timeline());animation->set_effect(effect);time_container->add_animation(animation);@@ -243,12 +364,10 @@ WebIDL::ExceptionOr<float> SVGAnimationElement::get_start_time()// Returns the begin time, in seconds, for this animation element's current interval, if it exists, regardless of// whether the interval has begun yet. If there is no current interval, then a DOMException with code// INVALID_STATE_ERR is thrown.- // NB: An animation element in an SVG document fragment has one interval, which begins when the timeline of the- // fragment begins.- // FIXME: Resolve the begin times of intervals from the begin attribute.- if (!is_connected() || !time_container())+ auto begin_time = is_connected() && time_container() ? interval_begin_time() : Optional<double> {};+ if (!begin_time.has_value())return WebIDL::InvalidStateError::create(HTML::relevant_realm(*this), "The animation element has no current interval"_utf16);- return 0;+ return static_cast<float>(*begin_time / 1000.);}// https://svgwg.org/specs/animations/#__svg__SVGAnimationElement__getCurrentTime@@ -275,4 +394,87 @@ WebIDL::ExceptionOr<float> SVGAnimationElement::get_simple_duration()return static_cast<float>(duration / 1000.);}+// https://svgwg.org/specs/animations/#__svg__SVGAnimationElement__beginElement+void SVGAnimationElement::begin_element()+{+ // Creates a begin instance time for the current time. The new instance time is added to the begin instance times+ // list. The behavior of this method is equivalent to beginElementAt(0).+ begin_element_at(0);+}++// https://svgwg.org/specs/animations/#__svg__SVGAnimationElement__beginElementAt+void SVGAnimationElement::begin_element_at(float offset)+{+ // NB: An animation element outside of an SVG document fragment has no timeline to create an instance time on.+ if (!is_connected() || !time_container())+ return;++ // Creates a begin instance time for the current time plus the specified offset. The new instance time is added to+ // the begin instance times list.+ // The instance time associated with a beginElementAt() or endElementAt() call is the current presentation time at+ // the time of the DOM method call, plus or minus the specified offset.+ auto current_time = current_presentation_time();+ auto instance_time = current_time + static_cast<double>(offset) * 1000.;++ // Note that beginElement() is subject to the ‘restart’ attribute in the same manner that event-based begin timing+ // is.+ switch (restart()) {+ case Restart::Always:+ // The animation can be restarted at any time.+ break;+ case Restart::WhenNotActive:+ // The animation can only be restarted when it is not active (i.e. after the active end). Attempts to restart+ // the animation during its active duration are ignored.+ if (is_active_at(current_time))+ return;+ break;+ case Restart::Never:+ // The element cannot be restarted for the remainder of the current simple duration of the parent time+ // container.+ if (auto begin_time = interval_begin_time(); begin_time.has_value() && *begin_time <= current_time)+ return;+ break;+ }++ // NB: An instance time that is still to come does not replace the begin of a current interval that begins+ // before it, and that has not ended.+ // FIXME: Begin a new interval at such an instance time once it is reached.+ if (instance_time > current_time) {+ if (auto begin_time = interval_begin_time(); begin_time.has_value() && *begin_time <= instance_time+ && (current_time < *begin_time || is_active_at(current_time))) {+ return;+ }+ }++ // NB: The new interval ends only at an end instance time after its begin, so that one created at the same time+ // by an earlier endElement() call does not end it at once.+ m_begin_instance_time_from_dom = instance_time;+ if (m_end_instance_time_from_dom.has_value() && *m_end_instance_time_from_dom <= instance_time)+ m_end_instance_time_from_dom.clear();+ update_animation();+}++// https://svgwg.org/specs/animations/#__svg__SVGAnimationElement__endElement+void SVGAnimationElement::end_element()+{+ // Creates an end instance time for the current time. The new instance time is added to the end instance times+ // list. The behavior of this method is equivalent to endElementAt(0).+ end_element_at(0);+}++// https://svgwg.org/specs/animations/#__svg__SVGAnimationElement__endElementAt+void SVGAnimationElement::end_element_at(float offset)+{+ // NB: An animation element outside of an SVG document fragment has no timeline to create an instance time on.+ if (!is_connected() || !time_container())+ return;++ // Creates a end instance time for the current time plus the specified offset. The new instance time is added to+ // the end instance times list.+ // The instance time associated with a beginElementAt() or endElementAt() call is the current presentation time at+ // the time of the DOM method call, plus or minus the specified offset.+ m_end_instance_time_from_dom = current_presentation_time() + static_cast<double>(offset) * 1000.;+ update_animation();+}+}diff --git a/Libraries/LibWeb/SVG/SVGAnimationElement.h b/Libraries/LibWeb/SVG/SVGAnimationElement.hindex bb92d0d5b3e..103bfc6927c 100644--- a/Libraries/LibWeb/SVG/SVGAnimationElement.h+++ b/Libraries/LibWeb/SVG/SVGAnimationElement.h@@ -33,6 +33,11 @@ public:float get_current_time();WebIDL::ExceptionOr<float> get_simple_duration();+ void begin_element();+ void begin_element_at(float offset);+ void end_element();+ void end_element_at(float offset);+protected:SVGAnimationElement(DOM::Document&, DOM::QualifiedName);@@ -56,7 +61,25 @@ private:double repeat_count() const;Bindings::FillMode fill_mode() const;+ enum class Restart : u8 {+ Always,+ WhenNotActive,+ Never,+ };+ Restart restart() const;++ double current_presentation_time();+ Optional<double> begin_time_from_begin_attribute() const;+ Optional<double> interval_begin_time() const;+ Optional<double> interval_end_time() const;+ bool is_active_at(double time) const;+GC::Ptr<SMILAnimation> m_animation;++ // NB: The latest instance times that the DOM methods created, in milliseconds on the timeline of the SVG document+ // fragment.+ Optional<double> m_begin_instance_time_from_dom;+ Optional<double> m_end_instance_time_from_dom;};}diff --git a/Libraries/LibWeb/SVG/SVGAnimationElement.idl b/Libraries/LibWeb/SVG/SVGAnimationElement.idlindex 9a571c400c2..f88eb20fa82 100644--- a/Libraries/LibWeb/SVG/SVGAnimationElement.idl+++ b/Libraries/LibWeb/SVG/SVGAnimationElement.idl@@ -12,10 +12,10 @@ interface SVGAnimationElement : SVGElement {float getCurrentTime();float getSimpleDuration();- [FIXME] undefined beginElement();- [FIXME] undefined beginElementAt(float offset);- [FIXME] undefined endElement();- [FIXME] undefined endElementAt(float offset);+ undefined beginElement();+ undefined beginElementAt(float offset);+ undefined endElement();+ undefined endElementAt(float offset);};// FIXME: SVGAnimationElement includes SVGTests;diff --git a/Tests/LibWeb/Text/expected/SVG/animation-element-begin-and-dom-methods.txt b/Tests/LibWeb/Text/expected/SVG/animation-element-begin-and-dom-methods.txtnew file mode 100644index 00000000000..c40f625e45c--- /dev/null+++ b/Tests/LibWeb/Text/expected/SVG/animation-element-begin-and-dom-methods.txt@@ -0,0 +1,60 @@+before any DOM method call (t=0.5)+ offset: opacity 1.000, start time 1+ earliest-offset: opacity 0.750, start time -1+ indefinite: opacity 1.000, start time InvalidStateError+ always: opacity 0.250, start time 0+ when-not-active: opacity 0.250, start time 0+ never: opacity 0.250, start time 0+ later-instance: opacity 0.250, start time 0+ later-instance-pending: opacity 1.000, start time 1+ ended: opacity 1.000, start time InvalidStateError+ ended-frozen: opacity 1.000, start time InvalidStateError+ set-ended: opacity 1.000, start time InvalidStateError+after beginning the elements (t=1.5)+ offset: opacity 0.250, start time 1+ earliest-offset: opacity 1.000, start time -1+ indefinite: opacity 0.250, start time 1+ always: opacity 0.500, start time 0.5+ when-not-active: opacity 0.750, start time 0+ never: opacity 0.750, start time 0+ later-instance: opacity 0.750, start time 0+ later-instance-pending: opacity 0.250, start time 1+ ended: opacity 0.500, start time 0.5+ ended-frozen: opacity 0.500, start time 0.5+ set-ended: opacity 0.500, start time 0.5+after ending the elements (t=1.75)+ offset: opacity 0.375, start time 1+ earliest-offset: opacity 1.000, start time -1+ indefinite: opacity 0.375, start time 1+ always: opacity 0.625, start time 0.5+ when-not-active: opacity 0.875, start time 0+ never: opacity 0.875, start time 0+ later-instance: opacity 0.875, start time 0+ later-instance-pending: opacity 0.375, start time 1+ ended: opacity 1.000, start time 0.5+ ended-frozen: opacity 0.500, start time 0.5+ set-ended: opacity 0.500, start time 0.5+after the active end of the elements (t=2.5)+ offset: opacity 0.750, start time 1+ earliest-offset: opacity 1.000, start time -1+ indefinite: opacity 0.750, start time 1+ always: opacity 1.000, start time 0.5+ when-not-active: opacity 1.000, start time 0+ never: opacity 1.000, start time 0+ later-instance: opacity 1.000, start time 0+ later-instance-pending: opacity 0.750, start time 1+ ended: opacity 1.000, start time 0.5+ ended-frozen: opacity 0.500, start time 0.5+ set-ended: opacity 1.000, start time 0.5+after beginning the elements again (t=2.5)+ offset: opacity 0.750, start time 1+ earliest-offset: opacity 1.000, start time -1+ indefinite: opacity 0.750, start time 1+ always: opacity 1.000, start time 0.5+ when-not-active: opacity 0.000, start time 2.5+ never: opacity 1.000, start time 0+ later-instance: opacity 1.000, start time 0+ later-instance-pending: opacity 0.750, start time 1+ ended: opacity 0.000, start time 2.5+ ended-frozen: opacity 0.500, start time 0.5+ set-ended: opacity 1.000, start time 0.5diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txtindex 4a6892ea3ff..0d4b55c3ce0 100644--- a/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txt@@ -2,8 +2,8 @@ Harness status: OKFound 1780 tests-1610 Pass-170 Fail+1632 Pass+148 FailPass idl_test setupPass idl_test validationPass Partial interface Document: original interface defined@@ -1650,10 +1650,10 @@ Pass SVGAnimationElement interface: attribute onrepeatPass SVGAnimationElement interface: operation getStartTime()Pass SVGAnimationElement interface: operation getCurrentTime()Pass SVGAnimationElement interface: operation getSimpleDuration()-Fail SVGAnimationElement interface: operation beginElement()-Fail SVGAnimationElement interface: operation beginElementAt(float)-Fail SVGAnimationElement interface: operation endElement()-Fail SVGAnimationElement interface: operation endElementAt(float)+Pass SVGAnimationElement interface: operation beginElement()+Pass SVGAnimationElement interface: operation beginElementAt(float)+Pass SVGAnimationElement interface: operation endElement()+Pass SVGAnimationElement interface: operation endElementAt(float)Fail SVGAnimationElement interface: attribute requiredExtensionsFail SVGAnimationElement interface: attribute systemLanguagePass SVGAnimateElement interface: existence and properties of interface object@@ -1671,12 +1671,12 @@ Pass SVGAnimationElement interface: objects.animate must inherit property "onrepPass SVGAnimationElement interface: objects.animate must inherit property "getStartTime()" with the proper typePass SVGAnimationElement interface: objects.animate must inherit property "getCurrentTime()" with the proper typePass SVGAnimationElement interface: objects.animate must inherit property "getSimpleDuration()" with the proper type-Fail SVGAnimationElement interface: objects.animate must inherit property "beginElement()" with the proper type-Fail SVGAnimationElement interface: objects.animate must inherit property "beginElementAt(float)" with the proper type-Fail SVGAnimationElement interface: calling beginElementAt(float) on objects.animate with too few arguments must throw TypeError-Fail SVGAnimationElement interface: objects.animate must inherit property "endElement()" with the proper type-Fail SVGAnimationElement interface: objects.animate must inherit property "endElementAt(float)" with the proper type-Fail SVGAnimationElement interface: calling endElementAt(float) on objects.animate with too few arguments must throw TypeError+Pass SVGAnimationElement interface: objects.animate must inherit property "beginElement()" with the proper type+Pass SVGAnimationElement interface: objects.animate must inherit property "beginElementAt(float)" with the proper type+Pass SVGAnimationElement interface: calling beginElementAt(float) on objects.animate with too few arguments must throw TypeError+Pass SVGAnimationElement interface: objects.animate must inherit property "endElement()" with the proper type+Pass SVGAnimationElement interface: objects.animate must inherit property "endElementAt(float)" with the proper type+Pass SVGAnimationElement interface: calling endElementAt(float) on objects.animate with too few arguments must throw TypeErrorFail SVGAnimationElement interface: objects.animate must inherit property "requiredExtensions" with the proper typeFail SVGAnimationElement interface: objects.animate must inherit property "systemLanguage" with the proper typePass SVGElement interface: objects.animate must inherit property "className" with the proper type@@ -1699,12 +1699,12 @@ Pass SVGAnimationElement interface: objects.set must inherit property "onrepeat"Pass SVGAnimationElement interface: objects.set must inherit property "getStartTime()" with the proper typePass SVGAnimationElement interface: objects.set must inherit property "getCurrentTime()" with the proper typePass SVGAnimationElement interface: objects.set must inherit property "getSimpleDuration()" with the proper type-Fail SVGAnimationElement interface: objects.set must inherit property "beginElement()" with the proper type-Fail SVGAnimationElement interface: objects.set must inherit property "beginElementAt(float)" with the proper type-Fail SVGAnimationElement interface: calling beginElementAt(float) on objects.set with too few arguments must throw TypeError-Fail SVGAnimationElement interface: objects.set must inherit property "endElement()" with the proper type-Fail SVGAnimationElement interface: objects.set must inherit property "endElementAt(float)" with the proper type-Fail SVGAnimationElement interface: calling endElementAt(float) on objects.set with too few arguments must throw TypeError+Pass SVGAnimationElement interface: objects.set must inherit property "beginElement()" with the proper type+Pass SVGAnimationElement interface: objects.set must inherit property "beginElementAt(float)" with the proper type+Pass SVGAnimationElement interface: calling beginElementAt(float) on objects.set with too few arguments must throw TypeError+Pass SVGAnimationElement interface: objects.set must inherit property "endElement()" with the proper type+Pass SVGAnimationElement interface: objects.set must inherit property "endElementAt(float)" with the proper type+Pass SVGAnimationElement interface: calling endElementAt(float) on objects.set with too few arguments must throw TypeErrorFail SVGAnimationElement interface: objects.set must inherit property "requiredExtensions" with the proper typeFail SVGAnimationElement interface: objects.set must inherit property "systemLanguage" with the proper typePass SVGElement interface: objects.set must inherit property "className" with the proper type@@ -1727,12 +1727,12 @@ Pass SVGAnimationElement interface: objects.animateMotion must inherit propertyPass SVGAnimationElement interface: objects.animateMotion must inherit property "getStartTime()" with the proper typePass SVGAnimationElement interface: objects.animateMotion must inherit property "getCurrentTime()" with the proper typePass SVGAnimationElement interface: objects.animateMotion must inherit property "getSimpleDuration()" with the proper type-Fail SVGAnimationElement interface: objects.animateMotion must inherit property "beginElement()" with the proper type-Fail SVGAnimationElement interface: objects.animateMotion must inherit property "beginElementAt(float)" with the proper type-Fail SVGAnimationElement interface: calling beginElementAt(float) on objects.animateMotion with too few arguments must throw TypeError-Fail SVGAnimationElement interface: objects.animateMotion must inherit property "endElement()" with the proper type-Fail SVGAnimationElement interface: objects.animateMotion must inherit property "endElementAt(float)" with the proper type-Fail SVGAnimationElement interface: calling endElementAt(float) on objects.animateMotion with too few arguments must throw TypeError+Pass SVGAnimationElement interface: objects.animateMotion must inherit property "beginElement()" with the proper type+Pass SVGAnimationElement interface: objects.animateMotion must inherit property "beginElementAt(float)" with the proper type+Pass SVGAnimationElement interface: calling beginElementAt(float) on objects.animateMotion with too few arguments must throw TypeError+Pass SVGAnimationElement interface: objects.animateMotion must inherit property "endElement()" with the proper type+Pass SVGAnimationElement interface: objects.animateMotion must inherit property "endElementAt(float)" with the proper type+Pass SVGAnimationElement interface: calling endElementAt(float) on objects.animateMotion with too few arguments must throw TypeErrorFail SVGAnimationElement interface: objects.animateMotion must inherit property "requiredExtensions" with the proper typeFail SVGAnimationElement interface: objects.animateMotion must inherit property "systemLanguage" with the proper typePass SVGElement interface: objects.animateMotion must inherit property "className" with the proper typediff --git a/Tests/LibWeb/Text/input/SVG/animation-element-begin-and-dom-methods.html b/Tests/LibWeb/Text/input/SVG/animation-element-begin-and-dom-methods.htmlnew file mode 100644index 00000000000..a8890fde6a9--- /dev/null+++ b/Tests/LibWeb/Text/input/SVG/animation-element-begin-and-dom-methods.html@@ -0,0 +1,87 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<svg id="svg" width="100" height="100">+ <rect id="offset" width="10" height="10" opacity="1">+ <animate attributeName="opacity" from="0" to="1" begin="1s" dur="2s"/>+ </rect>+ <rect id="earliest-offset" width="10" height="10" opacity="1">+ <animate attributeName="opacity" from="0" to="1" begin="3s; -1s" dur="2s"/>+ </rect>+ <rect id="indefinite" width="10" height="10" opacity="1">+ <animate attributeName="opacity" from="0" to="1" begin="indefinite" dur="2s"/>+ </rect>+ <rect id="always" width="10" height="10" opacity="1">+ <animate attributeName="opacity" from="0" to="1" dur="2s"/>+ </rect>+ <rect id="when-not-active" width="10" height="10" opacity="1">+ <animate attributeName="opacity" from="0" to="1" dur="2s" restart="whenNotActive"/>+ </rect>+ <rect id="never" width="10" height="10" opacity="1">+ <animate attributeName="opacity" from="0" to="1" dur="2s" restart="never"/>+ </rect>+ <rect id="later-instance" width="10" height="10" opacity="1">+ <animate attributeName="opacity" from="0" to="1" dur="2s"/>+ </rect>+ <rect id="later-instance-pending" width="10" height="10" opacity="1">+ <animate attributeName="opacity" from="0" to="1" begin="1s" dur="2s"/>+ </rect>+ <rect id="ended" width="10" height="10" opacity="1">+ <animate attributeName="opacity" from="0" to="1" begin="indefinite" dur="2s" repeatCount="indefinite"/>+ </rect>+ <rect id="ended-frozen" width="10" height="10" opacity="1">+ <animate attributeName="opacity" from="0" to="1" begin="indefinite" dur="2s" repeatCount="indefinite" fill="freeze"/>+ </rect>+ <rect id="set-ended" width="10" height="10" opacity="1">+ <set attributeName="opacity" to="0.5" begin="indefinite"/>+ </rect>+</svg>+<script>+ asyncTest(async done => {+ const animation = id => document.getElementById(id).firstElementChild;+ const startTime = id => {+ try {+ return animation(id).getStartTime();+ } catch (error) {+ return error.name;+ }+ };+ const print = label => {+ println(`${label} (t=${svg.getCurrentTime()})`);+ for (const rect of document.querySelectorAll("rect"))+ println(` ${rect.id}: opacity ${Number(getComputedStyle(rect).opacity).toFixed(3)}, start time ${startTime(rect.id)}`);+ };++ await new Promise(resolve => window.addEventListener("load", resolve));+ await new Promise(requestAnimationFrame);+ svg.pauseAnimations();+ svg.setCurrentTime(0.5);+ print("before any DOM method call");++ animation("indefinite").beginElementAt(0.5);+ animation("always").beginElement();+ animation("when-not-active").beginElement();+ animation("never").beginElement();+ animation("later-instance").beginElementAt(10);+ animation("later-instance-pending").beginElementAt(1);+ animation("ended").beginElement();+ animation("ended-frozen").beginElement();+ animation("set-ended").beginElement();+ svg.setCurrentTime(1.5);+ print("after beginning the elements");++ animation("ended").endElement();+ animation("ended-frozen").endElement();+ animation("set-ended").endElementAt(0.5);+ svg.setCurrentTime(1.75);+ print("after ending the elements");++ svg.setCurrentTime(2.5);+ print("after the active end of the elements");++ animation("when-not-active").beginElement();+ animation("never").beginElement();+ animation("ended").beginElement();+ print("after beginning the elements again");+ done();+ });+</script>