mirror of
https://github.com/servo/servo.git
synced 2025-08-12 17:05:33 +01:00
layout: Implement outline
per CSS 2.1 § 18.4.
`invert` is not yet supported. Objects that get layers will not yet display outlines properly. This is because our overflow calculation doesn't take styles into account and because layers are always anchored to the top left of the border box. Since fixing this is work that is not related to outline *per se* I'm leaving that to a followup and making a note in the code.
This commit is contained in:
parent
512d55ecef
commit
52b9951cad
10 changed files with 242 additions and 6 deletions
|
@ -355,6 +355,38 @@ pub mod longhands {
|
|||
</%self:longhand>
|
||||
% endfor
|
||||
|
||||
${new_style_struct("Outline", is_inherited=False)}
|
||||
|
||||
// TODO(pcwalton): `invert`
|
||||
${predefined_type("outline-color", "CSSColor", "CurrentColor")}
|
||||
|
||||
<%self:single_component_value name="outline-style">
|
||||
pub use super::border_top_style::{get_initial_value, to_computed_value};
|
||||
pub type SpecifiedValue = super::border_top_style::SpecifiedValue;
|
||||
pub mod computed_value {
|
||||
pub type T = super::super::border_top_style::computed_value::T;
|
||||
}
|
||||
pub fn from_component_value(value: &ComponentValue, base_url: &Url)
|
||||
-> Result<SpecifiedValue,()> {
|
||||
match value {
|
||||
&Ident(ref ident) if ident.eq_ignore_ascii_case("hidden") => {
|
||||
// `hidden` is not a valid value.
|
||||
Err(())
|
||||
}
|
||||
_ => super::border_top_style::from_component_value(value, base_url)
|
||||
}
|
||||
}
|
||||
</%self:single_component_value>
|
||||
|
||||
<%self:longhand name="outline-width">
|
||||
pub use super::border_top_width::{get_initial_value, parse};
|
||||
pub use computed::compute_Au as to_computed_value;
|
||||
pub type SpecifiedValue = super::border_top_width::SpecifiedValue;
|
||||
pub mod computed_value {
|
||||
pub type T = super::super::border_top_width::computed_value::T;
|
||||
}
|
||||
</%self:longhand>
|
||||
|
||||
${new_style_struct("PositionOffsets", is_inherited=False)}
|
||||
|
||||
% for side in ["top", "right", "bottom", "left"]:
|
||||
|
@ -1544,6 +1576,52 @@ pub mod shorthands {
|
|||
})
|
||||
</%self:shorthand>
|
||||
|
||||
<%self:shorthand name="outline" sub_properties="outline-color outline-style outline-width">
|
||||
let (mut color, mut style, mut width, mut any) = (None, None, None, false);
|
||||
for component_value in input.skip_whitespace() {
|
||||
if color.is_none() {
|
||||
match specified::CSSColor::parse(component_value) {
|
||||
Ok(c) => {
|
||||
color = Some(c);
|
||||
any = true;
|
||||
continue
|
||||
}
|
||||
Err(()) => {}
|
||||
}
|
||||
}
|
||||
if style.is_none() {
|
||||
match border_top_style::from_component_value(component_value, base_url) {
|
||||
Ok(s) => {
|
||||
style = Some(s);
|
||||
any = true;
|
||||
continue
|
||||
}
|
||||
Err(()) => {}
|
||||
}
|
||||
}
|
||||
if width.is_none() {
|
||||
match parse_border_width(component_value, base_url) {
|
||||
Ok(w) => {
|
||||
width = Some(w);
|
||||
any = true;
|
||||
continue
|
||||
}
|
||||
Err(()) => {}
|
||||
}
|
||||
}
|
||||
return Err(())
|
||||
}
|
||||
if any {
|
||||
Ok(Longhands {
|
||||
outline_color: color,
|
||||
outline_style: style,
|
||||
outline_width: width,
|
||||
})
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
</%self:shorthand>
|
||||
|
||||
<%self:shorthand name="font" sub_properties="font-style font-variant font-weight
|
||||
font-size line-height font-family">
|
||||
let mut iter = input.skip_whitespace();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue