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,73 @@
|
|
|
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
|
+
//! Computed types for CSS values that are related to motion path.
|
|
6
|
+
|
|
7
|
+
use crate::derives::*;
|
|
8
|
+
use crate::values::computed::basic_shape::BasicShape;
|
|
9
|
+
use crate::values::computed::url::ComputedUrl;
|
|
10
|
+
use crate::values::computed::{Angle, LengthPercentage, Position};
|
|
11
|
+
use crate::values::generics::motion::{
|
|
12
|
+
GenericOffsetPath, GenericOffsetPathFunction, GenericOffsetPosition, GenericRayFunction,
|
|
13
|
+
};
|
|
14
|
+
use crate::Zero;
|
|
15
|
+
|
|
16
|
+
/// The computed value of ray() function.
|
|
17
|
+
pub type RayFunction = GenericRayFunction<Angle, Position>;
|
|
18
|
+
|
|
19
|
+
/// The computed value of <offset-path>.
|
|
20
|
+
pub type OffsetPathFunction = GenericOffsetPathFunction<BasicShape, RayFunction, ComputedUrl>;
|
|
21
|
+
|
|
22
|
+
/// The computed value of `offset-path`.
|
|
23
|
+
pub type OffsetPath = GenericOffsetPath<OffsetPathFunction>;
|
|
24
|
+
|
|
25
|
+
/// The computed value of `offset-position`.
|
|
26
|
+
pub type OffsetPosition = GenericOffsetPosition<LengthPercentage, LengthPercentage>;
|
|
27
|
+
|
|
28
|
+
#[inline]
|
|
29
|
+
fn is_auto_zero_angle(auto: &bool, angle: &Angle) -> bool {
|
|
30
|
+
*auto && angle.is_zero()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// A computed offset-rotate.
|
|
34
|
+
#[derive(
|
|
35
|
+
Animate,
|
|
36
|
+
Clone,
|
|
37
|
+
ComputeSquaredDistance,
|
|
38
|
+
Copy,
|
|
39
|
+
Debug,
|
|
40
|
+
Deserialize,
|
|
41
|
+
MallocSizeOf,
|
|
42
|
+
PartialEq,
|
|
43
|
+
Serialize,
|
|
44
|
+
ToAnimatedValue,
|
|
45
|
+
ToAnimatedZero,
|
|
46
|
+
ToCss,
|
|
47
|
+
ToResolvedValue,
|
|
48
|
+
ToTyped,
|
|
49
|
+
)]
|
|
50
|
+
#[repr(C)]
|
|
51
|
+
pub struct OffsetRotate {
|
|
52
|
+
/// If auto is false, this is a fixed angle which indicates a
|
|
53
|
+
/// constant clockwise rotation transformation applied to it by this
|
|
54
|
+
/// specified rotation angle. Otherwise, the angle will be added to
|
|
55
|
+
/// the angle of the direction in layout.
|
|
56
|
+
#[animation(constant)]
|
|
57
|
+
#[css(represents_keyword)]
|
|
58
|
+
pub auto: bool,
|
|
59
|
+
/// The angle value.
|
|
60
|
+
#[css(contextual_skip_if = "is_auto_zero_angle")]
|
|
61
|
+
pub angle: Angle,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
impl OffsetRotate {
|
|
65
|
+
/// Returns "auto 0deg".
|
|
66
|
+
#[inline]
|
|
67
|
+
pub fn auto() -> Self {
|
|
68
|
+
OffsetRotate {
|
|
69
|
+
auto: true,
|
|
70
|
+
angle: Zero::zero(),
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
//! Computed values for outline properties
|
|
6
|
+
|
|
7
|
+
pub use crate::values::specified::OutlineStyle;
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
//! Computed @page at-rule properties and named-page style properties
|
|
6
|
+
|
|
7
|
+
use crate::derives::*;
|
|
8
|
+
use crate::values::computed::length::NonNegativeLength;
|
|
9
|
+
use crate::values::computed::{Context, ToComputedValue};
|
|
10
|
+
use crate::values::generics;
|
|
11
|
+
use crate::values::generics::size::Size2D;
|
|
12
|
+
|
|
13
|
+
use crate::values::specified::page as specified;
|
|
14
|
+
pub use generics::page::GenericPageSize;
|
|
15
|
+
pub use generics::page::PageOrientation;
|
|
16
|
+
pub use generics::page::PageSizeOrientation;
|
|
17
|
+
pub use generics::page::PaperSize;
|
|
18
|
+
pub use specified::PageName;
|
|
19
|
+
|
|
20
|
+
/// Computed value of the @page size descriptor
|
|
21
|
+
///
|
|
22
|
+
/// The spec says that the computed value should be the same as the specified
|
|
23
|
+
/// value but with all absolute units, but it's not currently possibly observe
|
|
24
|
+
/// the computed value of page-size.
|
|
25
|
+
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue, ToShmem, ToTyped)]
|
|
26
|
+
#[repr(C, u8)]
|
|
27
|
+
#[typed(todo_derive_fields)]
|
|
28
|
+
pub enum PageSize {
|
|
29
|
+
/// Specified size, paper size, or paper size and orientation.
|
|
30
|
+
Size(Size2D<NonNegativeLength>),
|
|
31
|
+
/// `landscape` or `portrait` value, no specified size.
|
|
32
|
+
Orientation(PageSizeOrientation),
|
|
33
|
+
/// `auto` value
|
|
34
|
+
Auto,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
impl ToComputedValue for specified::PageSize {
|
|
38
|
+
type ComputedValue = PageSize;
|
|
39
|
+
|
|
40
|
+
fn to_computed_value(&self, ctx: &Context) -> Self::ComputedValue {
|
|
41
|
+
match self {
|
|
42
|
+
Self::Size(s) => PageSize::Size(s.to_computed_value(ctx)),
|
|
43
|
+
Self::PaperSize(p, PageSizeOrientation::Landscape) => PageSize::Size(Size2D {
|
|
44
|
+
width: p.long_edge().to_computed_value(ctx),
|
|
45
|
+
height: p.short_edge().to_computed_value(ctx),
|
|
46
|
+
}),
|
|
47
|
+
Self::PaperSize(p, PageSizeOrientation::Portrait) => PageSize::Size(Size2D {
|
|
48
|
+
width: p.short_edge().to_computed_value(ctx),
|
|
49
|
+
height: p.long_edge().to_computed_value(ctx),
|
|
50
|
+
}),
|
|
51
|
+
Self::Orientation(o) => PageSize::Orientation(*o),
|
|
52
|
+
Self::Auto => PageSize::Auto,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
|
57
|
+
match *computed {
|
|
58
|
+
PageSize::Size(s) => Self::Size(ToComputedValue::from_computed_value(&s)),
|
|
59
|
+
PageSize::Orientation(o) => Self::Orientation(o),
|
|
60
|
+
PageSize::Auto => Self::Auto,
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
impl PageSize {
|
|
66
|
+
/// `auto` value.
|
|
67
|
+
#[inline]
|
|
68
|
+
pub fn auto() -> Self {
|
|
69
|
+
PageSize::Auto
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/// Whether this is the `auto` value.
|
|
73
|
+
#[inline]
|
|
74
|
+
pub fn is_auto(&self) -> bool {
|
|
75
|
+
matches!(*self, PageSize::Auto)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
//! Common handling for the computed value CSS link-parameters: param() values.
|
|
6
|
+
//!
|
|
7
|
+
//! specified == computed for link-parameters
|
|
8
|
+
|
|
9
|
+
pub use crate::values::specified::param::LinkParameters;
|
|
@@ -0,0 +1,143 @@
|
|
|
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
|
+
//! Computed percentages.
|
|
6
|
+
|
|
7
|
+
use crate::derives::*;
|
|
8
|
+
use crate::typed_om::{ToTyped, TypedValue};
|
|
9
|
+
use crate::values::generics::{ClampToNonNegative, NonNegative};
|
|
10
|
+
use crate::values::specified::percentage::ToPercentage;
|
|
11
|
+
use crate::values::{reify_percentage, serialize_normalized_percentage, CSSFloat};
|
|
12
|
+
use crate::Zero;
|
|
13
|
+
use std::fmt;
|
|
14
|
+
use style_traits::{CssWriter, ToCss};
|
|
15
|
+
use thin_vec::ThinVec;
|
|
16
|
+
|
|
17
|
+
/// A computed percentage.
|
|
18
|
+
#[derive(
|
|
19
|
+
Animate,
|
|
20
|
+
Clone,
|
|
21
|
+
ComputeSquaredDistance,
|
|
22
|
+
Copy,
|
|
23
|
+
Debug,
|
|
24
|
+
Default,
|
|
25
|
+
Deserialize,
|
|
26
|
+
MallocSizeOf,
|
|
27
|
+
PartialEq,
|
|
28
|
+
PartialOrd,
|
|
29
|
+
Serialize,
|
|
30
|
+
SpecifiedValueInfo,
|
|
31
|
+
ToAnimatedValue,
|
|
32
|
+
ToAnimatedZero,
|
|
33
|
+
ToComputedValue,
|
|
34
|
+
ToResolvedValue,
|
|
35
|
+
ToShmem,
|
|
36
|
+
)]
|
|
37
|
+
#[repr(C)]
|
|
38
|
+
pub struct Percentage(pub CSSFloat);
|
|
39
|
+
|
|
40
|
+
impl ClampToNonNegative for Percentage {
|
|
41
|
+
#[inline]
|
|
42
|
+
fn clamp_to_non_negative(self) -> Self {
|
|
43
|
+
Percentage(self.0.max(0.))
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
impl Percentage {
|
|
48
|
+
/// 100%
|
|
49
|
+
#[inline]
|
|
50
|
+
pub fn hundred() -> Self {
|
|
51
|
+
Percentage(1.)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/// Returns the absolute value for this percentage.
|
|
55
|
+
#[inline]
|
|
56
|
+
pub fn abs(&self) -> Self {
|
|
57
|
+
Percentage(self.0.abs())
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
impl Zero for Percentage {
|
|
62
|
+
fn zero() -> Self {
|
|
63
|
+
Percentage(0.)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
fn is_zero(&self) -> bool {
|
|
67
|
+
self.0 == 0.
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
impl ToPercentage for Percentage {
|
|
72
|
+
fn to_percentage(&self) -> Option<CSSFloat> {
|
|
73
|
+
Some(self.0)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
impl std::ops::AddAssign for Percentage {
|
|
78
|
+
fn add_assign(&mut self, other: Self) {
|
|
79
|
+
self.0 += other.0
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
impl std::ops::Add for Percentage {
|
|
84
|
+
type Output = Self;
|
|
85
|
+
|
|
86
|
+
fn add(self, other: Self) -> Self {
|
|
87
|
+
Percentage(self.0 + other.0)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
impl std::ops::Sub for Percentage {
|
|
92
|
+
type Output = Self;
|
|
93
|
+
|
|
94
|
+
fn sub(self, other: Self) -> Self {
|
|
95
|
+
Percentage(self.0 - other.0)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
impl std::ops::Rem for Percentage {
|
|
100
|
+
type Output = Self;
|
|
101
|
+
|
|
102
|
+
fn rem(self, other: Self) -> Self {
|
|
103
|
+
Percentage(self.0 % other.0)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
impl From<f32> for Percentage {
|
|
108
|
+
fn from(value: f32) -> Self {
|
|
109
|
+
Self(value)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
impl From<Percentage> for f32 {
|
|
114
|
+
fn from(percentage: Percentage) -> f32 {
|
|
115
|
+
percentage.0
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
impl ToCss for Percentage {
|
|
120
|
+
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
|
121
|
+
where
|
|
122
|
+
W: fmt::Write,
|
|
123
|
+
{
|
|
124
|
+
serialize_normalized_percentage(self.0, dest)
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
impl ToTyped for Percentage {
|
|
129
|
+
fn to_typed(&self, dest: &mut ThinVec<TypedValue>) -> Result<(), ()> {
|
|
130
|
+
reify_percentage(self.0, dest)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/// A wrapper over a `Percentage`, whose value should be clamped to 0.
|
|
135
|
+
pub type NonNegativePercentage = NonNegative<Percentage>;
|
|
136
|
+
|
|
137
|
+
impl NonNegativePercentage {
|
|
138
|
+
/// 100%
|
|
139
|
+
#[inline]
|
|
140
|
+
pub fn hundred() -> Self {
|
|
141
|
+
NonNegative(Percentage::hundred())
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,273 @@
|
|
|
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
|
+
//! CSS handling for the computed value of
|
|
6
|
+
//! [`position`][position] values.
|
|
7
|
+
//!
|
|
8
|
+
//! [position]: https://drafts.csswg.org/css-backgrounds-3/#position
|
|
9
|
+
|
|
10
|
+
use crate::logical_geometry::PhysicalSide;
|
|
11
|
+
use crate::values::computed::{
|
|
12
|
+
Context, Integer, LengthPercentage, NonNegativeNumber, Percentage, ToComputedValue,
|
|
13
|
+
};
|
|
14
|
+
use crate::values::generics;
|
|
15
|
+
#[cfg(feature = "gecko")]
|
|
16
|
+
use crate::values::generics::position::TreeScoped;
|
|
17
|
+
use crate::values::generics::position::{
|
|
18
|
+
AnchorSideKeyword, AspectRatio as GenericAspectRatio, GenericAnchorFunction, GenericAnchorSide,
|
|
19
|
+
GenericInset, Position as GenericPosition, PositionComponent as GenericPositionComponent,
|
|
20
|
+
PositionOrAuto as GenericPositionOrAuto, ZIndex as GenericZIndex,
|
|
21
|
+
};
|
|
22
|
+
pub use crate::values::specified::position::{
|
|
23
|
+
AnchorName, DashedIdentAndOrTryTactic, FlexWrap, GridAutoFlow, GridTemplateAreas,
|
|
24
|
+
MasonryAutoFlow, PositionAnchor, PositionArea, PositionAreaAxis, PositionAreaKeyword,
|
|
25
|
+
PositionAreaType, PositionTryFallbacks, PositionTryFallbacksTryTactic,
|
|
26
|
+
PositionTryFallbacksTryTacticKeyword, PositionTryOrder, PositionVisibility, ScopedName,
|
|
27
|
+
};
|
|
28
|
+
use crate::Zero;
|
|
29
|
+
use std::fmt::{self, Write};
|
|
30
|
+
use style_traits::{CssWriter, ToCss};
|
|
31
|
+
|
|
32
|
+
/// The computed value of a CSS `<position>`
|
|
33
|
+
pub type Position = GenericPosition<HorizontalPosition, VerticalPosition>;
|
|
34
|
+
|
|
35
|
+
/// The computed value of an `auto | <position>`
|
|
36
|
+
pub type PositionOrAuto = GenericPositionOrAuto<Position>;
|
|
37
|
+
|
|
38
|
+
/// The computed value of a CSS horizontal position.
|
|
39
|
+
pub type HorizontalPosition = LengthPercentage;
|
|
40
|
+
|
|
41
|
+
/// The computed value of a CSS vertical position.
|
|
42
|
+
pub type VerticalPosition = LengthPercentage;
|
|
43
|
+
|
|
44
|
+
/// The computed value of anchor side.
|
|
45
|
+
pub type AnchorSide = GenericAnchorSide<Percentage>;
|
|
46
|
+
|
|
47
|
+
impl AnchorSide {
|
|
48
|
+
/// Break down given anchor side into its equivalent keyword and percentage.
|
|
49
|
+
pub fn keyword_and_percentage(&self) -> (AnchorSideKeyword, Percentage) {
|
|
50
|
+
match self {
|
|
51
|
+
Self::Percentage(p) => (AnchorSideKeyword::Start, *p),
|
|
52
|
+
Self::Keyword(k) => {
|
|
53
|
+
if matches!(k, AnchorSideKeyword::Center) {
|
|
54
|
+
(AnchorSideKeyword::Start, Percentage(0.5))
|
|
55
|
+
} else {
|
|
56
|
+
(*k, Percentage::zero())
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/// The computed value of an `anchor()` function.
|
|
64
|
+
pub type AnchorFunction = GenericAnchorFunction<Percentage, Inset>;
|
|
65
|
+
|
|
66
|
+
#[cfg(feature = "gecko")]
|
|
67
|
+
use crate::{
|
|
68
|
+
gecko_bindings::structs::AnchorPosOffsetResolutionParams,
|
|
69
|
+
values::{computed::Length, DashedIdent},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
impl AnchorFunction {
|
|
73
|
+
/// Resolve the anchor function with the given resolver. Returns `Err()` if no anchor is found.
|
|
74
|
+
#[cfg(feature = "gecko")]
|
|
75
|
+
pub fn resolve(
|
|
76
|
+
anchor_name: &TreeScoped<DashedIdent>,
|
|
77
|
+
anchor_side: &AnchorSide,
|
|
78
|
+
prop_side: PhysicalSide,
|
|
79
|
+
params: &AnchorPosOffsetResolutionParams,
|
|
80
|
+
) -> Result<Length, ()> {
|
|
81
|
+
use crate::gecko_bindings::structs::Gecko_GetAnchorPosOffset;
|
|
82
|
+
|
|
83
|
+
let (keyword, percentage) = anchor_side.keyword_and_percentage();
|
|
84
|
+
let mut offset = Length::zero();
|
|
85
|
+
let valid = unsafe {
|
|
86
|
+
Gecko_GetAnchorPosOffset(
|
|
87
|
+
params,
|
|
88
|
+
anchor_name.value.0.as_ptr(),
|
|
89
|
+
&anchor_name.scope,
|
|
90
|
+
prop_side as u8,
|
|
91
|
+
keyword as u8,
|
|
92
|
+
percentage.0,
|
|
93
|
+
&mut offset,
|
|
94
|
+
)
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
if !valid {
|
|
98
|
+
return Err(());
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
Ok(offset)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/// Perform the adjustment of a given value for a given try tactic, as per:
|
|
106
|
+
/// https://drafts.csswg.org/css-anchor-position-1/#swap-due-to-a-try-tactic
|
|
107
|
+
pub(crate) trait TryTacticAdjustment {
|
|
108
|
+
/// Performs the adjustments necessary given an old side we're relative to, and a new side
|
|
109
|
+
/// we're relative to.
|
|
110
|
+
fn try_tactic_adjustment(&mut self, old_side: PhysicalSide, new_side: PhysicalSide);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
impl<T: TryTacticAdjustment> TryTacticAdjustment for Box<T> {
|
|
114
|
+
fn try_tactic_adjustment(&mut self, old_side: PhysicalSide, new_side: PhysicalSide) {
|
|
115
|
+
(**self).try_tactic_adjustment(old_side, new_side);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
impl<T: TryTacticAdjustment> TryTacticAdjustment for generics::NonNegative<T> {
|
|
120
|
+
fn try_tactic_adjustment(&mut self, old_side: PhysicalSide, new_side: PhysicalSide) {
|
|
121
|
+
self.0.try_tactic_adjustment(old_side, new_side);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
impl<Percentage: TryTacticAdjustment> TryTacticAdjustment for GenericAnchorSide<Percentage> {
|
|
126
|
+
fn try_tactic_adjustment(&mut self, old_side: PhysicalSide, new_side: PhysicalSide) {
|
|
127
|
+
match self {
|
|
128
|
+
Self::Percentage(p) => p.try_tactic_adjustment(old_side, new_side),
|
|
129
|
+
Self::Keyword(side) => side.try_tactic_adjustment(old_side, new_side),
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
impl<Percentage: TryTacticAdjustment, Fallback: TryTacticAdjustment> TryTacticAdjustment
|
|
135
|
+
for GenericAnchorFunction<Percentage, Fallback>
|
|
136
|
+
{
|
|
137
|
+
fn try_tactic_adjustment(&mut self, old_side: PhysicalSide, new_side: PhysicalSide) {
|
|
138
|
+
self.side.try_tactic_adjustment(old_side, new_side);
|
|
139
|
+
if let Some(fallback) = self.fallback.as_mut() {
|
|
140
|
+
fallback.try_tactic_adjustment(old_side, new_side);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/// A computed type for `inset` properties.
|
|
146
|
+
pub type Inset = GenericInset<Percentage, LengthPercentage>;
|
|
147
|
+
impl TryTacticAdjustment for Inset {
|
|
148
|
+
// https://drafts.csswg.org/css-anchor-position-1/#swap-due-to-a-try-tactic:
|
|
149
|
+
//
|
|
150
|
+
// For inset properties, change the specified side in anchor() functions to maintain the
|
|
151
|
+
// same relative relationship to the new direction that they had to the old.
|
|
152
|
+
//
|
|
153
|
+
// If a <percentage> is used, and directions are opposing, change it to 100% minus the
|
|
154
|
+
// original percentage.
|
|
155
|
+
fn try_tactic_adjustment(&mut self, old_side: PhysicalSide, new_side: PhysicalSide) {
|
|
156
|
+
match self {
|
|
157
|
+
Self::Auto => {},
|
|
158
|
+
Self::AnchorContainingCalcFunction(lp) | Self::LengthPercentage(lp) => {
|
|
159
|
+
lp.try_tactic_adjustment(old_side, new_side)
|
|
160
|
+
},
|
|
161
|
+
Self::AnchorFunction(anchor) => anchor.try_tactic_adjustment(old_side, new_side),
|
|
162
|
+
Self::AnchorSizeFunction(anchor) => anchor.try_tactic_adjustment(old_side, new_side),
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
impl Position {
|
|
168
|
+
/// `50% 50%`
|
|
169
|
+
#[inline]
|
|
170
|
+
pub fn center() -> Self {
|
|
171
|
+
Self::new(
|
|
172
|
+
LengthPercentage::new_percent(Percentage(0.5)),
|
|
173
|
+
LengthPercentage::new_percent(Percentage(0.5)),
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/// `0% 0%`
|
|
178
|
+
#[inline]
|
|
179
|
+
pub fn zero() -> Self {
|
|
180
|
+
Self::new(LengthPercentage::zero(), LengthPercentage::zero())
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
impl ToCss for Position {
|
|
185
|
+
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
|
186
|
+
where
|
|
187
|
+
W: Write,
|
|
188
|
+
{
|
|
189
|
+
self.horizontal.to_css(dest)?;
|
|
190
|
+
dest.write_char(' ')?;
|
|
191
|
+
self.vertical.to_css(dest)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
impl GenericPositionComponent for LengthPercentage {
|
|
196
|
+
fn is_center(&self) -> bool {
|
|
197
|
+
match self.to_percentage() {
|
|
198
|
+
Some(Percentage(per)) => per == 0.5,
|
|
199
|
+
_ => false,
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
#[inline]
|
|
205
|
+
fn block_or_inline_to_inferred(keyword: PositionAreaKeyword) -> PositionAreaKeyword {
|
|
206
|
+
if matches!(
|
|
207
|
+
keyword.axis(),
|
|
208
|
+
PositionAreaAxis::Block | PositionAreaAxis::Inline
|
|
209
|
+
) {
|
|
210
|
+
keyword.with_axis(PositionAreaAxis::Inferred)
|
|
211
|
+
} else {
|
|
212
|
+
keyword
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
#[inline]
|
|
217
|
+
fn inferred_to_block(keyword: PositionAreaKeyword) -> PositionAreaKeyword {
|
|
218
|
+
keyword.with_inferred_axis(PositionAreaAxis::Block)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
#[inline]
|
|
222
|
+
fn inferred_to_inline(keyword: PositionAreaKeyword) -> PositionAreaKeyword {
|
|
223
|
+
keyword.with_inferred_axis(PositionAreaAxis::Inline)
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// This exists because the spec currently says that further simplifications
|
|
227
|
+
// should be made to the computed value. That's confusing though, and probably
|
|
228
|
+
// all these simplifications should be wrapped up into the simplifications that
|
|
229
|
+
// we make to the specified value. I.e. all this should happen in
|
|
230
|
+
// PositionArea::parse_internal().
|
|
231
|
+
// See also https://github.com/w3c/csswg-drafts/issues/12759
|
|
232
|
+
impl ToComputedValue for PositionArea {
|
|
233
|
+
type ComputedValue = Self;
|
|
234
|
+
|
|
235
|
+
fn to_computed_value(&self, _context: &Context) -> Self {
|
|
236
|
+
let mut computed = *self;
|
|
237
|
+
let pair_type = self.get_type();
|
|
238
|
+
if pair_type == PositionAreaType::Logical || pair_type == PositionAreaType::SelfLogical {
|
|
239
|
+
if computed.second != PositionAreaKeyword::None {
|
|
240
|
+
computed.first = block_or_inline_to_inferred(computed.first);
|
|
241
|
+
computed.second = block_or_inline_to_inferred(computed.second);
|
|
242
|
+
}
|
|
243
|
+
} else if pair_type == PositionAreaType::Inferred
|
|
244
|
+
|| pair_type == PositionAreaType::SelfInferred
|
|
245
|
+
{
|
|
246
|
+
if computed.second == PositionAreaKeyword::SpanAll {
|
|
247
|
+
// We remove the superfluous span-all, converting the inferred
|
|
248
|
+
// keyword to a logical keyword to avoid ambiguity, per spec.
|
|
249
|
+
computed.first = inferred_to_block(computed.first);
|
|
250
|
+
computed.second = PositionAreaKeyword::None;
|
|
251
|
+
} else if computed.first == PositionAreaKeyword::SpanAll {
|
|
252
|
+
computed.first = computed.second;
|
|
253
|
+
computed.first = inferred_to_inline(computed.first);
|
|
254
|
+
computed.second = PositionAreaKeyword::None;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if computed.first == computed.second {
|
|
259
|
+
computed.second = PositionAreaKeyword::None;
|
|
260
|
+
}
|
|
261
|
+
computed
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
fn from_computed_value(computed: &Self) -> Self {
|
|
265
|
+
*computed
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/// A computed value for the `z-index` property.
|
|
270
|
+
pub type ZIndex = GenericZIndex<Integer>;
|
|
271
|
+
|
|
272
|
+
/// A computed value for the `aspect-ratio` property.
|
|
273
|
+
pub type AspectRatio = GenericAspectRatio<NonNegativeNumber>;
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
//! `<ratio>` computed values.
|
|
6
|
+
|
|
7
|
+
use crate::values::animated::{Animate, Procedure};
|
|
8
|
+
use crate::values::computed::NonNegativeNumber;
|
|
9
|
+
use crate::values::distance::{ComputeSquaredDistance, SquaredDistance};
|
|
10
|
+
use crate::values::generics::ratio::Ratio as GenericRatio;
|
|
11
|
+
use crate::values::generics::NonNegative;
|
|
12
|
+
use crate::Zero;
|
|
13
|
+
use std::cmp::Ordering;
|
|
14
|
+
|
|
15
|
+
/// A computed <ratio> value.
|
|
16
|
+
pub type Ratio = GenericRatio<NonNegativeNumber>;
|
|
17
|
+
|
|
18
|
+
impl PartialOrd for Ratio {
|
|
19
|
+
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
|
20
|
+
f64::partial_cmp(
|
|
21
|
+
&((self.0).0 as f64 * (other.1).0 as f64),
|
|
22
|
+
&((self.1).0 as f64 * (other.0).0 as f64),
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
impl Ratio {
|
|
28
|
+
/// Returns the f32 value by dividing the first value by the second one.
|
|
29
|
+
#[inline]
|
|
30
|
+
fn to_f32(&self) -> f32 {
|
|
31
|
+
debug_assert!(!self.is_degenerate());
|
|
32
|
+
(self.0).0 / (self.1).0
|
|
33
|
+
}
|
|
34
|
+
/// Returns a new Ratio.
|
|
35
|
+
#[inline]
|
|
36
|
+
pub fn new(a: f32, b: f32) -> Self {
|
|
37
|
+
GenericRatio(a.into(), b.into())
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/// https://drafts.csswg.org/css-values/#combine-ratio
|
|
42
|
+
impl Animate for Ratio {
|
|
43
|
+
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
|
44
|
+
// If either <ratio> is degenerate, the values cannot be interpolated.
|
|
45
|
+
if self.is_degenerate() || other.is_degenerate() {
|
|
46
|
+
return Err(());
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Addition of <ratio>s is not possible, and based on
|
|
50
|
+
// https://drafts.csswg.org/css-values-4/#not-additive,
|
|
51
|
+
// we simply use the first value as the result value.
|
|
52
|
+
// Besides, the procedure for accumulation should be identical to addition here.
|
|
53
|
+
if matches!(procedure, Procedure::Add | Procedure::Accumulate { .. }) {
|
|
54
|
+
return Ok(*self);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// The interpolation of a <ratio> is defined by converting each <ratio> to a number by
|
|
58
|
+
// dividing the first value by the second (so a ratio of 3 / 2 would become 1.5), taking
|
|
59
|
+
// the logarithm of that result (so the 1.5 would become approximately 0.176), then
|
|
60
|
+
// interpolating those values.
|
|
61
|
+
//
|
|
62
|
+
// The result during the interpolation is converted back to a <ratio> by inverting the
|
|
63
|
+
// logarithm, then interpreting the result as a <ratio> with the result as the first value
|
|
64
|
+
// and 1 as the second value.
|
|
65
|
+
let start = self.to_f32().ln();
|
|
66
|
+
let end = other.to_f32().ln();
|
|
67
|
+
let e = std::f32::consts::E;
|
|
68
|
+
let result = e.powf(start.animate(&end, procedure)?);
|
|
69
|
+
// The range of the result is [0, inf), based on the easing function.
|
|
70
|
+
if result.is_zero() || result.is_infinite() {
|
|
71
|
+
return Err(());
|
|
72
|
+
}
|
|
73
|
+
Ok(GenericRatio(NonNegative(result), NonNegative(1.0)))
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
impl ComputeSquaredDistance for Ratio {
|
|
78
|
+
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
|
|
79
|
+
if self.is_degenerate() || other.is_degenerate() {
|
|
80
|
+
return Err(());
|
|
81
|
+
}
|
|
82
|
+
// Use the distance of their logarithm values. (This is used by testing, so don't
|
|
83
|
+
// need to care about the base. Here we use the same base as that in animate().)
|
|
84
|
+
self.to_f32()
|
|
85
|
+
.ln()
|
|
86
|
+
.compute_squared_distance(&other.to_f32().ln())
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
//! Computed types for CSS borders.
|
|
6
|
+
|
|
7
|
+
use crate::typed_om::{ToTyped, TypedValue};
|
|
8
|
+
use crate::values::computed::length::NonNegativeLengthOrNumber;
|
|
9
|
+
use crate::values::generics::rect::Rect;
|
|
10
|
+
use thin_vec::ThinVec;
|
|
11
|
+
|
|
12
|
+
/// A specified rectangle made of four `<length-or-number>` values.
|
|
13
|
+
pub type NonNegativeLengthOrNumberRect = Rect<NonNegativeLengthOrNumber>;
|
|
14
|
+
|
|
15
|
+
impl ToTyped for NonNegativeLengthOrNumberRect {
|
|
16
|
+
fn to_typed(&self, _dest: &mut ThinVec<TypedValue>) -> Result<(), ()> {
|
|
17
|
+
Err(())
|
|
18
|
+
}
|
|
19
|
+
}
|