blitz-pdf 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (370) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +355 -2
  3. package/THIRD_PARTY_NOTICES.md +25 -0
  4. package/assets/icon.svg +4 -0
  5. package/dist/api.d.ts +7 -0
  6. package/dist/api.d.ts.map +1 -0
  7. package/dist/api.js +46 -0
  8. package/dist/api.js.map +1 -0
  9. package/dist/assets.d.ts +7 -0
  10. package/dist/assets.d.ts.map +1 -0
  11. package/dist/assets.js +52 -0
  12. package/dist/assets.js.map +1 -0
  13. package/dist/browser.d.ts +3 -0
  14. package/dist/browser.d.ts.map +1 -0
  15. package/dist/browser.js +3 -0
  16. package/dist/browser.js.map +1 -0
  17. package/dist/node.d.ts +3 -0
  18. package/dist/node.d.ts.map +1 -0
  19. package/dist/node.js +10 -0
  20. package/dist/node.js.map +1 -0
  21. package/dist/options.d.ts +24 -0
  22. package/dist/options.d.ts.map +1 -0
  23. package/dist/options.js +135 -0
  24. package/dist/options.js.map +1 -0
  25. package/dist/types.d.ts +51 -0
  26. package/dist/types.d.ts.map +1 -0
  27. package/dist/types.js +2 -0
  28. package/dist/types.js.map +1 -0
  29. package/examples/bun.ts +8 -0
  30. package/examples/german-invoice/README.md +70 -0
  31. package/examples/german-invoice/data.mjs +83 -0
  32. package/examples/german-invoice/invoice.css +59 -0
  33. package/examples/german-invoice/template.mjs +49 -0
  34. package/examples/german-invoice.mjs +20 -0
  35. package/examples/invoice.html +29 -0
  36. package/examples/node.mjs +8 -0
  37. package/examples/pagination.html +40 -0
  38. package/examples/pagination.mjs +8 -0
  39. package/licenses/DejaVu.txt +187 -0
  40. package/licenses/RUST_DEPENDENCIES.txt +11577 -0
  41. package/package.json +89 -4
  42. package/src/api.ts +44 -0
  43. package/src/assets.ts +43 -0
  44. package/src/browser.ts +6 -0
  45. package/src/node.ts +12 -0
  46. package/src/options.ts +101 -0
  47. package/src/types.ts +49 -0
  48. package/vendor/README.md +17 -0
  49. package/vendor/stylo/.cargo-ok +1 -0
  50. package/vendor/stylo/.cargo_vcs_info.json +6 -0
  51. package/vendor/stylo/Cargo.lock +1485 -0
  52. package/vendor/stylo/Cargo.toml +274 -0
  53. package/vendor/stylo/LICENSE +373 -0
  54. package/vendor/stylo/README.md +6 -0
  55. package/vendor/stylo/applicable_declarations.rs +328 -0
  56. package/vendor/stylo/author_styles.rs +79 -0
  57. package/vendor/stylo/bezier.rs +176 -0
  58. package/vendor/stylo/bloom.rs +414 -0
  59. package/vendor/stylo/build.rs +91 -0
  60. package/vendor/stylo/build_gecko.rs +393 -0
  61. package/vendor/stylo/color/color_function.rs +601 -0
  62. package/vendor/stylo/color/component.rs +207 -0
  63. package/vendor/stylo/color/convert.rs +935 -0
  64. package/vendor/stylo/color/gamut/raytrace.rs +265 -0
  65. package/vendor/stylo/color/gamut.rs +227 -0
  66. package/vendor/stylo/color/mix.rs +645 -0
  67. package/vendor/stylo/color/mod.rs +750 -0
  68. package/vendor/stylo/color/parsing.rs +770 -0
  69. package/vendor/stylo/color/to_css.rs +297 -0
  70. package/vendor/stylo/context.rs +716 -0
  71. package/vendor/stylo/counter_style/mod.rs +754 -0
  72. package/vendor/stylo/counter_style/predefined.rs +61 -0
  73. package/vendor/stylo/counter_style/update_predefined.py +35 -0
  74. package/vendor/stylo/custom_properties.rs +2023 -0
  75. package/vendor/stylo/custom_properties_map.rs +220 -0
  76. package/vendor/stylo/data.rs +693 -0
  77. package/vendor/stylo/device/gecko.rs +486 -0
  78. package/vendor/stylo/device/mod.rs +304 -0
  79. package/vendor/stylo/device/servo.rs +507 -0
  80. package/vendor/stylo/dom.rs +1164 -0
  81. package/vendor/stylo/dom_apis.rs +937 -0
  82. package/vendor/stylo/driver.rs +172 -0
  83. package/vendor/stylo/error_reporting.rs +484 -0
  84. package/vendor/stylo/font_face.rs +558 -0
  85. package/vendor/stylo/font_metrics.rs +124 -0
  86. package/vendor/stylo/gecko/anon_boxes.toml +113 -0
  87. package/vendor/stylo/gecko/arc_types.rs +211 -0
  88. package/vendor/stylo/gecko/conversions.rs +59 -0
  89. package/vendor/stylo/gecko/data.rs +222 -0
  90. package/vendor/stylo/gecko/media_features.rs +971 -0
  91. package/vendor/stylo/gecko/mod.rs +20 -0
  92. package/vendor/stylo/gecko/non_ts_pseudo_class_list.rs +119 -0
  93. package/vendor/stylo/gecko/pseudo_element.rs +640 -0
  94. package/vendor/stylo/gecko/pseudo_element_definition.mako.rs +298 -0
  95. package/vendor/stylo/gecko/pseudo_elements.py +137 -0
  96. package/vendor/stylo/gecko/pseudo_elements.toml +197 -0
  97. package/vendor/stylo/gecko/regen_pseudo_elements.py +33 -0
  98. package/vendor/stylo/gecko/restyle_damage.rs +127 -0
  99. package/vendor/stylo/gecko/selector_parser.rs +627 -0
  100. package/vendor/stylo/gecko/snapshot.rs +202 -0
  101. package/vendor/stylo/gecko/snapshot_helpers.rs +334 -0
  102. package/vendor/stylo/gecko/traversal.rs +52 -0
  103. package/vendor/stylo/gecko/wrapper.rs +2258 -0
  104. package/vendor/stylo/gecko_bindings/mod.rs +34 -0
  105. package/vendor/stylo/gecko_bindings/sugar/mod.rs +12 -0
  106. package/vendor/stylo/gecko_bindings/sugar/ns_com_ptr.rs +15 -0
  107. package/vendor/stylo/gecko_bindings/sugar/ns_compatibility.rs +19 -0
  108. package/vendor/stylo/gecko_bindings/sugar/ns_style_auto_array.rs +111 -0
  109. package/vendor/stylo/gecko_bindings/sugar/origin_flags.rs +31 -0
  110. package/vendor/stylo/gecko_bindings/sugar/ownership.rs +70 -0
  111. package/vendor/stylo/gecko_bindings/sugar/refptr.rs +299 -0
  112. package/vendor/stylo/gecko_string_cache/mod.rs +543 -0
  113. package/vendor/stylo/gecko_string_cache/namespace.rs +106 -0
  114. package/vendor/stylo/global_style_data.rs +224 -0
  115. package/vendor/stylo/invalidation/element/document_state.rs +156 -0
  116. package/vendor/stylo/invalidation/element/element_wrapper.rs +432 -0
  117. package/vendor/stylo/invalidation/element/invalidation_map.rs +1631 -0
  118. package/vendor/stylo/invalidation/element/invalidator.rs +1470 -0
  119. package/vendor/stylo/invalidation/element/mod.rs +13 -0
  120. package/vendor/stylo/invalidation/element/relative_selector.rs +1399 -0
  121. package/vendor/stylo/invalidation/element/restyle_hints.rs +226 -0
  122. package/vendor/stylo/invalidation/element/state_and_attributes.rs +756 -0
  123. package/vendor/stylo/invalidation/media_queries.rs +144 -0
  124. package/vendor/stylo/invalidation/mod.rs +10 -0
  125. package/vendor/stylo/invalidation/stylesheets.rs +745 -0
  126. package/vendor/stylo/invalidation/viewport_units.rs +71 -0
  127. package/vendor/stylo/lib.rs +336 -0
  128. package/vendor/stylo/logical_geometry.rs +1684 -0
  129. package/vendor/stylo/macros.rs +70 -0
  130. package/vendor/stylo/matching.rs +1226 -0
  131. package/vendor/stylo/media_queries/media_list.rs +168 -0
  132. package/vendor/stylo/media_queries/media_query.rs +190 -0
  133. package/vendor/stylo/media_queries/mod.rs +13 -0
  134. package/vendor/stylo/parallel.rs +205 -0
  135. package/vendor/stylo/parser.rs +276 -0
  136. package/vendor/stylo/piecewise_linear.rs +282 -0
  137. package/vendor/stylo/prefs.rs +33 -0
  138. package/vendor/stylo/properties/build.py +119 -0
  139. package/vendor/stylo/properties/cascade.rs +2704 -0
  140. package/vendor/stylo/properties/computed_value_flags.rs +206 -0
  141. package/vendor/stylo/properties/counted_unknown_properties.py +104 -0
  142. package/vendor/stylo/properties/counter_style_descriptors.toml +45 -0
  143. package/vendor/stylo/properties/data.py +1375 -0
  144. package/vendor/stylo/properties/declaration_block.rs +1788 -0
  145. package/vendor/stylo/properties/font_face_descriptors.toml +50 -0
  146. package/vendor/stylo/properties/gecko.mako.rs +1555 -0
  147. package/vendor/stylo/properties/helpers/animated_properties.mako.rs +800 -0
  148. package/vendor/stylo/properties/helpers.mako.rs +812 -0
  149. package/vendor/stylo/properties/longhands.toml +4305 -0
  150. package/vendor/stylo/properties/mod.rs +1857 -0
  151. package/vendor/stylo/properties/properties.html.mako +31 -0
  152. package/vendor/stylo/properties/properties.mako.rs +3103 -0
  153. package/vendor/stylo/properties/property_descriptors.toml +18 -0
  154. package/vendor/stylo/properties/shorthands.rs +4241 -0
  155. package/vendor/stylo/properties/shorthands.toml +575 -0
  156. package/vendor/stylo/properties/vendored_python/mako-1.3.10-py3-none-any.whl +0 -0
  157. package/vendor/stylo/properties/vendored_python/markupsafe/LICENSE.txt +28 -0
  158. package/vendor/stylo/properties/vendored_python/markupsafe/__init__.py +384 -0
  159. package/vendor/stylo/properties/vendored_python/toml-0.10.2-py2.py3-none-any.whl +0 -0
  160. package/vendor/stylo/properties/view_transition_descriptors.toml +11 -0
  161. package/vendor/stylo/properties_and_values/mod.rs +12 -0
  162. package/vendor/stylo/properties_and_values/registry.rs +65 -0
  163. package/vendor/stylo/properties_and_values/rule.rs +331 -0
  164. package/vendor/stylo/properties_and_values/syntax/ascii.rs +60 -0
  165. package/vendor/stylo/properties_and_values/syntax/data_type.rs +146 -0
  166. package/vendor/stylo/properties_and_values/syntax/mod.rs +437 -0
  167. package/vendor/stylo/properties_and_values/value.rs +758 -0
  168. package/vendor/stylo/queries/condition.rs +996 -0
  169. package/vendor/stylo/queries/feature.rs +199 -0
  170. package/vendor/stylo/queries/feature_expression.rs +1170 -0
  171. package/vendor/stylo/queries/mod.rs +19 -0
  172. package/vendor/stylo/queries/values.rs +46 -0
  173. package/vendor/stylo/rule_cache.rs +267 -0
  174. package/vendor/stylo/rule_collector.rs +554 -0
  175. package/vendor/stylo/rule_tree/core.rs +787 -0
  176. package/vendor/stylo/rule_tree/level.rs +396 -0
  177. package/vendor/stylo/rule_tree/map.rs +201 -0
  178. package/vendor/stylo/rule_tree/mod.rs +427 -0
  179. package/vendor/stylo/rule_tree/source.rs +80 -0
  180. package/vendor/stylo/rule_tree/unsafe_box.rs +78 -0
  181. package/vendor/stylo/scoped_tls.rs +80 -0
  182. package/vendor/stylo/selector_map.rs +1050 -0
  183. package/vendor/stylo/selector_parser.rs +305 -0
  184. package/vendor/stylo/servo/animation.rs +1922 -0
  185. package/vendor/stylo/servo/attr.rs +714 -0
  186. package/vendor/stylo/servo/encoding_support.rs +81 -0
  187. package/vendor/stylo/servo/media_features.rs +254 -0
  188. package/vendor/stylo/servo/mod.rs +16 -0
  189. package/vendor/stylo/servo/restyle_damage.rs +215 -0
  190. package/vendor/stylo/servo/selector_parser.rs +1036 -0
  191. package/vendor/stylo/servo/shadow_parts.rs +207 -0
  192. package/vendor/stylo/shared_lock.rs +271 -0
  193. package/vendor/stylo/sharing/checks.rs +281 -0
  194. package/vendor/stylo/sharing/mod.rs +1000 -0
  195. package/vendor/stylo/simple_buckets_map.rs +52 -0
  196. package/vendor/stylo/str.rs +168 -0
  197. package/vendor/stylo/style_adjuster.rs +1086 -0
  198. package/vendor/stylo/style_resolver.rs +658 -0
  199. package/vendor/stylo/stylesheet_set.rs +658 -0
  200. package/vendor/stylo/stylesheets/appearance_base_rule.rs +51 -0
  201. package/vendor/stylo/stylesheets/container_rule.rs +769 -0
  202. package/vendor/stylo/stylesheets/counter_style_rule.rs +7 -0
  203. package/vendor/stylo/stylesheets/document_rule.rs +272 -0
  204. package/vendor/stylo/stylesheets/font_face_rule.rs +7 -0
  205. package/vendor/stylo/stylesheets/font_feature_values_rule.rs +481 -0
  206. package/vendor/stylo/stylesheets/font_palette_values_rule.rs +304 -0
  207. package/vendor/stylo/stylesheets/import_rule.rs +259 -0
  208. package/vendor/stylo/stylesheets/keyframes_rule.rs +733 -0
  209. package/vendor/stylo/stylesheets/layer_rule.rs +221 -0
  210. package/vendor/stylo/stylesheets/loader.rs +29 -0
  211. package/vendor/stylo/stylesheets/margin_rule.rs +190 -0
  212. package/vendor/stylo/stylesheets/media_rule.rs +191 -0
  213. package/vendor/stylo/stylesheets/mod.rs +918 -0
  214. package/vendor/stylo/stylesheets/namespace_rule.rs +43 -0
  215. package/vendor/stylo/stylesheets/nested_declarations_rule.rs +51 -0
  216. package/vendor/stylo/stylesheets/origin.rs +249 -0
  217. package/vendor/stylo/stylesheets/page_rule.rs +354 -0
  218. package/vendor/stylo/stylesheets/position_try_rule.rs +68 -0
  219. package/vendor/stylo/stylesheets/property_rule.rs +5 -0
  220. package/vendor/stylo/stylesheets/rule_list.rs +167 -0
  221. package/vendor/stylo/stylesheets/rule_parser.rs +1189 -0
  222. package/vendor/stylo/stylesheets/rules_iterator.rs +397 -0
  223. package/vendor/stylo/stylesheets/scope_rule.rs +511 -0
  224. package/vendor/stylo/stylesheets/starting_style_rule.rs +54 -0
  225. package/vendor/stylo/stylesheets/style_rule.rs +80 -0
  226. package/vendor/stylo/stylesheets/stylesheet.rs +570 -0
  227. package/vendor/stylo/stylesheets/supports_rule.rs +486 -0
  228. package/vendor/stylo/stylesheets/view_transition_rule.rs +81 -0
  229. package/vendor/stylo/stylist.rs +5076 -0
  230. package/vendor/stylo/thread_state.rs +87 -0
  231. package/vendor/stylo/traversal.rs +765 -0
  232. package/vendor/stylo/traversal_flags.rs +68 -0
  233. package/vendor/stylo/typed_om/mod.rs +981 -0
  234. package/vendor/stylo/typed_om/numeric.rs +128 -0
  235. package/vendor/stylo/typed_om/numeric_declaration.rs +93 -0
  236. package/vendor/stylo/typed_om/numeric_type.rs +640 -0
  237. package/vendor/stylo/typed_om/sum_value.rs +426 -0
  238. package/vendor/stylo/url/gecko.rs +367 -0
  239. package/vendor/stylo/url/mod.rs +71 -0
  240. package/vendor/stylo/url/servo.rs +239 -0
  241. package/vendor/stylo/use_counters/mod.rs +137 -0
  242. package/vendor/stylo/values/animated/color.rs +103 -0
  243. package/vendor/stylo/values/animated/effects.rs +26 -0
  244. package/vendor/stylo/values/animated/font.rs +37 -0
  245. package/vendor/stylo/values/animated/grid.rs +161 -0
  246. package/vendor/stylo/values/animated/lists.rs +141 -0
  247. package/vendor/stylo/values/animated/mod.rs +550 -0
  248. package/vendor/stylo/values/animated/svg.rs +46 -0
  249. package/vendor/stylo/values/animated/text.rs +58 -0
  250. package/vendor/stylo/values/animated/transform.rs +1592 -0
  251. package/vendor/stylo/values/computed/align.rs +90 -0
  252. package/vendor/stylo/values/computed/angle.rs +130 -0
  253. package/vendor/stylo/values/computed/animation.rs +124 -0
  254. package/vendor/stylo/values/computed/background.rs +13 -0
  255. package/vendor/stylo/values/computed/basic_shape.rs +267 -0
  256. package/vendor/stylo/values/computed/border.rs +163 -0
  257. package/vendor/stylo/values/computed/box.rs +267 -0
  258. package/vendor/stylo/values/computed/calc.rs +334 -0
  259. package/vendor/stylo/values/computed/color.rs +161 -0
  260. package/vendor/stylo/values/computed/column.rs +11 -0
  261. package/vendor/stylo/values/computed/corner_shape.rs +155 -0
  262. package/vendor/stylo/values/computed/counters.rs +26 -0
  263. package/vendor/stylo/values/computed/easing.rs +109 -0
  264. package/vendor/stylo/values/computed/effects.rs +30 -0
  265. package/vendor/stylo/values/computed/flex.rs +19 -0
  266. package/vendor/stylo/values/computed/font.rs +1517 -0
  267. package/vendor/stylo/values/computed/image.rs +273 -0
  268. package/vendor/stylo/values/computed/length.rs +576 -0
  269. package/vendor/stylo/values/computed/length_percentage.rs +1055 -0
  270. package/vendor/stylo/values/computed/list.rs +16 -0
  271. package/vendor/stylo/values/computed/mod.rs +1141 -0
  272. package/vendor/stylo/values/computed/motion.rs +73 -0
  273. package/vendor/stylo/values/computed/outline.rs +7 -0
  274. package/vendor/stylo/values/computed/page.rs +77 -0
  275. package/vendor/stylo/values/computed/param.rs +9 -0
  276. package/vendor/stylo/values/computed/percentage.rs +143 -0
  277. package/vendor/stylo/values/computed/position.rs +273 -0
  278. package/vendor/stylo/values/computed/ratio.rs +88 -0
  279. package/vendor/stylo/values/computed/rect.rs +19 -0
  280. package/vendor/stylo/values/computed/resolution.rs +76 -0
  281. package/vendor/stylo/values/computed/svg.rs +66 -0
  282. package/vendor/stylo/values/computed/table.rs +7 -0
  283. package/vendor/stylo/values/computed/text.rs +199 -0
  284. package/vendor/stylo/values/computed/time.rs +83 -0
  285. package/vendor/stylo/values/computed/transform.rs +559 -0
  286. package/vendor/stylo/values/computed/tree_counting.rs +30 -0
  287. package/vendor/stylo/values/computed/ui.rs +23 -0
  288. package/vendor/stylo/values/computed/url.rs +12 -0
  289. package/vendor/stylo/values/distance.rs +139 -0
  290. package/vendor/stylo/values/generics/animation.rs +363 -0
  291. package/vendor/stylo/values/generics/background.rs +65 -0
  292. package/vendor/stylo/values/generics/basic_shape.rs +1389 -0
  293. package/vendor/stylo/values/generics/border.rs +303 -0
  294. package/vendor/stylo/values/generics/box.rs +552 -0
  295. package/vendor/stylo/values/generics/calc.rs +2986 -0
  296. package/vendor/stylo/values/generics/color.rs +318 -0
  297. package/vendor/stylo/values/generics/column.rs +44 -0
  298. package/vendor/stylo/values/generics/counters.rs +320 -0
  299. package/vendor/stylo/values/generics/easing.rs +132 -0
  300. package/vendor/stylo/values/generics/effects.rs +131 -0
  301. package/vendor/stylo/values/generics/flex.rs +34 -0
  302. package/vendor/stylo/values/generics/font.rs +376 -0
  303. package/vendor/stylo/values/generics/grid.rs +962 -0
  304. package/vendor/stylo/values/generics/image.rs +653 -0
  305. package/vendor/stylo/values/generics/length.rs +656 -0
  306. package/vendor/stylo/values/generics/mod.rs +303 -0
  307. package/vendor/stylo/values/generics/motion.rs +274 -0
  308. package/vendor/stylo/values/generics/page.rs +167 -0
  309. package/vendor/stylo/values/generics/position.rs +669 -0
  310. package/vendor/stylo/values/generics/ratio.rs +88 -0
  311. package/vendor/stylo/values/generics/rect.rs +147 -0
  312. package/vendor/stylo/values/generics/size.rs +102 -0
  313. package/vendor/stylo/values/generics/svg.rs +226 -0
  314. package/vendor/stylo/values/generics/text.rs +268 -0
  315. package/vendor/stylo/values/generics/transform.rs +1157 -0
  316. package/vendor/stylo/values/generics/ui.rs +147 -0
  317. package/vendor/stylo/values/generics/url.rs +51 -0
  318. package/vendor/stylo/values/mod.rs +820 -0
  319. package/vendor/stylo/values/resolved/animation.rs +33 -0
  320. package/vendor/stylo/values/resolved/color.rs +53 -0
  321. package/vendor/stylo/values/resolved/counters.rs +45 -0
  322. package/vendor/stylo/values/resolved/mod.rs +316 -0
  323. package/vendor/stylo/values/specified/align.rs +711 -0
  324. package/vendor/stylo/values/specified/angle.rs +407 -0
  325. package/vendor/stylo/values/specified/animation.rs +921 -0
  326. package/vendor/stylo/values/specified/background.rs +270 -0
  327. package/vendor/stylo/values/specified/basic_shape.rs +986 -0
  328. package/vendor/stylo/values/specified/border.rs +430 -0
  329. package/vendor/stylo/values/specified/box.rs +2231 -0
  330. package/vendor/stylo/values/specified/calc.rs +1657 -0
  331. package/vendor/stylo/values/specified/color.rs +1210 -0
  332. package/vendor/stylo/values/specified/column.rs +11 -0
  333. package/vendor/stylo/values/specified/corner_shape.rs +152 -0
  334. package/vendor/stylo/values/specified/counters.rs +242 -0
  335. package/vendor/stylo/values/specified/easing.rs +225 -0
  336. package/vendor/stylo/values/specified/effects.rs +421 -0
  337. package/vendor/stylo/values/specified/flex.rs +42 -0
  338. package/vendor/stylo/values/specified/font.rs +2103 -0
  339. package/vendor/stylo/values/specified/frequency.rs +39 -0
  340. package/vendor/stylo/values/specified/grid.rs +407 -0
  341. package/vendor/stylo/values/specified/image.rs +1385 -0
  342. package/vendor/stylo/values/specified/intersection_observer.rs +80 -0
  343. package/vendor/stylo/values/specified/length.rs +2024 -0
  344. package/vendor/stylo/values/specified/list.rs +190 -0
  345. package/vendor/stylo/values/specified/mod.rs +531 -0
  346. package/vendor/stylo/values/specified/motion.rs +316 -0
  347. package/vendor/stylo/values/specified/number.rs +603 -0
  348. package/vendor/stylo/values/specified/outline.rs +69 -0
  349. package/vendor/stylo/values/specified/page.rs +94 -0
  350. package/vendor/stylo/values/specified/param.rs +121 -0
  351. package/vendor/stylo/values/specified/percentage.rs +364 -0
  352. package/vendor/stylo/values/specified/position.rs +2247 -0
  353. package/vendor/stylo/values/specified/ratio.rs +29 -0
  354. package/vendor/stylo/values/specified/rect.rs +28 -0
  355. package/vendor/stylo/values/specified/resolution.rs +237 -0
  356. package/vendor/stylo/values/specified/source_size_list.rs +135 -0
  357. package/vendor/stylo/values/specified/svg.rs +427 -0
  358. package/vendor/stylo/values/specified/svg_path.rs +1115 -0
  359. package/vendor/stylo/values/specified/table.rs +38 -0
  360. package/vendor/stylo/values/specified/text.rs +1561 -0
  361. package/vendor/stylo/values/specified/time.rs +313 -0
  362. package/vendor/stylo/values/specified/transform.rs +599 -0
  363. package/vendor/stylo/values/specified/tree_counting.rs +32 -0
  364. package/vendor/stylo/values/specified/ui.rs +344 -0
  365. package/vendor/stylo/values/specified/url.rs +12 -0
  366. package/vendor/stylo/values/tagged_numeric.rs +253 -0
  367. package/wasm/blitz_pdf.d.ts +67 -0
  368. package/wasm/blitz_pdf.js +699 -0
  369. package/wasm/blitz_pdf_bg.wasm +0 -0
  370. package/wasm/blitz_pdf_bg.wasm.d.ts +20 -0
