whoamiEmilio Cobos Álvarez
emilio@mozilla.com
components/style, without counting dependencies.layout.css.servo.enabled), probably on 57.pub trait DomTraversal<E: TElement> : Sync {
// ...
}#[derive(Clone, Copy)]
pub struct GeckoNode<'ln>(pub &'ln RawGeckoNode);AtomicRefCell to wrap read-write data where statically proving its correct usage is not possible.rayon: Easy, fast, and safe parallelism primitives.for chunk in nodes.chunks(WORK_UNIT_MAX) {
let nodes = chunk.iter().cloned().collect::<WorkUnit<E::ConcreteNode>>();
let traversal_data_copy = traversal_data.clone();
scope.spawn(move |scope| {
let n = nodes;
top_down_dom(&*n, 0, root,
traversal_data_copy, scope, pool, traversal, tls)
});
}derive + generics.Currently derivable traits: ToCss, ComputeSquaredDistance, HasViewportPercentage, ToAnimatedValue, ToComputedValue.
Lots of other cleanups possible / in the way.
@nox is responsible for most of this (thanks to the synstructure crate, by @mystor).
/// A generic value for a single `filter`.
#[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))]
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToAnimatedValue, ToComputedValue, ToCss)]
pub enum Filter<Angle, Factor, Length, DropShadow> {
/// `blur(<length>)`
#[css(function)]
Blur(Length),
/// `brightness(<factor>)`
#[css(function)]
Brightness(Factor),
// ...
}The kinda-ugly part :-)
The basic layer of separation is that the rust style system outputs C++ structs.
We use FFI functions for high-level functionality, with conversion between rust and C++ types, bindgen for fast access.
Had to rewrite bindgen to make it work in mozilla-central.
#[repr(C)]
#[derive(Debug)]
pub struct nsStyleFont {
pub mFont: root::nsFont,
pub mSize: root::nscoord,
pub mGenericID: u8,
pub mScriptLevel: i8,
pub mMathVariant: u8,
// ...
}Correct layout enforced by runtime assertions.
Lots of improvements possible, little time before 57 :)
emilio@mozilla.com.