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,658 @@
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
+ //! Style resolution for a given element or pseudo-element.
6
+
7
+ use crate::applicable_declarations::ApplicableDeclarationList;
8
+ use crate::computed_value_flags::ComputedValueFlags;
9
+ use crate::context::{CascadeInputs, ElementCascadeInputs, StyleContext};
10
+ use crate::data::{EagerPseudoStyles, ElementStyles};
11
+ use crate::dom::{TElement, TNode};
12
+ use crate::matching::MatchMethods;
13
+ use crate::properties::longhands::display::computed_value::T as Display;
14
+ use crate::properties::{ComputedValues, FirstLineReparenting};
15
+ use crate::rule_tree::{RuleCascadeFlags, RuleTree, StrongRuleNode};
16
+ use crate::selector_parser::{PseudoElement, SelectorImpl};
17
+ use crate::stylist::RuleInclusion;
18
+ use log::Level::Trace;
19
+ use selectors::matching::{
20
+ MatchingContext, MatchingForInvalidation, MatchingMode, NeedsSelectorFlags, VisitedHandlingMode,
21
+ };
22
+ #[cfg(feature = "gecko")]
23
+ use selectors::parser::PseudoElement as PseudoElementTrait;
24
+ use servo_arc::Arc;
25
+
26
+ /// Whether pseudo-elements should be resolved or not.
27
+ #[derive(Clone, Copy, Debug, Eq, PartialEq)]
28
+ pub enum PseudoElementResolution {
29
+ /// Only resolve pseudo-styles if possibly applicable.
30
+ IfApplicable,
31
+ /// Force pseudo-element resolution.
32
+ Force,
33
+ }
34
+
35
+ /// A struct that takes care of resolving the style of a given element.
36
+ pub struct StyleResolverForElement<'a, 'ctx, 'le, E>
37
+ where
38
+ 'ctx: 'a,
39
+ 'le: 'ctx,
40
+ E: TElement + MatchMethods + 'le,
41
+ {
42
+ element: E,
43
+ context: &'a mut StyleContext<'ctx, E>,
44
+ rule_inclusion: RuleInclusion,
45
+ pseudo_resolution: PseudoElementResolution,
46
+ _marker: ::std::marker::PhantomData<&'le E>,
47
+ }
48
+
49
+ struct MatchingResults {
50
+ rule_node: StrongRuleNode,
51
+ flags: ComputedValueFlags,
52
+ }
53
+
54
+ /// A style returned from the resolver machinery.
55
+ pub struct ResolvedStyle(pub Arc<ComputedValues>);
56
+
57
+ impl ResolvedStyle {
58
+ /// Convenience accessor for the style.
59
+ #[inline]
60
+ pub fn style(&self) -> &ComputedValues {
61
+ &self.0
62
+ }
63
+ }
64
+
65
+ /// The primary style of an element or an element-backed pseudo-element.
66
+ pub struct PrimaryStyle {
67
+ /// The style itself.
68
+ pub style: ResolvedStyle,
69
+ /// Whether the style was reused from another element via the rule node (see
70
+ /// `StyleSharingCache::lookup_by_rules`).
71
+ pub reused_via_rule_node: bool,
72
+ }
73
+
74
+ /// A set of style returned from the resolver machinery.
75
+ pub struct ResolvedElementStyles {
76
+ /// Primary style.
77
+ pub primary: PrimaryStyle,
78
+ /// Pseudo styles.
79
+ pub pseudos: EagerPseudoStyles,
80
+ }
81
+
82
+ impl ResolvedElementStyles {
83
+ /// Convenience accessor for the primary style.
84
+ pub fn primary_style(&self) -> &Arc<ComputedValues> {
85
+ &self.primary.style.0
86
+ }
87
+
88
+ /// Convenience mutable accessor for the style.
89
+ pub fn primary_style_mut(&mut self) -> &mut Arc<ComputedValues> {
90
+ &mut self.primary.style.0
91
+ }
92
+ }
93
+
94
+ impl PrimaryStyle {
95
+ /// Convenience accessor for the style.
96
+ pub fn style(&self) -> &ComputedValues {
97
+ &self.style.0
98
+ }
99
+ }
100
+
101
+ impl From<ResolvedElementStyles> for ElementStyles {
102
+ fn from(r: ResolvedElementStyles) -> ElementStyles {
103
+ ElementStyles {
104
+ primary: Some(r.primary.style.0),
105
+ pseudos: r.pseudos,
106
+ }
107
+ }
108
+ }
109
+
110
+ pub(crate) fn with_default_parent_styles<E, F, R>(element: E, f: F) -> R
111
+ where
112
+ E: TElement,
113
+ F: FnOnce(Option<&ComputedValues>, Option<&ComputedValues>) -> R,
114
+ {
115
+ let parent_el = element.inheritance_parent();
116
+ let parent_data = parent_el.as_ref().and_then(|e| e.borrow_data());
117
+ let parent_style = parent_data.as_ref().map(|d| d.styles.primary());
118
+
119
+ let mut layout_parent_el = parent_el;
120
+ let layout_parent_data;
121
+ let mut layout_parent_style = parent_style;
122
+ if parent_style.is_some_and(|s| s.is_display_contents()) {
123
+ layout_parent_el = Some(layout_parent_el.unwrap().layout_parent());
124
+ layout_parent_data = layout_parent_el.as_ref().unwrap().borrow_data().unwrap();
125
+ layout_parent_style = Some(layout_parent_data.styles.primary());
126
+ }
127
+
128
+ f(
129
+ parent_style.map(|x| &**x),
130
+ layout_parent_style.map(|s| &**s),
131
+ )
132
+ }
133
+
134
+ fn layout_parent_style_for_pseudo<'a>(
135
+ primary_style: &'a PrimaryStyle,
136
+ layout_parent_style: Option<&'a ComputedValues>,
137
+ ) -> Option<&'a ComputedValues> {
138
+ if primary_style.style().is_display_contents() {
139
+ layout_parent_style
140
+ } else {
141
+ Some(primary_style.style())
142
+ }
143
+ }
144
+
145
+ fn eager_pseudo_is_definitely_not_generated(
146
+ pseudo: &PseudoElement,
147
+ style: &ComputedValues,
148
+ ) -> bool {
149
+ if !pseudo.is_before_or_after() {
150
+ return false;
151
+ }
152
+
153
+ if style
154
+ .flags
155
+ .intersects(ComputedValueFlags::DISPLAY_OR_CONTENT_DEPEND_ON_INHERITED_STYLE)
156
+ {
157
+ return false;
158
+ }
159
+
160
+ style.get_box().clone_display() == Display::None || style.ineffective_content_property()
161
+ }
162
+
163
+ impl<'a, 'ctx, 'le, E> StyleResolverForElement<'a, 'ctx, 'le, E>
164
+ where
165
+ 'ctx: 'a,
166
+ 'le: 'ctx,
167
+ E: TElement + MatchMethods + 'le,
168
+ {
169
+ /// Trivially construct a new StyleResolverForElement.
170
+ pub fn new(
171
+ element: E,
172
+ context: &'a mut StyleContext<'ctx, E>,
173
+ rule_inclusion: RuleInclusion,
174
+ pseudo_resolution: PseudoElementResolution,
175
+ ) -> Self {
176
+ debug_assert_eq!(
177
+ element.as_node().depth(),
178
+ context.thread_local.current_dom_depth
179
+ );
180
+ Self {
181
+ element,
182
+ context,
183
+ rule_inclusion,
184
+ pseudo_resolution,
185
+ _marker: ::std::marker::PhantomData,
186
+ }
187
+ }
188
+
189
+ /// Resolve just the style of a given element.
190
+ pub fn resolve_primary_style(
191
+ &mut self,
192
+ parent_style: Option<&ComputedValues>,
193
+ layout_parent_style: Option<&ComputedValues>,
194
+ ) -> PrimaryStyle {
195
+ let primary_results = self.match_primary(VisitedHandlingMode::AllLinksUnvisited);
196
+
197
+ let inside_link = parent_style.is_some_and(|s| s.visited_style().is_some());
198
+
199
+ let visited_rules = if self.context.shared.visited_styles_enabled
200
+ && (inside_link || self.element.is_link())
201
+ {
202
+ if self.needs_visited_matching() {
203
+ let visited_matching_results =
204
+ self.match_primary(VisitedHandlingMode::RelevantLinkVisited);
205
+ Some(visited_matching_results.rule_node)
206
+ } else {
207
+ // Not `None`: the style sharing cache compares these against
208
+ // the candidate's visited rules, which are the same node.
209
+ Some(primary_results.rule_node.clone())
210
+ }
211
+ } else {
212
+ None
213
+ };
214
+
215
+ self.cascade_primary_style(
216
+ CascadeInputs {
217
+ rules: Some(primary_results.rule_node),
218
+ visited_rules,
219
+ flags: primary_results.flags,
220
+ included_cascade_flags: RuleCascadeFlags::empty(),
221
+ },
222
+ parent_style,
223
+ layout_parent_style,
224
+ )
225
+ }
226
+
227
+ /// Whether matching again with the relevant link treated as visited can give a different rule
228
+ /// node than the pass we already did.
229
+ ///
230
+ /// `:link` and `:visited` only match links, so for anything else other than them (and their
231
+ /// pseudo-elements), this needs a selector testing link state from a position that reaches a
232
+ /// non-link, like `a:visited span`.
233
+ fn needs_visited_matching(&self) -> bool {
234
+ if self.element.is_link() {
235
+ return true;
236
+ }
237
+ if self.element.implemented_pseudo_element().is_some()
238
+ && self
239
+ .element
240
+ .pseudo_element_originating_element()
241
+ .is_some_and(|e| e.is_link())
242
+ {
243
+ return true;
244
+ }
245
+ self.context
246
+ .shared
247
+ .stylist
248
+ .any_applicable_rule_data(self.element, |data| data.has_non_link_visited_dependency())
249
+ }
250
+
251
+ fn cascade_primary_style(
252
+ &mut self,
253
+ inputs: CascadeInputs,
254
+ parent_style: Option<&ComputedValues>,
255
+ layout_parent_style: Option<&ComputedValues>,
256
+ ) -> PrimaryStyle {
257
+ // Before doing the cascade, check the sharing cache and see if we can
258
+ // reuse the style via rule node identity.
259
+ let may_reuse = self.element.matches_user_and_content_rules()
260
+ && parent_style.is_some()
261
+ && inputs.rules.is_some()
262
+ && inputs.included_cascade_flags.is_empty();
263
+
264
+ if may_reuse {
265
+ let cached = self.context.thread_local.sharing_cache.lookup_by_rules(
266
+ self.context.shared,
267
+ parent_style.unwrap(),
268
+ &inputs,
269
+ self.element,
270
+ self.context.thread_local.current_dom_depth,
271
+ );
272
+ if let Some(mut primary_style) = cached {
273
+ self.context.thread_local.statistics.styles_reused += 1;
274
+ primary_style.reused_via_rule_node |= true;
275
+ return primary_style;
276
+ }
277
+ }
278
+
279
+ // No style to reuse. Cascade the style, starting with visited style
280
+ // if necessary.
281
+ PrimaryStyle {
282
+ style: self.cascade_style_and_visited(
283
+ inputs,
284
+ parent_style,
285
+ layout_parent_style,
286
+ /* pseudo = */ None,
287
+ ),
288
+ reused_via_rule_node: false,
289
+ }
290
+ }
291
+
292
+ /// Resolve the style of a given element, and all its eager pseudo-elements.
293
+ pub fn resolve_style(
294
+ &mut self,
295
+ parent_style: Option<&ComputedValues>,
296
+ layout_parent_style: Option<&ComputedValues>,
297
+ ) -> ResolvedElementStyles {
298
+ let primary_style = self.resolve_primary_style(parent_style, layout_parent_style);
299
+
300
+ let mut pseudo_styles = EagerPseudoStyles::default();
301
+
302
+ if self
303
+ .element
304
+ .implemented_pseudo_element()
305
+ .is_none_or(|p| p.is_element_backed())
306
+ {
307
+ let layout_parent_style_for_pseudo =
308
+ layout_parent_style_for_pseudo(&primary_style, layout_parent_style);
309
+ SelectorImpl::each_eagerly_cascaded_pseudo_element(|pseudo| {
310
+ let pseudo_style = self.resolve_pseudo_style(
311
+ &pseudo,
312
+ &primary_style,
313
+ layout_parent_style_for_pseudo,
314
+ );
315
+
316
+ if let Some(style) = pseudo_style {
317
+ if !matches!(self.pseudo_resolution, PseudoElementResolution::Force)
318
+ && eager_pseudo_is_definitely_not_generated(&pseudo, &style.0)
319
+ {
320
+ return;
321
+ }
322
+ pseudo_styles.set(&pseudo, style.0);
323
+ }
324
+ })
325
+ }
326
+
327
+ ResolvedElementStyles {
328
+ primary: primary_style,
329
+ pseudos: pseudo_styles,
330
+ }
331
+ }
332
+
333
+ /// Resolve an element's styles with the default inheritance parent/layout
334
+ /// parents.
335
+ pub fn resolve_style_with_default_parents(&mut self) -> ResolvedElementStyles {
336
+ with_default_parent_styles(self.element, |parent_style, layout_parent_style| {
337
+ self.resolve_style(parent_style, layout_parent_style)
338
+ })
339
+ }
340
+
341
+ /// Cascade a set of rules, using the default parent for inheritance.
342
+ pub fn cascade_style_and_visited_with_default_parents(
343
+ &mut self,
344
+ inputs: CascadeInputs,
345
+ ) -> ResolvedStyle {
346
+ with_default_parent_styles(self.element, |parent_style, layout_parent_style| {
347
+ self.cascade_style_and_visited(
348
+ inputs,
349
+ parent_style,
350
+ layout_parent_style,
351
+ /* pseudo = */ None,
352
+ )
353
+ })
354
+ }
355
+
356
+ /// Cascade a set of rules for pseudo element, using the default parent for inheritance.
357
+ pub fn cascade_style_and_visited_for_pseudo_with_default_parents(
358
+ &mut self,
359
+ inputs: CascadeInputs,
360
+ pseudo: &PseudoElement,
361
+ primary_style: &PrimaryStyle,
362
+ ) -> ResolvedStyle {
363
+ with_default_parent_styles(self.element, |_, layout_parent_style| {
364
+ let layout_parent_style_for_pseudo =
365
+ layout_parent_style_for_pseudo(primary_style, layout_parent_style);
366
+
367
+ self.cascade_style_and_visited(
368
+ inputs,
369
+ Some(primary_style.style()),
370
+ layout_parent_style_for_pseudo,
371
+ Some(pseudo),
372
+ )
373
+ })
374
+ }
375
+
376
+ fn cascade_style_and_visited(
377
+ &mut self,
378
+ inputs: CascadeInputs,
379
+ parent_style: Option<&ComputedValues>,
380
+ layout_parent_style: Option<&ComputedValues>,
381
+ pseudo: Option<&PseudoElement>,
382
+ ) -> ResolvedStyle {
383
+ debug_assert!(pseudo.is_none_or(|p| p.is_eager()));
384
+
385
+ let mut conditions = Default::default();
386
+ let values = self.context.shared.stylist.cascade_style_and_visited(
387
+ Some(self.element),
388
+ pseudo,
389
+ &inputs,
390
+ &self.context.shared.guards,
391
+ parent_style,
392
+ layout_parent_style,
393
+ FirstLineReparenting::No,
394
+ /* try_tactic = */ &Default::default(),
395
+ Some(&self.context.thread_local.rule_cache),
396
+ &mut conditions,
397
+ &mut self.context.thread_local.tree_counting_caches,
398
+ );
399
+
400
+ self.context.thread_local.rule_cache.insert_if_possible(
401
+ &self.context.shared.guards,
402
+ &values,
403
+ pseudo,
404
+ &inputs,
405
+ &conditions,
406
+ );
407
+
408
+ ResolvedStyle(values)
409
+ }
410
+
411
+ /// Cascade the element and pseudo-element styles with the default parents.
412
+ pub fn cascade_styles_with_default_parents(
413
+ &mut self,
414
+ inputs: ElementCascadeInputs,
415
+ ) -> ResolvedElementStyles {
416
+ with_default_parent_styles(self.element, move |parent_style, layout_parent_style| {
417
+ let primary_style =
418
+ self.cascade_primary_style(inputs.primary, parent_style, layout_parent_style);
419
+
420
+ let mut pseudo_styles = EagerPseudoStyles::default();
421
+ if let Some(mut pseudo_array) = inputs.pseudos.into_array() {
422
+ let layout_parent_style_for_pseudo = if primary_style.style().is_display_contents()
423
+ {
424
+ layout_parent_style
425
+ } else {
426
+ Some(primary_style.style())
427
+ };
428
+
429
+ for (i, inputs) in pseudo_array.iter_mut().enumerate() {
430
+ if let Some(inputs) = inputs.take() {
431
+ let pseudo = PseudoElement::from_eager_index(i);
432
+
433
+ let style = self.cascade_style_and_visited(
434
+ inputs,
435
+ Some(primary_style.style()),
436
+ layout_parent_style_for_pseudo,
437
+ Some(&pseudo),
438
+ );
439
+
440
+ if !matches!(self.pseudo_resolution, PseudoElementResolution::Force)
441
+ && eager_pseudo_is_definitely_not_generated(&pseudo, &style.0)
442
+ {
443
+ continue;
444
+ }
445
+
446
+ pseudo_styles.set(&pseudo, style.0);
447
+ }
448
+ }
449
+ }
450
+
451
+ ResolvedElementStyles {
452
+ primary: primary_style,
453
+ pseudos: pseudo_styles,
454
+ }
455
+ })
456
+ }
457
+
458
+ fn resolve_pseudo_style(
459
+ &mut self,
460
+ pseudo: &PseudoElement,
461
+ originating_element_style: &PrimaryStyle,
462
+ layout_parent_style: Option<&ComputedValues>,
463
+ ) -> Option<ResolvedStyle> {
464
+ let MatchingResults {
465
+ rule_node,
466
+ mut flags,
467
+ } = self.match_pseudo(
468
+ &originating_element_style.style.0,
469
+ pseudo,
470
+ VisitedHandlingMode::AllLinksUnvisited,
471
+ )?;
472
+
473
+ let mut visited_rules = None;
474
+ if originating_element_style.style().visited_style().is_some() {
475
+ visited_rules = self
476
+ .match_pseudo(
477
+ &originating_element_style.style.0,
478
+ pseudo,
479
+ VisitedHandlingMode::RelevantLinkVisited,
480
+ )
481
+ .map(|results| {
482
+ flags |= results.flags;
483
+ results.rule_node
484
+ });
485
+ }
486
+
487
+ Some(self.cascade_style_and_visited(
488
+ CascadeInputs {
489
+ rules: Some(rule_node),
490
+ visited_rules,
491
+ flags,
492
+ included_cascade_flags: RuleCascadeFlags::empty(),
493
+ },
494
+ Some(originating_element_style.style()),
495
+ layout_parent_style,
496
+ Some(pseudo),
497
+ ))
498
+ }
499
+
500
+ fn match_primary(&mut self, visited_handling: VisitedHandlingMode) -> MatchingResults {
501
+ debug!(
502
+ "Match primary for {:?}, visited: {:?}",
503
+ self.element, visited_handling
504
+ );
505
+ let mut applicable_declarations = ApplicableDeclarationList::new();
506
+
507
+ let bloom_filter = self.context.thread_local.bloom_filter.filter();
508
+ let selector_caches = &mut self.context.thread_local.selector_caches;
509
+ let mut matching_context = MatchingContext::new_for_visited(
510
+ MatchingMode::Normal,
511
+ Some(bloom_filter),
512
+ selector_caches,
513
+ visited_handling,
514
+ self.context.shared.quirks_mode(),
515
+ NeedsSelectorFlags::Yes,
516
+ MatchingForInvalidation::No,
517
+ );
518
+
519
+ let stylist = &self.context.shared.stylist;
520
+ // Compute the primary rule node.
521
+ stylist.push_applicable_declarations(
522
+ self.element,
523
+ None,
524
+ self.element.style_attribute(),
525
+ self.element.smil_override(),
526
+ self.element.animation_declarations(self.context.shared),
527
+ self.rule_inclusion,
528
+ &mut applicable_declarations,
529
+ &mut matching_context,
530
+ );
531
+
532
+ let rule_node = stylist
533
+ .rule_tree()
534
+ .compute_rule_node(&mut applicable_declarations, &self.context.shared.guards);
535
+
536
+ if log_enabled!(Trace) {
537
+ trace!("Matched rules for {:?}:", self.element);
538
+ for rn in rule_node.self_and_ancestors() {
539
+ let source = rn.style_source();
540
+ if source.is_some() {
541
+ trace!(" > {:?}", source);
542
+ }
543
+ }
544
+ }
545
+
546
+ MatchingResults {
547
+ rule_node,
548
+ flags: matching_context.extra_data.cascade_input_flags,
549
+ }
550
+ }
551
+
552
+ fn match_pseudo(
553
+ &mut self,
554
+ originating_element_style: &ComputedValues,
555
+ pseudo_element: &PseudoElement,
556
+ visited_handling: VisitedHandlingMode,
557
+ ) -> Option<MatchingResults> {
558
+ debug!(
559
+ "Match pseudo {:?} for {:?}, visited: {:?}",
560
+ self.element, pseudo_element, visited_handling
561
+ );
562
+ debug_assert!(pseudo_element.is_eager());
563
+
564
+ let mut applicable_declarations = ApplicableDeclarationList::new();
565
+
566
+ let stylist = &self.context.shared.stylist;
567
+
568
+ if !self
569
+ .element
570
+ .may_generate_pseudo(pseudo_element, originating_element_style)
571
+ {
572
+ return None;
573
+ }
574
+
575
+ let bloom_filter = self.context.thread_local.bloom_filter.filter();
576
+ let selector_caches = &mut self.context.thread_local.selector_caches;
577
+
578
+ let mut matching_context = MatchingContext::<'_, E::Impl>::new_for_visited(
579
+ MatchingMode::ForStatelessPseudoElement,
580
+ Some(bloom_filter),
581
+ selector_caches,
582
+ visited_handling,
583
+ self.context.shared.quirks_mode(),
584
+ NeedsSelectorFlags::Yes,
585
+ MatchingForInvalidation::No,
586
+ );
587
+ matching_context.extra_data.originating_element_style = Some(originating_element_style);
588
+
589
+ // NB: We handle animation rules for ::before and ::after when
590
+ // traversing them.
591
+ stylist.push_applicable_declarations(
592
+ self.element,
593
+ Some(pseudo_element),
594
+ None,
595
+ None,
596
+ /* animation_declarations = */ Default::default(),
597
+ self.rule_inclusion,
598
+ &mut applicable_declarations,
599
+ &mut matching_context,
600
+ );
601
+
602
+ if applicable_declarations.is_empty() {
603
+ return None;
604
+ }
605
+
606
+ let rule_node = stylist
607
+ .rule_tree()
608
+ .compute_rule_node(&mut applicable_declarations, &self.context.shared.guards);
609
+
610
+ Some(MatchingResults {
611
+ rule_node,
612
+ flags: matching_context.extra_data.cascade_input_flags,
613
+ })
614
+ }
615
+
616
+ /// Resolve the starting style by recascading with @starting-style rules included, similar to
617
+ /// how after_change_style works.
618
+ pub fn resolve_starting_style(
619
+ &mut self,
620
+ primary_style: &Arc<ComputedValues>,
621
+ ) -> Option<ResolvedStyle> {
622
+ if !RuleTree::has_starting_style(primary_style.rules()) {
623
+ return None;
624
+ }
625
+ let inputs = CascadeInputs {
626
+ rules: Some(primary_style.rules().clone()),
627
+ visited_rules: primary_style.visited_rules().cloned(),
628
+ flags: primary_style.flags.for_cascade_inputs(),
629
+ included_cascade_flags: RuleCascadeFlags::STARTING_STYLE,
630
+ };
631
+ Some(self.cascade_style_and_visited_with_default_parents(inputs))
632
+ }
633
+
634
+ /// If there is no transition rule in the ComputedValues, it returns None.
635
+ pub fn after_change_style(
636
+ &mut self,
637
+ primary_style: &Arc<ComputedValues>,
638
+ ) -> Option<Arc<ComputedValues>> {
639
+ let rule_node = primary_style.rules();
640
+ let without_transition_rules = RuleTree::remove_transition_rule_if_applicable(rule_node);
641
+ if without_transition_rules == *rule_node {
642
+ // We don't have transition rule in this case, so return None to let
643
+ // the caller use the original ComputedValues.
644
+ return None;
645
+ }
646
+
647
+ // FIXME(bug 868975): We probably need to transition visited style as well.
648
+ let inputs = CascadeInputs {
649
+ rules: Some(without_transition_rules),
650
+ visited_rules: primary_style.visited_rules().cloned(),
651
+ flags: primary_style.flags.for_cascade_inputs(),
652
+ included_cascade_flags: RuleCascadeFlags::empty(),
653
+ };
654
+
655
+ let style = self.cascade_style_and_visited_with_default_parents(inputs);
656
+ Some(style.0)
657
+ }
658
+ }