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,1036 @@
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
+ #![deny(missing_docs)]
6
+
7
+ //! Servo's selector parser.
8
+
9
+ use crate::attr::{AttrIdentifier, AttrValue};
10
+ use crate::computed_value_flags::ComputedValueFlags;
11
+ use crate::derives::*;
12
+ use crate::dom::{OpaqueNode, TElement, TNode};
13
+ use crate::invalidation::element::document_state::InvalidationMatchingData;
14
+ use crate::invalidation::element::element_wrapper::ElementSnapshot;
15
+ use crate::properties::longhands::display::computed_value::T as Display;
16
+ use crate::properties::{ComputedValues, PropertyFlags};
17
+ use crate::selector_parser::AttrValue as SelectorAttrValue;
18
+ use crate::selector_parser::{PseudoElementCascadeType, SelectorParser};
19
+ use crate::values::{AtomIdent, AtomString};
20
+ use crate::{Atom, CaseSensitivityExt, LocalName, Namespace, Prefix};
21
+ use cssparser::{
22
+ match_ignore_ascii_case, serialize_identifier, CowRcStr, Parser as CssParser, ToCss,
23
+ };
24
+ use dom::{DocumentState, ElementState};
25
+ use rustc_hash::FxHashMap;
26
+ use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint};
27
+ use selectors::parser::SelectorParseErrorKind;
28
+ use std::fmt;
29
+ use std::mem;
30
+ use std::ops::{Deref, DerefMut};
31
+ use style_traits::{ParseError, StyleParseErrorKind};
32
+
33
+ /// A pseudo-element, both public and private.
34
+ ///
35
+ /// NB: If you add to this list, be sure to update `each_simple_pseudo_element` too.
36
+ #[derive(
37
+ Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize, ToShmem,
38
+ )]
39
+ #[allow(missing_docs)]
40
+ #[repr(u8)]
41
+ pub enum PseudoElement {
42
+ // Eager pseudos. Keep these first so that eager_index() works.
43
+ After = 0,
44
+ Before,
45
+ Selection,
46
+ // If/when :first-letter is added, update is_first_letter accordingly.
47
+
48
+ // If/when :first-line is added, update is_first_line accordingly.
49
+
50
+ // If/when ::first-letter or ::first-line are added, adjust our
51
+ // property_restriction implementation to do property filtering for them.
52
+ // Also, make sure the UA sheet has the !important rules some of the
53
+ // APPLIES_TO_PLACEHOLDER properties expect!
54
+ FirstLetter,
55
+
56
+ // Non-eager pseudos.
57
+ Backdrop,
58
+ DetailsContent,
59
+ Marker,
60
+
61
+ // Implemented pseudos. These pseudo elements are representing the
62
+ // elements within an UA shadow DOM, and matching the elements with
63
+ // their appropriate styles.
64
+ ColorSwatch,
65
+ FileSelectorButton,
66
+ Placeholder,
67
+ SliderFill,
68
+ SliderThumb,
69
+ SliderTrack,
70
+ MozProgressBar,
71
+
72
+ // Private, Servo-specific implemented pseudos. Only matchable in UA sheet.
73
+ ServoTextControlInnerContainer,
74
+ ServoTextControlInnerEditor,
75
+
76
+ // Other Servo-specific pseudos.
77
+ ServoAnonymousBox,
78
+ ServoAnonymousTable,
79
+ ServoAnonymousTableCell,
80
+ ServoAnonymousTableRow,
81
+ ServoTableGrid,
82
+ ServoTableWrapper,
83
+ }
84
+
85
+ /// The count of all pseudo-elements.
86
+ pub const PSEUDO_COUNT: usize = PseudoElement::ServoTableWrapper as usize + 1;
87
+
88
+ impl ToCss for PseudoElement {
89
+ fn to_css<W>(&self, dest: &mut W) -> fmt::Result
90
+ where
91
+ W: fmt::Write,
92
+ {
93
+ use self::PseudoElement::*;
94
+ dest.write_str(match *self {
95
+ After => "::after",
96
+ Before => "::before",
97
+ Selection => "::selection",
98
+ FirstLetter => "::first-letter",
99
+ Backdrop => "::backdrop",
100
+ DetailsContent => "::details-content",
101
+ Marker => "::marker",
102
+ ColorSwatch => "::color-swatch",
103
+ FileSelectorButton => "::file-selector-button",
104
+ Placeholder => "::placeholder",
105
+ SliderFill => "::slider-fill",
106
+ SliderTrack => "::slider-track",
107
+ SliderThumb => "::slider-thumb",
108
+ MozProgressBar => "::-moz-progress-bar",
109
+ ServoTextControlInnerContainer => "::-servo-text-control-inner-container",
110
+ ServoTextControlInnerEditor => "::-servo-text-control-inner-editor",
111
+ ServoAnonymousBox => "::-servo-anonymous-box",
112
+ ServoAnonymousTable => "::-servo-anonymous-table",
113
+ ServoAnonymousTableCell => "::-servo-anonymous-table-cell",
114
+ ServoAnonymousTableRow => "::-servo-anonymous-table-row",
115
+ ServoTableGrid => "::-servo-table-grid",
116
+ ServoTableWrapper => "::-servo-table-wrapper",
117
+ })
118
+ }
119
+ }
120
+
121
+ impl ::selectors::parser::PseudoElement for PseudoElement {
122
+ fn parses_as_element_backed(&self) -> bool {
123
+ matches!(self, Self::DetailsContent)
124
+ }
125
+ }
126
+
127
+ /// The number of eager pseudo-elements. Keep this in sync with cascade_type.
128
+ pub const EAGER_PSEUDO_COUNT: usize = 4;
129
+
130
+ impl PseudoElement {
131
+ /// Gets the canonical index of this eagerly-cascaded pseudo-element.
132
+ #[inline]
133
+ pub fn eager_index(&self) -> usize {
134
+ debug_assert!(self.is_eager());
135
+ self.clone() as usize
136
+ }
137
+
138
+ /// An index for this pseudo-element to be indexed in an enumerated array.
139
+ #[inline]
140
+ pub fn index(&self) -> usize {
141
+ self.clone() as usize
142
+ }
143
+
144
+ /// An array of `None`, one per pseudo-element.
145
+ pub fn pseudo_none_array<T>() -> [Option<T>; PSEUDO_COUNT] {
146
+ Default::default()
147
+ }
148
+
149
+ /// Creates a pseudo-element from an eager index.
150
+ #[inline]
151
+ pub fn from_eager_index(i: usize) -> Self {
152
+ const _: () = assert!(EAGER_PSEUDO_COUNT <= (u8::MAX as usize));
153
+ assert!(i < EAGER_PSEUDO_COUNT);
154
+ let result: PseudoElement = unsafe { mem::transmute(i as u8) };
155
+ debug_assert!(result.is_eager());
156
+ result
157
+ }
158
+
159
+ /// Whether the current pseudo element is ::before or ::after.
160
+ #[inline]
161
+ pub fn is_before_or_after(&self) -> bool {
162
+ self.is_before() || self.is_after()
163
+ }
164
+
165
+ /// Whether this is an unknown ::-webkit- pseudo-element.
166
+ #[inline]
167
+ pub fn is_unknown_webkit_pseudo_element(&self) -> bool {
168
+ false
169
+ }
170
+
171
+ /// Whether this pseudo-element is the ::marker pseudo.
172
+ #[inline]
173
+ pub fn is_marker(&self) -> bool {
174
+ *self == PseudoElement::Marker
175
+ }
176
+
177
+ /// Whether this pseudo-element is the ::selection pseudo.
178
+ #[inline]
179
+ pub fn is_selection(&self) -> bool {
180
+ *self == PseudoElement::Selection
181
+ }
182
+
183
+ /// Whether this pseudo-element is the ::before pseudo.
184
+ #[inline]
185
+ pub fn is_before(&self) -> bool {
186
+ *self == PseudoElement::Before
187
+ }
188
+
189
+ /// Whether this pseudo-element is the ::after pseudo.
190
+ #[inline]
191
+ pub fn is_after(&self) -> bool {
192
+ *self == PseudoElement::After
193
+ }
194
+
195
+ /// Whether the current pseudo element is :first-letter
196
+ #[inline]
197
+ pub fn is_first_letter(&self) -> bool {
198
+ *self == PseudoElement::FirstLetter
199
+ }
200
+
201
+ /// Whether the current pseudo element is :first-line
202
+ #[inline]
203
+ pub fn is_first_line(&self) -> bool {
204
+ false
205
+ }
206
+
207
+ /// Whether this pseudo-element is representing the color swatch
208
+ /// inside an `<input>` element.
209
+ #[inline]
210
+ pub fn is_color_swatch(&self) -> bool {
211
+ *self == PseudoElement::ColorSwatch
212
+ }
213
+
214
+ /// Whether this pseudo-element is eagerly-cascaded.
215
+ #[inline]
216
+ pub fn is_eager(&self) -> bool {
217
+ self.cascade_type() == PseudoElementCascadeType::Eager
218
+ }
219
+
220
+ /// Whether this pseudo-element is lazily-cascaded.
221
+ #[inline]
222
+ pub fn is_lazy(&self) -> bool {
223
+ self.cascade_type() == PseudoElementCascadeType::Lazy
224
+ }
225
+
226
+ /// Whether this pseudo-element is for an anonymous box.
227
+ pub fn is_anon_box(&self) -> bool {
228
+ self.is_precomputed()
229
+ }
230
+
231
+ /// Whether this pseudo-element skips flex/grid container display-based
232
+ /// fixup.
233
+ #[inline]
234
+ pub fn skip_item_display_fixup(&self) -> bool {
235
+ !self.is_before_or_after()
236
+ }
237
+
238
+ /// Whether this pseudo-element is precomputed.
239
+ #[inline]
240
+ pub fn is_precomputed(&self) -> bool {
241
+ self.cascade_type() == PseudoElementCascadeType::Precomputed
242
+ }
243
+
244
+ /// Returns which kind of cascade type has this pseudo.
245
+ ///
246
+ /// See the documentation for `PseudoElementCascadeType` for how we choose
247
+ /// which cascade type to use.
248
+ ///
249
+ /// Note: Keep eager pseudos in sync with `EAGER_PSEUDO_COUNT` and
250
+ /// `EMPTY_PSEUDO_ARRAY` in `style/data.rs`
251
+ #[inline]
252
+ pub fn cascade_type(&self) -> PseudoElementCascadeType {
253
+ match *self {
254
+ PseudoElement::After
255
+ | PseudoElement::Before
256
+ | PseudoElement::FirstLetter
257
+ | PseudoElement::Selection => PseudoElementCascadeType::Eager,
258
+ PseudoElement::Backdrop
259
+ | PseudoElement::ColorSwatch
260
+ | PseudoElement::FileSelectorButton
261
+ | PseudoElement::Marker
262
+ | PseudoElement::Placeholder
263
+ | PseudoElement::DetailsContent
264
+ | PseudoElement::SliderFill
265
+ | PseudoElement::SliderThumb
266
+ | PseudoElement::SliderTrack
267
+ | PseudoElement::MozProgressBar
268
+ | PseudoElement::ServoTextControlInnerContainer
269
+ | PseudoElement::ServoTextControlInnerEditor => PseudoElementCascadeType::Lazy,
270
+ PseudoElement::ServoAnonymousBox
271
+ | PseudoElement::ServoAnonymousTable
272
+ | PseudoElement::ServoAnonymousTableCell
273
+ | PseudoElement::ServoAnonymousTableRow
274
+ | PseudoElement::ServoTableGrid
275
+ | PseudoElement::ServoTableWrapper => PseudoElementCascadeType::Precomputed,
276
+ }
277
+ }
278
+
279
+ /// Covert non-canonical pseudo-element to canonical one, and keep a
280
+ /// canonical one as it is.
281
+ pub fn canonical(&self) -> PseudoElement {
282
+ self.clone()
283
+ }
284
+
285
+ /// Stub, only Gecko needs this
286
+ pub fn pseudo_info(&self) {
287
+ ()
288
+ }
289
+
290
+ /// Property flag that properties must have to apply to this pseudo-element.
291
+ #[inline]
292
+ pub fn property_restriction(&self) -> Option<PropertyFlags> {
293
+ Some(match self {
294
+ PseudoElement::FirstLetter => PropertyFlags::APPLIES_TO_FIRST_LETTER,
295
+ PseudoElement::Marker if crate::pref!("layout.css.marker.restricted") => {
296
+ PropertyFlags::APPLIES_TO_MARKER
297
+ },
298
+ PseudoElement::Placeholder => PropertyFlags::APPLIES_TO_PLACEHOLDER,
299
+ _ => return None,
300
+ })
301
+ }
302
+
303
+ /// Whether this pseudo-element should actually exist if it has
304
+ /// the given styles.
305
+ pub fn should_exist(&self, style: &ComputedValues) -> bool {
306
+ let display = style.get_box().clone_display();
307
+ if display == Display::None {
308
+ return false;
309
+ }
310
+ if self.is_before_or_after() && style.ineffective_content_property() {
311
+ return false;
312
+ }
313
+
314
+ true
315
+ }
316
+
317
+ /// Whether this pseudo-element is the ::highlight pseudo.
318
+ pub fn is_highlight(&self) -> bool {
319
+ false
320
+ }
321
+
322
+ /// Whether this pseudo-element takes an argument.
323
+ #[inline]
324
+ pub fn has_argument(&self) -> bool {
325
+ false
326
+ }
327
+
328
+ /// Whether this pseudo-element is the ::target-text pseudo.
329
+ #[inline]
330
+ pub fn is_target_text(&self) -> bool {
331
+ false
332
+ }
333
+
334
+ /// Whether this is a highlight pseudo-element that is styled lazily during
335
+ /// painting rather than during the restyle traversal. These pseudos need
336
+ /// explicit repaint triggering when their styles change.
337
+ #[inline]
338
+ pub fn is_lazy_painted_highlight_pseudo(&self) -> bool {
339
+ self.is_selection() || self.is_highlight() || self.is_target_text()
340
+ }
341
+
342
+ /// Whether this pseudo-element is "element-backed", which means that it inherits from its regular
343
+ /// flat tree parent, which might not be the originating element.
344
+ #[inline]
345
+ pub fn is_element_backed(&self) -> bool {
346
+ use selectors::parser::PseudoElement;
347
+ self.parses_as_element_backed()
348
+ || matches!(
349
+ self,
350
+ Self::Placeholder
351
+ | Self::ColorSwatch
352
+ | Self::FileSelectorButton
353
+ | Self::SliderFill
354
+ | Self::SliderThumb
355
+ | Self::SliderTrack
356
+ | Self::MozProgressBar
357
+ | Self::ServoTextControlInnerContainer
358
+ | Self::ServoTextControlInnerEditor,
359
+ )
360
+ }
361
+ }
362
+
363
+ /// The type used for storing `:lang` arguments.
364
+ pub type Lang = Box<str>;
365
+
366
+ /// The type used to store the state argument to the `:state` pseudo-class.
367
+ #[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToCss, ToShmem)]
368
+ pub struct CustomState(pub AtomIdent);
369
+
370
+ /// A non tree-structural pseudo-class.
371
+ /// See https://drafts.csswg.org/selectors-4/#structural-pseudos
372
+ #[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToShmem)]
373
+ #[allow(missing_docs)]
374
+ pub enum NonTSPseudoClass {
375
+ Active,
376
+ AnyLink,
377
+ Autofill,
378
+ Checked,
379
+ /// The :state` pseudo-class.
380
+ CustomState(CustomState),
381
+ Default,
382
+ Defined,
383
+ Disabled,
384
+ Enabled,
385
+ Focus,
386
+ FocusWithin,
387
+ FocusVisible,
388
+ Fullscreen,
389
+ Hover,
390
+ InRange,
391
+ Indeterminate,
392
+ Invalid,
393
+ Lang(Lang),
394
+ Link,
395
+ Modal,
396
+ MozMeterOptimum,
397
+ MozMeterSubOptimum,
398
+ MozMeterSubSubOptimum,
399
+ Open,
400
+ Optional,
401
+ OutOfRange,
402
+ PlaceholderShown,
403
+ PopoverOpen,
404
+ ReadOnly,
405
+ ReadWrite,
406
+ Required,
407
+ ServoNonZeroBorder,
408
+ Target,
409
+ UserInvalid,
410
+ UserValid,
411
+ Valid,
412
+ Visited,
413
+ }
414
+
415
+ impl ::selectors::parser::NonTSPseudoClass for NonTSPseudoClass {
416
+ #[inline]
417
+ fn is_active_or_hover(&self) -> bool {
418
+ matches!(*self, NonTSPseudoClass::Active | NonTSPseudoClass::Hover)
419
+ }
420
+
421
+ #[inline]
422
+ fn is_user_action_state(&self) -> bool {
423
+ matches!(
424
+ *self,
425
+ NonTSPseudoClass::Active | NonTSPseudoClass::Hover | NonTSPseudoClass::Focus
426
+ )
427
+ }
428
+
429
+ fn visit<V>(&self, _: &mut V) -> bool {
430
+ true
431
+ }
432
+ }
433
+
434
+ impl ToCss for NonTSPseudoClass {
435
+ fn to_css<W>(&self, dest: &mut W) -> fmt::Result
436
+ where
437
+ W: fmt::Write,
438
+ {
439
+ use self::NonTSPseudoClass::*;
440
+ if let Lang(ref lang) = *self {
441
+ dest.write_str(":lang(")?;
442
+ serialize_identifier(lang, dest)?;
443
+ return dest.write_char(')');
444
+ }
445
+
446
+ dest.write_str(match *self {
447
+ Self::Active => ":active",
448
+ Self::AnyLink => ":any-link",
449
+ Self::Autofill => ":autofill",
450
+ Self::Checked => ":checked",
451
+ Self::CustomState(ref state) => {
452
+ dest.write_str(":state(")?;
453
+ state.0.to_css(dest)?;
454
+ return dest.write_char(')');
455
+ },
456
+ Self::Default => ":default",
457
+ Self::Defined => ":defined",
458
+ Self::Disabled => ":disabled",
459
+ Self::Enabled => ":enabled",
460
+ Self::Focus => ":focus",
461
+ Self::FocusVisible => ":focus-visible",
462
+ Self::FocusWithin => ":focus-within",
463
+ Self::Fullscreen => ":fullscreen",
464
+ Self::Hover => ":hover",
465
+ Self::InRange => ":in-range",
466
+ Self::Indeterminate => ":indeterminate",
467
+ Self::Invalid => ":invalid",
468
+ Self::Link => ":link",
469
+ Self::Modal => ":modal",
470
+ Self::MozMeterOptimum => ":-moz-meter-optimum",
471
+ Self::MozMeterSubOptimum => ":-moz-meter-sub-optimum",
472
+ Self::MozMeterSubSubOptimum => ":-moz-meter-sub-sub-optimum",
473
+ Self::Open => ":open",
474
+ Self::Optional => ":optional",
475
+ Self::OutOfRange => ":out-of-range",
476
+ Self::PlaceholderShown => ":placeholder-shown",
477
+ Self::PopoverOpen => ":popover-open",
478
+ Self::ReadOnly => ":read-only",
479
+ Self::ReadWrite => ":read-write",
480
+ Self::Required => ":required",
481
+ Self::ServoNonZeroBorder => ":-servo-nonzero-border",
482
+ Self::Target => ":target",
483
+ Self::UserInvalid => ":user-invalid",
484
+ Self::UserValid => ":user-valid",
485
+ Self::Valid => ":valid",
486
+ Self::Visited => ":visited",
487
+ Self::Lang(_) => unreachable!(),
488
+ })
489
+ }
490
+ }
491
+
492
+ impl NonTSPseudoClass {
493
+ /// Gets a given state flag for this pseudo-class. This is used to do
494
+ /// selector matching, and it's set from the DOM.
495
+ pub fn state_flag(&self) -> ElementState {
496
+ match *self {
497
+ Self::Active => ElementState::ACTIVE,
498
+ Self::AnyLink => ElementState::VISITED_OR_UNVISITED,
499
+ Self::Autofill => ElementState::AUTOFILL,
500
+ Self::Checked => ElementState::CHECKED,
501
+ Self::Default => ElementState::DEFAULT,
502
+ Self::Defined => ElementState::DEFINED,
503
+ Self::Disabled => ElementState::DISABLED,
504
+ Self::Enabled => ElementState::ENABLED,
505
+ Self::Focus => ElementState::FOCUS,
506
+ Self::FocusVisible => ElementState::FOCUSRING,
507
+ Self::FocusWithin => ElementState::FOCUS_WITHIN,
508
+ Self::Fullscreen => ElementState::FULLSCREEN,
509
+ Self::Hover => ElementState::HOVER,
510
+ Self::InRange => ElementState::INRANGE,
511
+ Self::Indeterminate => ElementState::INDETERMINATE,
512
+ Self::Invalid => ElementState::INVALID,
513
+ Self::Link => ElementState::UNVISITED,
514
+ Self::Modal => ElementState::MODAL,
515
+ Self::MozMeterOptimum => ElementState::OPTIMUM,
516
+ Self::MozMeterSubOptimum => ElementState::SUB_OPTIMUM,
517
+ Self::MozMeterSubSubOptimum => ElementState::SUB_SUB_OPTIMUM,
518
+ Self::Open => ElementState::OPEN,
519
+ Self::Optional => ElementState::OPTIONAL_,
520
+ Self::OutOfRange => ElementState::OUTOFRANGE,
521
+ Self::PlaceholderShown => ElementState::PLACEHOLDER_SHOWN,
522
+ Self::PopoverOpen => ElementState::POPOVER_OPEN,
523
+ Self::ReadOnly => ElementState::READONLY,
524
+ Self::ReadWrite => ElementState::READWRITE,
525
+ Self::Required => ElementState::REQUIRED,
526
+ Self::Target => ElementState::URLTARGET,
527
+ Self::UserInvalid => ElementState::USER_INVALID,
528
+ Self::UserValid => ElementState::USER_VALID,
529
+ Self::Valid => ElementState::VALID,
530
+ Self::Visited => ElementState::VISITED,
531
+ Self::CustomState(_) | Self::Lang(_) | Self::ServoNonZeroBorder => {
532
+ ElementState::empty()
533
+ },
534
+ }
535
+ }
536
+
537
+ /// Get the document state flag associated with a pseudo-class, if any.
538
+ pub fn document_state_flag(&self) -> DocumentState {
539
+ DocumentState::empty()
540
+ }
541
+
542
+ /// Returns true if the given pseudoclass should trigger style sharing cache revalidation.
543
+ pub fn needs_cache_revalidation(&self) -> bool {
544
+ self.state_flag().is_empty()
545
+ }
546
+ }
547
+
548
+ /// The abstract struct we implement the selector parser implementation on top
549
+ /// of.
550
+ #[derive(Clone, Debug, MallocSizeOf, PartialEq)]
551
+ pub struct SelectorImpl;
552
+
553
+ /// A set of extra data to carry along with the matching context, either for
554
+ /// selector-matching or invalidation.
555
+ #[derive(Debug, Default)]
556
+ pub struct ExtraMatchingData<'a> {
557
+ /// The invalidation data to invalidate doc-state pseudo-classes correctly.
558
+ pub invalidation_data: InvalidationMatchingData,
559
+
560
+ /// The invalidation bits from matching container queries. These are here
561
+ /// just for convenience mostly.
562
+ pub cascade_input_flags: ComputedValueFlags,
563
+
564
+ /// The style of the originating element in order to evaluate @container
565
+ /// size queries affecting pseudo-elements.
566
+ pub originating_element_style: Option<&'a ComputedValues>,
567
+ }
568
+
569
+ impl ::selectors::SelectorImpl for SelectorImpl {
570
+ type PseudoElement = PseudoElement;
571
+ type NonTSPseudoClass = NonTSPseudoClass;
572
+
573
+ type ExtraMatchingData<'a> = ExtraMatchingData<'a>;
574
+ type AttrValue = AtomString;
575
+ type Identifier = AtomIdent;
576
+ type LocalName = LocalName;
577
+ type NamespacePrefix = Prefix;
578
+ type NamespaceUrl = Namespace;
579
+ type BorrowedLocalName = web_atoms::LocalName;
580
+ type BorrowedNamespaceUrl = web_atoms::Namespace;
581
+ }
582
+
583
+ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
584
+ type Impl = SelectorImpl;
585
+ type Error = StyleParseErrorKind;
586
+
587
+ #[inline]
588
+ fn parse_nth_child_of(&self) -> bool {
589
+ crate::pref!("layout.css.nth-child-of.enabled")
590
+ }
591
+
592
+ #[inline]
593
+ fn parse_is_and_where(&self) -> bool {
594
+ true
595
+ }
596
+
597
+ #[inline]
598
+ fn parse_has(&self) -> bool {
599
+ crate::pref!("layout.css.has-selector.enabled")
600
+ }
601
+
602
+ #[inline]
603
+ fn parse_parent_selector(&self) -> bool {
604
+ true
605
+ }
606
+
607
+ #[inline]
608
+ fn parse_part(&self) -> bool {
609
+ true
610
+ }
611
+
612
+ #[inline]
613
+ fn allow_forgiving_selectors(&self) -> bool {
614
+ !self.for_supports_rule
615
+ }
616
+
617
+ fn parse_non_ts_pseudo_class(
618
+ &self,
619
+ name: CowRcStr<'i>,
620
+ ) -> Result<NonTSPseudoClass, ParseError> {
621
+ let pseudo_class = match_ignore_ascii_case! { &name,
622
+ "active" => NonTSPseudoClass::Active,
623
+ "any-link" => NonTSPseudoClass::AnyLink,
624
+ "autofill" => NonTSPseudoClass::Autofill,
625
+ "checked" => NonTSPseudoClass::Checked,
626
+ "default" => NonTSPseudoClass::Default,
627
+ "defined" => NonTSPseudoClass::Defined,
628
+ "disabled" => NonTSPseudoClass::Disabled,
629
+ "enabled" => NonTSPseudoClass::Enabled,
630
+ "focus" => NonTSPseudoClass::Focus,
631
+ "focus-visible" => NonTSPseudoClass::FocusVisible,
632
+ "focus-within" => NonTSPseudoClass::FocusWithin,
633
+ "fullscreen" => NonTSPseudoClass::Fullscreen,
634
+ "hover" => NonTSPseudoClass::Hover,
635
+ "indeterminate" => NonTSPseudoClass::Indeterminate,
636
+ "invalid" => NonTSPseudoClass::Invalid,
637
+ "link" => NonTSPseudoClass::Link,
638
+ "modal" => NonTSPseudoClass::Modal,
639
+ "open" => NonTSPseudoClass::Open,
640
+ "optional" => NonTSPseudoClass::Optional,
641
+ "out-of-range" => NonTSPseudoClass::OutOfRange,
642
+ "placeholder-shown" => NonTSPseudoClass::PlaceholderShown,
643
+ "popover-open" => NonTSPseudoClass::PopoverOpen,
644
+ "read-only" => NonTSPseudoClass::ReadOnly,
645
+ "read-write" => NonTSPseudoClass::ReadWrite,
646
+ "required" => NonTSPseudoClass::Required,
647
+ "target" => NonTSPseudoClass::Target,
648
+ "user-invalid" => NonTSPseudoClass::UserInvalid,
649
+ "user-valid" => NonTSPseudoClass::UserValid,
650
+ "valid" => NonTSPseudoClass::Valid,
651
+ "visited" => NonTSPseudoClass::Visited,
652
+ "-moz-meter-optimum" => NonTSPseudoClass::MozMeterOptimum,
653
+ "-moz-meter-sub-optimum" => NonTSPseudoClass::MozMeterSubOptimum,
654
+ "-moz-meter-sub-sub-optimum" => NonTSPseudoClass::MozMeterSubSubOptimum,
655
+ "-servo-nonzero-border" => {
656
+ if !self.in_user_agent_stylesheet() {
657
+ return Err(ParseError::custom(
658
+ SelectorParseErrorKind::UnexpectedIdent
659
+ ))
660
+ }
661
+ NonTSPseudoClass::ServoNonZeroBorder
662
+ },
663
+ _ => return Err(ParseError::custom(SelectorParseErrorKind::UnexpectedIdent)),
664
+ };
665
+
666
+ Ok(pseudo_class)
667
+ }
668
+
669
+ fn parse_non_ts_functional_pseudo_class(
670
+ &self,
671
+ name: CowRcStr<'i>,
672
+ parser: &mut CssParser<'i>,
673
+ after_part: bool,
674
+ ) -> Result<NonTSPseudoClass, ParseError> {
675
+ let pseudo_class = match_ignore_ascii_case! { &name,
676
+ "lang" if !after_part => {
677
+ NonTSPseudoClass::Lang(parser.expect_ident_or_string()?.as_ref().into())
678
+ },
679
+ "state" => {
680
+ let result = AtomIdent::from(parser.expect_ident()?.as_ref());
681
+ NonTSPseudoClass::CustomState(CustomState(result))
682
+ },
683
+ _ => return Err(ParseError::custom(SelectorParseErrorKind::UnexpectedIdent)),
684
+ };
685
+
686
+ Ok(pseudo_class)
687
+ }
688
+
689
+ fn parse_pseudo_element(&self, name: CowRcStr<'i>) -> Result<PseudoElement, ParseError> {
690
+ use self::PseudoElement::*;
691
+ let pseudo_element = match_ignore_ascii_case! { &name,
692
+ "before" => Before,
693
+ "after" => After,
694
+ "backdrop" => Backdrop,
695
+ "selection" => Selection,
696
+ "file-selector-button" => FileSelectorButton,
697
+ "first-letter" => FirstLetter,
698
+ "marker" => Marker,
699
+ "details-content" => DetailsContent,
700
+ "color-swatch" => ColorSwatch,
701
+ "placeholder" => Placeholder,
702
+ "-servo-text-control-inner-container" => {
703
+ if !self.in_user_agent_stylesheet() {
704
+ return Err(ParseError::custom(SelectorParseErrorKind::UnexpectedIdent))
705
+ }
706
+ ServoTextControlInnerContainer
707
+ },
708
+ "-servo-text-control-inner-editor" => {
709
+ if !self.in_user_agent_stylesheet() {
710
+ return Err(ParseError::custom(SelectorParseErrorKind::UnexpectedIdent))
711
+ }
712
+ ServoTextControlInnerEditor
713
+ },
714
+ "slider-fill" => SliderFill,
715
+ "slider-thumb" => SliderThumb,
716
+ "slider-track" => SliderTrack,
717
+ "-moz-progress-bar" => MozProgressBar,
718
+ "-servo-anonymous-box" => {
719
+ if !self.in_user_agent_stylesheet() {
720
+ return Err(ParseError::custom(SelectorParseErrorKind::UnexpectedIdent))
721
+ }
722
+ ServoAnonymousBox
723
+ },
724
+ "-servo-anonymous-table" => {
725
+ if !self.in_user_agent_stylesheet() {
726
+ return Err(ParseError::custom(SelectorParseErrorKind::UnexpectedIdent))
727
+ }
728
+ ServoAnonymousTable
729
+ },
730
+ "-servo-anonymous-table-row" => {
731
+ if !self.in_user_agent_stylesheet() {
732
+ return Err(ParseError::custom(SelectorParseErrorKind::UnexpectedIdent))
733
+ }
734
+ ServoAnonymousTableRow
735
+ },
736
+ "-servo-anonymous-table-cell" => {
737
+ if !self.in_user_agent_stylesheet() {
738
+ return Err(ParseError::custom(SelectorParseErrorKind::UnexpectedIdent))
739
+ }
740
+ ServoAnonymousTableCell
741
+ },
742
+ "-servo-table-grid" => {
743
+ if !self.in_user_agent_stylesheet() {
744
+ return Err(ParseError::custom(SelectorParseErrorKind::UnexpectedIdent))
745
+ }
746
+ ServoTableGrid
747
+ },
748
+ "-servo-table-wrapper" => {
749
+ if !self.in_user_agent_stylesheet() {
750
+ return Err(ParseError::custom(SelectorParseErrorKind::UnexpectedIdent))
751
+ }
752
+ ServoTableWrapper
753
+ },
754
+ _ => return Err(ParseError::custom(SelectorParseErrorKind::UnexpectedIdent))
755
+
756
+ };
757
+
758
+ Ok(pseudo_element)
759
+ }
760
+
761
+ fn default_namespace(&self) -> Option<Namespace> {
762
+ self.namespaces.default.as_ref().map(|ns| ns.clone())
763
+ }
764
+
765
+ fn namespace_for_prefix(&self, prefix: &Prefix) -> Option<Namespace> {
766
+ self.namespaces.prefixes.get(prefix).cloned()
767
+ }
768
+
769
+ fn parse_host(&self) -> bool {
770
+ true
771
+ }
772
+
773
+ fn parse_slotted(&self) -> bool {
774
+ true
775
+ }
776
+ }
777
+
778
+ impl SelectorImpl {
779
+ /// A helper to traverse each eagerly cascaded pseudo-element, executing
780
+ /// `fun` on it.
781
+ #[inline]
782
+ pub fn each_eagerly_cascaded_pseudo_element<F>(mut fun: F)
783
+ where
784
+ F: FnMut(PseudoElement),
785
+ {
786
+ for i in 0..EAGER_PSEUDO_COUNT {
787
+ fun(PseudoElement::from_eager_index(i));
788
+ }
789
+ }
790
+ }
791
+
792
+ /// A map from elements to snapshots for the Servo style back-end.
793
+ #[derive(Debug)]
794
+ pub struct SnapshotMap(FxHashMap<OpaqueNode, ServoElementSnapshot>);
795
+
796
+ impl SnapshotMap {
797
+ /// Create a new empty `SnapshotMap`.
798
+ pub fn new() -> Self {
799
+ SnapshotMap(FxHashMap::default())
800
+ }
801
+
802
+ /// Get a snapshot given an element.
803
+ pub fn get<T: TElement>(&self, el: &T) -> Option<&ServoElementSnapshot> {
804
+ self.0.get(&el.as_node().opaque())
805
+ }
806
+ }
807
+
808
+ impl Deref for SnapshotMap {
809
+ type Target = FxHashMap<OpaqueNode, ServoElementSnapshot>;
810
+
811
+ fn deref(&self) -> &Self::Target {
812
+ &self.0
813
+ }
814
+ }
815
+
816
+ impl DerefMut for SnapshotMap {
817
+ fn deref_mut(&mut self) -> &mut Self::Target {
818
+ &mut self.0
819
+ }
820
+ }
821
+
822
+ /// Servo's version of an element snapshot.
823
+ #[derive(Debug, Default, MallocSizeOf)]
824
+ pub struct ServoElementSnapshot {
825
+ /// The stored state of the element.
826
+ pub state: Option<ElementState>,
827
+ /// The set of stored attributes and its values.
828
+ pub attrs: Option<Vec<(AttrIdentifier, AttrValue)>>,
829
+ /// The set of changed attributes and its values.
830
+ pub changed_attrs: Vec<LocalName>,
831
+ /// Whether the class attribute changed or not.
832
+ pub class_changed: bool,
833
+ /// Whether the id attribute changed or not.
834
+ pub id_changed: bool,
835
+ /// Whether other attributes other than id or class changed or not.
836
+ pub other_attributes_changed: bool,
837
+ }
838
+
839
+ impl ServoElementSnapshot {
840
+ /// Create an empty element snapshot.
841
+ pub fn new() -> Self {
842
+ Self::default()
843
+ }
844
+
845
+ /// Returns whether the id attribute changed or not.
846
+ pub fn id_changed(&self) -> bool {
847
+ self.id_changed
848
+ }
849
+
850
+ /// Returns whether the class attribute changed or not.
851
+ pub fn class_changed(&self) -> bool {
852
+ self.class_changed
853
+ }
854
+
855
+ /// Returns whether other attributes other than id or class changed or not.
856
+ pub fn other_attr_changed(&self) -> bool {
857
+ self.other_attributes_changed
858
+ }
859
+
860
+ fn get_attr(&self, namespace: &Namespace, name: &LocalName) -> Option<&AttrValue> {
861
+ self.attrs
862
+ .as_ref()
863
+ .unwrap()
864
+ .iter()
865
+ .find(|&&(ref ident, _)| ident.local_name == *name && ident.namespace == *namespace)
866
+ .map(|&(_, ref v)| v)
867
+ }
868
+
869
+ /// Executes the callback once for each attribute that changed.
870
+ #[inline]
871
+ pub fn each_attr_changed<F>(&self, mut callback: F)
872
+ where
873
+ F: FnMut(&LocalName),
874
+ {
875
+ for name in &self.changed_attrs {
876
+ callback(name)
877
+ }
878
+ }
879
+
880
+ fn any_attr_ignore_ns<F>(&self, name: &LocalName, mut f: F) -> bool
881
+ where
882
+ F: FnMut(&AttrValue) -> bool,
883
+ {
884
+ self.attrs
885
+ .as_ref()
886
+ .unwrap()
887
+ .iter()
888
+ .any(|&(ref ident, ref v)| ident.local_name == *name && f(v))
889
+ }
890
+ }
891
+
892
+ impl ElementSnapshot for ServoElementSnapshot {
893
+ fn state(&self) -> Option<ElementState> {
894
+ self.state.clone()
895
+ }
896
+
897
+ fn has_attrs(&self) -> bool {
898
+ self.attrs.is_some()
899
+ }
900
+
901
+ fn id_attr(&self) -> Option<&Atom> {
902
+ self.get_attr(&ns!(), &local_name!("id"))
903
+ .map(|v| v.as_atom())
904
+ }
905
+
906
+ fn is_part(&self, part_name: &AtomIdent) -> bool {
907
+ self.get_attr(&ns!(), &local_name!("part"))
908
+ .is_some_and(|v| {
909
+ v.as_tokens()
910
+ .iter()
911
+ .any(|atom| CaseSensitivity::CaseSensitive.eq_atom(atom, part_name))
912
+ })
913
+ }
914
+
915
+ fn imported_part(&self, _: &AtomIdent) -> Option<AtomIdent> {
916
+ None
917
+ }
918
+
919
+ fn has_class(&self, name: &AtomIdent, case_sensitivity: CaseSensitivity) -> bool {
920
+ self.get_attr(&ns!(), &local_name!("class"))
921
+ .map_or(false, |v| {
922
+ v.as_tokens()
923
+ .iter()
924
+ .any(|atom| case_sensitivity.eq_atom(atom, name))
925
+ })
926
+ }
927
+
928
+ fn each_class<F>(&self, mut callback: F)
929
+ where
930
+ F: FnMut(&AtomIdent),
931
+ {
932
+ if let Some(v) = self.get_attr(&ns!(), &local_name!("class")) {
933
+ for class in v.as_tokens() {
934
+ callback(AtomIdent::cast(class));
935
+ }
936
+ }
937
+ }
938
+
939
+ fn lang_attr(&self) -> Option<SelectorAttrValue> {
940
+ self.get_attr(&ns!(xml), &local_name!("lang"))
941
+ .or_else(|| self.get_attr(&ns!(), &local_name!("lang")))
942
+ .map(|v| SelectorAttrValue::from(v as &str))
943
+ }
944
+
945
+ /// Returns true if the snapshot has stored state for custom states
946
+ #[inline]
947
+ fn has_custom_states(&self) -> bool {
948
+ false
949
+ }
950
+
951
+ /// Returns true if the snapshot has a given CustomState
952
+ #[inline]
953
+ fn has_custom_state(&self, _state: &AtomIdent) -> bool {
954
+ false
955
+ }
956
+
957
+ #[inline]
958
+ fn each_custom_state<F>(&self, mut _callback: F)
959
+ where
960
+ F: FnMut(&AtomIdent),
961
+ {
962
+ }
963
+ }
964
+
965
+ impl ServoElementSnapshot {
966
+ /// selectors::Element::attr_matches
967
+ pub fn attr_matches(
968
+ &self,
969
+ ns: &NamespaceConstraint<&Namespace>,
970
+ local_name: &LocalName,
971
+ operation: &AttrSelectorOperation<&AtomString>,
972
+ ) -> bool {
973
+ match *ns {
974
+ NamespaceConstraint::Specific(ref ns) => self
975
+ .get_attr(ns, local_name)
976
+ .map_or(false, |value| value.eval_selector(operation)),
977
+ NamespaceConstraint::Any => {
978
+ self.any_attr_ignore_ns(local_name, |value| value.eval_selector(operation))
979
+ },
980
+ }
981
+ }
982
+ }
983
+
984
+ /// Returns whether the language is matched, as defined by
985
+ /// [RFC 4647](https://tools.ietf.org/html/rfc4647#section-3.3.2).
986
+ pub fn extended_filtering(tag: &str, range: &str) -> bool {
987
+ range.split(',').any(|lang_range| {
988
+ // step 1
989
+ let mut range_subtags = lang_range.split('\x2d');
990
+ let mut tag_subtags = tag.split('\x2d');
991
+
992
+ // step 2
993
+ // Note: [Level-4 spec](https://drafts.csswg.org/selectors/#lang-pseudo) check for wild card
994
+ if let (Some(range_subtag), Some(tag_subtag)) = (range_subtags.next(), tag_subtags.next()) {
995
+ if !(range_subtag.eq_ignore_ascii_case(tag_subtag)
996
+ || range_subtag.eq_ignore_ascii_case("*"))
997
+ {
998
+ return false;
999
+ }
1000
+ }
1001
+
1002
+ let mut current_tag_subtag = tag_subtags.next();
1003
+
1004
+ // step 3
1005
+ for range_subtag in range_subtags {
1006
+ // step 3a
1007
+ if range_subtag == "*" {
1008
+ continue;
1009
+ }
1010
+ match current_tag_subtag.clone() {
1011
+ Some(tag_subtag) => {
1012
+ // step 3c
1013
+ if range_subtag.eq_ignore_ascii_case(tag_subtag) {
1014
+ current_tag_subtag = tag_subtags.next();
1015
+ continue;
1016
+ }
1017
+ // step 3d
1018
+ if tag_subtag.len() == 1 {
1019
+ return false;
1020
+ }
1021
+ // else step 3e - continue with loop
1022
+ current_tag_subtag = tag_subtags.next();
1023
+ if current_tag_subtag.is_none() {
1024
+ return false;
1025
+ }
1026
+ },
1027
+ // step 3b
1028
+ None => {
1029
+ return false;
1030
+ },
1031
+ }
1032
+ }
1033
+ // step 4
1034
+ true
1035
+ })
1036
+ }