servo/webrender

Re-export app_units::Au or disable serde for app_units

Fechada

#3.045 aberto em 11 de set. de 2018

 (3 comentários) (2 reações) (0 responsável)Rust (319 forks)github user discovery
area: infrastructuredifficulty: easyhelp wantedtype: enhancement

Métricas do repositório

Stars
 (3.355 estrelas)
Métricas de merge de PR
 (Mesclagem média 20d 5h) (1 fundiu PR em 30d)

Description

In order to create a AddFontInstance struct, you have to use an app_units::Au. This is very annoying because:

  • app_units depends on serde and num_traits, both very compile-time heavy crates that are completely unused, yet they still need to be compiled in
  • This is the only place in the entire public webrender API where Au is used
  • app_units isn't re-exported, so other crates have to add the exact version that webrender uses to their Cargo.toml manually.

So my proposal is to create a function that creates an Au from an i32 value, this way you don't have to re-export the Au, i.e.:

pub fn webrender_create_au_from_px(value: i32) -> Option<Au> {
    let value = value * AU_PER_PX;
    if value < MIN_AU || value > MAX_AU {
        None
    } else {
        Some(Au(value))
    }
}

And please make serde and num-traits in the app-units crate optional - for a regular webrender application, these crates go completely unused because serde serialization is only used for the debugger, but these crates still have to be compiled, leading to bad compile times.

Guia do colaborador