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,1157 @@
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
+ //! Generic types for CSS values that are related to transformations.
6
+
7
+ use crate::derives::*;
8
+ use crate::typed_om::{
9
+ KeywordValue, MatrixComponent, NumericValue, PerspectiveComponent, PerspectiveValue,
10
+ RotateComponent, ScaleComponent, SkewComponent, ToTyped, TransformComponent,
11
+ TranslateComponent, TypedValue,
12
+ };
13
+ use crate::values::computed::length::Length as ComputedLength;
14
+ use crate::values::computed::length::LengthPercentage as ComputedLengthPercentage;
15
+ use crate::values::computed::transform::Matrix3D as ComputedMatrix3D;
16
+ use crate::values::specified::angle::Angle as SpecifiedAngle;
17
+ use crate::values::specified::length::Length as SpecifiedLength;
18
+ use crate::values::specified::length::LengthPercentage as SpecifiedLengthPercentage;
19
+ use crate::values::specified::number::Number as SpecifiedNumber;
20
+ use crate::values::{computed, CSSFloat};
21
+ use crate::{One, Zero, ZeroNoPercent};
22
+ use euclid::default::{Rect, Transform3D};
23
+ use std::fmt::{self, Write};
24
+ use std::ops::Neg;
25
+ use style_traits::{CssString, CssWriter, ToCss};
26
+ use thin_vec::ThinVec;
27
+
28
+ /// A generic 2D transformation matrix.
29
+ #[allow(missing_docs)]
30
+ #[derive(
31
+ Clone,
32
+ Copy,
33
+ Debug,
34
+ Deserialize,
35
+ MallocSizeOf,
36
+ PartialEq,
37
+ Serialize,
38
+ SpecifiedValueInfo,
39
+ ToAnimatedValue,
40
+ ToComputedValue,
41
+ ToCss,
42
+ ToResolvedValue,
43
+ ToShmem,
44
+ )]
45
+ #[css(comma, function = "matrix")]
46
+ #[repr(C)]
47
+ pub struct GenericMatrix<T> {
48
+ pub a: T,
49
+ pub b: T,
50
+ pub c: T,
51
+ pub d: T,
52
+ pub e: T,
53
+ pub f: T,
54
+ }
55
+
56
+ pub use self::GenericMatrix as Matrix;
57
+
58
+ #[allow(missing_docs)]
59
+ #[rustfmt::skip]
60
+ #[derive(
61
+ Clone,
62
+ Copy,
63
+ Debug,
64
+ Deserialize,
65
+ MallocSizeOf,
66
+ PartialEq,
67
+ Serialize,
68
+ SpecifiedValueInfo,
69
+ ToAnimatedValue,
70
+ ToComputedValue,
71
+ ToCss,
72
+ ToResolvedValue,
73
+ ToShmem,
74
+ )]
75
+ #[css(comma, function = "matrix3d")]
76
+ #[repr(C)]
77
+ pub struct GenericMatrix3D<T> {
78
+ pub m11: T, pub m12: T, pub m13: T, pub m14: T,
79
+ pub m21: T, pub m22: T, pub m23: T, pub m24: T,
80
+ pub m31: T, pub m32: T, pub m33: T, pub m34: T,
81
+ pub m41: T, pub m42: T, pub m43: T, pub m44: T,
82
+ }
83
+
84
+ pub use self::GenericMatrix3D as Matrix3D;
85
+
86
+ #[rustfmt::skip]
87
+ impl<T: ToFloat> TryFrom<Matrix<T>> for Transform3D<f64> {
88
+ type Error = ();
89
+
90
+ #[inline]
91
+ fn try_from(m: Matrix<T>) -> Result<Self, Self::Error> {
92
+ Ok(Transform3D::new(
93
+ m.a.to_f64()?, m.b.to_f64()?, 0.0, 0.0,
94
+ m.c.to_f64()?, m.d.to_f64()?, 0.0, 0.0,
95
+ 0.0, 0.0, 1.0, 0.0,
96
+ m.e.to_f64()?, m.f.to_f64()?, 0.0, 1.0,
97
+ ))
98
+ }
99
+ }
100
+
101
+ #[rustfmt::skip]
102
+ impl<T: ToFloat> TryFrom<Matrix3D<T>> for Transform3D<f64> {
103
+ type Error = ();
104
+
105
+ #[inline]
106
+ fn try_from(m: Matrix3D<T>) -> Result<Self, Self::Error> {
107
+ Ok(Transform3D::new(
108
+ m.m11.to_f64()?, m.m12.to_f64()?, m.m13.to_f64()?, m.m14.to_f64()?,
109
+ m.m21.to_f64()?, m.m22.to_f64()?, m.m23.to_f64()?, m.m24.to_f64()?,
110
+ m.m31.to_f64()?, m.m32.to_f64()?, m.m33.to_f64()?, m.m34.to_f64()?,
111
+ m.m41.to_f64()?, m.m42.to_f64()?, m.m43.to_f64()?, m.m44.to_f64()?,
112
+ ))
113
+ }
114
+ }
115
+
116
+ /// A generic transform origin.
117
+ #[derive(
118
+ Animate,
119
+ Clone,
120
+ ComputeSquaredDistance,
121
+ Copy,
122
+ Debug,
123
+ MallocSizeOf,
124
+ PartialEq,
125
+ SpecifiedValueInfo,
126
+ ToAnimatedValue,
127
+ ToAnimatedZero,
128
+ ToComputedValue,
129
+ ToCss,
130
+ ToResolvedValue,
131
+ ToShmem,
132
+ ToTyped,
133
+ )]
134
+ #[repr(C)]
135
+ #[typed(todo_derive_fields)]
136
+ pub struct GenericTransformOrigin<H, V, Depth> {
137
+ /// The horizontal origin.
138
+ pub horizontal: H,
139
+ /// The vertical origin.
140
+ pub vertical: V,
141
+ /// The depth.
142
+ pub depth: Depth,
143
+ }
144
+
145
+ pub use self::GenericTransformOrigin as TransformOrigin;
146
+
147
+ impl<H, V, D> TransformOrigin<H, V, D> {
148
+ /// Returns a new transform origin.
149
+ pub fn new(horizontal: H, vertical: V, depth: D) -> Self {
150
+ Self {
151
+ horizontal,
152
+ vertical,
153
+ depth,
154
+ }
155
+ }
156
+ }
157
+
158
+ fn is_same<N: PartialEq>(x: &N, y: &N) -> bool {
159
+ x == y
160
+ }
161
+
162
+ /// A value for the `perspective()` transform function, which is either a
163
+ /// non-negative `<length>` or `none`.
164
+ #[derive(
165
+ Clone,
166
+ Debug,
167
+ Deserialize,
168
+ MallocSizeOf,
169
+ PartialEq,
170
+ Serialize,
171
+ SpecifiedValueInfo,
172
+ ToAnimatedValue,
173
+ ToComputedValue,
174
+ ToCss,
175
+ ToResolvedValue,
176
+ ToShmem,
177
+ ToTyped,
178
+ )]
179
+ #[repr(C, u8)]
180
+ pub enum GenericPerspectiveFunction<L> {
181
+ /// `none`
182
+ None,
183
+ /// A `<length>`.
184
+ Length(L),
185
+ }
186
+
187
+ impl<L> GenericPerspectiveFunction<L> {
188
+ /// Returns `f32::INFINITY` or the result of a function on the length value.
189
+ pub fn infinity_or(&self, f: impl FnOnce(&L) -> f32) -> f32 {
190
+ match *self {
191
+ Self::None => f32::INFINITY,
192
+ Self::Length(ref l) => f(l),
193
+ }
194
+ }
195
+ }
196
+
197
+ pub use self::GenericPerspectiveFunction as PerspectiveFunction;
198
+
199
+ #[derive(
200
+ Clone,
201
+ Debug,
202
+ Deserialize,
203
+ MallocSizeOf,
204
+ PartialEq,
205
+ Serialize,
206
+ SpecifiedValueInfo,
207
+ ToAnimatedValue,
208
+ ToComputedValue,
209
+ ToCss,
210
+ ToResolvedValue,
211
+ ToShmem,
212
+ )]
213
+ #[repr(C, u8)]
214
+ /// A single operation in the list of a `transform` value
215
+ pub enum GenericTransformOperation<Angle, Number, Length, Integer, LengthPercentage>
216
+ where
217
+ Angle: Zero,
218
+ LengthPercentage: Zero + ZeroNoPercent,
219
+ Number: PartialEq,
220
+ {
221
+ /// Represents a 2D 2x3 matrix.
222
+ Matrix(GenericMatrix<Number>),
223
+ /// Represents a 3D 4x4 matrix.
224
+ Matrix3D(GenericMatrix3D<Number>),
225
+ /// A 2D skew.
226
+ ///
227
+ /// If the second angle is not provided it is assumed zero.
228
+ ///
229
+ /// Syntax can be skew(angle) or skew(angle, angle)
230
+ #[css(comma, function)]
231
+ Skew(Angle, #[css(skip_if = "Zero::is_zero")] Angle),
232
+ /// skewX(angle)
233
+ #[css(function = "skewX")]
234
+ SkewX(Angle),
235
+ /// skewY(angle)
236
+ #[css(function = "skewY")]
237
+ SkewY(Angle),
238
+ /// translate(x, y) or translate(x)
239
+ #[css(comma, function)]
240
+ Translate(
241
+ LengthPercentage,
242
+ #[css(skip_if = "ZeroNoPercent::is_zero_no_percent")] LengthPercentage,
243
+ ),
244
+ /// translateX(x)
245
+ #[css(function = "translateX")]
246
+ TranslateX(LengthPercentage),
247
+ /// translateY(y)
248
+ #[css(function = "translateY")]
249
+ TranslateY(LengthPercentage),
250
+ /// translateZ(z)
251
+ #[css(function = "translateZ")]
252
+ TranslateZ(Length),
253
+ /// translate3d(x, y, z)
254
+ #[css(comma, function = "translate3d")]
255
+ Translate3D(LengthPercentage, LengthPercentage, Length),
256
+ /// A 2D scaling factor.
257
+ ///
258
+ /// Syntax can be scale(factor) or scale(factor, factor)
259
+ #[css(comma, function)]
260
+ Scale(Number, #[css(contextual_skip_if = "is_same")] Number),
261
+ /// scaleX(factor)
262
+ #[css(function = "scaleX")]
263
+ ScaleX(Number),
264
+ /// scaleY(factor)
265
+ #[css(function = "scaleY")]
266
+ ScaleY(Number),
267
+ /// scaleZ(factor)
268
+ #[css(function = "scaleZ")]
269
+ ScaleZ(Number),
270
+ /// scale3D(factorX, factorY, factorZ)
271
+ #[css(comma, function = "scale3d")]
272
+ Scale3D(Number, Number, Number),
273
+ /// Describes a 2D Rotation.
274
+ ///
275
+ /// In a 3D scene `rotate(angle)` is equivalent to `rotateZ(angle)`.
276
+ #[css(function)]
277
+ Rotate(Angle),
278
+ /// Rotation in 3D space around the x-axis.
279
+ #[css(function = "rotateX")]
280
+ RotateX(Angle),
281
+ /// Rotation in 3D space around the y-axis.
282
+ #[css(function = "rotateY")]
283
+ RotateY(Angle),
284
+ /// Rotation in 3D space around the z-axis.
285
+ #[css(function = "rotateZ")]
286
+ RotateZ(Angle),
287
+ /// Rotation in 3D space.
288
+ ///
289
+ /// Generalization of rotateX, rotateY and rotateZ.
290
+ #[css(comma, function = "rotate3d")]
291
+ Rotate3D(Number, Number, Number, Angle),
292
+ /// Specifies a perspective projection matrix.
293
+ ///
294
+ /// Part of CSS Transform Module Level 2 and defined at
295
+ /// [§ 13.1. 3D Transform Function](https://drafts.csswg.org/css-transforms-2/#funcdef-perspective).
296
+ ///
297
+ /// The value must be greater than or equal to zero.
298
+ #[css(function)]
299
+ Perspective(GenericPerspectiveFunction<Length>),
300
+ /// A intermediate type for interpolation of mismatched transform lists.
301
+ #[allow(missing_docs)]
302
+ #[css(comma, function = "interpolatematrix")]
303
+ InterpolateMatrix {
304
+ from_list: GenericTransform<
305
+ GenericTransformOperation<Angle, Number, Length, Integer, LengthPercentage>,
306
+ >,
307
+ to_list: GenericTransform<
308
+ GenericTransformOperation<Angle, Number, Length, Integer, LengthPercentage>,
309
+ >,
310
+ progress: computed::Percentage,
311
+ },
312
+ /// A intermediate type for accumulation of mismatched transform lists.
313
+ #[allow(missing_docs)]
314
+ #[css(comma, function = "accumulatematrix")]
315
+ AccumulateMatrix {
316
+ from_list: GenericTransform<
317
+ GenericTransformOperation<Angle, Number, Length, Integer, LengthPercentage>,
318
+ >,
319
+ to_list: GenericTransform<
320
+ GenericTransformOperation<Angle, Number, Length, Integer, LengthPercentage>,
321
+ >,
322
+ count: Integer,
323
+ },
324
+ }
325
+
326
+ pub use self::GenericTransformOperation as TransformOperation;
327
+
328
+ /// Converts a transform operation into a transform component.
329
+ pub trait ToTransformComponent {
330
+ /// Attempt to convert `self` into a transform component.
331
+ ///
332
+ /// Implementations append the resulting component to `dest`. Returning
333
+ /// `Err(())` indicates that the transform operation cannot currently be
334
+ /// represented as a transform component.
335
+ fn to_transform_component(&self, _dest: &mut ThinVec<TransformComponent>) -> Result<(), ()>;
336
+ }
337
+
338
+ impl<Angle, Number, Length, Integer, LengthPercentage> ToTransformComponent
339
+ for TransformOperation<Angle, Number, Length, Integer, LengthPercentage>
340
+ where
341
+ Angle: Zero + ToTyped,
342
+ Number: PartialEq + ToFloat + ToTyped,
343
+ Length: ToTyped,
344
+ LengthPercentage: Zero + ToTyped + ZeroNoPercent,
345
+ {
346
+ fn to_transform_component(&self, dest: &mut ThinVec<TransformComponent>) -> Result<(), ()> {
347
+ use self::TransformOperation::*;
348
+
349
+ // https://drafts.css-houdini.org/css-typed-om-1/#reify-a-transform-function
350
+ let component = match *self {
351
+ Matrix(ref m) => TransformComponent::Matrix(MatrixComponent {
352
+ #[rustfmt::skip]
353
+ matrix: ComputedMatrix3D {
354
+ m11: m.a.to_f32()?, m12: m.b.to_f32()?, m13: 0.0, m14: 0.0,
355
+ m21: m.c.to_f32()?, m22: m.d.to_f32()?, m23: 0.0, m24: 0.0,
356
+ m31: 0.0, m32: 0.0, m33: 1.0, m34: 0.0,
357
+ m41: m.e.to_f32()?, m42: m.f.to_f32()?, m43: 0.0, m44: 1.0,
358
+ },
359
+ is_2d: true,
360
+ }),
361
+ Matrix3D(ref m) => TransformComponent::Matrix(MatrixComponent {
362
+ #[rustfmt::skip]
363
+ matrix: ComputedMatrix3D {
364
+ m11: m.m11.to_f32()?, m12: m.m12.to_f32()?, m13: m.m13.to_f32()?, m14: m.m14.to_f32()?,
365
+ m21: m.m21.to_f32()?, m22: m.m22.to_f32()?, m23: m.m23.to_f32()?, m24: m.m24.to_f32()?,
366
+ m31: m.m31.to_f32()?, m32: m.m32.to_f32()?, m33: m.m33.to_f32()?, m34: m.m34.to_f32()?,
367
+ m41: m.m41.to_f32()?, m42: m.m42.to_f32()?, m43: m.m43.to_f32()?, m44: m.m44.to_f32()?,
368
+ },
369
+ is_2d: false,
370
+ }),
371
+ Skew(ref theta_x, ref theta_y) => TransformComponent::Skew(SkewComponent {
372
+ ax: theta_x.to_numeric_value().ok_or(())?,
373
+ ay: theta_y.to_numeric_value().ok_or(())?,
374
+ }),
375
+ SkewX(ref theta) => TransformComponent::SkewX(theta.to_numeric_value().ok_or(())?),
376
+ SkewY(ref theta) => TransformComponent::SkewY(theta.to_numeric_value().ok_or(())?),
377
+ Translate(ref tx, ref ty) => TransformComponent::Translate(TranslateComponent {
378
+ x: tx.to_numeric_value().ok_or(())?,
379
+ y: ty.to_numeric_value().ok_or(())?,
380
+ z: NumericValue::zero_px(),
381
+ is_2d: true,
382
+ }),
383
+ TranslateX(ref t) => TransformComponent::Translate(TranslateComponent {
384
+ x: t.to_numeric_value().ok_or(())?,
385
+ y: NumericValue::zero_px(),
386
+ z: NumericValue::zero_px(),
387
+ is_2d: true,
388
+ }),
389
+ TranslateY(ref t) => TransformComponent::Translate(TranslateComponent {
390
+ x: NumericValue::zero_px(),
391
+ y: t.to_numeric_value().ok_or(())?,
392
+ z: NumericValue::zero_px(),
393
+ is_2d: true,
394
+ }),
395
+ TranslateZ(ref t) => TransformComponent::Translate(TranslateComponent {
396
+ x: NumericValue::zero_px(),
397
+ y: NumericValue::zero_px(),
398
+ z: t.to_numeric_value().ok_or(())?,
399
+ is_2d: false,
400
+ }),
401
+ Translate3D(ref tx, ref ty, ref tz) => {
402
+ TransformComponent::Translate(TranslateComponent {
403
+ x: tx.to_numeric_value().ok_or(())?,
404
+ y: ty.to_numeric_value().ok_or(())?,
405
+ z: tz.to_numeric_value().ok_or(())?,
406
+ is_2d: false,
407
+ })
408
+ },
409
+ Scale(ref sx, ref sy) => TransformComponent::Scale(ScaleComponent {
410
+ x: sx.to_numeric_value().ok_or(())?,
411
+ y: sy.to_numeric_value().ok_or(())?,
412
+ z: NumericValue::one(),
413
+ is_2d: true,
414
+ }),
415
+ ScaleX(ref s) => TransformComponent::Scale(ScaleComponent {
416
+ x: s.to_numeric_value().ok_or(())?,
417
+ y: NumericValue::one(),
418
+ z: NumericValue::one(),
419
+ is_2d: true,
420
+ }),
421
+ ScaleY(ref s) => TransformComponent::Scale(ScaleComponent {
422
+ x: NumericValue::one(),
423
+ y: s.to_numeric_value().ok_or(())?,
424
+ z: NumericValue::one(),
425
+ is_2d: true,
426
+ }),
427
+ ScaleZ(ref s) => TransformComponent::Scale(ScaleComponent {
428
+ x: NumericValue::one(),
429
+ y: NumericValue::one(),
430
+ z: s.to_numeric_value().ok_or(())?,
431
+ is_2d: false,
432
+ }),
433
+ Scale3D(ref sx, ref sy, ref sz) => TransformComponent::Scale(ScaleComponent {
434
+ x: sx.to_numeric_value().ok_or(())?,
435
+ y: sy.to_numeric_value().ok_or(())?,
436
+ z: sz.to_numeric_value().ok_or(())?,
437
+ is_2d: false,
438
+ }),
439
+ Rotate(ref theta) => TransformComponent::Rotate(RotateComponent {
440
+ angle: theta.to_numeric_value().ok_or(())?,
441
+ x: NumericValue::zero(),
442
+ y: NumericValue::zero(),
443
+ z: NumericValue::one(),
444
+ is_2d: true,
445
+ }),
446
+ RotateX(ref theta) => TransformComponent::Rotate(RotateComponent {
447
+ angle: theta.to_numeric_value().ok_or(())?,
448
+ x: NumericValue::one(),
449
+ y: NumericValue::zero(),
450
+ z: NumericValue::zero(),
451
+ is_2d: false,
452
+ }),
453
+ RotateY(ref theta) => TransformComponent::Rotate(RotateComponent {
454
+ angle: theta.to_numeric_value().ok_or(())?,
455
+ x: NumericValue::zero(),
456
+ y: NumericValue::one(),
457
+ z: NumericValue::zero(),
458
+ is_2d: false,
459
+ }),
460
+ RotateZ(ref theta) => TransformComponent::Rotate(RotateComponent {
461
+ angle: theta.to_numeric_value().ok_or(())?,
462
+ x: NumericValue::zero(),
463
+ y: NumericValue::zero(),
464
+ z: NumericValue::one(),
465
+ is_2d: false,
466
+ }),
467
+ Rotate3D(ref ax, ref ay, ref az, ref theta) => {
468
+ TransformComponent::Rotate(RotateComponent {
469
+ angle: theta.to_numeric_value().ok_or(())?,
470
+ x: ax.to_numeric_value().ok_or(())?,
471
+ y: ay.to_numeric_value().ok_or(())?,
472
+ z: az.to_numeric_value().ok_or(())?,
473
+ is_2d: false,
474
+ })
475
+ },
476
+ Perspective(ref p) => {
477
+ let length = match p.to_typed_value().ok_or(())? {
478
+ TypedValue::Numeric(value) => PerspectiveValue::Numeric(value),
479
+ TypedValue::Keyword(value) => PerspectiveValue::Keyword(value),
480
+ _ => return Err(()),
481
+ };
482
+ TransformComponent::Perspective(PerspectiveComponent { length })
483
+ },
484
+ _ => return Err(()),
485
+ };
486
+
487
+ dest.push(component);
488
+ Ok(())
489
+ }
490
+ }
491
+
492
+ #[derive(
493
+ Clone,
494
+ Debug,
495
+ Deserialize,
496
+ MallocSizeOf,
497
+ PartialEq,
498
+ Serialize,
499
+ SpecifiedValueInfo,
500
+ ToAnimatedValue,
501
+ ToComputedValue,
502
+ ToCss,
503
+ ToResolvedValue,
504
+ ToShmem,
505
+ )]
506
+ #[repr(C)]
507
+ /// A value of the `transform` property
508
+ pub struct GenericTransform<T>(#[css(if_empty = "none", iterable)] pub crate::OwnedSlice<T>);
509
+
510
+ pub use self::GenericTransform as Transform;
511
+
512
+ impl<T: ToTransformComponent> ToTyped for Transform<T> {
513
+ fn to_typed(&self, dest: &mut ThinVec<TypedValue>) -> Result<(), ()> {
514
+ if self.0.is_empty() {
515
+ dest.push(TypedValue::Keyword(KeywordValue(CssString::from("none"))));
516
+ return Ok(());
517
+ }
518
+
519
+ // https://drafts.css-houdini.org/css-typed-om-1/#reify-a-transform-list
520
+ let mut values = ThinVec::new();
521
+
522
+ let ops: &[T] = &self.0;
523
+ for item in ops {
524
+ item.to_transform_component(&mut values)?;
525
+ }
526
+
527
+ dest.push(TypedValue::Transform(values));
528
+ Ok(())
529
+ }
530
+ }
531
+
532
+ impl<Angle, Number, Length, Integer, LengthPercentage>
533
+ TransformOperation<Angle, Number, Length, Integer, LengthPercentage>
534
+ where
535
+ Angle: Zero,
536
+ LengthPercentage: Zero + ZeroNoPercent,
537
+ Number: PartialEq,
538
+ {
539
+ /// Check if it is any rotate function.
540
+ pub fn is_rotate(&self) -> bool {
541
+ use self::TransformOperation::*;
542
+ matches!(
543
+ *self,
544
+ Rotate(..) | Rotate3D(..) | RotateX(..) | RotateY(..) | RotateZ(..)
545
+ )
546
+ }
547
+
548
+ /// Check if it is any translate function
549
+ pub fn is_translate(&self) -> bool {
550
+ use self::TransformOperation::*;
551
+ match *self {
552
+ Translate(..) | Translate3D(..) | TranslateX(..) | TranslateY(..) | TranslateZ(..) => {
553
+ true
554
+ },
555
+ _ => false,
556
+ }
557
+ }
558
+
559
+ /// Check if it is any scale function
560
+ pub fn is_scale(&self) -> bool {
561
+ use self::TransformOperation::*;
562
+ match *self {
563
+ Scale(..) | Scale3D(..) | ScaleX(..) | ScaleY(..) | ScaleZ(..) => true,
564
+ _ => false,
565
+ }
566
+ }
567
+ }
568
+
569
+ /// Convert a length type into the absolute lengths.
570
+ pub trait ToAbsoluteLength {
571
+ /// Returns the absolute length as pixel value.
572
+ fn to_pixel_length(&self, containing_len: Option<ComputedLength>) -> Result<CSSFloat, ()>;
573
+ }
574
+
575
+ impl ToAbsoluteLength for SpecifiedLength {
576
+ // This returns Err(()) if there is any relative length or percentage. We use this when
577
+ // parsing a transform list of DOMMatrix because we want to return a DOM Exception
578
+ // if there is relative length.
579
+ #[inline]
580
+ fn to_pixel_length(&self, _containing_len: Option<ComputedLength>) -> Result<CSSFloat, ()> {
581
+ self.to_computed_pixel_length_without_context()
582
+ }
583
+ }
584
+
585
+ impl ToAbsoluteLength for SpecifiedLengthPercentage {
586
+ // This returns Err(()) if there is any relative length or percentage. We use this when
587
+ // parsing a transform list of DOMMatrix because we want to return a DOM Exception
588
+ // if there is relative length.
589
+ #[inline]
590
+ fn to_pixel_length(&self, _containing_len: Option<ComputedLength>) -> Result<CSSFloat, ()> {
591
+ use self::SpecifiedLengthPercentage::*;
592
+ match *self {
593
+ Length(len) => len.to_computed_pixel_length_without_context(),
594
+ Calc(ref calc) => calc.to_computed_pixel_length_without_context(),
595
+ Percentage(..) => Err(()),
596
+ }
597
+ }
598
+ }
599
+
600
+ impl ToAbsoluteLength for ComputedLength {
601
+ #[inline]
602
+ fn to_pixel_length(&self, _containing_len: Option<ComputedLength>) -> Result<CSSFloat, ()> {
603
+ Ok(self.px())
604
+ }
605
+ }
606
+
607
+ impl ToAbsoluteLength for ComputedLengthPercentage {
608
+ #[inline]
609
+ fn to_pixel_length(&self, containing_len: Option<ComputedLength>) -> Result<CSSFloat, ()> {
610
+ Ok(self
611
+ .maybe_percentage_relative_to(containing_len)
612
+ .ok_or(())?
613
+ .px())
614
+ }
615
+ }
616
+
617
+ /// Support the conversion to a 3d matrix.
618
+ pub trait ToMatrix {
619
+ /// Check if it is a 3d transform function.
620
+ fn is_3d(&self) -> bool;
621
+
622
+ /// Return the equivalent 3d matrix.
623
+ fn to_3d_matrix(
624
+ &self,
625
+ reference_box: Option<&Rect<ComputedLength>>,
626
+ ) -> Result<Transform3D<f64>, ()>;
627
+ }
628
+
629
+ /// A little helper to deal with both specified and computed angles.
630
+ pub trait ToRadians {
631
+ /// Return the radians value as a 64-bit floating point value.
632
+ fn radians64(&self) -> Result<f64, ()>;
633
+ }
634
+
635
+ impl ToRadians for computed::angle::Angle {
636
+ #[inline]
637
+ fn radians64(&self) -> Result<f64, ()> {
638
+ Ok(computed::angle::Angle::radians64(self))
639
+ }
640
+ }
641
+
642
+ impl ToRadians for SpecifiedAngle {
643
+ #[inline]
644
+ fn radians64(&self) -> Result<f64, ()> {
645
+ let degrees = self.degrees().ok_or(())?;
646
+ Ok(computed::angle::Angle::from_degrees(degrees).radians64())
647
+ }
648
+ }
649
+
650
+ /// Convert a number type into a float.
651
+ pub trait ToFloat {
652
+ /// Return the number as an f32, or Err(()) if the conversion is not possible.
653
+ fn to_f32(&self) -> Result<f32, ()>;
654
+
655
+ /// Return the number as an f64, or Err(()) if the conversion is not possible.
656
+ fn to_f64(&self) -> Result<f64, ()>;
657
+ }
658
+
659
+ impl ToFloat for SpecifiedNumber {
660
+ #[inline]
661
+ fn to_f32(&self) -> Result<f32, ()> {
662
+ self.resolve().ok_or(())
663
+ }
664
+
665
+ #[inline]
666
+ fn to_f64(&self) -> Result<f64, ()> {
667
+ self.resolve().map(|v| v as f64).ok_or(())
668
+ }
669
+ }
670
+
671
+ impl ToFloat for computed::Number {
672
+ #[inline]
673
+ fn to_f32(&self) -> Result<f32, ()> {
674
+ Ok(*self)
675
+ }
676
+
677
+ #[inline]
678
+ fn to_f64(&self) -> Result<f64, ()> {
679
+ Ok(*self as f64)
680
+ }
681
+ }
682
+
683
+ impl<Angle, Number, Length, Integer, LoP> ToMatrix
684
+ for TransformOperation<Angle, Number, Length, Integer, LoP>
685
+ where
686
+ Angle: Zero + ToRadians + Clone,
687
+ Number: PartialEq + Clone + ToFloat + ToFloat,
688
+ Length: ToAbsoluteLength,
689
+ LoP: Zero + ToAbsoluteLength + ZeroNoPercent,
690
+ {
691
+ #[inline]
692
+ fn is_3d(&self) -> bool {
693
+ use self::TransformOperation::*;
694
+ match *self {
695
+ Translate3D(..) | TranslateZ(..) | Rotate3D(..) | RotateX(..) | RotateY(..)
696
+ | RotateZ(..) | Scale3D(..) | ScaleZ(..) | Perspective(..) | Matrix3D(..) => true,
697
+ _ => false,
698
+ }
699
+ }
700
+
701
+ /// If |reference_box| is None, we will drop the percent part from translate because
702
+ /// we cannot resolve it without the layout info, for computed TransformOperation.
703
+ /// However, for specified TransformOperation, we will return Err(()) if there is any relative
704
+ /// lengths because the only caller, DOMMatrix, doesn't accept relative lengths.
705
+ #[inline]
706
+ fn to_3d_matrix(
707
+ &self,
708
+ reference_box: Option<&Rect<ComputedLength>>,
709
+ ) -> Result<Transform3D<f64>, ()> {
710
+ use self::TransformOperation::*;
711
+
712
+ let reference_width = reference_box.map(|v| v.size.width);
713
+ let reference_height = reference_box.map(|v| v.size.height);
714
+ let matrix = match *self {
715
+ Rotate3D(ref ax, ref ay, ref az, ref theta) => {
716
+ let theta = theta.radians64()?;
717
+ let (ax, ay, az, theta) = get_normalized_vector_and_angle(
718
+ ax.to_f32()?,
719
+ ay.to_f32()?,
720
+ az.to_f32()?,
721
+ theta,
722
+ );
723
+ Transform3D::rotation(
724
+ ax as f64,
725
+ ay as f64,
726
+ az as f64,
727
+ euclid::Angle::radians(theta),
728
+ )
729
+ },
730
+ RotateX(ref theta) => {
731
+ let theta = euclid::Angle::radians(theta.radians64()?);
732
+ Transform3D::rotation(1., 0., 0., theta)
733
+ },
734
+ RotateY(ref theta) => {
735
+ let theta = euclid::Angle::radians(theta.radians64()?);
736
+ Transform3D::rotation(0., 1., 0., theta)
737
+ },
738
+ RotateZ(ref theta) | Rotate(ref theta) => {
739
+ let theta = euclid::Angle::radians(theta.radians64()?);
740
+ Transform3D::rotation(0., 0., 1., theta)
741
+ },
742
+ Perspective(ref p) => {
743
+ let px = match p {
744
+ PerspectiveFunction::None => f32::INFINITY,
745
+ PerspectiveFunction::Length(p) => p.to_pixel_length(None)?,
746
+ };
747
+ create_perspective_matrix(px).cast()
748
+ },
749
+ Scale3D(ref sx, ref sy, ref sz) => {
750
+ Transform3D::scale(sx.to_f64()?, sy.to_f64()?, sz.to_f64()?)
751
+ },
752
+ Scale(ref sx, ref sy) => Transform3D::scale(sx.to_f64()?, sy.to_f64()?, 1.),
753
+ ScaleX(ref s) => Transform3D::scale(s.to_f64()?, 1., 1.),
754
+ ScaleY(ref s) => Transform3D::scale(1., s.to_f64()?, 1.),
755
+ ScaleZ(ref s) => Transform3D::scale(1., 1., s.to_f64()?),
756
+ Translate3D(ref tx, ref ty, ref tz) => {
757
+ let tx = tx.to_pixel_length(reference_width)? as f64;
758
+ let ty = ty.to_pixel_length(reference_height)? as f64;
759
+ Transform3D::translation(tx, ty, tz.to_pixel_length(None)? as f64)
760
+ },
761
+ Translate(ref tx, ref ty) => {
762
+ let tx = tx.to_pixel_length(reference_width)? as f64;
763
+ let ty = ty.to_pixel_length(reference_height)? as f64;
764
+ Transform3D::translation(tx, ty, 0.)
765
+ },
766
+ TranslateX(ref t) => {
767
+ let t = t.to_pixel_length(reference_width)? as f64;
768
+ Transform3D::translation(t, 0., 0.)
769
+ },
770
+ TranslateY(ref t) => {
771
+ let t = t.to_pixel_length(reference_height)? as f64;
772
+ Transform3D::translation(0., t, 0.)
773
+ },
774
+ TranslateZ(ref z) => Transform3D::translation(0., 0., z.to_pixel_length(None)? as f64),
775
+ Skew(ref theta_x, ref theta_y) => Transform3D::skew(
776
+ euclid::Angle::radians(theta_x.radians64()?),
777
+ euclid::Angle::radians(theta_y.radians64()?),
778
+ ),
779
+ SkewX(ref theta) => Transform3D::skew(
780
+ euclid::Angle::radians(theta.radians64()?),
781
+ euclid::Angle::radians(0.),
782
+ ),
783
+ SkewY(ref theta) => Transform3D::skew(
784
+ euclid::Angle::radians(0.),
785
+ euclid::Angle::radians(theta.radians64()?),
786
+ ),
787
+ Matrix3D(ref m) => m.clone().try_into()?,
788
+ Matrix(ref m) => m.clone().try_into()?,
789
+ InterpolateMatrix { .. } | AccumulateMatrix { .. } => {
790
+ // TODO: Convert InterpolateMatrix/AccumulateMatrix into a valid Transform3D by
791
+ // the reference box and do interpolation on these two Transform3D matrices.
792
+ // Both Gecko and Servo don't support this for computing distance, and Servo
793
+ // doesn't support animations on InterpolateMatrix/AccumulateMatrix, so
794
+ // return an identity matrix.
795
+ // Note: DOMMatrix doesn't go into this arm.
796
+ Transform3D::identity()
797
+ },
798
+ };
799
+ Ok(matrix)
800
+ }
801
+ }
802
+
803
+ impl<T> Transform<T> {
804
+ /// `none`
805
+ pub fn none() -> Self {
806
+ Transform(Default::default())
807
+ }
808
+ }
809
+
810
+ impl<T: ToMatrix> Transform<T> {
811
+ /// Return the equivalent 3d matrix of this transform list.
812
+ ///
813
+ /// We return a pair: the first one is the transform matrix, and the second one
814
+ /// indicates if there is any 3d transform function in this transform list.
815
+ #[rustfmt::skip]
816
+ pub fn to_transform_3d_matrix(
817
+ &self,
818
+ reference_box: Option<&Rect<ComputedLength>>
819
+ ) -> Result<(Transform3D<CSSFloat>, bool), ()> {
820
+ Self::components_to_transform_3d_matrix(&self.0, reference_box)
821
+ }
822
+
823
+ /// Converts a series of components to a 3d matrix.
824
+ #[rustfmt::skip]
825
+ pub fn components_to_transform_3d_matrix(
826
+ ops: &[T],
827
+ reference_box: Option<&Rect<ComputedLength>>,
828
+ ) -> Result<(Transform3D<CSSFloat>, bool), ()> {
829
+ let cast_3d_transform = |m: Transform3D<f64>| -> Transform3D<CSSFloat> {
830
+ let cast = |v: f64| v.min(f32::MAX as f64).max(f32::MIN as f64) as f32;
831
+ Transform3D::new(
832
+ cast(m.m11), cast(m.m12), cast(m.m13), cast(m.m14),
833
+ cast(m.m21), cast(m.m22), cast(m.m23), cast(m.m24),
834
+ cast(m.m31), cast(m.m32), cast(m.m33), cast(m.m34),
835
+ cast(m.m41), cast(m.m42), cast(m.m43), cast(m.m44),
836
+ )
837
+ };
838
+
839
+ let (m, is_3d) = Self::components_to_transform_3d_matrix_f64(ops, reference_box)?;
840
+ Ok((cast_3d_transform(m), is_3d))
841
+ }
842
+
843
+ /// Same as Transform::to_transform_3d_matrix but a f64 version.
844
+ pub fn to_transform_3d_matrix_f64(
845
+ &self,
846
+ reference_box: Option<&Rect<ComputedLength>>,
847
+ ) -> Result<(Transform3D<f64>, bool), ()> {
848
+ Self::components_to_transform_3d_matrix_f64(&self.0, reference_box)
849
+ }
850
+
851
+ /// Same as Transform::components_to_transform_3d_matrix but a f64 version.
852
+ fn components_to_transform_3d_matrix_f64(
853
+ ops: &[T],
854
+ reference_box: Option<&Rect<ComputedLength>>,
855
+ ) -> Result<(Transform3D<f64>, bool), ()> {
856
+ // We intentionally use Transform3D<f64> during computation to avoid
857
+ // error propagation because using f32 to compute triangle functions
858
+ // (e.g. in rotation()) is not accurate enough. In Gecko, we also use
859
+ // "double" to compute the triangle functions. Therefore, let's use
860
+ // Transform3D<f64> during matrix computation and cast it into f32 in
861
+ // the end.
862
+ let mut transform = Transform3D::<f64>::identity();
863
+ let mut contain_3d = false;
864
+
865
+ for operation in ops {
866
+ let matrix = operation.to_3d_matrix(reference_box)?;
867
+ contain_3d = contain_3d || operation.is_3d();
868
+ transform = matrix.then(&transform);
869
+ }
870
+
871
+ Ok((transform, contain_3d))
872
+ }
873
+ }
874
+
875
+ /// Return the transform matrix from a perspective length.
876
+ #[inline]
877
+ pub fn create_perspective_matrix(d: CSSFloat) -> Transform3D<CSSFloat> {
878
+ if d.is_finite() {
879
+ Transform3D::perspective(d.max(1.))
880
+ } else {
881
+ Transform3D::identity()
882
+ }
883
+ }
884
+
885
+ /// Return the normalized direction vector and its angle for Rotate3D.
886
+ pub fn get_normalized_vector_and_angle<T: Zero>(
887
+ x: CSSFloat,
888
+ y: CSSFloat,
889
+ z: CSSFloat,
890
+ angle: T,
891
+ ) -> (CSSFloat, CSSFloat, CSSFloat, T) {
892
+ use crate::values::computed::transform::DirectionVector;
893
+ use euclid::approxeq::ApproxEq;
894
+ let vector = DirectionVector::new(x, y, z);
895
+ if vector.square_length().approx_eq(&f32::zero()) {
896
+ // https://www.w3.org/TR/css-transforms-1/#funcdef-rotate3d
897
+ // A direction vector that cannot be normalized, such as [0, 0, 0], will cause the
898
+ // rotation to not be applied, so we use identity matrix (i.e. rotate3d(0, 0, 1, 0)).
899
+ (0., 0., 1., T::zero())
900
+ } else {
901
+ let vector = vector.robust_normalize();
902
+ (vector.x, vector.y, vector.z, angle)
903
+ }
904
+ }
905
+
906
+ #[derive(
907
+ Clone,
908
+ Copy,
909
+ Debug,
910
+ Deserialize,
911
+ MallocSizeOf,
912
+ PartialEq,
913
+ Serialize,
914
+ SpecifiedValueInfo,
915
+ ToAnimatedValue,
916
+ ToAnimatedZero,
917
+ ToComputedValue,
918
+ ToResolvedValue,
919
+ ToShmem,
920
+ ToTyped,
921
+ )]
922
+ #[repr(C, u8)]
923
+ #[typed(todo_derive_fields)]
924
+ /// A value of the `Rotate` property
925
+ ///
926
+ /// <https://drafts.csswg.org/css-transforms-2/#individual-transforms>
927
+ pub enum GenericRotate<Number, Angle> {
928
+ /// 'none'
929
+ None,
930
+ /// '<angle>'
931
+ Rotate(Angle),
932
+ /// '<number>{3} <angle>'
933
+ Rotate3D(Number, Number, Number, Angle),
934
+ }
935
+
936
+ pub use self::GenericRotate as Rotate;
937
+
938
+ /// A trait to check if the current 3D vector is parallel to the DirectionVector.
939
+ /// This is especially for serialization on Rotate.
940
+ pub trait IsParallelTo {
941
+ /// Returns true if this is parallel to the vector.
942
+ fn is_parallel_to(&self, vector: &computed::transform::DirectionVector) -> bool;
943
+ }
944
+
945
+ impl<Number, Angle> ToCss for Rotate<Number, Angle>
946
+ where
947
+ Number: Clone + PartialOrd + ToCss + Zero,
948
+ Angle: Clone + Neg<Output = Angle> + ToCss + Zero,
949
+ (Number, Number, Number): IsParallelTo,
950
+ {
951
+ fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
952
+ where
953
+ W: fmt::Write,
954
+ {
955
+ use crate::values::computed::transform::DirectionVector;
956
+ match *self {
957
+ Rotate::None => dest.write_str("none"),
958
+ Rotate::Rotate(ref angle) => angle.to_css(dest),
959
+ Rotate::Rotate3D(ref x, ref y, ref z, ref angle) => {
960
+ // If the axis is parallel with the x or y axes, it must serialize as the
961
+ // appropriate keyword. If a rotation about the z axis (that is, in 2D) is
962
+ // specified, the property must serialize as just an <angle>.
963
+ //
964
+ // Note that if the axis is parallel to x/y/z but pointing in the opposite
965
+ // direction, we need to negate the angle to maintain the correct meaning.
966
+ //
967
+ // https://drafts.csswg.org/css-transforms-2/#individual-transform-serialization
968
+ let v = (x.clone(), y.clone(), z.clone());
969
+ let (axis, angle) = if v.0.is_zero() && v.1.is_zero() && v.2.is_zero() {
970
+ // The zero length vector is parallel to every other vector, so
971
+ // is_parallel_to() returns true for it. However, it is definitely different
972
+ // from x axis, y axis, or z axis, and it's meaningless to perform a rotation
973
+ // using that direction vector. So we *have* to serialize it using that same
974
+ // vector - we can't simplify to some theoretically parallel axis-aligned
975
+ // vector.
976
+ (None, angle.clone())
977
+ } else if v.is_parallel_to(&DirectionVector::new(1., 0., 0.)) {
978
+ (
979
+ Some("x "),
980
+ if v.0 < Number::zero() {
981
+ -angle.clone()
982
+ } else {
983
+ angle.clone()
984
+ },
985
+ )
986
+ } else if v.is_parallel_to(&DirectionVector::new(0., 1., 0.)) {
987
+ (
988
+ Some("y "),
989
+ if v.1 < Number::zero() {
990
+ -angle.clone()
991
+ } else {
992
+ angle.clone()
993
+ },
994
+ )
995
+ } else if v.is_parallel_to(&DirectionVector::new(0., 0., 1.)) {
996
+ // When we're parallel to the z-axis, we can just serialize the angle.
997
+ let angle = if v.2 < Number::zero() {
998
+ -angle.clone()
999
+ } else {
1000
+ angle.clone()
1001
+ };
1002
+ return angle.to_css(dest);
1003
+ } else {
1004
+ (None, angle.clone())
1005
+ };
1006
+ match axis {
1007
+ Some(a) => dest.write_str(a)?,
1008
+ None => {
1009
+ x.to_css(dest)?;
1010
+ dest.write_char(' ')?;
1011
+ y.to_css(dest)?;
1012
+ dest.write_char(' ')?;
1013
+ z.to_css(dest)?;
1014
+ dest.write_char(' ')?;
1015
+ },
1016
+ }
1017
+ angle.to_css(dest)
1018
+ },
1019
+ }
1020
+ }
1021
+ }
1022
+
1023
+ #[derive(
1024
+ Clone,
1025
+ Copy,
1026
+ Debug,
1027
+ Deserialize,
1028
+ MallocSizeOf,
1029
+ PartialEq,
1030
+ Serialize,
1031
+ SpecifiedValueInfo,
1032
+ ToAnimatedValue,
1033
+ ToAnimatedZero,
1034
+ ToComputedValue,
1035
+ ToResolvedValue,
1036
+ ToShmem,
1037
+ ToTyped,
1038
+ )]
1039
+ #[repr(C, u8)]
1040
+ /// A value of the `Scale` property
1041
+ ///
1042
+ /// <https://drafts.csswg.org/css-transforms-2/#individual-transforms>
1043
+ pub enum GenericScale<Number> {
1044
+ /// 'none'
1045
+ None,
1046
+ /// '<number>{1,3}'
1047
+ Scale(Number, Number, Number),
1048
+ }
1049
+
1050
+ pub use self::GenericScale as Scale;
1051
+
1052
+ impl<Number> ToCss for Scale<Number>
1053
+ where
1054
+ Number: ToCss + PartialEq + Clone + ToFloat,
1055
+ {
1056
+ fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
1057
+ where
1058
+ W: fmt::Write,
1059
+ {
1060
+ match *self {
1061
+ Scale::None => dest.write_str("none"),
1062
+ Scale::Scale(ref x, ref y, ref z) => {
1063
+ x.to_css(dest)?;
1064
+
1065
+ let serialize_z = z.to_f32() != Ok(1.0);
1066
+ if serialize_z || x != y {
1067
+ dest.write_char(' ')?;
1068
+ y.to_css(dest)?;
1069
+ }
1070
+
1071
+ if serialize_z {
1072
+ dest.write_char(' ')?;
1073
+ z.to_css(dest)?;
1074
+ }
1075
+ Ok(())
1076
+ },
1077
+ }
1078
+ }
1079
+ }
1080
+
1081
+ #[inline]
1082
+ fn y_axis_and_z_axis_are_zero<LengthPercentage: Zero + ZeroNoPercent, Length: Zero>(
1083
+ _: &LengthPercentage,
1084
+ y: &LengthPercentage,
1085
+ z: &Length,
1086
+ ) -> bool {
1087
+ y.is_zero_no_percent() && z.is_zero()
1088
+ }
1089
+
1090
+ #[derive(
1091
+ Clone,
1092
+ Debug,
1093
+ Deserialize,
1094
+ MallocSizeOf,
1095
+ PartialEq,
1096
+ Serialize,
1097
+ SpecifiedValueInfo,
1098
+ ToAnimatedValue,
1099
+ ToAnimatedZero,
1100
+ ToComputedValue,
1101
+ ToCss,
1102
+ ToResolvedValue,
1103
+ ToShmem,
1104
+ ToTyped,
1105
+ )]
1106
+ #[repr(C, u8)]
1107
+ /// A value of the `translate` property
1108
+ ///
1109
+ /// https://drafts.csswg.org/css-transforms-2/#individual-transform-serialization:
1110
+ ///
1111
+ /// If a 2d translation is specified, the property must serialize with only one
1112
+ /// or two values (per usual, if the second value is 0px, the default, it must
1113
+ /// be omitted when serializing; however if 0% is the second value, it is included).
1114
+ ///
1115
+ /// If a 3d translation is specified and the value can be expressed as 2d, we treat as 2d and
1116
+ /// serialize accoringly. Otherwise, we serialize all three values.
1117
+ /// https://github.com/w3c/csswg-drafts/issues/3305
1118
+ ///
1119
+ /// <https://drafts.csswg.org/css-transforms-2/#individual-transforms>
1120
+ pub enum GenericTranslate<LengthPercentage, Length>
1121
+ where
1122
+ LengthPercentage: Zero + ZeroNoPercent,
1123
+ Length: Zero,
1124
+ {
1125
+ /// 'none'
1126
+ None,
1127
+ /// <length-percentage> [ <length-percentage> <length>? ]?
1128
+ Translate(
1129
+ LengthPercentage,
1130
+ #[css(contextual_skip_if = "y_axis_and_z_axis_are_zero")] LengthPercentage,
1131
+ #[css(skip_if = "Zero::is_zero")] Length,
1132
+ ),
1133
+ }
1134
+
1135
+ pub use self::GenericTranslate as Translate;
1136
+
1137
+ #[allow(missing_docs)]
1138
+ #[derive(
1139
+ Clone,
1140
+ Copy,
1141
+ Debug,
1142
+ MallocSizeOf,
1143
+ Parse,
1144
+ PartialEq,
1145
+ SpecifiedValueInfo,
1146
+ ToComputedValue,
1147
+ ToCss,
1148
+ ToResolvedValue,
1149
+ ToShmem,
1150
+ ToTyped,
1151
+ )]
1152
+ #[repr(u8)]
1153
+ pub enum TransformStyle {
1154
+ Flat,
1155
+ #[css(keyword = "preserve-3d")]
1156
+ Preserve3d,
1157
+ }