pagyra-js 0.0.20 → 0.0.21
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/README.md +55 -0
- package/dist/assets/fonts/licenses/selawik/SIL Open Font License.txt +43 -0
- package/dist/assets/fonts/ttf/arimo/Arimo-Bold.ttf +0 -0
- package/dist/assets/fonts/ttf/arimo/Arimo-BoldItalic.ttf +0 -0
- package/dist/assets/fonts/ttf/arimo/Arimo-Italic.ttf +0 -0
- package/dist/assets/fonts/ttf/arimo/Arimo-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/cinzeldecorative/CinzelDecorative-Black.ttf +0 -0
- package/dist/assets/fonts/ttf/cinzeldecorative/CinzelDecorative-Bold.ttf +0 -0
- package/dist/assets/fonts/ttf/cinzeldecorative/CinzelDecorative-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/dejavu/DejaVuSans.ttf +0 -0
- package/dist/assets/fonts/ttf/firecode/FiraCode-Bold.ttf +0 -0
- package/dist/assets/fonts/ttf/firecode/FiraCode-Light.ttf +0 -0
- package/dist/assets/fonts/ttf/firecode/FiraCode-Medium.ttf +0 -0
- package/dist/assets/fonts/ttf/firecode/FiraCode-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/firecode/FiraCode-SemiBold.ttf +0 -0
- package/dist/assets/fonts/ttf/notoemoji/NotoEmoji-Bold.ttf +0 -0
- package/dist/assets/fonts/ttf/notoemoji/NotoEmoji-Light.ttf +0 -0
- package/dist/assets/fonts/ttf/notoemoji/NotoEmoji-Medium.ttf +0 -0
- package/dist/assets/fonts/ttf/notoemoji/NotoEmoji-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/notoemoji/NotoEmoji-SemiBold.ttf +0 -0
- package/dist/assets/fonts/ttf/notosans/NotoSans-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/roboto/Roboto-Bold.ttf +0 -0
- package/dist/assets/fonts/ttf/roboto/Roboto-BoldItalic.ttf +0 -0
- package/dist/assets/fonts/ttf/roboto/Roboto-Italic.ttf +0 -0
- package/dist/assets/fonts/ttf/roboto/Roboto-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/selawik/selawk.ttf +0 -0
- package/dist/assets/fonts/ttf/selawik/selawkb.ttf +0 -0
- package/dist/assets/fonts/ttf/selawik/selawkl.ttf +0 -0
- package/dist/assets/fonts/ttf/selawik/selawksb.ttf +0 -0
- package/dist/assets/fonts/ttf/selawik/selawksl.ttf +0 -0
- package/dist/assets/fonts/ttf/stixtwomath/STIXTwoMath-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/tinos/Tinos-Bold.ttf +0 -0
- package/dist/assets/fonts/ttf/tinos/Tinos-BoldItalic.ttf +0 -0
- package/dist/assets/fonts/ttf/tinos/Tinos-Italic.ttf +0 -0
- package/dist/assets/fonts/ttf/tinos/Tinos-Regular.ttf +0 -0
- package/dist/assets/fonts/woff/lato/lato-latin-400-italic.woff +0 -0
- package/dist/assets/fonts/woff/lato/lato-latin-400-normal.woff +0 -0
- package/dist/assets/fonts/woff/lato/lato-latin-700-italic.woff +0 -0
- package/dist/assets/fonts/woff/lato/lato-latin-700-normal.woff +0 -0
- package/dist/assets/fonts/woff2/caveat/Caveat-Bold.woff2 +0 -0
- package/dist/assets/fonts/woff2/caveat/Caveat-Regular.woff2 +0 -0
- package/dist/assets/fonts/woff2/lato/lato-latin-400-italic.woff2 +0 -0
- package/dist/assets/fonts/woff2/lato/lato-latin-400-normal.woff2 +0 -0
- package/dist/assets/fonts/woff2/lato/lato-latin-700-italic.woff2 +0 -0
- package/dist/assets/fonts/woff2/lato/lato-latin-700-normal.woff2 +0 -0
- package/dist/browser/pagyra.min.js +34 -34
- package/dist/browser/pagyra.min.js.map +4 -4
- package/dist/playground/server.js +2 -0
- package/dist/src/css/compute-style/base-options.d.ts +7 -0
- package/dist/src/css/compute-style/base-options.js +24 -0
- package/dist/src/css/compute-style/declarations.d.ts +10 -0
- package/dist/src/css/compute-style/declarations.js +77 -0
- package/dist/src/css/compute-style/decoration.d.ts +8 -0
- package/dist/src/css/compute-style/decoration.js +55 -0
- package/dist/src/css/compute-style/defaults.d.ts +3 -0
- package/dist/src/css/compute-style/defaults.js +34 -0
- package/dist/src/css/compute-style/display.d.ts +3 -0
- package/dist/src/css/compute-style/display.js +85 -0
- package/dist/src/css/compute-style/float.d.ts +2 -0
- package/dist/src/css/compute-style/float.js +13 -0
- package/dist/src/css/compute-style/font.d.ts +12 -0
- package/dist/src/css/compute-style/font.js +57 -0
- package/dist/src/css/compute-style/overrides.d.ts +3 -0
- package/dist/src/css/compute-style/overrides.js +241 -0
- package/dist/src/css/compute-style.d.ts +2 -0
- package/dist/src/css/compute-style.js +34 -487
- package/dist/src/css/enums.d.ts +4 -0
- package/dist/src/css/enums.js +5 -0
- package/dist/src/css/layout-property-resolver.js +30 -18
- package/dist/src/css/length.d.ts +26 -2
- package/dist/src/css/length.js +48 -0
- package/dist/src/css/parsers/background-parser.js +1 -1
- package/dist/src/css/parsers/calc-parser.d.ts +2 -0
- package/dist/src/css/parsers/calc-parser.js +310 -0
- package/dist/src/css/parsers/content-parser.d.ts +2 -1
- package/dist/src/css/parsers/content-parser.js +7 -2
- package/dist/src/css/parsers/dimension-parser.js +37 -18
- package/dist/src/css/parsers/display-flex-parser.d.ts +4 -0
- package/dist/src/css/parsers/display-flex-parser.js +97 -0
- package/dist/src/css/parsers/filter-parser.d.ts +14 -0
- package/dist/src/css/parsers/filter-parser.js +255 -0
- package/dist/src/css/parsers/grid-parser-extended.d.ts +1 -0
- package/dist/src/css/parsers/grid-parser-extended.js +40 -1
- package/dist/src/css/parsers/grid-parser.d.ts +5 -2
- package/dist/src/css/parsers/grid-parser.js +71 -7
- package/dist/src/css/parsers/length-parser.d.ts +8 -3
- package/dist/src/css/parsers/length-parser.js +45 -2
- package/dist/src/css/parsers/margin-block-parser.js +3 -3
- package/dist/src/css/parsers/margin-parser.js +3 -3
- package/dist/src/css/parsers/padding-block-parser.js +3 -3
- package/dist/src/css/parsers/padding-inline-parser.js +3 -3
- package/dist/src/css/parsers/padding-parser.js +6 -6
- package/dist/src/css/parsers/position-parser.js +2 -22
- package/dist/src/css/parsers/register-parsers.js +29 -2
- package/dist/src/css/parsers/word-break-parser.d.ts +2 -0
- package/dist/src/css/parsers/word-break-parser.js +23 -0
- package/dist/src/css/properties/grid.d.ts +16 -2
- package/dist/src/css/properties/layout.d.ts +3 -1
- package/dist/src/css/properties/layout.js +1 -1
- package/dist/src/css/properties/misc.d.ts +5 -0
- package/dist/src/css/properties/typography.d.ts +3 -0
- package/dist/src/css/properties/visual.d.ts +36 -0
- package/dist/src/css/shorthands/box-shorthand.d.ts +2 -2
- package/dist/src/css/style-inheritance.d.ts +2 -1
- package/dist/src/css/style-inheritance.js +1 -0
- package/dist/src/css/style.d.ts +30 -10
- package/dist/src/css/style.js +8 -1
- package/dist/src/css/ua-defaults/base-defaults.d.ts +1 -0
- package/dist/src/css/ua-defaults/base-defaults.js +10 -1
- package/dist/src/css/ua-defaults/element-defaults.js +0 -2
- package/dist/src/html/css/parse-css.d.ts +2 -0
- package/dist/src/html/css/parse-css.js +32 -3
- package/dist/src/html/dom-converter/background-images.d.ts +3 -0
- package/dist/src/html/dom-converter/background-images.js +88 -0
- package/dist/src/html/dom-converter/convert-dom-node.d.ts +5 -0
- package/dist/src/html/dom-converter/convert-dom-node.js +81 -0
- package/dist/src/html/dom-converter/handlers/br-handler.d.ts +2 -0
- package/dist/src/html/dom-converter/handlers/br-handler.js +20 -0
- package/dist/src/html/dom-converter/handlers/form-control-handler.d.ts +2 -0
- package/dist/src/html/dom-converter/handlers/form-control-handler.js +28 -0
- package/dist/src/html/dom-converter/handlers/img-handler.d.ts +2 -0
- package/dist/src/html/dom-converter/handlers/img-handler.js +4 -0
- package/dist/src/html/dom-converter/handlers/index.d.ts +4 -0
- package/dist/src/html/dom-converter/handlers/index.js +19 -0
- package/dist/src/html/dom-converter/handlers/svg-handler.d.ts +2 -0
- package/dist/src/html/dom-converter/handlers/svg-handler.js +32 -0
- package/dist/src/html/dom-converter/handlers/types.d.ts +12 -0
- package/dist/src/html/dom-converter/handlers/types.js +2 -0
- package/dist/src/html/dom-converter/helpers.d.ts +7 -0
- package/dist/src/html/dom-converter/helpers.js +35 -0
- package/dist/src/html/dom-converter/index.d.ts +1 -0
- package/dist/src/html/dom-converter/index.js +1 -0
- package/dist/src/html/dom-converter/pseudo-elements.d.ts +6 -0
- package/dist/src/html/dom-converter/pseudo-elements.js +48 -0
- package/dist/src/html/dom-converter/text.d.ts +15 -0
- package/dist/src/html/dom-converter/text.js +170 -0
- package/dist/src/html/dom-converter.d.ts +1 -5
- package/dist/src/html/dom-converter.js +1 -417
- package/dist/src/html/image-converter.d.ts +5 -0
- package/dist/src/html-to-pdf/document-css.d.ts +14 -0
- package/dist/src/html-to-pdf/document-css.js +45 -0
- package/dist/src/html-to-pdf/fonts.d.ts +16 -0
- package/dist/src/html-to-pdf/fonts.js +74 -0
- package/dist/src/html-to-pdf/header-footer.d.ts +14 -0
- package/dist/src/html-to-pdf/header-footer.js +101 -0
- package/dist/src/html-to-pdf/html-parser.d.ts +6 -0
- package/dist/src/html-to-pdf/html-parser.js +81 -0
- package/dist/src/html-to-pdf/index.d.ts +3 -0
- package/dist/src/html-to-pdf/index.js +2 -0
- package/dist/src/html-to-pdf/layout-build.d.ts +37 -0
- package/dist/src/html-to-pdf/layout-build.js +73 -0
- package/dist/src/html-to-pdf/prepare-html-render.d.ts +2 -0
- package/dist/src/html-to-pdf/prepare-html-render.js +121 -0
- package/dist/src/html-to-pdf/render-finalize.d.ts +15 -0
- package/dist/src/html-to-pdf/render-finalize.js +27 -0
- package/dist/src/html-to-pdf/render-html-to-pdf.d.ts +3 -0
- package/dist/src/html-to-pdf/render-html-to-pdf.js +25 -0
- package/dist/src/html-to-pdf/resource-loader.d.ts +6 -0
- package/dist/src/html-to-pdf/resource-loader.js +120 -0
- package/dist/src/html-to-pdf/types.d.ts +38 -0
- package/dist/src/html-to-pdf/types.js +2 -0
- package/dist/src/html-to-pdf.d.ts +1 -37
- package/dist/src/html-to-pdf.js +1 -537
- package/dist/src/image/js-png-backend.d.ts +7 -0
- package/dist/src/image/js-png-backend.js +9 -0
- package/dist/src/image/png-backend.d.ts +5 -0
- package/dist/src/image/png-backend.js +1 -0
- package/dist/src/image/png-wasm-loader.d.ts +5 -0
- package/dist/src/image/png-wasm-loader.js +59 -0
- package/dist/src/image/wasm/png_decoder_wasm.d.ts +8 -0
- package/dist/src/image/wasm/png_decoder_wasm.js +24 -0
- package/dist/src/image/wasm/png_decoder_wasm_bg.js +16 -0
- package/dist/src/image/wasm-png-backend.d.ts +6 -0
- package/dist/src/image/wasm-png-backend.js +17 -0
- package/dist/src/layout/counter.d.ts +1 -2
- package/dist/src/layout/counter.js +18 -18
- package/dist/src/layout/inline/inline-utils.d.ts +1 -1
- package/dist/src/layout/inline/inline-utils.js +8 -7
- package/dist/src/layout/inline/layout.js +16 -3
- package/dist/src/layout/inline/run-placer.d.ts +1 -0
- package/dist/src/layout/inline/run-placer.js +2 -10
- package/dist/src/layout/pipeline/out-of-flow-manager.js +25 -1
- package/dist/src/layout/strategies/block.js +35 -24
- package/dist/src/layout/strategies/flex.js +305 -61
- package/dist/src/layout/strategies/form.d.ts +2 -0
- package/dist/src/layout/strategies/form.js +38 -13
- package/dist/src/layout/strategies/grid.js +166 -29
- package/dist/src/layout/strategies/image.js +53 -27
- package/dist/src/layout/strategies/inline.js +26 -21
- package/dist/src/layout/strategies/table.js +26 -18
- package/dist/src/layout/utils/content-measurer.d.ts +1 -1
- package/dist/src/layout/utils/content-measurer.js +8 -7
- package/dist/src/layout/utils/floats.d.ts +1 -0
- package/dist/src/layout/utils/floats.js +14 -12
- package/dist/src/layout/utils/margin.d.ts +4 -4
- package/dist/src/layout/utils/margin.js +20 -16
- package/dist/src/layout/utils/node-math.d.ts +12 -6
- package/dist/src/layout/utils/node-math.js +71 -41
- package/dist/src/layout/utils/sizing.js +2 -1
- package/dist/src/pdf/font-subset/font-registry.d.ts +6 -0
- package/dist/src/pdf/font-subset/font-registry.js +30 -2
- package/dist/src/pdf/header-footer-renderer.js +12 -1
- package/dist/src/pdf/layout-tree-builder.js +5 -1
- package/dist/src/pdf/page-painter.js +13 -0
- package/dist/src/pdf/pagination.js +2 -2
- package/dist/src/pdf/renderer/box-painter.js +28 -3
- package/dist/src/pdf/renderer/page-paint.js +11 -3
- package/dist/src/pdf/renderers/radius-utils.js +31 -38
- package/dist/src/pdf/renderers/shape-renderer.js +1 -1
- package/dist/src/pdf/renderers/shape-utils.js +1 -1
- package/dist/src/pdf/renderers/text-renderer.d.ts +9 -1
- package/dist/src/pdf/renderers/text-renderer.js +36 -2
- package/dist/src/pdf/stacking/build-stacking-contexts.js +1 -2
- package/dist/src/pdf/stacking/resolve-paint-order.d.ts +5 -6
- package/dist/src/pdf/stacking/resolve-paint-order.js +29 -9
- package/dist/src/pdf/stacking/types.d.ts +14 -0
- package/dist/src/pdf/svg/shape-renderer.js +47 -20
- package/dist/src/pdf/types.d.ts +7 -1
- package/dist/src/pdf/utils/border-radius-utils.js +31 -38
- package/dist/src/pdf/utils/color-utils.js +17 -2
- package/dist/src/pdf/utils/filter-utils.d.ts +29 -0
- package/dist/src/pdf/utils/filter-utils.js +85 -0
- package/dist/src/pdf/utils/node-text-run-factory.js +1 -1
- package/dist/src/pdf/utils/text-layout-adjuster.d.ts +0 -8
- package/dist/src/pdf/utils/text-layout-adjuster.js +12 -9
- package/dist/src/units/units.d.ts +1 -1
- package/dist/tests/css/box-sizing.spec.d.ts +1 -0
- package/dist/tests/css/box-sizing.spec.js +46 -0
- package/dist/tests/css/calc-parser.spec.d.ts +1 -0
- package/dist/tests/css/calc-parser.spec.js +68 -0
- package/dist/tests/css/container-query-units.spec.d.ts +1 -0
- package/dist/tests/css/container-query-units.spec.js +64 -0
- package/dist/tests/css/content-parser.spec.js +13 -0
- package/dist/tests/css/filter-parser.spec.d.ts +1 -0
- package/dist/tests/css/filter-parser.spec.js +116 -0
- package/dist/tests/css/flex-shorthand.spec.d.ts +1 -0
- package/dist/tests/css/flex-shorthand.spec.js +45 -0
- package/dist/tests/css/grid-clamp.spec.d.ts +1 -0
- package/dist/tests/css/grid-clamp.spec.js +82 -0
- package/dist/tests/css/parse-css-pseudo.spec.d.ts +1 -0
- package/dist/tests/css/parse-css-pseudo.spec.js +26 -0
- package/dist/tests/helpers/render-utils.d.ts +18 -2
- package/dist/tests/helpers/render-utils.js +25 -12
- package/dist/tests/html/dom-converter-pseudo-elements.spec.d.ts +1 -0
- package/dist/tests/html/dom-converter-pseudo-elements.spec.js +33 -0
- package/dist/tests/html/dom-converter-text.spec.d.ts +1 -0
- package/dist/tests/html/dom-converter-text.spec.js +67 -0
- package/dist/tests/image/png-backend.spec.d.ts +1 -0
- package/dist/tests/image/png-backend.spec.js +34 -0
- package/dist/tests/layout/box-sizing.spec.d.ts +1 -0
- package/dist/tests/layout/box-sizing.spec.js +75 -0
- package/dist/tests/layout/calc-padding.spec.d.ts +1 -0
- package/dist/tests/layout/calc-padding.spec.js +19 -0
- package/dist/tests/layout/container-query-units.spec.d.ts +1 -0
- package/dist/tests/layout/container-query-units.spec.js +24 -0
- package/dist/tests/layout/flex-auto-height.spec.d.ts +1 -0
- package/dist/tests/layout/flex-auto-height.spec.js +35 -0
- package/dist/tests/layout/flex-wrap-cards.spec.d.ts +1 -0
- package/dist/tests/layout/flex-wrap-cards.spec.js +16 -0
- package/dist/tests/layout/flex-wrap-grow-align-content.spec.d.ts +1 -0
- package/dist/tests/layout/flex-wrap-grow-align-content.spec.js +20 -0
- package/dist/tests/layout/grid-clamp-gap.spec.d.ts +1 -0
- package/dist/tests/layout/grid-clamp-gap.spec.js +22 -0
- package/dist/tests/layout/inline-fragments.spec.js +38 -0
- package/dist/tests/layout/paged-body-margin.spec.d.ts +1 -0
- package/dist/tests/layout/paged-body-margin.spec.js +92 -0
- package/dist/tests/layout/pseudo-counters-generated-content.spec.d.ts +1 -0
- package/dist/tests/layout/pseudo-counters-generated-content.spec.js +51 -0
- package/dist/tests/layout/responsive-clamp-grid-parity.spec.d.ts +1 -0
- package/dist/tests/layout/responsive-clamp-grid-parity.spec.js +75 -0
- package/dist/tests/layout/run-placer-baseline.spec.js +13 -11
- package/dist/tests/pdf/backdrop-filter-noop.spec.d.ts +1 -0
- package/dist/tests/pdf/backdrop-filter-noop.spec.js +140 -0
- package/dist/tests/pdf/filter-drop-shadow.spec.d.ts +1 -0
- package/dist/tests/pdf/filter-drop-shadow.spec.js +74 -0
- package/dist/tests/pdf/filter-opacity.spec.d.ts +1 -0
- package/dist/tests/pdf/filter-opacity.spec.js +30 -0
- package/dist/tests/pdf/font-subset-registry-key.spec.d.ts +1 -0
- package/dist/tests/pdf/font-subset-registry-key.spec.js +66 -0
- package/dist/tests/pdf/selawik-opt-in.spec.d.ts +1 -0
- package/dist/tests/pdf/selawik-opt-in.spec.js +106 -0
- package/dist/tests/pdf/system-ui-fallback-subset-regression.spec.d.ts +1 -0
- package/dist/tests/pdf/system-ui-fallback-subset-regression.spec.js +39 -0
- package/dist/tests/pdf/text-renderer-fallback.spec.js +55 -0
- package/dist/tests/pdf/text-transform-matrix.spec.js +8 -7
- package/package.json +2 -2
|
@@ -2,141 +2,19 @@
|
|
|
2
2
|
import {} from "../html/css/parse-css.js";
|
|
3
3
|
import {} from "../units/units.js";
|
|
4
4
|
import { ComputedStyle, } from "./style.js";
|
|
5
|
-
import { resolveNumberLike } from "./length.js";
|
|
6
5
|
import { ElementSpecificDefaults, BrowserDefaults } from "./browser-defaults.js";
|
|
7
6
|
import { applyDeclarationsToStyle } from "./apply-declarations.js";
|
|
8
|
-
import { normalizeFontWeight } from './font-weight.js';
|
|
9
|
-
import { FloatMode, Display } from "./enums.js";
|
|
10
7
|
import { log } from "../logging/debug.js";
|
|
11
|
-
import { cloneLineHeight, createNormalLineHeight, lineHeightEquals, resolveLineHeightInput } from "./line-height.js";
|
|
12
|
-
import { parseInlineStyle } from "./inline-style-parser.js";
|
|
13
8
|
import { StyleInheritanceResolver } from "./style-inheritance.js";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
case "none":
|
|
24
|
-
return FloatMode.None;
|
|
25
|
-
default:
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
// parseInlineStyle now imported from inline-style-parser.ts
|
|
30
|
-
function defaultDisplayForTag(tag) {
|
|
31
|
-
let display;
|
|
32
|
-
switch (tag) {
|
|
33
|
-
case "span":
|
|
34
|
-
case "a":
|
|
35
|
-
case "strong":
|
|
36
|
-
case "em":
|
|
37
|
-
case "b":
|
|
38
|
-
case "s":
|
|
39
|
-
case "strike":
|
|
40
|
-
case "del":
|
|
41
|
-
case "label":
|
|
42
|
-
case "code":
|
|
43
|
-
case "small":
|
|
44
|
-
case "time":
|
|
45
|
-
case "i":
|
|
46
|
-
case "u":
|
|
47
|
-
case "sub":
|
|
48
|
-
case "sup":
|
|
49
|
-
case "mark":
|
|
50
|
-
case "abbr":
|
|
51
|
-
case "cite":
|
|
52
|
-
case "dfn":
|
|
53
|
-
case "kbd":
|
|
54
|
-
case "q":
|
|
55
|
-
case "tt":
|
|
56
|
-
display = Display.Inline;
|
|
57
|
-
break;
|
|
58
|
-
case "table":
|
|
59
|
-
display = Display.Table;
|
|
60
|
-
break;
|
|
61
|
-
case "tbody":
|
|
62
|
-
case "thead":
|
|
63
|
-
case "tfoot":
|
|
64
|
-
display = Display.TableRowGroup;
|
|
65
|
-
break;
|
|
66
|
-
case "tr":
|
|
67
|
-
display = Display.TableRow;
|
|
68
|
-
break;
|
|
69
|
-
case "td":
|
|
70
|
-
case "th":
|
|
71
|
-
display = Display.TableCell;
|
|
72
|
-
break;
|
|
73
|
-
case "caption":
|
|
74
|
-
display = Display.TableCaption;
|
|
75
|
-
break;
|
|
76
|
-
case "div":
|
|
77
|
-
case "section":
|
|
78
|
-
case "main":
|
|
79
|
-
case "article":
|
|
80
|
-
case "header":
|
|
81
|
-
case "footer":
|
|
82
|
-
case "nav":
|
|
83
|
-
case "p":
|
|
84
|
-
case "ul":
|
|
85
|
-
case "ol":
|
|
86
|
-
case "li":
|
|
87
|
-
case "h1":
|
|
88
|
-
case "h2":
|
|
89
|
-
case "h3":
|
|
90
|
-
case "h4":
|
|
91
|
-
case "h5":
|
|
92
|
-
case "h6":
|
|
93
|
-
display = Display.Block;
|
|
94
|
-
break;
|
|
95
|
-
default:
|
|
96
|
-
display = Display.Block;
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
log("style", "trace", "defaultDisplayForTag", { tag, display });
|
|
100
|
-
return display;
|
|
101
|
-
}
|
|
102
|
-
const RELATIVE_FONT_SIZE_TAG_SCALE = {
|
|
103
|
-
small: 0.8,
|
|
104
|
-
big: 1.2,
|
|
105
|
-
};
|
|
106
|
-
function resolveDefaultsForComputedStyle(defaults, fontSize, rootFontSize) {
|
|
107
|
-
const { fontSize: defaultFontSize, marginTop, marginRight, marginBottom, marginLeft, paddingTop, paddingRight, paddingBottom, paddingLeft, borderTop, borderRight, borderBottom, borderLeft, ...rest } = defaults;
|
|
108
|
-
const resolved = { ...rest };
|
|
109
|
-
const resolveNumeric = (value) => resolveNumberLike(value, fontSize, rootFontSize);
|
|
110
|
-
if (defaultFontSize !== undefined) {
|
|
111
|
-
resolved.fontSize = resolveNumeric(defaultFontSize) ?? fontSize;
|
|
112
|
-
}
|
|
113
|
-
if (marginTop !== undefined)
|
|
114
|
-
resolved.marginTop = resolveNumeric(marginTop);
|
|
115
|
-
if (marginRight !== undefined)
|
|
116
|
-
resolved.marginRight = resolveNumeric(marginRight);
|
|
117
|
-
if (marginBottom !== undefined)
|
|
118
|
-
resolved.marginBottom = resolveNumeric(marginBottom);
|
|
119
|
-
if (marginLeft !== undefined)
|
|
120
|
-
resolved.marginLeft = resolveNumeric(marginLeft);
|
|
121
|
-
if (paddingTop !== undefined)
|
|
122
|
-
resolved.paddingTop = resolveNumeric(paddingTop);
|
|
123
|
-
if (paddingRight !== undefined)
|
|
124
|
-
resolved.paddingRight = resolveNumeric(paddingRight);
|
|
125
|
-
if (paddingBottom !== undefined)
|
|
126
|
-
resolved.paddingBottom = resolveNumeric(paddingBottom);
|
|
127
|
-
if (paddingLeft !== undefined)
|
|
128
|
-
resolved.paddingLeft = resolveNumeric(paddingLeft);
|
|
129
|
-
if (borderTop !== undefined)
|
|
130
|
-
resolved.borderTop = resolveNumeric(borderTop);
|
|
131
|
-
if (borderRight !== undefined)
|
|
132
|
-
resolved.borderRight = resolveNumeric(borderRight);
|
|
133
|
-
if (borderBottom !== undefined)
|
|
134
|
-
resolved.borderBottom = resolveNumeric(borderBottom);
|
|
135
|
-
if (borderLeft !== undefined)
|
|
136
|
-
resolved.borderLeft = resolveNumeric(borderLeft);
|
|
137
|
-
return resolved;
|
|
138
|
-
}
|
|
139
|
-
// resolveTrackSizeInputToAbsolute and resolveTrackDefinitionsInput now in layout-property-resolver.ts
|
|
9
|
+
import { resolveDeclarationsForElement, resolveDeclarationsForPseudoElement } from "./compute-style/declarations.js";
|
|
10
|
+
import { resolveDisplayForElement } from "./compute-style/display.js";
|
|
11
|
+
import { applyStyleInitOverrides } from "./compute-style/overrides.js";
|
|
12
|
+
import { applyTextDecorationOptions } from "./compute-style/decoration.js";
|
|
13
|
+
import { resolveDefaultsForComputedStyle } from "./compute-style/defaults.js";
|
|
14
|
+
import { computeFontContext } from "./compute-style/font.js";
|
|
15
|
+
import { mapFloatToMode } from "./compute-style/float.js";
|
|
16
|
+
import { createBaseStyleOptions } from "./compute-style/base-options.js";
|
|
17
|
+
import { Display } from "./enums.js";
|
|
140
18
|
export function computeStyleForElement(element, cssRules, parentStyle, units, rootFontSize) {
|
|
141
19
|
const tagName = element.tagName.toLowerCase();
|
|
142
20
|
// Get element-specific defaults from browser defaults system
|
|
@@ -148,350 +26,22 @@ export function computeStyleForElement(element, cssRules, parentStyle, units, ro
|
|
|
148
26
|
// Apply inheritance from parent
|
|
149
27
|
const inherited = StyleInheritanceResolver.resolveInheritedProperties(parentStyle, mergedDefaults);
|
|
150
28
|
const styleInit = {};
|
|
151
|
-
const
|
|
152
|
-
// Apply CSS rules
|
|
153
|
-
for (const rule of cssRules) {
|
|
154
|
-
if (rule.match(element)) {
|
|
155
|
-
log("style", "debug", "CSS rule matched", { selector: rule.selector, declarations: rule.declarations });
|
|
156
|
-
if (rule.declarations.display) {
|
|
157
|
-
log("style", "debug", "Display declaration found", { selector: rule.selector, display: rule.declarations.display });
|
|
158
|
-
}
|
|
159
|
-
// Normalize rule declarations to lowercase keys (except custom properties which are case-sensitive)
|
|
160
|
-
const normalizedRuleDeclarations = {};
|
|
161
|
-
for (const [prop, value] of Object.entries(rule.declarations)) {
|
|
162
|
-
if (prop.startsWith('--')) {
|
|
163
|
-
normalizedRuleDeclarations[prop] = value;
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
normalizedRuleDeclarations[prop.toLowerCase()] = value;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
Object.assign(aggregated, normalizedRuleDeclarations);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
// Apply inline styles (highest priority)
|
|
173
|
-
const inlineStyle = parseInlineStyle(element.getAttribute("style") ?? "");
|
|
174
|
-
if (Object.keys(inlineStyle).length > 0) {
|
|
175
|
-
log("style", "debug", "inline style applied", { declarations: inlineStyle });
|
|
176
|
-
}
|
|
177
|
-
Object.assign(aggregated, inlineStyle);
|
|
178
|
-
// === CSS Custom Properties (CSS Variables) Support ===
|
|
179
|
-
// 1. Inherit custom properties from parent
|
|
180
|
-
let customProperties = parentStyle.customProperties
|
|
181
|
-
? parentStyle.customProperties.clone()
|
|
182
|
-
: new CustomPropertiesMap();
|
|
183
|
-
// 2. Extract and merge custom properties from this element's declarations
|
|
184
|
-
const elementCustomProps = extractCustomProperties(aggregated);
|
|
185
|
-
customProperties = elementCustomProps.inherit(customProperties);
|
|
186
|
-
log("style", "debug", "custom properties", {
|
|
187
|
-
count: customProperties.size,
|
|
188
|
-
keys: customProperties.keys()
|
|
189
|
-
});
|
|
190
|
-
// 3. Resolve var() references in all declarations
|
|
191
|
-
const resolvedDeclarations = resolveDeclarationsWithVariables(aggregated, customProperties);
|
|
29
|
+
const { resolvedDeclarations, customProperties } = resolveDeclarationsForElement(element, cssRules, parentStyle.customProperties);
|
|
192
30
|
// Apply declarations to style accumulator
|
|
193
31
|
applyDeclarationsToStyle(resolvedDeclarations, styleInit, units, inherited.fontWeight ?? mergedDefaults.fontWeight);
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
let display = styleInit.display ?? defaultDisplay;
|
|
197
|
-
log("style", "debug", "computeStyleForElement display", {
|
|
198
|
-
tagName,
|
|
199
|
-
styleInitDisplay: styleInit.display,
|
|
200
|
-
defaultDisplay,
|
|
201
|
-
finalDisplay: display
|
|
202
|
-
});
|
|
203
|
-
// Force correct display for table elements if they're not set correctly
|
|
204
|
-
if (tagName === 'table') {
|
|
205
|
-
if (display !== Display.Table) {
|
|
206
|
-
log("style", "debug", "Forcing table display", { tagName, originalDisplay: display });
|
|
207
|
-
display = Display.Table;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
else if (tagName === 'thead' || tagName === 'tbody' || tagName === 'tfoot') {
|
|
211
|
-
if (display !== Display.TableRowGroup) {
|
|
212
|
-
log("style", "debug", "Forcing table-row-group display", { tagName, originalDisplay: display });
|
|
213
|
-
display = Display.TableRowGroup;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
else if (tagName === 'tr') {
|
|
217
|
-
if (display !== Display.TableRow) {
|
|
218
|
-
log("style", "debug", "Forcing table-row display", { tagName, originalDisplay: display });
|
|
219
|
-
display = Display.TableRow;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
else if (tagName === 'td' || tagName === 'th') {
|
|
223
|
-
if (display !== Display.TableCell) {
|
|
224
|
-
log("style", "debug", "Forcing table-cell display", { tagName, originalDisplay: display });
|
|
225
|
-
display = Display.TableCell;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
const floatValue = mapFloat(styleInit.float);
|
|
32
|
+
const display = resolveDisplayForElement(tagName, styleInit.display, mergedDefaults.display);
|
|
33
|
+
const floatValue = mapFloatToMode(styleInit.float);
|
|
229
34
|
// Build final style options with proper precedence:
|
|
230
35
|
// 1. Base browser defaults
|
|
231
36
|
// 2. Element-specific defaults
|
|
232
37
|
// 3. Inherited values
|
|
233
38
|
// 4. CSS rules
|
|
234
|
-
// 5. Inline styles
|
|
235
|
-
const
|
|
236
|
-
const
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
const rootFontReference = rootFontSize ?? parentStyle.fontSize;
|
|
241
|
-
const baseFontSize = inherited.fontSize;
|
|
242
|
-
let computedFontSize = baseFontSize;
|
|
243
|
-
if (styleInit.fontSize !== undefined) {
|
|
244
|
-
const resolvedFontSize = resolveNumberLike(styleInit.fontSize, inherited.fontSize, rootFontReference);
|
|
245
|
-
if (resolvedFontSize !== undefined) {
|
|
246
|
-
computedFontSize = resolvedFontSize;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
const resolvedFontSize = resolveNumberLike(mergedDefaults.fontSize, inherited.fontSize, rootFontReference);
|
|
251
|
-
if (resolvedFontSize !== undefined) {
|
|
252
|
-
computedFontSize = resolvedFontSize;
|
|
253
|
-
}
|
|
254
|
-
const relativeScale = RELATIVE_FONT_SIZE_TAG_SCALE[tagName];
|
|
255
|
-
if (relativeScale !== undefined) {
|
|
256
|
-
computedFontSize = (inherited.fontSize ?? 16) * relativeScale;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
const resolvedDefaults = resolveDefaultsForComputedStyle(mergedDefaults, computedFontSize, rootFontReference);
|
|
260
|
-
const styleOptions = {
|
|
261
|
-
customProperties,
|
|
262
|
-
// Start with merged defaults
|
|
263
|
-
...resolvedDefaults,
|
|
264
|
-
// Override with inherited values
|
|
265
|
-
color: inherited.color,
|
|
266
|
-
fontSize: computedFontSize,
|
|
267
|
-
lineHeight: cloneLineHeight(elementDefinesLineHeight ? mergedLineHeight : inherited.lineHeight),
|
|
268
|
-
fontFamily: inherited.fontFamily,
|
|
269
|
-
fontStyle: elementDefinesFontStyle ? mergedDefaults.fontStyle : inherited.fontStyle,
|
|
270
|
-
fontWeight: elementDefinesFontWeight ? mergedDefaults.fontWeight : normalizeFontWeight(inherited.fontWeight),
|
|
271
|
-
overflowWrap: inherited.overflowWrap,
|
|
272
|
-
textIndent: inherited.textIndent ?? mergedDefaults.textIndent ?? 0,
|
|
273
|
-
textTransform: inherited.textTransform ?? "none",
|
|
274
|
-
letterSpacing: inherited.letterSpacing ?? mergedDefaults.letterSpacing,
|
|
275
|
-
listStyleType: inherited.listStyleType ?? mergedDefaults.listStyleType ?? "disc",
|
|
276
|
-
// Apply computed values
|
|
277
|
-
display,
|
|
278
|
-
float: floatValue ?? FloatMode.None,
|
|
279
|
-
borderModel: styleInit.borderModel ?? mergedDefaults.borderModel,
|
|
280
|
-
};
|
|
281
|
-
if (styleInit.lineHeight !== undefined) {
|
|
282
|
-
styleOptions.lineHeight = resolveLineHeightInput(styleInit.lineHeight, computedFontSize, rootFontReference);
|
|
283
|
-
}
|
|
284
|
-
// Create unit resolver with computed font sizes
|
|
285
|
-
const unitResolver = new CssUnitResolver(computedFontSize, rootFontReference);
|
|
286
|
-
const assignLength = (value, setter) => {
|
|
287
|
-
unitResolver.createLengthAssigner(setter)(value);
|
|
288
|
-
};
|
|
289
|
-
const assignNumberLength = (value, setter) => {
|
|
290
|
-
unitResolver.createNumberAssigner(setter)(value);
|
|
291
|
-
};
|
|
292
|
-
if (styleInit.position !== undefined)
|
|
293
|
-
styleOptions.position = styleInit.position;
|
|
294
|
-
if (styleInit.top !== undefined)
|
|
295
|
-
assignLength(styleInit.top, (v) => (styleOptions.top = v));
|
|
296
|
-
if (styleInit.right !== undefined)
|
|
297
|
-
assignLength(styleInit.right, (v) => (styleOptions.right = v));
|
|
298
|
-
if (styleInit.bottom !== undefined)
|
|
299
|
-
assignLength(styleInit.bottom, (v) => (styleOptions.bottom = v));
|
|
300
|
-
if (styleInit.left !== undefined)
|
|
301
|
-
assignLength(styleInit.left, (v) => (styleOptions.left = v));
|
|
302
|
-
if (styleInit.zIndex !== undefined)
|
|
303
|
-
styleOptions.zIndex = styleInit.zIndex;
|
|
304
|
-
if (styleInit.color !== undefined)
|
|
305
|
-
styleOptions.color = styleInit.color;
|
|
306
|
-
if (styleInit.backgroundLayers !== undefined)
|
|
307
|
-
styleOptions.backgroundLayers = styleInit.backgroundLayers;
|
|
308
|
-
if (styleInit.clipPath !== undefined)
|
|
309
|
-
styleOptions.clipPath = styleInit.clipPath;
|
|
310
|
-
if (styleInit.borderColor !== undefined)
|
|
311
|
-
styleOptions.borderColor = styleInit.borderColor;
|
|
312
|
-
if (styleInit.borderStyleTop !== undefined)
|
|
313
|
-
styleOptions.borderStyleTop = styleInit.borderStyleTop;
|
|
314
|
-
if (styleInit.borderStyleRight !== undefined)
|
|
315
|
-
styleOptions.borderStyleRight = styleInit.borderStyleRight;
|
|
316
|
-
if (styleInit.borderStyleBottom !== undefined)
|
|
317
|
-
styleOptions.borderStyleBottom = styleInit.borderStyleBottom;
|
|
318
|
-
if (styleInit.borderStyleLeft !== undefined)
|
|
319
|
-
styleOptions.borderStyleLeft = styleInit.borderStyleLeft;
|
|
320
|
-
if (styleInit.boxShadows !== undefined) {
|
|
321
|
-
styleOptions.boxShadows = styleInit.boxShadows.map((shadow) => ({
|
|
322
|
-
inset: shadow.inset,
|
|
323
|
-
offsetX: unitResolver.resolveShadowLength(shadow.offsetX),
|
|
324
|
-
offsetY: unitResolver.resolveShadowLength(shadow.offsetY),
|
|
325
|
-
blurRadius: unitResolver.resolveShadowLength(shadow.blurRadius, true),
|
|
326
|
-
spreadRadius: unitResolver.resolveShadowLength(shadow.spreadRadius),
|
|
327
|
-
color: shadow.color,
|
|
328
|
-
}));
|
|
329
|
-
}
|
|
330
|
-
if (styleInit.textShadows !== undefined) {
|
|
331
|
-
styleOptions.textShadows = styleInit.textShadows.map((shadow) => ({
|
|
332
|
-
offsetX: unitResolver.resolveShadowLength(shadow.offsetX),
|
|
333
|
-
offsetY: unitResolver.resolveShadowLength(shadow.offsetY),
|
|
334
|
-
blurRadius: unitResolver.resolveShadowLength(shadow.blurRadius, true),
|
|
335
|
-
color: shadow.color,
|
|
336
|
-
}));
|
|
337
|
-
}
|
|
338
|
-
if (styleInit.fontFamily !== undefined)
|
|
339
|
-
styleOptions.fontFamily = styleInit.fontFamily;
|
|
340
|
-
if (styleInit.fontStyle !== undefined)
|
|
341
|
-
styleOptions.fontStyle = styleInit.fontStyle;
|
|
342
|
-
if (styleInit.fontVariant !== undefined)
|
|
343
|
-
styleOptions.fontVariant = styleInit.fontVariant;
|
|
344
|
-
if (styleInit.fontWeight !== undefined)
|
|
345
|
-
styleOptions.fontWeight = normalizeFontWeight(styleInit.fontWeight);
|
|
346
|
-
if (styleInit.overflowWrap !== undefined)
|
|
347
|
-
styleOptions.overflowWrap = styleInit.overflowWrap;
|
|
348
|
-
if (styleInit.marginTop !== undefined)
|
|
349
|
-
assignLength(styleInit.marginTop, (v) => (styleOptions.marginTop = v));
|
|
350
|
-
else
|
|
351
|
-
styleOptions.marginTop = resolveNumberLike(mergedDefaults.marginTop, computedFontSize, rootFontReference);
|
|
352
|
-
if (styleInit.marginRight !== undefined)
|
|
353
|
-
assignLength(styleInit.marginRight, (v) => (styleOptions.marginRight = v));
|
|
354
|
-
else
|
|
355
|
-
styleOptions.marginRight = resolveNumberLike(mergedDefaults.marginRight, computedFontSize, rootFontReference);
|
|
356
|
-
if (styleInit.marginBottom !== undefined)
|
|
357
|
-
assignLength(styleInit.marginBottom, (v) => (styleOptions.marginBottom = v));
|
|
358
|
-
else
|
|
359
|
-
styleOptions.marginBottom = resolveNumberLike(mergedDefaults.marginBottom, computedFontSize, rootFontReference);
|
|
360
|
-
if (styleInit.marginLeft !== undefined)
|
|
361
|
-
assignLength(styleInit.marginLeft, (v) => (styleOptions.marginLeft = v));
|
|
362
|
-
else
|
|
363
|
-
styleOptions.marginLeft = resolveNumberLike(mergedDefaults.marginLeft, computedFontSize, rootFontReference);
|
|
364
|
-
if (styleInit.paddingTop !== undefined)
|
|
365
|
-
assignLength(styleInit.paddingTop, (v) => (styleOptions.paddingTop = v));
|
|
366
|
-
if (styleInit.paddingRight !== undefined)
|
|
367
|
-
assignLength(styleInit.paddingRight, (v) => (styleOptions.paddingRight = v));
|
|
368
|
-
if (styleInit.paddingBottom !== undefined)
|
|
369
|
-
assignLength(styleInit.paddingBottom, (v) => (styleOptions.paddingBottom = v));
|
|
370
|
-
if (styleInit.paddingLeft !== undefined)
|
|
371
|
-
assignLength(styleInit.paddingLeft, (v) => (styleOptions.paddingLeft = v));
|
|
372
|
-
if (styleInit.borderTop !== undefined)
|
|
373
|
-
assignLength(styleInit.borderTop, (v) => (styleOptions.borderTop = v));
|
|
374
|
-
if (styleInit.borderRight !== undefined)
|
|
375
|
-
assignLength(styleInit.borderRight, (v) => (styleOptions.borderRight = v));
|
|
376
|
-
if (styleInit.borderBottom !== undefined)
|
|
377
|
-
assignLength(styleInit.borderBottom, (v) => (styleOptions.borderBottom = v));
|
|
378
|
-
if (styleInit.borderLeft !== undefined)
|
|
379
|
-
assignLength(styleInit.borderLeft, (v) => (styleOptions.borderLeft = v));
|
|
380
|
-
if (styleInit.borderTopLeftRadiusX !== undefined)
|
|
381
|
-
assignNumberLength(styleInit.borderTopLeftRadiusX, (v) => (styleOptions.borderTopLeftRadiusX = v));
|
|
382
|
-
if (styleInit.borderTopLeftRadiusY !== undefined)
|
|
383
|
-
assignNumberLength(styleInit.borderTopLeftRadiusY, (v) => (styleOptions.borderTopLeftRadiusY = v));
|
|
384
|
-
if (styleInit.borderTopRightRadiusX !== undefined)
|
|
385
|
-
assignNumberLength(styleInit.borderTopRightRadiusX, (v) => (styleOptions.borderTopRightRadiusX = v));
|
|
386
|
-
if (styleInit.borderTopRightRadiusY !== undefined)
|
|
387
|
-
assignNumberLength(styleInit.borderTopRightRadiusY, (v) => (styleOptions.borderTopRightRadiusY = v));
|
|
388
|
-
if (styleInit.borderBottomRightRadiusX !== undefined)
|
|
389
|
-
assignNumberLength(styleInit.borderBottomRightRadiusX, (v) => (styleOptions.borderBottomRightRadiusX = v));
|
|
390
|
-
if (styleInit.borderBottomRightRadiusY !== undefined)
|
|
391
|
-
assignNumberLength(styleInit.borderBottomRightRadiusY, (v) => (styleOptions.borderBottomRightRadiusY = v));
|
|
392
|
-
if (styleInit.borderBottomLeftRadiusX !== undefined)
|
|
393
|
-
assignNumberLength(styleInit.borderBottomLeftRadiusX, (v) => (styleOptions.borderBottomLeftRadiusX = v));
|
|
394
|
-
if (styleInit.borderBottomLeftRadiusY !== undefined)
|
|
395
|
-
assignNumberLength(styleInit.borderBottomLeftRadiusY, (v) => (styleOptions.borderBottomLeftRadiusY = v));
|
|
396
|
-
if (styleInit.width !== undefined)
|
|
397
|
-
assignLength(styleInit.width, (v) => (styleOptions.width = v));
|
|
398
|
-
if (styleInit.minWidth !== undefined)
|
|
399
|
-
assignLength(styleInit.minWidth, (v) => (styleOptions.minWidth = v));
|
|
400
|
-
if (styleInit.maxWidth !== undefined)
|
|
401
|
-
assignLength(styleInit.maxWidth, (v) => (styleOptions.maxWidth = v));
|
|
402
|
-
if (styleInit.height !== undefined)
|
|
403
|
-
assignLength(styleInit.height, (v) => (styleOptions.height = v));
|
|
404
|
-
if (styleInit.minHeight !== undefined)
|
|
405
|
-
assignLength(styleInit.minHeight, (v) => (styleOptions.minHeight = v));
|
|
406
|
-
if (styleInit.maxHeight !== undefined)
|
|
407
|
-
assignLength(styleInit.maxHeight, (v) => (styleOptions.maxHeight = v));
|
|
408
|
-
if (styleInit.trackListColumns !== undefined) {
|
|
409
|
-
const resolved = LayoutPropertyResolver.resolveTrackDefinitionsInput(styleInit.trackListColumns, computedFontSize, rootFontReference);
|
|
410
|
-
if (resolved) {
|
|
411
|
-
styleOptions.trackListColumns = resolved;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
if (styleInit.trackListRows !== undefined) {
|
|
415
|
-
const resolved = LayoutPropertyResolver.resolveTrackDefinitionsInput(styleInit.trackListRows, computedFontSize, rootFontReference);
|
|
416
|
-
if (resolved) {
|
|
417
|
-
styleOptions.trackListRows = resolved;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
if (styleInit.autoFlow !== undefined) {
|
|
421
|
-
styleOptions.autoFlow = styleInit.autoFlow;
|
|
422
|
-
}
|
|
423
|
-
if (styleInit.rowGap !== undefined) {
|
|
424
|
-
assignNumberLength(styleInit.rowGap, (v) => (styleOptions.rowGap = v));
|
|
425
|
-
}
|
|
426
|
-
if (styleInit.columnGap !== undefined) {
|
|
427
|
-
assignNumberLength(styleInit.columnGap, (v) => (styleOptions.columnGap = v));
|
|
428
|
-
}
|
|
429
|
-
if (styleInit.justifyContent !== undefined)
|
|
430
|
-
styleOptions.justifyContent = styleInit.justifyContent;
|
|
431
|
-
if (styleInit.alignItems !== undefined)
|
|
432
|
-
styleOptions.alignItems = styleInit.alignItems;
|
|
433
|
-
if (styleInit.alignContent !== undefined)
|
|
434
|
-
styleOptions.alignContent = styleInit.alignContent;
|
|
435
|
-
if (styleInit.alignSelf !== undefined)
|
|
436
|
-
styleOptions.alignSelf = styleInit.alignSelf;
|
|
437
|
-
if (styleInit.flexDirection !== undefined)
|
|
438
|
-
styleOptions.flexDirection = styleInit.flexDirection;
|
|
439
|
-
if (styleInit.flexWrap !== undefined)
|
|
440
|
-
styleOptions.flexWrap = styleInit.flexWrap;
|
|
441
|
-
if (styleInit.textAlign !== undefined)
|
|
442
|
-
styleOptions.textAlign = styleInit.textAlign;
|
|
443
|
-
if (styleInit.textIndent !== undefined)
|
|
444
|
-
assignLength(styleInit.textIndent, (v) => (styleOptions.textIndent = v));
|
|
445
|
-
if (styleInit.textTransform !== undefined)
|
|
446
|
-
styleOptions.textTransform = styleInit.textTransform;
|
|
447
|
-
if (styleInit.letterSpacing !== undefined)
|
|
448
|
-
assignNumberLength(styleInit.letterSpacing, (v) => (styleOptions.letterSpacing = v));
|
|
449
|
-
if (styleInit.listStyleType !== undefined)
|
|
450
|
-
styleOptions.listStyleType = styleInit.listStyleType;
|
|
451
|
-
// If a raw transform string was parsed, preserve it on the computed style so downstream
|
|
452
|
-
// consumers (e.g. text run builders / renderers) can apply mapping for text.
|
|
453
|
-
if (styleInit.transform !== undefined) {
|
|
454
|
-
styleOptions.transform = styleInit.transform;
|
|
455
|
-
}
|
|
456
|
-
if (styleInit.objectFit !== undefined) {
|
|
457
|
-
styleOptions.objectFit = styleInit.objectFit;
|
|
458
|
-
}
|
|
459
|
-
if (styleInit.opacity !== undefined) {
|
|
460
|
-
styleOptions.opacity = styleInit.opacity;
|
|
461
|
-
}
|
|
462
|
-
const defaultDecoration = mergedDefaults.textDecorationLine ?? "none";
|
|
463
|
-
let decoration = inherited.textDecorationLine ?? defaultDecoration;
|
|
464
|
-
if (elementDefaults.textDecorationLine !== undefined) {
|
|
465
|
-
decoration = elementDefaults.textDecorationLine;
|
|
466
|
-
}
|
|
467
|
-
if (styleInit.textDecorationLine !== undefined) {
|
|
468
|
-
decoration = styleInit.textDecorationLine;
|
|
469
|
-
}
|
|
470
|
-
styleOptions.textDecorationLine = decoration;
|
|
471
|
-
let decorationColor = styleInit.textDecorationColor !== undefined
|
|
472
|
-
? normalizeTextDecorationColor(styleInit.textDecorationColor)
|
|
473
|
-
: undefined;
|
|
474
|
-
if (decorationColor === undefined) {
|
|
475
|
-
decorationColor =
|
|
476
|
-
elementDefaults.textDecorationColor !== undefined
|
|
477
|
-
? normalizeTextDecorationColor(elementDefaults.textDecorationColor)
|
|
478
|
-
: undefined;
|
|
479
|
-
}
|
|
480
|
-
if (decorationColor === undefined && inherited.textDecorationColor !== undefined) {
|
|
481
|
-
decorationColor = inherited.textDecorationColor;
|
|
482
|
-
}
|
|
483
|
-
if (decorationColor !== undefined) {
|
|
484
|
-
styleOptions.textDecorationColor = decorationColor;
|
|
485
|
-
}
|
|
486
|
-
const defaultDecorationStyle = mergedDefaults.textDecorationStyle ?? "solid";
|
|
487
|
-
let decorationStyle = inherited.textDecorationStyle ?? defaultDecorationStyle;
|
|
488
|
-
if (elementDefaults.textDecorationStyle !== undefined) {
|
|
489
|
-
decorationStyle = elementDefaults.textDecorationStyle;
|
|
490
|
-
}
|
|
491
|
-
if (styleInit.textDecorationStyle !== undefined) {
|
|
492
|
-
decorationStyle = styleInit.textDecorationStyle;
|
|
493
|
-
}
|
|
494
|
-
styleOptions.textDecorationStyle = decorationStyle;
|
|
39
|
+
// 5. Inline styles
|
|
40
|
+
const fontContext = computeFontContext(tagName, styleInit, inherited, elementDefaults, baseDefaults, mergedDefaults, parentStyle.fontSize, rootFontSize);
|
|
41
|
+
const resolvedDefaults = resolveDefaultsForComputedStyle(mergedDefaults, fontContext.computedFontSize, fontContext.rootFontReference);
|
|
42
|
+
const styleOptions = createBaseStyleOptions(resolvedDefaults, inherited, fontContext, mergedDefaults, styleInit, display, floatValue, customProperties);
|
|
43
|
+
applyStyleInitOverrides(styleInit, styleOptions, mergedDefaults, fontContext.computedFontSize, fontContext.rootFontReference);
|
|
44
|
+
applyTextDecorationOptions(styleOptions, styleInit, inherited, mergedDefaults, elementDefaults);
|
|
495
45
|
// Debug fontStyle for em and strong elements
|
|
496
46
|
if (tagName === 'em' || tagName === 'strong') {
|
|
497
47
|
const debugInfo = {
|
|
@@ -504,23 +54,20 @@ export function computeStyleForElement(element, cssRules, parentStyle, units, ro
|
|
|
504
54
|
}
|
|
505
55
|
return new ComputedStyle(styleOptions);
|
|
506
56
|
}
|
|
507
|
-
function
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
}
|
|
511
|
-
const
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
const
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
return undefined;
|
|
524
|
-
}
|
|
525
|
-
return lower === "currentcolor" ? "currentcolor" : trimmed;
|
|
57
|
+
export function computeStyleForPseudoElement(element, cssRules, pseudoType, parentStyle, units, rootFontSize) {
|
|
58
|
+
const tagName = "span";
|
|
59
|
+
const baseDefaults = BrowserDefaults.createBaseDefaults();
|
|
60
|
+
const pseudoMergedDefaults = { ...baseDefaults, display: Display.Inline };
|
|
61
|
+
const inherited = StyleInheritanceResolver.resolveInheritedProperties(parentStyle, pseudoMergedDefaults);
|
|
62
|
+
const styleInit = {};
|
|
63
|
+
const { resolvedDeclarations, customProperties } = resolveDeclarationsForPseudoElement(element, cssRules, pseudoType, parentStyle.customProperties);
|
|
64
|
+
applyDeclarationsToStyle(resolvedDeclarations, styleInit, units, inherited.fontWeight ?? pseudoMergedDefaults.fontWeight);
|
|
65
|
+
const display = resolveDisplayForElement(tagName, styleInit.display, pseudoMergedDefaults.display);
|
|
66
|
+
const floatValue = mapFloatToMode(styleInit.float);
|
|
67
|
+
const fontContext = computeFontContext(tagName, styleInit, inherited, {}, baseDefaults, pseudoMergedDefaults, parentStyle.fontSize, rootFontSize);
|
|
68
|
+
const resolvedDefaults = resolveDefaultsForComputedStyle(pseudoMergedDefaults, fontContext.computedFontSize, fontContext.rootFontReference);
|
|
69
|
+
const styleOptions = createBaseStyleOptions(resolvedDefaults, inherited, fontContext, pseudoMergedDefaults, styleInit, display, floatValue, customProperties);
|
|
70
|
+
applyStyleInitOverrides(styleInit, styleOptions, pseudoMergedDefaults, fontContext.computedFontSize, fontContext.rootFontReference);
|
|
71
|
+
applyTextDecorationOptions(styleOptions, styleInit, inherited, pseudoMergedDefaults, {});
|
|
72
|
+
return new ComputedStyle(styleOptions);
|
|
526
73
|
}
|
package/dist/src/css/enums.d.ts
CHANGED
|
@@ -109,4 +109,8 @@ export declare enum BorderModel {
|
|
|
109
109
|
Collapse = "collapse"
|
|
110
110
|
}
|
|
111
111
|
export type FlexDirection = "row" | "row-reverse" | "column" | "column-reverse";
|
|
112
|
+
export declare enum BoxSizing {
|
|
113
|
+
ContentBox = "content-box",
|
|
114
|
+
BorderBox = "border-box"
|
|
115
|
+
}
|
|
112
116
|
export type AlignSelfValue = "auto" | AlignItems;
|
package/dist/src/css/enums.js
CHANGED
|
@@ -122,3 +122,8 @@ export var BorderModel;
|
|
|
122
122
|
BorderModel["Separate"] = "separate";
|
|
123
123
|
BorderModel["Collapse"] = "collapse";
|
|
124
124
|
})(BorderModel || (BorderModel = {}));
|
|
125
|
+
export var BoxSizing;
|
|
126
|
+
(function (BoxSizing) {
|
|
127
|
+
BoxSizing["ContentBox"] = "content-box";
|
|
128
|
+
BoxSizing["BorderBox"] = "border-box";
|
|
129
|
+
})(BoxSizing || (BoxSizing = {}));
|
|
@@ -8,25 +8,37 @@ export class LayoutPropertyResolver {
|
|
|
8
8
|
* Resolve a track size input to absolute values
|
|
9
9
|
*/
|
|
10
10
|
static resolveTrackSizeInputToAbsolute(track, fontSize, rootFontSize) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
switch (track.kind) {
|
|
12
|
+
case "fixed":
|
|
13
|
+
return {
|
|
14
|
+
kind: "fixed",
|
|
15
|
+
size: resolveNumberLike(track.size, fontSize, rootFontSize) ?? 0,
|
|
16
|
+
};
|
|
17
|
+
case "flex":
|
|
18
|
+
return {
|
|
19
|
+
kind: "flex",
|
|
20
|
+
flex: track.flex,
|
|
21
|
+
min: resolveNumberLike(track.min, fontSize, rootFontSize),
|
|
22
|
+
max: resolveNumberLike(track.max, fontSize, rootFontSize),
|
|
23
|
+
};
|
|
24
|
+
case "auto":
|
|
25
|
+
return {
|
|
26
|
+
kind: "auto",
|
|
27
|
+
min: resolveNumberLike(track.min, fontSize, rootFontSize),
|
|
28
|
+
max: resolveNumberLike(track.max, fontSize, rootFontSize),
|
|
29
|
+
};
|
|
30
|
+
case "clamp":
|
|
31
|
+
return {
|
|
32
|
+
kind: "clamp",
|
|
33
|
+
min: resolveNumberLike(track.min, fontSize, rootFontSize) ?? 0,
|
|
34
|
+
preferred: resolveNumberLike(track.preferred, fontSize, rootFontSize) ?? 0,
|
|
35
|
+
max: resolveNumberLike(track.max, fontSize, rootFontSize) ?? 0,
|
|
36
|
+
};
|
|
37
|
+
default:
|
|
38
|
+
return {
|
|
39
|
+
kind: "auto",
|
|
40
|
+
};
|
|
24
41
|
}
|
|
25
|
-
return {
|
|
26
|
-
kind: "auto",
|
|
27
|
-
min: resolveNumberLike(track.min, fontSize, rootFontSize),
|
|
28
|
-
max: resolveNumberLike(track.max, fontSize, rootFontSize),
|
|
29
|
-
};
|
|
30
42
|
}
|
|
31
43
|
/**
|
|
32
44
|
* Resolve track definitions (for CSS Grid)
|