mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Bug 1349417 - Part 8: stylo: Serialize system fonts correctly; r?xidorn
MozReview-Commit-ID: 4q1zZUcw6zF
This commit is contained in:
parent
681df60191
commit
59f16b57e7
2 changed files with 54 additions and 0 deletions
|
@ -2103,7 +2103,9 @@ ${helpers.single_keyword("-moz-math-variant",
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use cssparser::Parser;
|
use cssparser::Parser;
|
||||||
use properties::longhands;
|
use properties::longhands;
|
||||||
|
use std::fmt;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
|
use style_traits::ToCss;
|
||||||
use values::computed::{ToComputedValue, Context};
|
use values::computed::{ToComputedValue, Context};
|
||||||
<%
|
<%
|
||||||
system_fonts = """caption icon menu message-box small-caption status-bar
|
system_fonts = """caption icon menu message-box small-caption status-bar
|
||||||
|
@ -2124,6 +2126,16 @@ ${helpers.single_keyword("-moz-math-variant",
|
||||||
% endfor
|
% endfor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ToCss for SystemFont {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
|
dest.write_str(match *self {
|
||||||
|
% for font in system_fonts:
|
||||||
|
SystemFont::${to_camel_case(font)} => "${font}",
|
||||||
|
% endfor
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ComputedValues are compared at times
|
// ComputedValues are compared at times
|
||||||
// so we need these impls. We don't want to
|
// so we need these impls. We don't want to
|
||||||
// add Eq to Number (which contains a float)
|
// add Eq to Number (which contains a float)
|
||||||
|
|
|
@ -114,9 +114,51 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum CheckSystemResult {
|
||||||
|
AllSystem(SystemFont),
|
||||||
|
SomeSystem,
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
% if product == "gecko":
|
||||||
|
impl<'a> LonghandsToSerialize<'a> {
|
||||||
|
/// Check if some or all members are system fonts
|
||||||
|
fn check_system(&self) -> CheckSystemResult {
|
||||||
|
let mut sys = None;
|
||||||
|
let mut all = true;
|
||||||
|
|
||||||
|
% for prop in SYSTEM_FONT_LONGHANDS:
|
||||||
|
if let Some(s) = self.${prop}.get_system() {
|
||||||
|
debug_assert!(sys.is_none() || s == sys.unwrap());
|
||||||
|
sys = Some(s);
|
||||||
|
} else {
|
||||||
|
all = false;
|
||||||
|
}
|
||||||
|
% endfor
|
||||||
|
if self.line_height != &line_height::get_initial_specified_value() {
|
||||||
|
all = false
|
||||||
|
}
|
||||||
|
if all {
|
||||||
|
CheckSystemResult::AllSystem(sys.unwrap())
|
||||||
|
} else if sys.is_some() {
|
||||||
|
CheckSystemResult::SomeSystem
|
||||||
|
} else {
|
||||||
|
CheckSystemResult::None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
% endif
|
||||||
|
|
||||||
// This may be a bit off, unsure, possibly needs changes
|
// This may be a bit off, unsure, possibly needs changes
|
||||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
|
% if product == "gecko":
|
||||||
|
match self.check_system() {
|
||||||
|
CheckSystemResult::AllSystem(sys) => return sys.to_css(dest),
|
||||||
|
CheckSystemResult::SomeSystem => return Ok(()),
|
||||||
|
CheckSystemResult::None => ()
|
||||||
|
}
|
||||||
|
% endif
|
||||||
|
|
||||||
% if product == "gecko" or data.testing:
|
% if product == "gecko" or data.testing:
|
||||||
% for name in gecko_sub_properties:
|
% for name in gecko_sub_properties:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue