Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
fix(cssom): serialize computed font variant shorthand
ldm0e1788dd21673
diff --git a/moli-renderer-v8/src/native_bridge/element/styles/declaration/values.rs b/moli-renderer-v8/src/native_bridge/element/styles/declaration/values.rsindex 00816bdde..1ba3c973e 100644--- a/moli-renderer-v8/src/native_bridge/element/styles/declaration/values.rs+++ b/moli-renderer-v8/src/native_bridge/element/styles/declaration/values.rs@@ -2374,6 +2374,9 @@ fn computed_style_property_value_after_style_update(if property == "text-emphasis" {return computed_text_emphasis_shorthand_value(runtime, handle, context);}+ if property == "font-variant" {+ return computed_font_variant_shorthand_value(runtime, handle, resolution);+ }if property == "border" {return computed_border_shorthand_value(runtime, handle, context);}@@ -2630,6 +2633,18 @@ fn computed_text_emphasis_shorthand_value(format!("{style} {color}")}+fn computed_font_variant_shorthand_value(+ runtime: &JsContextHost,+ handle: DomHandle,+ resolution: StyleResolutionContext<'_>,+) -> String {+ let values = font_variant_longhands()+ .iter()+ .map(|property| resolution.computed_property(runtime, handle, property))+ .collect::<Vec<_>>();+ serialize_font_variant_shorthand_values(&values).unwrap_or_default()+}+fn computed_webkit_text_stroke_shorthand_value(runtime: &JsContextHost,handle: DomHandle,diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style.rsindex f9c564573..1191edbff 100644--- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style.rs+++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style.rs@@ -11873,6 +11873,48 @@ fn computed_style_uses_stylo_owned_extended_longhands() {}}+#[test]+fn computed_font_variant_serializes_from_computed_longhands() {+ let mut vm = new_parsed_test_vm(+ "https://font-variant-computed-shorthand.test/",+ r#"<html><head><style>+ #target { font-variant: small-caps; }+ </style></head><body>+ <div id="target"></div>+ <svg><text id="svg-target" font-variant="small-caps"></text></svg>+ </body></html>"#,+ );++ let result = vm+ .eval(+ r#"+(() => {+ const target = document.getElementById('target');+ const computed = getComputedStyle(target);+ const values = [computed.fontVariant];++ target.style.fontVariant = 'common-ligatures small-caps oldstyle-nums';+ values.push(computed.fontVariant);+ target.style.fontVariant = 'none';+ values.push(computed.fontVariant);+ target.style.fontVariant = 'normal';+ target.style.fontVariantNumeric = 'tabular-nums diagonal-fractions';+ values.push(computed.fontVariant);+ target.style.fontVariantNumeric = 'normal';+ values.push(computed.fontVariant);+ values.push(getComputedStyle(document.getElementById('svg-target')).fontVariant);+ return values.join('|');+})()+"#,+ )+ .expect("computed font-variant shorthand should evaluate");++ assert_eq!(+ result,+ "small-caps|common-ligatures small-caps oldstyle-nums|none|tabular-nums diagonal-fractions|normal|small-caps"+ );+}+#[test]fn computed_style_resolves_zoom() {let mut vm = new_parsed_test_vm(