style: Document the stylist module.

This commit is contained in:
Emilio Cobos Álvarez 2017-01-02 01:10:16 +01:00
parent 082866aba6
commit c5f2142d8f
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 108 additions and 30 deletions

View file

@ -1054,27 +1054,24 @@ impl LayoutThread {
let device = Device::new(MediaType::Screen, initial_viewport);
Arc::get_mut(&mut rw_data.stylist).unwrap().set_device(device, &data.document_stylesheets);
let constraints = rw_data.stylist.viewport_constraints().clone();
self.viewport_size = match constraints {
Some(ref constraints) => {
self.viewport_size =
rw_data.stylist.viewport_constraints().map_or(current_screen_size, |constraints| {
debug!("Viewport constraints: {:?}", constraints);
// other rules are evaluated against the actual viewport
Size2D::new(Au::from_f32_px(constraints.size.width),
Au::from_f32_px(constraints.size.height))
}
None => current_screen_size,
};
});
// Handle conditions where the entire flow tree is invalid.
let mut needs_dirtying = false;
let viewport_size_changed = self.viewport_size != old_viewport_size;
if viewport_size_changed {
if let Some(constraints) = constraints {
if let Some(constraints) = rw_data.stylist.viewport_constraints() {
// let the constellation know about the viewport constraints
rw_data.constellation_chan
.send(ConstellationMsg::ViewportConstrained(self.id, constraints))
.send(ConstellationMsg::ViewportConstrained(self.id, constraints.clone()))
.unwrap();
}
if data.document_stylesheets.iter().any(|sheet| sheet.dirty_on_viewport_size_change()) {