@vivliostyle/core 2.16.0 → 2.17.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.
@@ -94,14 +94,10 @@ export declare class PriorityQueue {
94
94
  */
95
95
  remove(): Comparable;
96
96
  }
97
- /**
98
- * @param prefix Prefix (containing leading and trailing hyphens)
99
- * @param cssPropName CSS property name
100
- * @return JavaScript property name
101
- */
102
- export declare function cssToJSProp(prefix: string, cssPropName: string): string;
103
97
  export declare const knownPrefixes: string[];
104
- export declare const propNameMap: {};
98
+ export declare const propNameMap: {
99
+ [key: string]: string[];
100
+ };
105
101
  export declare function checkIfPropertySupported(prefix: string, prop: string): boolean;
106
102
  export declare function getPrefixedPropertyNames(prop: string): string[] | null;
107
103
  export declare function setCSSProperty(elem: Element, prop: string, value: string): void;
@@ -5,9 +5,13 @@ import * as CssValidator from "./css-validator";
5
5
  import * as Exprs from "./exprs";
6
6
  import * as Matchers from "./matchers";
7
7
  import * as Vtree from "./vtree";
8
- import { CssCascade } from "./types";
9
- export interface ElementStyle extends CssCascade.ElementStyle {
10
- }
8
+ import { CssStyler } from "./types";
9
+ export declare type ElementStyle = {
10
+ [key: string]: CascadeValue | CascadeValue[] | ElementStyleMap | {
11
+ matcher: Matchers.Matcher;
12
+ styles: ElementStyle;
13
+ }[];
14
+ };
11
15
  export declare const inheritedProps: {
12
16
  "border-collapse": boolean;
13
17
  "border-spacing": boolean;
@@ -130,7 +134,7 @@ export declare class CascadeValue {
130
134
  getBaseValue(): CascadeValue;
131
135
  filterValue(visitor: Css.Visitor): CascadeValue;
132
136
  increaseSpecificity(specificity: number): CascadeValue;
133
- evaluate(context: Exprs.Context, propName: string): Css.Val;
137
+ evaluate(context: Exprs.Context, propName?: string): Css.Val;
134
138
  isEnabled(context: Exprs.Context): boolean;
135
139
  }
136
140
  /**
@@ -174,12 +178,12 @@ export declare function getProp(style: ElementStyle, name: string): CascadeValue
174
178
  /**
175
179
  * @return void
176
180
  */
177
- export declare function setProp(style: ElementStyle, name: string, value: CascadeValue): any;
181
+ export declare function setProp(style: ElementStyle, name: string, value: CascadeValue): void;
178
182
  export declare function getStyleMap(style: ElementStyle, name: string): ElementStyleMap;
179
183
  export declare function getMutableStyleMap(style: ElementStyle, name: string): ElementStyleMap;
180
184
  export declare const getViewConditionalStyleMap: (style: ElementStyle) => {
181
185
  matcher: Matchers.Matcher;
182
- styles: ElementStyleMap;
186
+ styles: ElementStyle;
183
187
  }[];
184
188
  export declare function getSpecial(style: ElementStyle, name: string): CascadeValue[];
185
189
  export declare function getMutableSpecial(style: ElementStyle, name: string): CascadeValue[];
@@ -715,7 +719,7 @@ export interface CounterListener {
715
719
  getExprContentListener(): Vtree.ExprContentListener;
716
720
  }
717
721
  export interface CounterResolver {
718
- setStyler(styler: any): void;
722
+ setStyler(styler: CssStyler.AbstractStyler): void;
719
723
  /**
720
724
  * Returns an Exprs.Val, whose value is calculated at the layout time by
721
725
  * retrieving the innermost page-based counter (null if it does not exist) by
@@ -920,15 +924,23 @@ export declare class CascadeInstance {
920
924
  */
921
925
  setNamedStrings(props: ElementStyle): void;
922
926
  processPseudoelementProps(pseudoprops: ElementStyle, element: Element): void;
923
- pushElement(element: Element, baseStyle: ElementStyle, elementOffset: number): void;
927
+ pushElement(styler: CssStyler.AbstractStyler, element: Element, baseStyle: ElementStyle, elementOffset: number): void;
924
928
  private applyAttrFilterInner;
925
929
  private applyAttrFilter;
930
+ /**
931
+ * Substitute all variables in property values in elementStyle
932
+ */
933
+ applyVarFilter(elementStyles: ElementStyle[], styler: CssStyler.AbstractStyler, element: Element | null): void;
934
+ /**
935
+ * Calculate all calc() in property values in elementStyle
936
+ */
937
+ applyCalcFilter(elementStyle: ElementStyle, styler: CssStyler.AbstractStyler): void;
926
938
  private applyActions;
927
939
  private pop;
928
940
  popRule(): void;
929
941
  popElement(element: Element): void;
930
942
  }
931
- export declare const EMPTY: any[];
943
+ export declare const EMPTY: string[];
932
944
  /**
933
945
  * Pseudoelement names in the order they should be processed, empty string is
934
946
  * the place where the element's DOM children are processed.
@@ -1170,3 +1182,24 @@ export declare const convertToPhysical: <T>(src: {
1170
1182
  }, dest: {
1171
1183
  [key: string]: T;
1172
1184
  }, vertical: boolean, rtl: boolean, transform: (p1: string, p2: CascadeValue) => T) => void;
1185
+ /**
1186
+ * Convert var() to its value
1187
+ */
1188
+ export declare class VarFilterVisitor extends Css.FilterVisitor {
1189
+ elementStyles: ElementStyle[];
1190
+ styler: CssStyler.AbstractStyler;
1191
+ element: Element | null;
1192
+ constructor(elementStyles: ElementStyle[], styler: CssStyler.AbstractStyler, element: Element | null);
1193
+ private getVarValue;
1194
+ /** @override */
1195
+ visitFunc(func: Css.Func): Css.Val;
1196
+ }
1197
+ /**
1198
+ * Convert calc() to its value
1199
+ */
1200
+ export declare class CalcFilterVisitor extends Css.FilterVisitor {
1201
+ styler: CssStyler.AbstractStyler;
1202
+ constructor(styler: CssStyler.AbstractStyler);
1203
+ /** @override */
1204
+ visitFunc(func: Css.Func): Css.Val;
1205
+ }
@@ -479,4 +479,4 @@ export declare function evaluateExprToCSS(context: Exprs.Context, val: Exprs.Val
479
479
  /**
480
480
  * @return val
481
481
  */
482
- export declare function evaluateCSSToCSS(context: Exprs.Context, val: Css.Val, propName: string): Css.Val;
482
+ export declare function evaluateCSSToCSS(context: Exprs.Context, val: Css.Val, propName?: string): Css.Val;
@@ -212,6 +212,6 @@ export declare class Styler implements AbstractStyler {
212
212
  */
213
213
  processContent(element: Element, styles: {
214
214
  [key: string]: Css.Val;
215
- }): void;
215
+ }, viewNode: Node): void;
216
216
  }
