accessibility_tree/
primitives.rs

1use crate::text;
2
3/// Origin at top-left corner, unit `1px`
4pub struct CssPx;
5
6pub use euclid::point2 as point;
7pub use euclid::rect;
8pub type Length<U> = euclid::Length<f32, U>;
9pub type Point<U> = euclid::TypedPoint2D<f32, U>;
10pub type Size<U> = euclid::TypedSize2D<f32, U>;
11pub type Rect<U> = euclid::TypedRect<f32, U>;
12pub type SideOffsets<U> = euclid::TypedSideOffsets2D<f32, U>;
13pub type Scale<Src, Dest> = euclid::TypedScale<f32, Src, Dest>;
14
15#[derive(Copy, Clone, PartialEq)]
16pub struct RGBA(pub f32, pub f32, pub f32, pub f32);
17
18pub struct TextRun<'a> {
19    pub segment: &'a text::ShapedSegment,
20    pub font_size: Length<CssPx>,
21    pub origin: Point<CssPx>,
22}
23
24impl From<cssparser::RGBA> for RGBA {
25    fn from(c: cssparser::RGBA) -> Self {
26        RGBA(c.red_f32(), c.green_f32(), c.blue_f32(), c.alpha_f32())
27    }
28}