render: respect CSS box sizing
This commit is contained in:
1 parent
a11f87d0c9
commit
4979606a2f
4 files changed
+172
-16
No files matched your search
@@ -265,6 +265,17 @@ fn apply_value(style: &mut LayoutStyle, name: &str, value: &str) {
|
||||
style.height = dimension_value(value);
|
||||
style.height_set = true;
|
||||
}
|
||||
"box-sizing" => {
|
||||
style.box_sizing = if value.eq_ignore_ascii_case("border-box") {
|
||||
crate::BoxSizing::BorderBox
|
||||
} else if value.eq_ignore_ascii_case("content-box") {
|
||||
crate::BoxSizing::ContentBox
|
||||
} else if value.eq_ignore_ascii_case("inherit") {
|
||||
crate::BoxSizing::Inherit
|
||||
} else {
|
||||
style.box_sizing
|
||||
};
|
||||
}
|
||||
"min-width" => style.min_width = dimension_value(value),
|
||||
"min-height" => style.min_height = dimension_value(value),
|
||||
"max-width" => style.max_width = dimension_value(value),
|
||||
@@ -2127,6 +2138,30 @@ mod tests {
|
||||
assert_eq!(s.height, crate::Dimension::Auto);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn box_sizing_defaults_to_content_box_and_parses_both_keywords() {
|
||||
assert_eq!(
|
||||
compute_style("div", None).box_sizing,
|
||||
crate::BoxSizing::ContentBox
|
||||
);
|
||||
assert_eq!(
|
||||
compute_style("div", Some("box-sizing:border-box")).box_sizing,
|
||||
crate::BoxSizing::BorderBox
|
||||
);
|
||||
assert_eq!(
|
||||
compute_style(
|
||||
"div",
|
||||
Some("box-sizing:border-box;box-sizing:content-box")
|
||||
)
|
||||
.box_sizing,
|
||||
crate::BoxSizing::ContentBox
|
||||
);
|
||||
assert_eq!(
|
||||
compute_style("div", Some("box-sizing:inherit")).box_sizing,
|
||||
crate::BoxSizing::Inherit
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn calc_with_multiply_and_divide() {
|
||||
// The exact shape MediaWiki uses to offset a TOC toggle button into
|
||||
|
||||
Reference in new issue
Block a user