Geckolib: Implement font-weight.

This commit is contained in:
Bobby Holley 2016-05-03 11:01:50 -07:00
parent 2c69278067
commit 9fdb791e93
2 changed files with 14 additions and 1 deletions

View file

@ -173,6 +173,7 @@ ${helpers.single_keyword("font-variant", "normal small-caps")}
pub mod computed_value {
use std::fmt;
#[derive(PartialEq, Eq, Copy, Clone, Hash, Deserialize, Serialize, HeapSizeOf, Debug)]
#[repr(u16)]
pub enum T {
% for weight in range(100, 901, 100):
Weight${weight} = ${weight},

View file

@ -424,7 +424,7 @@ fn static_assert() {
}
</%self:impl_trait>
<%self:impl_trait style_struct_name="Font" skip_longhands="font-size" skip_additionals="*">
<%self:impl_trait style_struct_name="Font" skip_longhands="font-size font-weight" skip_additionals="*">
// FIXME(bholley): Gecko has two different sizes, one of which (mSize) is the
// actual computed size, and the other of which (mFont.size) is the 'display
@ -441,6 +441,18 @@ fn static_assert() {
Au(self.gecko.mSize)
}
fn set_font_weight(&mut self, v: longhands::font_weight::computed_value::T) {
self.gecko.mFont.weight = v as u16;
}
<%call expr="impl_simple_copy('font_weight', 'mFont.weight')"></%call>
fn clone_font_weight(&self) -> longhands::font_weight::computed_value::T {
debug_assert!(self.gecko.mFont.weight >= 100);
debug_assert!(self.gecko.mFont.weight <= 900);
debug_assert!(self.gecko.mFont.weight % 10 == 0);
unsafe { transmute(self.gecko.mFont.weight) }
}
// This is used for PartialEq, which we don't implement for gecko style structs.
fn compute_font_hash(&mut self) {}