1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use crate::layout::*;
use freya_dom::prelude::{DioxusDOMAdapter, FreyaDOM};
use freya_engine::prelude::*;
use torin::geometry::Area;

/// Process the layout of the DOM
pub fn process_layout(
    fdom: &FreyaDOM,
    area: Area,
    font_collection: &mut FontCollection,
    scale_factor: f32,
    default_fonts: &[String],
) {
    {
        let rdom = fdom.rdom();
        let mut dom_adapter = DioxusDOMAdapter::new_with_cache(rdom);
        let skia_measurer = SkiaMeasurer::new(rdom, font_collection, default_fonts, scale_factor);

        // Finds the best Node from where to start measuring
        fdom.layout().find_best_root(&mut dom_adapter);

        let root_id = fdom.rdom().root_id();

        // Measure the layout
        fdom.layout()
            .measure(root_id, area, &mut Some(skia_measurer), &mut dom_adapter);
    }

    fdom.measure_all_paragraphs(scale_factor);
}