Unify CSS feature query truth
This commit is contained in:
1 parent
33d94eaf85
commit
d41a4b88e6
5 files changed
+749
-29
No files matched your search
@@ -2457,6 +2457,7 @@ pub fn build_extension() -> Extension {
|
||||
ops.push(op_image_metadata());
|
||||
ops.push(op_layout_geometry());
|
||||
ops.push(op_computed_style());
|
||||
ops.push(op_css_supports());
|
||||
ops.push(op_layout_metrics());
|
||||
ops.push(op_scroll_offset());
|
||||
ops.push(op_scroll_to());
|
||||
@@ -2703,6 +2704,15 @@ fn op_computed_style(state: &OpState, #[string] nid_str: String) -> String {
|
||||
serde_json::Value::Object(object).to_string()
|
||||
}
|
||||
|
||||
/// Use the renderer's declaration parser as the single feature-query source
|
||||
/// of truth. Keeping this bridge synchronous and state-free makes the common
|
||||
/// two-argument `CSS.supports()` overload a single native call.
|
||||
#[cfg(feature = "render")]
|
||||
#[op2(fast)]
|
||||
fn op_css_supports(#[string] name: &str, #[string] value: &str) -> bool {
|
||||
obscura_render::style::supports_declaration(name, value)
|
||||
}
|
||||
|
||||
/// Root scrolling overflow in CSS pixels. The JS CSSOM probes this op only in
|
||||
/// render builds; default scraping builds retain their deliberately unbounded
|
||||
/// synthetic scrolling behavior.
|
||||
|
||||
@@ -3086,13 +3086,19 @@ mod tests {
|
||||
CSS.supports("color", "light-dark(rgb(1, 2, 3), color-mix(in srgb, white 50%, black))"),
|
||||
CSS.supports("(color:light-dark(red, light-dark(white, black)))"),
|
||||
CSS.supports("color", "light-dark(red)"),
|
||||
CSS.supports("color", "light-dark(red, rgb(1, 2, 3)")
|
||||
CSS.supports("color", "light-dark(red, rgb(1, 2, 3)"),
|
||||
CSS.supports("border", "2px dashed red"),
|
||||
CSS.supports("border-width", "10%"),
|
||||
CSS.supports("word-break", "break-all"),
|
||||
CSS.supports("filter", "blur(2px)"),
|
||||
CSS.supports("content", "attr(data-label)"),
|
||||
CSS.supports("display", "grid;")
|
||||
])"#,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
result,
|
||||
serde_json::json!("[false,false,false,true,false,true,true,true,false,false,false,true,false,true,true,false,false]")
|
||||
serde_json::json!("[false,false,false,false,false,true,true,true,false,false,false,true,false,true,true,false,false,true,false,true,false,true,false]")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user