217
217
  export declare const columnProps: string[];
@@ -74,8 +74,11 @@ export declare enum TokenType {
74
74
  LT_EQ = 48,
75
75
  EQ_EQ = 49,
76
76
  COL_COL = 50,
77
- INVALID = 51,
78
- LAST = 51
77
+ CDO = 51,
78
+ CDC = 52,
79
+ UNKNOWN = 53,
80
+ INVALID = 54,
81
+ LAST = 54
79
82
  }
80
83
  export declare class Token {
81
84
  type: TokenType;
@@ -84,6 +87,7 @@ export declare class Token {
84
87
  text: string;
85
88
  position: number;
86
89
  constructor();
90
+ toString(): string;
87
91
  }
88
92
  /**
89
93
  * @enum {number}
@@ -167,7 +171,9 @@ export declare enum Action {
167
171
  COL_COL = 77,
168
172
  TOCLASS = 78,
169
173
  CHKSP = 79,
170
- EOF = 80
174
+ EOF = 80,
175
+ CDO = 81,
176
+ CDC = 82
171
177
  }
172
178
  export declare function makeActions(def: Action, spec: Action[]): Action[];
173
179
  /**
@@ -499,3 +499,4 @@ export declare class ValidatorSet {
499
499
  validatePropertyAndHandleShorthand(name: string, value: Css.Val, important: boolean, receiver: PropertyReceiver): void;
500
500
  }
501
501
  export declare function baseValidatorSet(): ValidatorSet;
502
+ export declare function containsVar(val: Css.Val): boolean;
@@ -21,10 +21,7 @@
21
21
  import * as Base from "./base";
22
22
  import * as Exprs from "./exprs";
23
23
  export declare class Visitor {
24
- /**
25
- * @return void
26
- */
27
- visitValues(values: Val[]): any;
24
+ visitValues(values: Val[]): Val[];
28
25
  visitEmpty(empty: Val): Val;
29
26
  visitSlash(slash: Val): Val;
30
27
  visitStr(str: Str): Val;
@@ -41,8 +38,16 @@ export declare class Visitor {
41
38
  visitExpr(expr: Expr): Val;
42
39
  }
43
40
  export declare class FilterVisitor extends Visitor {
41
+ error: boolean;
44
42
  constructor();
43
+ /**
44
+ * @override
45
+ */
45
46
  visitValues(values: Val[]): Val[];
47
+ /**
48
+ * @override
49
+ */
50
+ visitEmpty(empty: Val): Val;
46
51
  /**
47
52
  * @override
48
53
  */
@@ -109,7 +114,7 @@ export declare class Val {
109
114
  isNum(): boolean;
110
115
  isIdent(): boolean;
111
116
  isSpaceList(): boolean;
112
- visit(visitor: any): any;
117
+ visit(visitor: Visitor): Val;
113
118
  }
114
119
  export declare class Empty extends Val {
115
120
  private static empty;
@@ -126,7 +131,7 @@ export declare class Empty extends Val {
126
131
  /**
127
132
  * @override
128
133
  */
129
- visit(visitor: any): any;
134
+ visit(visitor: Visitor): Val;
130
135
  }
131
136
  export declare const empty: Empty;
132
137
  export declare class Slash extends Val {
@@ -144,7 +149,7 @@ export declare class Slash extends Val {
144
149
  /**
145
150
  * @override
146
151
  */
147
- visit(visitor: any): any;
152
+ visit(visitor: Visitor): Val;
148
153
  }
149
154
  export declare const slash: Slash;
150
155
  export declare class Str extends Val {
@@ -161,7 +166,7 @@ export declare class Str extends Val {
161
166
  /**
162
167
  * @override
163
168
  */
164
- visit(visitor: any): any;
169
+ visit(visitor: Visitor): Val;
165
170
  }
166
171
  export declare class Ident extends Val {
167
172
  name: string;
@@ -177,7 +182,7 @@ export declare class Ident extends Val {
177
182
  /**
178
183
  * @override
179
184
  */
180
- visit(visitor: any): any;
185
+ visit(visitor: Visitor): Val;
181
186
  /**
182
187
  * @override
183
188
  */
@@ -199,7 +204,7 @@ export declare class Numeric extends Val {
199
204
  /**
200
205
  * @override
201
206
  */
202
- visit(visitor: any): any;
207
+ visit(visitor: Visitor): Val;
203
208
  /**
204
209
  * @override
205
210
  */
@@ -219,7 +224,7 @@ export declare class Num extends Val {
219
224
  /**
220
225
  * @override
221
226
  */
222
- visit(visitor: any): any;
227
+ visit(visitor: Visitor): Val;
223
228
  /**
224
229
  * @override
225
230
  */
@@ -230,7 +235,7 @@ export declare class Int extends Num {
230
235
  /**
231
236
  * @override
232
237
  */
233
- visit(visitor: any): any;
238
+ visit(visitor: Visitor): Val;
234
239
  }
235
240
  export declare class HexColor extends Val {
236
241
  hex: string;
@@ -242,7 +247,7 @@ export declare class HexColor extends Val {
242
247
  /**
243
248
  * @override
244
249
  */
245
- visit(visitor: any): any;
250
+ visit(visitor: Visitor): Val;
246
251
  }
247
252
  export declare class URL extends Val {
248
253
  url: string;
@@ -254,7 +259,7 @@ export declare class URL extends Val {
254
259
  /**
255
260
  * @override
256
261
  */
257
- visit(visitor: any): any;
262
+ visit(visitor: Visitor): Val;
258
263
  }
259
264
  export declare class URange extends Val {
260
265
  urangeText: string;
@@ -266,7 +271,7 @@ export declare class URange extends Val {
266
271
  /**
267
272
  * @override
268
273
  */
269
- visit(visitor: any): any;
274
+ visit(visitor: Visitor): Val;
270
275
  }
271
276
  export declare function appendList(buf: Base.StringBuffer, values: Val[], separator: string, toString: boolean): void;
272
277
  export declare class SpaceList extends Val {
@@ -279,7 +284,7 @@ export declare class SpaceList extends Val {
279
284
  /**
280
285
  * @override
281
286
  */
282
- visit(visitor: any): any;
287
+ visit(visitor: Visitor): Val;
283
288
  /**
284
289
  * @override
285
290
  */
@@ -295,7 +300,7 @@ export declare class CommaList extends Val {
295
300
  /**
296
301
  * @override
297
302
  */
298
- visit(visitor: any): any;
303
+ visit(visitor: Visitor): Val;
299
304
  }
300
305
  export declare class Func extends Val {
301
306
  name: string;
@@ -308,7 +313,7 @@ export declare class Func extends Val {
308
313
  /**
309
314
  * @override
310
315
  */
311
- visit(visitor: any): any;
316
+ visit(visitor: Visitor): Val;
312
317
  }
313
318
  export declare class Expr extends Val {
314
319
  expr: Exprs.Val;
@@ -324,12 +329,23 @@ export declare class Expr extends Val {
324
329
  /**
325
330
  * @override
326
331
  */
327
- visit(visitor: any): any;
332
+ visit(visitor: Visitor): Val;
328
333
  /**
329
334
  * @override
330
335
  */
331
336
  isExpr(): boolean;
332
337
  }
338
+ /**
339
+ * Custom property value, may be arbitrary token
340
+ */
341
+ export declare class AnyToken extends Val {
342
+ text: string;
343
+ constructor(text: string);
344
+ /**
345
+ * @override
346
+ */
347
+ appendTo(buf: Base.StringBuffer, toString: boolean): void;
348
+ }
333
349
  export declare function toNumber(val: Val, context: Exprs.Context): number;
334
350
  /**
335
351
  * Convert numeric value to px
@@ -352,3 +368,4 @@ export declare function isDefaultingValue(value: Val): boolean;
352
368
  * Function to sort property names in the order they should be processed
353
369
  */
354
370
  export declare function processingOrderFn(name1: string, name2: string): number;
371
+ export declare function isCustomPropName(name: string): boolean;
@@ -32,5 +32,5 @@ export declare class PseudoelementStyler implements PseudoElement.PseudoelementS
32
32
  */
33
33
  processContent(element: Element, styles: {
34
34
  [key: string]: Css.Val;
35
- }): void;
35
+ }, viewNode: Node): void;
36
36
  }
@@ -26,15 +26,16 @@ import * as TaskUtil from "./task-util";
26
26
  export declare type FormattingContextType = "Block" | "RepetitiveElementsOwner" | "Table";
27
27
  export declare type FragmentLayoutConstraintType = "AfterIfContinue" | "EntireTable" | "RepetitiveElementsOwner" | "TableRow";
28
28
  export declare namespace CssCascade {
29
- interface ElementStyle {
30
- }
29
+ type ElementStyle = {
30
+ [key: string]: any;
31
+ };
31
32
  }
32
33
  export declare namespace CssStyler {
33
34
  interface AbstractStyler {
34
35
  getStyle(element: Element, deep: boolean): CssCascade.ElementStyle;
35
36
  processContent(element: Element, styles: {
36
37
  [key: string]: Css.Val;
37
- }): any;
38
+ }, viewNode: Node): any;
38
39
  }
39
40
  }
40
41
  export declare namespace Layout {
@@ -69,7 +69,7 @@ export declare class ViewFactory extends Base.SimpleEventTarget implements Vtree
69
69
  createPseudoelementShadow(element: Element, isRoot: boolean, cascStyle: CssCascade.ElementStyle, computedStyle: {
70
70
  [key: string]: Css.Val;
71
71
  }, styler: CssStyler.AbstractStyler, context: Exprs.Context, parentShadow: Vtree.ShadowContext, subShadow: Vtree.ShadowContext): Vtree.ShadowContext;
72
- getPseudoMap(cascStyle: CssCascade.ElementStyle, regionIds: string[], isFootnote: boolean, nodeContext: Vtree.NodeContext, context: Exprs.Context): {};
72
+ getPseudoMap(cascStyle: CssCascade.ElementStyle, regionIds: string[], isFootnote: boolean, nodeContext: Vtree.NodeContext, context: Exprs.Context): CssCascade.ElementStyleMap;
73
73
  createRefShadow(href: string, type: Vtree.ShadowType, element: Element, parentShadow: Vtree.ShadowContext, subShadow: Vtree.ShadowContext): Task.Result<Vtree.ShadowContext>;
74
74
  createShadows(element: Element, isRoot: any, cascStyle: CssCascade.ElementStyle, computedStyle: {
75
75
  [key: string]: Css.Val;