mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Bug 1349417 - Part 8: stylo: Serialize system fonts correctly; r?xidorn
MozReview-Commit-ID: 4q1zZUcw6zF
This commit is contained in:
parent
795ab74f04
commit
5a07227db5
2 changed files with 54 additions and 0 deletions
|
@ -2183,7 +2183,9 @@ ${helpers.single_keyword("-moz-math-variant",
|
|||
use app_units::Au;
|
||||
use cssparser::Parser;
|
||||
use properties::longhands;
|
||||
use std::fmt;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use style_traits::ToCss;
|
||||
use values::computed::{ToComputedValue, Context};
|
||||
<%
|
||||
system_fonts = """caption icon menu message-box small-caption status-bar
|
||||
|
@ -2204,6 +2206,16 @@ ${helpers.single_keyword("-moz-math-variant",
|
|||
% 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
|
||||
// so we need these impls. We don't want to
|
||||
// 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
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
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:
|
||||
% for name in gecko_sub_properties:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue