use dom_struct::dom_struct;
use crate::dom::bindings::codegen::Bindings::ResizeObserverSizeBinding::ResizeObserverSizeMethods;
use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector};
use crate::dom::bindings::root::DomRoot;
use crate::dom::window::Window;
use crate::script_runtime::CanGc;
#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)]
pub struct ResizeObserverSizeImpl {
inline_size: f64,
block_size: f64,
}
impl ResizeObserverSizeImpl {
pub fn new(inline_size: f64, block_size: f64) -> ResizeObserverSizeImpl {
ResizeObserverSizeImpl {
inline_size,
block_size,
}
}
pub fn inline_size(&self) -> f64 {
self.inline_size
}
pub fn block_size(&self) -> f64 {
self.block_size
}
}
#[dom_struct]
pub struct ResizeObserverSize {
reflector_: Reflector,
size_impl: ResizeObserverSizeImpl,
}
impl ResizeObserverSize {
fn new_inherited(size_impl: ResizeObserverSizeImpl) -> ResizeObserverSize {
ResizeObserverSize {
reflector_: Reflector::new(),
size_impl,
}
}
pub fn new(window: &Window, size_impl: ResizeObserverSizeImpl) -> DomRoot<ResizeObserverSize> {
let observer_size = Box::new(ResizeObserverSize::new_inherited(size_impl));
reflect_dom_object_with_proto(observer_size, window, None, CanGc::note())
}
}
impl ResizeObserverSizeMethods for ResizeObserverSize {
fn InlineSize(&self) -> f64 {
self.size_impl.inline_size()
}
fn BlockSize(&self) -> f64 {
self.size_impl.block_size()
}
}