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.
- package/LICENSE +21 -0
- package/README.md +355 -2
- package/THIRD_PARTY_NOTICES.md +25 -0
- package/assets/icon.svg +4 -0
- package/dist/api.d.ts +7 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +46 -0
- package/dist/api.js.map +1 -0
- package/dist/assets.d.ts +7 -0
- package/dist/assets.d.ts.map +1 -0
- package/dist/assets.js +52 -0
- package/dist/assets.js.map +1 -0
- package/dist/browser.d.ts +3 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +3 -0
- package/dist/browser.js.map +1 -0
- package/dist/node.d.ts +3 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +10 -0
- package/dist/node.js.map +1 -0
- package/dist/options.d.ts +24 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +135 -0
- package/dist/options.js.map +1 -0
- package/dist/types.d.ts +51 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/examples/bun.ts +8 -0
- package/examples/german-invoice/README.md +70 -0
- package/examples/german-invoice/data.mjs +83 -0
- package/examples/german-invoice/invoice.css +59 -0
- package/examples/german-invoice/template.mjs +49 -0
- package/examples/german-invoice.mjs +20 -0
- package/examples/invoice.html +29 -0
- package/examples/node.mjs +8 -0
- package/examples/pagination.html +40 -0
- package/examples/pagination.mjs +8 -0
- package/licenses/DejaVu.txt +187 -0
- package/licenses/RUST_DEPENDENCIES.txt +11577 -0
- package/package.json +89 -4
- package/src/api.ts +44 -0
- package/src/assets.ts +43 -0
- package/src/browser.ts +6 -0
- package/src/node.ts +12 -0
- package/src/options.ts +101 -0
- package/src/types.ts +49 -0
- package/vendor/README.md +17 -0
- package/vendor/stylo/.cargo-ok +1 -0
- package/vendor/stylo/.cargo_vcs_info.json +6 -0
- package/vendor/stylo/Cargo.lock +1485 -0
- package/vendor/stylo/Cargo.toml +274 -0
- package/vendor/stylo/LICENSE +373 -0
- package/vendor/stylo/README.md +6 -0
- package/vendor/stylo/applicable_declarations.rs +328 -0
- package/vendor/stylo/author_styles.rs +79 -0
- package/vendor/stylo/bezier.rs +176 -0
- package/vendor/stylo/bloom.rs +414 -0
- package/vendor/stylo/build.rs +91 -0
- package/vendor/stylo/build_gecko.rs +393 -0
- package/vendor/stylo/color/color_function.rs +601 -0
- package/vendor/stylo/color/component.rs +207 -0
- package/vendor/stylo/color/convert.rs +935 -0
- package/vendor/stylo/color/gamut/raytrace.rs +265 -0
- package/vendor/stylo/color/gamut.rs +227 -0
- package/vendor/stylo/color/mix.rs +645 -0
- package/vendor/stylo/color/mod.rs +750 -0
- package/vendor/stylo/color/parsing.rs +770 -0
- package/vendor/stylo/color/to_css.rs +297 -0
- package/vendor/stylo/context.rs +716 -0
- package/vendor/stylo/counter_style/mod.rs +754 -0
- package/vendor/stylo/counter_style/predefined.rs +61 -0
- package/vendor/stylo/counter_style/update_predefined.py +35 -0
- package/vendor/stylo/custom_properties.rs +2023 -0
- package/vendor/stylo/custom_properties_map.rs +220 -0
- package/vendor/stylo/data.rs +693 -0
- package/vendor/stylo/device/gecko.rs +486 -0
- package/vendor/stylo/device/mod.rs +304 -0
- package/vendor/stylo/device/servo.rs +507 -0
- package/vendor/stylo/dom.rs +1164 -0
- package/vendor/stylo/dom_apis.rs +937 -0
- package/vendor/stylo/driver.rs +172 -0
- package/vendor/stylo/error_reporting.rs +484 -0
- package/vendor/stylo/font_face.rs +558 -0
- package/vendor/stylo/font_metrics.rs +124 -0
- package/vendor/stylo/gecko/anon_boxes.toml +113 -0
- package/vendor/stylo/gecko/arc_types.rs +211 -0
- package/vendor/stylo/gecko/conversions.rs +59 -0
- package/vendor/stylo/gecko/data.rs +222 -0
- package/vendor/stylo/gecko/media_features.rs +971 -0
- package/vendor/stylo/gecko/mod.rs +20 -0
- package/vendor/stylo/gecko/non_ts_pseudo_class_list.rs +119 -0
- package/vendor/stylo/gecko/pseudo_element.rs +640 -0
- package/vendor/stylo/gecko/pseudo_element_definition.mako.rs +298 -0
- package/vendor/stylo/gecko/pseudo_elements.py +137 -0
- package/vendor/stylo/gecko/pseudo_elements.toml +197 -0
- package/vendor/stylo/gecko/regen_pseudo_elements.py +33 -0
- package/vendor/stylo/gecko/restyle_damage.rs +127 -0
- package/vendor/stylo/gecko/selector_parser.rs +627 -0
- package/vendor/stylo/gecko/snapshot.rs +202 -0
- package/vendor/stylo/gecko/snapshot_helpers.rs +334 -0
- package/vendor/stylo/gecko/traversal.rs +52 -0
- package/vendor/stylo/gecko/wrapper.rs +2258 -0
- package/vendor/stylo/gecko_bindings/mod.rs +34 -0
- package/vendor/stylo/gecko_bindings/sugar/mod.rs +12 -0
- package/vendor/stylo/gecko_bindings/sugar/ns_com_ptr.rs +15 -0
- package/vendor/stylo/gecko_bindings/sugar/ns_compatibility.rs +19 -0
- package/vendor/stylo/gecko_bindings/sugar/ns_style_auto_array.rs +111 -0
- package/vendor/stylo/gecko_bindings/sugar/origin_flags.rs +31 -0
- package/vendor/stylo/gecko_bindings/sugar/ownership.rs +70 -0
- package/vendor/stylo/gecko_bindings/sugar/refptr.rs +299 -0
- package/vendor/stylo/gecko_string_cache/mod.rs +543 -0
- package/vendor/stylo/gecko_string_cache/namespace.rs +106 -0
- package/vendor/stylo/global_style_data.rs +224 -0
- package/vendor/stylo/invalidation/element/document_state.rs +156 -0
- package/vendor/stylo/invalidation/element/element_wrapper.rs +432 -0
- package/vendor/stylo/invalidation/element/invalidation_map.rs +1631 -0
- package/vendor/stylo/invalidation/element/invalidator.rs +1470 -0
- package/vendor/stylo/invalidation/element/mod.rs +13 -0
- package/vendor/stylo/invalidation/element/relative_selector.rs +1399 -0
- package/vendor/stylo/invalidation/element/restyle_hints.rs +226 -0
- package/vendor/stylo/invalidation/element/state_and_attributes.rs +756 -0
- package/vendor/stylo/invalidation/media_queries.rs +144 -0
- package/vendor/stylo/invalidation/mod.rs +10 -0
- package/vendor/stylo/invalidation/stylesheets.rs +745 -0
- package/vendor/stylo/invalidation/viewport_units.rs +71 -0
- package/vendor/stylo/lib.rs +336 -0
- package/vendor/stylo/logical_geometry.rs +1684 -0
- package/vendor/stylo/macros.rs +70 -0
- package/vendor/stylo/matching.rs +1226 -0
- package/vendor/stylo/media_queries/media_list.rs +168 -0
- package/vendor/stylo/media_queries/media_query.rs +190 -0
- package/vendor/stylo/media_queries/mod.rs +13 -0
- package/vendor/stylo/parallel.rs +205 -0
- package/vendor/stylo/parser.rs +276 -0
- package/vendor/stylo/piecewise_linear.rs +282 -0
- package/vendor/stylo/prefs.rs +33 -0
- package/vendor/stylo/properties/build.py +119 -0
- package/vendor/stylo/properties/cascade.rs +2704 -0
- package/vendor/stylo/properties/computed_value_flags.rs +206 -0
- package/vendor/stylo/properties/counted_unknown_properties.py +104 -0
- package/vendor/stylo/properties/counter_style_descriptors.toml +45 -0
- package/vendor/stylo/properties/data.py +1375 -0
- package/vendor/stylo/properties/declaration_block.rs +1788 -0
- package/vendor/stylo/properties/font_face_descriptors.toml +50 -0
- package/vendor/stylo/properties/gecko.mako.rs +1555 -0
- package/vendor/stylo/properties/helpers/animated_properties.mako.rs +800 -0
- package/vendor/stylo/properties/helpers.mako.rs +812 -0
- package/vendor/stylo/properties/longhands.toml +4305 -0
- package/vendor/stylo/properties/mod.rs +1857 -0
- package/vendor/stylo/properties/properties.html.mako +31 -0
- package/vendor/stylo/properties/properties.mako.rs +3103 -0
- package/vendor/stylo/properties/property_descriptors.toml +18 -0
- package/vendor/stylo/properties/shorthands.rs +4241 -0
- package/vendor/stylo/properties/shorthands.toml +575 -0
- package/vendor/stylo/properties/vendored_python/mako-1.3.10-py3-none-any.whl +0 -0
- package/vendor/stylo/properties/vendored_python/markupsafe/LICENSE.txt +28 -0
- package/vendor/stylo/properties/vendored_python/markupsafe/__init__.py +384 -0
- package/vendor/stylo/properties/vendored_python/toml-0.10.2-py2.py3-none-any.whl +0 -0
- package/vendor/stylo/properties/view_transition_descriptors.toml +11 -0
- package/vendor/stylo/properties_and_values/mod.rs +12 -0
- package/vendor/stylo/properties_and_values/registry.rs +65 -0
- package/vendor/stylo/properties_and_values/rule.rs +331 -0
- package/vendor/stylo/properties_and_values/syntax/ascii.rs +60 -0
- package/vendor/stylo/properties_and_values/syntax/data_type.rs +146 -0
- package/vendor/stylo/properties_and_values/syntax/mod.rs +437 -0
- package/vendor/stylo/properties_and_values/value.rs +758 -0
- package/vendor/stylo/queries/condition.rs +996 -0
- package/vendor/stylo/queries/feature.rs +199 -0
- package/vendor/stylo/queries/feature_expression.rs +1170 -0
- package/vendor/stylo/queries/mod.rs +19 -0
- package/vendor/stylo/queries/values.rs +46 -0
- package/vendor/stylo/rule_cache.rs +267 -0
- package/vendor/stylo/rule_collector.rs +554 -0
- package/vendor/stylo/rule_tree/core.rs +787 -0
- package/vendor/stylo/rule_tree/level.rs +396 -0
- package/vendor/stylo/rule_tree/map.rs +201 -0
- package/vendor/stylo/rule_tree/mod.rs +427 -0
- package/vendor/stylo/rule_tree/source.rs +80 -0
- package/vendor/stylo/rule_tree/unsafe_box.rs +78 -0
- package/vendor/stylo/scoped_tls.rs +80 -0
- package/vendor/stylo/selector_map.rs +1050 -0
- package/vendor/stylo/selector_parser.rs +305 -0
- package/vendor/stylo/servo/animation.rs +1922 -0
- package/vendor/stylo/servo/attr.rs +714 -0
- package/vendor/stylo/servo/encoding_support.rs +81 -0
- package/vendor/stylo/servo/media_features.rs +254 -0
- package/vendor/stylo/servo/mod.rs +16 -0
- package/vendor/stylo/servo/restyle_damage.rs +215 -0
- package/vendor/stylo/servo/selector_parser.rs +1036 -0
- package/vendor/stylo/servo/shadow_parts.rs +207 -0
- package/vendor/stylo/shared_lock.rs +271 -0
- package/vendor/stylo/sharing/checks.rs +281 -0
- package/vendor/stylo/sharing/mod.rs +1000 -0
- package/vendor/stylo/simple_buckets_map.rs +52 -0
- package/vendor/stylo/str.rs +168 -0
- package/vendor/stylo/style_adjuster.rs +1086 -0
- package/vendor/stylo/style_resolver.rs +658 -0
- package/vendor/stylo/stylesheet_set.rs +658 -0
- package/vendor/stylo/stylesheets/appearance_base_rule.rs +51 -0
- package/vendor/stylo/stylesheets/container_rule.rs +769 -0
- package/vendor/stylo/stylesheets/counter_style_rule.rs +7 -0
- package/vendor/stylo/stylesheets/document_rule.rs +272 -0
- package/vendor/stylo/stylesheets/font_face_rule.rs +7 -0
- package/vendor/stylo/stylesheets/font_feature_values_rule.rs +481 -0
- package/vendor/stylo/stylesheets/font_palette_values_rule.rs +304 -0
- package/vendor/stylo/stylesheets/import_rule.rs +259 -0
- package/vendor/stylo/stylesheets/keyframes_rule.rs +733 -0
- package/vendor/stylo/stylesheets/layer_rule.rs +221 -0
- package/vendor/stylo/stylesheets/loader.rs +29 -0
- package/vendor/stylo/stylesheets/margin_rule.rs +190 -0
- package/vendor/stylo/stylesheets/media_rule.rs +191 -0
- package/vendor/stylo/stylesheets/mod.rs +918 -0
- package/vendor/stylo/stylesheets/namespace_rule.rs +43 -0
- package/vendor/stylo/stylesheets/nested_declarations_rule.rs +51 -0
- package/vendor/stylo/stylesheets/origin.rs +249 -0
- package/vendor/stylo/stylesheets/page_rule.rs +354 -0
- package/vendor/stylo/stylesheets/position_try_rule.rs +68 -0
- package/vendor/stylo/stylesheets/property_rule.rs +5 -0
- package/vendor/stylo/stylesheets/rule_list.rs +167 -0
- package/vendor/stylo/stylesheets/rule_parser.rs +1189 -0
- package/vendor/stylo/stylesheets/rules_iterator.rs +397 -0
- package/vendor/stylo/stylesheets/scope_rule.rs +511 -0
- package/vendor/stylo/stylesheets/starting_style_rule.rs +54 -0
- package/vendor/stylo/stylesheets/style_rule.rs +80 -0
- package/vendor/stylo/stylesheets/stylesheet.rs +570 -0
- package/vendor/stylo/stylesheets/supports_rule.rs +486 -0
- package/vendor/stylo/stylesheets/view_transition_rule.rs +81 -0
- package/vendor/stylo/stylist.rs +5076 -0
- package/vendor/stylo/thread_state.rs +87 -0
- package/vendor/stylo/traversal.rs +765 -0
- package/vendor/stylo/traversal_flags.rs +68 -0
- package/vendor/stylo/typed_om/mod.rs +981 -0
- package/vendor/stylo/typed_om/numeric.rs +128 -0
- package/vendor/stylo/typed_om/numeric_declaration.rs +93 -0
- package/vendor/stylo/typed_om/numeric_type.rs +640 -0
- package/vendor/stylo/typed_om/sum_value.rs +426 -0
- package/vendor/stylo/url/gecko.rs +367 -0
- package/vendor/stylo/url/mod.rs +71 -0
- package/vendor/stylo/url/servo.rs +239 -0
- package/vendor/stylo/use_counters/mod.rs +137 -0
- package/vendor/stylo/values/animated/color.rs +103 -0
- package/vendor/stylo/values/animated/effects.rs +26 -0
- package/vendor/stylo/values/animated/font.rs +37 -0
- package/vendor/stylo/values/animated/grid.rs +161 -0
- package/vendor/stylo/values/animated/lists.rs +141 -0
- package/vendor/stylo/values/animated/mod.rs +550 -0
- package/vendor/stylo/values/animated/svg.rs +46 -0
- package/vendor/stylo/values/animated/text.rs +58 -0
- package/vendor/stylo/values/animated/transform.rs +1592 -0
- package/vendor/stylo/values/computed/align.rs +90 -0
- package/vendor/stylo/values/computed/angle.rs +130 -0
- package/vendor/stylo/values/computed/animation.rs +124 -0
- package/vendor/stylo/values/computed/background.rs +13 -0
- package/vendor/stylo/values/computed/basic_shape.rs +267 -0
- package/vendor/stylo/values/computed/border.rs +163 -0
- package/vendor/stylo/values/computed/box.rs +267 -0
- package/vendor/stylo/values/computed/calc.rs +334 -0
- package/vendor/stylo/values/computed/color.rs +161 -0
- package/vendor/stylo/values/computed/column.rs +11 -0
- package/vendor/stylo/values/computed/corner_shape.rs +155 -0
- package/vendor/stylo/values/computed/counters.rs +26 -0
- package/vendor/stylo/values/computed/easing.rs +109 -0
- package/vendor/stylo/values/computed/effects.rs +30 -0
- package/vendor/stylo/values/computed/flex.rs +19 -0
- package/vendor/stylo/values/computed/font.rs +1517 -0
- package/vendor/stylo/values/computed/image.rs +273 -0
- package/vendor/stylo/values/computed/length.rs +576 -0
- package/vendor/stylo/values/computed/length_percentage.rs +1055 -0
- package/vendor/stylo/values/computed/list.rs +16 -0
- package/vendor/stylo/values/computed/mod.rs +1141 -0
- package/vendor/stylo/values/computed/motion.rs +73 -0
- package/vendor/stylo/values/computed/outline.rs +7 -0
- package/vendor/stylo/values/computed/page.rs +77 -0
- package/vendor/stylo/values/computed/param.rs +9 -0
- package/vendor/stylo/values/computed/percentage.rs +143 -0
- package/vendor/stylo/values/computed/position.rs +273 -0
- package/vendor/stylo/values/computed/ratio.rs +88 -0
- package/vendor/stylo/values/computed/rect.rs +19 -0
- package/vendor/stylo/values/computed/resolution.rs +76 -0
- package/vendor/stylo/values/computed/svg.rs +66 -0
- package/vendor/stylo/values/computed/table.rs +7 -0
- package/vendor/stylo/values/computed/text.rs +199 -0
- package/vendor/stylo/values/computed/time.rs +83 -0
- package/vendor/stylo/values/computed/transform.rs +559 -0
- package/vendor/stylo/values/computed/tree_counting.rs +30 -0
- package/vendor/stylo/values/computed/ui.rs +23 -0
- package/vendor/stylo/values/computed/url.rs +12 -0
- package/vendor/stylo/values/distance.rs +139 -0
- package/vendor/stylo/values/generics/animation.rs +363 -0
- package/vendor/stylo/values/generics/background.rs +65 -0
- package/vendor/stylo/values/generics/basic_shape.rs +1389 -0
- package/vendor/stylo/values/generics/border.rs +303 -0
- package/vendor/stylo/values/generics/box.rs +552 -0
- package/vendor/stylo/values/generics/calc.rs +2986 -0
- package/vendor/stylo/values/generics/color.rs +318 -0
- package/vendor/stylo/values/generics/column.rs +44 -0
- package/vendor/stylo/values/generics/counters.rs +320 -0
- package/vendor/stylo/values/generics/easing.rs +132 -0
- package/vendor/stylo/values/generics/effects.rs +131 -0
- package/vendor/stylo/values/generics/flex.rs +34 -0
- package/vendor/stylo/values/generics/font.rs +376 -0
- package/vendor/stylo/values/generics/grid.rs +962 -0
- package/vendor/stylo/values/generics/image.rs +653 -0
- package/vendor/stylo/values/generics/length.rs +656 -0
- package/vendor/stylo/values/generics/mod.rs +303 -0
- package/vendor/stylo/values/generics/motion.rs +274 -0
- package/vendor/stylo/values/generics/page.rs +167 -0
- package/vendor/stylo/values/generics/position.rs +669 -0
- package/vendor/stylo/values/generics/ratio.rs +88 -0
- package/vendor/stylo/values/generics/rect.rs +147 -0
- package/vendor/stylo/values/generics/size.rs +102 -0
- package/vendor/stylo/values/generics/svg.rs +226 -0
- package/vendor/stylo/values/generics/text.rs +268 -0
- package/vendor/stylo/values/generics/transform.rs +1157 -0
- package/vendor/stylo/values/generics/ui.rs +147 -0
- package/vendor/stylo/values/generics/url.rs +51 -0
- package/vendor/stylo/values/mod.rs +820 -0
- package/vendor/stylo/values/resolved/animation.rs +33 -0
- package/vendor/stylo/values/resolved/color.rs +53 -0
- package/vendor/stylo/values/resolved/counters.rs +45 -0
- package/vendor/stylo/values/resolved/mod.rs +316 -0
- package/vendor/stylo/values/specified/align.rs +711 -0
- package/vendor/stylo/values/specified/angle.rs +407 -0
- package/vendor/stylo/values/specified/animation.rs +921 -0
- package/vendor/stylo/values/specified/background.rs +270 -0
- package/vendor/stylo/values/specified/basic_shape.rs +986 -0
- package/vendor/stylo/values/specified/border.rs +430 -0
- package/vendor/stylo/values/specified/box.rs +2231 -0
- package/vendor/stylo/values/specified/calc.rs +1657 -0
- package/vendor/stylo/values/specified/color.rs +1210 -0
- package/vendor/stylo/values/specified/column.rs +11 -0
- package/vendor/stylo/values/specified/corner_shape.rs +152 -0
- package/vendor/stylo/values/specified/counters.rs +242 -0
- package/vendor/stylo/values/specified/easing.rs +225 -0
- package/vendor/stylo/values/specified/effects.rs +421 -0
- package/vendor/stylo/values/specified/flex.rs +42 -0
- package/vendor/stylo/values/specified/font.rs +2103 -0
- package/vendor/stylo/values/specified/frequency.rs +39 -0
- package/vendor/stylo/values/specified/grid.rs +407 -0
- package/vendor/stylo/values/specified/image.rs +1385 -0
- package/vendor/stylo/values/specified/intersection_observer.rs +80 -0
- package/vendor/stylo/values/specified/length.rs +2024 -0
- package/vendor/stylo/values/specified/list.rs +190 -0
- package/vendor/stylo/values/specified/mod.rs +531 -0
- package/vendor/stylo/values/specified/motion.rs +316 -0
- package/vendor/stylo/values/specified/number.rs +603 -0
- package/vendor/stylo/values/specified/outline.rs +69 -0
- package/vendor/stylo/values/specified/page.rs +94 -0
- package/vendor/stylo/values/specified/param.rs +121 -0
- package/vendor/stylo/values/specified/percentage.rs +364 -0
- package/vendor/stylo/values/specified/position.rs +2247 -0
- package/vendor/stylo/values/specified/ratio.rs +29 -0
- package/vendor/stylo/values/specified/rect.rs +28 -0
- package/vendor/stylo/values/specified/resolution.rs +237 -0
- package/vendor/stylo/values/specified/source_size_list.rs +135 -0
- package/vendor/stylo/values/specified/svg.rs +427 -0
- package/vendor/stylo/values/specified/svg_path.rs +1115 -0
- package/vendor/stylo/values/specified/table.rs +38 -0
- package/vendor/stylo/values/specified/text.rs +1561 -0
- package/vendor/stylo/values/specified/time.rs +313 -0
- package/vendor/stylo/values/specified/transform.rs +599 -0
- package/vendor/stylo/values/specified/tree_counting.rs +32 -0
- package/vendor/stylo/values/specified/ui.rs +344 -0
- package/vendor/stylo/values/specified/url.rs +12 -0
- package/vendor/stylo/values/tagged_numeric.rs +253 -0
- package/wasm/blitz_pdf.d.ts +67 -0
- package/wasm/blitz_pdf.js +699 -0
- package/wasm/blitz_pdf_bg.wasm +0 -0
- package/wasm/blitz_pdf_bg.wasm.d.ts +20 -0
|
@@ -0,0 +1,132 @@
|
|
|
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 Easing Functions.
|
|
6
|
+
//! https://drafts.csswg.org/css-easing/#timing-functions
|
|
7
|
+
|
|
8
|
+
use crate::derives::*;
|
|
9
|
+
|
|
10
|
+
/// A generic easing function.
|
|
11
|
+
#[derive(
|
|
12
|
+
Clone,
|
|
13
|
+
Debug,
|
|
14
|
+
MallocSizeOf,
|
|
15
|
+
PartialEq,
|
|
16
|
+
SpecifiedValueInfo,
|
|
17
|
+
ToCss,
|
|
18
|
+
ToShmem,
|
|
19
|
+
ToTyped,
|
|
20
|
+
Serialize,
|
|
21
|
+
Deserialize,
|
|
22
|
+
)]
|
|
23
|
+
#[value_info(ty = "TIMING_FUNCTION")]
|
|
24
|
+
#[repr(u8, C)]
|
|
25
|
+
pub enum TimingFunction<Integer, Number, LinearStops> {
|
|
26
|
+
/// `linear | ease | ease-in | ease-out | ease-in-out`
|
|
27
|
+
Keyword(TimingKeyword),
|
|
28
|
+
/// `cubic-bezier(<number>, <number>, <number>, <number>)`
|
|
29
|
+
#[allow(missing_docs)]
|
|
30
|
+
#[css(comma, function)]
|
|
31
|
+
#[typed(skip)]
|
|
32
|
+
CubicBezier {
|
|
33
|
+
x1: Number,
|
|
34
|
+
y1: Number,
|
|
35
|
+
x2: Number,
|
|
36
|
+
y2: Number,
|
|
37
|
+
},
|
|
38
|
+
/// `step-start | step-end | steps(<integer>, [ <step-position> ]?)`
|
|
39
|
+
/// `<step-position> = jump-start | jump-end | jump-none | jump-both | start | end`
|
|
40
|
+
#[css(comma, function)]
|
|
41
|
+
#[typed(skip)]
|
|
42
|
+
#[value_info(other_values = "step-start,step-end")]
|
|
43
|
+
Steps(Integer, #[css(skip_if = "is_end")] StepPosition),
|
|
44
|
+
/// linear([<linear-stop>]#)
|
|
45
|
+
/// <linear-stop> = <output> && <linear-stop-length>?
|
|
46
|
+
/// <linear-stop-length> = <percentage>{1, 2}
|
|
47
|
+
#[css(function = "linear")]
|
|
48
|
+
#[typed(skip)]
|
|
49
|
+
LinearFunction(LinearStops),
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
#[allow(missing_docs)]
|
|
53
|
+
#[derive(
|
|
54
|
+
Clone,
|
|
55
|
+
Copy,
|
|
56
|
+
Debug,
|
|
57
|
+
Eq,
|
|
58
|
+
MallocSizeOf,
|
|
59
|
+
Parse,
|
|
60
|
+
PartialEq,
|
|
61
|
+
SpecifiedValueInfo,
|
|
62
|
+
ToComputedValue,
|
|
63
|
+
ToCss,
|
|
64
|
+
ToResolvedValue,
|
|
65
|
+
ToShmem,
|
|
66
|
+
ToTyped,
|
|
67
|
+
Serialize,
|
|
68
|
+
Deserialize,
|
|
69
|
+
)]
|
|
70
|
+
#[repr(u8)]
|
|
71
|
+
pub enum TimingKeyword {
|
|
72
|
+
Linear,
|
|
73
|
+
Ease,
|
|
74
|
+
EaseIn,
|
|
75
|
+
EaseOut,
|
|
76
|
+
EaseInOut,
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/// Before flag, defined as per https://drafts.csswg.org/css-easing/#before-flag
|
|
80
|
+
/// This flag is never user-specified.
|
|
81
|
+
#[allow(missing_docs)]
|
|
82
|
+
#[derive(PartialEq)]
|
|
83
|
+
#[repr(u8)]
|
|
84
|
+
pub enum BeforeFlag {
|
|
85
|
+
Unset,
|
|
86
|
+
Set,
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
#[allow(missing_docs)]
|
|
90
|
+
#[derive(
|
|
91
|
+
Clone,
|
|
92
|
+
Copy,
|
|
93
|
+
Debug,
|
|
94
|
+
Eq,
|
|
95
|
+
MallocSizeOf,
|
|
96
|
+
Parse,
|
|
97
|
+
PartialEq,
|
|
98
|
+
ToComputedValue,
|
|
99
|
+
ToCss,
|
|
100
|
+
ToResolvedValue,
|
|
101
|
+
ToShmem,
|
|
102
|
+
Serialize,
|
|
103
|
+
Deserialize,
|
|
104
|
+
)]
|
|
105
|
+
#[repr(u8)]
|
|
106
|
+
pub enum StepPosition {
|
|
107
|
+
JumpStart,
|
|
108
|
+
JumpEnd,
|
|
109
|
+
JumpNone,
|
|
110
|
+
JumpBoth,
|
|
111
|
+
Start,
|
|
112
|
+
End,
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
#[inline]
|
|
116
|
+
fn is_end(position: &StepPosition) -> bool {
|
|
117
|
+
*position == StepPosition::JumpEnd || *position == StepPosition::End
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
impl<Integer, Number, LinearStops> TimingFunction<Integer, Number, LinearStops> {
|
|
121
|
+
/// `ease`
|
|
122
|
+
#[inline]
|
|
123
|
+
pub fn ease() -> Self {
|
|
124
|
+
TimingFunction::Keyword(TimingKeyword::Ease)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/// Returns true if it is `ease`.
|
|
128
|
+
#[inline]
|
|
129
|
+
pub fn is_ease(&self) -> bool {
|
|
130
|
+
matches!(*self, TimingFunction::Keyword(TimingKeyword::Ease))
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
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 related to effects.
|
|
6
|
+
use crate::derives::*;
|
|
7
|
+
|
|
8
|
+
use crate::values::generics::{NonNegative, ZeroToOne};
|
|
9
|
+
|
|
10
|
+
/// A generic value for a single `box-shadow`.
|
|
11
|
+
#[derive(
|
|
12
|
+
Animate,
|
|
13
|
+
Clone,
|
|
14
|
+
ComputeSquaredDistance,
|
|
15
|
+
Debug,
|
|
16
|
+
MallocSizeOf,
|
|
17
|
+
PartialEq,
|
|
18
|
+
SpecifiedValueInfo,
|
|
19
|
+
ToAnimatedValue,
|
|
20
|
+
ToAnimatedZero,
|
|
21
|
+
ToCss,
|
|
22
|
+
ToResolvedValue,
|
|
23
|
+
ToShmem,
|
|
24
|
+
ToTyped,
|
|
25
|
+
)]
|
|
26
|
+
#[repr(C)]
|
|
27
|
+
#[typed(todo_derive_fields)]
|
|
28
|
+
pub struct GenericBoxShadow<Color, SizeLength, BlurShapeLength, ShapeLength> {
|
|
29
|
+
/// The base shadow.
|
|
30
|
+
pub base: GenericSimpleShadow<Color, SizeLength, BlurShapeLength>,
|
|
31
|
+
/// The spread radius.
|
|
32
|
+
pub spread: ShapeLength,
|
|
33
|
+
/// Whether this is an inset box shadow.
|
|
34
|
+
#[animation(constant)]
|
|
35
|
+
#[css(represents_keyword)]
|
|
36
|
+
pub inset: bool,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
pub use self::GenericBoxShadow as BoxShadow;
|
|
40
|
+
|
|
41
|
+
/// A generic value for a single `filter`.
|
|
42
|
+
#[derive(
|
|
43
|
+
Clone,
|
|
44
|
+
ComputeSquaredDistance,
|
|
45
|
+
Debug,
|
|
46
|
+
Deserialize,
|
|
47
|
+
MallocSizeOf,
|
|
48
|
+
PartialEq,
|
|
49
|
+
Serialize,
|
|
50
|
+
SpecifiedValueInfo,
|
|
51
|
+
ToAnimatedValue,
|
|
52
|
+
ToComputedValue,
|
|
53
|
+
ToCss,
|
|
54
|
+
ToResolvedValue,
|
|
55
|
+
ToShmem,
|
|
56
|
+
ToTyped,
|
|
57
|
+
)]
|
|
58
|
+
#[animation(no_bound(U))]
|
|
59
|
+
#[repr(C, u8)]
|
|
60
|
+
#[typed(todo_derive_fields)]
|
|
61
|
+
pub enum GenericFilter<Angle, Factor, Length, Shadow, U> {
|
|
62
|
+
/// `blur(<length>)`
|
|
63
|
+
#[css(function)]
|
|
64
|
+
Blur(#[animation(field_bound)] NonNegative<Length>),
|
|
65
|
+
/// `brightness(<factor>)`
|
|
66
|
+
#[css(function)]
|
|
67
|
+
Brightness(#[animation(field_bound)] NonNegative<Factor>),
|
|
68
|
+
/// `contrast(<factor>)`
|
|
69
|
+
#[css(function)]
|
|
70
|
+
Contrast(#[animation(field_bound)] NonNegative<Factor>),
|
|
71
|
+
/// `grayscale(<factor>)`
|
|
72
|
+
#[css(function)]
|
|
73
|
+
Grayscale(#[animation(field_bound)] ZeroToOne<Factor>),
|
|
74
|
+
/// `hue-rotate(<angle>)`
|
|
75
|
+
#[css(function)]
|
|
76
|
+
HueRotate(Angle),
|
|
77
|
+
/// `invert(<factor>)`
|
|
78
|
+
#[css(function)]
|
|
79
|
+
Invert(#[animation(field_bound)] ZeroToOne<Factor>),
|
|
80
|
+
/// `opacity(<factor>)`
|
|
81
|
+
#[css(function)]
|
|
82
|
+
Opacity(#[animation(field_bound)] ZeroToOne<Factor>),
|
|
83
|
+
/// `saturate(<factor>)`
|
|
84
|
+
#[css(function)]
|
|
85
|
+
Saturate(#[animation(field_bound)] NonNegative<Factor>),
|
|
86
|
+
/// `sepia(<factor>)`
|
|
87
|
+
#[css(function)]
|
|
88
|
+
Sepia(#[animation(field_bound)] ZeroToOne<Factor>),
|
|
89
|
+
/// `drop-shadow(...)`
|
|
90
|
+
#[css(function)]
|
|
91
|
+
DropShadow(Shadow),
|
|
92
|
+
/// `<url>`
|
|
93
|
+
#[animation(error)]
|
|
94
|
+
Url(U),
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
pub use self::GenericFilter as Filter;
|
|
98
|
+
|
|
99
|
+
/// A generic value for the `drop-shadow()` filter and the `text-shadow` property.
|
|
100
|
+
///
|
|
101
|
+
/// Contrary to the canonical order from the spec, the color is serialised
|
|
102
|
+
/// first, like in Gecko and Webkit.
|
|
103
|
+
#[derive(
|
|
104
|
+
Animate,
|
|
105
|
+
Clone,
|
|
106
|
+
ComputeSquaredDistance,
|
|
107
|
+
Debug,
|
|
108
|
+
MallocSizeOf,
|
|
109
|
+
PartialEq,
|
|
110
|
+
SpecifiedValueInfo,
|
|
111
|
+
ToAnimatedValue,
|
|
112
|
+
ToAnimatedZero,
|
|
113
|
+
ToCss,
|
|
114
|
+
ToResolvedValue,
|
|
115
|
+
ToShmem,
|
|
116
|
+
ToTyped,
|
|
117
|
+
)]
|
|
118
|
+
#[repr(C)]
|
|
119
|
+
#[typed(todo_derive_fields)]
|
|
120
|
+
pub struct GenericSimpleShadow<Color, SizeLength, ShapeLength> {
|
|
121
|
+
/// Color.
|
|
122
|
+
pub color: Color,
|
|
123
|
+
/// Horizontal radius.
|
|
124
|
+
pub horizontal: SizeLength,
|
|
125
|
+
/// Vertical radius.
|
|
126
|
+
pub vertical: SizeLength,
|
|
127
|
+
/// Blur radius.
|
|
128
|
+
pub blur: ShapeLength,
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
pub use self::GenericSimpleShadow as SimpleShadow;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 related to flexbox.
|
|
6
|
+
use crate::derives::*;
|
|
7
|
+
|
|
8
|
+
/// A generic value for the `flex-basis` property.
|
|
9
|
+
#[derive(
|
|
10
|
+
Animate,
|
|
11
|
+
Clone,
|
|
12
|
+
ComputeSquaredDistance,
|
|
13
|
+
Copy,
|
|
14
|
+
Debug,
|
|
15
|
+
MallocSizeOf,
|
|
16
|
+
PartialEq,
|
|
17
|
+
SpecifiedValueInfo,
|
|
18
|
+
ToAnimatedValue,
|
|
19
|
+
ToAnimatedZero,
|
|
20
|
+
ToComputedValue,
|
|
21
|
+
ToCss,
|
|
22
|
+
ToResolvedValue,
|
|
23
|
+
ToShmem,
|
|
24
|
+
ToTyped,
|
|
25
|
+
)]
|
|
26
|
+
#[repr(C)]
|
|
27
|
+
pub enum GenericFlexBasis<S> {
|
|
28
|
+
/// `content`
|
|
29
|
+
Content,
|
|
30
|
+
/// `<width>`
|
|
31
|
+
Size(S),
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
pub use self::GenericFlexBasis as FlexBasis;
|
|
@@ -0,0 +1,376 @@
|
|
|
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 font stuff.
|
|
6
|
+
|
|
7
|
+
use crate::derives::*;
|
|
8
|
+
use crate::parser::{Parse, ParserContext};
|
|
9
|
+
use crate::typed_om::{KeywordValue, ToTyped, TypedValue};
|
|
10
|
+
use crate::values::animated::ToAnimatedZero;
|
|
11
|
+
use crate::{One, Zero};
|
|
12
|
+
use byteorder::{BigEndian, ReadBytesExt};
|
|
13
|
+
use cssparser::Parser;
|
|
14
|
+
use std::fmt::{self, Write};
|
|
15
|
+
use std::io::Cursor;
|
|
16
|
+
use style_traits::{CssString, CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
|
17
|
+
use thin_vec::ThinVec;
|
|
18
|
+
|
|
19
|
+
/// A trait for values that are labelled with a FontTag (for feature and
|
|
20
|
+
/// variation settings).
|
|
21
|
+
pub trait TaggedFontValue {
|
|
22
|
+
/// The value's tag.
|
|
23
|
+
fn tag(&self) -> FontTag;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/// https://drafts.csswg.org/css-fonts-4/#feature-tag-value
|
|
27
|
+
#[derive(
|
|
28
|
+
Clone,
|
|
29
|
+
Debug,
|
|
30
|
+
Deserialize,
|
|
31
|
+
Eq,
|
|
32
|
+
Hash,
|
|
33
|
+
MallocSizeOf,
|
|
34
|
+
PartialEq,
|
|
35
|
+
Serialize,
|
|
36
|
+
SpecifiedValueInfo,
|
|
37
|
+
ToAnimatedValue,
|
|
38
|
+
ToComputedValue,
|
|
39
|
+
ToResolvedValue,
|
|
40
|
+
ToShmem,
|
|
41
|
+
)]
|
|
42
|
+
pub struct FeatureTagValue<Integer> {
|
|
43
|
+
/// A four-character tag, packed into a u32 (one byte per character).
|
|
44
|
+
pub tag: FontTag,
|
|
45
|
+
/// The actual value.
|
|
46
|
+
pub value: Integer,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
impl<T> TaggedFontValue for FeatureTagValue<T> {
|
|
50
|
+
fn tag(&self) -> FontTag {
|
|
51
|
+
self.tag
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
impl<Integer> ToCss for FeatureTagValue<Integer>
|
|
56
|
+
where
|
|
57
|
+
Integer: One + ToCss + PartialEq,
|
|
58
|
+
{
|
|
59
|
+
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
|
60
|
+
where
|
|
61
|
+
W: Write,
|
|
62
|
+
{
|
|
63
|
+
self.tag.to_css(dest)?;
|
|
64
|
+
// Don't serialize the default value.
|
|
65
|
+
if !self.value.is_one() {
|
|
66
|
+
dest.write_char(' ')?;
|
|
67
|
+
self.value.to_css(dest)?;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
Ok(())
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/// Variation setting for a single feature, see:
|
|
75
|
+
///
|
|
76
|
+
/// https://drafts.csswg.org/css-fonts-4/#font-variation-settings-def
|
|
77
|
+
#[derive(
|
|
78
|
+
Animate,
|
|
79
|
+
Clone,
|
|
80
|
+
ComputeSquaredDistance,
|
|
81
|
+
Debug,
|
|
82
|
+
Deserialize,
|
|
83
|
+
Eq,
|
|
84
|
+
MallocSizeOf,
|
|
85
|
+
PartialEq,
|
|
86
|
+
Serialize,
|
|
87
|
+
SpecifiedValueInfo,
|
|
88
|
+
ToAnimatedValue,
|
|
89
|
+
ToComputedValue,
|
|
90
|
+
ToCss,
|
|
91
|
+
ToResolvedValue,
|
|
92
|
+
ToShmem,
|
|
93
|
+
)]
|
|
94
|
+
pub struct VariationValue<Number> {
|
|
95
|
+
/// A four-character tag, packed into a u32 (one byte per character).
|
|
96
|
+
#[animation(constant)]
|
|
97
|
+
pub tag: FontTag,
|
|
98
|
+
/// The actual value.
|
|
99
|
+
pub value: Number,
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
impl<T> TaggedFontValue for VariationValue<T> {
|
|
103
|
+
fn tag(&self) -> FontTag {
|
|
104
|
+
self.tag
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/// A value both for font-variation-settings and font-feature-settings.
|
|
109
|
+
#[derive(
|
|
110
|
+
Clone,
|
|
111
|
+
Debug,
|
|
112
|
+
Deserialize,
|
|
113
|
+
Eq,
|
|
114
|
+
Hash,
|
|
115
|
+
MallocSizeOf,
|
|
116
|
+
PartialEq,
|
|
117
|
+
Serialize,
|
|
118
|
+
SpecifiedValueInfo,
|
|
119
|
+
ToAnimatedValue,
|
|
120
|
+
ToCss,
|
|
121
|
+
ToResolvedValue,
|
|
122
|
+
ToShmem,
|
|
123
|
+
ToTyped,
|
|
124
|
+
)]
|
|
125
|
+
#[css(comma)]
|
|
126
|
+
#[typed(todo_derive_fields)]
|
|
127
|
+
pub struct FontSettings<T>(#[css(if_empty = "normal", iterable)] pub Box<[T]>);
|
|
128
|
+
|
|
129
|
+
impl<T> FontSettings<T> {
|
|
130
|
+
/// Default value of font settings as `normal`.
|
|
131
|
+
#[inline]
|
|
132
|
+
pub fn normal() -> Self {
|
|
133
|
+
FontSettings(vec![].into_boxed_slice())
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
impl<T: Parse> Parse for FontSettings<T> {
|
|
138
|
+
/// https://drafts.csswg.org/css-fonts-4/#descdef-font-face-font-feature-settings
|
|
139
|
+
/// https://drafts.csswg.org/css-fonts-4/#font-variation-settings-def
|
|
140
|
+
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ParseError> {
|
|
141
|
+
if input
|
|
142
|
+
.try_parse(|i| i.expect_ident_matching("normal"))
|
|
143
|
+
.is_ok()
|
|
144
|
+
{
|
|
145
|
+
return Ok(Self::normal());
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
Ok(FontSettings(
|
|
149
|
+
input
|
|
150
|
+
.parse_comma_separated(|i| T::parse(context, i))?
|
|
151
|
+
.into_boxed_slice(),
|
|
152
|
+
))
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/// A font four-character tag, represented as a u32 for convenience.
|
|
157
|
+
///
|
|
158
|
+
/// See:
|
|
159
|
+
/// https://drafts.csswg.org/css-fonts-4/#font-variation-settings-def
|
|
160
|
+
/// https://drafts.csswg.org/css-fonts-4/#descdef-font-face-font-feature-settings
|
|
161
|
+
///
|
|
162
|
+
#[derive(
|
|
163
|
+
Clone,
|
|
164
|
+
Copy,
|
|
165
|
+
Deserialize,
|
|
166
|
+
Eq,
|
|
167
|
+
Hash,
|
|
168
|
+
MallocSizeOf,
|
|
169
|
+
PartialEq,
|
|
170
|
+
Serialize,
|
|
171
|
+
SpecifiedValueInfo,
|
|
172
|
+
ToAnimatedValue,
|
|
173
|
+
ToComputedValue,
|
|
174
|
+
ToResolvedValue,
|
|
175
|
+
ToShmem,
|
|
176
|
+
)]
|
|
177
|
+
pub struct FontTag(pub u32);
|
|
178
|
+
|
|
179
|
+
impl fmt::Debug for FontTag {
|
|
180
|
+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
181
|
+
let tag_bytes = self.0.to_be_bytes();
|
|
182
|
+
|
|
183
|
+
let mut tuple = f.debug_tuple("FontTag");
|
|
184
|
+
if let Ok(utf8_tag) = str::from_utf8(&tag_bytes) {
|
|
185
|
+
tuple.field(&utf8_tag);
|
|
186
|
+
} else {
|
|
187
|
+
tuple.field(&tag_bytes);
|
|
188
|
+
};
|
|
189
|
+
tuple.finish()
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
impl ToCss for FontTag {
|
|
194
|
+
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
|
195
|
+
where
|
|
196
|
+
W: Write,
|
|
197
|
+
{
|
|
198
|
+
use byteorder::ByteOrder;
|
|
199
|
+
use std::str;
|
|
200
|
+
|
|
201
|
+
let mut raw = [0u8; 4];
|
|
202
|
+
BigEndian::write_u32(&mut raw, self.0);
|
|
203
|
+
str::from_utf8(&raw).unwrap_or_default().to_css(dest)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
impl Parse for FontTag {
|
|
208
|
+
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Self, ParseError> {
|
|
209
|
+
let tag = input.expect_string()?;
|
|
210
|
+
|
|
211
|
+
// allowed strings of length 4 containing chars: <U+20, U+7E>
|
|
212
|
+
if tag.len() != 4 || tag.as_bytes().iter().any(|c| *c < b' ' || *c > b'~') {
|
|
213
|
+
return Err(ParseError::custom(StyleParseErrorKind::UnspecifiedError));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
let mut raw = Cursor::new(tag.as_bytes());
|
|
217
|
+
Ok(FontTag(raw.read_u32::<BigEndian>().unwrap()))
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/// A generic value for the `font-style` property.
|
|
222
|
+
///
|
|
223
|
+
/// https://drafts.csswg.org/css-fonts-4/#font-style-prop
|
|
224
|
+
#[allow(missing_docs)]
|
|
225
|
+
#[derive(
|
|
226
|
+
Animate,
|
|
227
|
+
Clone,
|
|
228
|
+
ComputeSquaredDistance,
|
|
229
|
+
Copy,
|
|
230
|
+
Debug,
|
|
231
|
+
Deserialize,
|
|
232
|
+
Hash,
|
|
233
|
+
MallocSizeOf,
|
|
234
|
+
PartialEq,
|
|
235
|
+
Serialize,
|
|
236
|
+
SpecifiedValueInfo,
|
|
237
|
+
ToAnimatedValue,
|
|
238
|
+
ToAnimatedZero,
|
|
239
|
+
ToResolvedValue,
|
|
240
|
+
ToShmem,
|
|
241
|
+
)]
|
|
242
|
+
#[value_info(other_values = "normal")]
|
|
243
|
+
pub enum FontStyle<Angle> {
|
|
244
|
+
// Note that 'oblique 0deg' represents 'normal', and will serialize as such.
|
|
245
|
+
#[value_info(starts_with_keyword)]
|
|
246
|
+
Oblique(Angle),
|
|
247
|
+
#[animation(error)]
|
|
248
|
+
Italic,
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
impl<Angle: Zero> FontStyle<Angle> {
|
|
252
|
+
/// Return the 'normal' value, which is represented as 'oblique 0deg'.
|
|
253
|
+
pub fn normal() -> Self {
|
|
254
|
+
Self::Oblique(Angle::zero())
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/// A generic value for the `font-size-adjust` property.
|
|
259
|
+
///
|
|
260
|
+
/// https://drafts.csswg.org/css-fonts-5/#font-size-adjust-prop
|
|
261
|
+
#[allow(missing_docs)]
|
|
262
|
+
#[repr(u8)]
|
|
263
|
+
#[derive(
|
|
264
|
+
Animate,
|
|
265
|
+
Clone,
|
|
266
|
+
ComputeSquaredDistance,
|
|
267
|
+
Copy,
|
|
268
|
+
Debug,
|
|
269
|
+
Deserialize,
|
|
270
|
+
Hash,
|
|
271
|
+
MallocSizeOf,
|
|
272
|
+
PartialEq,
|
|
273
|
+
Serialize,
|
|
274
|
+
SpecifiedValueInfo,
|
|
275
|
+
ToAnimatedValue,
|
|
276
|
+
ToAnimatedZero,
|
|
277
|
+
ToComputedValue,
|
|
278
|
+
ToResolvedValue,
|
|
279
|
+
ToShmem,
|
|
280
|
+
)]
|
|
281
|
+
pub enum GenericFontSizeAdjust<Factor> {
|
|
282
|
+
#[animation(error)]
|
|
283
|
+
None,
|
|
284
|
+
#[value_info(starts_with_keyword)]
|
|
285
|
+
ExHeight(Factor),
|
|
286
|
+
#[value_info(starts_with_keyword)]
|
|
287
|
+
CapHeight(Factor),
|
|
288
|
+
#[value_info(starts_with_keyword)]
|
|
289
|
+
ChWidth(Factor),
|
|
290
|
+
#[value_info(starts_with_keyword)]
|
|
291
|
+
IcWidth(Factor),
|
|
292
|
+
#[value_info(starts_with_keyword)]
|
|
293
|
+
IcHeight(Factor),
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
impl<Factor: ToCss> ToCss for GenericFontSizeAdjust<Factor> {
|
|
297
|
+
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
|
298
|
+
where
|
|
299
|
+
W: Write,
|
|
300
|
+
{
|
|
301
|
+
let (prefix, value) = match self {
|
|
302
|
+
Self::None => return dest.write_str("none"),
|
|
303
|
+
Self::ExHeight(v) => ("", v),
|
|
304
|
+
Self::CapHeight(v) => ("cap-height ", v),
|
|
305
|
+
Self::ChWidth(v) => ("ch-width ", v),
|
|
306
|
+
Self::IcWidth(v) => ("ic-width ", v),
|
|
307
|
+
Self::IcHeight(v) => ("ic-height ", v),
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
dest.write_str(prefix)?;
|
|
311
|
+
value.to_css(dest)
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
impl<Factor: ToTyped> ToTyped for GenericFontSizeAdjust<Factor> {
|
|
316
|
+
fn to_typed(&self, dest: &mut ThinVec<TypedValue>) -> Result<(), ()> {
|
|
317
|
+
match self {
|
|
318
|
+
Self::None => {
|
|
319
|
+
dest.push(TypedValue::Keyword(KeywordValue(CssString::from("none"))));
|
|
320
|
+
Ok(())
|
|
321
|
+
},
|
|
322
|
+
Self::ExHeight(v) => v.to_typed(dest),
|
|
323
|
+
_ => Err(()),
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/// A generic value for the `line-height` property.
|
|
329
|
+
#[derive(
|
|
330
|
+
Animate,
|
|
331
|
+
Clone,
|
|
332
|
+
ComputeSquaredDistance,
|
|
333
|
+
Copy,
|
|
334
|
+
Debug,
|
|
335
|
+
Deserialize,
|
|
336
|
+
MallocSizeOf,
|
|
337
|
+
PartialEq,
|
|
338
|
+
Serialize,
|
|
339
|
+
SpecifiedValueInfo,
|
|
340
|
+
ToAnimatedValue,
|
|
341
|
+
ToCss,
|
|
342
|
+
ToShmem,
|
|
343
|
+
ToTyped,
|
|
344
|
+
)]
|
|
345
|
+
#[repr(C, u8)]
|
|
346
|
+
pub enum GenericLineHeight<N, L> {
|
|
347
|
+
/// `normal`
|
|
348
|
+
Normal,
|
|
349
|
+
/// `<number>`
|
|
350
|
+
Number(N),
|
|
351
|
+
/// `<length-percentage>`
|
|
352
|
+
Length(L),
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
pub use self::GenericLineHeight as LineHeight;
|
|
356
|
+
|
|
357
|
+
impl<N, L> ToAnimatedZero for LineHeight<N, L> {
|
|
358
|
+
#[inline]
|
|
359
|
+
fn to_animated_zero(&self) -> Result<Self, ()> {
|
|
360
|
+
Err(())
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
impl<N, L> LineHeight<N, L> {
|
|
365
|
+
/// Returns `normal`.
|
|
366
|
+
#[inline]
|
|
367
|
+
pub fn normal() -> Self {
|
|
368
|
+
LineHeight::Normal
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/// Returns whether the value is `normal`.
|
|
372
|
+
#[inline]
|
|
373
|
+
pub fn is_normal(&self) -> bool {
|
|
374
|
+
matches!(self, Self::Normal)
|
|
375
|
+
}
|
|
376
|
+
}
|