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,693 @@
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
+ //! Per-node data used in style calculation.
6
+
7
+ use crate::computed_value_flags::ComputedValueFlags;
8
+ use crate::context::{SharedStyleContext, StackLimitChecker};
9
+ use crate::dom::TElement;
10
+ use crate::invalidation::element::invalidator::InvalidationResult;
11
+ use crate::invalidation::element::restyle_hints::RestyleHint;
12
+ use crate::properties::ComputedValues;
13
+ use crate::selector_parser::{PseudoElement, RestyleDamage, EAGER_PSEUDO_COUNT};
14
+ use crate::style_resolver::{PrimaryStyle, ResolvedElementStyles, ResolvedStyle};
15
+ use crate::values::specified::TreeCountingFunction;
16
+ #[cfg(feature = "gecko")]
17
+ use malloc_size_of::MallocSizeOfOps;
18
+ use selectors::matching::SelectorCaches;
19
+ use servo_arc::Arc;
20
+ use std::ops::{Deref, DerefMut};
21
+ use std::{fmt, mem};
22
+
23
+ #[cfg(debug_assertions)]
24
+ use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
25
+
26
+ bitflags! {
27
+ /// Various flags stored on ElementData.
28
+ #[derive(Debug, Default)]
29
+ pub struct ElementDataFlags: u8 {
30
+ /// Whether the styles changed for this restyle.
31
+ const WAS_RESTYLED = 1 << 0;
32
+ /// Whether the last traversal of this element did not do
33
+ /// any style computation. This is not true during the initial
34
+ /// styling pass, nor is it true when we restyle (in which case
35
+ /// WAS_RESTYLED is set).
36
+ ///
37
+ /// This bit always corresponds to the last time the element was
38
+ /// traversed, so each traversal simply updates it with the appropriate
39
+ /// value.
40
+ const TRAVERSED_WITHOUT_STYLING = 1 << 1;
41
+
42
+ /// Whether the primary style of this element data was reused from
43
+ /// another element via a rule node comparison. This allows us to
44
+ /// differentiate between elements that shared styles because they met
45
+ /// all the criteria of the style sharing cache, compared to elements
46
+ /// that reused style structs via rule node identity.
47
+ ///
48
+ /// The former gives us stronger transitive guarantees that allows us to
49
+ /// apply the style sharing cache to cousins.
50
+ const PRIMARY_STYLE_REUSED_VIA_RULE_NODE = 1 << 2;
51
+ }
52
+ }
53
+
54
+ /// A lazily-allocated list of styles for eagerly-cascaded pseudo-elements.
55
+ ///
56
+ /// We use an Arc so that sharing these styles via the style sharing cache does
57
+ /// not require duplicate allocations. We leverage the copy-on-write semantics of
58
+ /// Arc::make_mut(), which is free (i.e. does not require atomic RMU operations)
59
+ /// in servo_arc.
60
+ #[derive(Clone, Debug, Default)]
61
+ pub struct EagerPseudoStyles(Option<Arc<EagerPseudoArray>>);
62
+
63
+ #[derive(Default)]
64
+ struct EagerPseudoArray(EagerPseudoArrayInner);
65
+ type EagerPseudoArrayInner = [Option<Arc<ComputedValues>>; EAGER_PSEUDO_COUNT];
66
+
67
+ impl Deref for EagerPseudoArray {
68
+ type Target = EagerPseudoArrayInner;
69
+ fn deref(&self) -> &Self::Target {
70
+ &self.0
71
+ }
72
+ }
73
+
74
+ impl DerefMut for EagerPseudoArray {
75
+ fn deref_mut(&mut self) -> &mut Self::Target {
76
+ &mut self.0
77
+ }
78
+ }
79
+
80
+ // Manually implement `Clone` here because the derived impl of `Clone` for
81
+ // array types assumes the value inside is `Copy`.
82
+ impl Clone for EagerPseudoArray {
83
+ fn clone(&self) -> Self {
84
+ let mut clone = Self::default();
85
+ for i in 0..EAGER_PSEUDO_COUNT {
86
+ clone[i] = self.0[i].clone();
87
+ }
88
+ clone
89
+ }
90
+ }
91
+
92
+ // Override Debug to print which pseudos we have, and substitute the rule node
93
+ // for the much-more-verbose ComputedValues stringification.
94
+ impl fmt::Debug for EagerPseudoArray {
95
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
96
+ write!(f, "EagerPseudoArray {{ ")?;
97
+ for i in 0..EAGER_PSEUDO_COUNT {
98
+ if let Some(ref values) = self[i] {
99
+ write!(
100
+ f,
101
+ "{:?}: {:?}, ",
102
+ PseudoElement::from_eager_index(i),
103
+ &values.rules
104
+ )?;
105
+ }
106
+ }
107
+ write!(f, "}}")
108
+ }
109
+ }
110
+
111
+ // Can't use [None; EAGER_PSEUDO_COUNT] here because it complains
112
+ // about Copy not being implemented for our Arc type.
113
+ const EMPTY_PSEUDO_ARRAY: &EagerPseudoArrayInner = &[None, None, None, None];
114
+
115
+ impl EagerPseudoStyles {
116
+ /// Returns whether there are any pseudo styles.
117
+ pub fn is_empty(&self) -> bool {
118
+ self.0.is_none()
119
+ }
120
+
121
+ /// Grabs a reference to the list of styles, if they exist.
122
+ pub fn as_optional_array(&self) -> Option<&EagerPseudoArrayInner> {
123
+ match self.0 {
124
+ None => None,
125
+ Some(ref x) => Some(&x.0),
126
+ }
127
+ }
128
+
129
+ /// Grabs a reference to the list of styles or a list of None if
130
+ /// there are no styles to be had.
131
+ pub fn as_array(&self) -> &EagerPseudoArrayInner {
132
+ self.as_optional_array().unwrap_or(EMPTY_PSEUDO_ARRAY)
133
+ }
134
+
135
+ /// Returns a reference to the style for a given eager pseudo, if it exists.
136
+ pub fn get(&self, pseudo: &PseudoElement) -> Option<&Arc<ComputedValues>> {
137
+ debug_assert!(pseudo.is_eager());
138
+ self.0
139
+ .as_ref()
140
+ .and_then(|p| p[pseudo.eager_index()].as_ref())
141
+ }
142
+
143
+ /// Sets the style for the eager pseudo.
144
+ pub fn set(&mut self, pseudo: &PseudoElement, value: Arc<ComputedValues>) {
145
+ if self.0.is_none() {
146
+ self.0 = Some(Arc::new(Default::default()));
147
+ }
148
+ let arr = Arc::make_mut(self.0.as_mut().unwrap());
149
+ arr[pseudo.eager_index()] = Some(value);
150
+ }
151
+ }
152
+
153
+ /// The styles associated with a node, including the styles for any
154
+ /// pseudo-elements.
155
+ #[derive(Clone, Default)]
156
+ pub struct ElementStyles {
157
+ /// The element's style.
158
+ pub primary: Option<Arc<ComputedValues>>,
159
+ /// A list of the styles for the element's eagerly-cascaded pseudo-elements.
160
+ pub pseudos: EagerPseudoStyles,
161
+ }
162
+
163
+ // There's one of these per rendered elements so it better be small.
164
+ size_of_test!(ElementStyles, 16);
165
+
166
+ /// Information on how this element uses viewport units.
167
+ #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
168
+ pub enum ViewportUnitUsage {
169
+ /// No viewport units are used.
170
+ None = 0,
171
+ /// There are viewport units used from regular style rules (which means we
172
+ /// should re-cascade).
173
+ FromDeclaration,
174
+ /// There are viewport units used from container queries (which means we
175
+ /// need to re-selector-match).
176
+ FromQuery,
177
+ }
178
+
179
+ impl ElementStyles {
180
+ /// Returns the primary style.
181
+ pub fn get_primary(&self) -> Option<&Arc<ComputedValues>> {
182
+ self.primary.as_ref()
183
+ }
184
+
185
+ /// Returns the primary style. Panic if no style available.
186
+ pub fn primary(&self) -> &Arc<ComputedValues> {
187
+ self.primary.as_ref().unwrap()
188
+ }
189
+
190
+ /// Whether this element `display` value is `none`.
191
+ pub fn is_display_none(&self) -> bool {
192
+ self.primary().get_box().clone_display().is_none()
193
+ }
194
+
195
+ /// Whether this element uses viewport units.
196
+ pub fn viewport_unit_usage(&self) -> ViewportUnitUsage {
197
+ fn usage_from_flags(flags: ComputedValueFlags) -> ViewportUnitUsage {
198
+ if flags.intersects(ComputedValueFlags::USES_VIEWPORT_UNITS_ON_CONTAINER_QUERIES) {
199
+ return ViewportUnitUsage::FromQuery;
200
+ }
201
+ if flags.intersects(ComputedValueFlags::USES_VIEWPORT_UNITS) {
202
+ return ViewportUnitUsage::FromDeclaration;
203
+ }
204
+ ViewportUnitUsage::None
205
+ }
206
+
207
+ let primary = self.primary();
208
+ let mut usage = usage_from_flags(primary.flags);
209
+
210
+ // Check cached lazy pseudos on the primary style.
211
+ primary.each_cached_lazy_pseudo(|style| {
212
+ usage = std::cmp::max(usage, usage_from_flags(style.flags));
213
+ });
214
+
215
+ for pseudo_style in self.pseudos.as_array() {
216
+ if let Some(pseudo_style) = pseudo_style {
217
+ usage = std::cmp::max(usage, usage_from_flags(pseudo_style.flags));
218
+ // Also check cached lazy pseudos on eager pseudo styles.
219
+ pseudo_style.each_cached_lazy_pseudo(|style| {
220
+ usage = std::cmp::max(usage, usage_from_flags(style.flags));
221
+ });
222
+ }
223
+ }
224
+
225
+ usage
226
+ }
227
+
228
+ /// Whether this element uses sibling-count() or sibling-index().
229
+ pub fn uses_tree_counting_function(&self, t: TreeCountingFunction) -> bool {
230
+ let usage_from_flags = |flags: ComputedValueFlags| -> bool {
231
+ if t == TreeCountingFunction::SiblingCount
232
+ && flags.intersects(ComputedValueFlags::USES_SIBLING_COUNT)
233
+ {
234
+ return true;
235
+ }
236
+ if t == TreeCountingFunction::SiblingIndex
237
+ && flags.intersects(ComputedValueFlags::USES_SIBLING_INDEX)
238
+ {
239
+ return true;
240
+ }
241
+ false
242
+ };
243
+
244
+ let primary = self.primary();
245
+ let mut usage = usage_from_flags(primary.flags);
246
+
247
+ for pseudo_style in self.pseudos.as_array().iter().flatten() {
248
+ usage |= usage_from_flags(pseudo_style.flags);
249
+ }
250
+
251
+ usage
252
+ }
253
+
254
+ #[cfg(feature = "gecko")]
255
+ fn size_of_excluding_cvs(&self, _ops: &mut MallocSizeOfOps) -> usize {
256
+ // As the method name suggests, we don't measures the ComputedValues
257
+ // here, because they are measured on the C++ side.
258
+
259
+ // XXX: measure the EagerPseudoArray itself, but not the ComputedValues
260
+ // within it.
261
+
262
+ 0
263
+ }
264
+ }
265
+
266
+ // We manually implement Debug for ElementStyles so that we can avoid the
267
+ // verbose stringification of every property in the ComputedValues. We
268
+ // substitute the rule node instead.
269
+ impl fmt::Debug for ElementStyles {
270
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
271
+ write!(
272
+ f,
273
+ "ElementStyles {{ primary: {:?}, pseudos: {:?} }}",
274
+ self.primary.as_ref().map(|x| &x.rules),
275
+ self.pseudos
276
+ )
277
+ }
278
+ }
279
+
280
+ /// Style system data associated with an Element.
281
+ ///
282
+ /// In Gecko, this hangs directly off the Element. Servo, this is embedded
283
+ /// inside of layout data, which itself hangs directly off the Element. In
284
+ /// both cases, it is wrapped inside an AtomicRefCell to ensure thread safety.
285
+ #[derive(Debug, Default)]
286
+ pub struct ElementData {
287
+ /// The styles for the element and its pseudo-elements.
288
+ pub styles: ElementStyles,
289
+
290
+ /// The restyle damage, indicating what kind of layout changes are required
291
+ /// afte restyling.
292
+ pub damage: RestyleDamage,
293
+
294
+ /// The restyle hint, which indicates whether selectors need to be rematched
295
+ /// for this element, its children, and its descendants.
296
+ pub hint: RestyleHint,
297
+
298
+ /// Flags.
299
+ pub flags: ElementDataFlags,
300
+ }
301
+
302
+ /// A struct that wraps ElementData, giving it the ability of doing thread-safety checks.
303
+ #[derive(Debug, Default)]
304
+ pub struct ElementDataWrapper {
305
+ inner: std::cell::UnsafeCell<ElementData>,
306
+ /// Implements optional (debug_assertions-only) thread-safety checking.
307
+ #[cfg(debug_assertions)]
308
+ refcell: AtomicRefCell<()>,
309
+ }
310
+
311
+ /// A read-only reference to ElementData.
312
+ #[derive(Debug)]
313
+ pub struct ElementDataMut<'a> {
314
+ v: &'a mut ElementData,
315
+ #[cfg(debug_assertions)]
316
+ _borrow: AtomicRefMut<'a, ()>,
317
+ }
318
+
319
+ /// A mutable reference to ElementData.
320
+ #[derive(Debug)]
321
+ pub struct ElementDataRef<'a> {
322
+ v: &'a ElementData,
323
+ #[cfg(debug_assertions)]
324
+ _borrow: AtomicRef<'a, ()>,
325
+ }
326
+
327
+ impl ElementDataWrapper {
328
+ /// Gets a non-exclusive reference to this ElementData.
329
+ #[inline(always)]
330
+ pub fn borrow(&self) -> ElementDataRef<'_> {
331
+ #[cfg(debug_assertions)]
332
+ let borrow = self.refcell.borrow();
333
+ ElementDataRef {
334
+ v: unsafe { &*self.inner.get() },
335
+ #[cfg(debug_assertions)]
336
+ _borrow: borrow,
337
+ }
338
+ }
339
+
340
+ /// Gets an exclusive reference to this ElementData.
341
+ #[inline(always)]
342
+ pub fn borrow_mut(&self) -> ElementDataMut<'_> {
343
+ #[cfg(debug_assertions)]
344
+ let borrow = self.refcell.borrow_mut();
345
+ ElementDataMut {
346
+ v: unsafe { &mut *self.inner.get() },
347
+ #[cfg(debug_assertions)]
348
+ _borrow: borrow,
349
+ }
350
+ }
351
+ }
352
+
353
+ impl<'a> Deref for ElementDataRef<'a> {
354
+ type Target = ElementData;
355
+ #[inline]
356
+ fn deref(&self) -> &Self::Target {
357
+ self.v
358
+ }
359
+ }
360
+
361
+ impl<'a> Deref for ElementDataMut<'a> {
362
+ type Target = ElementData;
363
+ #[inline]
364
+ fn deref(&self) -> &Self::Target {
365
+ &*self.v
366
+ }
367
+ }
368
+
369
+ impl<'a> DerefMut for ElementDataMut<'a> {
370
+ fn deref_mut(&mut self) -> &mut Self::Target {
371
+ &mut *self.v
372
+ }
373
+ }
374
+
375
+ // There's one of these per rendered elements so it better be small.
376
+ size_of_test!(ElementData, 24);
377
+
378
+ /// The kind of restyle that a single element should do.
379
+ #[derive(Debug)]
380
+ pub enum RestyleKind {
381
+ /// We need to run selector matching plus re-cascade, that is, a full
382
+ /// restyle.
383
+ MatchAndCascade,
384
+ /// We need to recascade with some replacement rule, such as the style
385
+ /// attribute, or animation rules.
386
+ CascadeWithReplacements(RestyleHint),
387
+ /// We only need to recascade, for example, because only inherited
388
+ /// properties in the parent changed.
389
+ CascadeOnly,
390
+ }
391
+
392
+ fn needs_to_match_self(hint: RestyleHint, style: &ComputedValues) -> bool {
393
+ if hint.intersects(RestyleHint::RESTYLE_SELF) {
394
+ return true;
395
+ }
396
+ if hint.intersects(RestyleHint::RESTYLE_SELF_IF_PSEUDO) && style.is_pseudo_style() {
397
+ return true;
398
+ }
399
+ if hint.intersects(RestyleHint::RESTYLE_IF_AFFECTED_BY_WM_OR_ANCESTOR_FONT)
400
+ && style
401
+ .flags
402
+ .intersects(ComputedValueFlags::USES_FONT_OR_WM_RELATIVE_UNITS_ON_CONTAINER_QUERIES)
403
+ {
404
+ return true;
405
+ }
406
+ hint.intersects(
407
+ RestyleHint::RESTYLE_IF_AFFECTED_BY_STYLE_QUERIES
408
+ | RestyleHint::RESTYLE_IF_AFFECTED_BY_NAMED_STYLE_CONTAINER,
409
+ ) && style
410
+ .flags
411
+ .intersects(ComputedValueFlags::DEPENDS_ON_CONTAINER_STYLE_QUERY)
412
+ }
413
+
414
+ fn needs_to_recascade_self(hint: RestyleHint, style: &ComputedValues) -> bool {
415
+ if hint.intersects(RestyleHint::RECASCADE_SELF) {
416
+ return true;
417
+ }
418
+ if hint.intersects(RestyleHint::RECASCADE_SELF_IF_INHERIT_RESET_STYLE)
419
+ && style
420
+ .flags
421
+ .contains(ComputedValueFlags::INHERITS_RESET_STYLE)
422
+ {
423
+ return true;
424
+ }
425
+ if hint.intersects(RestyleHint::RESTYLE_IF_AFFECTED_BY_WM_OR_ANCESTOR_FONT)
426
+ && style
427
+ .flags
428
+ .contains(ComputedValueFlags::USES_FONT_OR_WM_RELATIVE_UNITS)
429
+ {
430
+ return true;
431
+ }
432
+ false
433
+ }
434
+
435
+ impl ElementData {
436
+ /// Invalidates style for this element, its descendants, and later siblings,
437
+ /// based on the snapshot of the element that we took when attributes or
438
+ /// state changed.
439
+ pub fn invalidate_style_if_needed<E: TElement>(
440
+ &mut self,
441
+ element: E,
442
+ shared_context: &SharedStyleContext,
443
+ stack_limit_checker: Option<&StackLimitChecker>,
444
+ selector_caches: &mut SelectorCaches,
445
+ ) -> InvalidationResult {
446
+ // In animation-only restyle we shouldn't touch snapshot at all.
447
+ if shared_context.traversal_flags.for_animation_only() {
448
+ return InvalidationResult::empty();
449
+ }
450
+
451
+ use crate::invalidation::element::invalidator::TreeStyleInvalidator;
452
+ use crate::invalidation::element::state_and_attributes::StateAndAttrInvalidationProcessor;
453
+
454
+ debug!(
455
+ "invalidate_style_if_needed: {:?}, flags: {:?}, has_snapshot: {}, \
456
+ handled_snapshot: {}, pseudo: {:?}",
457
+ element,
458
+ shared_context.traversal_flags,
459
+ element.has_snapshot(),
460
+ element.handled_snapshot(),
461
+ element.implemented_pseudo_element()
462
+ );
463
+
464
+ if !element.has_snapshot() || element.handled_snapshot() {
465
+ return InvalidationResult::empty();
466
+ }
467
+
468
+ let mut processor =
469
+ StateAndAttrInvalidationProcessor::new(shared_context, element, self, selector_caches);
470
+
471
+ let invalidator = TreeStyleInvalidator::new(element, stack_limit_checker, &mut processor);
472
+
473
+ let result = invalidator.invalidate();
474
+
475
+ unsafe { element.set_handled_snapshot() }
476
+ debug_assert!(element.handled_snapshot());
477
+
478
+ result
479
+ }
480
+
481
+ /// Returns true if this element has styles.
482
+ #[inline]
483
+ pub fn has_styles(&self) -> bool {
484
+ self.styles.primary.is_some()
485
+ }
486
+
487
+ /// Returns this element's styles as resolved styles to use for sharing.
488
+ pub fn share_styles(&self) -> ResolvedElementStyles {
489
+ ResolvedElementStyles {
490
+ primary: self.share_primary_style(),
491
+ pseudos: self.styles.pseudos.clone(),
492
+ }
493
+ }
494
+
495
+ /// Returns this element's primary style as a resolved style to use for sharing.
496
+ pub fn share_primary_style(&self) -> PrimaryStyle {
497
+ let reused_via_rule_node = self
498
+ .flags
499
+ .contains(ElementDataFlags::PRIMARY_STYLE_REUSED_VIA_RULE_NODE);
500
+
501
+ PrimaryStyle {
502
+ style: ResolvedStyle(self.styles.primary().clone()),
503
+ reused_via_rule_node,
504
+ }
505
+ }
506
+
507
+ /// Return a copy of the element's primary style as a resolved style with the
508
+ /// given flags.
509
+ pub fn clone_style_with_flags(&self, flags: ComputedValueFlags) -> ResolvedStyle {
510
+ let primary_style = self.styles.primary();
511
+ // We are only using this pseudo to find the correct pseudo type so it
512
+ // does not matter it technically belongs to a different style.
513
+ let pseudo = primary_style.pseudo();
514
+ ResolvedStyle(
515
+ primary_style
516
+ .deref()
517
+ .clone_with_flags(flags, pseudo.as_ref()),
518
+ )
519
+ }
520
+
521
+ /// Sets a new set of styles, returning the old ones.
522
+ pub fn set_styles(&mut self, new_styles: ResolvedElementStyles) -> ElementStyles {
523
+ self.flags.set(
524
+ ElementDataFlags::PRIMARY_STYLE_REUSED_VIA_RULE_NODE,
525
+ new_styles.primary.reused_via_rule_node,
526
+ );
527
+ mem::replace(&mut self.styles, new_styles.into())
528
+ }
529
+
530
+ /// Returns the kind of restyling that we're going to need to do on this
531
+ /// element, based of the stored restyle hint.
532
+ pub fn restyle_kind(&self, shared_context: &SharedStyleContext) -> Option<RestyleKind> {
533
+ let style = match self.styles.primary {
534
+ Some(ref s) => s,
535
+ None => return Some(RestyleKind::MatchAndCascade),
536
+ };
537
+
538
+ if shared_context.traversal_flags.for_animation_only() {
539
+ return self.restyle_kind_for_animation(shared_context);
540
+ }
541
+
542
+ let hint = self.hint;
543
+ if hint.is_empty() {
544
+ return None;
545
+ }
546
+
547
+ if needs_to_match_self(hint, style) {
548
+ return Some(RestyleKind::MatchAndCascade);
549
+ }
550
+
551
+ if hint.has_replacements() {
552
+ debug_assert!(
553
+ !hint.has_animation_hint(),
554
+ "Animation only restyle hint should have already processed"
555
+ );
556
+ return Some(RestyleKind::CascadeWithReplacements(
557
+ hint & RestyleHint::replacements(),
558
+ ));
559
+ }
560
+
561
+ if needs_to_recascade_self(hint, style) {
562
+ return Some(RestyleKind::CascadeOnly);
563
+ }
564
+
565
+ None
566
+ }
567
+
568
+ /// Returns the kind of restyling for animation-only restyle.
569
+ fn restyle_kind_for_animation(
570
+ &self,
571
+ shared_context: &SharedStyleContext,
572
+ ) -> Option<RestyleKind> {
573
+ debug_assert!(shared_context.traversal_flags.for_animation_only());
574
+ debug_assert!(self.has_styles());
575
+
576
+ // FIXME: We should ideally restyle here, but it is a hack to work around our weird
577
+ // animation-only traversal stuff: If we're display: none and the rules we could
578
+ // match could change, we consider our style up-to-date. This is because re-cascading with
579
+ // and old style doesn't guarantee returning the correct animation style (that's
580
+ // bug 1393323). So if our display changed, and it changed from display: none, we would
581
+ // incorrectly forget about it and wouldn't be able to correctly style our descendants
582
+ // later.
583
+ // XXX Figure out if this still makes sense.
584
+ let hint = self.hint;
585
+ if self.styles.is_display_none() && hint.intersects(RestyleHint::RESTYLE_SELF) {
586
+ return None;
587
+ }
588
+
589
+ let style = self.styles.primary();
590
+ // Return either CascadeWithReplacements or CascadeOnly in case of animation-only restyle.
591
+ // I.e. animation-only restyle never does selector matching.
592
+ if hint.has_animation_hint() {
593
+ return Some(RestyleKind::CascadeWithReplacements(
594
+ hint & RestyleHint::for_animations(),
595
+ ));
596
+ }
597
+
598
+ if needs_to_recascade_self(hint, style) {
599
+ return Some(RestyleKind::CascadeOnly);
600
+ }
601
+ None
602
+ }
603
+
604
+ /// Drops any restyle state from the element.
605
+ ///
606
+ /// FIXME(bholley): The only caller of this should probably just assert that the hint is empty
607
+ /// and call clear_flags_and_damage().
608
+ #[inline]
609
+ pub fn clear_restyle_state(&mut self) {
610
+ self.hint = RestyleHint::empty();
611
+ self.clear_restyle_flags_and_damage();
612
+ }
613
+
614
+ /// Drops restyle flags and damage from the element.
615
+ #[inline]
616
+ pub fn clear_restyle_flags_and_damage(&mut self) {
617
+ self.damage = RestyleDamage::empty();
618
+ self.flags.remove(ElementDataFlags::WAS_RESTYLED);
619
+ }
620
+
621
+ /// Mark this element as restyled, which is useful to know whether we need
622
+ /// to do a post-traversal.
623
+ pub fn set_restyled(&mut self) {
624
+ self.flags.insert(ElementDataFlags::WAS_RESTYLED);
625
+ self.flags
626
+ .remove(ElementDataFlags::TRAVERSED_WITHOUT_STYLING);
627
+ }
628
+
629
+ /// Returns true if this element was restyled.
630
+ #[inline]
631
+ pub fn is_restyle(&self) -> bool {
632
+ self.flags.contains(ElementDataFlags::WAS_RESTYLED)
633
+ }
634
+
635
+ /// Mark that we traversed this element without computing any style for it.
636
+ pub fn set_traversed_without_styling(&mut self) {
637
+ self.flags
638
+ .insert(ElementDataFlags::TRAVERSED_WITHOUT_STYLING);
639
+ }
640
+
641
+ /// Returns whether this element has been part of a restyle.
642
+ #[inline]
643
+ pub fn contains_restyle_data(&self) -> bool {
644
+ self.is_restyle() || !self.hint.is_empty() || !self.damage.is_empty()
645
+ }
646
+
647
+ /// Returns whether it is safe to perform cousin sharing based on the ComputedValues
648
+ /// identity of the primary style in this ElementData. There are a few subtle things
649
+ /// to check.
650
+ ///
651
+ /// First, if a parent element was already styled and we traversed past it without
652
+ /// restyling it, that may be because our clever invalidation logic was able to prove
653
+ /// that the styles of that element would remain unchanged despite changes to the id
654
+ /// or class attributes. However, style sharing relies on the strong guarantee that all
655
+ /// the classes and ids up the respective parent chains are identical. As such, if we
656
+ /// skipped styling for one (or both) of the parents on this traversal, we can't share
657
+ /// styles across cousins. Note that this is a somewhat conservative check. We could
658
+ /// tighten it by having the invalidation logic explicitly flag elements for which it
659
+ /// ellided styling.
660
+ ///
661
+ /// Second, we want to only consider elements whose ComputedValues match due to a hit
662
+ /// in the style sharing cache, rather than due to the rule-node-based reuse that
663
+ /// happens later in the styling pipeline. The former gives us the stronger guarantees
664
+ /// we need for style sharing, the latter does not.
665
+ pub fn safe_for_cousin_sharing(&self) -> bool {
666
+ if self.flags.intersects(
667
+ ElementDataFlags::TRAVERSED_WITHOUT_STYLING
668
+ | ElementDataFlags::PRIMARY_STYLE_REUSED_VIA_RULE_NODE,
669
+ ) {
670
+ return false;
671
+ }
672
+ if !self
673
+ .styles
674
+ .primary()
675
+ .get_box()
676
+ .clone_container_type()
677
+ .is_normal()
678
+ {
679
+ return false;
680
+ }
681
+ true
682
+ }
683
+
684
+ /// Measures memory usage.
685
+ #[cfg(feature = "gecko")]
686
+ pub fn size_of_excluding_cvs(&self, ops: &mut MallocSizeOfOps) -> usize {
687
+ let n = self.styles.size_of_excluding_cvs(ops);
688
+
689
+ // We may measure more fields in the future if DMD says it's worth it.
690
+
691
+ n
692
+ }
693
+ }