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,511 @@
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
+ //! A [`@scope`][scope] rule.
6
+ //!
7
+ //! [scope]: https://drafts.csswg.org/css-cascade-6/#scoped-styles
8
+
9
+ use crate::applicable_declarations::ScopeProximity;
10
+ use crate::derives::*;
11
+ use crate::dom::TElement;
12
+ use crate::parser::ParserContext;
13
+ use crate::selector_parser::{SelectorImpl, SelectorParser};
14
+ use crate::shared_lock::{
15
+ DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard,
16
+ };
17
+ use crate::simple_buckets_map::SimpleBucketsMap;
18
+ use crate::stylesheets::CssRules;
19
+ use cssparser::{Parser, SourceLocation, ToCss};
20
+ #[cfg(feature = "gecko")]
21
+ use malloc_size_of::{
22
+ MallocSizeOfOps, MallocUnconditionalShallowSizeOf, MallocUnconditionalSizeOf,
23
+ };
24
+ use selectors::context::{MatchingContext, QuirksMode};
25
+ use selectors::matching::matches_selector;
26
+ use selectors::parser::{Component, ParseRelative, Selector, SelectorList};
27
+ use selectors::OpaqueElement;
28
+ use servo_arc::Arc;
29
+ use std::fmt::{self, Write};
30
+ use style_traits::{CssStringWriter, CssWriter, ParseError};
31
+
32
+ /// A scoped rule.
33
+ #[derive(Debug, ToShmem)]
34
+ pub struct ScopeRule {
35
+ /// Bounds at which this rule applies.
36
+ pub bounds: ScopeBounds,
37
+ /// The nested rules inside the block.
38
+ pub rules: Arc<Locked<CssRules>>,
39
+ /// The source position where this rule was found.
40
+ pub source_location: SourceLocation,
41
+ }
42
+
43
+ impl DeepCloneWithLock for ScopeRule {
44
+ fn deep_clone_with_lock(&self, lock: &SharedRwLock, guard: &SharedRwLockReadGuard) -> Self {
45
+ let rules = self.rules.read_with(guard);
46
+ Self {
47
+ bounds: self.bounds.clone(),
48
+ rules: Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard))),
49
+ source_location: self.source_location,
50
+ }
51
+ }
52
+ }
53
+
54
+ impl ToCssWithGuard for ScopeRule {
55
+ fn to_css(&self, guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result {
56
+ dest.write_str("@scope")?;
57
+ {
58
+ let mut writer = CssWriter::new(dest);
59
+ if let Some(start) = self.bounds.start.as_ref() {
60
+ writer.write_str(" (")?;
61
+ start.to_css(&mut writer)?;
62
+ writer.write_char(')')?;
63
+ }
64
+ if let Some(end) = self.bounds.end.as_ref() {
65
+ writer.write_str(" to (")?;
66
+ end.to_css(&mut writer)?;
67
+ writer.write_char(')')?;
68
+ }
69
+ }
70
+ self.rules.read_with(guard).to_css_block(guard, dest)
71
+ }
72
+ }
73
+
74
+ impl ScopeRule {
75
+ /// Measure heap usage.
76
+ #[cfg(feature = "gecko")]
77
+ pub fn size_of(&self, guard: &SharedRwLockReadGuard, ops: &mut MallocSizeOfOps) -> usize {
78
+ self.rules.unconditional_shallow_size_of(ops)
79
+ + self.rules.read_with(guard).size_of(guard, ops)
80
+ + self.bounds.size_of(ops)
81
+ }
82
+ }
83
+
84
+ /// Bounds of the scope.
85
+ #[derive(Debug, Clone, ToShmem)]
86
+ pub struct ScopeBounds {
87
+ /// Start of the scope.
88
+ pub start: Option<SelectorList<SelectorImpl>>,
89
+ /// End of the scope.
90
+ pub end: Option<SelectorList<SelectorImpl>>,
91
+ }
92
+
93
+ impl ScopeBounds {
94
+ #[cfg(feature = "gecko")]
95
+ fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
96
+ fn bound_size_of(
97
+ bound: &Option<SelectorList<SelectorImpl>>,
98
+ ops: &mut MallocSizeOfOps,
99
+ ) -> usize {
100
+ bound
101
+ .as_ref()
102
+ .map(|list| list.unconditional_size_of(ops))
103
+ .unwrap_or(0)
104
+ }
105
+ bound_size_of(&self.start, ops) + bound_size_of(&self.end, ops)
106
+ }
107
+ }
108
+
109
+ fn parse_scope(
110
+ context: &ParserContext,
111
+ input: &mut Parser,
112
+ parse_relative: ParseRelative,
113
+ for_end: bool,
114
+ ) -> Result<Option<SelectorList<SelectorImpl>>, ParseError> {
115
+ input.try_parse(|input| {
116
+ if for_end {
117
+ // scope-end not existing is valid.
118
+ if input.try_parse(|i| i.expect_ident_matching("to")).is_err() {
119
+ return Ok(None);
120
+ }
121
+ }
122
+ let parens = input.try_parse(|i| i.expect_parenthesis_block());
123
+ if for_end {
124
+ // `@scope to {}` is NOT valid.
125
+ parens?;
126
+ } else if parens.is_err() {
127
+ // `@scope {}` is valid.
128
+ return Ok(None);
129
+ }
130
+ input.parse_nested_block(|input| {
131
+ let selector_parser = SelectorParser {
132
+ stylesheet_origin: context.stylesheet_origin,
133
+ namespaces: &context.namespaces,
134
+ url_data: context.url_data,
135
+ for_supports_rule: false,
136
+ };
137
+ let parse_relative = if for_end {
138
+ ParseRelative::ForScope
139
+ } else {
140
+ parse_relative
141
+ };
142
+ Ok(Some(SelectorList::parse_disallow_pseudo(
143
+ &selector_parser,
144
+ input,
145
+ parse_relative,
146
+ )?))
147
+ })
148
+ })
149
+ }
150
+
151
+ impl ScopeBounds {
152
+ /// Parse a container condition.
153
+ pub fn parse(
154
+ context: &ParserContext,
155
+ input: &mut Parser,
156
+ parse_relative: ParseRelative,
157
+ ) -> Result<Self, ParseError> {
158
+ let start = parse_scope(context, input, parse_relative, false)?;
159
+ let end = parse_scope(context, input, parse_relative, true)?;
160
+ Ok(Self { start, end })
161
+ }
162
+ }
163
+
164
+ /// Types of implicit scope root.
165
+ #[derive(Debug, Copy, Clone, MallocSizeOf)]
166
+ pub enum ImplicitScopeRoot {
167
+ /// This implicit scope root is in the light tree.
168
+ InLightTree(OpaqueElement),
169
+ /// This implicit scope root is the document element, regardless of which (light|shadow) tree
170
+ /// the element being matched is. This is the case for e.g. if you specified an implicit scope
171
+ /// within a user stylesheet.
172
+ DocumentElement,
173
+ /// The implicit scope root is in a constructed stylesheet - the scope root the element
174
+ /// under consideration's shadow root (If one exists).
175
+ Constructed,
176
+ /// This implicit scope root is in the shadow tree.
177
+ InShadowTree(OpaqueElement),
178
+ /// This implicit scope root is the shadow host of the stylesheet-containing shadow tree.
179
+ ShadowHost(OpaqueElement),
180
+ }
181
+
182
+ impl ImplicitScopeRoot {
183
+ /// Return true if this matches the shadow host.
184
+ pub fn matches_shadow_host(&self) -> bool {
185
+ match self {
186
+ Self::InLightTree(..) | Self::InShadowTree(..) | Self::DocumentElement => false,
187
+ Self::ShadowHost(..) | Self::Constructed => true,
188
+ }
189
+ }
190
+
191
+ /// Return the implicit scope root element.
192
+ pub fn element(&self, current_host: Option<OpaqueElement>) -> ImplicitScopeTarget {
193
+ match self {
194
+ Self::InLightTree(e) | Self::InShadowTree(e) | Self::ShadowHost(e) => {
195
+ ImplicitScopeTarget::Element(*e)
196
+ },
197
+ Self::Constructed | Self::DocumentElement => {
198
+ if matches!(self, Self::Constructed) {
199
+ if let Some(host) = current_host {
200
+ return ImplicitScopeTarget::Element(host);
201
+ }
202
+ }
203
+ ImplicitScopeTarget::DocumentElement
204
+ },
205
+ }
206
+ }
207
+ }
208
+
209
+ /// Target of this implicit scope.
210
+ pub enum ImplicitScopeTarget {
211
+ /// Target matches only the specified element.
212
+ Element(OpaqueElement),
213
+ /// Implicit scope whose target is the document element.
214
+ DocumentElement,
215
+ }
216
+
217
+ impl ImplicitScopeTarget {
218
+ /// Check if this element is the implicit scope.
219
+ fn check<E: TElement>(&self, element: E) -> bool {
220
+ match self {
221
+ Self::Element(e) => element.opaque() == *e,
222
+ Self::DocumentElement => element.is_root(),
223
+ }
224
+ }
225
+ }
226
+
227
+ /// Target of this scope.
228
+ pub enum ScopeTarget<'a> {
229
+ /// Target matches an element matching the specified selector list.
230
+ Selector(&'a SelectorList<SelectorImpl>),
231
+ /// Target matches an implicit scope target.
232
+ Implicit(ImplicitScopeTarget),
233
+ }
234
+
235
+ impl<'a> ScopeTarget<'a> {
236
+ /// Check if the given element is the scope.
237
+ fn check<E: TElement>(
238
+ &self,
239
+ element: E,
240
+ scope: Option<OpaqueElement>,
241
+ scope_subject_map: &ScopeSubjectMap,
242
+ context: &mut MatchingContext<E::Impl>,
243
+ ) -> bool {
244
+ match self {
245
+ Self::Selector(list) => context.nest_for_scope_condition(scope, |context| {
246
+ if scope_subject_map.early_reject(element, context.quirks_mode()) {
247
+ return false;
248
+ }
249
+ for selector in list.slice().iter() {
250
+ if matches_selector(selector, 0, None, &element, context) {
251
+ return true;
252
+ }
253
+ }
254
+ false
255
+ }),
256
+ Self::Implicit(t) => t.check(element),
257
+ }
258
+ }
259
+ }
260
+
261
+ /// A scope root candidate.
262
+ #[derive(Clone, Copy, Debug)]
263
+ pub struct ScopeRootCandidate {
264
+ /// This candidate's scope root.
265
+ pub root: OpaqueElement,
266
+ /// Ancestor hop from the element under consideration to this scope root.
267
+ pub proximity: ScopeProximity,
268
+ }
269
+
270
+ impl ScopeRootCandidate {
271
+ /// Get the element corresponding to this scope root candidate.
272
+ pub fn get_scope_root_element<E>(&self, originating_element: E) -> Option<E>
273
+ where
274
+ E: TElement,
275
+ {
276
+ // Could just unsafe-convert from opaque element - technically
277
+ // faster as well, but it doesn't seem worth having to manually
278
+ // assure safety every time.
279
+ let mut e = originating_element;
280
+ let hops = self.proximity.get()?;
281
+ for _ in 0..hops {
282
+ e = e.parent_element()?;
283
+ }
284
+ debug_assert_eq!(e.opaque(), self.root);
285
+ Some(e)
286
+ }
287
+ }
288
+
289
+ /// Collect potential scope roots for a given element and its scope target.
290
+ /// The check may not pass the ceiling, if specified.
291
+ pub fn collect_scope_roots<E>(
292
+ element: E,
293
+ ceiling: Option<OpaqueElement>,
294
+ context: &mut MatchingContext<E::Impl>,
295
+ target: &ScopeTarget,
296
+ matches_shadow_host: bool,
297
+ scope_subject_map: &ScopeSubjectMap,
298
+ ) -> Vec<ScopeRootCandidate>
299
+ where
300
+ E: TElement,
301
+ {
302
+ let mut result = vec![];
303
+ let mut parent = Some(element);
304
+ let mut proximity = 0usize;
305
+ while let Some(p) = parent {
306
+ if target.check(p, ceiling, scope_subject_map, context) {
307
+ result.push(ScopeRootCandidate {
308
+ root: p.opaque(),
309
+ proximity: ScopeProximity::new(proximity),
310
+ });
311
+ // Note that we can't really break here - we need to consider
312
+ // ALL scope roots to figure out whch one didn't end.
313
+ }
314
+ if ceiling == Some(p.opaque()) {
315
+ break;
316
+ }
317
+ parent = p.parent_element();
318
+ proximity += 1;
319
+ // We we got to the top of the shadow tree - keep going
320
+ // if we may match the shadow host.
321
+ if parent.is_none() && matches_shadow_host {
322
+ parent = p.containing_shadow_host();
323
+ }
324
+ }
325
+ result
326
+ }
327
+
328
+ /// Given the scope-end selector, check if the element is outside of the scope.
329
+ /// That is, check if any ancestor to the root matches the scope-end selector.
330
+ pub fn element_is_outside_of_scope<E>(
331
+ selector: &Selector<E::Impl>,
332
+ element: E,
333
+ root: OpaqueElement,
334
+ context: &mut MatchingContext<E::Impl>,
335
+ root_may_be_shadow_host: bool,
336
+ ) -> bool
337
+ where
338
+ E: TElement,
339
+ {
340
+ let mut parent = Some(element);
341
+ context.nest_for_scope_condition(Some(root), |context| {
342
+ while let Some(p) = parent {
343
+ if matches_selector(selector, 0, None, &p, context) {
344
+ return true;
345
+ }
346
+ if p.opaque() == root {
347
+ // Reached the top, not lying outside of scope.
348
+ break;
349
+ }
350
+ parent = p.parent_element();
351
+ if parent.is_none() && root_may_be_shadow_host {
352
+ if let Some(host) = p.containing_shadow_host() {
353
+ // Pretty much an edge case where user specified scope-start and -end of :host
354
+ return host.opaque() == root;
355
+ }
356
+ }
357
+ }
358
+ false
359
+ })
360
+ }
361
+
362
+ /// A map containing simple selectors in subjects of scope selectors.
363
+ /// This allows fast-rejecting scopes before running the full match.
364
+ #[derive(Clone, Debug, Default, MallocSizeOf)]
365
+ pub struct ScopeSubjectMap {
366
+ buckets: SimpleBucketsMap<()>,
367
+ any: bool,
368
+ }
369
+
370
+ impl ScopeSubjectMap {
371
+ /// Add the `<scope-start>` of a scope.
372
+ pub fn add_bound_start(
373
+ &mut self,
374
+ selectors: &SelectorList<SelectorImpl>,
375
+ quirks_mode: QuirksMode,
376
+ ) {
377
+ if self.add_selector_list(selectors, quirks_mode) {
378
+ self.any = true;
379
+ }
380
+ }
381
+
382
+ fn add_selector_list(
383
+ &mut self,
384
+ selectors: &SelectorList<SelectorImpl>,
385
+ quirks_mode: QuirksMode,
386
+ ) -> bool {
387
+ let mut is_any = false;
388
+ for selector in selectors.slice().iter() {
389
+ is_any = is_any || self.add_selector(selector, quirks_mode);
390
+ }
391
+ is_any
392
+ }
393
+
394
+ fn add_selector(&mut self, selector: &Selector<SelectorImpl>, quirks_mode: QuirksMode) -> bool {
395
+ let mut is_any = true;
396
+ let iter = selector.iter();
397
+ for c in iter {
398
+ let component_any = match c {
399
+ Component::Class(cls) => {
400
+ match self.buckets.classes.try_entry(cls.0.clone(), quirks_mode) {
401
+ Ok(e) => {
402
+ e.or_insert(());
403
+ false
404
+ },
405
+ Err(_) => true,
406
+ }
407
+ },
408
+ Component::ID(id) => match self.buckets.ids.try_entry(id.0.clone(), quirks_mode) {
409
+ Ok(e) => {
410
+ e.or_insert(());
411
+ false
412
+ },
413
+ Err(_) => true,
414
+ },
415
+ Component::LocalName(local_name) => {
416
+ self.buckets
417
+ .local_names
418
+ .insert(local_name.lower_name.clone(), ());
419
+ false
420
+ },
421
+ Component::Is(list) | Component::Where(list) => {
422
+ self.add_selector_list(list, quirks_mode)
423
+ },
424
+ _ => true,
425
+ };
426
+
427
+ is_any = is_any && component_any;
428
+ }
429
+ is_any
430
+ }
431
+
432
+ /// Shrink the map as much as possible.
433
+ pub fn shrink_if_needed(&mut self) {
434
+ self.buckets.shrink_if_needed();
435
+ }
436
+
437
+ /// Clear the map.
438
+ pub fn clear(&mut self) {
439
+ self.buckets.clear();
440
+ self.any = false;
441
+ }
442
+
443
+ /// Could a given element possibly be a scope root?
444
+ fn early_reject<E: TElement>(&self, element: E, quirks_mode: QuirksMode) -> bool {
445
+ if self.any {
446
+ return false;
447
+ }
448
+
449
+ if let Some(id) = element.id() {
450
+ if self.buckets.ids.get(id, quirks_mode).is_some() {
451
+ return false;
452
+ }
453
+ }
454
+
455
+ let mut found = false;
456
+ element.each_class(|cls| {
457
+ if self.buckets.classes.get(cls, quirks_mode).is_some() {
458
+ found = true;
459
+ }
460
+ });
461
+ if found {
462
+ return false;
463
+ }
464
+
465
+ if self.buckets.local_names.get(element.local_name()).is_some() {
466
+ return false;
467
+ }
468
+
469
+ true
470
+ }
471
+ }
472
+
473
+ /// Determine if this selector list, when used as a scope bound selector, is considered trivial.
474
+ pub fn scope_selector_list_is_trivial(list: &SelectorList<SelectorImpl>) -> bool {
475
+ fn scope_selector_is_trivial(selector: &Selector<SelectorImpl>) -> bool {
476
+ // A selector is trivial if:
477
+ // * There is no selector conditional on its siblings and/or descendant to match, and
478
+ // * There is no dependency on sibling relations, and
479
+ // * There's no ID selector in the selector. A more correct approach may be to ensure that
480
+ // scoping roots of the style sharing candidates and targets have matching IDs, but that
481
+ // requires re-plumbing what we pass around for scope roots.
482
+ let mut iter = selector.iter();
483
+ loop {
484
+ for c in iter.by_ref() {
485
+ match c {
486
+ Component::ID(_)
487
+ | Component::Nth(_)
488
+ | Component::NthOf(_)
489
+ | Component::Has(_) => return false,
490
+ Component::Is(list) | Component::Where(list) | Component::Negation(list) => {
491
+ if !scope_selector_list_is_trivial(list) {
492
+ return false;
493
+ }
494
+ },
495
+ _ => (),
496
+ }
497
+ }
498
+
499
+ match iter.next_sequence() {
500
+ Some(c) => {
501
+ if c.is_sibling() {
502
+ return false;
503
+ }
504
+ },
505
+ None => return true,
506
+ }
507
+ }
508
+ }
509
+
510
+ list.slice().iter().all(scope_selector_is_trivial)
511
+ }
@@ -0,0 +1,54 @@
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
+ //! before-change style: the `@starting-style` rules.
6
+ //! https://drafts.csswg.org/css-transitions-2/#defining-before-change-style
7
+
8
+ use crate::derives::*;
9
+ use crate::shared_lock::{DeepCloneWithLock, Locked};
10
+ use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
11
+ use crate::stylesheets::CssRules;
12
+ use cssparser::SourceLocation;
13
+ #[cfg(feature = "gecko")]
14
+ use malloc_size_of::{MallocSizeOfOps, MallocUnconditionalShallowSizeOf};
15
+ use servo_arc::Arc;
16
+ use std::fmt::{self, Debug, Write};
17
+ use style_traits::CssStringWriter;
18
+
19
+ /// A [`@starting-style`][starting-style] rule.
20
+ ///
21
+ /// [starting-style]: https://drafts.csswg.org/css-transitions-2/#at-ruledef-starting-style
22
+ #[derive(Debug, ToShmem)]
23
+ pub struct StartingStyleRule {
24
+ /// The nested rules to this starting-style rule.
25
+ pub rules: Arc<Locked<CssRules>>,
26
+ /// The source position where this starting-style rule was found.
27
+ pub source_location: SourceLocation,
28
+ }
29
+
30
+ impl StartingStyleRule {
31
+ /// Measure heap usage.
32
+ #[cfg(feature = "gecko")]
33
+ pub fn size_of(&self, guard: &SharedRwLockReadGuard, ops: &mut MallocSizeOfOps) -> usize {
34
+ self.rules.unconditional_shallow_size_of(ops)
35
+ + self.rules.read_with(guard).size_of(guard, ops)
36
+ }
37
+ }
38
+
39
+ impl ToCssWithGuard for StartingStyleRule {
40
+ fn to_css(&self, guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result {
41
+ dest.write_str("@starting-style")?;
42
+ self.rules.read_with(guard).to_css_block(guard, dest)
43
+ }
44
+ }
45
+
46
+ impl DeepCloneWithLock for StartingStyleRule {
47
+ fn deep_clone_with_lock(&self, lock: &SharedRwLock, guard: &SharedRwLockReadGuard) -> Self {
48
+ let rules = self.rules.read_with(guard);
49
+ StartingStyleRule {
50
+ rules: Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard))),
51
+ source_location: self.source_location,
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,80 @@
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
+ //! A style rule.
6
+
7
+ use crate::derives::*;
8
+ use crate::properties::PropertyDeclarationBlock;
9
+ use crate::selector_parser::SelectorImpl;
10
+ use crate::shared_lock::{
11
+ DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard,
12
+ };
13
+ use crate::stylesheets::{style_or_page_rule_to_css, CssRules};
14
+ use cssparser::SourceLocation;
15
+ #[cfg(feature = "gecko")]
16
+ use malloc_size_of::{
17
+ MallocSizeOf, MallocSizeOfOps, MallocUnconditionalShallowSizeOf, MallocUnconditionalSizeOf,
18
+ };
19
+ use selectors::SelectorList;
20
+ use servo_arc::Arc;
21
+ use std::fmt::{self, Write};
22
+ use style_traits::CssStringWriter;
23
+
24
+ /// A style rule, with selectors and declarations.
25
+ #[derive(Debug, ToShmem)]
26
+ pub struct StyleRule {
27
+ /// The list of selectors in this rule.
28
+ pub selectors: SelectorList<SelectorImpl>,
29
+ /// The declaration block with the properties it contains.
30
+ pub block: Arc<Locked<PropertyDeclarationBlock>>,
31
+ /// The nested rules to this style rule. Only non-`None` when nesting is enabled.
32
+ pub rules: Option<Arc<Locked<CssRules>>>,
33
+ /// The location in the sheet where it was found.
34
+ pub source_location: SourceLocation,
35
+ }
36
+
37
+ impl DeepCloneWithLock for StyleRule {
38
+ /// Deep clones this StyleRule.
39
+ fn deep_clone_with_lock(
40
+ &self,
41
+ lock: &SharedRwLock,
42
+ guard: &SharedRwLockReadGuard,
43
+ ) -> StyleRule {
44
+ StyleRule {
45
+ selectors: self.selectors.clone(),
46
+ block: Arc::new(lock.wrap(self.block.read_with(guard).clone())),
47
+ rules: self.rules.as_ref().map(|rules| {
48
+ let rules = rules.read_with(guard);
49
+ Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard)))
50
+ }),
51
+ source_location: self.source_location,
52
+ }
53
+ }
54
+ }
55
+
56
+ impl StyleRule {
57
+ /// Measure heap usage.
58
+ #[cfg(feature = "gecko")]
59
+ pub fn size_of(&self, guard: &SharedRwLockReadGuard, ops: &mut MallocSizeOfOps) -> usize {
60
+ let mut n = 0;
61
+ n += self.selectors.unconditional_size_of(ops);
62
+ n += self.block.unconditional_shallow_size_of(ops)
63
+ + self.block.read_with(guard).size_of(ops);
64
+ if let Some(ref rules) = self.rules {
65
+ n += rules.unconditional_shallow_size_of(ops)
66
+ + rules.read_with(guard).size_of(guard, ops)
67
+ }
68
+ n
69
+ }
70
+ }
71
+
72
+ impl ToCssWithGuard for StyleRule {
73
+ /// https://drafts.csswg.org/cssom/#serialize-a-css-rule CSSStyleRule
74
+ fn to_css(&self, guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result {
75
+ use cssparser::ToCss;
76
+ self.selectors.to_css(dest)?;
77
+ dest.write_char(' ')?;
78
+ style_or_page_rule_to_css(self.rules.as_ref(), &self.block, guard, dest)
79
+ }
80
+ }