render: shape atomic generated controls

This commit is contained in:
SGavrl committed 2026-07-26 21:51:34 +00:00
1 parent 9ffc071ce0
commit 237ba35639
6 files changed
+271 -26

No files matched your search

+16
View File
@@ -107,6 +107,14 @@ pub fn ua_style(tag: &str) -> LayoutStyle {
} else if tag == "a" {
style.color = Some([0, 0, 238, 255]); // blue
style.underline = Some(true); // UA default: links are underlined
} else if tag == "button" {
// HTML buttons are inline-block controls whose anonymous inner
// content is centered by the browser UA sheet. Keep the atomic outer
// participation separate from the internal text alignment: authored
// display/text-align declarations still cascade over both values.
style.display = Display::Inline;
style.is_inline_block = true;
style.text_align = Some(taffy::AlignItems::CENTER);
} else if tag == "input" {
// Native text controls are atomic inline-level boxes with their own
// platform font and intrinsic border-box dimensions; they do not
@@ -3528,6 +3536,14 @@ mod tests {
assert_eq!(collapsed.border_collapse, Some(true));
}
#[test]
fn button_ua_style_is_a_centered_atomic_inline_box() {
let button = ua_style("button");
assert_eq!(button.display, crate::Display::Inline);
assert!(button.is_inline_block);
assert_eq!(button.text_align, Some(taffy::AlignItems::CENTER));
}
#[test]
fn border_none_clears_native_and_per_side_widths() {
let input = compute_style("input", Some("border:none"));