@@ -0,0 +1,758 @@
1
+ /* This Source Code Form is subject to the terms of the Mozilla Public
2
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
+
5
+ //! Parsing for registered custom properties.
6
+
7
+ use super::{
8
+ rule::Descriptors as PropertyDescriptors,
9
+ syntax::{
10
+ data_type::DataType, Component as SyntaxComponent, ComponentName, Descriptor, Multiplier,
11
+ },
12
+ };
13
+ use crate::custom_properties::{AttrTaint, ComputedValue as ComputedPropertyValue};
14
+ use crate::derives::*;
15
+ use crate::parser::{Parse, ParserContext};
16
+ use crate::properties;
17
+ use crate::properties::{CSSWideKeyword, CustomDeclarationValue};
18
+ use crate::stylesheets::{CssRuleType, Origin, UrlExtraData};
19
+ use crate::values::{
20
+ animated::{self, Animate, Procedure},
21
+ computed::{self, ToComputedValue},
22
+ specified, CustomIdent,
23
+ };
24
+ use crate::{Namespace, Prefix};
25
+ use cssparser::{BasicParseErrorKind, ParseErrorKind, Parser as CSSParser, TokenSerializationType};
26
+ use rustc_hash::FxHashMap;
27
+ use selectors::matching::QuirksMode;
28
+ use servo_arc::Arc;
29
+ use smallvec::SmallVec;
30
+ use std::fmt::{self, Write};
31
+ use style_traits::{
32
+ owned_str::OwnedStr, CssWriter, ParseError as StyleParseError, ParsingMode,
33
+ PropertySyntaxParseError, StyleParseErrorKind, ToCss,
34
+ };
35
+
36
+ /// A single component of the computed value.
37
+ pub type ComputedValueComponent = GenericValueComponent<
38
+ computed::Length,
39
+ computed::Number,
40
+ computed::Percentage,
41
+ computed::LengthPercentage,
42
+ computed::Color,
43
+ computed::Image,
44
+ computed::url::ComputedUrl,
45
+ computed::Integer,
46
+ computed::Angle,
47
+ computed::Time,
48
+ computed::Resolution,
49
+ computed::Transform,
50
+ >;
51
+
52
+ /// A single component of the specified value.
53
+ pub type SpecifiedValueComponent = GenericValueComponent<
54
+ specified::Length,
55
+ specified::Number,
56
+ specified::Percentage,
57
+ specified::LengthPercentage,
58
+ specified::Color,
59
+ specified::Image,
60
+ specified::url::SpecifiedUrl,
61
+ specified::Integer,
62
+ specified::Angle,
63
+ specified::Time,
64
+ specified::Resolution,
65
+ specified::Transform,
66
+ >;
67
+
68
+ impl<L, N, P, LP, C, Image, U, Integer, A, T, R, Transform>
69
+ GenericValueComponent<L, N, P, LP, C, Image, U, Integer, A, T, R, Transform>
70
+ {
71
+ fn serialization_types(&self) -> (TokenSerializationType, TokenSerializationType) {
72
+ let first_token_type = match self {
73
+ Self::Length(_) | Self::Angle(_) | Self::Time(_) | Self::Resolution(_) => {
74
+ TokenSerializationType::Dimension
75
+ },
76
+ Self::Number(_) | Self::Integer(_) => TokenSerializationType::Number,
77
+ Self::Percentage(_) | Self::LengthPercentage(_) => TokenSerializationType::Percentage,
78
+ Self::Color(_)
79
+ | Self::Image(_)
80
+ | Self::Url(_)
81
+ | Self::TransformFunction(_)
82
+ | Self::TransformList(_) => TokenSerializationType::Function,
83
+ Self::CustomIdent(_) => TokenSerializationType::Ident,
84
+ Self::String(_) => TokenSerializationType::Other,
85
+ };
86
+ let last_token_type = if first_token_type == TokenSerializationType::Function {
87
+ TokenSerializationType::Other
88
+ } else {
89
+ first_token_type
90
+ };
91
+ (first_token_type, last_token_type)
92
+ }
93
+ }
94
+
95
+ /// A generic enum used for both specified value components and computed value components.
96
+ #[derive(
97
+ Animate, Clone, ToCss, ToComputedValue, ToResolvedValue, Debug, MallocSizeOf, PartialEq, ToShmem,
98
+ )]
99
+ #[animation(no_bound(Image, Url))]
100
+ pub enum GenericValueComponent<
101
+ Length,
102
+ Number,
103
+ Percentage,
104
+ LengthPercentage,
105
+ Color,
106
+ Image,
107
+ Url,
108
+ Integer,
109
+ Angle,
110
+ Time,
111
+ Resolution,
112
+ TransformFunction,
113
+ > {
114
+ /// A <length> value
115
+ Length(Length),
116
+ /// A <number> value
117
+ Number(Number),
118
+ /// A <percentage> value
119
+ Percentage(Percentage),
120
+ /// A <length-percentage> value
121
+ LengthPercentage(LengthPercentage),
122
+ /// A <color> value
123
+ Color(Color),
124
+ /// An <image> value
125
+ #[animation(error)]
126
+ Image(Image),
127
+ /// A <url> value
128
+ #[animation(error)]
129
+ Url(Url),
130
+ /// An <integer> value
131
+ Integer(Integer),
132
+ /// An <angle> value
133
+ Angle(Angle),
134
+ /// A <time> value
135
+ Time(Time),
136
+ /// A <resolution> value
137
+ Resolution(Resolution),
138
+ /// A <transform-function> value
139
+ /// TODO(bug 1884606): <transform-function> `none` should not interpolate.
140
+ TransformFunction(TransformFunction),
141
+ /// A <custom-ident> value
142
+ #[animation(error)]
143
+ CustomIdent(CustomIdent),
144
+ /// A <transform-list> value, equivalent to <transform-function>+
145
+ /// TODO(bug 1884606): <transform-list> `none` should not interpolate.
146
+ TransformList(ComponentList<Self>),
147
+ /// A <string> value
148
+ #[animation(error)]
149
+ String(OwnedStr),
150
+ }
151
+
152
+ /// A list of component values, including the list's multiplier.
153
+ #[derive(Clone, ToComputedValue, ToResolvedValue, Debug, MallocSizeOf, PartialEq, ToShmem)]
154
+ pub struct ComponentList<Component> {
155
+ /// Multiplier
156
+ pub multiplier: Multiplier,
157
+ /// The list of components contained.
158
+ pub components: crate::OwnedSlice<Component>,
159
+ }
160
+
161
+ impl<Component: Animate> Animate for ComponentList<Component> {
162
+ fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
163
+ if self.multiplier != other.multiplier {
164
+ return Err(());
165
+ }
166
+ let components = animated::lists::by_computed_value::animate(
167
+ &self.components,
168
+ &other.components,
169
+ procedure,
170
+ )?;
171
+ Ok(Self {
172
+ multiplier: self.multiplier,
173
+ components,
174
+ })
175
+ }
176
+ }
177
+
178
+ impl<Component: ToCss> ToCss for ComponentList<Component> {
179
+ fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
180
+ where
181
+ W: Write,
182
+ {
183
+ let mut iter = self.components.iter();
184
+ let Some(first) = iter.next() else {
185
+ return Ok(());
186
+ };
187
+ first.to_css(dest)?;
188
+
189
+ // The separator implied by the multiplier for this list.
190
+ let separator = match self.multiplier {
191
+ // <https://drafts.csswg.org/cssom-1/#serialize-a-whitespace-separated-list>
192
+ Multiplier::Space => " ",
193
+ // <https://drafts.csswg.org/cssom-1/#serialize-a-comma-separated-list>
194
+ Multiplier::Comma => ", ",
195
+ };
196
+ for component in iter {
197
+ dest.write_str(separator)?;
198
+ component.to_css(dest)?;
199
+ }
200
+ Ok(())
201
+ }
202
+ }
203
+
204
+ /// A struct for a single specified registered custom property value that includes its original URL
205
+ /// data so the value can be uncomputed later.
206
+ #[derive(Clone, Debug, MallocSizeOf, ToCss, ToComputedValue, ToResolvedValue, ToShmem, ToTyped)]
207
+ #[typed(todo_derive_fields)]
208
+ pub struct Value<Component> {
209
+ /// The registered custom property value.
210
+ pub(crate) v: ValueInner<Component>,
211
+ /// The URL data of the registered custom property from before it was computed. This is
212
+ /// necessary to uncompute registered custom properties.
213
+ #[css(skip)]
214
+ url_data: UrlExtraData,
215
+ /// Flag indicating whether this value is tainted by an attr().
216
+ #[css(skip)]
217
+ pub attr_tainted: bool,
218
+ }
219
+
220
+ impl<Component: PartialEq> PartialEq for Value<Component> {
221
+ // Ignore the url_data field when comparing values for equality.
222
+ // attr_tainted is compared so the cascade doesn't treat a tainted
223
+ // value as equal to an untainted one, which could lose the taint.
224
+ fn eq(&self, other: &Self) -> bool {
225
+ self.v == other.v && self.attr_tainted == other.attr_tainted
226
+ }
227
+ }
228
+
229
+ impl<Component: Animate> Animate for Value<Component> {
230
+ fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
231
+ let v = self.v.animate(&other.v, procedure)?;
232
+ Ok(Value {
233
+ v,
234
+ url_data: self.url_data.clone(),
235
+ attr_tainted: self.attr_tainted,
236
+ })
237
+ }
238
+ }
239
+
240
+ impl<Component> Value<Component> {
241
+ /// Creates a new registered custom property value.
242
+ pub fn new(v: ValueInner<Component>, url_data: UrlExtraData) -> Self {
243
+ Self {
244
+ v,
245
+ url_data,
246
+ attr_tainted: Default::default(),
247
+ }
248
+ }
249
+
250
+ /// Creates a new registered custom property value presumed to have universal syntax.
251
+ pub fn universal(var: Arc<ComputedPropertyValue>) -> Self {
252
+ let attr_tainted = var.is_attr_tainted();
253
+ let url_data = var.url_data.clone();
254
+ let v = ValueInner::Universal(var);
255
+ Self {
256
+ v,
257
+ url_data,
258
+ attr_tainted,
259
+ }
260
+ }
261
+ }
262
+
263
+ impl<L, N, P, LP, C, Image, U, Integer, A, T, R, Transform>
264
+ Value<GenericValueComponent<L, N, P, LP, C, Image, U, Integer, A, T, R, Transform>>
265
+ where
266
+ Self: ToCss,
267
+ {
268
+ fn serialization_types(&self) -> (TokenSerializationType, TokenSerializationType) {
269
+ match &self.v {
270
+ ValueInner::Component(component) => component.serialization_types(),
271
+ ValueInner::Universal(_) => unreachable!(),
272
+ ValueInner::List(list) => list
273
+ .components
274
+ .first()
275
+ .map_or(Default::default(), |f| f.serialization_types()),
276
+ }
277
+ }
278
+
279
+ /// Convert to an untyped variable value.
280
+ pub fn to_variable_value(&self) -> ComputedPropertyValue {
281
+ if let ValueInner::Universal(ref value) = self.v {
282
+ return (**value).clone();
283
+ }
284
+ let serialization_types = self.serialization_types();
285
+ ComputedPropertyValue::new(
286
+ self.to_css_string(),
287
+ &self.url_data,
288
+ serialization_types.0,
289
+ serialization_types.1,
290
+ )
291
+ }
292
+ }
293
+
294
+ /// A specified registered custom property value.
295
+ #[derive(
296
+ Animate, ToComputedValue, ToResolvedValue, ToCss, Clone, Debug, MallocSizeOf, PartialEq, ToShmem,
297
+ )]
298
+ pub enum ValueInner<Component> {
299
+ /// A single specified component value whose syntax descriptor component did not have a
300
+ /// multiplier.
301
+ Component(Component),
302
+ /// A specified value whose syntax descriptor was the universal syntax definition.
303
+ #[animation(error)]
304
+ Universal(#[ignore_malloc_size_of = "Arc"] Arc<ComputedPropertyValue>),
305
+ /// A list of specified component values whose syntax descriptor component had a multiplier.
306
+ List(#[animation(field_bound)] ComponentList<Component>),
307
+ }
308
+
309
+ /// Specified custom property value.
310
+ pub type SpecifiedValue = Value<SpecifiedValueComponent>;
311
+
312
+ /// Computed custom property value.
313
+ pub type ComputedValue = Value<ComputedValueComponent>;
314
+
315
+ impl SpecifiedValue {
316
+ /// Convert a registered custom property to a Computed custom property value, given input and a
317
+ /// property registration.
318
+ pub fn compute(
319
+ input: &mut CSSParser,
320
+ registration: &PropertyDescriptors,
321
+ namespaces: Option<&FxHashMap<Prefix, Namespace>>,
322
+ url_data: &UrlExtraData,
323
+ context: &computed::Context,
324
+ allow_computationally_dependent: AllowComputationallyDependent,
325
+ attr_taint: AttrTaint,
326
+ ) -> Result<ComputedValue, ()> {
327
+ debug_assert!(!registration.is_universal(), "Shouldn't be needed");
328
+ let Some(ref syntax) = registration.syntax else {
329
+ return Err(());
330
+ };
331
+ let Ok(value) = Self::parse(
332
+ input,
333
+ syntax,
334
+ url_data,
335
+ namespaces,
336
+ allow_computationally_dependent,
337
+ attr_taint,
338
+ ) else {
339
+ return Err(());
340
+ };
341
+
342
+ Ok(value.to_computed_value(context))
343
+ }
344
+
345
+ /// Parse and validate a registered custom property value according to its syntax descriptor,
346
+ /// and check for computational independence.
347
+ pub fn parse(
348
+ input: &mut CSSParser,
349
+ syntax: &Descriptor,
350
+ url_data: &UrlExtraData,
351
+ namespaces: Option<&FxHashMap<Prefix, Namespace>>,
352
+ allow_computationally_dependent: AllowComputationallyDependent,
353
+ attr_taint: AttrTaint,
354
+ ) -> Result<Self, StyleParseError> {
355
+ if syntax.is_universal() {
356
+ let parsed = ComputedPropertyValue::parse(input, namespaces, url_data)?;
357
+ return Ok(Self::new(
358
+ ValueInner::Universal(Arc::new(parsed)),
359
+ url_data.clone(),
360
+ ));
361
+ }
362
+
363
+ let mut values = SmallComponentVec::new();
364
+ let mut multiplier = None;
365
+ {
366
+ let mut parser = Parser::new(syntax, &mut values, &mut multiplier);
367
+ parser.parse(input, url_data, allow_computationally_dependent, attr_taint)?;
368
+ }
369
+ let v = if let Some(multiplier) = multiplier {
370
+ ValueInner::List(ComponentList {
371
+ multiplier,
372
+ components: values.to_vec().into(),
373
+ })
374
+ } else {
375
+ ValueInner::Component(values[0].clone())
376
+ };
377
+ Ok(Self::new(v, url_data.clone()))
378
+ }
379
+ }
380
+
381
+ impl ComputedValue {
382
+ /// Uncomputes the value so that it can go back into the cascade.
383
+ pub fn to_declared_value(&self) -> properties::CustomDeclarationValue {
384
+ if let ValueInner::Universal(ref var) = self.v {
385
+ // The attr()-taint of the wrapper must survive the round-trip through the declared
386
+ // value, otherwise re-cascading the reference-free inner value
387
+ // would launder the taint and allow attribute-derived URLs to be fetched.
388
+ // This is necessary because we currently reimplement the cascade for animations in
389
+ // Servo_GetComputedKeyframeValues. We should instead just use the 'normal' path for
390
+ // animated values. For more information see Bug 1883255.
391
+ // https://drafts.csswg.org/css-values-5/#attr-security
392
+ if self.attr_tainted && !var.is_attr_tainted() {
393
+ let mut tainted = (**var).clone();
394
+ tainted.explicitly_attr_tainted = true;
395
+ return properties::CustomDeclarationValue::Unparsed(Arc::new(tainted));
396
+ }
397
+ return properties::CustomDeclarationValue::Unparsed(Arc::clone(var));
398
+ }
399
+ properties::CustomDeclarationValue::Parsed(Arc::new(ToComputedValue::from_computed_value(
400
+ self,
401
+ )))
402
+ }
403
+
404
+ /// Returns the contained variable value if it exists, otherwise `None`.
405
+ pub fn as_universal(&self) -> Option<&Arc<ComputedPropertyValue>> {
406
+ if let ValueInner::Universal(ref var) = self.v {
407
+ Some(var)
408
+ } else {
409
+ None
410
+ }
411
+ }
412
+ }
413
+
414
+ /// Whether the computed value parsing should allow computationaly dependent values like 3em or
415
+ /// var(-foo).
416
+ ///
417
+ /// https://drafts.css-houdini.org/css-properties-values-api-1/#computationally-independent
418
+ pub enum AllowComputationallyDependent {
419
+ /// Only computationally independent values are allowed.
420
+ No,
421
+ /// Computationally independent and dependent values are allowed.
422
+ Yes,
423
+ }
424
+
425
+ type SmallComponentVec = SmallVec<[SpecifiedValueComponent; 1]>;
426
+
427
+ struct Parser<'a> {
428
+ syntax: &'a Descriptor,
429
+ output: &'a mut SmallComponentVec,
430
+ output_multiplier: &'a mut Option<Multiplier>,
431
+ }
432
+
433
+ impl<'a> Parser<'a> {
434
+ fn new(
435
+ syntax: &'a Descriptor,
436
+ output: &'a mut SmallComponentVec,
437
+ output_multiplier: &'a mut Option<Multiplier>,
438
+ ) -> Self {
439
+ Self {
440
+ syntax,
441
+ output,
442
+ output_multiplier,
443
+ }
444
+ }
445
+
446
+ fn parse(
447
+ &mut self,
448
+ input: &mut CSSParser,
449
+ url_data: &UrlExtraData,
450
+ allow_computationally_dependent: AllowComputationallyDependent,
451
+ attr_taint: AttrTaint,
452
+ ) -> Result<(), StyleParseError> {
453
+ use self::AllowComputationallyDependent::*;
454
+ let parsing_mode = match allow_computationally_dependent {
455
+ No => ParsingMode::DISALLOW_COMPUTATIONALLY_DEPENDENT,
456
+ Yes => ParsingMode::DEFAULT,
457
+ };
458
+ let context = &ParserContext::new(
459
+ Origin::Author,
460
+ url_data,
461
+ Some(CssRuleType::Style),
462
+ parsing_mode,
463
+ QuirksMode::NoQuirks,
464
+ /* namespaces = */ Default::default(),
465
+ None,
466
+ None,
467
+ attr_taint,
468
+ );
469
+ for component in self.syntax.components.iter() {
470
+ let result = input.try_parse(|input| {
471
+ input.parse_entirely(|input| {
472
+ Self::parse_value(context, input, &component.unpremultiplied())
473
+ })
474
+ });
475
+ let Ok(values) = result else { continue };
476
+ self.output.extend(values);
477
+ *self.output_multiplier = component.multiplier();
478
+ break;
479
+ }
480
+ if self.output.is_empty() {
481
+ return Err(StyleParseError::from_basic_kind(
482
+ BasicParseErrorKind::EndOfInput,
483
+ ));
484
+ }
485
+ Ok(())
486
+ }
487
+
488
+ fn parse_value(
489
+ context: &ParserContext,
490
+ input: &mut CSSParser,
491
+ component: &SyntaxComponent,
492
+ ) -> Result<SmallComponentVec, StyleParseError> {
493
+ let mut values = SmallComponentVec::new();
494
+ values.push(Self::parse_component_without_multiplier(
495
+ context, input, component,
496
+ )?);
497
+
498
+ if let Some(multiplier) = component.multiplier() {
499
+ loop {
500
+ let result = Self::expect_multiplier(input, &multiplier);
501
+ if Self::expect_multiplier_yielded_eof_error(&result) {
502
+ break;
503
+ }
504
+ result?;
505
+ values.push(Self::parse_component_without_multiplier(
506
+ context, input, component,
507
+ )?);
508
+ }
509
+ }
510
+ Ok(values)
511
+ }
512
+
513
+ fn parse_component_without_multiplier(
514
+ context: &ParserContext,
515
+ input: &mut CSSParser,
516
+ component: &SyntaxComponent,
517
+ ) -> Result<SpecifiedValueComponent, StyleParseError> {
518
+ let data_type = match component.name() {
519
+ ComponentName::DataType(ty) => ty,
520
+ ComponentName::Ident(name) => {
521
+ let ident = CustomIdent::parse(input, &[])?;
522
+ if ident != *name {
523
+ return Err(StyleParseError::custom(
524
+ StyleParseErrorKind::UnspecifiedError,
525
+ ));
526
+ }
527
+ return Ok(SpecifiedValueComponent::CustomIdent(ident));
528
+ },
529
+ };
530
+
531
+ let value = match data_type {
532
+ DataType::Length => {
533
+ SpecifiedValueComponent::Length(specified::Length::parse(context, input)?)
534
+ },
535
+ DataType::Number => {
536
+ SpecifiedValueComponent::Number(specified::Number::parse(context, input)?)
537
+ },
538
+ DataType::Percentage => {
539
+ SpecifiedValueComponent::Percentage(specified::Percentage::parse(context, input)?)
540
+ },
541
+ DataType::LengthPercentage => SpecifiedValueComponent::LengthPercentage(
542
+ specified::LengthPercentage::parse(context, input)?,
543
+ ),
544
+ DataType::Color => {
545
+ SpecifiedValueComponent::Color(specified::Color::parse(context, input)?)
546
+ },
547
+ DataType::Image => {
548
+ SpecifiedValueComponent::Image(specified::Image::parse_forbid_none(context, input)?)
549
+ },
550
+ DataType::Url => {
551
+ SpecifiedValueComponent::Url(specified::url::SpecifiedUrl::parse(context, input)?)
552
+ },
553
+ DataType::Integer => {
554
+ SpecifiedValueComponent::Integer(specified::Integer::parse(context, input)?)
555
+ },
556
+ DataType::Angle => {
557
+ SpecifiedValueComponent::Angle(specified::Angle::parse(context, input)?)
558
+ },
559
+ DataType::Time => {
560
+ SpecifiedValueComponent::Time(specified::Time::parse(context, input)?)
561
+ },
562
+ DataType::Resolution => {
563
+ SpecifiedValueComponent::Resolution(specified::Resolution::parse(context, input)?)
564
+ },
565
+ DataType::TransformFunction => SpecifiedValueComponent::TransformFunction(
566
+ specified::Transform::parse(context, input)?,
567
+ ),
568
+ DataType::CustomIdent => {
569
+ let name = CustomIdent::parse(input, &[])?;
570
+ SpecifiedValueComponent::CustomIdent(name)
571
+ },
572
+ DataType::TransformList => {
573
+ let mut values = vec![];
574
+ let Some(multiplier) = component.unpremultiplied().multiplier() else {
575
+ debug_assert!(false, "Unpremultiplied <transform-list> had no multiplier?");
576
+ return Err(StyleParseError::custom(
577
+ StyleParseErrorKind::PropertySyntaxField(
578
+ PropertySyntaxParseError::UnexpectedEOF,
579
+ ),
580
+ ));
581
+ };
582
+ debug_assert_eq!(multiplier, Multiplier::Space);
583
+ loop {
584
+ values.push(SpecifiedValueComponent::TransformFunction(
585
+ specified::Transform::parse(context, input)?,
586
+ ));
587
+ let result = Self::expect_multiplier(input, &multiplier);
588
+ if Self::expect_multiplier_yielded_eof_error(&result) {
589
+ break;
590
+ }
591
+ result?;
592
+ }
593
+ let list = ComponentList {
594
+ multiplier,
595
+ components: values.into(),
596
+ };
597
+ SpecifiedValueComponent::TransformList(list)
598
+ },
599
+ DataType::String => {
600
+ let string = input.expect_string()?;
601
+ SpecifiedValueComponent::String(string.as_ref().to_owned().into())
602
+ },
603
+ };
604
+ Ok(value)
605
+ }
606
+
607
+ fn expect_multiplier_yielded_eof_error(result: &Result<(), StyleParseError>) -> bool {
608
+ matches!(
609
+ result,
610
+ Err(StyleParseError {
611
+ kind: ParseErrorKind::Basic(BasicParseErrorKind::EndOfInput),
612
+ ..
613
+ })
614
+ )
615
+ }
616
+
617
+ fn expect_multiplier(
618
+ input: &mut CSSParser,
619
+ multiplier: &Multiplier,
620
+ ) -> Result<(), StyleParseError> {
621
+ match multiplier {
622
+ Multiplier::Space => {
623
+ input.expect_whitespace()?;
624
+ if input.is_exhausted() {
625
+ // If there was trailing whitespace, do not interpret it as a multiplier
626
+ return Err(StyleParseError::from_basic_kind(
627
+ BasicParseErrorKind::EndOfInput,
628
+ ));
629
+ }
630
+ Ok(())
631
+ },
632
+ Multiplier::Comma => Ok(input.expect_comma()?),
633
+ }
634
+ }
635
+ }
636
+
637
+ /// An animated value for custom property.
638
+ #[derive(Clone, Debug, MallocSizeOf, PartialEq)]
639
+ pub struct CustomAnimatedValue {
640
+ /// The name of the custom property.
641
+ pub(crate) name: crate::custom_properties::Name,
642
+ /// The computed value of the custom property.
643
+ /// `None` represents the guaranteed-invalid value.
644
+ pub(crate) value: Option<ComputedValue>,
645
+ }
646
+
647
+ impl Animate for CustomAnimatedValue {
648
+ fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
649
+ if self.name != other.name {
650
+ return Err(());
651
+ }
652
+ let value = self.value.animate(&other.value, procedure)?;
653
+ Ok(Self {
654
+ name: self.name.clone(),
655
+ value,
656
+ })
657
+ }
658
+ }
659
+
660
+ impl CustomAnimatedValue {
661
+ pub(crate) fn from_computed(
662
+ name: &crate::custom_properties::Name,
663
+ value: Option<&ComputedValue>,
664
+ ) -> Self {
665
+ Self {
666
+ name: name.clone(),
667
+ value: value.cloned(),
668
+ }
669
+ }
670
+
671
+ pub(crate) fn from_declaration(
672
+ declaration: &properties::CustomDeclaration,
673
+ context: &mut computed::Context,
674
+ ) -> Option<Self> {
675
+ let computed_value = match declaration.value {
676
+ properties::CustomDeclarationValue::Unparsed(ref value) => Some({
677
+ debug_assert!(
678
+ context.builder.stylist.is_some(),
679
+ "Need a Stylist to get property registration!"
680
+ );
681
+ let registration = context
682
+ .builder
683
+ .stylist
684
+ .unwrap()
685
+ .get_custom_property_registration(&declaration.name);
686
+ if registration.is_universal() {
687
+ // FIXME: Do we need to perform substitution here somehow?
688
+ ComputedValue::universal(Arc::clone(value))
689
+ } else {
690
+ let mut input = CSSParser::new(&value.css);
691
+ SpecifiedValue::compute(
692
+ &mut input,
693
+ registration,
694
+ None,
695
+ &value.url_data,
696
+ context,
697
+ AllowComputationallyDependent::Yes,
698
+ /* attr_taint */ Default::default(),
699
+ )
700
+ .unwrap_or_else(|_| ComputedValue::universal(Arc::clone(value)))
701
+ }
702
+ }),
703
+ properties::CustomDeclarationValue::Parsed(ref v) => Some(v.to_computed_value(context)),
704
+ properties::CustomDeclarationValue::CSSWideKeyword(keyword) => {
705
+ let stylist = context.builder.stylist.unwrap();
706
+ let registration = stylist.get_custom_property_registration(&declaration.name);
707
+ match keyword {
708
+ CSSWideKeyword::Initial => stylist
709
+ .get_custom_property_initial_values()
710
+ .get(registration, &declaration.name),
711
+ CSSWideKeyword::Inherit => context
712
+ .builder
713
+ .inherited_custom_properties()
714
+ .get(registration, &declaration.name),
715
+ CSSWideKeyword::Unset => {
716
+ if registration.inherits() {
717
+ context
718
+ .builder
719
+ .inherited_custom_properties()
720
+ .get(registration, &declaration.name)
721
+ } else {
722
+ stylist
723
+ .get_custom_property_initial_values()
724
+ .get(registration, &declaration.name)
725
+ }
726
+ },
727
+ // FIXME(emilio, bug 1533327): I think revert (and
728
+ // revert-layer) handling is not fine here, but what to
729
+ // do instead?
730
+ //
731
+ // Seems we'd need the computed value as if it was
732
+ // revert, somehow. Returning `None` seems fine for now...
733
+ //
734
+ // Note that once this is fixed, this method should be
735
+ // able to return `Self` instead of Option<Self>`.
736
+ CSSWideKeyword::Revert
737
+ | CSSWideKeyword::RevertRule
738
+ | CSSWideKeyword::RevertLayer => return None,
739
+ }
740
+ .cloned()
741
+ },
742
+ };
743
+ Some(Self {
744
+ name: declaration.name.clone(),
745
+ value: computed_value,
746
+ })
747
+ }
748
+
749
+ pub(crate) fn to_declaration(&self) -> properties::PropertyDeclaration {
750
+ properties::PropertyDeclaration::Custom(properties::CustomDeclaration {
751
+ name: self.name.clone(),
752
+ value: match &self.value {
753
+ Some(value) => value.to_declared_value(),
754
+ None => CustomDeclarationValue::CSSWideKeyword(CSSWideKeyword::Initial),
755
+ },
756
+ })
757
+ }
758
+ }