Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

fix(css): use native font size adjustment shorthand semantics

ldm02356a63eff87
diff --git a/Cargo.lock b/Cargo.lock
index 753d1b28e..efe1502ce 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5023,7 +5023,7 @@ dependencies = [
[[package]]
name = "selectors"
version = "0.41.0"
-source = "git+https://github.com/lexmount/stylo?rev=973988b9c592a802eefdc5abe6072dd9ba221385#973988b9c592a802eefdc5abe6072dd9ba221385"
+source = "git+https://github.com/lexmount/stylo?rev=2fe93b20d5ba764842071c2290d0281805d80656#2fe93b20d5ba764842071c2290d0281805d80656"
dependencies = [
"bitflags",
"cssparser",
@@ -5153,7 +5153,7 @@ dependencies = [
[[package]]
name = "servo_arc"
version = "0.5.0"
-source = "git+https://github.com/lexmount/stylo?rev=973988b9c592a802eefdc5abe6072dd9ba221385#973988b9c592a802eefdc5abe6072dd9ba221385"
+source = "git+https://github.com/lexmount/stylo?rev=2fe93b20d5ba764842071c2290d0281805d80656#2fe93b20d5ba764842071c2290d0281805d80656"
dependencies = [
"serde",
"stable_deref_trait",
@@ -5482,7 +5482,7 @@ dependencies = [
[[package]]
name = "stylo"
version = "0.22.0"
-source = "git+https://github.com/lexmount/stylo?rev=973988b9c592a802eefdc5abe6072dd9ba221385#973988b9c592a802eefdc5abe6072dd9ba221385"
+source = "git+https://github.com/lexmount/stylo?rev=2fe93b20d5ba764842071c2290d0281805d80656#2fe93b20d5ba764842071c2290d0281805d80656"
dependencies = [
"app_units",
"arrayvec",
@@ -5538,7 +5538,7 @@ dependencies = [
[[package]]
name = "stylo_atoms"
version = "0.22.0"
-source = "git+https://github.com/lexmount/stylo?rev=973988b9c592a802eefdc5abe6072dd9ba221385#973988b9c592a802eefdc5abe6072dd9ba221385"
+source = "git+https://github.com/lexmount/stylo?rev=2fe93b20d5ba764842071c2290d0281805d80656#2fe93b20d5ba764842071c2290d0281805d80656"
dependencies = [
"string_cache 0.11.0",
"string_cache_codegen 0.11.2",
@@ -5547,7 +5547,7 @@ dependencies = [
[[package]]
name = "stylo_derive"
version = "0.22.0"
-source = "git+https://github.com/lexmount/stylo?rev=973988b9c592a802eefdc5abe6072dd9ba221385#973988b9c592a802eefdc5abe6072dd9ba221385"
+source = "git+https://github.com/lexmount/stylo?rev=2fe93b20d5ba764842071c2290d0281805d80656#2fe93b20d5ba764842071c2290d0281805d80656"
dependencies = [
"darling",
"proc-macro2",
@@ -5559,7 +5559,7 @@ dependencies = [
[[package]]
name = "stylo_dom"
version = "0.22.0"
-source = "git+https://github.com/lexmount/stylo?rev=973988b9c592a802eefdc5abe6072dd9ba221385#973988b9c592a802eefdc5abe6072dd9ba221385"
+source = "git+https://github.com/lexmount/stylo?rev=2fe93b20d5ba764842071c2290d0281805d80656#2fe93b20d5ba764842071c2290d0281805d80656"
dependencies = [
"bitflags",
"stylo_malloc_size_of",
@@ -5568,7 +5568,7 @@ dependencies = [
[[package]]
name = "stylo_malloc_size_of"
version = "0.22.0"
-source = "git+https://github.com/lexmount/stylo?rev=973988b9c592a802eefdc5abe6072dd9ba221385#973988b9c592a802eefdc5abe6072dd9ba221385"
+source = "git+https://github.com/lexmount/stylo?rev=2fe93b20d5ba764842071c2290d0281805d80656#2fe93b20d5ba764842071c2290d0281805d80656"
dependencies = [
"app_units",
"cssparser",
@@ -5586,7 +5586,7 @@ dependencies = [
[[package]]
name = "stylo_static_prefs"
version = "0.22.0"
-source = "git+https://github.com/lexmount/stylo?rev=973988b9c592a802eefdc5abe6072dd9ba221385#973988b9c592a802eefdc5abe6072dd9ba221385"
+source = "git+https://github.com/lexmount/stylo?rev=2fe93b20d5ba764842071c2290d0281805d80656#2fe93b20d5ba764842071c2290d0281805d80656"
dependencies = [
"toml",
]
@@ -5605,7 +5605,7 @@ dependencies = [
[[package]]
name = "stylo_traits"
version = "0.22.0"
-source = "git+https://github.com/lexmount/stylo?rev=973988b9c592a802eefdc5abe6072dd9ba221385#973988b9c592a802eefdc5abe6072dd9ba221385"
+source = "git+https://github.com/lexmount/stylo?rev=2fe93b20d5ba764842071c2290d0281805d80656#2fe93b20d5ba764842071c2290d0281805d80656"
dependencies = [
"app_units",
"bitflags",
@@ -5915,7 +5915,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "to_shmem"
version = "0.6.0"
-source = "git+https://github.com/lexmount/stylo?rev=973988b9c592a802eefdc5abe6072dd9ba221385#973988b9c592a802eefdc5abe6072dd9ba221385"
+source = "git+https://github.com/lexmount/stylo?rev=2fe93b20d5ba764842071c2290d0281805d80656#2fe93b20d5ba764842071c2290d0281805d80656"
dependencies = [
"cssparser",
"servo_arc",
@@ -5928,7 +5928,7 @@ dependencies = [
[[package]]
name = "to_shmem_derive"
version = "0.2.0"
-source = "git+https://github.com/lexmount/stylo?rev=973988b9c592a802eefdc5abe6072dd9ba221385#973988b9c592a802eefdc5abe6072dd9ba221385"
+source = "git+https://github.com/lexmount/stylo?rev=2fe93b20d5ba764842071c2290d0281805d80656#2fe93b20d5ba764842071c2290d0281805d80656"
dependencies = [
"darling",
"proc-macro2",
diff --git a/Cargo.toml b/Cargo.toml
index 9b4144584..d5d2f0ef7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -112,13 +112,13 @@ curl-sys = { git = "https://github.com/lexmount/curl-rust", rev = "0392e12475d8d
cookie = { git = "https://github.com/ldm0/cookie-rs", branch = "priority" }
v8 = { path = "vendor/v8-152.2.0" }
deno_v8 = { path = "vendor/deno_v8-0.3.0" }
-selectors = { git = "https://github.com/lexmount/stylo", rev = "973988b9c592a802eefdc5abe6072dd9ba221385" }
-servo_arc = { git = "https://github.com/lexmount/stylo", rev = "973988b9c592a802eefdc5abe6072dd9ba221385" }
-stylo = { git = "https://github.com/lexmount/stylo", rev = "973988b9c592a802eefdc5abe6072dd9ba221385" }
-stylo_atoms = { git = "https://github.com/lexmount/stylo", rev = "973988b9c592a802eefdc5abe6072dd9ba221385" }
-stylo_dom = { git = "https://github.com/lexmount/stylo", rev = "973988b9c592a802eefdc5abe6072dd9ba221385" }
-stylo_static_prefs = { git = "https://github.com/lexmount/stylo", rev = "973988b9c592a802eefdc5abe6072dd9ba221385" }
-stylo_traits = { git = "https://github.com/lexmount/stylo", rev = "973988b9c592a802eefdc5abe6072dd9ba221385" }
+selectors = { git = "https://github.com/lexmount/stylo", rev = "2fe93b20d5ba764842071c2290d0281805d80656" }
+servo_arc = { git = "https://github.com/lexmount/stylo", rev = "2fe93b20d5ba764842071c2290d0281805d80656" }
+stylo = { git = "https://github.com/lexmount/stylo", rev = "2fe93b20d5ba764842071c2290d0281805d80656" }
+stylo_atoms = { git = "https://github.com/lexmount/stylo", rev = "2fe93b20d5ba764842071c2290d0281805d80656" }
+stylo_dom = { git = "https://github.com/lexmount/stylo", rev = "2fe93b20d5ba764842071c2290d0281805d80656" }
+stylo_static_prefs = { git = "https://github.com/lexmount/stylo", rev = "2fe93b20d5ba764842071c2290d0281805d80656" }
+stylo_traits = { git = "https://github.com/lexmount/stylo", rev = "2fe93b20d5ba764842071c2290d0281805d80656" }
svgtypes = { git = "https://github.com/lexmount/svgtypes", branch = "moli" }
taffy = { git = "https://github.com/ldm0/taffy", rev = "0a337871fa44db7d48571b06668f92737eefa8c2" }
diff --git a/moli-renderer-v8/src/native_bridge/element/styles/declaration/values/computed_properties/font.rs b/moli-renderer-v8/src/native_bridge/element/styles/declaration/values/computed_properties/font.rs
index d6859d855..1c376462c 100644
--- a/moli-renderer-v8/src/native_bridge/element/styles/declaration/values/computed_properties/font.rs
+++ b/moli-renderer-v8/src/native_bridge/element/styles/declaration/values/computed_properties/font.rs
@@ -5,11 +5,6 @@ pub(super) fn computed_shorthand(
handle: DomHandle,
resolution: StyleResolutionContext<'_>,
) -> String {
- // Servo's font schema excludes this compatibility longhand. It is reset
- // by font, but a non-initial value cannot be expressed by the shorthand.
- if resolution.computed_property(runtime, handle, "font-size-adjust") != "none" {
- return String::new();
- }
let mut block = moli_css_parse::CssDeclarationBlock::default();
for longhand in style::properties::ShorthandId::Font.longhands() {
let property = longhand.name();
diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style/css_computed_font.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style/css_computed_font.rs
index 0d5395af2..62e11a4bc 100644
--- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style/css_computed_font.rs
+++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style/css_computed_font.rs
@@ -8,3 +8,13 @@ fn css_computed_font_serializes_resolved_longhands_and_retains_values() {
"true"
);
}
+
+#[test]
+fn css_computed_font_size_adjust_uses_native_reset_and_cascade() {
+ let mut vm = new_parsed_test_vm("https://font-size-adjust.test/", "<!doctype html><body>");
+ assert_eq!(
+ vm.eval(include_str!("css_computed_font_size_adjust.js"))
+ .unwrap(),
+ "true"
+ );
+}
diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style/css_computed_font_size_adjust.js b/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style/css_computed_font_size_adjust.js
new file mode 100644
index 000000000..cd49cd03f
--- /dev/null
+++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style/css_computed_font_size_adjust.js
@@ -0,0 +1,50 @@
+(() => {
+ const check = (ok, message) => { if (!ok) throw new Error(message); };
+ for (const doc of [document, document.implementation.createHTMLDocument('')]) {
+ const style = doc.createElement('div').style;
+ style.cssText = 'font:16px serif;font-size-adjust:0';
+ check(style.font === '', 'non-initial size adjustment prevents font serialization');
+ style.font = '12px sans-serif';
+ check(style.fontSizeAdjust === 'none', 'font resets size adjustment');
+ check(style.font === '12px sans-serif', 'font serializes after reset');
+ style.fontSizeAdjust = '0.5';
+ style.setProperty('font', '16px serif', 'important');
+ check(style.fontSizeAdjust === 'none', 'important font resets size adjustment');
+ check(style.getPropertyPriority('font-size-adjust') === 'important', 'reset priority');
+ }
+ const parent = document.createElement('div');
+ const child = document.createElement('div');
+ parent.style.cssText = 'font:20px serif;font-size-adjust:0.75;--font:16px serif';
+ parent.append(child); document.body.append(parent);
+ const computed = getComputedStyle(child);
+ function adjusted(expected) {
+ check(getComputedStyle(child).fontSizeAdjust === expected, 'computed size adjustment: ' + expected);
+ check(computed.fontSizeAdjust === expected, 'live computed size adjustment: ' + expected);
+ }
+ child.style.font = '16px serif';
+ adjusted('none');
+ const retained = computed.font;
+ child.style.fontSizeAdjust = '0';
+ adjusted('0');
+ check(child.style.font === '' && getComputedStyle(child).font === '', 'font cannot express size adjustment');
+ check(computed.font === '', 'unrepresentable computed shorthand');
+ child.style.font = '12px sans-serif';
+ adjusted('none');
+ check(String(retained) === '16px serif', 'retained font value');
+ check(computed.font === '12px sans-serif', 'live declaration observes font reset');
+ for (const keyword of ['initial', 'inherit', 'unset', 'revert', 'revert-layer']) {
+ child.style.cssText = 'font:16px serif;font-size-adjust:0';
+ child.style.font = keyword;
+ check(child.style.fontSizeAdjust === keyword, 'font expands CSS-wide keyword: ' + keyword);
+ adjusted(keyword === 'initial' ? 'none' : '0.75');
+ }
+ child.style.cssText = 'font-size-adjust:0;font:var(--font)';
+ check(child.style.fontSizeAdjust === '', 'pending shorthand substitution');
+ adjusted('none');
+ check(getComputedStyle(child).font === '16px serif', 'valid substituted shorthand');
+ child.style.font = 'var(--missing)';
+ adjusted('0.75');
+ check(getComputedStyle(child).font === '', 'invalid substitution inherits non-initial adjustment');
+ parent.remove();
+ return true;
+})()