use dom_struct::dom_struct;
use js::context::JSContext;
use js::jsapi::JSObject;
use js::rust::HandleObject;
use script_bindings::codegen::GenericUnionTypes::UnrestrictedDoubleOrKeyframeEffectOptions;
use script_bindings::reflector::reflect_dom_object_with_proto_and_cx;
use script_bindings::root::{Dom, DomRoot};
use crate::dom::animationeffect::AnimationEffect;
use crate::dom::bindings::codegen::Bindings::KeyframeEffectBinding::KeyframeEffectMethods;
use crate::dom::bindings::root::MutNullableDom;
use crate::dom::element::Element;
use crate::dom::window::Window;
#[dom_struct]
pub(crate) struct KeyframeEffect {
animationeffect: AnimationEffect,
window: Dom<Window>,
target_element: MutNullableDom<Element>,
}
impl KeyframeEffect {
pub(crate) fn new_inherited(window: &Window) -> Self {
Self {
window: Dom::from_ref(window),
animationeffect: AnimationEffect::new_inherited(),
target_element: Default::default(),
}
}
fn new_with_proto_and_cx(
cx: &mut JSContext,
window: &Window,
proto: Option<HandleObject>,
) -> DomRoot<Self> {
reflect_dom_object_with_proto_and_cx(
Box::new(Self::new_inherited(window)),
window,
proto,
cx,
)
}
pub(crate) fn new(cx: &mut JSContext, window: &Window) -> DomRoot<Self> {
Self::new_with_proto_and_cx(cx, window, None)
}
}
impl KeyframeEffectMethods<crate::DomTypeHolder> for KeyframeEffect {
fn Constructor(
cx: &mut JSContext,
window: &Window,
_: Option<HandleObject>,
target: Option<&Element>,
keyframes: *mut JSObject,
_options: UnrestrictedDoubleOrKeyframeEffectOptions,
) -> DomRoot<KeyframeEffect> {
let effect = KeyframeEffect::new(cx, window);
effect.target_element.set(target);
effect.SetKeyframes(cx, keyframes);
effect
}
fn SetKeyframes(&self, _cx: &mut JSContext, _keyframes: *mut JSObject) {
}
}