Skip to content

armgit / moli

Public Imported from GitHub
0

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

feat(layout): update Taffy and Stylo forks with current Blitz adapters

ldm0e78f5a33b2b6
diff --git a/Cargo.lock b/Cargo.lock
index 5e908ce31..952cf3322 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -889,14 +889,14 @@ dependencies = [
[[package]]
name = "cssparser"
-version = "0.37.0"
+version = "0.38.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8c9cdaae01d5ed7882b04d795e7f752f46ff52d2fa3b50a20d28c464510bba98"
+checksum = "11119743ad110e8c1bdccd930d7f5c30c99e5fc76a7b63ec9807e84eef0c5f59"
dependencies = [
"cssparser-macros",
"dtoa-short",
"itoa",
- "phf",
+ "phf 0.14.0",
"serde",
"smallvec",
]
@@ -1822,7 +1822,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46a1761807faccc9a19e86944bbf40610014066306f96edcdedc2fb714bcb7b8"
dependencies = [
"log",
- "markup5ever",
+ "markup5ever 0.39.0",
+]
+
+[[package]]
+name = "html5ever"
+version = "0.40.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "456a1a377e608e555d22ddab27ac0114bc7a7b4199078108e34c2aeae6c9b130"
+dependencies = [
+ "log",
+ "markup5ever 0.40.0",
+ "memchr",
]
[[package]]
@@ -2476,7 +2487,18 @@ checksum = "7122d987ec5f704ee56f6e5b41a7d93722e9aae27ae07cafa4036c4d3f9757de"
dependencies = [
"log",
"tendril",
- "web_atoms",
+ "web_atoms 0.2.3",
+]
+
+[[package]]
+name = "markup5ever"
+version = "0.40.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ab3dc68ac4a0f5719e560136778c1ee716e296030d75dbd4484e37e39e3a842"
+dependencies = [
+ "log",
+ "tendril",
+ "web_atoms 0.3.0",
]
[[package]]
@@ -2485,10 +2507,10 @@ version = "0.39.0+unofficial"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ac010f19d6c4af81eeb4018a39d7a115de9d285af45c126a4ac02e6fc5716b7"
dependencies = [
- "html5ever",
- "markup5ever",
+ "html5ever 0.39.0",
+ "markup5ever 0.39.0",
"tendril",
- "xml5ever",
+ "xml5ever 0.39.0",
]
[[package]]
@@ -2650,7 +2672,7 @@ name = "moli-charset-parser"
version = "0.1.0"
dependencies = [
"encoding_rs",
- "html5ever",
+ "html5ever 0.40.1",
]
[[package]]
@@ -2811,7 +2833,7 @@ dependencies = [
name = "moli-dom"
version = "0.1.0"
dependencies = [
- "html5ever",
+ "html5ever 0.40.1",
"indexmap",
"moli-css-parse",
"moli-html-input-temporal",
@@ -2935,7 +2957,7 @@ dependencies = [
name = "moli-html2md"
version = "0.1.0"
dependencies = [
- "html5ever",
+ "html5ever 0.39.0",
"markup5ever_rcdom",
"pulldown-cmark",
"serde_json",
@@ -3129,15 +3151,15 @@ name = "moli-parser"
version = "0.1.0"
dependencies = [
"anyhow",
- "html5ever",
- "markup5ever",
+ "html5ever 0.40.1",
+ "markup5ever 0.40.0",
"moli-dom",
"moli-fetch",
"moli-page-types",
"moli-script",
"moli-stylesheet-blocking",
"url",
- "xml5ever",
+ "xml5ever 0.40.0",
"xmlparser",
]
@@ -3288,13 +3310,13 @@ dependencies = [
"futures-util",
"hashlink",
"html-escape",
- "html5ever",
+ "html5ever 0.40.1",
"http",
"httpdate",
"indexmap",
"kurbo",
"lopdf",
- "markup5ever",
+ "markup5ever 0.40.0",
"moli-action-window",
"moli-broadcast-channel",
"moli-browser-profile",
@@ -3379,7 +3401,7 @@ dependencies = [
"wasm_dep_analyzer",
"widestring",
"wuff",
- "xml5ever",
+ "xml5ever 0.39.0",
"xmlparser",
]
@@ -3720,7 +3742,7 @@ dependencies = [
"anyhow",
"axum",
"futures-util",
- "html5ever",
+ "html5ever 0.40.1",
"parking_lot",
"rcgen",
"serde",
@@ -3736,7 +3758,7 @@ name = "moli-xpath"
version = "0.1.0"
dependencies = [
"log",
- "markup5ever",
+ "markup5ever 0.40.0",
]
[[package]]
@@ -4027,7 +4049,7 @@ version = "0.127.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c50246449a5fa669debd2debeb90be4c30f0a3a2e954f852ec40e5ef49701285"
dependencies = [
- "phf",
+ "phf 0.13.1",
"proc-macro2",
"quote",
"syn 2.0.117",
@@ -4130,7 +4152,7 @@ dependencies = [
"oxc_diagnostics",
"oxc_span",
"oxc_str",
- "phf",
+ "phf 0.13.1",
"rustc-hash 2.1.1",
"unicode-id-start",
]
@@ -4177,7 +4199,7 @@ dependencies = [
"oxc_index",
"oxc_span",
"oxc_str",
- "phf",
+ "phf 0.13.1",
"unicode-id-start",
]
@@ -4312,8 +4334,19 @@ version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf"
dependencies = [
- "phf_macros",
- "phf_shared",
+ "phf_macros 0.13.1",
+ "phf_shared 0.13.1",
+ "serde",
+]
+
+[[package]]
+name = "phf"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "010378780309880b08997fae13be7834dba947d36393bd372f2b1556deb2a2f6"
+dependencies = [
+ "phf_macros 0.14.0",
+ "phf_shared 0.14.0",
"serde",
]
@@ -4323,8 +4356,18 @@ version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49aa7f9d80421bca176ca8dbfebe668cc7a2684708594ec9f3c0db0805d5d6e1"
dependencies = [
- "phf_generator",
- "phf_shared",
+ "phf_generator 0.13.1",
+ "phf_shared 0.13.1",
+]
+
+[[package]]
+name = "phf_codegen"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "41b585a510fb76fdebead6897982ef2a03a21d8e6cbcca904999742a4afc6ffe"
+dependencies = [
+ "phf_generator 0.14.0",
+ "phf_shared 0.14.0",
]
[[package]]
@@ -4334,7 +4377,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "135ace3a761e564ec88c03a77317a7c6b80bb7f7135ef2544dbe054243b89737"
dependencies = [
"fastrand",
- "phf_shared",
+ "phf_shared 0.13.1",
+]
+
+[[package]]
+name = "phf_generator"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aeb62e0959d5a1bebc965f4d15d9e2b7cea002b6b0f5ba8cde6cc26738467100"
+dependencies = [
+ "fastrand",
+ "phf_shared 0.14.0",
]
[[package]]
@@ -4343,8 +4396,21 @@ version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "812f032b54b1e759ccd5f8b6677695d5268c588701effba24601f6932f8269ef"
dependencies = [
- "phf_generator",
- "phf_shared",
+ "phf_generator 0.13.1",
+ "phf_shared 0.13.1",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.117",
+]
+
+[[package]]
+name = "phf_macros"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5fa8d0ca26d424d27630da600c6624696e7dec8bf7b3b492b383c5dc49e5e085"
+dependencies = [
+ "phf_generator 0.14.0",
+ "phf_shared 0.14.0",
"proc-macro2",
"quote",
"syn 2.0.117",
@@ -4359,6 +4425,15 @@ dependencies = [
"siphasher",
]
+[[package]]
+name = "phf_shared"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c6fd9027e2d9319be6349febd1db4e8d02aa544921200c9b777720ac34a3aa89"
+dependencies = [
+ "siphasher",
+]
+
[[package]]
name = "pico-args"
version = "0.5.0"
@@ -4922,16 +4997,14 @@ dependencies = [
[[package]]
name = "selectors"
-version = "0.40.0"
-source = "git+https://github.com/lexmount/stylo?rev=0c7e8baf63b6714e7614834fadbc09710f3c3d27#0c7e8baf63b6714e7614834fadbc09710f3c3d27"
+version = "0.41.0"
+source = "git+https://github.com/lexmount/stylo?rev=2fce24a36f03223f9ad75672bf1d8b35e47fc285#2fce24a36f03223f9ad75672bf1d8b35e47fc285"
dependencies = [
"bitflags",
"cssparser",
"derive_more",
"log",
"new_debug_unreachable",
- "phf",
- "phf_codegen",
"precomputed-hash",
"rustc-hash 2.1.1",
"servo_arc",
@@ -5054,8 +5127,8 @@ dependencies = [
[[package]]
name = "servo_arc"
-version = "0.4.3"
-source = "git+https://github.com/lexmount/stylo?rev=0c7e8baf63b6714e7614834fadbc09710f3c3d27#0c7e8baf63b6714e7614834fadbc09710f3c3d27"
+version = "0.5.0"
+source = "git+https://github.com/lexmount/stylo?rev=2fce24a36f03223f9ad75672bf1d8b35e47fc285#2fce24a36f03223f9ad75672bf1d8b35e47fc285"
dependencies = [
"serde",
"stable_deref_trait",
@@ -5275,7 +5348,20 @@ checksum = "a18596f8c785a729f2819c0f6a7eae6ebeebdfffbfe4214ae6b087f690e31901"
dependencies = [
"new_debug_unreachable",
"parking_lot",
- "phf_shared",
+ "phf_shared 0.13.1",
+ "precomputed-hash",
+ "serde",
+]
+
+[[package]]
+name = "string_cache"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ffa8a5dbe8b3f0bbe29d4c3225daafaeead63afdc1b65fc4c01a1384166038e6"
+dependencies = [
+ "new_debug_unreachable",
+ "parking_lot",
+ "phf_shared 0.14.0",
"precomputed-hash",
"serde",
]
@@ -5286,8 +5372,20 @@ version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "585635e46db231059f76c5849798146164652513eb9e8ab2685939dd90f29b69"
dependencies = [
- "phf_generator",
- "phf_shared",
+ "phf_generator 0.13.1",
+ "phf_shared 0.13.1",
+ "proc-macro2",
+ "quote",
+]
+
+[[package]]
+name = "string_cache_codegen"
+version = "0.11.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "928dcdf75e47626b3617a976ec205d9f057584c371c1f23b782129268d0e6edc"
+dependencies = [
+ "phf_generator 0.14.0",
+ "phf_shared 0.14.0",
"proc-macro2",
"quote",
]
@@ -5341,8 +5439,8 @@ dependencies = [
[[package]]
name = "stylo"
-version = "0.20.0"
-source = "git+https://github.com/lexmount/stylo?rev=0c7e8baf63b6714e7614834fadbc09710f3c3d27#0c7e8baf63b6714e7614834fadbc09710f3c3d27"
+version = "0.22.0"
+source = "git+https://github.com/lexmount/stylo?rev=2fce24a36f03223f9ad75672bf1d8b35e47fc285#2fce24a36f03223f9ad75672bf1d8b35e47fc285"
dependencies = [
"app_units",
"arrayvec",
@@ -5376,7 +5474,7 @@ dependencies = [
"smallbitvec",
"smallvec",
"static_assertions",
- "string_cache",
+ "string_cache 0.11.0",
"strum",
"strum_macros",
"stylo_atoms",
@@ -5392,22 +5490,22 @@ dependencies = [
"url",
"void",
"walkdir",
- "web_atoms",
+ "web_atoms 0.3.0",
]
[[package]]
name = "stylo_atoms"
-version = "0.20.0"
-source = "git+https://github.com/lexmount/stylo?rev=0c7e8baf63b6714e7614834fadbc09710f3c3d27#0c7e8baf63b6714e7614834fadbc09710f3c3d27"
+version = "0.22.0"
+source = "git+https://github.com/lexmount/stylo?rev=2fce24a36f03223f9ad75672bf1d8b35e47fc285#2fce24a36f03223f9ad75672bf1d8b35e47fc285"
dependencies = [
- "string_cache",
- "string_cache_codegen",
+ "string_cache 0.11.0",
+ "string_cache_codegen 0.11.2",
]
[[package]]
name = "stylo_derive"
-version = "0.20.0"
-source = "git+https://github.com/lexmount/stylo?rev=0c7e8baf63b6714e7614834fadbc09710f3c3d27#0c7e8baf63b6714e7614834fadbc09710f3c3d27"
+version = "0.22.0"
+source = "git+https://github.com/lexmount/stylo?rev=2fce24a36f03223f9ad75672bf1d8b35e47fc285#2fce24a36f03223f9ad75672bf1d8b35e47fc285"
dependencies = [
"darling",
"proc-macro2",
@@ -5418,8 +5516,8 @@ dependencies = [
[[package]]
name = "stylo_dom"
-version = "0.20.0"
-source = "git+https://github.com/lexmount/stylo?rev=0c7e8baf63b6714e7614834fadbc09710f3c3d27#0c7e8baf63b6714e7614834fadbc09710f3c3d27"
+version = "0.22.0"
+source = "git+https://github.com/lexmount/stylo?rev=2fce24a36f03223f9ad75672bf1d8b35e47fc285#2fce24a36f03223f9ad75672bf1d8b35e47fc285"
dependencies = [
"bitflags",
"stylo_malloc_size_of",
@@ -5427,34 +5525,36 @@ dependencies = [
[[package]]
name = "stylo_malloc_size_of"
-version = "0.20.0"
-source = "git+https://github.com/lexmount/stylo?rev=0c7e8baf63b6714e7614834fadbc09710f3c3d27#0c7e8baf63b6714e7614834fadbc09710f3c3d27"
+version = "0.22.0"
+source = "git+https://github.com/lexmount/stylo?rev=2fce24a36f03223f9ad75672bf1d8b35e47fc285#2fce24a36f03223f9ad75672bf1d8b35e47fc285"
dependencies = [
"app_units",
"cssparser",
"euclid",
+ "parking_lot",
"selectors",
"servo_arc",
"smallbitvec",
"smallvec",
- "string_cache",
+ "string_cache 0.11.0",
"thin-vec",
"void",
]
[[package]]
name = "stylo_static_prefs"
-version = "0.20.0"
-source = "git+https://github.com/lexmount/stylo?rev=0c7e8baf63b6714e7614834fadbc09710f3c3d27#0c7e8baf63b6714e7614834fadbc09710f3c3d27"
+version = "0.22.0"
+source = "git+https://github.com/lexmount/stylo?rev=2fce24a36f03223f9ad75672bf1d8b35e47fc285#2fce24a36f03223f9ad75672bf1d8b35e47fc285"
dependencies = [
"toml",
]
[[package]]
name = "stylo_taffy"
-version = "0.3.0-beta.1"
-source = "git+https://github.com/DioxusLabs/blitz?rev=5081c65811a4396f5a99b2e0aca542a4a4a6606f#5081c65811a4396f5a99b2e0aca542a4a4a6606f"
+version = "0.3.0-beta.4"
+source = "git+https://github.com/DioxusLabs/blitz?rev=fb8d6c15e9ce062b3b41e71cd48988f0093506cc#fb8d6c15e9ce062b3b41e71cd48988f0093506cc"
dependencies = [
+ "bitflags",
"stylo",
"stylo_atoms",
"taffy",
@@ -5462,8 +5562,8 @@ dependencies = [
[[package]]
name = "stylo_traits"
-version = "0.20.0"
-source = "git+https://github.com/lexmount/stylo?rev=0c7e8baf63b6714e7614834fadbc09710f3c3d27#0c7e8baf63b6714e7614834fadbc09710f3c3d27"
+version = "0.22.0"
+source = "git+https://github.com/lexmount/stylo?rev=2fce24a36f03223f9ad75672bf1d8b35e47fc285#2fce24a36f03223f9ad75672bf1d8b35e47fc285"
dependencies = [
"app_units",
"bitflags",
@@ -5549,10 +5649,9 @@ dependencies = [
[[package]]
name = "taffy"
-version = "0.13.0"
-source = "git+https://github.com/ldm0/taffy?rev=3c19aa124ebcef6320a4e84e141be19f4af659c3#3c19aa124ebcef6320a4e84e141be19f4af659c3"
+version = "0.15.0"
+source = "git+https://github.com/ldm0/taffy?rev=e2ce07300697a9d8196117cd343e7b158ae5320d#e2ce07300697a9d8196117cd343e7b158ae5320d"
dependencies = [
- "arrayvec",
"serde",
"slotmap",
"smallvec",
@@ -5565,7 +5664,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
dependencies = [
"fastrand",
- "getrandom 0.3.4",
+ "getrandom 0.4.3",
"once_cell",
"rustix 1.1.4",
"windows-sys 0.61.2",
@@ -5773,21 +5872,21 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "to_shmem"
-version = "0.5.0"
-source = "git+https://github.com/lexmount/stylo?rev=0c7e8baf63b6714e7614834fadbc09710f3c3d27#0c7e8baf63b6714e7614834fadbc09710f3c3d27"
+version = "0.6.0"
+source = "git+https://github.com/lexmount/stylo?rev=2fce24a36f03223f9ad75672bf1d8b35e47fc285#2fce24a36f03223f9ad75672bf1d8b35e47fc285"
dependencies = [
"cssparser",
"servo_arc",
"smallbitvec",
"smallvec",
- "string_cache",
+ "string_cache 0.11.0",
"thin-vec",
]
[[package]]
name = "to_shmem_derive"
-version = "0.1.0"
-source = "git+https://github.com/lexmount/stylo?rev=0c7e8baf63b6714e7614834fadbc09710f3c3d27#0c7e8baf63b6714e7614834fadbc09710f3c3d27"
+version = "0.2.0"
+source = "git+https://github.com/lexmount/stylo?rev=2fce24a36f03223f9ad75672bf1d8b35e47fc285#2fce24a36f03223f9ad75672bf1d8b35e47fc285"
dependencies = [
"darling",
"proc-macro2",
@@ -6405,10 +6504,22 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57a9779e9f04d2ac1ce317aee707aa2f6b773afba7b931222bff6983843b1576"
dependencies = [
- "phf",
- "phf_codegen",
- "string_cache",
- "string_cache_codegen",
+ "phf 0.13.1",
+ "phf_codegen 0.13.1",
+ "string_cache 0.9.0",
+ "string_cache_codegen 0.6.1",
+]
+
+[[package]]
+name = "web_atoms"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7572660c8890448ba236b7376f27e389c6a7e1c70195622faced601f855c0ada"
+dependencies = [
+ "phf 0.14.0",
+ "phf_codegen 0.14.0",
+ "string_cache 0.11.0",
+ "string_cache_codegen 0.11.2",
]
[[package]]
@@ -6743,9 +6854,19 @@ dependencies = [
[[package]]
name = "xml5ever"
version = "0.39.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5ab627f34ff61b80d756180d556f9c68801d836d271b3b8c094504ceca69d221"
+dependencies = [
+ "log",
+ "markup5ever 0.39.0",
+]
+
+[[package]]
+name = "xml5ever"
+version = "0.40.0"
dependencies = [
"log",
- "markup5ever",
+ "markup5ever 0.40.0",
]
[[package]]
diff --git a/Cargo.toml b/Cargo.toml
index 64813e55f..4ae70267a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -92,7 +92,7 @@ members = [
"moli-http-cache",
"moli-wpt-compat"
]
-exclude = ["vendor/xml5ever-0.39.0"]
+exclude = ["vendor/xml5ever-0.40.0"]
[workspace.package]
license = "MIT OR Apache-2.0"
@@ -103,21 +103,24 @@ fontique = { git = "https://github.com/lexmount/parley", rev = "a18cfc3ba6638d44
# Share fontations between shaping, raster rendering and PDF font subsetting.
subsetter = { git = "https://github.com/lexmount/subsetter", rev = "8d3815245835af309559c3b4a872d6a0a54913a9" }
url = { git = "https://github.com/lexmount/rust-url", rev = "ca9fcad2b99f20c30c28a618ad78410f6fd31161" }
-xml5ever = { path = "vendor/xml5ever-0.39.0" }
+xml5ever = { path = "vendor/xml5ever-0.40.0" }
curl = { git = "https://github.com/lexmount/curl-rust", rev = "9d40ca90d8f19ccfd11afe7dd49bc32aab79435c" }
curl-sys = { git = "https://github.com/lexmount/curl-rust", rev = "9d40ca90d8f19ccfd11afe7dd49bc32aab79435c" }
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 = "0c7e8baf63b6714e7614834fadbc09710f3c3d27" }
-servo_arc = { git = "https://github.com/lexmount/stylo", rev = "0c7e8baf63b6714e7614834fadbc09710f3c3d27" }
-stylo = { git = "https://github.com/lexmount/stylo", rev = "0c7e8baf63b6714e7614834fadbc09710f3c3d27" }
-stylo_atoms = { git = "https://github.com/lexmount/stylo", rev = "0c7e8baf63b6714e7614834fadbc09710f3c3d27" }
-stylo_dom = { git = "https://github.com/lexmount/stylo", rev = "0c7e8baf63b6714e7614834fadbc09710f3c3d27" }
-stylo_static_prefs = { git = "https://github.com/lexmount/stylo", rev = "0c7e8baf63b6714e7614834fadbc09710f3c3d27" }
-stylo_traits = { git = "https://github.com/lexmount/stylo", rev = "0c7e8baf63b6714e7614834fadbc09710f3c3d27" }
+selectors = { git = "https://github.com/lexmount/stylo", rev = "2fce24a36f03223f9ad75672bf1d8b35e47fc285" }
+servo_arc = { git = "https://github.com/lexmount/stylo", rev = "2fce24a36f03223f9ad75672bf1d8b35e47fc285" }
+stylo = { git = "https://github.com/lexmount/stylo", rev = "2fce24a36f03223f9ad75672bf1d8b35e47fc285" }
+stylo_atoms = { git = "https://github.com/lexmount/stylo", rev = "2fce24a36f03223f9ad75672bf1d8b35e47fc285" }
+stylo_dom = { git = "https://github.com/lexmount/stylo", rev = "2fce24a36f03223f9ad75672bf1d8b35e47fc285" }
+stylo_static_prefs = { git = "https://github.com/lexmount/stylo", rev = "2fce24a36f03223f9ad75672bf1d8b35e47fc285" }
+stylo_traits = { git = "https://github.com/lexmount/stylo", rev = "2fce24a36f03223f9ad75672bf1d8b35e47fc285" }
svgtypes = { git = "https://github.com/lexmount/svgtypes", branch = "moli" }
-taffy = { git = "https://github.com/ldm0/taffy", rev = "3c19aa124ebcef6320a4e84e141be19f4af659c3" }
+taffy = { git = "https://github.com/ldm0/taffy", rev = "e2ce07300697a9d8196117cd343e7b158ae5320d" }
+
+[patch."https://github.com/DioxusLabs/taffy"]
+taffy = { git = "https://github.com/ldm0/taffy", rev = "e2ce07300697a9d8196117cd343e7b158ae5320d" }
[workspace.lints.clippy]
disallowed_methods = "deny"
diff --git a/moli-charset-parser/Cargo.toml b/moli-charset-parser/Cargo.toml
index fd6ecc292..bbf797b09 100644
--- a/moli-charset-parser/Cargo.toml
+++ b/moli-charset-parser/Cargo.toml
@@ -6,7 +6,7 @@ edition = "2024"
[dependencies]
encoding_rs = "0.8"
-html5ever = "0.39.0"
+html5ever = "0.40"
[lints]
workspace = true
diff --git a/moli-charset-parser/src/prescan.rs b/moli-charset-parser/src/prescan.rs
index 015a5b0f8..7dbf62cfc 100644
--- a/moli-charset-parser/src/prescan.rs
+++ b/moli-charset-parser/src/prescan.rs
@@ -157,14 +157,14 @@ impl MetaCharsetTokenSink {
}
if tag.kind == TagKind::StartTag
- && tag.name.as_ref() == "meta"
+ && &*tag.name == "meta"
&& let Some(encoding) = meta_charset_from_token(tag)
{
*self.result.borrow_mut() = HtmlMetaCharsetScanResult::Found(encoding);
return;
}
- let tag_name = tag.name.as_ref();
+ let tag_name: &str = tag.name.as_ref();
let is_head_compatible = matches!(
tag_name,
"script" | "noscript" | "style" | "link" | "meta" | "object" | "title" | "base"
@@ -276,7 +276,7 @@ fn meta_charset_from_token(tag: &Tag) -> Option<&'static Encoding> {
fn html_token_attr_value(tag: &Tag, name: &str) -> Option<String> {
tag.attrs
.iter()
- .find(|attr| attr.name.local.as_ref().eq_ignore_ascii_case(name))
+ .find(|attr| str::eq_ignore_ascii_case(&attr.name.local, name))
.map(|attr| attr.value.to_string())
}
diff --git a/moli-css-parse/Cargo.toml b/moli-css-parse/Cargo.toml
index 863df412c..d818aac9d 100644
--- a/moli-css-parse/Cargo.toml
+++ b/moli-css-parse/Cargo.toml
@@ -5,9 +5,9 @@ version = "0.1.0"
edition = "2024"
[dependencies]
-cssparser = "0.37"
-stylo = "0.20"
-style_traits = { package = "stylo_traits", version = "0.20" }
+cssparser = "0.38"
+stylo = "0.22"
+style_traits = { package = "stylo_traits", version = "0.22" }
url = "2"
[lints]
diff --git a/moli-css-parse/src/color.rs b/moli-css-parse/src/color.rs
index d97de6294..2fa730973 100644
--- a/moli-css-parse/src/color.rs
+++ b/moli-css-parse/src/color.rs
@@ -1,8 +1,8 @@
//! CSS color parsing helpers shared by HTML and CSS observable surfaces.
-use cssparser::{Parser, ParserInput};
+use cssparser::Parser;
use style::{
- color::AbsoluteColor,
+ color::{AbsoluteColor, ColorSpace},
context::QuirksMode,
custom_properties::AttrTaint,
parser::{Parse, ParserContext},
@@ -38,7 +38,7 @@ pub fn parse_css_color_to_srgb_bytes(value: &str) -> Option<[u8; 4]> {
.ok()?
.resolve_to_absolute(&AbsoluteColor::BLACK),
};
- Some(absolute.to_nscolor().to_le_bytes())
+ Some(absolute_srgb_bytes(absolute))
}
/// Resolve a CSS system-color keyword through the headless Servo light
@@ -47,7 +47,7 @@ pub fn css_system_color_srgb(value: &str) -> Option<(u8, u8, u8)> {
let Color::System(system) = parse_specified_color(value)? else {
return None;
};
- let [red, green, blue, _alpha] = system_color_absolute(system).to_nscolor().to_le_bytes();
+ let [red, green, blue, _alpha] = absolute_srgb_bytes(system_color_absolute(system));
Some((red, green, blue))
}
@@ -68,8 +68,8 @@ pub fn parse_css_color_scheme_flags(value: &str) -> Option<ColorSchemeFlags> {
None,
AttrTaint::default(),
);
- let mut input = ParserInput::new(value);
- Parser::new(&mut input)
+ let input = value;
+ Parser::new(input)
.parse_entirely(|input| ColorScheme::parse(&context, input))
.ok()
.map(|scheme| scheme.bits)
@@ -88,8 +88,8 @@ fn parse_specified_color(value: &str) -> Option<Color> {
None,
AttrTaint::default(),
);
- let mut input = ParserInput::new(value);
- Parser::new(&mut input)
+ let input = value;
+ Parser::new(input)
.parse_entirely(|input| Color::parse(&context, input))
.ok()
}
@@ -139,6 +139,13 @@ fn system_color_absolute(system: SystemColor) -> AbsoluteColor {
AbsoluteColor::srgb_legacy(red, green, blue, 1.0)
}
+fn absolute_srgb_bytes(color: AbsoluteColor) -> [u8; 4] {
+ color
+ .to_color_space(ColorSpace::Srgb)
+ .raw_components()
+ .map(|component| (component * 255.0).round() as u8)
+}
+
#[cfg(test)]
mod tests {
use super::*;
diff --git a/moli-css-parse/src/declaration.rs b/moli-css-parse/src/declaration.rs
index e45af0bca..025d535ee 100644
--- a/moli-css-parse/src/declaration.rs
+++ b/moli-css-parse/src/declaration.rs
@@ -1,6 +1,6 @@
use cssparser::{
- AtRuleParser, CowRcStr, DeclarationParser, ParseError, Parser, ParserInput,
- QualifiedRuleParser, RuleBodyItemParser, RuleBodyParser,
+ AtRuleParser, CowRcStr, DeclarationParser, ParseError, Parser, QualifiedRuleParser,
+ RuleBodyItemParser, RuleBodyParser,
};
use crate::{
@@ -32,8 +32,8 @@ pub fn parse_declaration_list(
style_text: &str,
options: DeclarationParseOptions,
) -> Vec<CssDeclaration> {
- let mut input = ParserInput::new(style_text);
- let mut input = Parser::new(&mut input);
+ let input = style_text;
+ let mut input = Parser::new(input);
let mut parser = DeclarationListParser { options };
RuleBodyParser::new(&mut input, &mut parser)
.filter_map(Result::ok)
@@ -51,9 +51,9 @@ impl<'i> DeclarationParser<'i> for DeclarationListParser {
fn parse_value<'t>(
&mut self,
name: CowRcStr<'i>,
- input: &mut Parser<'i, 't>,
+ input: &mut Parser<'i>,
_declaration_start: &cssparser::ParserState,
- ) -> Result<Self::Declaration, ParseError<'i, Self::Error>> {
+ ) -> Result<Self::Declaration, ParseError<Self::Error>> {
let value_start = input.position();
if !input.is_exhausted() {
let first_token_ok = input
@@ -62,7 +62,7 @@ impl<'i> DeclarationParser<'i> for DeclarationListParser {
if !first_token_ok {
let raw_value = input.slice_from(value_start).trim();
if !crate::value::css_declaration_value_has_valid_var_functions(raw_value) {
- return Err(input.new_custom_error(()));
+ return Err(cssparser::ParseError::custom(()));
}
}
}
@@ -79,7 +79,7 @@ impl<'i> DeclarationParser<'i> for DeclarationListParser {
value
};
if name.is_empty() || (value.is_empty() && !self.options.preserve_empty_values) {
- return Err(input.new_custom_error(()));
+ return Err(cssparser::ParseError::custom(()));
}
Ok(CssDeclaration {
name,
diff --git a/moli-css-parse/src/font_face.rs b/moli-css-parse/src/font_face.rs
index 88239222d..c8cb8cde3 100644
--- a/moli-css-parse/src/font_face.rs
+++ b/moli-css-parse/src/font_face.rs
@@ -1,12 +1,12 @@
-use cssparser::{Parser, ParserInput, Token};
+use cssparser::{Parser, Token};
use crate::unquote_css_string;
pub use style::moli_font_face::{CssFontFace, normalize_font_face_src, parse_font_faces};
pub fn font_load_query_contains_css_wide_keyword(query: &str) -> bool {
- let mut input = ParserInput::new(query);
- let mut input = Parser::new(&mut input);
+ let input = query;
+ let mut input = Parser::new(input);
while let Ok(token) = input.next() {
match token {
Token::Ident(value)
@@ -26,8 +26,8 @@ pub fn font_load_query_is_valid(query: &str) -> bool {
// Servo's Stylo configuration does not parse system fonts. Their entire
// shorthand syntax is one of these six identifiers; use CSS tokens so
// escapes, comments and case folding work without accepting trailing input.
- let mut input = ParserInput::new(query);
- let mut parser = Parser::new(&mut input);
+ let input = query;
+ let mut parser = Parser::new(input);
if let Ok(name) = parser.expect_ident_cloned()
&& matches!(
name.to_ascii_lowercase().as_str(),
diff --git a/moli-css-parse/src/root_margin.rs b/moli-css-parse/src/root_margin.rs
index 4328cb2e3..cccecd37f 100644
--- a/moli-css-parse/src/root_margin.rs
+++ b/moli-css-parse/src/root_margin.rs
@@ -1,8 +1,8 @@
-use cssparser::{Parser, ParserInput, Token};
+use cssparser::{Parser, Token};
pub fn normalize_root_margin(value: &str) -> Option<String> {
- let mut input = ParserInput::new(value);
- let mut parser = Parser::new(&mut input);
+ let input = value;
+ let mut parser = Parser::new(input);
let raw_parts = parser.parse_entirely(parse_root_margin_components).ok()?;
let parts: Vec<&str> = match raw_parts.as_slice() {
[] => return Some("0px 0px 0px 0px".to_owned()),
@@ -32,32 +32,32 @@ pub fn root_margin_components(value: &str, root_width: f64) -> [f64; 4] {
result
}
-fn parse_root_margin_components<'i, 't>(
- input: &mut Parser<'i, 't>,
-) -> Result<Vec<String>, cssparser::ParseError<'i, ()>> {
+fn parse_root_margin_components<'i>(
+ input: &mut Parser<'i>,
+) -> Result<Vec<String>, cssparser::ParseError<()>> {
let mut parts = Vec::new();
while !input.is_exhausted() {
if parts.len() == 4 {
- return Err(input.new_custom_error(()));
+ return Err(cssparser::ParseError::custom(()));
}
parts.push(parse_root_margin_component(input)?);
}
Ok(parts)
}
-fn parse_root_margin_component<'i, 't>(
- input: &mut Parser<'i, 't>,
-) -> Result<String, cssparser::ParseError<'i, ()>> {
+fn parse_root_margin_component<'i>(
+ input: &mut Parser<'i>,
+) -> Result<String, cssparser::ParseError<()>> {
match input.next()?.clone() {
Token::Dimension { value, unit, .. } if unit.eq_ignore_ascii_case("px") => {
format_css_number(value)
.map(|number| format!("{number}px"))
- .ok_or_else(|| input.new_custom_error(()))
+ .ok_or_else(|| cssparser::ParseError::custom(()))
}
Token::Percentage { unit_value, .. } => format_css_number(unit_value * 100.0)
.map(|number| format!("{number}%"))
- .ok_or_else(|| input.new_custom_error(())),
- _ => Err(input.new_custom_error(())),
+ .ok_or_else(|| cssparser::ParseError::custom(())),
+ _ => Err(cssparser::ParseError::custom(())),
}
}
diff --git a/moli-css-parse/src/stylo_stylesheet.rs b/moli-css-parse/src/stylo_stylesheet.rs
index 53ffc760a..5a4fedfe4 100644
--- a/moli-css-parse/src/stylo_stylesheet.rs
+++ b/moli-css-parse/src/stylo_stylesheet.rs
@@ -2,7 +2,7 @@
use std::{borrow::Cow, sync::Once};
-use cssparser::{Parser, ParserInput, ToCss, Token, TokenSerializationType};
+use cssparser::{Parser, ToCss, Token, TokenSerializationType};
pub use style::moli_rule_tree::{
CssConditionRuleView, CssCounterStyleRuleView, CssFontFaceRuleView,
CssFontFeatureValueEntryView, CssFontFeatureValuesRuleView, CssImportRuleView,
@@ -97,8 +97,8 @@ pub fn parse_font_face_descriptor_entry_with_stylo(
/// comments between otherwise adjacent range tokens. Refuse the rewrite when
/// removing a comment would merge two tokens, so invalid input stays invalid.
fn remove_css_comments_without_retokenizing(value: &str) -> Option<String> {
- let mut input = ParserInput::new(value);
- let mut input = Parser::new(&mut input);
+ let input = value;
+ let mut input = Parser::new(input);
let mut output = String::with_capacity(value.len());
let mut original_tokens = Vec::new();
let mut removed_comment = false;
@@ -130,8 +130,8 @@ fn remove_css_comments_without_retokenizing(value: &str) -> Option<String> {
}
fn css_token_fingerprints(value: &str) -> Option<Vec<(TokenSerializationType, String)>> {
- let mut input = ParserInput::new(value);
- let mut input = Parser::new(&mut input);
+ let input = value;
+ let mut input = Parser::new(input);
let mut tokens = Vec::new();
loop {
let Ok(token) = input.next_including_whitespace_and_comments().cloned() else {
@@ -219,8 +219,8 @@ fn parse_descriptor_declaration_block_with_stylo(
rule_type: CssRuleType,
) -> Option<String> {
with_descriptor_declaration_context(rule_type, |context| {
- let mut input = ParserInput::new(style_text);
- let mut input = Parser::new(&mut input);
+ let input = style_text;
+ let mut input = Parser::new(input);
let block = parse_property_declaration_list(context, &mut input, &[]);
Some(declaration_block_css_text(&block))
})
diff --git a/moli-css-parse/src/util.rs b/moli-css-parse/src/util.rs
index 9656c7281..17fcf2ef6 100644
--- a/moli-css-parse/src/util.rs
+++ b/moli-css-parse/src/util.rs
@@ -10,6 +10,7 @@ pub fn canonical_style_property_name(property: &str) -> String {
}
let lowered = property.to_ascii_lowercase();
match lowered.as_str() {
+ "font-width" => "font-stretch".to_owned(),
"color-adjust" => "print-color-adjust".to_owned(),
"-webkit-align-content" => "align-content".to_owned(),
"-webkit-align-items" => "align-items".to_owned(),
diff --git a/moli-css-parse/src/value.rs b/moli-css-parse/src/value.rs
index f1fb03183..292c80b07 100644
--- a/moli-css-parse/src/value.rs
+++ b/moli-css-parse/src/value.rs
@@ -6,9 +6,7 @@
//! projection, and custom-property / var() syntax checks needed before Stylo can
//! resolve substituted values.
-use cssparser::{
- ParseError, Parser, ParserInput, ToCss, Token, TokenSerializationType, serialize_string,
-};
+use cssparser::{ParseError, Parser, ToCss, Token, TokenSerializationType, serialize_string};
/// This is a conservative token trigger, not grammar validation.
pub fn css_value_may_contain_env_function(value: &str) -> bool {
@@ -67,8 +65,8 @@ pub fn normalize_custom_property_specified_value(value: &str) -> Option<String>
/// This preserves component value structure and validates nested env() syntax.
/// It is a serializer, not a property grammar parser.
pub fn normalize_cssom_component_value_serialization(value: &str) -> Option<String> {
- let mut input = ParserInput::new(value);
- let mut input = Parser::new(&mut input);
+ let input = value;
+ let mut input = Parser::new(input);
let mut css_text = String::new();
serialize_cssom_component_values(&mut input, &mut css_text, TokenSerializationType::Nothing)?;
Some(css_text.trim().to_owned())
@@ -76,8 +74,8 @@ pub fn normalize_cssom_component_value_serialization(value: &str) -> Option<Stri
/// Token-serialize component values onto one line without deciding validity.
pub fn serialize_component_values_single_line(value: &str) -> Option<String> {
- let mut input = ParserInput::new(value);
- let mut input = Parser::new(&mut input);
+ let input = value;
+ let mut input = Parser::new(input);
let mut css_text = String::new();
serialize_component_values_preserving_tokens(
&mut input,
@@ -87,8 +85,8 @@ pub fn serialize_component_values_single_line(value: &str) -> Option<String> {
Some(css_text.trim().to_owned())
}
-fn serialize_cssom_component_values<'i, 't>(
- input: &mut Parser<'i, 't>,
+fn serialize_cssom_component_values<'i>(
+ input: &mut Parser<'i>,
css_text: &mut String,
mut previous_token: TokenSerializationType,
) -> Option<TokenSerializationType> {
@@ -120,16 +118,16 @@ fn serialize_cssom_component_values<'i, 't>(
if let Token::Function(name) = &token
&& name.eq_ignore_ascii_case("env")
{
- let nested: Result<(), ParseError<'_, ()>> = input.parse_nested_block(|input| {
+ let nested: Result<(), ParseError<()>> = input.parse_nested_block(|input| {
serialize_cssom_env_function_body(input, css_text)
- .ok_or_else(|| input.new_custom_error::<(), ()>(()))
+ .ok_or_else(|| cssparser::ParseError::custom::<()>(()))
});
nested.ok()?;
} else {
- let nested: Result<TokenSerializationType, ParseError<'_, ()>> = input
+ let nested: Result<TokenSerializationType, ParseError<()>> = input
.parse_nested_block(|input| {
serialize_cssom_component_values(input, css_text, previous_token)
- .ok_or_else(|| input.new_custom_error::<(), ()>(()))
+ .ok_or_else(|| cssparser::ParseError::custom::<()>(()))
});
nested.ok()?;
}
@@ -140,8 +138,8 @@ fn serialize_cssom_component_values<'i, 't>(
Some(previous_token)
}
-fn serialize_component_values_preserving_tokens<'i, 't>(
- input: &mut Parser<'i, 't>,
+fn serialize_component_values_preserving_tokens<'i>(
+ input: &mut Parser<'i>,
css_text: &mut String,
mut previous_token: TokenSerializationType,
) -> Option<TokenSerializationType> {
@@ -169,10 +167,10 @@ fn serialize_component_values_preserving_tokens<'i, 't>(
_ => None,
};
if let Some(closing_token) = closing_token {
- let nested: Result<TokenSerializationType, ParseError<'_, ()>> = input
- .parse_nested_block(|input| {
+ let nested: Result<TokenSerializationType, ParseError<()>> =
+ input.parse_nested_block(|input| {
serialize_component_values_preserving_tokens(input, css_text, previous_token)
- .ok_or_else(|| input.new_custom_error::<(), ()>(()))
+ .ok_or_else(|| cssparser::ParseError::custom::<()>(()))
});
nested.ok()?;
closing_token.to_css(css_text).ok()?;
@@ -182,8 +180,8 @@ fn serialize_component_values_preserving_tokens<'i, 't>(
Some(previous_token)
}
-fn serialize_cssom_env_function_body<'i, 't>(
- input: &mut Parser<'i, 't>,
+fn serialize_cssom_env_function_body<'i>(
+ input: &mut Parser<'i>,
css_text: &mut String,
) -> Option<()> {
let name = next_non_whitespace_component_token(input)?;
@@ -218,7 +216,7 @@ fn serialize_cssom_env_function_body<'i, 't>(
Some(())
}
-fn next_non_whitespace_component_token<'i, 't>(input: &mut Parser<'i, 't>) -> Option<Token<'i>> {
+fn next_non_whitespace_component_token<'i>(input: &mut Parser<'i>) -> Option<Token<'i>> {
loop {
let token = input
.next_including_whitespace_and_comments()
@@ -240,10 +238,7 @@ fn css_env_index_token_is_valid(token: &Token<'_>) -> bool {
)
}
-fn serialize_cssom_env_fallback<'i, 't>(
- input: &mut Parser<'i, 't>,
- css_text: &mut String,
-) -> Option<()> {
+fn serialize_cssom_env_fallback<'i>(input: &mut Parser<'i>, css_text: &mut String) -> Option<()> {
let fallback_start = input.position();
let mut fallback = String::new();
serialize_cssom_component_values(input, &mut fallback, TokenSerializationType::Nothing)?;
@@ -262,8 +257,8 @@ fn serialize_cssom_env_fallback<'i, 't>(
}
fn css_var_functions_are_valid(value: &str) -> bool {
- let mut input = ParserInput::new(value);
- let mut input = Parser::new(&mut input);
+ let input = value;
+ let mut input = Parser::new(input);
validate_css_var_functions_in_component_values(&mut input).is_some()
|| left_open_css_var_function_is_valid(value)
}
@@ -276,8 +271,8 @@ fn left_open_css_var_function_is_valid(value: &str) -> bool {
let Some(body) = strip_ascii_case_prefix(value, "var(") else {
return false;
};
- let mut input = ParserInput::new(body);
- let mut input = Parser::new(&mut input);
+ let input = body;
+ let mut input = Parser::new(input);
validate_css_var_function_body(&mut input).is_some()
}
@@ -292,8 +287,8 @@ fn recover_left_open_css_var_function(value: &str) -> Option<&str> {
if body.contains(')') {
return None;
}
- let mut input = ParserInput::new(body);
- let mut input = Parser::new(&mut input);
+ let input = body;
+ let mut input = Parser::new(input);
validate_css_var_function_body(&mut input)
.is_some()
.then_some(recovered)
@@ -306,7 +301,7 @@ fn strip_ascii_case_prefix<'a>(value: &'a str, prefix: &str) -> Option<&'a str>
.then(|| &value[prefix.len()..])
}
-fn validate_css_var_functions_in_component_values(input: &mut Parser<'_, '_>) -> Option<()> {
+fn validate_css_var_functions_in_component_values(input: &mut Parser<'_>) -> Option<()> {
while let Ok(token) = input.next_including_whitespace_and_comments().cloned() {
let nested_block = match token {
Token::Function(name) => Some((Some(name), Token::CloseParenthesis)),
@@ -322,15 +317,15 @@ fn validate_css_var_functions_in_component_values(input: &mut Parser<'_, '_>) ->
.as_ref()
.is_some_and(|name| name.eq_ignore_ascii_case("var"))
{
- let nested: Result<(), ParseError<'_, ()>> = input.parse_nested_block(|input| {
+ let nested: Result<(), ParseError<()>> = input.parse_nested_block(|input| {
validate_css_var_function_body(input)
- .ok_or_else(|| input.new_custom_error::<(), ()>(()))
+ .ok_or_else(|| cssparser::ParseError::custom::<()>(()))
});
nested.ok()?;
} else {
- let nested: Result<(), ParseError<'_, ()>> = input.parse_nested_block(|input| {
+ let nested: Result<(), ParseError<()>> = input.parse_nested_block(|input| {
validate_css_var_functions_in_component_values(input)
- .ok_or_else(|| input.new_custom_error::<(), ()>(()))
+ .ok_or_else(|| cssparser::ParseError::custom::<()>(()))
});
nested.ok()?;
}
@@ -338,7 +333,7 @@ fn validate_css_var_functions_in_component_values(input: &mut Parser<'_, '_>) ->
Some(())
}
-fn validate_css_var_function_body(input: &mut Parser<'_, '_>) -> Option<()> {
+fn validate_css_var_function_body(input: &mut Parser<'_>) -> Option<()> {
let name = next_non_whitespace_component_token(input)?;
let Token::Ident(name) = name else {
return None;
diff --git a/moli-dom/Cargo.toml b/moli-dom/Cargo.toml
index cbc046214..1e0fc6617 100644
--- a/moli-dom/Cargo.toml
+++ b/moli-dom/Cargo.toml
@@ -5,17 +5,17 @@ version = "0.1.0"
edition = "2024"
[dependencies]
-html5ever = "0.39.0"
+html5ever = "0.40"
indexmap = "2.14.2"
moli-css-parse = { path = "../moli-css-parse" }
moli-html-input-type = { path = "../moli-html-input-type" }
moli-html2md = { path = "../moli-html2md" }
moli-html-input-temporal = { path = "../moli-html-input-temporal" }
percent-encoding = "2.3"
-selectors = "0.40"
+selectors = "0.41"
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.145"
-servo_arc = "0.4.3"
+servo_arc = "0.5"
thin-vec = "0.2.14"
url = "2.5.7"
diff --git a/moli-layout/Cargo.toml b/moli-layout/Cargo.toml
index 5de7cb761..908986004 100644
--- a/moli-layout/Cargo.toml
+++ b/moli-layout/Cargo.toml
@@ -13,9 +13,9 @@ moli-system-fonts = { path = "../moli-system-fonts" }
moli-trace = { path = "../moli-trace" }
parley = "=0.11.0"
read-fonts = "0.41.0"
-stylo = "0.20"
-stylo_taffy = { git = "https://github.com/DioxusLabs/blitz", rev = "5081c65811a4396f5a99b2e0aca542a4a4a6606f", default-features = false, features = ["std", "block", "flexbox", "grid", "floats"] }
-taffy = { version = "=0.13.0", default-features = false, features = ["std", "block_layout", "flexbox", "grid", "float_layout", "content_size", "calc", "detailed_layout_info"] }
+stylo = "0.22"
+stylo_taffy = { git = "https://github.com/DioxusLabs/blitz", rev = "fb8d6c15e9ce062b3b41e71cd48988f0093506cc", default-features = false, features = ["std", "block", "flexbox", "grid", "floats"] }
+taffy = { version = "=0.15.0", default-features = false, features = ["std", "block_layout", "flexbox", "grid", "float_layout", "content_size", "calc", "detailed_layout_info"] }
thiserror = "2.0.17"
tracing = "0.1.41"
wuff = { version = "0.2.9", default-features = false, features = ["z"] }
diff --git a/moli-layout/src/grid.rs b/moli-layout/src/grid.rs
index ea4728b80..4a7b46214 100644
--- a/moli-layout/src/grid.rs
+++ b/moli-layout/src/grid.rs
@@ -8,7 +8,7 @@ use crate::{
pub(crate) fn project_resolved_grid_tracks(
style: &taffy::Style<Atom>,
- detailed: taffy::DetailedGridInfo,
+ detailed: taffy::DetailedGridInfo<Atom>,
) -> Option<LayoutResolvedGridTracks> {
let row_line_names = expanded_line_names(
&style.grid_template_rows,
@@ -29,22 +29,21 @@ pub(crate) fn project_resolved_grid_tracks(
}
fn project_tracks(
- tracks: taffy::DetailedGridTracksInfo,
+ tracks: taffy::DetailedGridTracksInfo<Atom>,
explicit_line_names: Vec<Vec<Atom>>,
) -> Option<LayoutResolvedGridTrackList> {
let track_count = usize::from(tracks.negative_implicit_tracks)
.checked_add(usize::from(tracks.explicit_tracks))?
.checked_add(usize::from(tracks.positive_implicit_tracks))?;
- if tracks.sizes.len() != track_count
- || tracks.gutters.len() != track_count.saturating_add(1)
+ if tracks.positions.len() != track_count
|| explicit_line_names.len() != usize::from(tracks.explicit_tracks).saturating_add(1)
{
return None;
}
let used_track_sizes = tracks
- .sizes
+ .positions
.into_iter()
- .map(to_blink_layout_unit)
+ .map(|position| to_blink_layout_unit(position.end - position.start))
.collect::<Option<Vec<_>>>()?;
Some(LayoutResolvedGridTrackList {
negative_implicit_track_count: usize::from(tracks.negative_implicit_tracks),
diff --git a/moli-layout/src/intrinsic.rs b/moli-layout/src/intrinsic.rs
index 7702ce8f7..6c4d3e1f9 100644
--- a/moli-layout/src/intrinsic.rs
+++ b/moli-layout/src/intrinsic.rs
@@ -31,7 +31,10 @@ where
available_width: f32,
) -> f32 {
let intrinsic_input = |width| LayoutInput {
- definite_dimensions: inputs.known_dimensions,
+ known_dimensions_are_definite: Size {
+ width: true,
+ height: true,
+ },
available_space: Size {
width,
height: inputs.available_space.height,
@@ -75,6 +78,8 @@ where
horizontal_margin: f32,
) -> LayoutOutput {
let layout_box = &self.boxes[child.index()];
+ let preferred_width = layout_box.style.taffy.size.width;
+ let is_replaced = layout_box.is_replaced();
let uses_fit_content = !layout_box.is_replaced()
&& layout_box.style.taffy.size.width.is_auto()
&& matches!(
@@ -85,16 +90,43 @@ where
| LayoutDisplay::InlineListItem
| LayoutDisplay::InlineTable
);
- let AvailableSpace::Definite(available_width) = inputs.available_space.width else {
- return self.compute_child_layout(child.to_taffy(), inputs);
- };
if !uses_fit_content {
+ // The IFC owns an atomic inline's preferred intrinsic width just
+ // as Taffy's block parent owns its children's sizing keywords.
+ // A definite line width must not turn min-content into fit-content.
+ let inputs = if !is_replaced
+ && inputs.sizing_mode == taffy::SizingMode::InherentSize
+ && inputs.known_dimensions.width.is_none()
+ {
+ let width = if preferred_width.is_min_content() {
+ AvailableSpace::MinContent
+ } else if preferred_width.is_max_content() {
+ AvailableSpace::MaxContent
+ } else {
+ inputs.available_space.width
+ };
+ LayoutInput {
+ available_space: Size {
+ width,
+ ..inputs.available_space
+ },
+ ..inputs
+ }
+ } else {
+ inputs
+ };
return self.compute_child_layout(child.to_taffy(), inputs);
}
+ let AvailableSpace::Definite(available_width) = inputs.available_space.width else {
+ return self.compute_child_layout(child.to_taffy(), inputs);
+ };
let intrinsic_inputs = LayoutInput {
known_dimensions: Size::NONE,
- definite_dimensions: Size::NONE,
+ known_dimensions_are_definite: Size {
+ width: true,
+ height: true,
+ },
..inputs
};
let fit_content = self.measure_fit_content_width(
@@ -108,14 +140,20 @@ where
};
let definite_dimensions = Size {
width: Some(fit_content),
- height: inputs.definite_dimensions.height,
+ height: inputs
+ .known_dimensions
+ .height
+ .filter(|_| inputs.known_dimensions_are_definite.height),
};
self.compute_child_layout(
child.to_taffy(),
LayoutInput {
known_dimensions,
- definite_dimensions,
+ known_dimensions_are_definite: (known_dimensions)
+ .zip_map(definite_dimensions, |known, definite| {
+ known.is_none() || definite.is_some()
+ }),
..inputs
},
)
diff --git a/moli-layout/src/overflow.rs b/moli-layout/src/overflow.rs
index 9ed1897b9..ffda3dce9 100644
--- a/moli-layout/src/overflow.rs
+++ b/moli-layout/src/overflow.rs
@@ -330,11 +330,11 @@ where
local_scrollport.y,
local_scrollport
.width
- .max(layout.content_size.width)
+ .max(layout.scrollable_overflow_rect.right)
.max(0.0),
local_scrollport
.height
- .max(layout.content_size.height)
+ .max(layout.scrollable_overflow_rect.bottom)
.max(0.0),
);
if is_root {
diff --git a/moli-layout/src/positioned.rs b/moli-layout/src/positioned.rs
index ee94f7ed1..117016463 100644
--- a/moli-layout/src/positioned.rs
+++ b/moli-layout/src/positioned.rs
@@ -98,7 +98,8 @@ pub(crate) fn flex_main_axis_static_edge(
| AlignContentKeyword::SpaceEvenly => LogicalStaticEdge::Center,
AlignContentKeyword::Start => LogicalStaticEdge::Start,
AlignContentKeyword::End => LogicalStaticEdge::End,
- AlignContentKeyword::FlexStart
+ AlignContentKeyword::Normal
+ | AlignContentKeyword::FlexStart
| AlignContentKeyword::Stretch
| AlignContentKeyword::SpaceBetween => {
if is_reverse {
@@ -157,7 +158,10 @@ impl FlexCrossAxisStaticContext {
keyword => keyword,
};
- if self.flex_wrap == FlexWrap::WrapReverse {
+ if matches!(
+ self.flex_wrap,
+ FlexWrap::WrapReverse | FlexWrap::BalanceReverse
+ ) {
keyword = match keyword {
AlignItemsKeyword::FlexStart => AlignItemsKeyword::FlexEnd,
AlignItemsKeyword::FlexEnd => AlignItemsKeyword::FlexStart,
@@ -168,10 +172,16 @@ impl FlexCrossAxisStaticContext {
match keyword {
AlignItemsKeyword::Center => LogicalStaticEdge::Center,
AlignItemsKeyword::FlexEnd => LogicalStaticEdge::End,
- AlignItemsKeyword::Stretch if self.flex_wrap == FlexWrap::WrapReverse => {
+ AlignItemsKeyword::Normal | AlignItemsKeyword::Stretch
+ if matches!(
+ self.flex_wrap,
+ FlexWrap::WrapReverse | FlexWrap::BalanceReverse
+ ) =>
+ {
LogicalStaticEdge::End
}
- AlignItemsKeyword::Start
+ AlignItemsKeyword::Normal
+ | AlignItemsKeyword::Start
| AlignItemsKeyword::End
| AlignItemsKeyword::FlexStart
| AlignItemsKeyword::SelfStart
diff --git a/moli-layout/src/replaced.rs b/moli-layout/src/replaced.rs
index f66059e3c..54c97918e 100644
--- a/moli-layout/src/replaced.rs
+++ b/moli-layout/src/replaced.rs
@@ -319,16 +319,16 @@ pub(crate) fn measure_replaced(
let transferred_height = preferred_size.width.and_then(|width| {
content_height_from_width(width, resolved_aspect_ratio, padding_border_sum)
});
- if is_min_or_max_content(style.min_size.width) {
+ if is_min_or_max_content(style.min_size.width.into()) {
min_size.width = transferred_width;
}
- if is_min_or_max_content(style.min_size.height) {
+ if is_min_or_max_content(style.min_size.height.into()) {
min_size.height = transferred_height;
}
- if is_min_or_max_content(style.max_size.width) {
+ if is_min_or_max_content(style.max_size.width.into()) {
max_size.width = transferred_width;
}
- if is_min_or_max_content(style.max_size.height) {
+ if is_min_or_max_content(style.max_size.height.into()) {
max_size.height = transferred_height;
}
}
@@ -406,7 +406,7 @@ pub(crate) fn measure_replaced(
// fit-content pass. A ratio-only SVG still stretches against its
// definite containing block in these probes (unlike an in-flow
// SVG inside a shrink-to-fit container, which contributes zero).
- if style.position != taffy::Position::Absolute {
+ if !style.position.is_out_of_flow() {
return None;
}
let insets = style
@@ -751,8 +751,8 @@ mod tests {
height: taffy::Dimension::length(40.0),
},
min_size: Size {
- width: taffy::Dimension::min_content(),
- height: taffy::Dimension::auto(),
+ width: taffy::Dimension::min_content().into(),
+ height: taffy::Dimension::auto().into(),
},
..taffy::Style::default()
};
@@ -764,7 +764,7 @@ mod tests {
}
);
- min_width.min_size.width = taffy::Dimension::max_content();
+ min_width.min_size.width = taffy::Dimension::max_content().into();
assert_eq!(
measure(&min_width),
Size {
@@ -779,8 +779,8 @@ mod tests {
height: taffy::Dimension::length(70.0),
},
max_size: Size {
- width: taffy::Dimension::min_content(),
- height: taffy::Dimension::auto(),
+ width: taffy::Dimension::min_content().into(),
+ height: taffy::Dimension::auto().into(),
},
..taffy::Style::default()
};
@@ -792,7 +792,7 @@ mod tests {
}
);
- max_width.max_size.width = taffy::Dimension::max_content();
+ max_width.max_size.width = taffy::Dimension::max_content().into();
assert_eq!(
measure(&max_width),
Size {
@@ -807,8 +807,8 @@ mod tests {
height: taffy::Dimension::length(30.0),
},
min_size: Size {
- width: taffy::Dimension::auto(),
- height: taffy::Dimension::min_content(),
+ width: taffy::Dimension::auto().into(),
+ height: taffy::Dimension::min_content().into(),
},
..taffy::Style::default()
};
@@ -820,7 +820,7 @@ mod tests {
}
);
- min_height.min_size.height = taffy::Dimension::max_content();
+ min_height.min_size.height = taffy::Dimension::max_content().into();
assert_eq!(
measure(&min_height),
Size {
@@ -835,8 +835,8 @@ mod tests {
height: taffy::Dimension::length(80.0),
},
max_size: Size {
- width: taffy::Dimension::auto(),
- height: taffy::Dimension::min_content(),
+ width: taffy::Dimension::auto().into(),
+ height: taffy::Dimension::min_content().into(),
},
..taffy::Style::default()
};
@@ -848,7 +848,7 @@ mod tests {
}
);
- max_height.max_size.height = taffy::Dimension::max_content();
+ max_height.max_size.height = taffy::Dimension::max_content().into();
assert_eq!(
measure(&max_height),
Size {
diff --git a/moli-layout/src/style.rs b/moli-layout/src/style.rs
index f0904f61c..60df158c9 100644
--- a/moli-layout/src/style.rs
+++ b/moli-layout/src/style.rs
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
//
// The Stylo-to-Taffy projection uses the standalone `stylo_taffy` crate from
-// DioxusLabs/blitz commit d788124ab881f9bb537cb452ec1d837604a374a8.
+// DioxusLabs/blitz commit fb8d6c15e9ce062b3b41e71cd48988f0093506cc.
use std::sync::Arc;
@@ -31,7 +31,6 @@ use style::{
BaselineShift as GenericBaselineShift, BaselineShiftKeyword,
Perspective as GenericPerspective,
},
- flex::GenericFlexBasis,
grid::GenericGridTemplateComponent,
image::GenericImage,
length::{GenericMaxSize, GenericSize},
@@ -409,12 +408,10 @@ impl LayoutDisplay {
}
}
-/// Exact CSS positioning mode retained beside Taffy's reduced two-state model.
+/// CSS positioning mode retained for browser containing-block and scrolling rules.
///
-/// Taffy 0.12 represents both CSS `static` and `relative` as
-/// [`taffy::Position::Relative`], and both `absolute` and `fixed` as
-/// [`taffy::Position::Absolute`]. Layout must retain the browser-level value so
-/// containing-block selection does not accidentally use the direct box parent.
+/// The numeric backend also distinguishes all five modes. The browser owns
+/// transform/contain containing blocks and applies sticky offsets after layout.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum LayoutPosition {
#[default]
@@ -633,7 +630,8 @@ impl ResolvedLayoutStyle {
};
let text_transform_value = computed.clone_text_transform();
let text_transform = match text_transform_value.case() {
- TextTransformCase::None => InlineTextTransform::None,
+ // Mathematical character substitution is not supported by the text adapter yet.
+ TextTransformCase::None | TextTransformCase::MathAuto => InlineTextTransform::None,
TextTransformCase::Uppercase => InlineTextTransform::Uppercase,
TextTransformCase::Lowercase => InlineTextTransform::Lowercase,
TextTransformCase::Capitalize => InlineTextTransform::Capitalize,
@@ -817,25 +815,25 @@ impl ResolvedLayoutStyle {
height: taffy_size_dimension(&position_style.height, taffy.size.height),
};
taffy.min_size = Size {
- width: taffy_size_dimension(&position_style.min_width, taffy.min_size.width),
- height: taffy_size_dimension(&position_style.min_height, taffy.min_size.height),
+ width: taffy_size_dimension(&position_style.min_width, taffy.min_size.width.into())
+ .into(),
+ height: taffy_size_dimension(&position_style.min_height, taffy.min_size.height.into())
+ .into(),
};
taffy.max_size = Size {
- width: taffy_max_size_dimension(&position_style.max_width, taffy.max_size.width),
- height: taffy_max_size_dimension(&position_style.max_height, taffy.max_size.height),
+ width: taffy_max_size_dimension(&position_style.max_width, taffy.max_size.width.into())
+ .into(),
+ height: taffy_max_size_dimension(
+ &position_style.max_height,
+ taffy.max_size.height.into(),
+ )
+ .into(),
};
// Taffy's generic leaf algorithm transfers aspect ratios before a
// replaced-element measure callback runs. CSS Sizing 4 defines zero,
// infinite and NaN ratios as degenerate, so normalize them at the
// Stylo/Taffy seam instead of relying only on replaced measurement.
taffy.aspect_ratio = preferred_aspect_ratio.numeric_ratio();
- if matches!(position_style.flex_basis, GenericFlexBasis::Content) {
- // Blitz's fixed stylo_taffy revision predates Taffy's typed
- // `content` flex-basis. Preserve the Stylo distinction here so
- // Taffy ignores the preferred main size and follows the content
- // flex-base-size algorithm instead of treating it as `auto`.
- taffy.flex_basis = taffy::Dimension::content();
- }
taffy.item_is_table = matches!(display, LayoutDisplay::Table | LayoutDisplay::InlineTable);
let sticky_inset = taffy.inset;
let establishes_transform_containing_block =
@@ -853,10 +851,8 @@ impl ResolvedLayoutStyle {
let pointer_events =
computed.clone_pointer_events() != style::computed_values::pointer_events::T::None;
if matches!(position, LayoutPosition::Static | LayoutPosition::Sticky) {
- // `stylo_taffy` must map both CSS static and relative to Taffy's
- // single in-flow `Relative` variant. Taffy would therefore apply
- // author insets to a static box unless the browser-level adapter
- // clears them here.
+ // Static insets do not affect layout. Sticky thresholds are saved
+ // separately and applied by the browser after normal-flow layout.
taffy.inset = taffy::Rect {
left: taffy::LengthPercentageAuto::auto(),
right: taffy::LengthPercentageAuto::auto(),
@@ -934,11 +930,13 @@ impl ResolvedLayoutStyle {
|| taffy.overflow.y != taffy::Overflow::Visible;
let overflow_x = LayoutOverflowMode::from_taffy(taffy.overflow.x);
let overflow_y = LayoutOverflowMode::from_taffy(taffy.overflow.y);
- let out_of_flow = taffy.position == TaffyPosition::Absolute;
- let position = if out_of_flow {
- LayoutPosition::Absolute
- } else {
- LayoutPosition::Static
+ let out_of_flow = taffy.position.is_out_of_flow();
+ let position = match taffy.position {
+ TaffyPosition::Static => LayoutPosition::Static,
+ TaffyPosition::Relative => LayoutPosition::Relative,
+ TaffyPosition::Absolute => LayoutPosition::Absolute,
+ TaffyPosition::Fixed => LayoutPosition::Fixed,
+ TaffyPosition::Sticky => LayoutPosition::Sticky,
};
let sticky_inset = taffy.inset;
Self {
@@ -1076,10 +1074,12 @@ impl ResolvedLayoutStyle {
self.out_of_flow = matches!(position, LayoutPosition::Absolute | LayoutPosition::Fixed);
self.position = position;
self.sticky_inset = self.taffy.inset;
- self.taffy.position = if self.out_of_flow {
- TaffyPosition::Absolute
- } else {
- TaffyPosition::Relative
+ self.taffy.position = match position {
+ LayoutPosition::Static => TaffyPosition::Static,
+ LayoutPosition::Relative => TaffyPosition::Relative,
+ LayoutPosition::Absolute => TaffyPosition::Absolute,
+ LayoutPosition::Fixed => TaffyPosition::Fixed,
+ LayoutPosition::Sticky => TaffyPosition::Sticky,
};
if matches!(position, LayoutPosition::Static | LayoutPosition::Sticky) {
self.taffy.inset = taffy::Rect {
@@ -1549,12 +1549,12 @@ impl ResolvedLayoutStyle {
height: zero_dimension,
};
placeholder.taffy.min_size = Size {
- width: zero_dimension,
- height: zero_dimension,
+ width: zero_dimension.into(),
+ height: zero_dimension.into(),
};
placeholder.taffy.max_size = Size {
- width: zero_dimension,
- height: zero_dimension,
+ width: zero_dimension.into(),
+ height: zero_dimension.into(),
};
placeholder.taffy.padding = taffy::Rect {
left: zero_length,
@@ -2149,7 +2149,7 @@ impl ResolvedLayoutStyle {
| LayoutDisplay::Inline
| LayoutDisplay::InlineBlock
) {
- self.taffy.align_content = Some(taffy::AlignContent::SAFE_CENTER);
+ self.taffy.align_content = taffy::AlignContent::SAFE_CENTER;
}
}
}
diff --git a/moli-layout/src/stylo_to_parley.rs b/moli-layout/src/stylo_to_parley.rs
index 13da9c81d..41d3e2231 100644
--- a/moli-layout/src/stylo_to_parley.rs
+++ b/moli-layout/src/stylo_to_parley.rs
@@ -17,8 +17,8 @@ use style::{
properties::ComputedValues,
values::{
computed::font::{
- FontFeatureSettings, FontStretch, FontStyle as StyloFontStyle, FontSynthesis,
- FontVariationSettings, GenericFontFamily, SingleFontFamily,
+ FontFeatureSettings, FontStyle as StyloFontStyle, FontSynthesis, FontVariationSettings,
+ FontWidth as StyloFontWidth, GenericFontFamily, SingleFontFamily,
},
computed::{
Length, OverflowWrap as StyloOverflowWrap, TextDecorationLine,
@@ -186,7 +186,7 @@ pub(crate) fn text_style(computed: &ComputedValues) -> TextStyle<'static, 'stati
},
font_family: FontFamily::List(Cow::Owned(families)),
font_size,
- font_width: font_width(font.font_stretch),
+ font_width: font_width(font.font_width),
font_style: font_style(font.font_style),
font_weight: FontWeight::new(font.font_weight.value()),
font_variations: FontVariations::List(Cow::Owned(variations)),
@@ -231,7 +231,7 @@ pub(crate) fn text_style(computed: &ComputedValues) -> TextStyle<'static, 'stati
fn font_family_name(family: &SingleFontFamily) -> FontFamilyName<'static> {
match family {
SingleFontFamily::FamilyName(name) => {
- let name = name.name.as_ref();
+ let name: &str = name.name.as_ref();
#[cfg(target_vendor = "apple")]
if name == "-apple-system" {
return FontFamilyName::Generic(GenericFamily::SystemUi);
@@ -267,7 +267,7 @@ fn generic_font_family(family: GenericFontFamily) -> GenericFamily {
}
}
-fn font_width(stretch: FontStretch) -> FontWidth {
+fn font_width(stretch: StyloFontWidth) -> FontWidth {
FontWidth::from_percentage(stretch.0.to_float())
}
diff --git a/moli-layout/src/table.rs b/moli-layout/src/table.rs
index ba88d3751..28ab8c46d 100644
--- a/moli-layout/src/table.rs
+++ b/moli-layout/src/table.rs
@@ -143,7 +143,7 @@ struct TableContext {
rows: Vec<TableRow>,
columns: Vec<TableColumn>,
captions: Vec<LayoutBoxId>,
- detailed: Option<DetailedGridInfo>,
+ detailed: Option<DetailedGridInfo<Atom>>,
collapsed_borders: bool,
column_count: usize,
column_constraints: Vec<TableColumnConstraint>,
@@ -255,11 +255,11 @@ where
min_border_box_size
};
- let current = style.min_size.width;
+ let current = Dimension::from(style.min_size.width);
if current.is_auto() {
- style.min_size.width = Dimension::length(min_style_size);
+ style.min_size.width = Dimension::length(min_style_size).into();
} else if current.tag() == taffy::CompactLength::LENGTH_TAG {
- style.min_size.width = Dimension::length(current.value().max(min_style_size));
+ style.min_size.width = Dimension::length(current.value().max(min_style_size)).into();
}
}
@@ -377,8 +377,8 @@ where
// Fixed Grid tracks can return without measuring child baselines.
// Use the row pass, including the absence of a baseline in a table
// with no rows; final cell layout may refine it below.
- output.first_baselines.y = context.measured_baselines.0;
- output.last_baselines.y = context.measured_baselines.1;
+ output.baselines.first = context.measured_baselines.0;
+ output.baselines.last = context.measured_baselines.1;
}
{
@@ -416,16 +416,20 @@ where
shift_grid_children(world, &context.cells, top_height);
apply_structural_layout(world, root, &context, top_height, output.size);
}
- if let Some(first_baseline) = &mut output.first_baselines.y {
+ if let Some(first_baseline) = &mut output.baselines.first {
*first_baseline += top_height;
}
- if let Some(last_baseline) = &mut output.last_baselines.y {
+ if let Some(last_baseline) = &mut output.baselines.last {
*last_baseline += top_height;
}
output.size.height += top_height + bottom_height;
- output.content_size.height += top_height + bottom_height;
- output.content_size.width = output.content_size.width.min(output.size.width);
- output.content_size.height = output.content_size.height.min(output.size.height);
+ output.scrollable_overflow_rect.bottom += top_height + bottom_height;
+ output.scrollable_overflow_rect.right =
+ output.scrollable_overflow_rect.right.min(output.size.width);
+ output.scrollable_overflow_rect.bottom = output
+ .scrollable_overflow_rect
+ .bottom
+ .min(output.size.height);
}
output
}
@@ -611,7 +615,10 @@ impl TableContext {
caption.to_taffy(),
LayoutInput {
known_dimensions: Size::NONE,
- definite_dimensions: Size::NONE,
+ known_dimensions_are_definite: Size {
+ width: true,
+ height: true,
+ },
parent_size: Size::NONE,
parent_writing_mode: self.writing_mode,
available_space: self.writing_mode.to_physical(LogicalSize {
@@ -725,12 +732,12 @@ impl TableContext {
set_physical_inline_dimension(
self.writing_mode,
&mut self.style.min_size,
- Dimension::auto(),
+ Dimension::auto().into(),
);
set_physical_inline_dimension(
self.writing_mode,
&mut self.style.max_size,
- Dimension::auto(),
+ Dimension::auto().into(),
);
let mut grid_space = space;
@@ -764,7 +771,9 @@ impl TableContext {
let logical_max_size = self.writing_mode.to_logical(self.style.max_size);
let percentage_basis = space.percentage_resolution_size.inline_size;
let box_sizing_adjustment = if self.style.box_sizing == taffy::BoxSizing::ContentBox {
- inline_insets
+ // Outer spacing is represented as Grid padding but remains inside
+ // the CSS table's content box, as in the block-size row solver.
+ inline_insets - 2.0 * self.inline_border_spacing
} else {
0.0
};
@@ -793,10 +802,10 @@ impl TableContext {
.then(|| resolve_dimension(logical_size.inline_size))
.flatten();
let min_size = authored_sizes_apply
- .then(|| resolve_dimension(logical_min_size.inline_size))
+ .then(|| resolve_dimension(logical_min_size.inline_size.into()))
.flatten();
let max_size = authored_sizes_apply
- .then(|| resolve_dimension(logical_max_size.inline_size))
+ .then(|| resolve_dimension(logical_max_size.inline_size.into()))
.flatten();
let mut used = space
@@ -915,14 +924,14 @@ fn collect_rows<N>(
let authored_style = &world.boxes[cell.index()].style;
let mut cell_style = authored_style.taffy.clone();
cell_style.margin = Rect::ZERO.map(style_helpers::length);
- if cell_style.align_content.is_none() {
+ if cell_style.align_content.keyword() == taffy::AlignContentKeyword::Normal {
cell_style.align_content = match authored_style.vertical_align().kind {
- LayoutInlineAlignment::Middle => Some(taffy::AlignContent::CENTER),
- LayoutInlineAlignment::Bottom => Some(taffy::AlignContent::END),
- LayoutInlineAlignment::Top => Some(taffy::AlignContent::START),
+ LayoutInlineAlignment::Middle => taffy::AlignContent::CENTER,
+ LayoutInlineAlignment::Bottom => taffy::AlignContent::END,
+ LayoutInlineAlignment::Top => taffy::AlignContent::START,
LayoutInlineAlignment::Baseline
| LayoutInlineAlignment::TextTop
- | LayoutInlineAlignment::TextBottom => None,
+ | LayoutInlineAlignment::TextBottom => taffy::AlignContent::NORMAL,
};
}
cells.push(TableCell {
@@ -1100,12 +1109,12 @@ where
let logical_max_size = table_writing_mode.to_logical(style.max_size);
let preferred = outer_fixed_size(logical_size.inline_size, inline_insets, style.box_sizing);
let css_min = outer_fixed_size(
- logical_min_size.inline_size,
+ logical_min_size.inline_size.into(),
inline_insets,
style.box_sizing,
);
let css_max = outer_fixed_size(
- logical_max_size.inline_size,
+ logical_max_size.inline_size.into(),
inline_insets,
style.box_sizing,
);
@@ -1184,7 +1193,10 @@ where
});
let intrinsic_inputs = LayoutInput {
known_dimensions: Size::NONE,
- definite_dimensions: Size::NONE,
+ known_dimensions_are_definite: Size {
+ width: true,
+ height: true,
+ },
parent_size: Size::NONE,
parent_writing_mode: table_writing_mode,
available_space,
@@ -1229,15 +1241,11 @@ fn physical_inline_sum(writing_mode: WritingMode, rect: Rect<f32>) -> f32 {
fn clear_table_cell_inline_sizing(style: &mut Style<Atom>, writing_mode: WritingMode) {
set_physical_inline_dimension(writing_mode, &mut style.size, Dimension::auto());
- set_physical_inline_dimension(writing_mode, &mut style.min_size, Dimension::auto());
- set_physical_inline_dimension(writing_mode, &mut style.max_size, Dimension::auto());
+ set_physical_inline_dimension(writing_mode, &mut style.min_size, Dimension::auto().into());
+ set_physical_inline_dimension(writing_mode, &mut style.max_size, Dimension::auto().into());
}
-fn set_physical_inline_dimension(
- writing_mode: WritingMode,
- size: &mut Size<Dimension>,
- value: Dimension,
-) {
+fn set_physical_inline_dimension<T>(writing_mode: WritingMode, size: &mut Size<T>, value: T) {
if writing_mode.is_horizontal() {
size.width = value;
} else {
@@ -1268,9 +1276,9 @@ where
width: Some((width - margin.left - margin.right).max(0.0)),
height: None,
},
- definite_dimensions: Size {
- width: Some((width - margin.left - margin.right).max(0.0)),
- height: None,
+ known_dimensions_are_definite: Size {
+ width: true,
+ height: true,
},
parent_size: Size {
width: Some(width),
@@ -1294,7 +1302,7 @@ where
world,
caption,
Point { x: margin.left, y },
- output,
+ &output,
order,
Some(width),
);
@@ -1339,18 +1347,31 @@ fn apply_structural_layout<N>(
let Some(detailed) = context.detailed.as_ref() else {
return;
};
- let row_starts = track_starts(origin.y, &detailed.rows.sizes, &detailed.rows.gutters);
- let column_starts = track_starts(origin.x, &detailed.columns.sizes, &detailed.columns.gutters);
- let content_width = track_extent(&detailed.columns.sizes, &detailed.columns.gutters);
- // Empty tables retain spacing in their intrinsic inline contribution,
- // while their row/group rectangles span the content box when no real
- // columns exist. Keep that distinction out of column sizing.
+ // Native track positions already include border, padding, gaps and content
+ // alignment, and columns remain in logical order even when RTL reverses
+ // their physical positions.
+ let row_starts: Vec<_> = detailed
+ .rows
+ .positions
+ .iter()
+ .map(|track| track.start + top_offset)
+ .collect();
+ let column_bounds = track_range_bounds(
+ &detailed.columns.positions,
+ 0,
+ detailed.columns.positions.len(),
+ )
+ .unwrap_or(Line {
+ start: origin.x,
+ end: origin.x,
+ });
+ let content_width = column_bounds.end - column_bounds.start;
let empty_inline_spacing = if context.cells.is_empty() && context.columns.is_empty() {
context.inline_border_spacing
} else {
0.0
};
- let part_x = origin.x - empty_inline_spacing;
+ let part_x = column_bounds.start - empty_inline_spacing;
let part_width = content_width + 2.0 * empty_inline_spacing;
let occupied_sections = || {
context
@@ -1364,20 +1385,20 @@ fn apply_structural_layout<N>(
.map_or(0, |(_, range)| range.start);
let last_section_track = occupied_sections()
.next_back()
- .map_or(detailed.rows.sizes.len(), |(_, range)| range.end);
- let content_top = row_starts
- .get(first_section_track)
- .copied()
- .unwrap_or(origin.y);
- let content_height = track_range_extent(
- &detailed.rows.sizes,
- &detailed.rows.gutters,
+ .map_or(detailed.rows.positions.len(), |(_, range)| range.end);
+ let row_bounds = track_range_bounds(
+ &detailed.rows.positions,
first_section_track,
last_section_track,
- );
+ )
+ .unwrap_or(Line {
+ start: origin.y - top_offset,
+ end: origin.y - top_offset,
+ });
+ let content_top = row_bounds.start + top_offset;
+ let content_height = row_bounds.end - row_bounds.start;
if context.collapsed_borders {
- // Border conflicts are indexed by actual rows. Empty-section tracks
- // occupy space but must not change the conflict grid's row count.
+ // Empty-section tracks occupy space without adding conflict-grid rows.
let mut row_lines: Vec<_> = context
.rows
.iter()
@@ -1387,8 +1408,18 @@ fn apply_structural_layout<N>(
*first = origin.y;
}
row_lines.push(origin.y + content_height);
- let mut column_lines = column_starts.clone();
- column_lines.push(origin.x + content_width);
+ let rtl = context.style.direction.is_rtl();
+ let mut column_lines: Vec<_> = detailed
+ .columns
+ .positions
+ .iter()
+ .map(|track| if rtl { track.end } else { track.start })
+ .collect();
+ column_lines.push(if rtl {
+ column_bounds.start
+ } else {
+ column_bounds.end
+ });
set_collapsed_border_geometry(world, root, &column_lines, &row_lines);
}
@@ -1396,10 +1427,9 @@ fn apply_structural_layout<N>(
let y = row_starts.get(row.grid_index).copied().unwrap_or(origin.y);
let height = detailed
.rows
- .sizes
+ .positions
.get(row.grid_index)
- .copied()
- .unwrap_or(0.0);
+ .map_or(0.0, |track| track.end - track.start);
set_table_part_layout(world, row.id, part_x, y, part_width, height);
}
for (&group, tracks) in context.section_boxes.iter().zip(&context.section_tracks) {
@@ -1409,27 +1439,38 @@ fn apply_structural_layout<N>(
) {
continue;
}
- let y = row_starts
- .get(tracks.start)
- .copied()
- .unwrap_or(origin.y + content_height);
- let height = track_range_extent(
- &detailed.rows.sizes,
- &detailed.rows.gutters,
- tracks.start,
- tracks.end,
+ let bounds = track_range_bounds(&detailed.rows.positions, tracks.start, tracks.end)
+ .unwrap_or(Line {
+ start: row_bounds.end,
+ end: row_bounds.end,
+ });
+ set_table_part_layout(
+ world,
+ group,
+ part_x,
+ bounds.start + top_offset,
+ part_width,
+ bounds.end - bounds.start,
);
- set_table_part_layout(world, group, part_x, y, part_width, height);
}
for column in &context.columns {
- let x = column_starts.get(column.start).copied().unwrap_or(origin.x);
- let width = track_range_extent(
- &detailed.columns.sizes,
- &detailed.columns.gutters,
+ let bounds = track_range_bounds(
+ &detailed.columns.positions,
column.start,
column.start.saturating_add(column.span),
+ )
+ .unwrap_or(Line {
+ start: origin.x,
+ end: origin.x,
+ });
+ set_table_part_layout(
+ world,
+ column.id,
+ bounds.start,
+ content_top,
+ bounds.end - bounds.start,
+ content_height,
);
- set_table_part_layout(world, column.id, x, content_top, width, content_height);
}
let mut column_groups = context
.columns
@@ -1450,46 +1491,31 @@ fn apply_structural_layout<N>(
end = end.max(column.start.saturating_add(column.span));
}
if start != usize::MAX {
- let x = column_starts.get(start).copied().unwrap_or(origin.x);
- let width = track_range_extent(
- &detailed.columns.sizes,
- &detailed.columns.gutters,
- start,
- end,
+ let bounds =
+ track_range_bounds(&detailed.columns.positions, start, end).unwrap_or(Line {
+ start: origin.x,
+ end: origin.x,
+ });
+ set_table_part_layout(
+ world,
+ group,
+ bounds.start,
+ content_top,
+ bounds.end - bounds.start,
+ content_height,
);
- set_table_part_layout(world, group, x, content_top, width, content_height);
}
}
-
- // Keep the root in the numeric tree even for an empty table.
- let _ = root;
}
-fn track_starts(origin: f32, sizes: &[f32], gutters: &[f32]) -> Vec<f32> {
- let mut starts = Vec::with_capacity(sizes.len());
- let mut cursor = origin + gutters.first().copied().unwrap_or(0.0);
- for (index, size) in sizes.iter().copied().enumerate() {
- starts.push(cursor);
- cursor += size + gutters.get(index + 1).copied().unwrap_or(0.0);
+fn track_range_bounds(positions: &[Line<f32>], start: usize, end: usize) -> Option<Line<f32>> {
+ let tracks = positions.get(start..end.min(positions.len()))?;
+ let mut bounds = *tracks.first()?;
+ for track in &tracks[1..] {
+ bounds.start = bounds.start.min(track.start);
+ bounds.end = bounds.end.max(track.end);
}
- starts
-}
-
-fn track_extent(sizes: &[f32], gutters: &[f32]) -> f32 {
- sizes.iter().sum::<f32>() + gutters.iter().sum::<f32>()
-}
-
-fn track_range_extent(sizes: &[f32], gutters: &[f32], start: usize, end: usize) -> f32 {
- let end = end.min(sizes.len());
- if start >= end {
- return 0.0;
- }
- sizes[start..end].iter().sum::<f32>()
- + gutters
- .get(start + 1..end)
- .unwrap_or_default()
- .iter()
- .sum::<f32>()
+ Some(bounds)
}
fn set_table_part_layout<N>(
@@ -1511,7 +1537,7 @@ fn set_table_part_layout<N>(
order: 0,
location: Point { x, y },
size: Size { width, height },
- content_size: Size { width, height },
+ scrollable_overflow_rect: Size { width, height }.into(),
scrollbar_size: Size::ZERO,
border: Rect::ZERO,
padding: Rect::ZERO,
@@ -1523,7 +1549,7 @@ fn set_box_layout<N>(
world: &mut LayoutWorld<N>,
id: LayoutBoxId,
location: Point<f32>,
- output: LayoutOutput,
+ output: &LayoutOutput,
order: usize,
parent_width: Option<f32>,
) where
@@ -1543,7 +1569,7 @@ fn set_box_layout<N>(
order: u32::try_from(order).unwrap_or(u32::MAX),
location,
size: output.size,
- content_size: output.content_size,
+ scrollable_overflow_rect: output.scrollable_overflow_rect,
scrollbar_size: Size::ZERO,
border,
padding,
@@ -1679,7 +1705,7 @@ where
&& let Some(layout) = &mut self.context.cells[cell_index].block_layout
&& layout.baseline.is_some()
{
- layout.baseline = output.first_baselines.y;
+ layout.baseline = output.baselines.first;
}
output
}
@@ -1711,7 +1737,11 @@ where
&self.context.cells[usize::from(child_node_id)].style
}
- fn set_detailed_grid_info(&mut self, _node_id: NodeId, detailed_grid_info: DetailedGridInfo) {
+ fn set_detailed_grid_info(
+ &mut self,
+ _node_id: NodeId,
+ detailed_grid_info: DetailedGridInfo<Atom>,
+ ) {
self.context.detailed = Some(detailed_grid_info);
}
}
@@ -1792,9 +1822,9 @@ mod tests {
width: Some(200.0),
height: None,
},
- definite_dimensions: Size {
- width: Some(200.0),
- height: None,
+ known_dimensions_are_definite: Size {
+ width: true,
+ height: true,
},
parent_size: Size {
width: Some(200.0),
@@ -1823,7 +1853,7 @@ mod tests {
for id in cells.iter().chain([&caption, &group]) {
assert_eq!(world.boxes[id.index()].unrounded_layout.size, Size::ZERO);
}
- assert_eq!(cold.first_baselines.y, Some(40.0));
+ assert_eq!(cold.baselines.first, Some(40.0));
assert_eq!(cold, world.compute_child_layout(root.to_taffy(), inputs));
assert_eq!(
world.boxes[root.index()]
@@ -1859,7 +1889,7 @@ mod tests {
prepared.invalidate_scrollbar_feedback(&mut world, &[group], false);
let changed = world.compute_child_layout(root.to_taffy(), inputs);
assert_eq!(changed.size.height, 140.0);
- assert_eq!(changed.first_baselines.y, Some(50.0));
+ assert_eq!(changed.baselines.first, Some(50.0));
assert_eq!(
world.boxes[root.index()]
.table_measure_cache
@@ -2023,7 +2053,7 @@ mod tests {
height: 10.0
}
);
- assert_eq!(cold.first_baselines.y, Some(10.0));
+ assert_eq!(cold.baselines.first, Some(10.0));
let computations = |world: &LayoutWorld<usize>| {
world
.boxes
diff --git a/moli-layout/src/table/block.rs b/moli-layout/src/table/block.rs
index 1073768cd..f795db633 100644
--- a/moli-layout/src/table/block.rs
+++ b/moli-layout/src/table/block.rs
@@ -20,8 +20,8 @@ pub(super) fn set_block<T>(mode: WritingMode, size: &mut Size<T>, value: T) {
pub(super) fn clear_cell_block_sizing(style: &mut Style<Atom>, mode: WritingMode) {
set_block(mode, &mut style.size, Dimension::auto());
- set_block(mode, &mut style.min_size, Dimension::auto());
- set_block(mode, &mut style.max_size, Dimension::auto());
+ set_block(mode, &mut style.min_size, Dimension::auto().into());
+ set_block(mode, &mut style.max_size, Dimension::auto().into());
}
fn fixed(dimension: Dimension) -> Option<f32> {
@@ -63,24 +63,17 @@ impl TableContext {
}
}
if let Some(detailed) = &self.detailed {
- let padding = self
- .style
- .padding
- .resolve_or_zero(Some(output.size.width), resolve_stylo_calc_value);
- let border = self
- .style
- .border
- .resolve_or_zero(Some(output.size.width), resolve_stylo_calc_value);
- let starts = track_starts(
- padding.top + border.top,
- &detailed.rows.sizes,
- &detailed.rows.gutters,
- );
+ let starts: Vec<_> = detailed
+ .rows
+ .positions
+ .iter()
+ .map(|track| track.start)
+ .collect();
if let Some(Some(baseline)) = baselines.first() {
- output.first_baselines.y = Some(starts[self.rows[0].grid_index] + baseline);
+ output.baselines.first = Some(starts[self.rows[0].grid_index] + baseline);
}
if let Some(Some(baseline)) = baselines.last() {
- output.last_baselines.y =
+ output.baselines.last =
Some(starts[self.rows.last().unwrap().grid_index] + baseline);
}
}
@@ -137,12 +130,40 @@ impl TableContext {
let target = space
.known_size
.block_size
- .or_else(|| authored.then(|| resolve(preferred)).flatten());
+ .or_else(|| authored.then(|| resolve(preferred)).flatten())
+ .or_else(|| {
+ // Table wrappers now resolve their own dimensions instead of
+ // receiving an aspect-ratio height from the block parent.
+ // The ratio supplies a preferred row target; cell minima can
+ // still grow it. Internal table boxes never enter this path.
+ if !authored || !preferred.is_auto() {
+ return None;
+ }
+ let ratio = taffy::ResolvedAspectRatio::new(
+ self.style.aspect_ratio?,
+ self.style.box_sizing,
+ );
+ let decoration = Size {
+ width: padding.left + padding.right + border.left + border.right
+ - 2.0 * self.inline_border_spacing,
+ height: insets - 2.0 * self.block_border_spacing,
+ };
+ Size {
+ width: space.known_size.inline_size,
+ height: None,
+ }
+ .maybe_apply_aspect_ratio_with_box_sizing(
+ ratio,
+ taffy::BoxSizing::BorderBox,
+ decoration,
+ )
+ .height
+ });
let min = authored
- .then(|| resolve(mode.to_logical(self.style.min_size).block_size))
+ .then(|| resolve(mode.to_logical(self.style.min_size).block_size.into()))
.flatten();
let max = authored
- .then(|| resolve(mode.to_logical(self.style.max_size).block_size))
+ .then(|| resolve(mode.to_logical(self.style.max_size).block_size.into()))
.flatten();
let target = target
.map(|v| v.min(max.unwrap_or(f32::INFINITY)))
@@ -190,7 +211,8 @@ impl TableContext {
let baseline_aligned = matches!(
world.boxes[cell.id.index()].style.vertical_align().kind,
LayoutInlineAlignment::Baseline
- ) && authored_style.align_content.is_none();
+ ) && authored_style.align_content.keyword()
+ == taffy::AlignContentKeyword::Normal;
let inline = self.column_sizes[cell.column..cell.column + cell.column_span]
.iter()
.sum::<f32>()
@@ -200,10 +222,10 @@ impl TableContext {
inline_size: Some(inline),
block_size: None,
}),
- definite_dimensions: mode.to_physical(LogicalSize {
- inline_size: Some(inline),
- block_size: None,
- }),
+ known_dimensions_are_definite: Size {
+ width: true,
+ height: true,
+ },
parent_size: mode.to_physical(LogicalSize {
inline_size: space.known_size.inline_size,
block_size: None,
@@ -241,9 +263,9 @@ impl TableContext {
let natural = mode.to_logical(output.size).block_size;
let cell = &mut self.cells[index];
let baseline = if mode.is_horizontal() {
- output.first_baselines.y.or(output.block_content_end)
+ output.baselines.first.or(output.block_content_end)
} else {
- output.first_baselines.x
+ output.horizontal_baselines.first
};
let end_inset = if mode.is_horizontal() {
cell_padding.bottom + cell_border.bottom
@@ -346,9 +368,9 @@ impl TableContext {
width: Some(inline),
height: None,
},
- definite_dimensions: Size {
- width: Some(inline),
- height: None,
+ known_dimensions_are_definite: Size {
+ width: true,
+ height: true,
},
parent_size: Size {
width: Some(cell_percentage_basis),
@@ -374,8 +396,8 @@ impl TableContext {
layout_cell(world, cell, measure_inputs, mode, Some(layout))
});
let cell = &mut self.cells[index];
- cell.block_layout.as_mut().unwrap().baseline = output.first_baselines.y;
- if let Some(baseline) = output.first_baselines.y {
+ cell.block_layout.as_mut().unwrap().baseline = output.baselines.first;
+ if let Some(baseline) = output.baselines.first {
let row = &mut rows[cell.row];
row.ascent = Some(row.ascent.unwrap_or(0.0).max(baseline));
}
@@ -477,7 +499,7 @@ impl TableContext {
track.into()
})
.collect();
- self.style.align_content = Some(taffy::AlignContent::START);
+ self.style.align_content = taffy::AlignContent::START;
set_block(
mode,
&mut self.style.size,
@@ -493,8 +515,8 @@ impl TableContext {
used
}),
);
- set_block(mode, &mut self.style.min_size, Dimension::auto());
- set_block(mode, &mut self.style.max_size, Dimension::auto());
+ set_block(mode, &mut self.style.min_size, Dimension::auto().into());
+ set_block(mode, &mut self.style.max_size, Dimension::auto().into());
space.known_size.block_size = Some(used);
// Used geometry alone is not a new percentage-resolution guarantee.
space.into_layout_input()
@@ -518,8 +540,8 @@ where
set_block(mode, &mut inputs.known_dimensions, Some(layout.size));
set_block(
mode,
- &mut inputs.definite_dimensions,
- layout.definite.then_some(layout.size),
+ &mut inputs.known_dimensions_are_definite,
+ layout.definite,
);
// The used border box is always the absolute containing block, including
// auto-height cells. Normal-flow percentages need a separate guarantee.
@@ -532,10 +554,10 @@ where
world.compute_child_layout(cell.to_taffy(), inputs)
};
world.table_cell_percentage_height = previous;
- if layout.baseline.is_some() && output.first_baselines.y.is_none() {
+ if layout.baseline.is_some() && output.baselines.first.is_none() {
// This is measured again with final percentage constraints, but before
// relative positioning or absolute descendants contribute overflow.
- output.first_baselines.y = output.block_content_end;
+ output.baselines.first = output.block_content_end;
}
// Block/inline layout has already aligned the content group inside this
// final geometry. Only baseline alignment needs a later table-wide shift.
@@ -594,7 +616,12 @@ where
N: Copy + Debug + Eq + Hash,
{
for child in world.boxes[cell.index()].layout_children.clone() {
- if world.boxes[child.index()].style.taffy.position != taffy::Position::Absolute {
+ if !world.boxes[child.index()]
+ .style
+ .taffy
+ .position
+ .is_out_of_flow()
+ {
world.boxes[child.index()].unrounded_layout.location.y += offset;
}
}
diff --git a/moli-layout/src/table/cache.rs b/moli-layout/src/table/cache.rs
index d767423e3..766e3de4a 100644
--- a/moli-layout/src/table/cache.rs
+++ b/moli-layout/src/table/cache.rs
@@ -18,8 +18,9 @@ impl TableMeasureCache {
pub(crate) fn get(&mut self, inputs: LayoutInput) -> Option<LayoutOutput> {
let index = self.entries.iter().position(|(key, _)| *key == inputs)?;
let entry = self.entries.remove(index);
+ let output = entry.1.clone();
self.entries.push(entry);
- Some(entry.1)
+ Some(output)
}
pub(crate) fn store(&mut self, inputs: LayoutInput, output: LayoutOutput) {
@@ -43,7 +44,7 @@ impl TableMeasureCache {
#[cfg(test)]
mod tests {
use super::*;
- use taffy::{AvailableSpace, Point, RunMode, Size, SizingPurpose, WritingMode};
+ use taffy::{AvailableSpace, Baselines, RunMode, Size, SizingPurpose, WritingMode};
fn inputs(width: f32) -> LayoutInput {
LayoutInput {
@@ -60,7 +61,7 @@ mod tests {
fn measured_baselines_survive_reuse_but_not_different_constraints() {
let mut cache = TableMeasureCache::default();
let input = inputs(80.0);
- let output = LayoutOutput::from_sizes_and_baseline_sets(
+ let output = LayoutOutput::from_sizes_and_baselines(
Size {
width: 80.0,
height: 100.0,
@@ -68,21 +69,21 @@ mod tests {
Size {
width: 80.0,
height: 120.0,
- },
- Point {
- x: None,
- y: Some(15.0),
- },
- Point {
- x: None,
- y: Some(85.0),
+ }
+ .into(),
+ Baselines {
+ first: Some(15.0),
+ last: Some(85.0),
},
);
- cache.store(input, output);
+ cache.store(input, output.clone());
assert_eq!(cache.get(input), Some(output));
for changed in [
LayoutInput {
- definite_dimensions: input.known_dimensions,
+ known_dimensions_are_definite: Size {
+ width: false,
+ height: true,
+ },
..input
},
LayoutInput {
diff --git a/moli-layout/src/table/collapsed_borders.rs b/moli-layout/src/table/collapsed_borders.rs
index 4a80fd060..efd735ccc 100644
--- a/moli-layout/src/table/collapsed_borders.rs
+++ b/moli-layout/src/table/collapsed_borders.rs
@@ -288,24 +288,29 @@ impl CollapsedTableBorders {
{
let (start_width, start_wins) = self.horizontal_joint(row, column, true);
let (end_width, end_wins) = self.horizontal_joint(row, column, false);
+ let direction = if columns[column + 1] < columns[column] {
+ -1.0
+ } else {
+ 1.0
+ };
let mut start = columns[column];
let mut end = columns[column + 1];
if start_wins {
- start -= start_width / 2.0;
+ start -= direction * start_width / 2.0;
} else {
- start += start_width / 2.0;
+ start += direction * start_width / 2.0;
}
if end_wins {
- end += end_width / 2.0;
+ end += direction * end_width / 2.0;
} else {
- end -= end_width / 2.0;
+ end -= direction * end_width / 2.0;
}
- if end > start {
+ if (end - start) * direction > 0.0 {
self.segments.push(CollapsedTableBorderSegment {
rect: LayoutRect::new(
- start,
+ start.min(end),
rows[row] - edge.width / 2.0,
- end - start,
+ (end - start).abs(),
edge.width,
),
color: edge.color,
diff --git a/moli-layout/src/taffy_tree.rs b/moli-layout/src/taffy_tree.rs
index aca7be84e..ba3cb7407 100644
--- a/moli-layout/src/taffy_tree.rs
+++ b/moli-layout/src/taffy_tree.rs
@@ -181,12 +181,12 @@ where
height: Dimension::length(viewport.css_height as f32),
},
min_size: Size {
- width: Dimension::length(viewport.css_width as f32),
- height: Dimension::length(viewport.css_height as f32),
+ width: Dimension::length(viewport.css_width as f32).into(),
+ height: Dimension::length(viewport.css_height as f32).into(),
},
max_size: Size {
- width: Dimension::length(viewport.css_width as f32),
- height: Dimension::length(viewport.css_height as f32),
+ width: Dimension::length(viewport.css_width as f32).into(),
+ height: Dimension::length(viewport.css_height as f32).into(),
},
// The synthetic viewport is the initial containing block. Model UA
// scrollbar gutters as its non-painted border: in-flow root content
@@ -369,6 +369,16 @@ impl<Tree> RoundTree for CssSubpixelRoundTree<'_, Tree>
where
Tree: RoundTree + ?Sized,
{
+ fn is_out_of_flow(&self, node: NodeId) -> bool {
+ self.tree.is_out_of_flow(node)
+ }
+ fn hoisted_child_count(&self, node: NodeId) -> usize {
+ self.tree.hoisted_child_count(node)
+ }
+ fn get_hoisted_child_id(&self, node: NodeId, index: usize) -> NodeId {
+ self.tree.get_hoisted_child_id(node, index)
+ }
+
fn get_unrounded_layout(&self, node_id: NodeId) -> Layout {
scale_layout(
self.tree.get_unrounded_layout(node_id),
@@ -386,7 +396,7 @@ fn scale_layout(layout: Layout, factor: f32) -> Layout {
Layout {
location: layout.location.map(|value| value * factor),
size: layout.size.map(|value| value * factor),
- content_size: layout.content_size.map(|value| value * factor),
+ scrollable_overflow_rect: layout.scrollable_overflow_rect.map(|value| value * factor),
scrollbar_size: layout.scrollbar_size.map(|value| value * factor),
border: layout.border.map(|value| value * factor),
padding: layout.padding.map(|value| value * factor),
@@ -608,7 +618,10 @@ where
.max(0.0);
let inputs = LayoutInput {
known_dimensions: Size::NONE,
- definite_dimensions: Size::NONE,
+ known_dimensions_are_definite: Size {
+ width: true,
+ height: true,
+ },
parent_size: Size {
width: Some(parent_width),
height: None,
@@ -663,7 +676,7 @@ where
world.set_inline_child_layout(
marker,
Point { x, y },
- output,
+ &output,
marker.index(),
Some(parent_width),
);
@@ -704,7 +717,10 @@ where
.max(0.0);
let inputs = LayoutInput {
known_dimensions: Size::NONE,
- definite_dimensions: Size::NONE,
+ known_dimensions_are_definite: Size {
+ width: true,
+ height: true,
+ },
parent_size: Size {
width: Some(content_width),
height: None,
@@ -736,7 +752,7 @@ where
world.set_inline_child_layout(
content,
Point { x, y },
- output,
+ &output,
content.index(),
Some(content_width),
);
@@ -1040,10 +1056,10 @@ where
let cross_overflows = child_layout.size.get_abs(physical_cross_axis) + child_cross_margin_size
> content_size.get_abs(physical_cross_axis);
let main_edge =
- flex_main_axis_static_edge(container_box.style.taffy.justify_content, is_reverse);
+ flex_main_axis_static_edge(Some(container_box.style.taffy.justify_content), is_reverse);
let cross_edge = FlexCrossAxisStaticContext {
align_self: child_box.style.taffy.align_self,
- align_items: container_box.style.taffy.align_items,
+ align_items: Some(container_box.style.taffy.align_items),
flex_wrap: container_box.style.taffy.flex_wrap,
child_writing_mode: child_box.style.writing_mode(),
child_direction: child_box.style.taffy.direction,
@@ -1279,7 +1295,7 @@ fn layout_inline_absolute_child<N>(
{
let child_writing_mode = world.boxes[child.index()].style.writing_mode();
let style = world.boxes[child.index()].style.taffy.clone();
- if style.display == Display::None || style.position != taffy::Position::Absolute {
+ if style.display == Display::None || !style.position.is_out_of_flow() {
return;
}
@@ -1386,7 +1402,10 @@ fn layout_inline_absolute_child<N>(
child,
LayoutInput {
known_dimensions,
- definite_dimensions: known_dimensions,
+ known_dimensions_are_definite: Size {
+ width: true,
+ height: true,
+ },
parent_size: area.size.map(Some),
parent_writing_mode: area.writing_mode,
available_space,
@@ -1408,7 +1427,10 @@ fn layout_inline_absolute_child<N>(
child.to_taffy(),
LayoutInput {
known_dimensions,
- definite_dimensions: known_dimensions,
+ known_dimensions_are_definite: Size {
+ width: true,
+ height: true,
+ },
parent_size: area.size.map(Some),
parent_writing_mode: area.writing_mode,
available_space,
@@ -1428,7 +1450,10 @@ fn layout_inline_absolute_child<N>(
child.to_taffy(),
LayoutInput {
known_dimensions: final_size.map(Some),
- definite_dimensions: known_dimensions,
+ known_dimensions_are_definite: (final_size.map(Some))
+ .zip_map(known_dimensions, |known, definite| {
+ known.is_none() || definite.is_some()
+ }),
parent_size: area.size.map(Some),
parent_writing_mode: area.writing_mode,
available_space,
@@ -1500,7 +1525,7 @@ fn layout_inline_absolute_child<N>(
world.boxes[child.index()].unrounded_layout = Layout {
order: 0,
size: final_size,
- content_size: output.content_size,
+ scrollable_overflow_rect: output.scrollable_overflow_rect,
scrollbar_size,
location: Point {
x: area.origin.x + x - numeric_parent_origin.x,
@@ -1612,6 +1637,17 @@ where
}
}
+ fn get_parent_writing_mode(&self, node_id: NodeId) -> taffy::WritingMode {
+ if self.is_viewport_taffy_node(node_id) {
+ return self.get_writing_mode(node_id);
+ }
+ let id = LayoutBoxId::from_taffy(node_id);
+ self.boxes[id.index()]
+ .layout_parent
+ .map(|parent| self.boxes[parent.index()].style.writing_mode())
+ .unwrap_or_else(|| self.get_writing_mode(node_id))
+ }
+
fn get_resolved_aspect_ratio(&self, node_id: NodeId) -> Option<taffy::ResolvedAspectRatio> {
if self.is_viewport_taffy_node(node_id) {
return self.viewport_layout.style.aspect_ratio.and_then(|ratio| {
@@ -1676,7 +1712,11 @@ where
};
if self.is_viewport_taffy_node(node_id) {
return compute_cached_layout(self, node_id, inputs, |world, node_id, inputs| {
- compute_block_layout(world, node_id, inputs, None)
+ let mut output = compute_block_layout(world, node_id, inputs, None);
+ if inputs.run_mode == RunMode::PerformLayout {
+ taffy::compute_oof_layout(world, node_id, &mut output);
+ }
+ output
});
}
if self.should_hide(node_id, inputs) {
@@ -1701,7 +1741,7 @@ where
self.boxes[id.index()]
.table_measure_cache
.get_or_insert_with(Default::default)
- .store(inputs, output);
+ .store(inputs, output.clone());
return output;
}
if self.measure_baselines && inputs.run_mode == RunMode::ComputeSize {
@@ -1717,7 +1757,7 @@ impl<N> CacheTree for LayoutWorld<N>
where
N: Copy + Debug + Eq + Hash,
{
- fn cache_get(&self, node_id: NodeId, inputs: &LayoutInput) -> Option<LayoutOutput> {
+ fn cache_get(&mut self, node_id: NodeId, inputs: &LayoutInput) -> Option<LayoutOutput> {
if self.is_viewport_taffy_node(node_id) {
self.viewport_layout.cache.get(inputs)
} else {
@@ -1862,7 +1902,11 @@ where
self.get_core_container_style(child_node_id)
}
- fn set_detailed_grid_info(&mut self, node_id: NodeId, detailed_grid_info: DetailedGridInfo) {
+ fn set_detailed_grid_info(
+ &mut self,
+ node_id: NodeId,
+ detailed_grid_info: DetailedGridInfo<Atom>,
+ ) {
let layout_box = &self.boxes[LayoutBoxId::from_taffy(node_id).index()];
if layout_box
.capability_diagnostics
@@ -1889,6 +1933,16 @@ impl<N> RoundTree for LayoutWorld<N>
where
N: Copy + Debug + Eq + Hash,
{
+ fn is_out_of_flow(&self, _: NodeId) -> bool {
+ false
+ }
+ fn hoisted_child_count(&self, _: NodeId) -> usize {
+ 0
+ }
+ fn get_hoisted_child_id(&self, _: NodeId, _: usize) -> NodeId {
+ unreachable!()
+ }
+
fn get_unrounded_layout(&self, node_id: NodeId) -> Layout {
if self.is_viewport_taffy_node(node_id) {
self.viewport_layout.unrounded_layout
@@ -1942,7 +1996,11 @@ where
inputs: LayoutInput,
block_context: Option<&mut BlockContext<'_>>,
) -> LayoutOutput {
- self.compute_child_layout_for_box(node_id, inputs, block_context)
+ let mut output = self.compute_child_layout_for_box(node_id, inputs, block_context);
+ if inputs.run_mode == RunMode::PerformLayout {
+ taffy::compute_oof_layout(self, node_id, &mut output);
+ }
+ output
}
fn compute_child_layout_for_box(
@@ -2069,7 +2127,8 @@ where
// horizontal margins. Grid's final item layout (including its
// two-axis abspos measurement) removes margins in both axes;
// its single-axis track contributions still include them.
- // Atomic inlines and flex items use margin-inclusive space.
+ // Atomic inlines use margin-inclusive space. Flex now removes
+ // margins before both measuring and laying out its children.
// Select by the actual parent algorithm: flex/grid items are also
// blockified and ignore their authored float.
let parent_is_grid = layout_box.layout_parent.is_some_and(|parent| {
@@ -2078,19 +2137,26 @@ where
.display()
.is_grid_container()
});
- let available_space_margins =
- if parent_is_grid && inputs.axis == taffy::RequestedAxis::Both {
- AvailableSpaceMargins::Excluded
- } else if style.position != taffy::Position::Absolute
- && (box_is_effectively_floated(self, id)
- || layout_box
- .layout_parent
- .is_none_or(|parent| original_parent_uses_block_layout(self, parent)))
- {
- AvailableSpaceMargins::HorizontalExcluded
- } else {
- AvailableSpaceMargins::Included
- };
+ let parent_is_flex = layout_box.layout_parent.is_some_and(|parent| {
+ self.boxes[parent.index()]
+ .style
+ .display()
+ .is_flex_container()
+ });
+ let available_space_margins = if parent_is_flex
+ || (parent_is_grid && inputs.axis == taffy::RequestedAxis::Both)
+ {
+ AvailableSpaceMargins::Excluded
+ } else if !style.position.is_out_of_flow()
+ && (box_is_effectively_floated(self, id)
+ || layout_box
+ .layout_parent
+ .is_none_or(|parent| original_parent_uses_block_layout(self, parent)))
+ {
+ AvailableSpaceMargins::HorizontalExcluded
+ } else {
+ AvailableSpaceMargins::Included
+ };
// `measure_replaced` is the complete CSS replaced-element sizing
// algorithm ported from Blitz: it resolves preferred/min/max
// sizes and returns a border-box size. Taffy's generic leaf
@@ -2150,24 +2216,9 @@ where
let writing_mode = self.boxes[id.index()].style.writing_mode();
let resolved_aspect_ratio = self.boxes[id.index()].resolved_aspect_ratio();
let is_floated = box_is_effectively_floated(self, id);
- // Both Taffy's block-float parent and Moli's IFC float parent
- // pass the border-box space left after horizontal margins. Taffy's
- // generic leaf adapter normally subtracts a leaf's own margins, so
- // restore them only around that adapter to keep the parent-owned
- // float-margin contract from being applied twice.
- let leaf_inputs = if is_floated {
- let margin = style
- .margin
- .resolve_or_zero(inputs.parent_size.width, resolve_stylo_calc_value);
- LayoutInput {
- available_space: inputs
- .available_space
- .map_width(|width| width.maybe_add(margin.left + margin.right)),
- ..inputs
- }
- } else {
- inputs
- };
+ // The 0.15 leaf contract takes space after margins. Both the native
+ // block parent and the IFC float parent already supply that space.
+ let leaf_inputs = inputs;
// The leaf adapter's size-only shortcut drops the line baselines.
// Only the adapter needs full measurement: the original inputs still
// keep Parley on its measurement path without final paint fragments.
@@ -2262,7 +2313,7 @@ where
height: content_box_height,
};
let block_offset = single_subject_block_alignment_offset(
- style.align_content,
+ Some(style.align_content),
content_box_height - measurement.alignment_block_size,
);
measurement.translate_block_axis(block_offset);
@@ -2273,16 +2324,16 @@ where
+ scrollbar_insets.top
+ block_offset,
);
- output.content_size.height = output.content_size.height.max(
+ output.scrollable_overflow_rect.bottom = output.scrollable_overflow_rect.bottom.max(
measurement.alignment_block_size
+ padding.top
+ padding.bottom
+ block_offset.max(0.0),
);
- output.first_baselines.y = measurement
+ output.baselines.first = measurement
.first_baseline
.map(|baseline| baseline + padding.top + border.top + scrollbar_insets.top);
- output.last_baselines.y = measurement
+ output.baselines.last = measurement
.last_baseline
.map(|baseline| baseline + padding.top + border.top + scrollbar_insets.top);
if measurement.has_non_phantom_line {
@@ -2359,7 +2410,10 @@ where
sizing_purpose: inputs.sizing_purpose,
axis: inputs.axis,
known_dimensions: Size::NONE,
- definite_dimensions: Size::NONE,
+ known_dimensions_are_definite: Size {
+ width: true,
+ height: true,
+ },
parent_size: available_space.into_options(),
parent_writing_mode,
available_space,
@@ -2413,7 +2467,7 @@ where
let object_index = usize::try_from(inline_box.id)
.expect("Parley returned an inline object id outside usize");
atomic_baseline_ascents[object_index] = self
- .atomic_inline_baseline(object.box_id, child_output)
+ .atomic_inline_baseline(object.box_id, &child_output)
.map(|baseline| margins.top + baseline);
atomic[object_index] = Some(AtomicMeasurement {
output: child_output,
@@ -2730,7 +2784,7 @@ where
}
}
- fn atomic_inline_baseline(&self, id: LayoutBoxId, output: LayoutOutput) -> Option<f32> {
+ fn atomic_inline_baseline(&self, id: LayoutBoxId, output: &LayoutOutput) -> Option<f32> {
let layout_box = &self.boxes[id.index()];
match layout_box.style.display() {
// Blink's block layout marks these atomic fragments to use their
@@ -2739,7 +2793,7 @@ where
crate::LayoutDisplay::InlineBlock | crate::LayoutDisplay::InlineListItem => {
(layout_box.style.taffy.overflow.x == taffy::Overflow::Visible
&& layout_box.style.taffy.overflow.y == taffy::Overflow::Visible)
- .then_some(output.last_baselines.y)
+ .then_some(output.baselines.last)
.flatten()
}
// Flex, grid, and table formatting contexts expose their first
@@ -2747,7 +2801,7 @@ where
// the inline-block overflow exception to these fragment types.
crate::LayoutDisplay::InlineFlex
| crate::LayoutDisplay::InlineGrid
- | crate::LayoutDisplay::InlineTable => output.first_baselines.y,
+ | crate::LayoutDisplay::InlineTable => output.baselines.first,
// Replaced and other atomic inline-level boxes synthesize their
// baseline at the appropriate box edge in the caller.
_ => None,
@@ -2859,6 +2913,7 @@ where
let output = self.compute_child_layout(child.to_taffy(), layout_inputs);
let state = breaker.state_mut();
let position = block_context.place_floated_box(
+ child.index() as u64,
output.size + margin.sum_axes(),
state.line_y() as f32,
direction,
@@ -2904,7 +2959,7 @@ where
self.set_inline_child_layout(
floated.child,
floated.location,
- floated.output,
+ &floated.output,
floated.order,
floated.parent_width,
);
@@ -2949,7 +3004,7 @@ where
if object.role != InlineObjectRole::Atomic {
continue;
}
- let Some(atomic) = measurement.atomic[object_index] else {
+ let Some(atomic) = &measurement.atomic[object_index] else {
continue;
};
let inset_offset = relative_atomic_inset_offset(
@@ -2967,7 +3022,7 @@ where
+ vertical_offset
+ inset_offset.y,
},
- atomic.output,
+ &atomic.output,
object_index,
measurement.percentage_basis,
);
@@ -2979,7 +3034,7 @@ where
&mut self,
child: LayoutBoxId,
location: Point<f32>,
- output: LayoutOutput,
+ output: &LayoutOutput,
order: usize,
parent_width: Option<f32>,
) {
@@ -2998,7 +3053,7 @@ where
order: u32::try_from(order).unwrap_or(u32::MAX),
location,
size: output.size,
- content_size: output.content_size,
+ scrollable_overflow_rect: output.scrollable_overflow_rect,
scrollbar_size,
border,
padding,
@@ -3031,13 +3086,13 @@ fn inline_percentage_basis(
.or_else(|| (sizing_purpose == SizingPurpose::IntrinsicContribution).then_some(0.0))
}
-#[derive(Clone, Copy)]
+#[derive(Clone)]
struct AtomicMeasurement {
output: LayoutOutput,
margins: taffy::Rect<f32>,
}
-#[derive(Clone, Copy)]
+#[derive(Clone)]
struct InlineFloatPlacement {
child: LayoutBoxId,
location: Point<f32>,
@@ -3114,7 +3169,8 @@ pub(crate) fn single_subject_block_alignment_offset(
keyword = AlignContentKeyword::Start;
}
match keyword {
- AlignContentKeyword::Start
+ AlignContentKeyword::Normal
+ | AlignContentKeyword::Start
| AlignContentKeyword::FlexStart
| AlignContentKeyword::Stretch
| AlignContentKeyword::SpaceBetween => 0.0,
@@ -3206,6 +3262,28 @@ fn measure_text(
#[cfg(test)]
mod cache_storage_tests;
+impl<N: Copy + Debug + Eq + Hash> taffy::LayoutContainingBlock for LayoutWorld<N> {
+ type OofItemStyle<'a>
+ = &'a Style<Atom>
+ where
+ Self: 'a;
+ fn get_oof_item_style(&self, node: NodeId) -> Self::OofItemStyle<'_> {
+ self.get_core_container_style(node)
+ }
+ fn get_containing_block_claims(&self, _: NodeId) -> taffy::ContainingBlockClaims {
+ // prepare_layout_tree has already attached every positioned box to
+ // its CSS containing block. Internal static-position probes retain
+ // their original formatting parent. Claim those numeric edges here:
+ // bubbling them again would change their coordinate parent while
+ // leaving Moli's retained geometry graph unchanged.
+ taffy::ContainingBlockClaims::ALL
+ }
+ // The prepared numeric graph is the browser's retained geometry ownership graph.
+ // Taffy's transient hoisted lists would duplicate edges already stored there.
+ fn clear_hoisted_children(&mut self, _: NodeId) {}
+ fn add_hoisted_children(&mut self, _: NodeId, _: &[NodeId]) {}
+}
+
#[cfg(test)]
mod tests {
use super::{inline_percentage_basis, round_layout_to_css_subpixels};
@@ -3259,6 +3337,15 @@ mod tests {
impl TraverseTree for TestRoundTree {}
impl RoundTree for TestRoundTree {
+ fn is_out_of_flow(&self, _: NodeId) -> bool {
+ false
+ }
+ fn hoisted_child_count(&self, _: NodeId) -> usize {
+ 0
+ }
+ fn get_hoisted_child_id(&self, _: NodeId, _: usize) -> NodeId {
+ unreachable!()
+ }
fn get_unrounded_layout(&self, node_id: NodeId) -> Layout {
self.0[usize::from(node_id)].unrounded
}
@@ -3353,9 +3440,9 @@ mod tests {
width: Some(100.0),
height: None,
},
- definite_dimensions: Size {
- width: Some(100.0),
- height: None,
+ known_dimensions_are_definite: Size {
+ width: true,
+ height: true,
},
parent_size: Size {
width: Some(100.0),
diff --git a/moli-layout/src/taffy_tree/cache_storage_tests.rs b/moli-layout/src/taffy_tree/cache_storage_tests.rs
index dd099ba78..c37512b52 100644
--- a/moli-layout/src/taffy_tree/cache_storage_tests.rs
+++ b/moli-layout/src/taffy_tree/cache_storage_tests.rs
@@ -31,9 +31,9 @@ fn input() -> LayoutInput {
width: Some(60.0),
height: Some(20.0),
},
- definite_dimensions: Size {
- width: Some(60.0),
- height: Some(20.0),
+ known_dimensions_are_definite: Size {
+ width: true,
+ height: true,
},
parent_size: Size {
width: Some(240.0),
diff --git a/moli-layout/src/taffy_tree/measurement.rs b/moli-layout/src/taffy_tree/measurement.rs
index c359abfa3..448081acd 100644
--- a/moli-layout/src/taffy_tree/measurement.rs
+++ b/moli-layout/src/taffy_tree/measurement.rs
@@ -42,6 +42,10 @@ impl<N: Copy + Debug + Eq + Hash> LayoutPartialTree for FullMeasurementTree<'_,
self.0.get_writing_mode(node_id)
}
+ fn get_parent_writing_mode(&self, node: NodeId) -> taffy::WritingMode {
+ self.0.get_parent_writing_mode(node)
+ }
+
fn get_scrollbar_insets(&self, node_id: NodeId) -> taffy::Rect<f32> {
self.0.get_scrollbar_insets(node_id)
}
@@ -171,5 +175,5 @@ impl<N: Copy + Debug + Eq + Hash> LayoutGridContainer for FullMeasurementTree<'_
self.0.get_grid_child_style(node_id)
}
- fn set_detailed_grid_info(&mut self, _: NodeId, _: DetailedGridInfo) {}
+ fn set_detailed_grid_info(&mut self, _: NodeId, _: DetailedGridInfo<Atom>) {}
}
diff --git a/moli-layout/src/world.rs b/moli-layout/src/world.rs
index 4a4894af9..32c6bd813 100644
--- a/moli-layout/src/world.rs
+++ b/moli-layout/src/world.rs
@@ -696,9 +696,9 @@ where
}
}
- pub(crate) fn numeric_cache(&self, id: LayoutBoxId) -> Option<&Cache> {
+ pub(crate) fn numeric_cache(&mut self, id: LayoutBoxId) -> Option<&mut Cache> {
let slot = self.boxes.get(id.index())?.cache_slot?;
- self.box_caches.get((slot.get() - 1) as usize)
+ self.box_caches.get_mut((slot.get() - 1) as usize)
}
pub(crate) fn numeric_cache_mut(&mut self, id: LayoutBoxId) -> &mut Cache {
diff --git a/moli-layout/tests/main_layout_contract.rs b/moli-layout/tests/main_layout_contract.rs
index c23eb3988..0157dc1b0 100644
--- a/moli-layout/tests/main_layout_contract.rs
+++ b/moli-layout/tests/main_layout_contract.rs
@@ -331,7 +331,7 @@ fn flex_wrap_gap_and_cross_axis_distribution_are_numeric() {
width: length(10.0),
height: length(20.0),
},
- align_content: Some(AlignContent::SPACE_BETWEEN),
+ align_content: AlignContent::SPACE_BETWEEN,
..Style::default()
},
PaintColor::TRANSPARENT,
@@ -500,7 +500,7 @@ fn flex_grow_shrink_and_cross_axis_alignment_are_numeric() {
width: length(300.0),
height: length(100.0),
},
- align_items: Some(taffy::AlignItems::CENTER),
+ align_items: taffy::AlignItems::CENTER,
..Style::default()
},
PaintColor::TRANSPARENT,
@@ -729,8 +729,8 @@ fn grid_container_justify_items_center_shrink_wraps_an_auto_sized_item() {
width: length(300.0),
height: length(200.0),
},
- justify_items: Some(taffy::AlignItems::CENTER),
- align_items: Some(taffy::AlignItems::CENTER),
+ justify_items: taffy::AlignItems::CENTER,
+ align_items: taffy::AlignItems::CENTER,
..Style::default()
},
PaintColor::TRANSPARENT,
@@ -781,8 +781,8 @@ fn centered_grid_item_with_percent_height_and_auto_block_margin_keeps_intrinsic_
bottom: length(0.0),
},
grid_template_rows: vec![fr(1.0)],
- justify_items: Some(taffy::AlignItems::CENTER),
- align_items: Some(taffy::AlignItems::CENTER),
+ justify_items: taffy::AlignItems::CENTER,
+ align_items: taffy::AlignItems::CENTER,
..Style::default()
},
PaintColor::TRANSPARENT,
@@ -798,7 +798,7 @@ fn centered_grid_item_with_percent_height_and_auto_block_margin_keeps_intrinsic_
height: percent(1.0),
},
max_size: Size {
- width: Dimension::auto(),
+ width: Dimension::auto().into(),
height: length(92.0),
},
margin: Rect {
@@ -1140,7 +1140,7 @@ fn block_percentage_box_sizing_and_min_max_resolve_against_containing_block() {
},
max_size: Size {
width: length(240.0),
- height: Dimension::auto(),
+ height: Dimension::auto().into(),
},
margin: Rect {
left: length(30.0),
diff --git a/moli-layout/tests/phase4_layout_contract.rs b/moli-layout/tests/phase4_layout_contract.rs
index b7a5048a1..fd1227101 100644
--- a/moli-layout/tests/phase4_layout_contract.rs
+++ b/moli-layout/tests/phase4_layout_contract.rs
@@ -332,8 +332,8 @@ fn padded_intrinsic_items_measure_wrapping_in_content_box_space() {
style(LayoutDisplay::Block, YELLOW)
.tap_taffy(|taffy| {
taffy.size.width = Dimension::max_content();
- taffy.min_size.width = Dimension::min_content();
- taffy.max_size.width = Dimension::percent(1.0);
+ taffy.min_size.width = Dimension::min_content().into();
+ taffy.max_size.width = Dimension::percent(1.0).into();
taffy.box_sizing = BoxSizing::ContentBox;
taffy.justify_self = Some(taffy::AlignSelf::START);
taffy.flex_shrink = 0.0;
@@ -421,8 +421,8 @@ fn assert_grid_intrinsic_item_contributes_constrained_height(min_width: Dimensio
style(LayoutDisplay::Block, PaintColor::TRANSPARENT)
.tap_taffy(|taffy| {
taffy.size.width = Dimension::max_content();
- taffy.min_size.width = min_width;
- taffy.max_size.width = Dimension::percent(1.0);
+ taffy.min_size.width = min_width.into();
+ taffy.max_size.width = Dimension::percent(1.0).into();
taffy.justify_self = Some(taffy::AlignSelf::CENTER);
})
.with_text_metrics(47.0, 52.0),
@@ -1134,7 +1134,7 @@ fn block_content_alignment_moves_the_inline_float_fragment_group() {
width: Dimension::length(200.0),
height: Dimension::length(100.0),
};
- taffy.align_content = Some(taffy::AlignContent::SAFE_CENTER);
+ taffy.align_content = taffy::AlignContent::SAFE_CENTER;
}),
);
styles.primary.insert(
@@ -2796,7 +2796,7 @@ fn single_row_textarea_does_not_expand_its_flex_search_bar() {
style(LayoutDisplay::Flex, PaintColor::TRANSPARENT).tap_taffy(|taffy| {
taffy.display = taffy::Display::Flex;
taffy.size.width = Dimension::length(300.0);
- taffy.min_size.height = Dimension::length(50.0);
+ taffy.min_size.height = Dimension::length(50.0).into();
}),
);
styles.primary.insert(
diff --git a/moli-layout/tests/phase5_output_contract.rs b/moli-layout/tests/phase5_output_contract.rs
index e4c6a205e..f555da1a5 100644
--- a/moli-layout/tests/phase5_output_contract.rs
+++ b/moli-layout/tests/phase5_output_contract.rs
@@ -1470,7 +1470,7 @@ fn stable_both_edges_reserves_horizontal_space_during_numeric_layout() {
},
min_size: Size {
width: length(400.0),
- height: Dimension::auto(),
+ height: Dimension::auto().into(),
},
..Style::default()
},
diff --git a/moli-parser/Cargo.toml b/moli-parser/Cargo.toml
index 0e29e24b3..cc55a5ca0 100644
--- a/moli-parser/Cargo.toml
+++ b/moli-parser/Cargo.toml
@@ -12,15 +12,15 @@ test-support = []
[dependencies]
anyhow = "1.0.100"
-html5ever = "0.39.0"
+html5ever = "0.40"
moli-dom = { path = "../moli-dom" }
moli-fetch = { path = "../moli-fetch" }
moli-page-types = { path = "../moli-page-types" }
moli-script = { path = "../moli-script" }
moli-stylesheet-blocking = { path = "../moli-stylesheet-blocking" }
-markup5ever = "0.39.0"
+markup5ever = "0.40"
url = "2.5.7"
-xml5ever = "0.39.0"
+xml5ever = "0.40.0"
xmlparser = "0.13.6"
[lints]
diff --git a/moli-parser/src/html.rs b/moli-parser/src/html.rs
index b2e49a073..35da70b9b 100644
--- a/moli-parser/src/html.rs
+++ b/moli-parser/src/html.rs
@@ -1450,9 +1450,9 @@ impl ParseHandle {
fn is_script_element(&self) -> bool {
self.element_name.as_ref().is_some_and(|name| {
- name.local.as_ref() == "script"
+ AsRef::<str>::as_ref(&name.local) == "script"
&& matches!(
- name.ns.as_ref(),
+ AsRef::<str>::as_ref(&name.ns),
"http://www.w3.org/1999/xhtml" | "http://www.w3.org/2000/svg"
)
})
@@ -2031,7 +2031,7 @@ mod tests {
fragment_context
.element_name
.as_deref()
- .map(|name| name.local.as_ref()),
+ .map(|name| AsRef::<str>::as_ref(&name.local)),
Some("body")
);
}
diff --git a/moli-parser/src/live_target.rs b/moli-parser/src/live_target.rs
index 0753329dc..d638b9af3 100644
--- a/moli-parser/src/live_target.rs
+++ b/moli-parser/src/live_target.rs
@@ -2549,8 +2549,8 @@ impl ParserStreamHtmlTreeSinkTarget {
}
self.note_blocking_stylesheet_pause_if_needed(node_id);
let is_html_link = handle.element_name.as_ref().is_some_and(|name| {
- name.ns.as_ref() == "http://www.w3.org/1999/xhtml"
- && name.local.as_ref().eq_ignore_ascii_case("link")
+ AsRef::<str>::as_ref(&name.ns) == "http://www.w3.org/1999/xhtml"
+ && AsRef::<str>::as_ref(&name.local).eq_ignore_ascii_case("link")
});
if is_html_link {
// `<link>` is a void element, so html5ever does not necessarily
@@ -2646,9 +2646,9 @@ impl ParserStreamHtmlTreeSinkTarget {
}
self.finish_parsing_children(node_id);
if element.is_some_and(|element| {
- element.name.local.as_ref() == "style"
+ AsRef::<str>::as_ref(&element.name.local) == "style"
&& matches!(
- element.name.ns.as_ref(),
+ AsRef::<str>::as_ref(&element.name.ns),
"http://www.w3.org/1999/xhtml" | "http://www.w3.org/2000/svg"
)
}) {
@@ -2663,11 +2663,11 @@ impl ParserStreamHtmlTreeSinkTarget {
let mut first = true;
let mut matching_index = None;
for (index, element) in self.open_parser_elements.iter().enumerate().rev() {
- let is_html = element.name.ns.as_ref() == "http://www.w3.org/1999/xhtml";
+ let is_html = AsRef::<str>::as_ref(&element.name.ns) == "http://www.w3.org/1999/xhtml";
if !first && is_html {
return None;
}
- if element.name.local.as_ref().eq_ignore_ascii_case(local_name) {
+ if AsRef::<str>::as_ref(&element.name.local).eq_ignore_ascii_case(local_name) {
matching_index = Some(index);
break;
}
@@ -2697,8 +2697,8 @@ impl ParserStreamHtmlTreeSinkTarget {
local_name: &str,
) -> Option<NativeNodeId> {
let element = self.open_parser_elements.last()?;
- if element.name.ns.as_ref() == "http://www.w3.org/1999/xhtml"
- || !element.name.local.as_ref().eq_ignore_ascii_case(local_name)
+ if AsRef::<str>::as_ref(&element.name.ns) == "http://www.w3.org/1999/xhtml"
+ || !AsRef::<str>::as_ref(&element.name.local).eq_ignore_ascii_case(local_name)
{
return None;
}
@@ -3202,10 +3202,7 @@ impl ParserStreamHtmlTreeSinkTarget {
.into_iter()
.map(|attribute| {
if attribute.name.ns.to_string().is_empty()
- && attribute
- .name
- .local
- .as_ref()
+ && AsRef::<str>::as_ref(&attribute.name.local)
.eq_ignore_ascii_case("customelementregistry")
{
has_null_custom_element_registry_attribute = true;
diff --git a/moli-parser/src/session.rs b/moli-parser/src/session.rs
index 9b8e3581f..6bcfb0494 100644
--- a/moli-parser/src/session.rs
+++ b/moli-parser/src/session.rs
@@ -85,21 +85,25 @@ impl EmbedderPausingTreeBuilder {
) -> TokenSinkResult<ParseHandle> {
let current_script_nonceable = match &token {
Token::TagToken(tag)
- if tag.kind == TagKind::StartTag && tag.name.as_ref() == "script" =>
+ if tag.kind == TagKind::StartTag && AsRef::<str>::as_ref(&tag.name) == "script" =>
{
let nonce = tag
.attrs
.iter()
.find(|attribute| {
- attribute.name.ns.is_empty() && attribute.name.local.as_ref() == "nonce"
+ attribute.name.ns.is_empty()
+ && AsRef::<str>::as_ref(&attribute.name.local) == "nonce"
})
.map(|attribute| attribute.value.as_ref());
Some(script_element_nonce_is_nonceable(
nonce,
tag.had_duplicate_attributes,
- tag.attrs
- .iter()
- .map(|attribute| (attribute.name.local.as_ref(), attribute.value.as_ref())),
+ tag.attrs.iter().map(|attribute| {
+ (
+ AsRef::<str>::as_ref(&attribute.name.local),
+ attribute.value.as_ref(),
+ )
+ }),
))
}
_ => None,
diff --git a/moli-parser/src/xml.rs b/moli-parser/src/xml.rs
index baf749428..9e5e8a117 100644
--- a/moli-parser/src/xml.rs
+++ b/moli-parser/src/xml.rs
@@ -430,8 +430,8 @@ impl<'a> XmlLiveTreeSinkTarget<'a> {
for attribute in attrs {
let already_exists = element.attributes().iter().any(|existing| {
- existing.namespace() == attribute.name.ns.as_ref()
- && existing.local_name() == attribute.name.local.as_ref()
+ existing.namespace() == AsRef::<str>::as_ref(&attribute.name.ns)
+ && existing.local_name() == AsRef::<str>::as_ref(&attribute.name.local)
&& existing.prefix()
== attribute.name.prefix.as_ref().map(|prefix| prefix.as_ref())
});
diff --git a/moli-parser/src/xml_stream.rs b/moli-parser/src/xml_stream.rs
index a4ee1d5b3..f9a40f501 100644
--- a/moli-parser/src/xml_stream.rs
+++ b/moli-parser/src/xml_stream.rs
@@ -732,9 +732,9 @@ impl TreeSink for XmlStreamDocumentSink {
fn pop(&self, node: &Self::Handle) {
let is_script = node.inner.element_name.as_ref().is_some_and(|name| {
- name.local.as_ref() == "script"
+ AsRef::<str>::as_ref(&name.local) == "script"
&& matches!(
- name.ns.as_ref(),
+ AsRef::<str>::as_ref(&name.ns),
"http://www.w3.org/1999/xhtml" | "http://www.w3.org/2000/svg"
)
});
@@ -794,9 +794,9 @@ fn xml_name_to_html(name: &XmlQualName) -> HtmlQualName {
HtmlQualName::new(
name.prefix
.as_ref()
- .map(|prefix| HtmlPrefix::from(prefix.as_ref())),
- HtmlNamespace::from(name.ns.as_ref()),
- HtmlLocalName::from(name.local.as_ref()),
+ .map(|prefix| HtmlPrefix::from(AsRef::<str>::as_ref(prefix))),
+ HtmlNamespace::from(AsRef::<str>::as_ref(&name.ns)),
+ HtmlLocalName::from(AsRef::<str>::as_ref(&name.local)),
)
}
diff --git a/moli-renderer-v8/Cargo.toml b/moli-renderer-v8/Cargo.toml
index 5e810f1f5..5dc657c60 100644
--- a/moli-renderer-v8/Cargo.toml
+++ b/moli-renderer-v8/Cargo.toml
@@ -21,9 +21,9 @@ base64 = "0.22"
brotlic = "0.8.2"
bytes = "1"
crossbeam-channel = "0.5.15"
-cssparser = "0.37"
+cssparser = "0.38"
data-url = "0.3.2"
-dom = { package = "stylo_dom", version = "0.20" }
+dom = { package = "stylo_dom", version = "0.22" }
encoding_rs = "0.8"
flate2 = { version = "1.1.9", default-features = false, features = ["zlib"] }
euclid = "0.22"
@@ -31,9 +31,9 @@ kurbo = "0.13.1"
futures-util = "0.3.31"
precomputed-hash = "0.1"
percent-encoding = "2.3"
-selectors = "0.40"
-stylo = "0.20"
-stylo_static_prefs = "0.20"
+selectors = "0.41"
+stylo = "0.22"
+stylo_static_prefs = "0.22"
moli-action-window = { path = "../moli-action-window" }
moli-broadcast-channel = { path = "../moli-broadcast-channel" }
moli-browser-profile = { path = "../moli-browser-profile" }
@@ -98,12 +98,12 @@ curl = { version = "0.4.51", default-features = false, features = ["brotli", "ht
http = "1"
httpdate = "1.0.3"
html-escape = "0.2.13"
-html5ever = "0.39.0"
+html5ever = "0.40"
hashlink = "0.12.2"
indexmap = "2.14.2"
parking_lot = "0.12"
fastrand = "2.3.0"
-markup5ever = "0.39.0"
+markup5ever = "0.40"
xml5ever = "0.39.0"
serde = { version = "1.0.228", features = ["derive"] }
serde_json = { version = "1.0.145", features = ["raw_value"] }
@@ -118,7 +118,7 @@ tracing = "0.1.41"
url = "2.5.7"
uuid = { version = "1.23.1", default-features = false }
widestring = "1.2.1"
-style_traits = { package = "stylo_traits", version = "0.20" }
+style_traits = { package = "stylo_traits", version = "0.22" }
xmlparser = "0.13.6"
typed-num = { version = "0.3.0", default-features = false, features = ["serde"] }
wasm_dep_analyzer = { git = "https://github.com/ldm0/wasm_dep_analyzer", branch = "moli0" }
diff --git a/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/font_face/descriptors.rs b/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/font_face/descriptors.rs
index f8c41fb13..b16a66ab0 100644
--- a/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/font_face/descriptors.rs
+++ b/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/font_face/descriptors.rs
@@ -23,8 +23,8 @@ impl FontFaceDescriptor {
if self.slot == FONT_FACE_VARIANT_SLOT {
// The legacy FontFace variant attribute uses the CSS 2.1 values;
// Stylo no longer exposes font-variant as an @font-face descriptor.
- let mut input = cssparser::ParserInput::new(value);
- let mut parser = cssparser::Parser::new(&mut input);
+ let input = value;
+ let mut parser = cssparser::Parser::new(input);
let ident = parser.expect_ident().ok()?.to_ascii_lowercase();
parser.expect_exhausted().ok()?;
return matches!(ident.as_str(), "normal" | "small-caps").then_some(ident);
diff --git a/moli-renderer-v8/src/context_bootstrap/css_runtime/supports.rs b/moli-renderer-v8/src/context_bootstrap/css_runtime/supports.rs
index 3d7379293..16914a846 100644
--- a/moli-renderer-v8/src/context_bootstrap/css_runtime/supports.rs
+++ b/moli-renderer-v8/src/context_bootstrap/css_runtime/supports.rs
@@ -5,7 +5,7 @@ mod values;
pub(crate) use condition::css_supports_condition_text;
use crate::webidl;
-use cssparser::{Parser, ParserInput};
+use cssparser::Parser;
use style::{
context::QuirksMode,
parser::ParserContext,
@@ -64,8 +64,8 @@ fn stylo_supports_property_value(property: &str, value: &str) -> bool {
}
fn stylo_supports_condition_text(condition: &str) -> Option<bool> {
- let mut input = ParserInput::new(condition);
- let mut parser = Parser::new(&mut input);
+ let input = condition;
+ let mut parser = Parser::new(input);
let condition = parser
.parse_entirely(|input| parse_condition_or_declaration(input))
.ok()?;
@@ -88,6 +88,12 @@ fn eval_stylo_supports_condition(condition: &SupportsCondition, context: &Parser
shell_supports_declaration(&declaration.0).unwrap_or_else(|| declaration.eval(context))
}
SupportsCondition::Selector(selector) => selector.eval(context),
+ SupportsCondition::AtRule(_) => {
+ let css = condition.to_css_string();
+ condition::css_supports_at_rule_condition(&css)
+ .unwrap_or_else(|| condition.eval(context))
+ }
+ SupportsCondition::NamedFeature(_) => condition.eval(context),
SupportsCondition::FontFormat(_) | SupportsCondition::FontTech(_) => {
let css = condition.to_css_string();
condition::css_supports_font_feature_condition(&css).unwrap_or(false)
@@ -99,8 +105,8 @@ fn eval_stylo_supports_condition(condition: &SupportsCondition, context: &Parser
}
fn shell_supports_declaration(declaration: &str) -> Option<bool> {
- let mut input = ParserInput::new(declaration);
- let mut parser = Parser::new(&mut input);
+ let input = declaration;
+ let mut parser = Parser::new(input);
let property = parser.expect_ident_cloned().ok()?;
let property = crate::css_style::canonical_style_property_name(&property);
if !crate::detached_css_style::css_style_declaration_is_shell_property(&property) {
@@ -112,7 +118,7 @@ fn shell_supports_declaration(declaration: &str) -> Option<bool> {
let supported = parser
.parse_until_before(cssparser::Delimiter::Bang, |input| {
style::properties::CSSWideKeyword::parse(input)
- .map_err(|()| input.new_custom_error::<(), ()>(()))
+ .map_err(|()| cssparser::ParseError::<()>::custom(()))
})
.is_ok();
let _ = parser.try_parse(cssparser::parse_important);
diff --git a/moli-renderer-v8/src/context_bootstrap/css_runtime/supports/condition.rs b/moli-renderer-v8/src/context_bootstrap/css_runtime/supports/condition.rs
index 8e44f3209..89e46a2cd 100644
--- a/moli-renderer-v8/src/context_bootstrap/css_runtime/supports/condition.rs
+++ b/moli-renderer-v8/src/context_bootstrap/css_runtime/supports/condition.rs
@@ -16,8 +16,8 @@ pub(crate) fn css_supports_condition_text(condition: &str) -> bool {
}
pub(super) fn css_supports_font_feature_condition(condition: &str) -> Option<bool> {
- let mut input = cssparser::ParserInput::new(condition);
- let mut parser = cssparser::Parser::new(&mut input);
+ let input = condition;
+ let mut parser = cssparser::Parser::new(input);
let function = parser.expect_function().ok()?.clone();
let function = function.as_ref();
if !matches!(function, "font-format" | "font-tech") {
@@ -26,7 +26,7 @@ pub(super) fn css_supports_font_feature_condition(condition: &str) -> Option<boo
let result = parser.parse_nested_block(|nested| {
let ident = nested.expect_ident()?.clone();
nested.expect_exhausted()?;
- Ok::<_, cssparser::ParseError<'_, ()>>(match function {
+ Ok::<_, cssparser::ParseError<()>>(match function {
"font-format" => supports_font_format_keyword(ident.as_ref()),
"font-tech" => supports_font_tech_keyword(ident.as_ref()),
_ => false,
@@ -62,8 +62,8 @@ fn supports_font_tech_keyword(keyword: &str) -> bool {
}
pub(super) fn css_supports_at_rule_condition(condition: &str) -> Option<bool> {
- let mut input = cssparser::ParserInput::new(condition);
- let mut parser = cssparser::Parser::new(&mut input);
+ let input = condition;
+ let mut parser = cssparser::Parser::new(input);
let function = parser.expect_function().ok()?.clone();
if function.as_ref() != "at-rule" {
return None;
@@ -71,7 +71,7 @@ pub(super) fn css_supports_at_rule_condition(condition: &str) -> Option<bool> {
let result = parser.parse_nested_block(|nested| {
let token = nested.next()?;
let cssparser::Token::AtKeyword(name) = token else {
- return Ok::<_, cssparser::ParseError<'_, ()>>(false);
+ return Ok::<_, cssparser::ParseError<()>>(false);
};
let name = name.to_ascii_lowercase();
if nested.expect_exhausted().is_err() {
diff --git a/moli-renderer-v8/src/context_bootstrap/css_runtime/typed_om/mod.rs b/moli-renderer-v8/src/context_bootstrap/css_runtime/typed_om/mod.rs
index 233a32230..d854809b5 100644
--- a/moli-renderer-v8/src/context_bootstrap/css_runtime/typed_om/mod.rs
+++ b/moli-renderer-v8/src/context_bootstrap/css_runtime/typed_om/mod.rs
@@ -5,7 +5,7 @@ use crate::{
util::{get_private_object, get_private_value, set_private_value, throw_type_error, v8_string},
webidl, window_host,
};
-use cssparser::{Parser, ParserInput, Token};
+use cssparser::{Parser, Token};
use moli_webapi_declare::{WebApiFunctionTemplate, WebApiObject};
mod map;
diff --git a/moli-renderer-v8/src/context_bootstrap/css_runtime/typed_om/values.rs b/moli-renderer-v8/src/context_bootstrap/css_runtime/typed_om/values.rs
index d9835b84b..b91935019 100644
--- a/moli-renderer-v8/src/context_bootstrap/css_runtime/typed_om/values.rs
+++ b/moli-renderer-v8/src/context_bootstrap/css_runtime/typed_om/values.rs
@@ -173,19 +173,19 @@ pub(super) fn style_value_from_text<'s>(
}
fn parse_single_keyword_value(text: &str) -> Option<String> {
- let mut input = ParserInput::new(text);
- let mut parser = Parser::new(&mut input);
+ let input = text;
+ let mut parser = Parser::new(input);
parser
.parse_entirely(|input| match input.next()?.clone() {
Token::Ident(keyword) => Ok(keyword.to_string()),
- _ => Err(input.new_custom_error::<(), ()>(())),
+ _ => Err(cssparser::ParseError::<()>::custom(())),
})
.ok()
}
fn parse_single_unit_value(text: &str) -> Option<(f64, String)> {
- let mut input = ParserInput::new(text);
- let mut parser = Parser::new(&mut input);
+ let input = text;
+ let mut parser = Parser::new(input);
parser
.parse_entirely(|input| {
let token = input.next()?.clone();
@@ -197,11 +197,11 @@ fn parse_single_unit_value(text: &str) -> Option<(f64, String)> {
Token::Dimension { value, unit, .. } => {
let unit = unit.to_ascii_lowercase();
if normalize_unit_name(&unit).is_none() {
- return Err(input.new_custom_error::<(), ()>(()));
+ return Err(cssparser::ParseError::<()>::custom(()));
}
Ok((f64::from(value), unit))
}
- _ => Err(input.new_custom_error::<(), ()>(())),
+ _ => Err(cssparser::ParseError::<()>::custom(())),
}
})
.ok()
diff --git a/moli-renderer-v8/src/css_custom_function.rs b/moli-renderer-v8/src/css_custom_function.rs
index 558d321d0..d9c996861 100644
--- a/moli-renderer-v8/src/css_custom_function.rs
+++ b/moli-renderer-v8/src/css_custom_function.rs
@@ -1,5 +1,5 @@
use cssparser::{
- AtRuleParser, CowRcStr, ParseError, Parser, ParserInput, QualifiedRuleParser, StyleSheetParser,
+ AtRuleParser, CowRcStr, ParseError, Parser, QualifiedRuleParser, StyleSheetParser,
};
#[derive(Clone, Debug)]
@@ -11,8 +11,8 @@ pub(crate) struct CustomCssProjectionAtRule {
}
pub(crate) fn custom_css_projection_at_rules(css_text: &str) -> Vec<CustomCssProjectionAtRule> {
- let mut input = ParserInput::new(css_text);
- let mut input = Parser::new(&mut input);
+ let input = css_text;
+ let mut input = Parser::new(input);
let mut parser = CustomCssProjectionRuleTextParser;
let style_sheet = StyleSheetParser::new(&mut input, &mut parser);
let mut rules = Vec::new();
@@ -29,8 +29,8 @@ pub(crate) fn custom_css_projection_at_rules(css_text: &str) -> Vec<CustomCssPro
pub(crate) fn single_custom_css_function_projection(
css_text: &str,
) -> Option<CustomCssProjectionAtRule> {
- let mut input = ParserInput::new(css_text);
- let mut input = Parser::new(&mut input);
+ let input = css_text;
+ let mut input = Parser::new(input);
let mut parser = CustomCssProjectionRuleTextParser;
let mut style_sheet = StyleSheetParser::new(&mut input, &mut parser);
let parsed = match style_sheet.next()? {
@@ -85,8 +85,8 @@ impl<'i> AtRuleParser<'i> for CustomCssProjectionRuleTextParser {
fn parse_prelude<'t>(
&mut self,
name: CowRcStr<'i>,
- input: &mut Parser<'i, 't>,
- ) -> Result<Self::Prelude, ParseError<'i, Self::Error>> {
+ input: &mut Parser<'i>,
+ ) -> Result<Self::Prelude, ParseError<Self::Error>> {
let start = input.position();
custom_css_projection_consume_rule_tokens(input);
Ok(CustomCssProjectionAtRulePrelude {
@@ -99,8 +99,8 @@ impl<'i> AtRuleParser<'i> for CustomCssProjectionRuleTextParser {
&mut self,
prelude: Self::Prelude,
_start: &cssparser::ParserState,
- input: &mut Parser<'i, 't>,
- ) -> Result<Self::AtRule, ParseError<'i, Self::Error>> {
+ input: &mut Parser<'i>,
+ ) -> Result<Self::AtRule, ParseError<Self::Error>> {
let block_start = input.position();
custom_css_projection_consume_rule_tokens(input);
Ok(CustomCssProjectionRule::AtRule(
@@ -134,8 +134,8 @@ impl<'i> QualifiedRuleParser<'i> for CustomCssProjectionRuleTextParser {
fn parse_prelude<'t>(
&mut self,
- input: &mut Parser<'i, 't>,
- ) -> Result<Self::Prelude, ParseError<'i, Self::Error>> {
+ input: &mut Parser<'i>,
+ ) -> Result<Self::Prelude, ParseError<Self::Error>> {
custom_css_projection_consume_rule_tokens(input);
Ok(())
}
@@ -144,14 +144,14 @@ impl<'i> QualifiedRuleParser<'i> for CustomCssProjectionRuleTextParser {
&mut self,
_prelude: Self::Prelude,
_start: &cssparser::ParserState,
- input: &mut Parser<'i, 't>,
- ) -> Result<Self::QualifiedRule, ParseError<'i, Self::Error>> {
+ input: &mut Parser<'i>,
+ ) -> Result<Self::QualifiedRule, ParseError<Self::Error>> {
custom_css_projection_consume_rule_tokens(input);
Ok(CustomCssProjectionRule::Qualified)
}
}
-fn custom_css_projection_consume_rule_tokens(input: &mut Parser<'_, '_>) {
+fn custom_css_projection_consume_rule_tokens(input: &mut Parser<'_>) {
while input.next_including_whitespace_and_comments().is_ok() {}
}
diff --git a/moli-renderer-v8/src/css_resource_urls.rs b/moli-renderer-v8/src/css_resource_urls.rs
index 1629048b6..4aae85731 100644
--- a/moli-renderer-v8/src/css_resource_urls.rs
+++ b/moli-renderer-v8/src/css_resource_urls.rs
@@ -1,4 +1,4 @@
-use cssparser::{Parser, ParserInput, Token, UnicodeRange};
+use cssparser::{Parser, Token, UnicodeRange};
use moli_crypto::sha256_hex;
use moli_css_parse::{
DeclarationParseOptions, parse_declaration_list, parse_font_face_rule_view_with_stylo,
@@ -288,12 +288,12 @@ fn parsed_web_font_face(css_text: &str) -> Option<ParsedWebFontFace> {
}
fn parse_font_unicode_ranges(value: &str) -> Option<Vec<WebFontUnicodeRange>> {
- let mut input = ParserInput::new(value);
- let mut input = Parser::new(&mut input);
+ let input = value;
+ let mut input = Parser::new(input);
input
.parse_comma_separated(|input| {
let range = UnicodeRange::parse(input)?;
- Ok::<_, cssparser::ParseError<'_, ()>>(WebFontUnicodeRange::new(range.start, range.end))
+ Ok::<_, cssparser::ParseError<()>>(WebFontUnicodeRange::new(range.start, range.end))
})
.ok()
}
@@ -354,8 +354,8 @@ fn parse_css_angle_degrees(value: &str) -> Option<f32> {
}
fn preferred_font_source_url(source: &str, base_url: &Url) -> Option<Url> {
- let mut input = ParserInput::new(source);
- let mut input = Parser::new(&mut input);
+ let input = source;
+ let mut input = Parser::new(input);
let mut candidate_url: Option<String> = None;
let mut candidate_format_is_supported = true;
while let Ok(token) = input.next_including_whitespace_and_comments().cloned() {
@@ -371,19 +371,19 @@ fn preferred_font_source_url(source: &str, base_url: &Url) -> Option<Url> {
Token::Function(name) if name.eq_ignore_ascii_case("url") => {
let _ = input.parse_nested_block(|input| {
candidate_url = css_url_function_value(input);
- Ok::<(), cssparser::ParseError<'_, ()>>(())
+ Ok::<(), cssparser::ParseError<()>>(())
});
}
Token::Function(name) if name.eq_ignore_ascii_case("format") => {
let _ = input.parse_nested_block(|input| {
candidate_format_is_supported = font_format_function_is_supported(input);
- Ok::<(), cssparser::ParseError<'_, ()>>(())
+ Ok::<(), cssparser::ParseError<()>>(())
});
}
Token::Function(_) | Token::ParenthesisBlock | Token::SquareBracketBlock => {
let _ = input.parse_nested_block(|input| {
skip_css_block(input);
- Ok::<(), cssparser::ParseError<'_, ()>>(())
+ Ok::<(), cssparser::ParseError<()>>(())
});
}
_ => {}
@@ -394,7 +394,7 @@ fn preferred_font_source_url(source: &str, base_url: &Url) -> Option<Url> {
.and_then(|url| resolve_font_source_url(&url, base_url))
}
-fn css_url_function_value<'i, 't>(input: &mut Parser<'i, 't>) -> Option<String> {
+fn css_url_function_value<'i>(input: &mut Parser<'i>) -> Option<String> {
while let Ok(token) = input.next_including_whitespace_and_comments().cloned() {
match token {
Token::WhiteSpace(_) | Token::Comment(_) => {}
@@ -407,7 +407,7 @@ fn css_url_function_value<'i, 't>(input: &mut Parser<'i, 't>) -> Option<String>
None
}
-fn font_format_function_is_supported<'i, 't>(input: &mut Parser<'i, 't>) -> bool {
+fn font_format_function_is_supported<'i>(input: &mut Parser<'i>) -> bool {
let mut saw_format = false;
while let Ok(token) = input.next_including_whitespace_and_comments().cloned() {
let value = match token {
@@ -446,7 +446,7 @@ fn resolve_font_source_url(raw_url: &str, base_url: &Url) -> Option<Url> {
matches!(url.scheme(), "http" | "https" | "data" | "blob").then_some(url)
}
-fn skip_css_block<'i, 't>(input: &mut Parser<'i, 't>) {
+fn skip_css_block<'i>(input: &mut Parser<'i>) {
while let Ok(token) = input.next_including_whitespace_and_comments().cloned() {
match token {
Token::Function(_)
@@ -455,7 +455,7 @@ fn skip_css_block<'i, 't>(input: &mut Parser<'i, 't>) {
| Token::CurlyBracketBlock => {
let _ = input.parse_nested_block(|input| {
skip_css_block(input);
- Ok::<(), cssparser::ParseError<'_, ()>>(())
+ Ok::<(), cssparser::ParseError<()>>(())
});
}
_ => {}
diff --git a/moli-renderer-v8/src/css_style.rs b/moli-renderer-v8/src/css_style.rs
index cbf667911..ffcadbf82 100644
--- a/moli-renderer-v8/src/css_style.rs
+++ b/moli-renderer-v8/src/css_style.rs
@@ -1,8 +1,6 @@
use crate::webidl;
-use cssparser::{
- ParseError, Parser, ParserInput, SourcePosition, ToCss, Token, TokenSerializationType,
-};
+use cssparser::{ParseError, Parser, SourcePosition, ToCss, Token, TokenSerializationType};
use moli_css_parse::{
CssDeclaration, CssFontFace, DeclarationParseOptions, parse_declaration_list, parse_font_faces,
};
@@ -21,8 +19,8 @@ pub(crate) fn stylo_property_is_chromium_exposed(name: &str) -> bool {
}
pub(crate) fn parse_css_style_shell_keyword(value: &str) -> Option<&'static str> {
- let mut input = ParserInput::new(value);
- let mut parser = Parser::new(&mut input);
+ let input = value;
+ let mut parser = Parser::new(input);
let keyword = style::properties::CSSWideKeyword::parse(&mut parser).ok()?;
parser.expect_exhausted().ok()?;
Some(keyword.to_str())
@@ -837,8 +835,8 @@ pub(crate) fn normalize_cssom_flex_shorthand_value(value: &str) -> Option<String
/// Splits top-level component values for box-like CSSOM reconstruction. Validity
/// for the shorthand or its longhands must come from Stylo/PDB.
pub(crate) fn box_shorthand_value_components(value: &str) -> Option<Vec<String>> {
- let mut input = ParserInput::new(value);
- let mut input = Parser::new(&mut input);
+ let input = value;
+ let mut input = Parser::new(input);
let mut components = Vec::new();
let mut component_start: Option<SourcePosition> = None;
let mut component_end: Option<SourcePosition> = None;
@@ -861,9 +859,9 @@ pub(crate) fn box_shorthand_value_components(value: &str) -> Option<Vec<String>>
component_start.get_or_insert(token_start);
if css_component_token_starts_nested_block(&token) {
- let nested: Result<(), ParseError<'_, ()>> = input.parse_nested_block(|input| {
+ let nested: Result<(), ParseError<()>> = input.parse_nested_block(|input| {
consume_nested_css_component(input)
- .ok_or_else(|| input.new_custom_error::<(), ()>(()))
+ .ok_or_else(|| cssparser::ParseError::<()>::custom(()))
});
nested.ok()?;
}
@@ -877,8 +875,8 @@ pub(crate) fn box_shorthand_value_components(value: &str) -> Option<Vec<String>>
/// Splits only top-level comma layers while preserving nested component text.
/// The caller is responsible for using this only after grammar validation.
pub(crate) fn top_level_comma_separated_component_values(value: &str) -> Option<Vec<String>> {
- let mut input = ParserInput::new(value);
- let mut input = Parser::new(&mut input);
+ let input = value;
+ let mut input = Parser::new(input);
let mut layers = Vec::new();
let mut layer_start: Option<SourcePosition> = None;
let mut layer_end: Option<SourcePosition> = None;
@@ -900,9 +898,9 @@ pub(crate) fn top_level_comma_separated_component_values(value: &str) -> Option<
layer_start.get_or_insert(token_start);
if css_component_token_starts_nested_block(&token) {
- let nested: Result<(), ParseError<'_, ()>> = input.parse_nested_block(|input| {
+ let nested: Result<(), ParseError<()>> = input.parse_nested_block(|input| {
consume_nested_css_component(input)
- .ok_or_else(|| input.new_custom_error::<(), ()>(()))
+ .ok_or_else(|| cssparser::ParseError::<()>::custom(()))
});
nested.ok()?;
}
@@ -916,8 +914,8 @@ pub(crate) fn top_level_comma_separated_component_values(value: &str) -> Option<
pub(crate) fn normalize_cssom_component_value_serialization_with_spaced_slash(
value: &str,
) -> Option<String> {
- let mut input = ParserInput::new(value);
- let mut input = Parser::new(&mut input);
+ let input = value;
+ let mut input = Parser::new(input);
let mut parts = Vec::new();
let mut part_start: Option<SourcePosition> = None;
let mut part_end: Option<SourcePosition> = None;
@@ -940,9 +938,9 @@ pub(crate) fn normalize_cssom_component_value_serialization_with_spaced_slash(
part_start.get_or_insert(token_start);
if css_component_token_starts_nested_block(&token) {
- let nested: Result<(), ParseError<'_, ()>> = input.parse_nested_block(|input| {
+ let nested: Result<(), ParseError<()>> = input.parse_nested_block(|input| {
consume_nested_css_component(input)
- .ok_or_else(|| input.new_custom_error::<(), ()>(()))
+ .ok_or_else(|| cssparser::ParseError::<()>::custom(()))
});
nested.ok()?;
}
@@ -957,7 +955,7 @@ pub(crate) fn normalize_cssom_component_value_serialization_with_spaced_slash(
}
fn push_top_level_slash_component(
- input: &Parser<'_, '_>,
+ input: &Parser<'_>,
parts: &mut Vec<String>,
part_start: &mut Option<SourcePosition>,
part_end: Option<SourcePosition>,
@@ -972,7 +970,7 @@ fn push_top_level_slash_component(
}
fn push_top_level_comma_component(
- input: &Parser<'_, '_>,
+ input: &Parser<'_>,
layers: &mut Vec<String>,
layer_start: &mut Option<SourcePosition>,
layer_end: Option<SourcePosition>,
@@ -984,7 +982,7 @@ fn push_top_level_comma_component(
}
fn push_box_shorthand_component(
- input: &Parser<'_, '_>,
+ input: &Parser<'_>,
components: &mut Vec<String>,
component_start: &mut Option<SourcePosition>,
component_end: Option<SourcePosition>,
@@ -1007,12 +1005,12 @@ fn css_component_token_starts_nested_block(token: &Token<'_>) -> bool {
)
}
-fn consume_nested_css_component(input: &mut Parser<'_, '_>) -> Option<()> {
+fn consume_nested_css_component(input: &mut Parser<'_>) -> Option<()> {
while let Ok(token) = input.next_including_whitespace_and_comments().cloned() {
if css_component_token_starts_nested_block(&token) {
- let nested: Result<(), ParseError<'_, ()>> = input.parse_nested_block(|input| {
+ let nested: Result<(), ParseError<()>> = input.parse_nested_block(|input| {
consume_nested_css_component(input)
- .ok_or_else(|| input.new_custom_error::<(), ()>(()))
+ .ok_or_else(|| cssparser::ParseError::<()>::custom(()))
});
nested.ok()?;
}
@@ -1021,8 +1019,8 @@ fn consume_nested_css_component(input: &mut Parser<'_, '_>) -> Option<()> {
}
pub(crate) fn background_shorthand_color(value: &str) -> Option<String> {
- let mut input = ParserInput::new(value);
- let mut input = Parser::new(&mut input);
+ let input = value;
+ let mut input = Parser::new(input);
while let Ok(token) = input.next_including_whitespace_and_comments().cloned() {
match token {
Token::WhiteSpace(_) | Token::Comment(_) => {}
@@ -1042,8 +1040,8 @@ pub(crate) fn background_shorthand_color(value: &str) -> Option<String> {
}
pub(crate) fn border_shorthand_width(value: &str) -> Option<String> {
- let mut input = ParserInput::new(value);
- let mut input = Parser::new(&mut input);
+ let input = value;
+ let mut input = Parser::new(input);
while let Ok(token) = input.next_including_whitespace_and_comments().cloned() {
match token {
Token::WhiteSpace(_) | Token::Comment(_) => {}
@@ -1078,8 +1076,8 @@ pub(crate) fn border_shorthand_width(value: &str) -> Option<String> {
}
pub(crate) fn border_shorthand_color(value: &str) -> Option<String> {
- let mut input = ParserInput::new(value);
- let mut input = Parser::new(&mut input);
+ let input = value;
+ let mut input = Parser::new(input);
while let Ok(token) = input.next_including_whitespace_and_comments().cloned() {
match token {
Token::WhiteSpace(_) | Token::Comment(_) => {}
@@ -1101,8 +1099,8 @@ pub(crate) fn border_shorthand_color(value: &str) -> Option<String> {
}
pub(crate) fn border_shorthand_style(value: &str) -> Option<String> {
- let mut input = ParserInput::new(value);
- let mut input = Parser::new(&mut input);
+ let input = value;
+ let mut input = Parser::new(input);
while let Ok(token) = input.next_including_whitespace_and_comments().cloned() {
match token {
Token::WhiteSpace(_) | Token::Comment(_) => {}
@@ -1150,7 +1148,7 @@ pub(crate) fn system_color_rgb(value: &str) -> Option<(u8, u8, u8)> {
moli_css_parse::css_system_color_srgb(value)
}
-fn shorthand_component_function_text(input: &mut Parser<'_, '_>, name: &str) -> Option<String> {
+fn shorthand_component_function_text(input: &mut Parser<'_>, name: &str) -> Option<String> {
let mut css_text = String::new();
css_text.push_str(name);
css_text.push('(');
@@ -1162,15 +1160,15 @@ fn shorthand_component_function_text(input: &mut Parser<'_, '_>, name: &str) ->
TokenSerializationType::Nothing,
)
.map(|_| ())
- .ok_or_else(|| nested.new_custom_error::<(), ()>(()))
+ .ok_or_else(|| cssparser::ParseError::<()>::custom(()))
})
.ok()?;
css_text.push(')');
Some(css_text)
}
-fn serialize_shorthand_component_values<'i, 't>(
- input: &mut Parser<'i, 't>,
+fn serialize_shorthand_component_values<'i>(
+ input: &mut Parser<'i>,
css_text: &mut String,
mut previous_token: TokenSerializationType,
) -> Option<TokenSerializationType> {
@@ -1199,10 +1197,10 @@ fn serialize_shorthand_component_values<'i, 't>(
_ => None,
};
if let Some(closing_token) = closing_token {
- let nested: Result<TokenSerializationType, ParseError<'_, ()>> = input
- .parse_nested_block(|input| {
+ let nested: Result<TokenSerializationType, ParseError<()>> =
+ input.parse_nested_block(|input| {
serialize_shorthand_component_values(input, css_text, previous_token)
- .ok_or_else(|| input.new_custom_error::<(), ()>(()))
+ .ok_or_else(|| cssparser::ParseError::<()>::custom(()))
});
nested.ok()?;
closing_token.to_css(css_text).ok()?;
diff --git a/moli-renderer-v8/src/live_stylesheet/mod.rs b/moli-renderer-v8/src/live_stylesheet/mod.rs
index 92b691e8f..faf92edac 100644
--- a/moli-renderer-v8/src/live_stylesheet/mod.rs
+++ b/moli-renderer-v8/src/live_stylesheet/mod.rs
@@ -6,7 +6,7 @@ use std::{
sync::{Arc as StdArc, Weak as StdWeak, atomic::AtomicBool},
};
-use cssparser::{Parser, ParserInput, SourceLocation, Token};
+use cssparser::{Parser, SourceLocation, Token};
use parking_lot::Mutex;
use selectors::SelectorList;
use style::stylesheets::keyframes_rule::{Keyframe, KeyframeSelectors, KeyframesRule};
@@ -699,8 +699,8 @@ fn css_rule_insert_error(error: RulesMutateError) -> CssRuleInsertError {
}
fn css_text_starts_with_at_keyword(css_text: &str, expected: &str) -> bool {
- let mut input = ParserInput::new(css_text);
- let mut parser = Parser::new(&mut input);
+ let input = css_text;
+ let mut parser = Parser::new(input);
loop {
match parser.next_including_whitespace_and_comments() {
Ok(Token::WhiteSpace(_) | Token::Comment(_)) => {}
@@ -797,8 +797,8 @@ fn decode_data_stylesheet(url: &url::Url) -> Option<String> {
}
fn parse_keyframe_selectors(selector_text: &str) -> Result<KeyframeSelectors, CssRuleInsertError> {
- let mut input = ParserInput::new(selector_text);
- let mut input = Parser::new(&mut input);
+ let input = selector_text;
+ let mut input = Parser::new(input);
input
.parse_entirely(KeyframeSelectors::parse)
.map_err(|_| CssRuleInsertError::Syntax)
diff --git a/moli-renderer-v8/src/live_stylesheet/mutation.rs b/moli-renderer-v8/src/live_stylesheet/mutation.rs
index 8e8d73a9c..7b300f48d 100644
--- a/moli-renderer-v8/src/live_stylesheet/mutation.rs
+++ b/moli-renderer-v8/src/live_stylesheet/mutation.rs
@@ -757,8 +757,8 @@ impl LiveStylesheet {
return Err(CssRuleInsertError::HierarchyRequest);
}
let selectors = self.with_parser_context(CssRuleType::Page, None, |context| {
- let mut input = ParserInput::new(selector_text);
- let mut input = Parser::new(&mut input);
+ let input = selector_text;
+ let mut input = Parser::new(input);
input.parse_entirely(|input| PageSelectors::parse(context, input))
});
let selectors = selectors.map_err(|_| CssRuleInsertError::Syntax)?;
@@ -949,8 +949,8 @@ impl LiveStylesheet {
rule_type: CssRuleType,
) -> PropertyDeclarationBlock {
self.with_parser_context(rule_type, None, |context| {
- let mut input = ParserInput::new(declaration_text);
- let mut input = Parser::new(&mut input);
+ let input = declaration_text;
+ let mut input = Parser::new(input);
parse_property_declaration_list(context, &mut input, &[])
})
}
@@ -972,8 +972,8 @@ impl LiveStylesheet {
url_data: context.url_data,
for_supports_rule: false,
};
- let mut input = ParserInput::new(selector_text);
- let mut input = Parser::new(&mut input);
+ let input = selector_text;
+ let mut input = Parser::new(input);
input
.parse_entirely(|input| {
SelectorList::parse(
diff --git a/moli-renderer-v8/src/native_bridge/element/styles/declaration/parse/declaration_parser.rs b/moli-renderer-v8/src/native_bridge/element/styles/declaration/parse/declaration_parser.rs
index c87f7980b..e5aa74745 100644
--- a/moli-renderer-v8/src/native_bridge/element/styles/declaration/parse/declaration_parser.rs
+++ b/moli-renderer-v8/src/native_bridge/element/styles/declaration/parse/declaration_parser.rs
@@ -292,7 +292,7 @@ pub(super) fn parse_strict_style_property_entries(
let mut value = CssString::new();
declaration.to_css(&mut value).ok()?;
entries.push(StyleEntry {
- name: id.name().to_owned(),
+ name: canonical_style_property_name(id.name()),
value,
priority,
});
@@ -608,8 +608,8 @@ pub(super) fn parse_normalized_style_property_entries(
}
pub(super) fn value_mixes_css_wide_keyword(value: &str) -> bool {
- let mut input = cssparser::ParserInput::new(value);
- let mut input = cssparser::Parser::new(&mut input);
+ let input = value;
+ let mut input = cssparser::Parser::new(input);
let mut component_count = 0usize;
let mut has_css_wide_keyword = false;
while let Ok(token) = input.next_including_whitespace_and_comments().cloned() {
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.rs
index 5ef8b6817..68b6c292d 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
@@ -22,7 +22,7 @@ use crate::{
},
},
};
-use cssparser::{Parser, ParserInput, Token, serialize_identifier, serialize_string};
+use cssparser::{Parser, Token, serialize_identifier, serialize_string};
use moli_selector::html_directionality;
use std::collections::{HashMap, HashSet};
use style::{properties::ComputedValues, servo_arc::Arc as ServoArc, stylesheets::CssRuleType};
diff --git a/moli-renderer-v8/src/native_bridge/element/styles/declaration/values/computed_properties.rs b/moli-renderer-v8/src/native_bridge/element/styles/declaration/values/computed_properties.rs
index e5f4835b0..1cd982761 100644
--- a/moli-renderer-v8/src/native_bridge/element/styles/declaration/values/computed_properties.rs
+++ b/moli-renderer-v8/src/native_bridge/element/styles/declaration/values/computed_properties.rs
@@ -1381,13 +1381,13 @@ fn transition_property_token_is_valid(value: &str) -> bool {
}
fn transition_property_token_serialization(value: &str) -> Option<String> {
- let mut input = ParserInput::new(value);
- let mut input = Parser::new(&mut input);
+ let input = value;
+ let mut input = Parser::new(input);
let ident = input
.parse_entirely(|input| {
input
.expect_ident_cloned()
- .map_err(|_| input.new_custom_error::<(), ()>(()))
+ .map_err(|_| cssparser::ParseError::<()>::custom(()))
})
.ok()?;
let lowered = ident.to_ascii_lowercase();
diff --git a/moli-renderer-v8/src/native_bridge/element/styles/declaration/values/specified_values.rs b/moli-renderer-v8/src/native_bridge/element/styles/declaration/values/specified_values.rs
index e58c24095..c776303cc 100644
--- a/moli-renderer-v8/src/native_bridge/element/styles/declaration/values/specified_values.rs
+++ b/moli-renderer-v8/src/native_bridge/element/styles/declaration/values/specified_values.rs
@@ -179,8 +179,8 @@ fn active_css_animation_names_with_resolution(
}
pub(super) fn animation_shorthand_names(value: &str) -> Vec<String> {
- let mut input = ParserInput::new(value);
- let mut input = Parser::new(&mut input);
+ let input = value;
+ let mut input = Parser::new(input);
let mut names = Vec::new();
let mut current = None;
while let Ok(token) = input.next_including_whitespace_and_comments().cloned() {
@@ -195,7 +195,7 @@ pub(super) fn animation_shorthand_names(value: &str) -> Vec<String> {
current = Some(value.to_string());
}
Token::Function(_) => {
- let _ = input.parse_nested_block(|_| Ok::<_, cssparser::ParseError<'_, ()>>(()));
+ let _ = input.parse_nested_block(|_| Ok::<_, cssparser::ParseError<()>>(()));
}
_ => {}
}
@@ -691,8 +691,8 @@ fn normalize_content_specified_value(value: &str) -> Option<String> {
pub(super) fn normalize_cssom_font_family_value(value: &str) -> Option<String> {
let trimmed = value.trim();
- let mut input = ParserInput::new(trimmed);
- let mut input = Parser::new(&mut input);
+ let input = trimmed;
+ let mut input = Parser::new(input);
let token = input
.next_including_whitespace_and_comments()
.cloned()
@@ -827,8 +827,8 @@ fn split_top_level_once(input: &str, needle: char) -> Option<(&str, &str)> {
}
fn cssom_value_is_attr_function(value: &str) -> bool {
- let mut input = ParserInput::new(value);
- let mut input = Parser::new(&mut input);
+ let input = value;
+ let mut input = Parser::new(input);
matches!(
input.next_including_whitespace_and_comments(),
Ok(Token::Function(name)) if name.eq_ignore_ascii_case("attr")
@@ -836,8 +836,8 @@ fn cssom_value_is_attr_function(value: &str) -> bool {
}
fn normalize_cssom_counter_function(value: &str) -> Option<String> {
- let mut input = ParserInput::new(value);
- let mut input = Parser::new(&mut input);
+ let input = value;
+ let mut input = Parser::new(input);
let Ok(Token::Function(name)) = input.next_including_whitespace_and_comments() else {
return None;
};
@@ -855,7 +855,7 @@ fn normalize_cssom_counter_function(value: &str) -> Option<String> {
input.expect_exhausted()?;
Some(style)
};
- Ok::<_, cssparser::ParseError<'_, ()>>((counter_name, style))
+ Ok::<_, cssparser::ParseError<()>>((counter_name, style))
})
.ok()?;
input.expect_exhausted().ok()?;
@@ -881,8 +881,8 @@ pub(super) struct SimpleVarFunction {
}
pub(super) fn simple_var_function_parts(value: &str) -> Option<SimpleVarFunction> {
- let mut input = ParserInput::new(value);
- let mut parser = Parser::new(&mut input);
+ let input = value;
+ let mut parser = Parser::new(input);
parser.expect_function_matching("var").ok()?;
let parts = parser
.parse_nested_block(|input| {
@@ -894,17 +894,17 @@ pub(super) fn simple_var_function_parts(value: &str) -> Option<SimpleVarFunction
input.expect_comma()?;
Some(
simple_var_fallback_component_text(input)
- .ok_or_else(|| input.new_custom_error(()))?,
+ .ok_or_else(|| cssparser::ParseError::custom(()))?,
)
};
- Ok::<_, cssparser::ParseError<'_, ()>>(SimpleVarFunction { name, fallback })
+ Ok::<_, cssparser::ParseError<()>>(SimpleVarFunction { name, fallback })
})
.ok()?;
parser.expect_exhausted().ok()?;
parts.name.starts_with("--").then_some(parts)
}
-fn simple_var_fallback_component_text(input: &mut Parser<'_, '_>) -> Option<String> {
+fn simple_var_fallback_component_text(input: &mut Parser<'_>) -> Option<String> {
let start = input.position();
while input.next_including_whitespace_and_comments().is_ok() {}
let value = input.slice_from(start).trim();
diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/layout_geometry.rs b/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/layout_geometry.rs
index c3806fa27..0f3f26b9f 100644
--- a/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/layout_geometry.rs
+++ b/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/layout_geometry.rs
@@ -1133,3 +1133,47 @@ document.body.innerHTML = `
.await
.expect("intrinsic width fixture should run");
}
+
+#[tokio::test(flavor = "current_thread")]
+async fn nested_inline_intrinsic_keywords_survive_float_contribution_probes() {
+ run_page_vm_async_test(async move {
+ let loader = crate::network::ResourceRequestClient::new(&FetchConfig::default())?;
+ let mut page = test_page_vm_with_loader_and_document_url(
+ &loader,
+ Vec::new(),
+ Url::parse("https://example.com/intrinsic-nested-keywords.html")?,
+ );
+ let fixture = include_str!("../../../../../tests/fixtures/intrinsic-nested-keywords.html");
+ page.vm_mut().eval(&format!(
+ "document.open();document.write({});document.close()",
+ serde_json::to_string(fixture)?
+ ))?;
+ page.vm_mut()
+ .screenshot_layout_snapshot(moli_layout::PaintViewport::new(800, 600, 1.0))?
+ .expect("nested intrinsic fixture should retain a root");
+ // Chromium and the frozen 0.13 browser agree on these dimensions.
+ // A max-content child must remain 240px wide even when its float's
+ // intrinsic contribution is measured with MinContent available space.
+ for (keyword, width, height) in [
+ ("min-content", 160, 40),
+ ("max-content", 240, 20),
+ ("fit-content", 160, 40),
+ ] {
+ for prefix in ["float", "inline"] {
+ let id = format!("{prefix}-{keyword}");
+ let actual = page.vm_mut().eval(&format!(
+ "(()=>{{const r=document.getElementById({}).getBoundingClientRect();return JSON.stringify([r.width,r.height])}})()",
+ serde_json::to_string(&id)?
+ ))?;
+ assert_eq!(
+ serde_json::from_str::<serde_json::Value>(&actual)?,
+ serde_json::json!([width, height]),
+ "{id}"
+ );
+ }
+ }
+ Ok::<_, anyhow::Error>(())
+ })
+ .await
+ .expect("nested intrinsic keyword fixture should run");
+}
diff --git a/moli-renderer-v8/src/runtime/script_preloads.rs b/moli-renderer-v8/src/runtime/script_preloads.rs
index c8ccec45e..8f0a55856 100644
--- a/moli-renderer-v8/src/runtime/script_preloads.rs
+++ b/moli-renderer-v8/src/runtime/script_preloads.rs
@@ -779,14 +779,14 @@ fn buffered_script_kind_from_type(script_type: Option<&str>) -> crate::types::Sc
fn html_attr_value(attrs: &[Attribute], name: &str) -> Option<String> {
attrs
.iter()
- .find(|attr| attr.name.local.as_ref().eq_ignore_ascii_case(name))
+ .find(|attr| AsRef::<str>::as_ref(&attr.name.local).eq_ignore_ascii_case(name))
.map(|attr| attr.value.to_string())
}
fn html_attr_present(attrs: &[Attribute], name: &str) -> bool {
attrs
.iter()
- .any(|attr| attr.name.local.as_ref().eq_ignore_ascii_case(name))
+ .any(|attr| AsRef::<str>::as_ref(&attr.name.local).eq_ignore_ascii_case(name))
}
#[derive(Default)]
@@ -1375,9 +1375,12 @@ impl HtmlPreloadScannerSink {
let nonce = script_element_nonce_is_nonceable(
nonce.as_deref(),
tag.had_duplicate_attributes,
- tag.attrs
- .iter()
- .map(|attribute| (attribute.name.local.as_ref(), attribute.value.as_ref())),
+ tag.attrs.iter().map(|attribute| {
+ (
+ AsRef::<str>::as_ref(&attribute.name.local),
+ attribute.value.as_ref(),
+ )
+ }),
)
.then_some(nonce.as_deref())
.flatten();
@@ -1557,7 +1560,7 @@ impl HtmlPreloadScannerSink {
}
fn maybe_note_image_fetch(&self, tag: &Tag) {
- if tag.name.as_ref() == "img"
+ if AsRef::<str>::as_ref(&tag.name) == "img"
&& (html_attr_value(&tag.attrs, "src")
.as_deref()
.is_some_and(|src| !src.trim().is_empty())
@@ -1609,7 +1612,7 @@ impl HtmlPreloadScannerSink {
}
fn maybe_note_meta_csp(&self, tag: &Tag) {
- if tag.name.as_ref() == "meta"
+ if AsRef::<str>::as_ref(&tag.name) == "meta"
&& html_attr_value(&tag.attrs, "http-equiv")
.as_deref()
.is_some_and(|value| value.eq_ignore_ascii_case("content-security-policy"))
@@ -1647,7 +1650,7 @@ impl TokenSink for HtmlPreloadScannerSink {
let Token::TagToken(tag) = token else {
return TokenSinkResult::Continue;
};
- if tag.name.as_ref() == "template" {
+ if AsRef::<str>::as_ref(&tag.name) == "template" {
match tag.kind {
TagKind::StartTag => {
self.template_depth
@@ -1667,7 +1670,7 @@ impl TokenSink for HtmlPreloadScannerSink {
TokenSinkResult::Continue
};
}
- if tag.name.as_ref() == "picture" {
+ if AsRef::<str>::as_ref(&tag.name) == "picture" {
match tag.kind {
TagKind::StartTag => {
self.picture_depth
@@ -1685,7 +1688,7 @@ impl TokenSink for HtmlPreloadScannerSink {
}
self.maybe_note_meta_csp(&tag);
- match tag.name.as_ref() {
+ match AsRef::<str>::as_ref(&tag.name) {
"base" => {
self.maybe_update_base_url(&tag);
TokenSinkResult::Continue
@@ -1710,7 +1713,7 @@ impl TokenSink for HtmlPreloadScannerSink {
}
fn tokenizer_state_for_preload_scanner_tag(tag: &Tag) -> TokenSinkResult<()> {
- match tag.name.as_ref() {
+ match AsRef::<str>::as_ref(&tag.name) {
"script" => TokenSinkResult::RawData(ScriptData),
"noscript" | "style" | "xmp" | "iframe" | "noembed" | "noframes" => {
TokenSinkResult::RawData(Rawtext)
diff --git a/moli-renderer-v8/src/style_engine/media_list.rs b/moli-renderer-v8/src/style_engine/media_list.rs
index bfed903e0..bfc12a1c7 100644
--- a/moli-renderer-v8/src/style_engine/media_list.rs
+++ b/moli-renderer-v8/src/style_engine/media_list.rs
@@ -1,4 +1,4 @@
-use cssparser::{Parser, ParserInput};
+use cssparser::Parser;
use euclid::{Scale, Size2D};
use std::fmt::Debug;
use style::{
@@ -90,8 +90,8 @@ pub(crate) fn delete_media_query_list_medium(media_text: &str, medium: &str) ->
}
fn parse_stylo_media_list(context: &mut ParserContext, media_text: &str) -> MediaList {
- let mut input = ParserInput::new(media_text);
- let mut parser = Parser::new(&mut input);
+ let input = media_text;
+ let mut parser = Parser::new(input);
MediaList::parse(context, &mut parser)
}
@@ -156,7 +156,7 @@ impl FontMetricsProvider for MediaQueryFontMetricsProvider {
) -> FontMetrics {
let mut metrics = FontMetrics::default();
if font.clone_font_family().families.iter().next().is_some_and(
- |family| matches!(family, SingleFontFamily::FamilyName(name) if name.name.as_ref().eq_ignore_ascii_case("Ahem")),
+ |family| matches!(family, SingleFontFamily::FamilyName(name) if AsRef::<str>::as_ref(&name.name).eq_ignore_ascii_case("Ahem")),
) {
metrics.zero_advance_measure = Some(base_size);
}
diff --git a/moli-renderer-v8/src/style_engine/mod.rs b/moli-renderer-v8/src/style_engine/mod.rs
index 03791fce9..112648105 100644
--- a/moli-renderer-v8/src/style_engine/mod.rs
+++ b/moli-renderer-v8/src/style_engine/mod.rs
@@ -1143,7 +1143,6 @@ pub(crate) fn ensure_stylo_browser_compat_prefs() {
stylo_static_prefs::set_pref!("layout.container-queries.enabled", true);
stylo_static_prefs::set_pref!("layout.columns.enabled", true);
stylo_static_prefs::set_pref!("layout.css.at-scope.enabled", true);
- stylo_static_prefs::set_pref!("layout.css.attr.enabled", true);
stylo_static_prefs::set_pref!("layout.css.content.alt-text.enabled", true);
stylo_static_prefs::set_pref!("layout.css.font-palette.enabled", true);
stylo_static_prefs::set_pref!("layout.css.margin-rules.enabled", true);
diff --git a/moli-renderer-v8/src/style_engine/stylesheet.rs b/moli-renderer-v8/src/style_engine/stylesheet.rs
index 9254096a8..f7c6f7445 100644
--- a/moli-renderer-v8/src/style_engine/stylesheet.rs
+++ b/moli-renderer-v8/src/style_engine/stylesheet.rs
@@ -561,7 +561,9 @@ fn font_family_list_starts_with_ahem(font: &Font) -> bool {
.iter()
.next()
.is_some_and(|family| match family {
- SingleFontFamily::FamilyName(name) => name.name.as_ref().eq_ignore_ascii_case("Ahem"),
+ SingleFontFamily::FamilyName(name) => {
+ AsRef::<str>::as_ref(&name.name).eq_ignore_ascii_case("Ahem")
+ }
SingleFontFamily::Generic(_) => false,
})
}
diff --git a/moli-renderer-v8/tests/fixtures/intrinsic-nested-keywords.html b/moli-renderer-v8/tests/fixtures/intrinsic-nested-keywords.html
new file mode 100644
index 000000000..b71157b4a
--- /dev/null
+++ b/moli-renderer-v8/tests/fixtures/intrinsic-nested-keywords.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<style>
+body { margin: 0 }
+.host { width: 100px; height: 100px; font-size: 0; line-height: 0 }
+.float { float: left }
+.probe { display: inline-block }
+i, b { display: inline-block; width: 160px; height: 20px }
+b { width: 80px }
+</style>
+<div class="host"><div id="float-min-content" class="float"><span id="inline-min-content" class="probe" style="width:min-content"><i></i><wbr><b></b></span></div></div>
+<div class="host"><div id="float-max-content" class="float"><span id="inline-max-content" class="probe" style="width:max-content"><i></i><wbr><b></b></span></div></div>
+<div class="host"><div id="float-fit-content" class="float"><span id="inline-fit-content" class="probe" style="width:fit-content"><i></i><wbr><b></b></span></div></div>
diff --git a/moli-selector/Cargo.toml b/moli-selector/Cargo.toml
index b2d243159..c4e6230a9 100644
--- a/moli-selector/Cargo.toml
+++ b/moli-selector/Cargo.toml
@@ -6,8 +6,8 @@ edition = "2024"
[dependencies]
app_units = "0.7.8"
-cssparser = "0.37"
-dom = { package = "stylo_dom", version = "0.20" }
+cssparser = "0.38"
+dom = { package = "stylo_dom", version = "0.22" }
euclid = "0.22"
moli-css-parse = { path = "../moli-css-parse" }
moli-dom = { path = "../moli-dom" }
@@ -15,9 +15,9 @@ indexmap = "2.14.2"
parking_lot = "0.12"
percent-encoding = "2.3"
precomputed-hash = "0.1"
-selectors = "0.40"
-stylo = "0.20"
-style_traits = { package = "stylo_traits", version = "0.20" }
+selectors = "0.41"
+stylo = "0.22"
+style_traits = { package = "stylo_traits", version = "0.22" }
url = "2.5.7"
[lints]
diff --git a/moli-selector/src/cssom_selector.rs b/moli-selector/src/cssom_selector.rs
index e7b8d108a..fe7e7bc97 100644
--- a/moli-selector/src/cssom_selector.rs
+++ b/moli-selector/src/cssom_selector.rs
@@ -1,11 +1,8 @@
-use cssparser::{
- BasicParseErrorKind, ParseError, Parser, ParserInput, Token, parse_nth, serialize_identifier,
- serialize_string,
-};
+use cssparser::{ParseError, Parser, Token, parse_nth, serialize_identifier, serialize_string};
use moli_css_parse::serialize_component_values_single_line;
-fn css_parse_error<'i>(error: cssparser::BasicParseError<'i>) -> ParseError<'i, ()> {
+fn css_parse_error(error: cssparser::BasicParseError) -> ParseError<()> {
error.into()
}
@@ -71,22 +68,22 @@ struct CssAttributeSelector {
}
pub(crate) fn selector_list_has_namespace_separator(selector_text: &str) -> bool {
- let mut input = ParserInput::new(selector_text);
- let mut input = Parser::new(&mut input);
+ let input = selector_text;
+ let mut input = Parser::new(input);
selector_tokens_have_namespace_separator(&mut input)
}
pub(crate) fn selector_list_namespace_prefixes(selector_text: &str) -> Vec<String> {
- let mut input = ParserInput::new(selector_text);
- let mut input = Parser::new(&mut input);
+ let input = selector_text;
+ let mut input = Parser::new(input);
let mut prefixes = Vec::new();
collect_selector_namespace_prefixes(&mut input, &mut prefixes);
prefixes
}
fn parse_css_attribute_selector(selector_text: &str) -> Option<CssAttributeSelector> {
- let mut input = ParserInput::new(selector_text);
- let mut parser = Parser::new(&mut input);
+ let input = selector_text;
+ let mut parser = Parser::new(input);
parser
.parse_entirely(|parser| {
parser
@@ -97,9 +94,9 @@ fn parse_css_attribute_selector(selector_text: &str) -> Option<CssAttributeSelec
.ok()
}
-fn parse_css_attribute_selector_block<'i, 't>(
- input: &mut Parser<'i, 't>,
-) -> Result<CssAttributeSelector, ParseError<'i, ()>> {
+fn parse_css_attribute_selector_block<'i>(
+ input: &mut Parser<'i>,
+) -> Result<CssAttributeSelector, ParseError<()>> {
let name = input.expect_ident_cloned().map_err(css_parse_error)?;
if input.is_exhausted() {
return Ok(CssAttributeSelector {
@@ -116,7 +113,7 @@ fn parse_css_attribute_selector_block<'i, 't>(
Token::PrefixMatch => CssAttributeSelectorOperator::Prefix,
Token::SuffixMatch => CssAttributeSelectorOperator::Suffix,
Token::SubstringMatch => CssAttributeSelectorOperator::Substring,
- _ => return Err(input.new_custom_error(())),
+ _ => return Err(cssparser::ParseError::custom(())),
};
let expected = input
.expect_ident_or_string()
@@ -124,7 +121,7 @@ fn parse_css_attribute_selector_block<'i, 't>(
.as_ref()
.to_owned();
if !input.is_exhausted() {
- return Err(input.new_custom_error(()));
+ return Err(cssparser::ParseError::custom(()));
}
Ok(CssAttributeSelector {
@@ -410,8 +407,8 @@ fn matching_close_parenthesis(selector_text: &str, open_index: usize) -> Option<
}
fn parse_nth_argument(argument: &str) -> Option<(i32, i32)> {
- let mut input = ParserInput::new(argument);
- let mut parser = Parser::new(&mut input);
+ let input = argument;
+ let mut parser = Parser::new(input);
let parsed = parse_nth(&mut parser).ok()?;
parser.is_exhausted().then_some(parsed)
}
@@ -437,7 +434,7 @@ fn is_identifier_continue(ch: char) -> bool {
is_identifier_start(ch) || ch.is_ascii_digit()
}
-fn selector_tokens_have_namespace_separator(input: &mut Parser<'_, '_>) -> bool {
+fn selector_tokens_have_namespace_separator(input: &mut Parser<'_>) -> bool {
let mut found = false;
while let Ok(token) = input.next_including_whitespace_and_comments().cloned() {
match token {
@@ -448,7 +445,7 @@ fn selector_tokens_have_namespace_separator(input: &mut Parser<'_, '_>) -> bool
| Token::CurlyBracketBlock => {
let _ = input.parse_nested_block(|input| {
found |= selector_tokens_have_namespace_separator(input);
- Ok::<_, cssparser::ParseError<'_, ()>>(())
+ Ok::<_, cssparser::ParseError<()>>(())
});
}
_ => {}
@@ -457,7 +454,7 @@ fn selector_tokens_have_namespace_separator(input: &mut Parser<'_, '_>) -> bool
found
}
-fn collect_selector_namespace_prefixes(input: &mut Parser<'_, '_>, prefixes: &mut Vec<String>) {
+fn collect_selector_namespace_prefixes(input: &mut Parser<'_>, prefixes: &mut Vec<String>) {
let mut previous_prefix_candidate: Option<String> = None;
while let Ok(token) = input.next_including_whitespace_and_comments().cloned() {
match token {
@@ -478,7 +475,7 @@ fn collect_selector_namespace_prefixes(input: &mut Parser<'_, '_>, prefixes: &mu
previous_prefix_candidate = None;
let _ = input.parse_nested_block(|input| {
collect_selector_namespace_prefixes(input, prefixes);
- Ok::<_, cssparser::ParseError<'_, ()>>(())
+ Ok::<_, cssparser::ParseError<()>>(())
});
}
Token::SquareBracketBlock => {
@@ -536,12 +533,12 @@ fn trailing_unclosed_attribute_selector_index(selector_text: &str) -> Option<usi
}
pub(crate) fn dom_api_selector_list_uses_defined_pseudo_class(selector_text: &str) -> bool {
- let mut input = ParserInput::new(selector_text);
- let mut parser = Parser::new(&mut input);
+ let input = selector_text;
+ let mut parser = Parser::new(input);
selector_tokens_use_pseudo_class(&mut parser, "defined")
}
-fn selector_tokens_use_pseudo_class(parser: &mut Parser<'_, '_>, pseudo_class_name: &str) -> bool {
+fn selector_tokens_use_pseudo_class(parser: &mut Parser<'_>, pseudo_class_name: &str) -> bool {
let mut previous_was_colon = false;
while let Ok(token) = parser.next_including_whitespace_and_comments().cloned() {
match token {
@@ -563,7 +560,7 @@ fn selector_tokens_use_pseudo_class(parser: &mut Parser<'_, '_>, pseudo_class_na
.parse_nested_block(|parser| {
selector_tokens_use_pseudo_class(parser, pseudo_class_name)
.then_some(())
- .ok_or_else(|| parser.new_custom_error::<(), ()>(()))
+ .ok_or_else(|| cssparser::ParseError::<()>::custom(()))
})
.is_ok()
{
@@ -585,8 +582,8 @@ fn selector_tokens_use_pseudo_class(parser: &mut Parser<'_, '_>, pseudo_class_na
}
pub(crate) fn dom_api_selector_list_has_only_known_pseudo_elements(selector_text: &str) -> bool {
- let mut input = ParserInput::new(selector_text);
- let mut parser = Parser::new(&mut input);
+ let input = selector_text;
+ let mut parser = Parser::new(input);
let mut saw_any_selector = false;
let mut current_has_tokens = false;
let mut current_ends_with_known_pseudo_element = false;
@@ -634,8 +631,8 @@ pub(crate) fn dom_api_selector_list_has_only_known_pseudo_elements(selector_text
}
pub(crate) fn dom_api_selector_list_contains_known_pseudo_element(selector_text: &str) -> bool {
- let mut input = ParserInput::new(selector_text);
- let mut parser = Parser::new(&mut input);
+ let input = selector_text;
+ let mut parser = Parser::new(input);
while !parser.is_exhausted() {
let Ok(token) = parser.next_including_whitespace_and_comments().cloned() else {
@@ -669,8 +666,8 @@ pub(crate) fn dom_api_selector_list_contains_known_pseudo_element(selector_text:
}
pub(crate) fn selector_list_has_invalid_terminal_pseudo_element_chain(selector_text: &str) -> bool {
- let mut input = ParserInput::new(selector_text);
- let mut parser = Parser::new(&mut input);
+ let input = selector_text;
+ let mut parser = Parser::new(input);
let mut selector_has_terminal_pseudo_element = false;
while !parser.is_exhausted() {
@@ -718,7 +715,7 @@ enum KnownPseudoElementKind {
}
fn parse_known_pseudo_element_after_colon(
- parser: &mut Parser<'_, '_>,
+ parser: &mut Parser<'_>,
) -> Option<KnownPseudoElementKind> {
let state = parser.state();
if !matches!(
@@ -789,8 +786,8 @@ pub fn get_computed_style_pseudo_element(value: &str) -> GetComputedStylePseudoE
}
fn parse_get_computed_style_pseudo_component(value: &str, allow_modern: bool) -> Option<String> {
- let mut input = ParserInput::new(value);
- let mut parser = Parser::new(&mut input);
+ let input = value;
+ let mut parser = Parser::new(input);
let token = parser
.next_including_whitespace_and_comments()
.ok()?
@@ -825,10 +822,10 @@ fn parse_get_computed_style_pseudo_component(value: &str, allow_modern: bool) ->
.then_some(pseudo)
}
-fn parse_functional_pseudo_element_argument<'i, 't>(
+fn parse_functional_pseudo_element_argument<'i>(
name: &str,
- parser: &mut Parser<'i, 't>,
-) -> Result<String, cssparser::ParseError<'i, ()>> {
+ parser: &mut Parser<'i>,
+) -> Result<String, cssparser::ParseError<()>> {
let argument = match name {
"highlight"
| "view-transition-image-pair"
@@ -840,7 +837,7 @@ fn parse_functional_pseudo_element_argument<'i, 't>(
.map_err(cssparser::ParseError::from)?;
let ident = ident.to_string();
if ident == "*" {
- return Err(parser.new_custom_error(()));
+ return Err(cssparser::ParseError::custom(()));
}
ident
}
@@ -849,23 +846,23 @@ fn parse_functional_pseudo_element_argument<'i, 't>(
.expect_ident_cloned()
.map_err(cssparser::ParseError::from)?;
if !ident.eq_ignore_ascii_case("select") {
- return Err(parser.new_custom_error(()));
+ return Err(cssparser::ParseError::custom(()));
}
"select".to_owned()
}
- _ => return Err(parser.new_custom_error(())),
+ _ => return Err(cssparser::ParseError::custom(())),
};
if parser.is_exhausted() {
Ok(argument)
} else {
- Err(parser.new_custom_error(()))
+ Err(cssparser::ParseError::custom(()))
}
}
fn consume_nested_component_value<'i>(
- input: &mut Parser<'i, '_>,
+ input: &mut Parser<'i>,
token: &Token<'i>,
-) -> Result<(), cssparser::ParseError<'i, ()>> {
+) -> Result<(), cssparser::ParseError<()>> {
if matches!(
token,
Token::Function(_)
@@ -878,16 +875,14 @@ fn consume_nested_component_value<'i>(
Ok(())
}
-fn consume_component_values<'i>(
- input: &mut Parser<'i, '_>,
-) -> Result<(), cssparser::ParseError<'i, ()>> {
+fn consume_component_values<'i>(input: &mut Parser<'i>) -> Result<(), cssparser::ParseError<()>> {
while !input.is_exhausted() {
let token = input
.next_including_whitespace_and_comments()
.map_err(cssparser::ParseError::from)?
.clone();
if token.is_parse_error() {
- return Err(input.new_error(BasicParseErrorKind::UnexpectedToken(token)));
+ return Err(cssparser::BasicParseError::unexpected_token().into());
}
consume_nested_component_value(input, &token)?;
}
diff --git a/moli-selector/src/detached_stylo.rs b/moli-selector/src/detached_stylo.rs
index 98e001d55..259db6236 100644
--- a/moli-selector/src/detached_stylo.rs
+++ b/moli-selector/src/detached_stylo.rs
@@ -434,14 +434,14 @@ where
local_name: &<Self::Impl as selectors::parser::SelectorImpl>::BorrowedLocalName,
) -> bool {
self.local_name()
- .is_some_and(|actual| actual == local_name.as_ref())
+ .is_some_and(|actual| actual == **local_name)
}
fn has_namespace(
&self,
ns: &<Self::Impl as selectors::parser::SelectorImpl>::BorrowedNamespaceUrl,
) -> bool {
- self.namespace_uri() == ns.as_ref()
+ self.namespace_uri() == **ns
}
fn is_same_type(&self, other: &Self) -> bool {
@@ -458,11 +458,11 @@ where
) -> bool {
let namespace_matches = match ns {
NamespaceConstraint::Any => true,
- NamespaceConstraint::Specific(namespace) => namespace.as_ref().is_empty(),
+ NamespaceConstraint::Specific(namespace) => (**namespace).is_empty(),
};
namespace_matches
&& self
- .attribute_value(local_name.as_ref())
+ .attribute_value(local_name)
.is_some_and(|actual| operation.eval_str(&actual))
}
@@ -549,8 +549,8 @@ where
) -> bool {
self.attribute_value("id")
.is_some_and(|actual| match case_sensitivity {
- CaseSensitivity::CaseSensitive => actual == id.as_ref(),
- CaseSensitivity::AsciiCaseInsensitive => actual.eq_ignore_ascii_case(id.as_ref()),
+ CaseSensitivity::CaseSensitive => actual == AsRef::<str>::as_ref(&id.0),
+ CaseSensitivity::AsciiCaseInsensitive => actual.eq_ignore_ascii_case(id),
})
}
@@ -563,10 +563,8 @@ where
classes
.split_ascii_whitespace()
.any(|class| match case_sensitivity {
- CaseSensitivity::CaseSensitive => class == name.as_ref(),
- CaseSensitivity::AsciiCaseInsensitive => {
- class.eq_ignore_ascii_case(name.as_ref())
- }
+ CaseSensitivity::CaseSensitive => class == &**name,
+ CaseSensitivity::AsciiCaseInsensitive => class.eq_ignore_ascii_case(name),
})
})
}
@@ -586,11 +584,8 @@ where
}
fn is_part(&self, name: &<Self::Impl as selectors::parser::SelectorImpl>::Identifier) -> bool {
- self.attribute_value("part").is_some_and(|parts| {
- parts
- .split_ascii_whitespace()
- .any(|part| part == name.as_ref())
- })
+ self.attribute_value("part")
+ .is_some_and(|parts| parts.split_ascii_whitespace().any(|part| part == &**name))
}
fn is_empty(&self) -> bool {
diff --git a/moli-selector/src/lib.rs b/moli-selector/src/lib.rs
index 5f5c28840..8c74b235f 100644
--- a/moli-selector/src/lib.rs
+++ b/moli-selector/src/lib.rs
@@ -642,7 +642,7 @@ mod tests {
assert!(element.is_html_element());
assert_eq!(element.id().map(AsRef::as_ref), Some("target"));
let mut classes = Vec::new();
- element.each_class(|class| classes.push(class.as_ref().to_owned()));
+ element.each_class(|class| classes.push(AsRef::<str>::as_ref(&class.0).to_owned()));
assert_eq!(classes, vec!["card", "selected"]);
assert!(element.state().contains(ElementState::DISABLED));
@@ -922,10 +922,10 @@ mod tests {
url_data: &url_data,
for_supports_rule: false,
};
- let mut input = cssparser::ParserInput::new(selector);
+ let input = selector;
let selectors = SelectorList::parse(
&parser,
- &mut cssparser::Parser::new(&mut input),
+ &mut cssparser::Parser::new(input),
ParseRelative::No,
)
.expect("style selector should parse");
diff --git a/moli-selector/src/stylo/query/element.rs b/moli-selector/src/stylo/query/element.rs
index 0d8500e4c..e98a8ca33 100644
--- a/moli-selector/src/stylo/query/element.rs
+++ b/moli-selector/src/stylo/query/element.rs
@@ -129,8 +129,8 @@ impl<'a> TElement for QueryElement<'a> {
type TraversalChildrenIterator = vec::IntoIter<QueryNode<'a>>;
fn get_attr(&self, attr: &LocalName, namespace: &Namespace) -> Option<String> {
- let local_name = attr.as_ref();
- let namespace = namespace.as_ref();
+ let local_name: &str = attr.as_ref();
+ let namespace = &**namespace;
self.element()
.attributes()
.iter()
@@ -244,8 +244,7 @@ impl<'a> TElement for QueryElement<'a> {
let Some(exportparts) = self.element().attribute("exportparts") else {
return;
};
- for (_, outer) in
- exported_part_mappings(exportparts).filter(|(inner, _)| *inner == name.as_ref())
+ for (_, outer) in exported_part_mappings(exportparts).filter(|(inner, _)| *inner == &**name)
{
callback(self.atom_cache.atom_ident(outer));
}
@@ -551,14 +550,14 @@ impl SelectorsElement for QueryElement<'_> {
&self,
local_name: &<Self::Impl as selectors::parser::SelectorImpl>::BorrowedLocalName,
) -> bool {
- self.element().local_name() == local_name.as_ref()
+ self.element().local_name() == &**local_name
}
fn has_namespace(
&self,
ns: &<Self::Impl as selectors::parser::SelectorImpl>::BorrowedNamespaceUrl,
) -> bool {
- self.element().namespace() == ns.as_ref()
+ self.element().namespace() == &**ns
}
fn is_same_type(&self, other: &Self) -> bool {
@@ -574,7 +573,7 @@ impl SelectorsElement for QueryElement<'_> {
&<Self::Impl as selectors::parser::SelectorImpl>::AttrValue,
>,
) -> bool {
- let wanted_name = local_name.as_ref();
+ let wanted_name = &**local_name;
self.element().attributes().iter().any(|attribute| {
if attribute.local_name() != wanted_name {
return false;
@@ -582,7 +581,7 @@ impl SelectorsElement for QueryElement<'_> {
let namespace_matches = match ns {
NamespaceConstraint::Any => true,
NamespaceConstraint::Specific(namespace) => {
- attribute.namespace() == namespace.as_ref()
+ attribute.namespace() == AsRef::<str>::as_ref(&namespace.0)
}
};
namespace_matches && operation.eval_str(attribute.value())
@@ -693,8 +692,8 @@ impl SelectorsElement for QueryElement<'_> {
self.element()
.id()
.is_some_and(|actual| match case_sensitivity {
- CaseSensitivity::CaseSensitive => actual == id.as_ref(),
- CaseSensitivity::AsciiCaseInsensitive => actual.eq_ignore_ascii_case(id.as_ref()),
+ CaseSensitivity::CaseSensitive => actual == &**id,
+ CaseSensitivity::AsciiCaseInsensitive => actual.eq_ignore_ascii_case(id),
})
}
@@ -707,10 +706,8 @@ impl SelectorsElement for QueryElement<'_> {
classes
.split_ascii_whitespace()
.any(|class| match case_sensitivity {
- CaseSensitivity::CaseSensitive => class == name.as_ref(),
- CaseSensitivity::AsciiCaseInsensitive => {
- class.eq_ignore_ascii_case(name.as_ref())
- }
+ CaseSensitivity::CaseSensitive => class == &**name,
+ CaseSensitivity::AsciiCaseInsensitive => class.eq_ignore_ascii_case(name),
})
})
}
@@ -731,11 +728,9 @@ impl SelectorsElement for QueryElement<'_> {
}
fn is_part(&self, name: &<Self::Impl as selectors::parser::SelectorImpl>::Identifier) -> bool {
- self.element().attribute("part").is_some_and(|parts| {
- parts
- .split_ascii_whitespace()
- .any(|part| part == name.as_ref())
- })
+ self.element()
+ .attribute("part")
+ .is_some_and(|parts| parts.split_ascii_whitespace().any(|part| part == &**name))
}
fn is_empty(&self) -> bool {
diff --git a/moli-selector/src/stylo/selector_parse.rs b/moli-selector/src/stylo/selector_parse.rs
index 3cfa6863b..08ca204d8 100644
--- a/moli-selector/src/stylo/selector_parse.rs
+++ b/moli-selector/src/stylo/selector_parse.rs
@@ -73,10 +73,10 @@ fn parse_dom_api_selector_list_text_for_url(
url_data: &url_data,
for_supports_rule: false,
};
- let mut input = cssparser::ParserInput::new(selector);
+ let input = selector;
selectors::parser::SelectorList::parse(
&parser,
- &mut cssparser::Parser::new(&mut input),
+ &mut cssparser::Parser::new(input),
ParseRelative::No,
)
.map_err(|error| SelectorError::syntax(format!("{error:?}")))
@@ -247,10 +247,10 @@ fn parse_style_rule_selector_list_for_url_and_namespaces_with_relative(
url_data: &url_data,
for_supports_rule,
};
- let mut input = cssparser::ParserInput::new(selector);
+ let input = selector;
selectors::parser::SelectorList::parse(
&parser,
- &mut cssparser::Parser::new(&mut input),
+ &mut cssparser::Parser::new(input),
parse_relative,
)
.map_err(|error| SelectorError::syntax(format!("{error:?}")))
diff --git a/moli-selector/src/stylo/style_traversal.rs b/moli-selector/src/stylo/style_traversal.rs
index 7034c8610..bdd2d28d6 100644
--- a/moli-selector/src/stylo/style_traversal.rs
+++ b/moli-selector/src/stylo/style_traversal.rs
@@ -2251,14 +2251,14 @@ impl SelectorsElement for StyleElement<'_> {
&self,
local_name: &<Self::Impl as selectors::parser::SelectorImpl>::BorrowedLocalName,
) -> bool {
- self.element().local_name() == local_name.as_ref()
+ self.element().local_name() == AsRef::<str>::as_ref(local_name)
}
fn has_namespace(
&self,
ns: &<Self::Impl as selectors::parser::SelectorImpl>::BorrowedNamespaceUrl,
) -> bool {
- self.element().namespace() == ns.as_ref()
+ self.element().namespace() == AsRef::<str>::as_ref(ns)
}
fn is_same_type(&self, other: &Self) -> bool {
diff --git a/moli-window-features/Cargo.toml b/moli-window-features/Cargo.toml
index 89a63a98b..b9bd9cf86 100644
--- a/moli-window-features/Cargo.toml
+++ b/moli-window-features/Cargo.toml
@@ -5,7 +5,7 @@ edition = "2024"
[dependencies]
indexmap = "2.14.2"
-stylo = "0.20"
+stylo = "0.22"
[lints]
workspace = true
diff --git a/moli-wpt-compat/Cargo.toml b/moli-wpt-compat/Cargo.toml
index 5fb8d59c4..7a3ff4a9f 100644
--- a/moli-wpt-compat/Cargo.toml
+++ b/moli-wpt-compat/Cargo.toml
@@ -8,7 +8,7 @@ edition = "2024"
futures-util = { version = "0.3", default-features = false, features = ["sink", "std"] }
anyhow = "1.0.100"
axum = { version = "0.8.6", features = ["ws"] }
-html5ever = "0.39.0"
+html5ever = "0.40"
parking_lot = "0.12"
rcgen = { version = "0.13", default-features = false, features = ["aws_lc_rs"] }
serde = { version = "1.0.228", features = ["derive"] }
diff --git a/moli-wpt-compat/src/meta.rs b/moli-wpt-compat/src/meta.rs
index b2dfc5468..e7cf69af1 100644
--- a/moli-wpt-compat/src/meta.rs
+++ b/moli-wpt-compat/src/meta.rs
@@ -500,7 +500,7 @@ impl WptHtmlStaticReferenceSink {
let Some(src) = tag
.attrs
.iter()
- .find(|attr| attr.name.local.as_ref().eq_ignore_ascii_case("src"))
+ .find(|attr| AsRef::<str>::as_ref(&attr.name.local).eq_ignore_ascii_case("src"))
.map(|attr| attr.value.to_string())
else {
return;
@@ -523,7 +523,7 @@ impl TokenSink for WptHtmlStaticReferenceSink {
return TokenSinkResult::Continue;
}
- match tag.name.as_ref() {
+ match AsRef::<str>::as_ref(&tag.name) {
"script" => {
self.collect_src_reference(&tag);
TokenSinkResult::RawData(ScriptData)
diff --git a/moli-xpath/Cargo.toml b/moli-xpath/Cargo.toml
index f8c2ffc12..67b9303b5 100644
--- a/moli-xpath/Cargo.toml
+++ b/moli-xpath/Cargo.toml
@@ -6,7 +6,7 @@ license = "MPL-2.0"
[dependencies]
log = "0.4"
-markup5ever = "0.39.0"
+markup5ever = "0.40"
[lints]
workspace = true
diff --git a/moli-xpath/src/eval.rs b/moli-xpath/src/eval.rs
index 614759e12..a0578a0cd 100644
--- a/moli-xpath/src/eval.rs
+++ b/moli-xpath/src/eval.rs
@@ -196,9 +196,7 @@ pub(crate) fn element_name_test(
match comparison_mode {
NameTestComparisonMode::HtmlElement | NameTestComparisonMode::HtmlAttribute => {
- expected_name
- .local
- .as_ref()
+ AsRef::<str>::as_ref(&expected_name.local)
.eq_ignore_ascii_case(actual_name.local.as_ref())
}
NameTestComparisonMode::XHtml => expected_name.local == actual_name.local,
diff --git a/vendor/xml5ever-0.39.0/Cargo.toml b/vendor/xml5ever-0.40.0/Cargo.toml
similarity index 96%
rename from vendor/xml5ever-0.39.0/Cargo.toml
rename to vendor/xml5ever-0.40.0/Cargo.toml
index ebcf2564b..0c0e4e738 100644
--- a/vendor/xml5ever-0.39.0/Cargo.toml
+++ b/vendor/xml5ever-0.40.0/Cargo.toml
@@ -11,9 +11,9 @@
[package]
edition = "2021"
-rust-version = "1.71.0"
+rust-version = "1.85"
name = "xml5ever"
-version = "0.39.0"
+version = "0.40.0"
authors = ["The xml5ever project developers"]
build = false
exclude = ["xml5lib-tests/*"]
@@ -64,7 +64,7 @@ harness = false
version = "0.4"
[dependencies.markup5ever]
-version = "0.39"
+version = "0.40"
[dev-dependencies.criterion]
version = "0.8"
diff --git a/vendor/xml5ever-0.39.0/LICENSE-APACHE b/vendor/xml5ever-0.40.0/LICENSE-APACHE
similarity index 100%
rename from vendor/xml5ever-0.39.0/LICENSE-APACHE
rename to vendor/xml5ever-0.40.0/LICENSE-APACHE
diff --git a/vendor/xml5ever-0.39.0/LICENSE-MIT b/vendor/xml5ever-0.40.0/LICENSE-MIT
similarity index 100%
rename from vendor/xml5ever-0.39.0/LICENSE-MIT
rename to vendor/xml5ever-0.40.0/LICENSE-MIT
diff --git a/vendor/xml5ever-0.39.0/MOLI_VENDORING.md b/vendor/xml5ever-0.40.0/MOLI_VENDORING.md
similarity index 75%
rename from vendor/xml5ever-0.39.0/MOLI_VENDORING.md
rename to vendor/xml5ever-0.40.0/MOLI_VENDORING.md
index 0e69e8cc7..5dfb596c5 100644
--- a/vendor/xml5ever-0.39.0/MOLI_VENDORING.md
+++ b/vendor/xml5ever-0.40.0/MOLI_VENDORING.md
@@ -1,6 +1,6 @@
-# xml5ever 0.39.0
+# xml5ever 0.40.0
-This directory contains the source of the crates.io `xml5ever` 0.39.0 release.
+This directory contains the source of the crates.io `xml5ever` 0.40.0 release.
It is patched locally because Moli needs the tokenizer to preserve CDATA as a
distinct token, the XML tree builder to surface CDATA nodes to its sink, and
namespace declarations to remain available as DOM attributes after binding.
@@ -9,3 +9,6 @@ referenced carriage returns and C1 values without HTML's Windows-1252 mapping.
The upstream source is licensed under MIT or Apache-2.0; see `LICENSE-MIT` and
`LICENSE-APACHE` in this directory.
+
+Updated with the crates.io 0.40.0 release. The CDATA, namespace attribute,
+and XML character-reference patches above are retained on the new source.
diff --git a/vendor/xml5ever-0.39.0/README.md b/vendor/xml5ever-0.40.0/README.md
similarity index 100%
rename from vendor/xml5ever-0.39.0/README.md
rename to vendor/xml5ever-0.40.0/README.md
diff --git a/vendor/xml5ever-0.39.0/benches/xml5ever.rs b/vendor/xml5ever-0.40.0/benches/xml5ever.rs
similarity index 100%
rename from vendor/xml5ever-0.39.0/benches/xml5ever.rs
rename to vendor/xml5ever-0.40.0/benches/xml5ever.rs
diff --git a/vendor/xml5ever-0.40.0/data/bench/strong.xml b/vendor/xml5ever-0.40.0/data/bench/strong.xml
new file mode 100644
index 000000000..0ef665e5d
--- /dev/null
+++ b/vendor/xml5ever-0.40.0/data/bench/strong.xml
@@ -0,0 +1 @@
+<strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>
\ No newline at end of file
diff --git a/vendor/xml5ever-0.39.0/examples/README.md b/vendor/xml5ever-0.40.0/examples/README.md
similarity index 100%
rename from vendor/xml5ever-0.39.0/examples/README.md
rename to vendor/xml5ever-0.40.0/examples/README.md
diff --git a/vendor/xml5ever-0.39.0/examples/example.xml b/vendor/xml5ever-0.40.0/examples/example.xml
similarity index 100%
rename from vendor/xml5ever-0.39.0/examples/example.xml
rename to vendor/xml5ever-0.40.0/examples/example.xml
diff --git a/vendor/xml5ever-0.39.0/examples/simple_xml_tokenizer.rs b/vendor/xml5ever-0.40.0/examples/simple_xml_tokenizer.rs
similarity index 100%
rename from vendor/xml5ever-0.39.0/examples/simple_xml_tokenizer.rs
rename to vendor/xml5ever-0.40.0/examples/simple_xml_tokenizer.rs
diff --git a/vendor/xml5ever-0.39.0/examples/xml_tokenizer.rs b/vendor/xml5ever-0.40.0/examples/xml_tokenizer.rs
similarity index 100%
rename from vendor/xml5ever-0.39.0/examples/xml_tokenizer.rs
rename to vendor/xml5ever-0.40.0/examples/xml_tokenizer.rs
diff --git a/vendor/xml5ever-0.39.0/src/driver.rs b/vendor/xml5ever-0.40.0/src/driver.rs
similarity index 100%
rename from vendor/xml5ever-0.39.0/src/driver.rs
rename to vendor/xml5ever-0.40.0/src/driver.rs
diff --git a/vendor/xml5ever-0.39.0/src/lib.rs b/vendor/xml5ever-0.40.0/src/lib.rs
similarity index 100%
rename from vendor/xml5ever-0.39.0/src/lib.rs
rename to vendor/xml5ever-0.40.0/src/lib.rs
diff --git a/vendor/xml5ever-0.39.0/src/macros.rs b/vendor/xml5ever-0.40.0/src/macros.rs
similarity index 100%
rename from vendor/xml5ever-0.39.0/src/macros.rs
rename to vendor/xml5ever-0.40.0/src/macros.rs
diff --git a/vendor/xml5ever-0.39.0/src/serialize/mod.rs b/vendor/xml5ever-0.40.0/src/serialize/mod.rs
similarity index 100%
rename from vendor/xml5ever-0.39.0/src/serialize/mod.rs
rename to vendor/xml5ever-0.40.0/src/serialize/mod.rs
diff --git a/vendor/xml5ever-0.39.0/src/tokenizer/char_ref/mod.rs b/vendor/xml5ever-0.40.0/src/tokenizer/char_ref/mod.rs
similarity index 100%
rename from vendor/xml5ever-0.39.0/src/tokenizer/char_ref/mod.rs
rename to vendor/xml5ever-0.40.0/src/tokenizer/char_ref/mod.rs
diff --git a/vendor/xml5ever-0.39.0/src/tokenizer/interface.rs b/vendor/xml5ever-0.40.0/src/tokenizer/interface.rs
similarity index 100%
rename from vendor/xml5ever-0.39.0/src/tokenizer/interface.rs
rename to vendor/xml5ever-0.40.0/src/tokenizer/interface.rs
diff --git a/vendor/xml5ever-0.39.0/src/tokenizer/mod.rs b/vendor/xml5ever-0.40.0/src/tokenizer/mod.rs
similarity index 72%
rename from vendor/xml5ever-0.39.0/src/tokenizer/mod.rs
rename to vendor/xml5ever-0.40.0/src/tokenizer/mod.rs
index 09d091974..aa7ecd6c2 100644
--- a/vendor/xml5ever-0.39.0/src/tokenizer/mod.rs
+++ b/vendor/xml5ever-0.40.0/src/tokenizer/mod.rs
@@ -24,6 +24,7 @@ use log::debug;
use markup5ever::{ns, small_char_set, TokenizerResult};
use std::borrow::Cow::{self, Borrowed};
use std::cell::{Cell, RefCell, RefMut};
+use std::cmp::Reverse;
use std::collections::BTreeMap;
use std::mem::replace;
@@ -596,26 +597,20 @@ macro_rules! go (
// These can only come at the end.
- ( $me:ident : to $s:ident ) => ({ $me.state.set(XmlState::$s); return ProcessResult::Continue; });
- ( $me:ident : to $s:ident $k1:expr ) => ({ $me.state.set(XmlState::$s($k1)); return ProcessResult::Continue; });
- ( $me:ident : to $s:ident $k1:ident $k2:expr ) => ({ $me.state.set(XmlState::$s($k1($k2))); return ProcessResult::Continue; });
-
- ( $me:ident : reconsume $s:ident ) => ({ $me.reconsume.set(true); go!($me: to $s); });
- ( $me:ident : reconsume $s:ident $k1:expr ) => ({ $me.reconsume.set(true); go!($me: to $s $k1); });
- ( $me:ident : reconsume $s:ident $k1:ident $k2:expr ) => ({ $me.reconsume.set(true); go!($me: to $s $k1 $k2); });
-
+ ( $me:ident : to $s:expr ) => ({ $me.state.set($s); return ProcessResult::Continue; });
+ ( $me:ident : reconsume $s:expr ) => ({ $me.reconsume.set(true); go!($me: to $s); });
( $me:ident : consume_char_ref ) => ({ $me.consume_char_ref(None); return ProcessResult::Continue; });
( $me:ident : consume_char_ref $addnl:expr ) => ({ $me.consume_char_ref(Some($addnl)); return ProcessResult::Continue; });
// We have a default next state after emitting a tag, but the sink can override.
- ( $me:ident : emit_tag $s:ident ) => ({
- $me.state.set(XmlState::$s);
+ ( $me:ident : emit_tag $s:expr ) => ({
+ $me.state.set($s);
return $me.emit_current_tag();
});
// We have a special when dealing with empty and short tags in Xml
- ( $me:ident : emit_short_tag $s:ident ) => ({
- $me.state.set(XmlState::$s);
+ ( $me:ident : emit_short_tag $s:expr ) => ({
+ $me.state.set($s);
return $me.emit_short_tag();
});
@@ -657,13 +652,6 @@ macro_rules! get_char ( ($me:expr, $input:expr) => {{
character
}});
-macro_rules! pop_except_from ( ($me:expr, $input:expr, $set:expr) => {{
- let Some(popped_element) = $me.pop_except_from($input, $set) else {
- return ProcessResult::Done;
- };
- popped_element
-}});
-
macro_rules! eat ( ($me:expr, $input:expr, $pat:expr) => {{
let Some(value) = $me.eat($input, $pat) else {
return ProcessResult::Done;
@@ -694,9 +682,15 @@ impl<Sink: TokenSink> XmlTokenizer<Sink> {
match self.state.get() {
//§ data-state
XmlState::Data => loop {
- match pop_except_from!(self, input, small_char_set!('\r' '&' '<')) {
+ let Some(popped_element) =
+ self.pop_except_from(input, small_char_set!('\r' '&' '<'))
+ else {
+ return ProcessResult::Done;
+ };
+
+ match popped_element {
FromSet('&') => go!(self: consume_char_ref),
- FromSet('<') => go!(self: to TagState),
+ FromSet('<') => go!(self: to XmlState::TagState),
FromSet(c) => go!(self: emit c),
NotFromSet(b) => self.emit_chars(b),
}
@@ -704,38 +698,38 @@ impl<Sink: TokenSink> XmlTokenizer<Sink> {
//§ tag-state
XmlState::TagState => loop {
match get_char!(self, input) {
- '!' => go!(self: to MarkupDecl),
- '/' => go!(self: to EndTagState),
- '?' => go!(self: to Pi),
+ '!' => go!(self: to XmlState::MarkupDecl),
+ '/' => go!(self: to XmlState::EndTagState),
+ '?' => go!(self: to XmlState::Pi),
'\t' | '\n' | ' ' | ':' | '<' | '>' => {
- go!(self: error; emit '<'; reconsume Data)
+ go!(self: error; emit '<'; reconsume XmlState::Data)
},
- cl => go!(self: create_tag StartTag cl; to TagName),
+ cl => go!(self: create_tag StartTag cl; to XmlState::TagName),
}
},
//§ end-tag-state
XmlState::EndTagState => loop {
match get_char!(self, input) {
- '>' => go!(self: emit_short_tag Data),
+ '>' => go!(self: emit_short_tag XmlState::Data),
'\t' | '\n' | ' ' | '<' | ':' => {
- go!(self: error; emit '<'; emit '/'; reconsume Data)
+ go!(self: error; emit '<'; emit '/'; reconsume XmlState::Data)
},
- cl => go!(self: create_tag EndTag cl; to EndTagName),
+ cl => go!(self: create_tag EndTag cl; to XmlState::EndTagName),
}
},
//§ end-tag-name-state
XmlState::EndTagName => loop {
match get_char!(self, input) {
- '\t' | '\n' | ' ' => go!(self: to EndTagNameAfter),
- '/' => go!(self: error; to EndTagNameAfter),
- '>' => go!(self: emit_tag Data),
+ '\t' | '\n' | ' ' => go!(self: to XmlState::EndTagNameAfter),
+ '/' => go!(self: error; to XmlState::EndTagNameAfter),
+ '>' => go!(self: emit_tag XmlState::Data),
cl => go!(self: push_tag cl),
}
},
//§ end-tag-name-after-state
XmlState::EndTagNameAfter => loop {
match get_char!(self, input) {
- '>' => go!(self: emit_tag Data),
+ '>' => go!(self: emit_tag XmlState::Data),
'\t' | '\n' | ' ' => (),
_ => self.emit_error(Borrowed("Unexpected element in tag name")),
}
@@ -743,15 +737,15 @@ impl<Sink: TokenSink> XmlTokenizer<Sink> {
//§ pi-state
XmlState::Pi => loop {
match get_char!(self, input) {
- '\t' | '\n' | ' ' => go!(self: error; reconsume BogusComment),
- cl => go!(self: create_pi cl; to PiTarget),
+ '\t' | '\n' | ' ' => go!(self: error; reconsume XmlState::BogusComment),
+ cl => go!(self: create_pi cl; to XmlState::PiTarget),
}
},
//§ pi-target-state
XmlState::PiTarget => loop {
match get_char!(self, input) {
- '\t' | '\n' | ' ' => go!(self: to PiTargetAfter),
- '?' => go!(self: to PiAfter),
+ '\t' | '\n' | ' ' => go!(self: to XmlState::PiTargetAfter),
+ '?' => go!(self: to XmlState::PiAfter),
cl => go!(self: push_pi_target cl),
}
},
@@ -759,13 +753,13 @@ impl<Sink: TokenSink> XmlTokenizer<Sink> {
XmlState::PiTargetAfter => loop {
match get_char!(self, input) {
'\t' | '\n' | ' ' => (),
- _ => go!(self: reconsume PiData),
+ _ => go!(self: reconsume XmlState::PiData),
}
},
//§ pi-data-state
XmlState::PiData => loop {
match get_char!(self, input) {
- '?' => go!(self: to PiAfter),
+ '?' => go!(self: to XmlState::PiAfter),
cl => go!(self: push_pi_data cl),
}
},
@@ -773,119 +767,122 @@ impl<Sink: TokenSink> XmlTokenizer<Sink> {
XmlState::PiAfter => loop {
match get_char!(self, input) {
'>' => go!(self: emit_pi Data),
- '?' => go!(self: to PiAfter),
- cl => go!(self: push_pi_data cl),
+ // The '?' that got us here is not part of a '?>', so it is
+ // ordinary data. The one we just read may still close the
+ // processing instruction, so stay in this state.
+ '?' => go!(self: push_pi_data '?'; to XmlState::PiAfter),
+ cl => go!(self: push_pi_data '?'; push_pi_data cl; to XmlState::PiData),
}
},
//§ markup-declaration-state
XmlState::MarkupDecl => loop {
if eat!(self, input, "--") {
- go!(self: clear_comment; to CommentStart);
+ go!(self: clear_comment; to XmlState::CommentStart);
} else if eat!(self, input, "[CDATA[") {
- go!(self: clear_cdata; to Cdata);
+ go!(self: clear_cdata; to XmlState::Cdata);
} else if eat!(self, input, "DOCTYPE") {
- go!(self: to Doctype);
+ go!(self: to XmlState::Doctype);
} else {
// FIXME: 'error' gives wrong message
- go!(self: error; to BogusComment);
+ go!(self: error; to XmlState::BogusComment);
}
},
//§ comment-start-state
XmlState::CommentStart => loop {
match get_char!(self, input) {
- '-' => go!(self: to CommentStartDash),
- '>' => go!(self: error; emit_comment; to Data),
- _ => go!(self: reconsume Comment),
+ '-' => go!(self: to XmlState::CommentStartDash),
+ '>' => go!(self: error; emit_comment; to XmlState::Data),
+ _ => go!(self: reconsume XmlState::Comment),
}
},
//§ comment-start-dash-state
XmlState::CommentStartDash => loop {
match get_char!(self, input) {
- '-' => go!(self: to CommentEnd),
- '>' => go!(self: error; emit_comment; to Data),
- _ => go!(self: push_comment '-'; reconsume Comment),
+ '-' => go!(self: to XmlState::CommentEnd),
+ '>' => go!(self: error; emit_comment; to XmlState::Data),
+ _ => go!(self: push_comment '-'; reconsume XmlState::Comment),
}
},
//§ comment-state
XmlState::Comment => loop {
match get_char!(self, input) {
- '<' => go!(self: push_comment '<'; to CommentLessThan),
- '-' => go!(self: to CommentEndDash),
+ '<' => go!(self: push_comment '<'; to XmlState::CommentLessThan),
+ '-' => go!(self: to XmlState::CommentEndDash),
c => go!(self: push_comment c),
}
},
//§ comment-less-than-sign-state
XmlState::CommentLessThan => loop {
match get_char!(self, input) {
- '!' => go!(self: push_comment '!';to CommentLessThanBang),
+ '!' => go!(self: push_comment '!';to XmlState::CommentLessThanBang),
'<' => go!(self: push_comment '<'),
- _ => go!(self: reconsume Comment),
+ _ => go!(self: reconsume XmlState::Comment),
}
},
//§ comment-less-than-sign-bang-state
XmlState::CommentLessThanBang => loop {
match get_char!(self, input) {
- '-' => go!(self: to CommentLessThanBangDash),
- _ => go!(self: reconsume Comment),
+ '-' => go!(self: to XmlState::CommentLessThanBangDash),
+ _ => go!(self: reconsume XmlState::Comment),
}
},
//§ comment-less-than-sign-bang-dash-state
XmlState::CommentLessThanBangDash => loop {
match get_char!(self, input) {
- '-' => go!(self: to CommentLessThanBangDashDash),
- _ => go!(self: reconsume CommentEndDash),
+ '-' => go!(self: to XmlState::CommentLessThanBangDashDash),
+ _ => go!(self: reconsume XmlState::CommentEndDash),
}
},
//§ comment-less-than-sign-bang-dash-dash-state
XmlState::CommentLessThanBangDashDash => loop {
match get_char!(self, input) {
- '>' => go!(self: reconsume CommentEnd),
- _ => go!(self: error; reconsume CommentEnd),
+ '>' => go!(self: reconsume XmlState::CommentEnd),
+ _ => go!(self: error; reconsume XmlState::CommentEnd),
}
},
//§ comment-end-dash-state
XmlState::CommentEndDash => loop {
match get_char!(self, input) {
- '-' => go!(self: to CommentEnd),
- _ => go!(self: push_comment '-'; reconsume Comment),
+ '-' => go!(self: to XmlState::CommentEnd),
+ _ => go!(self: push_comment '-'; reconsume XmlState::Comment),
}
},
//§ comment-end-state
XmlState::CommentEnd => loop {
match get_char!(self, input) {
- '>' => go!(self: emit_comment; to Data),
- '!' => go!(self: to CommentEndBang),
+ '>' => go!(self: emit_comment; to XmlState::Data),
+ '!' => go!(self: to XmlState::CommentEndBang),
'-' => go!(self: push_comment '-'),
- _ => go!(self: append_comment "--"; reconsume Comment),
+ _ => go!(self: append_comment "--"; reconsume XmlState::Comment),
}
},
//§ comment-end-bang-state
XmlState::CommentEndBang => loop {
match get_char!(self, input) {
- '-' => go!(self: append_comment "--!"; to CommentEndDash),
- '>' => go!(self: error; emit_comment; to Data),
- _ => go!(self: append_comment "--!"; reconsume Comment),
+ '-' => go!(self: append_comment "--!"; to XmlState::CommentEndDash),
+ '>' => go!(self: error; emit_comment; to XmlState::Data),
+ _ => go!(self: append_comment "--!"; reconsume XmlState::Comment),
}
},
//§ bogus-comment-state
XmlState::BogusComment => loop {
match get_char!(self, input) {
- '>' => go!(self: emit_comment; to Data),
+ '>' => go!(self: emit_comment; to XmlState::Data),
c => go!(self: push_comment c),
}
},
//§ cdata-state
XmlState::Cdata => loop {
match get_char!(self, input) {
- ']' => go!(self: to CdataBracket),
+ ']' => go!(self: to XmlState::CdataBracket),
cl => go!(self: push_cdata cl),
}
},
//§ cdata-bracket-state
XmlState::CdataBracket => loop {
match get_char!(self, input) {
- ']' => go!(self: to CdataEnd),
- cl => go!(self: push_cdata ']'; push_cdata cl; to Cdata),
+ ']' => go!(self: to XmlState::CdataEnd),
+ cl => go!(self: push_cdata ']'; push_cdata cl; to XmlState::Cdata),
}
},
//§ cdata-end-state
@@ -893,15 +890,17 @@ impl<Sink: TokenSink> XmlTokenizer<Sink> {
match get_char!(self, input) {
'>' => go!(self: emit_cdata Data),
']' => go!(self: push_cdata ']'),
- cl => go!(self: push_cdata ']'; push_cdata ']'; push_cdata cl; to Cdata),
+ cl => {
+ go!(self: push_cdata ']'; push_cdata ']'; push_cdata cl; to XmlState::Cdata)
+ },
}
},
//§ tag-name-state
XmlState::TagName => loop {
match get_char!(self, input) {
- '\t' | '\n' | ' ' => go!(self: to TagAttrNameBefore),
- '>' => go!(self: emit_tag Data),
- '/' => go!(self: set_empty_tag; to TagEmpty),
+ '\t' | '\n' | ' ' => go!(self: to XmlState::TagAttrNameBefore),
+ '>' => go!(self: emit_tag XmlState::Data),
+ '/' => go!(self: set_empty_tag; to XmlState::TagEmpty),
cl => go!(self: push_tag cl),
}
},
@@ -909,26 +908,26 @@ impl<Sink: TokenSink> XmlTokenizer<Sink> {
XmlState::TagEmpty => loop {
match get_char!(self, input) {
'>' => go!(self: emit_empty_tag Data),
- _ => go!(self: reconsume TagAttrValueBefore),
+ _ => go!(self: reconsume XmlState::TagAttrValueBefore),
}
},
//§ tag-attribute-name-before-state
XmlState::TagAttrNameBefore => loop {
match get_char!(self, input) {
'\t' | '\n' | ' ' => (),
- '>' => go!(self: emit_tag Data),
- '/' => go!(self: set_empty_tag; to TagEmpty),
+ '>' => go!(self: emit_tag XmlState::Data),
+ '/' => go!(self: set_empty_tag; to XmlState::TagEmpty),
':' => go!(self: error),
- cl => go!(self: create_attr cl; to TagAttrName),
+ cl => go!(self: create_attr cl; to XmlState::TagAttrName),
}
},
//§ tag-attribute-name-state
XmlState::TagAttrName => loop {
match get_char!(self, input) {
- '=' => go!(self: to TagAttrValueBefore),
- '>' => go!(self: emit_tag Data),
- '\t' | '\n' | ' ' => go!(self: to TagAttrNameAfter),
- '/' => go!(self: set_empty_tag; to TagEmpty),
+ '=' => go!(self: to XmlState::TagAttrValueBefore),
+ '>' => go!(self: emit_tag XmlState::Data),
+ '\t' | '\n' | ' ' => go!(self: to XmlState::TagAttrNameAfter),
+ '/' => go!(self: set_empty_tag; to XmlState::TagEmpty),
cl => go!(self: push_name cl),
}
},
@@ -936,27 +935,33 @@ impl<Sink: TokenSink> XmlTokenizer<Sink> {
XmlState::TagAttrNameAfter => loop {
match get_char!(self, input) {
'\t' | '\n' | ' ' => (),
- '=' => go!(self: to TagAttrValueBefore),
- '>' => go!(self: emit_tag Data),
- '/' => go!(self: set_empty_tag; to TagEmpty),
- cl => go!(self: create_attr cl; to TagAttrName),
+ '=' => go!(self: to XmlState::TagAttrValueBefore),
+ '>' => go!(self: emit_tag XmlState::Data),
+ '/' => go!(self: set_empty_tag; to XmlState::TagEmpty),
+ cl => go!(self: create_attr cl; to XmlState::TagAttrName),
}
},
//§ tag-attribute-value-before-state
XmlState::TagAttrValueBefore => loop {
match get_char!(self, input) {
'\t' | '\n' | ' ' => (),
- '"' => go!(self: to TagAttrValue DoubleQuoted),
- '\'' => go!(self: to TagAttrValue SingleQuoted),
- '&' => go!(self: reconsume TagAttrValue(Unquoted)),
- '>' => go!(self: emit_tag Data),
- cl => go!(self: push_value cl; to TagAttrValue(Unquoted)),
+ '"' => go!(self: to XmlState::TagAttrValue(DoubleQuoted)),
+ '\'' => go!(self: to XmlState::TagAttrValue(SingleQuoted)),
+ '&' => go!(self: reconsume XmlState::TagAttrValue(Unquoted)),
+ '>' => go!(self: emit_tag XmlState::Data),
+ cl => go!(self: push_value cl; to XmlState::TagAttrValue(Unquoted)),
}
},
//§ tag-attribute-value-double-quoted-state
XmlState::TagAttrValue(DoubleQuoted) => loop {
- match pop_except_from!(self, input, small_char_set!('\n' '"' '&')) {
- FromSet('"') => go!(self: to TagAttrNameBefore),
+ let Some(popped_element) =
+ self.pop_except_from(input, small_char_set!('\n' '"' '&'))
+ else {
+ return ProcessResult::Done;
+ };
+
+ match popped_element {
+ FromSet('"') => go!(self: to XmlState::TagAttrNameBefore),
FromSet('&') => go!(self: consume_char_ref '"' ),
FromSet(c) => go!(self: push_value c),
NotFromSet(ref b) => go!(self: append_value b),
@@ -964,8 +969,14 @@ impl<Sink: TokenSink> XmlTokenizer<Sink> {
},
//§ tag-attribute-value-single-quoted-state
XmlState::TagAttrValue(SingleQuoted) => loop {
- match pop_except_from!(self, input, small_char_set!('\n' '\'' '&')) {
- FromSet('\'') => go!(self: to TagAttrNameBefore),
+ let Some(popped_element) =
+ self.pop_except_from(input, small_char_set!('\n' '\'' '&'))
+ else {
+ return ProcessResult::Done;
+ };
+
+ match popped_element {
+ FromSet('\'') => go!(self: to XmlState::TagAttrNameBefore),
FromSet('&') => go!(self: consume_char_ref '\''),
FromSet(c) => go!(self: push_value c),
NotFromSet(ref b) => go!(self: append_value b),
@@ -973,10 +984,18 @@ impl<Sink: TokenSink> XmlTokenizer<Sink> {
},
//§ tag-attribute-value-double-quoted-state
XmlState::TagAttrValue(Unquoted) => loop {
- match pop_except_from!(self, input, small_char_set!('\n' '\t' ' ' '&' '>')) {
- FromSet('\t') | FromSet('\n') | FromSet(' ') => go!(self: to TagAttrNameBefore),
+ let Some(popped_element) =
+ self.pop_except_from(input, small_char_set!('\n' '\t' ' ' '&' '>'))
+ else {
+ return ProcessResult::Done;
+ };
+
+ match popped_element {
+ FromSet('\t') | FromSet('\n') | FromSet(' ') => {
+ go!(self: to XmlState::TagAttrNameBefore)
+ },
FromSet('&') => go!(self: consume_char_ref),
- FromSet('>') => go!(self: emit_tag Data),
+ FromSet('>') => go!(self: emit_tag XmlState::Data),
FromSet(c) => go!(self: push_value c),
NotFromSet(ref b) => go!(self: append_value b),
}
@@ -985,93 +1004,101 @@ impl<Sink: TokenSink> XmlTokenizer<Sink> {
//§ doctype-state
XmlState::Doctype => loop {
match get_char!(self, input) {
- '\t' | '\n' | '\x0C' | ' ' => go!(self: to BeforeDoctypeName),
- _ => go!(self: error; reconsume BeforeDoctypeName),
+ '\t' | '\n' | '\x0C' | ' ' => go!(self: to XmlState::BeforeDoctypeName),
+ _ => go!(self: error; reconsume XmlState::BeforeDoctypeName),
}
},
//§ before-doctype-name-state
XmlState::BeforeDoctypeName => loop {
match get_char!(self, input) {
'\t' | '\n' | '\x0C' | ' ' => (),
- '>' => go!(self: error; emit_doctype; to Data),
+ '>' => go!(self: error; emit_doctype; to XmlState::Data),
c => go!(self: create_doctype; push_doctype_name (c.to_ascii_lowercase());
- to DoctypeName),
+ to XmlState::DoctypeName),
}
},
//§ doctype-name-state
XmlState::DoctypeName => loop {
match get_char!(self, input) {
- '\t' | '\n' | '\x0C' | ' ' => go!(self: to AfterDoctypeName),
- '>' => go!(self: emit_doctype; to Data),
+ '\t' | '\n' | '\x0C' | ' ' => go!(self: to XmlState::AfterDoctypeName),
+ '>' => go!(self: emit_doctype; to XmlState::Data),
c => go!(self: push_doctype_name (c.to_ascii_lowercase());
- to DoctypeName),
+ to XmlState::DoctypeName),
}
},
//§ after-doctype-name-state
XmlState::AfterDoctypeName => loop {
if eat!(self, input, "public") {
- go!(self: to AfterDoctypeKeyword Public);
+ go!(self: to XmlState::AfterDoctypeKeyword(Public));
} else if eat!(self, input, "system") {
- go!(self: to AfterDoctypeKeyword System);
+ go!(self: to XmlState::AfterDoctypeKeyword(System));
} else {
match get_char!(self, input) {
'\t' | '\n' | '\x0C' | ' ' => (),
- '>' => go!(self: emit_doctype; to Data),
- _ => go!(self: error; to BogusDoctype),
+ '>' => go!(self: emit_doctype; to XmlState::Data),
+ _ => go!(self: error; to XmlState::BogusDoctype),
}
}
},
//§ after-doctype-public-keyword-state
XmlState::AfterDoctypeKeyword(Public) => loop {
match get_char!(self, input) {
- '\t' | '\n' | '\x0C' | ' ' => go!(self: to BeforeDoctypeIdentifier Public),
+ '\t' | '\n' | '\x0C' | ' ' => {
+ go!(self: to XmlState::BeforeDoctypeIdentifier(Public))
+ },
'"' => {
- go!(self: error; clear_doctype_id Public; to DoctypeIdentifierDoubleQuoted Public)
+ go!(self: error; clear_doctype_id Public; to XmlState::DoctypeIdentifierDoubleQuoted(Public))
},
'\'' => {
- go!(self: error; clear_doctype_id Public; to DoctypeIdentifierSingleQuoted Public)
+ go!(self: error; clear_doctype_id Public; to XmlState::DoctypeIdentifierSingleQuoted(Public))
},
- '>' => go!(self: error; emit_doctype; to Data),
- _ => go!(self: error; to BogusDoctype),
+ '>' => go!(self: error; emit_doctype; to XmlState::Data),
+ _ => go!(self: error; to XmlState::BogusDoctype),
}
},
//§ after-doctype-system-keyword-state
XmlState::AfterDoctypeKeyword(System) => loop {
match get_char!(self, input) {
- '\t' | '\n' | '\x0C' | ' ' => go!(self: to BeforeDoctypeIdentifier System),
+ '\t' | '\n' | '\x0C' | ' ' => {
+ go!(self: to XmlState::BeforeDoctypeIdentifier(System))
+ },
'"' => {
- go!(self: error; clear_doctype_id System; to DoctypeIdentifierDoubleQuoted System)
+ go!(self: error; clear_doctype_id System; to XmlState::DoctypeIdentifierDoubleQuoted(System))
},
'\'' => {
- go!(self: error; clear_doctype_id System; to DoctypeIdentifierSingleQuoted System)
+ go!(self: error; clear_doctype_id System; to XmlState::DoctypeIdentifierSingleQuoted(System))
},
- '>' => go!(self: error; emit_doctype; to Data),
- _ => go!(self: error; to BogusDoctype),
+ '>' => go!(self: error; emit_doctype; to XmlState::Data),
+ _ => go!(self: error; to XmlState::BogusDoctype),
}
},
//§ before_doctype_public_identifier_state before_doctype_system_identifier_state
XmlState::BeforeDoctypeIdentifier(kind) => loop {
match get_char!(self, input) {
'\t' | '\n' | '\x0C' | ' ' => (),
- '"' => go!(self: clear_doctype_id kind; to DoctypeIdentifierDoubleQuoted kind),
- '\'' => go!(self: clear_doctype_id kind; to DoctypeIdentifierSingleQuoted kind),
- '>' => go!(self: error; emit_doctype; to Data),
- _ => go!(self: error; to BogusDoctype),
+ '"' => {
+ go!(self: clear_doctype_id kind; to XmlState::DoctypeIdentifierDoubleQuoted(kind))
+ },
+ '\'' => {
+ go!(self: clear_doctype_id kind; to XmlState::DoctypeIdentifierSingleQuoted(kind))
+ },
+ '>' => go!(self: error; emit_doctype; to XmlState::Data),
+ _ => go!(self: error; to XmlState::BogusDoctype),
}
},
//§ doctype_public_identifier_double_quoted_state doctype_system_identifier_double_quoted_state
XmlState::DoctypeIdentifierDoubleQuoted(kind) => loop {
match get_char!(self, input) {
- '"' => go!(self: to AfterDoctypeIdentifier kind),
- '>' => go!(self: error; emit_doctype; to Data),
+ '"' => go!(self: to XmlState::AfterDoctypeIdentifier(kind)),
+ '>' => go!(self: error; emit_doctype; to XmlState::Data),
c => go!(self: push_doctype_id kind c),
}
},
//§ doctype_public_identifier_single_quoted_state doctype_system_identifier_single_quoted_state
XmlState::DoctypeIdentifierSingleQuoted(kind) => loop {
match get_char!(self, input) {
- '\'' => go!(self: to AfterDoctypeIdentifier kind),
- '>' => go!(self: error; emit_doctype; to Data),
+ '\'' => go!(self: to XmlState::AfterDoctypeIdentifier(kind)),
+ '>' => go!(self: error; emit_doctype; to XmlState::Data),
c => go!(self: push_doctype_id kind c),
}
},
@@ -1079,40 +1106,40 @@ impl<Sink: TokenSink> XmlTokenizer<Sink> {
XmlState::AfterDoctypeIdentifier(Public) => loop {
match get_char!(self, input) {
'\t' | '\n' | '\x0C' | ' ' => {
- go!(self: to BetweenDoctypePublicAndSystemIdentifiers)
+ go!(self: to XmlState::BetweenDoctypePublicAndSystemIdentifiers)
},
'\'' => {
- go!(self: error; clear_doctype_id System; to DoctypeIdentifierSingleQuoted(System))
+ go!(self: error; clear_doctype_id System; to XmlState::DoctypeIdentifierSingleQuoted(System))
},
'"' => {
- go!(self: error; clear_doctype_id System; to DoctypeIdentifierDoubleQuoted(System))
+ go!(self: error; clear_doctype_id System; to XmlState::DoctypeIdentifierDoubleQuoted(System))
},
- '>' => go!(self: emit_doctype; to Data),
- _ => go!(self: error; to BogusDoctype),
+ '>' => go!(self: emit_doctype; to XmlState::Data),
+ _ => go!(self: error; to XmlState::BogusDoctype),
}
},
//§ doctype_system_identifier_single_quoted_state
XmlState::AfterDoctypeIdentifier(System) => loop {
match get_char!(self, input) {
'\t' | '\n' | '\x0C' | ' ' => (),
- '>' => go!(self: emit_doctype; to Data),
- _ => go!(self: error; to BogusDoctype),
+ '>' => go!(self: emit_doctype; to XmlState::Data),
+ _ => go!(self: error; to XmlState::BogusDoctype),
}
},
//§ between_doctype_public_and_system_identifier_state
XmlState::BetweenDoctypePublicAndSystemIdentifiers => loop {
match get_char!(self, input) {
'\t' | '\n' | '\x0C' | ' ' => (),
- '>' => go!(self: emit_doctype; to Data),
- '\'' => go!(self: to DoctypeIdentifierSingleQuoted System),
- '"' => go!(self: to DoctypeIdentifierDoubleQuoted System),
- _ => go!(self: error; to BogusDoctype),
+ '>' => go!(self: emit_doctype; to XmlState::Data),
+ '\'' => go!(self: to XmlState::DoctypeIdentifierSingleQuoted(System)),
+ '"' => go!(self: to XmlState::DoctypeIdentifierDoubleQuoted(System)),
+ _ => go!(self: error; to XmlState::BogusDoctype),
}
},
//§ bogus_doctype_state
XmlState::BogusDoctype => loop {
if get_char!(self, input) == '>' {
- go!(self: emit_doctype; to Data);
+ go!(self: emit_doctype; to XmlState::Data);
}
},
}
@@ -1162,12 +1189,9 @@ impl<Sink: TokenSink> XmlTokenizer<Sink> {
.iter()
.map(|(s, t)| (*s, *t))
.collect();
- results.sort_by(|&(_, x), &(_, y)| y.cmp(&x));
+ results.sort_by_key(|&(_, x)| Reverse(x));
- let total: u64 = results
- .iter()
- .map(|&(_, t)| t)
- .fold(0, ::std::ops::Add::add);
+ let total: u64 = results.iter().map(|&(_, t)| t).sum();
debug!("\nTokenizer profile, in nanoseconds");
debug!(
"\n{:12} total in token sink",
@@ -1186,33 +1210,35 @@ impl<Sink: TokenSink> XmlTokenizer<Sink> {
match self.state.get() {
XmlState::Data => go!(self: eof),
XmlState::CommentStart | XmlState::CommentLessThan | XmlState::CommentLessThanBang => {
- go!(self: reconsume Comment)
+ go!(self: reconsume XmlState::Comment)
},
- XmlState::CommentLessThanBangDash => go!(self: reconsume CommentEndDash),
- XmlState::CommentLessThanBangDashDash => go!(self: reconsume CommentEnd),
+ XmlState::CommentLessThanBangDash => go!(self: reconsume XmlState::CommentEndDash),
+ XmlState::CommentLessThanBangDashDash => go!(self: reconsume XmlState::CommentEnd),
XmlState::CommentStartDash
| XmlState::Comment
| XmlState::CommentEndDash
| XmlState::CommentEnd
| XmlState::CommentEndBang => go!(self: error_eof; emit_comment; eof),
- XmlState::TagState => go!(self: error_eof; emit '<'; to Data),
- XmlState::EndTagState => go!(self: error_eof; emit '<'; emit '/'; to Data),
- XmlState::TagEmpty => go!(self: error_eof; to TagAttrNameBefore),
- XmlState::Cdata => go!(self: error_eof; emit_incomplete_cdata 0; to Data),
+ XmlState::TagState => go!(self: error_eof; emit '<'; to XmlState::Data),
+ XmlState::EndTagState => go!(self: error_eof; emit '<'; emit '/'; to XmlState::Data),
+ XmlState::TagEmpty => go!(self: error_eof; to XmlState::TagAttrNameBefore),
+ XmlState::Cdata => go!(self: error_eof; emit_incomplete_cdata 0; to XmlState::Data),
XmlState::CdataBracket => {
- go!(self: error_eof; emit_incomplete_cdata 1; to Data)
+ go!(self: error_eof; emit_incomplete_cdata 1; to XmlState::Data)
},
- XmlState::CdataEnd => go!(self: error_eof; emit_incomplete_cdata 2; to Data),
- XmlState::Pi => go!(self: error_eof; to BogusComment),
- XmlState::PiTargetAfter | XmlState::PiAfter => go!(self: reconsume PiData),
- XmlState::MarkupDecl => go!(self: error_eof; to BogusComment),
+ XmlState::CdataEnd => go!(self: error_eof; emit_incomplete_cdata 2; to XmlState::Data),
+ XmlState::Pi => go!(self: error_eof; to XmlState::BogusComment),
+ XmlState::PiTargetAfter => go!(self: reconsume XmlState::PiData),
+ // The '?' we consumed to get here never became a '?>', so keep it.
+ XmlState::PiAfter => go!(self: push_pi_data '?'; reconsume XmlState::PiData),
+ XmlState::MarkupDecl => go!(self: error_eof; to XmlState::BogusComment),
XmlState::TagName
| XmlState::TagAttrNameBefore
| XmlState::EndTagName
| XmlState::TagAttrNameAfter
| XmlState::EndTagNameAfter
| XmlState::TagAttrValueBefore
- | XmlState::TagAttrValue(_) => go!(self: error_eof; emit_tag Data),
+ | XmlState::TagAttrValue(_) => go!(self: error_eof; emit_tag XmlState::Data),
XmlState::PiData | XmlState::PiTarget => go!(self: error_eof; emit_pi Data),
XmlState::TagAttrName => go!(self: error_eof; emit_start_tag Data),
XmlState::BeforeDoctypeName
@@ -1225,10 +1251,10 @@ impl<Sink: TokenSink> XmlTokenizer<Sink> {
| XmlState::DoctypeIdentifierSingleQuoted(_)
| XmlState::DoctypeIdentifierDoubleQuoted(_)
| XmlState::BetweenDoctypePublicAndSystemIdentifiers => {
- go!(self: error_eof; emit_doctype; to Data)
+ go!(self: error_eof; emit_doctype; to XmlState::Data)
},
- XmlState::BogusDoctype => go!(self: emit_doctype; to Data),
- XmlState::BogusComment => go!(self: emit_comment; to Data),
+ XmlState::BogusDoctype => go!(self: emit_doctype; to XmlState::Data),
+ XmlState::BogusComment => go!(self: emit_comment; to XmlState::Data),
}
}
@@ -1281,27 +1307,26 @@ impl<Sink: TokenSink> XmlTokenizer<Sink> {
return;
}
- // Check for a duplicate attribute.
+ let qname = process_qname(replace(
+ &mut self.current_attr_name.borrow_mut(),
+ StrTendril::new(),
+ ));
+
+ // Check for a duplicate attribute. Two attributes are the same only if
+ // both their prefix and their local name match, so xml:lang and lang
+ // are distinct names and may sit on the same element.
// FIXME: the spec says we should error as soon as the name is finished.
// FIXME: linear time search, do we care?
- let dup = {
- let current_attr_name = self.current_attr_name.borrow();
- let name = &current_attr_name[..];
- self.current_tag_attrs
- .borrow()
- .iter()
- .any(|a| &*a.name.local == name)
- };
+ let dup = self
+ .current_tag_attrs
+ .borrow()
+ .iter()
+ .any(|a| a.name.prefix == qname.prefix && a.name.local == qname.local);
if dup {
self.emit_error(Borrowed("Duplicate attribute"));
- self.current_attr_name.borrow_mut().clear();
self.current_attr_value.borrow_mut().clear();
} else {
- let qname = process_qname(replace(
- &mut self.current_attr_name.borrow_mut(),
- StrTendril::new(),
- ));
let attr = Attribute {
name: qname.clone(),
value: replace(&mut self.current_attr_value.borrow_mut(), StrTendril::new()),
@@ -1324,9 +1349,152 @@ impl<Sink: TokenSink> XmlTokenizer<Sink> {
#[cfg(test)]
mod test {
- use super::process_qname;
- use crate::tendril::SliceExt;
+ use super::{process_qname, ProcessResult, Token, TokenSink, XmlTokenizer};
+ use crate::tendril::{SliceExt, StrTendril};
use crate::{LocalName, Prefix};
+ use markup5ever::buffer_queue::BufferQueue;
+ use std::cell::RefCell;
+
+ struct PiCollector {
+ pis: RefCell<Vec<(String, String)>>,
+ }
+
+ impl TokenSink for PiCollector {
+ type Handle = ();
+
+ fn process_token(&self, token: Token) -> ProcessResult<()> {
+ if let Token::ProcessingInstruction(pi) = token {
+ self.pis
+ .borrow_mut()
+ .push((pi.target.to_string(), pi.data.to_string()));
+ }
+ ProcessResult::Continue
+ }
+ }
+
+ struct ErrorCollector {
+ errors: RefCell<Vec<String>>,
+ }
+
+ impl TokenSink for ErrorCollector {
+ type Handle = ();
+
+ fn process_token(&self, token: Token) -> ProcessResult<()> {
+ if let Token::ParseError(error) = token {
+ self.errors.borrow_mut().push(error.to_string());
+ }
+ ProcessResult::Continue
+ }
+ }
+
+ fn tokenize_pis(input: &str) -> Vec<(String, String)> {
+ let sink = PiCollector {
+ pis: RefCell::new(Vec::new()),
+ };
+ let queue = BufferQueue::default();
+ queue.push_back(StrTendril::from(input));
+ let tokenizer = XmlTokenizer::new(sink, Default::default());
+ let _ = tokenizer.feed(&queue);
+ tokenizer.end();
+ tokenizer.sink.pis.into_inner()
+ }
+
+ fn tokenize_errors(input: &str) -> Vec<String> {
+ let sink = ErrorCollector {
+ errors: RefCell::new(Vec::new()),
+ };
+ let queue = BufferQueue::default();
+ queue.push_back(StrTendril::from(input));
+ let tokenizer = XmlTokenizer::new(sink, Default::default());
+ let _ = tokenizer.feed(&queue);
+ tokenizer.end();
+ tokenizer.sink.errors.into_inner()
+ }
+
+ #[test]
+ fn pi_data_keeps_question_marks() {
+ assert_eq!(
+ tokenize_pis(r#"<?xml-stylesheet href="style.xsl?v=2"?>"#),
+ vec![(
+ "xml-stylesheet".to_owned(),
+ r#"href="style.xsl?v=2""#.to_owned()
+ )]
+ );
+
+ assert_eq!(
+ tokenize_pis("<?target a?b?c?>"),
+ vec![("target".to_owned(), "a?b?c".to_owned())]
+ );
+
+ // A run of question marks only ends the instruction when one of them
+ // is followed by '>'.
+ assert_eq!(
+ tokenize_pis("<?target a???>"),
+ vec![("target".to_owned(), "a??".to_owned())]
+ );
+ }
+
+ #[test]
+ fn pi_only_ends_on_question_mark_gt() {
+ // The '>' here is data, because the character before it is not a '?'.
+ assert_eq!(
+ tokenize_pis("<?target a?b>c?>"),
+ vec![("target".to_owned(), "a?b>c".to_owned())]
+ );
+ }
+
+ #[test]
+ fn pi_without_data_is_empty() {
+ assert_eq!(
+ tokenize_pis("<?target?>"),
+ vec![("target".to_owned(), String::new())]
+ );
+
+ assert_eq!(
+ tokenize_pis("<?target ?>"),
+ vec![("target".to_owned(), String::new())]
+ );
+ }
+
+ #[test]
+ fn unterminated_pi_keeps_trailing_question_mark() {
+ assert_eq!(
+ tokenize_pis("<?target a?"),
+ vec![("target".to_owned(), "a?".to_owned())]
+ );
+ }
+
+ #[test]
+ fn qualified_and_unqualified_names_are_distinct() {
+ // The xml prefix is bound to http://www.w3.org/XML/1998/namespace by
+ // definition, so xml:lang and lang have different expanded names and
+ // both orderings are fine. This is the second of the two legal cases
+ // in https://www.w3.org/TR/REC-xml-names/#uniqAttrs
+ assert!(tokenize_errors(r#"<root xml:lang="en" lang="en"/>"#).is_empty());
+ assert!(tokenize_errors(r#"<root lang="en" xml:lang="en"/>"#).is_empty());
+ }
+
+ #[test]
+ fn different_prefixes_are_left_to_the_tree_builder() {
+ // Whether these two are duplicates depends on what a and b are bound
+ // to, and the tokenizer has no bindings, so it says nothing either way.
+ // XmlTreeBuilder::bind_attr_qname resolves the prefixes and compares
+ // expanded names, which is where a real duplicate gets caught.
+ assert!(tokenize_errors(r#"<root a:name="1" b:name="2"/>"#).is_empty());
+ }
+
+ #[test]
+ fn real_duplicates_are_still_reported() {
+ assert_eq!(
+ tokenize_errors(r#"<root lang="en" lang="fr"/>"#),
+ vec!["Duplicate attribute".to_owned()]
+ );
+
+ assert_eq!(
+ tokenize_errors(r#"<root xml:lang="en" xml:lang="fr"/>"#),
+ vec!["Duplicate attribute".to_owned()]
+ );
+ }
#[test]
fn simple_namespace() {
diff --git a/vendor/xml5ever-0.39.0/src/tokenizer/qname.rs b/vendor/xml5ever-0.40.0/src/tokenizer/qname.rs
similarity index 100%
rename from vendor/xml5ever-0.39.0/src/tokenizer/qname.rs
rename to vendor/xml5ever-0.40.0/src/tokenizer/qname.rs
diff --git a/vendor/xml5ever-0.39.0/src/tokenizer/states.rs b/vendor/xml5ever-0.40.0/src/tokenizer/states.rs
similarity index 100%
rename from vendor/xml5ever-0.39.0/src/tokenizer/states.rs
rename to vendor/xml5ever-0.40.0/src/tokenizer/states.rs
diff --git a/vendor/xml5ever-0.39.0/src/tree_builder/mod.rs b/vendor/xml5ever-0.40.0/src/tree_builder/mod.rs
similarity index 99%
rename from vendor/xml5ever-0.39.0/src/tree_builder/mod.rs
rename to vendor/xml5ever-0.40.0/src/tree_builder/mod.rs
index 1b1d6af60..9dca11bd4 100644
--- a/vendor/xml5ever-0.39.0/src/tree_builder/mod.rs
+++ b/vendor/xml5ever-0.40.0/src/tree_builder/mod.rs
@@ -583,7 +583,7 @@ where
debug!(
"Close tag: current_node.name {:?} \n Current tag {:?}",
self.sink.elem_name(&self.current_node()),
- &tag.name
+ tag.name
);
if *self.sink.elem_name(&self.current_node()).local_name() != tag.name.local {
diff --git a/vendor/xml5ever-0.39.0/src/tree_builder/types.rs b/vendor/xml5ever-0.40.0/src/tree_builder/types.rs
similarity index 100%
rename from vendor/xml5ever-0.39.0/src/tree_builder/types.rs
rename to vendor/xml5ever-0.40.0/src/tree_builder/types.rs