UNPKG

3.83 kBTypeScriptView Raw
1import type { DisplayObject } from '../display-objects';
2import type { BaseStyleProps } from '../types';
3import { CSSStyleValue } from './cssom';
4import { StyleValueRegistry } from './interfaces';
5export declare type CSSGlobalKeywords = 'unset' | 'initial' | 'inherit' | '';
6export interface PropertyParseOptions {
7 skipUpdateAttribute: boolean;
8 skipParse: boolean;
9}
10export declare const PropertySyntax: {
11 COLOR: string;
12 PAINT: string;
13 NUMBER: string;
14 LENGTH: string;
15 PERCENTAGE: string;
16 LENGTH_PERCENTAGE: string;
17 LIST_OF_POINTS: string;
18};
19export interface PropertyMetadata {
20 name: string;
21 /**
22 * The interpolable flag indicates whether a property can be animated smoothly.
23 * Default to `false`.
24 */
25 interpolable?: boolean;
26 /**
27 * The property will inherit by default if no value is specified.
28 * Default to `false`.
29 */
30 inherited?: boolean;
31 /**
32 * This property affects only one field on ComputedStyle, and can be set
33 * directly during inheritance instead of forcing a recalc.
34 */
35 independent?: boolean;
36 /**
37 * This specifies the default value for this field.
38 * - for keyword fields, this is the initial keyword
39 * - for other fields, this is a string containg the C++ expression that is used to initialise the field.
40 */
41 defaultValue?: string;
42 /**
43 * The resolved value used for getComputedStyle() depends on layout for this
44 * property, which means we may need to update layout to return the correct
45 * value from getComputedStyle().
46 */
47 layoutDependent?: boolean;
48 /**
49 * This specifies all valid keyword values for the property.
50 */
51 keywords?: string[];
52 /**
53 * eg. strokeWidth is an alias of lineWidth
54 */
55 alias?: string[];
56 /**
57 * sort before init attributes according to this priority
58 */
59 parsePriority?: number;
60 /**
61 * eg. <color> <paint> <number>
62 */
63 syntax?: string;
64 handler?: any;
65}
66/**
67 * Blink used them in code generation(css_properties.json5)
68 */
69export declare const BUILT_IN_PROPERTIES: PropertyMetadata[];
70export declare class DefaultStyleValueRegistry implements StyleValueRegistry {
71 /**
72 * need recalc later
73 */
74 dirty: boolean;
75 private cache;
76 private unresolvedProperties;
77 /**
78 * eg.
79 *
80 * document: {
81 * fontSize: [
82 *
83 * ]
84 * }
85 */
86 private cascadeProperties;
87 init(): void;
88 registerMetadata(metadata: PropertyMetadata): void;
89 getMetadata(name: string): PropertyMetadata;
90 /**
91 * * parse value, eg.
92 * fill: 'red' => CSSRGB
93 * translateX: '10px' => CSSUnitValue { unit: 'px', value: 10 }
94 * fontSize: '2em' => { unit: 'px', value: 32 }
95 *
96 * * calculate used value
97 * * post process
98 */
99 processProperties(object: DisplayObject, attributes: BaseStyleProps, options?: Partial<PropertyParseOptions>): void;
100 /**
101 * string -> parsed value
102 */
103 parseProperty(name: string, value: any, object: DisplayObject): CSSStyleValue;
104 /**
105 * computed value -> used value
106 */
107 computeProperty(name: string, computed: CSSStyleValue, object: DisplayObject): boolean;
108 postProcessProperty(name: string, object: DisplayObject): void;
109 isPropertyResolved(object: DisplayObject, name: string): boolean;
110 /**
111 * resolve later
112 */
113 addUnresolveProperty(object: DisplayObject, name: string): void;
114 tryToResolveProperty(object: DisplayObject, name: string, options?: {
115 inherited?: boolean;
116 }): any;
117 recalc(object: DisplayObject): void;
118 /**
119 * update geometry when relative props changed,
120 * eg. r of Circle, width/height of Rect
121 */
122 updateGeometry(object: DisplayObject): void;
123 private isPropertyInheritable;
124}