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,224 @@
|
|
|
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
|
+
//! Global style data
|
|
6
|
+
|
|
7
|
+
use crate::context::StyleSystemOptions;
|
|
8
|
+
#[cfg(feature = "gecko")]
|
|
9
|
+
use crate::gecko_bindings::bindings;
|
|
10
|
+
use crate::parallel::STYLE_THREAD_STACK_SIZE_KB;
|
|
11
|
+
use crate::shared_lock::SharedRwLock;
|
|
12
|
+
use crate::thread_state;
|
|
13
|
+
use parking_lot::{Mutex, RwLock, RwLockReadGuard};
|
|
14
|
+
#[cfg(all(unix, not(target_arch = "wasm32")))]
|
|
15
|
+
use std::os::unix::thread::{JoinHandleExt, RawPthread};
|
|
16
|
+
#[cfg(windows)]
|
|
17
|
+
use std::os::windows::{io::AsRawHandle, prelude::RawHandle};
|
|
18
|
+
use std::{io, sync::LazyLock, thread};
|
|
19
|
+
use thin_vec::ThinVec;
|
|
20
|
+
|
|
21
|
+
/// Platform-specific handle to a thread.
|
|
22
|
+
#[cfg(all(unix, not(target_arch = "wasm32")))]
|
|
23
|
+
pub type PlatformThreadHandle = RawPthread;
|
|
24
|
+
/// Platform-specific handle to a thread.
|
|
25
|
+
#[cfg(windows)]
|
|
26
|
+
pub type PlatformThreadHandle = RawHandle;
|
|
27
|
+
|
|
28
|
+
/// A noop thread join handle for wasm
|
|
29
|
+
/// The usize field is a dummy field to make this type non-zero sized so as not to confuse FFI
|
|
30
|
+
#[cfg(all(target_arch = "wasm32", not(feature = "gecko")))]
|
|
31
|
+
pub struct DummyThreadHandle;
|
|
32
|
+
#[cfg(all(target_arch = "wasm32", not(feature = "gecko")))]
|
|
33
|
+
impl DummyThreadHandle {
|
|
34
|
+
/// A noop thread join method for wasm
|
|
35
|
+
pub fn join(&self) {
|
|
36
|
+
// Do nothing
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
#[cfg(all(target_arch = "wasm32", not(feature = "gecko")))]
|
|
40
|
+
/// Platform-specific handle to a thread.
|
|
41
|
+
pub type PlatformThreadHandle = DummyThreadHandle;
|
|
42
|
+
|
|
43
|
+
/// Global style data
|
|
44
|
+
pub struct GlobalStyleData {
|
|
45
|
+
/// Shared RWLock for CSSOM objects
|
|
46
|
+
pub shared_lock: SharedRwLock,
|
|
47
|
+
|
|
48
|
+
/// Global style system options determined by env vars.
|
|
49
|
+
pub options: StyleSystemOptions,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/// Global thread pool.
|
|
53
|
+
pub struct StyleThreadPool {
|
|
54
|
+
/// How many threads parallel styling can use. If not using a thread pool, this is set to `None`.
|
|
55
|
+
pub num_threads: Option<usize>,
|
|
56
|
+
|
|
57
|
+
/// The parallel styling thread pool.
|
|
58
|
+
///
|
|
59
|
+
/// For leak-checking purposes, we want to terminate the thread-pool, which
|
|
60
|
+
/// waits for all the async jobs to complete. Thus the RwLock.
|
|
61
|
+
style_thread_pool: RwLock<Option<rayon::ThreadPool>>,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
fn thread_name(index: usize) -> String {
|
|
65
|
+
format!("StyleThread#{}", index)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/// JoinHandles for spawned style threads. These will be joined during
|
|
69
|
+
/// StyleThreadPool::shutdown() after exiting the thread pool.
|
|
70
|
+
///
|
|
71
|
+
/// This would be quite inefficient if rayon destroyed and re-created
|
|
72
|
+
/// threads regularly during threadpool operation in response to demand,
|
|
73
|
+
/// however rayon actually never destroys its threads until the entire
|
|
74
|
+
/// thread pool is shut-down, so the size of this list is bounded.
|
|
75
|
+
static STYLE_THREAD_JOIN_HANDLES: Mutex<Vec<thread::JoinHandle<()>>> = Mutex::new(Vec::new());
|
|
76
|
+
|
|
77
|
+
fn thread_spawn(options: rayon::ThreadBuilder) -> io::Result<()> {
|
|
78
|
+
let mut b = thread::Builder::new();
|
|
79
|
+
if let Some(name) = options.name() {
|
|
80
|
+
b = b.name(name.to_owned());
|
|
81
|
+
}
|
|
82
|
+
if let Some(stack_size) = options.stack_size() {
|
|
83
|
+
b = b.stack_size(stack_size);
|
|
84
|
+
}
|
|
85
|
+
let join_handle = b.spawn(|| options.run())?;
|
|
86
|
+
STYLE_THREAD_JOIN_HANDLES.lock().push(join_handle);
|
|
87
|
+
Ok(())
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
fn thread_startup(_index: usize) {
|
|
91
|
+
thread_state::initialize_layout_worker_thread();
|
|
92
|
+
#[cfg(feature = "gecko")]
|
|
93
|
+
unsafe {
|
|
94
|
+
bindings::Gecko_SetJemallocThreadLocalArena(true);
|
|
95
|
+
let name = thread_name(_index);
|
|
96
|
+
gecko_profiler::register_thread(&name);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
fn thread_shutdown(_: usize) {
|
|
101
|
+
#[cfg(feature = "gecko")]
|
|
102
|
+
unsafe {
|
|
103
|
+
gecko_profiler::unregister_thread();
|
|
104
|
+
bindings::Gecko_SetJemallocThreadLocalArena(false);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
impl StyleThreadPool {
|
|
109
|
+
/// Shuts down the thread pool, waiting for all work to complete.
|
|
110
|
+
pub fn shutdown() {
|
|
111
|
+
if STYLE_THREAD_JOIN_HANDLES.lock().is_empty() {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
{
|
|
115
|
+
// Drop the pool.
|
|
116
|
+
let _ = STYLE_THREAD_POOL.style_thread_pool.write().take();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Join spawned threads until all of the threads have been joined. This
|
|
120
|
+
// will usually be pretty fast, as on shutdown there should be basically
|
|
121
|
+
// no threads left running.
|
|
122
|
+
while let Some(join_handle) = STYLE_THREAD_JOIN_HANDLES.lock().pop() {
|
|
123
|
+
let _ = join_handle.join();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/// Returns a reference to the thread pool.
|
|
128
|
+
///
|
|
129
|
+
/// We only really want to give read-only access to the pool, except
|
|
130
|
+
/// for shutdown().
|
|
131
|
+
pub fn pool(&self) -> RwLockReadGuard<'_, Option<rayon::ThreadPool>> {
|
|
132
|
+
self.style_thread_pool.read()
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/// Returns a list of the pool's platform-specific thread handles.
|
|
136
|
+
pub fn get_thread_handles(handles: &mut ThinVec<PlatformThreadHandle>) {
|
|
137
|
+
// Force the lazy initialization of STYLE_THREAD_POOL so that the threads get spawned and
|
|
138
|
+
// their join handles are added to STYLE_THREAD_JOIN_HANDLES.
|
|
139
|
+
LazyLock::force(&STYLE_THREAD_POOL);
|
|
140
|
+
|
|
141
|
+
for join_handle in STYLE_THREAD_JOIN_HANDLES.lock().iter() {
|
|
142
|
+
#[cfg(all(unix, not(target_arch = "wasm32")))]
|
|
143
|
+
let handle = join_handle.as_pthread_t();
|
|
144
|
+
#[cfg(windows)]
|
|
145
|
+
let handle = join_handle.as_raw_handle();
|
|
146
|
+
#[cfg(all(target_arch = "wasm32", not(feature = "gecko")))]
|
|
147
|
+
let handle = {
|
|
148
|
+
let _ = join_handle;
|
|
149
|
+
DummyThreadHandle
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
handles.push(handle);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
#[cfg(feature = "servo")]
|
|
158
|
+
fn stylo_threads_pref() -> i32 {
|
|
159
|
+
crate::pref!("layout.threads")
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
#[cfg(feature = "gecko")]
|
|
163
|
+
fn stylo_threads_pref() -> i32 {
|
|
164
|
+
crate::pref!("layout.css.stylo-threads")
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/// The performance benefit of additional threads seems to level off at around six, so we cap it
|
|
168
|
+
/// there on many-core machines (see bug 1431285 comment 14).
|
|
169
|
+
pub(crate) const STYLO_MAX_THREADS: usize = 6;
|
|
170
|
+
|
|
171
|
+
/// Global thread pool
|
|
172
|
+
pub static STYLE_THREAD_POOL: LazyLock<StyleThreadPool> = LazyLock::new(|| {
|
|
173
|
+
use std::cmp;
|
|
174
|
+
// We always set this pref on startup, before layout or script have had a chance of
|
|
175
|
+
// accessing (and thus creating) the thread-pool.
|
|
176
|
+
let threads_pref: i32 = stylo_threads_pref();
|
|
177
|
+
let num_threads = if threads_pref >= 0 {
|
|
178
|
+
threads_pref as usize
|
|
179
|
+
} else {
|
|
180
|
+
// Gecko may wish to override the default number of threads, for example on
|
|
181
|
+
// systems with heterogeneous CPUs.
|
|
182
|
+
#[cfg(feature = "gecko")]
|
|
183
|
+
let num_threads = unsafe { bindings::Gecko_GetNumStyleThreads() };
|
|
184
|
+
#[cfg(not(feature = "gecko"))]
|
|
185
|
+
let num_threads = -1;
|
|
186
|
+
|
|
187
|
+
if num_threads >= 0 {
|
|
188
|
+
num_threads as usize
|
|
189
|
+
} else {
|
|
190
|
+
// The default heuristic is num_virtual_cores * .75. This gives us three threads on a
|
|
191
|
+
// hyper-threaded dual core, and six threads on a hyper-threaded quad core.
|
|
192
|
+
cmp::max(num_cpus::get() * 3 / 4, 1)
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
let num_threads = cmp::min(num_threads, STYLO_MAX_THREADS);
|
|
197
|
+
// Since the main-thread is also part of the pool, having one thread or less doesn't make
|
|
198
|
+
// sense.
|
|
199
|
+
let (pool, num_threads) = if num_threads <= 1 {
|
|
200
|
+
(None, None)
|
|
201
|
+
} else {
|
|
202
|
+
let workers = rayon::ThreadPoolBuilder::new()
|
|
203
|
+
.spawn_handler(thread_spawn)
|
|
204
|
+
.use_current_thread()
|
|
205
|
+
.num_threads(num_threads)
|
|
206
|
+
.thread_name(thread_name)
|
|
207
|
+
.start_handler(thread_startup)
|
|
208
|
+
.exit_handler(thread_shutdown)
|
|
209
|
+
.stack_size(STYLE_THREAD_STACK_SIZE_KB * 1024)
|
|
210
|
+
.build();
|
|
211
|
+
(workers.ok(), Some(num_threads))
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
StyleThreadPool {
|
|
215
|
+
num_threads,
|
|
216
|
+
style_thread_pool: RwLock::new(pool),
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
/// Global style data
|
|
221
|
+
pub static GLOBAL_STYLE_DATA: LazyLock<GlobalStyleData> = LazyLock::new(|| GlobalStyleData {
|
|
222
|
+
shared_lock: SharedRwLock::new_leaked(),
|
|
223
|
+
options: StyleSystemOptions::default(),
|
|
224
|
+
});
|
|
@@ -0,0 +1,156 @@
|
|
|
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
|
+
//! An invalidation processor for style changes due to document state changes.
|
|
6
|
+
|
|
7
|
+
use crate::dom::TElement;
|
|
8
|
+
use crate::invalidation::element::invalidation_map::Dependency;
|
|
9
|
+
use crate::invalidation::element::invalidator::{
|
|
10
|
+
DescendantInvalidationLists, InvalidationVector, SiblingTraversalMap,
|
|
11
|
+
};
|
|
12
|
+
use crate::invalidation::element::invalidator::{Invalidation, InvalidationProcessor};
|
|
13
|
+
use crate::invalidation::element::state_and_attributes;
|
|
14
|
+
use crate::stylist::CascadeData;
|
|
15
|
+
use dom::DocumentState;
|
|
16
|
+
use selectors::matching::{
|
|
17
|
+
MatchingContext, MatchingForInvalidation, MatchingMode, NeedsSelectorFlags, QuirksMode,
|
|
18
|
+
SelectorCaches, VisitedHandlingMode,
|
|
19
|
+
};
|
|
20
|
+
use selectors::OpaqueElement;
|
|
21
|
+
|
|
22
|
+
/// A struct holding the members necessary to invalidate document state
|
|
23
|
+
/// selectors.
|
|
24
|
+
#[derive(Debug)]
|
|
25
|
+
pub struct InvalidationMatchingData {
|
|
26
|
+
/// The document state that has changed, which makes it always match.
|
|
27
|
+
pub document_state: DocumentState,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
impl Default for InvalidationMatchingData {
|
|
31
|
+
#[inline(always)]
|
|
32
|
+
fn default() -> Self {
|
|
33
|
+
Self {
|
|
34
|
+
document_state: DocumentState::empty(),
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/// An invalidation processor for style changes due to state and attribute
|
|
40
|
+
/// changes.
|
|
41
|
+
pub struct DocumentStateInvalidationProcessor<'a, 'b, E: TElement, I> {
|
|
42
|
+
rules: I,
|
|
43
|
+
matching_context: MatchingContext<'a, E::Impl>,
|
|
44
|
+
traversal_map: SiblingTraversalMap<E>,
|
|
45
|
+
document_states_changed: DocumentState,
|
|
46
|
+
_marker: std::marker::PhantomData<&'b ()>,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
impl<'a, 'b, E: TElement, I> DocumentStateInvalidationProcessor<'a, 'b, E, I> {
|
|
50
|
+
/// Creates a new DocumentStateInvalidationProcessor.
|
|
51
|
+
#[inline]
|
|
52
|
+
pub fn new(
|
|
53
|
+
rules: I,
|
|
54
|
+
document_states_changed: DocumentState,
|
|
55
|
+
selector_caches: &'a mut SelectorCaches,
|
|
56
|
+
quirks_mode: QuirksMode,
|
|
57
|
+
) -> Self {
|
|
58
|
+
let mut matching_context = MatchingContext::<'a, E::Impl>::new_for_visited(
|
|
59
|
+
MatchingMode::Normal,
|
|
60
|
+
None,
|
|
61
|
+
selector_caches,
|
|
62
|
+
VisitedHandlingMode::AllLinksVisitedAndUnvisited,
|
|
63
|
+
quirks_mode,
|
|
64
|
+
NeedsSelectorFlags::No,
|
|
65
|
+
MatchingForInvalidation::No,
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
matching_context.extra_data.invalidation_data.document_state = document_states_changed;
|
|
69
|
+
|
|
70
|
+
Self {
|
|
71
|
+
rules,
|
|
72
|
+
document_states_changed,
|
|
73
|
+
matching_context,
|
|
74
|
+
traversal_map: SiblingTraversalMap::default(),
|
|
75
|
+
_marker: std::marker::PhantomData,
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
impl<'a, 'b, E, I> InvalidationProcessor<'b, 'a, E>
|
|
81
|
+
for DocumentStateInvalidationProcessor<'a, 'b, E, I>
|
|
82
|
+
where
|
|
83
|
+
E: TElement,
|
|
84
|
+
I: Iterator<Item = &'b CascadeData>,
|
|
85
|
+
{
|
|
86
|
+
fn check_outer_dependency(&mut self, _: &Dependency, _: E, _: Option<OpaqueElement>) -> bool {
|
|
87
|
+
debug_assert!(
|
|
88
|
+
false,
|
|
89
|
+
"how, we should only have parent-less dependencies here!"
|
|
90
|
+
);
|
|
91
|
+
true
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
fn collect_invalidations(
|
|
95
|
+
&mut self,
|
|
96
|
+
_element: E,
|
|
97
|
+
self_invalidations: &mut InvalidationVector<'b>,
|
|
98
|
+
_descendant_invalidations: &mut DescendantInvalidationLists<'b>,
|
|
99
|
+
_sibling_invalidations: &mut InvalidationVector<'b>,
|
|
100
|
+
) -> bool {
|
|
101
|
+
for cascade_data in &mut self.rules {
|
|
102
|
+
let map = cascade_data.invalidation_map();
|
|
103
|
+
for dependency in &map.document_state_selectors {
|
|
104
|
+
if !dependency.state.intersects(self.document_states_changed) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// We pass `None` as a scope, as document state selectors aren't
|
|
109
|
+
// affected by the current scope.
|
|
110
|
+
//
|
|
111
|
+
// FIXME(emilio): We should really pass the relevant host for
|
|
112
|
+
// self.rules, so that we invalidate correctly if the selector
|
|
113
|
+
// happens to have something like :host(:-moz-window-inactive)
|
|
114
|
+
// for example.
|
|
115
|
+
self_invalidations.push(Invalidation::new(
|
|
116
|
+
&dependency.dependency,
|
|
117
|
+
/* host = */ None,
|
|
118
|
+
/* scope = */ None,
|
|
119
|
+
));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
false
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
fn matching_context(&mut self) -> &mut MatchingContext<'a, E::Impl> {
|
|
127
|
+
&mut self.matching_context
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
fn sibling_traversal_map(&self) -> &SiblingTraversalMap<E> {
|
|
131
|
+
&self.traversal_map
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
fn recursion_limit_exceeded(&mut self, _: E) {
|
|
135
|
+
unreachable!("We don't run document state invalidation with stack limits")
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
fn should_process_descendants(&mut self, element: E) -> bool {
|
|
139
|
+
match element.borrow_data() {
|
|
140
|
+
Some(d) => state_and_attributes::should_process_descendants(&d),
|
|
141
|
+
None => false,
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
fn invalidated_descendants(&mut self, element: E, child: E) {
|
|
146
|
+
state_and_attributes::invalidated_descendants(element, child)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
fn invalidated_self(&mut self, element: E) {
|
|
150
|
+
state_and_attributes::invalidated_self(element);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
fn invalidated_sibling(&mut self, sibling: E, of: E) {
|
|
154
|
+
state_and_attributes::invalidated_sibling(sibling, of);
|
|
155
|
+
}
|
|
156
|
+
}
|