/
Style.php
4648 lines (4066 loc) · 142 KB
/
Style.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* @package dompdf
* @link https://github.com/dompdf/dompdf
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
*/
namespace Dompdf\Css;
use Dompdf\Adapter\CPDF;
use Dompdf\Css\Content\Attr;
use Dompdf\Css\Content\CloseQuote;
use Dompdf\Css\Content\ContentPart;
use Dompdf\Css\Content\Counter;
use Dompdf\Css\Content\Counters;
use Dompdf\Css\Content\NoCloseQuote;
use Dompdf\Css\Content\NoOpenQuote;
use Dompdf\Css\Content\OpenQuote;
use Dompdf\Css\Content\StringPart;
use Dompdf\Css\Content\Url;
use Dompdf\Exception;
use Dompdf\FontMetrics;
use Dompdf\Frame;
use Dompdf\Helpers;
/**
* Represents CSS properties.
*
* The Style class is responsible for handling and storing CSS properties.
* It includes methods to resolve colors and lengths, as well as getters &
* setters for many CSS properties.
*
* Access to the different CSS properties is provided by the methods
* {@link Style::set_prop()} and {@link Style::get_specified()}, and the
* property overload methods {@link Style::__set()} and {@link Style::__get()},
* as well as {@link Style::set_used()}. The latter methods operate on used
* values and permit access to any (CSS) property using the following syntax:
*
* ```
* $style->margin_top = 10.0;
* echo $style->margin_top; // Returns `10.0`
* ```
*
* To declare a property from a string, use {@link Style::set_prop()}:
*
* ```
* $style->set_prop("margin_top", "1em");
* echo $style->get_specified("margin_top"); // Returns `1em`
* echo $style->margin_top; // Returns `12.0`, assuming the default font size
* ```
*
* Actual CSS parsing is performed in the {@link Stylesheet} class.
*
* @property string $azimuth
* @property string $background_attachment
* @property array|string $background_color
* @property string $background_image Image URL or `none`
* @property string $background_image_resolution
* @property array $background_position Pair of `[x, y]`, each value being a length in pt or a percentage value
* @property string $background_repeat
* @property array|string $background_size `cover`, `contain`, or `[width, height]`, each being a length, percentage, or `auto`
* @property string $border_collapse
* @property string $border_color Only use for setting all sides to the same color
* @property float[] $border_spacing Pair of `[horizontal, vertical]` spacing
* @property string $border_style Only use for setting all sides to the same style
* @property array|string $border_top_color
* @property array|string $border_right_color
* @property array|string $border_bottom_color
* @property array|string $border_left_color
* @property string $border_top_style Valid border style
* @property string $border_right_style Valid border style
* @property string $border_bottom_style Valid border style
* @property string $border_left_style Valid border style
* @property float $border_top_width Length in pt
* @property float $border_right_width Length in pt
* @property float $border_bottom_width Length in pt
* @property float $border_left_width Length in pt
* @property string $border_width Only use for setting all sides to the same width
* @property float|string $border_bottom_left_radius Radius in pt or a percentage value
* @property float|string $border_bottom_right_radius Radius in pt or a percentage value
* @property float|string $border_top_left_radius Radius in pt or a percentage value
* @property float|string $border_top_right_radius Radius in pt or a percentage value
* @property string $border_radius Only use for setting all corners to the same radius
* @property float|string $bottom Length in pt, a percentage value, or `auto`
* @property string $caption_side
* @property string $clear
* @property string $clip
* @property array|string $color
* @property ContentPart[]|string $content List of content components, `normal`, or `none`
* @property array|string $counter_increment Array defining the counters to increment or `none`
* @property array|string $counter_reset Array defining the counters to reset or `none`
* @property string $cue_after
* @property string $cue_before
* @property string $cue
* @property string $cursor
* @property string $direction
* @property string $display
* @property string $elevation
* @property string $empty_cells
* @property string $float
* @property string $font_family
* @property float $font_size Length in pt
* @property string $font_style `normal`, `italic`, or `oblique`
* @property string $font_variant
* @property int $font_weight Number in the range [1, 1000]
* @property float|string $height Length in pt, a percentage value, or `auto`
* @property string $image_resolution
* @property string $inset Only use for setting all box insets to the same length
* @property float|string $left Length in pt, a percentage value, or `auto`
* @property float $letter_spacing Length in pt
* @property float $line_height Length in pt
* @property string $list_style_image Image URL or `none`
* @property string $list_style_position `inside` or `outside`
* @property string $list_style_type
* @property float|string $margin_right Length in pt, a percentage value, or `auto`
* @property float|string $margin_left Length in pt, a percentage value, or `auto`
* @property float|string $margin_top Length in pt, a percentage value, or `auto`
* @property float|string $margin_bottom Length in pt, a percentage value, or `auto`
* @property string $margin Only use for setting all sides to the same length
* @property float|string $max_height Length in pt, a percentage value, or `none`
* @property float|string $max_width Length in pt, a percentage value, or `none`
* @property float|string $min_height Length in pt, a percentage value, or `auto`
* @property float|string $min_width Length in pt, a percentage value, or `auto`
* @property float $opacity Number in the range [0, 1]
* @property int $orphans
* @property array|string $outline_color
* @property string $outline_style Valid border style, except for `hidden`
* @property float $outline_width Length in pt
* @property float $outline_offset Length in pt
* @property string $overflow
* @property string $overflow_wrap
* @property float|string $padding_top Length in pt or a percentage value
* @property float|string $padding_right Length in pt or a percentage value
* @property float|string $padding_bottom Length in pt or a percentage value
* @property float|string $padding_left Length in pt or a percentage value
* @property string $padding Only use for setting all sides to the same length
* @property string $page_break_after
* @property string $page_break_before
* @property string $page_break_inside
* @property string $pause_after
* @property string $pause_before
* @property string $pause
* @property string $pitch_range
* @property string $pitch
* @property string $play_during
* @property string $position
* @property array|string $quotes List of quote pairs, or `none`
* @property string $richness
* @property float|string $right Length in pt, a percentage value, or `auto`
* @property float[]|string $size Pair of `[width, height]` or `auto`
* @property string $speak_header
* @property string $speak_numeral
* @property string $speak_punctuation
* @property string $speak
* @property string $speech_rate
* @property string $src
* @property string $stress
* @property string $table_layout
* @property string $text_align
* @property string $text_decoration
* @property float|string $text_indent Length in pt or a percentage value
* @property string $text_transform
* @property float|string $top Length in pt, a percentage value, or `auto`
* @property array $transform List of transforms
* @property array $transform_origin Triplet of `[x, y, z]`, each value being a length in pt, or a percentage value for x and y
* @property string $unicode_bidi
* @property string $unicode_range
* @property string $vertical_align
* @property string $visibility
* @property string $voice_family
* @property string $volume
* @property string $white_space
* @property int $widows
* @property float|string $width Length in pt, a percentage value, or `auto`
* @property string $word_break
* @property float $word_spacing Length in pt
* @property int|string $z_index Integer value or `auto`
* @property string $_dompdf_keep
*
* @package dompdf
*/
class Style
{
protected const CSS_IDENTIFIER = "-?[_a-zA-Z]+[_a-zA-Z0-9-]*";
protected const CSS_INTEGER = "[+-]?\d+";
protected const CSS_NUMBER = "[+-]?\d*\.?\d+(?:[eE][+-]?\d+)?";
protected const CSS_STRING = "" .
'"(?>(?:\\\\["]|[^"])*)(?<!\\\\)"|' . // String ""
"'(?>(?:\\\\[']|[^'])*)(?<!\\\\)'"; // String ''
protected const CSS_VAR = "var\((([^()]|(?R))*)\)";
/**
* @link https://www.w3.org/TR/css-values-4/#calc-syntax
*/
protected const CSS_MATH_FUNCTIONS = [
// Basic Arithmetic
"calc" => true,
// Comparison Functions
"min" => true,
"max" => true,
"clamp" => true,
// Stepped Value Functions
"round" => true, // Not fully supported
"mod" => true,
"rem" => true,
// Trigonometric Functions
"sin" => true,
"cos" => true,
"tan" => true,
"asin" => true,
"acos" => true,
"atan" => true,
"atan2" => true,
// Exponential Functions
"pow" => true,
"sqrt" => true,
"hypot" => true,
"log" => true,
"exp" => true,
// Sign-Related Functions
"abs" => true,
"sign" => true
];
/**
* https://www.w3.org/TR/css-values-3/#custom-idents
*/
protected const CUSTOM_IDENT_FORBIDDEN = ["inherit", "initial", "unset", "default"];
/**
* Default font size, in points.
*
* @var float
*/
public static $default_font_size = 12;
/**
* Default line height, as a fraction of the font size.
*
* @var float
*/
public static $default_line_height = 1.2;
/**
* Default "absolute" font sizes relative to the default font-size
* https://www.w3.org/TR/css-fonts-3/#absolute-size-value
*
* @var array<float>
*/
public static $font_size_keywords = [
"xx-small" => 0.6, // 3/5
"x-small" => 0.75, // 3/4
"small" => 0.889, // 8/9
"medium" => 1, // 1
"large" => 1.2, // 6/5
"x-large" => 1.5, // 3/2
"xx-large" => 2.0, // 2/1
];
/**
* List of valid text-align keywords.
*/
public const TEXT_ALIGN_KEYWORDS = ["left", "right", "center", "justify"];
/**
* List of valid vertical-align keywords.
*/
public const VERTICAL_ALIGN_KEYWORDS = ["baseline", "bottom", "middle",
"sub", "super", "text-bottom", "text-top", "top"];
/**
* List of all block-level (outer) display types.
* * https://www.w3.org/TR/css-display-3/#display-type
* * https://www.w3.org/TR/css-display-3/#block-level
*/
public const BLOCK_LEVEL_TYPES = [
"block",
// "flow-root",
"list-item",
// "flex",
// "grid",
"table"
];
/**
* List of all inline-level (outer) display types.
* * https://www.w3.org/TR/css-display-3/#display-type
* * https://www.w3.org/TR/css-display-3/#inline-level
*/
public const INLINE_LEVEL_TYPES = [
"inline",
"inline-block",
// "inline-flex",
// "inline-grid",
"inline-table"
];
/**
* List of all table-internal (outer) display types.
* * https://www.w3.org/TR/css-display-3/#layout-specific-display
*/
public const TABLE_INTERNAL_TYPES = [
"table-row-group",
"table-header-group",
"table-footer-group",
"table-row",
"table-cell",
"table-column-group",
"table-column",
"table-caption"
];
/**
* List of all inline (inner) display types.
*/
public const INLINE_TYPES = ["inline"];
/**
* List of all block (inner) display types.
*/
public const BLOCK_TYPES = ["block", "inline-block", "table-cell", "list-item"];
/**
* List of all table (inner) display types.
*/
public const TABLE_TYPES = ["table", "inline-table"];
/**
* Lookup table for valid display types. Initially computed from the
* different constants.
*
* @var array
*/
protected static $valid_display_types = [];
/**
* List of all positioned types.
*/
public const POSITIONED_TYPES = ["relative", "absolute", "fixed"];
/**
* List of valid border styles.
*/
public const BORDER_STYLES = [
"none", "hidden",
"dotted", "dashed", "solid",
"double", "groove", "ridge", "inset", "outset"
];
/**
* List of valid outline-style values.
* Same as the border styles, except `auto` is allowed, `hidden` is not.
*
* @link https://www.w3.org/TR/css-ui-4/#typedef-outline-line-style
*/
protected const OUTLINE_STYLES = [
"auto", "none",
"dotted", "dashed", "solid",
"double", "groove", "ridge", "inset", "outset"
];
/**
* Map of CSS shorthand properties and their corresponding sub-properties.
* The order of the sub-properties is relevant for the fallback getter,
* which is used in case no specific getter method is defined.
*
* @var array<string, string[]>
*/
protected static $_props_shorthand = [
"background" => [
"background_image",
"background_position",
"background_size",
"background_repeat",
// "background_origin",
// "background_clip",
"background_attachment",
"background_color"
],
"border" => [
"border_top_width",
"border_right_width",
"border_bottom_width",
"border_left_width",
"border_top_style",
"border_right_style",
"border_bottom_style",
"border_left_style",
"border_top_color",
"border_right_color",
"border_bottom_color",
"border_left_color"
],
"border_top" => [
"border_top_width",
"border_top_style",
"border_top_color"
],
"border_right" => [
"border_right_width",
"border_right_style",
"border_right_color"
],
"border_bottom" => [
"border_bottom_width",
"border_bottom_style",
"border_bottom_color"
],
"border_left" => [
"border_left_width",
"border_left_style",
"border_left_color"
],
"border_width" => [
"border_top_width",
"border_right_width",
"border_bottom_width",
"border_left_width"
],
"border_style" => [
"border_top_style",
"border_right_style",
"border_bottom_style",
"border_left_style"
],
"border_color" => [
"border_top_color",
"border_right_color",
"border_bottom_color",
"border_left_color"
],
"border_radius" => [
"border_top_left_radius",
"border_top_right_radius",
"border_bottom_right_radius",
"border_bottom_left_radius"
],
"font" => [
"font_family",
"font_size",
// "font_stretch",
"font_style",
"font_variant",
"font_weight",
"line_height"
],
"inset" => [
"top",
"right",
"bottom",
"left"
],
"list_style" => [
"list_style_image",
"list_style_position",
"list_style_type"
],
"margin" => [
"margin_top",
"margin_right",
"margin_bottom",
"margin_left"
],
"padding" => [
"padding_top",
"padding_right",
"padding_bottom",
"padding_left"
],
"outline" => [
"outline_width",
"outline_style",
"outline_color"
]
];
/**
* Maps legacy property names to actual property names.
*
* @var array<string, string>
*/
protected static $_props_alias = [
"word_wrap" => "overflow_wrap",
"_dompdf_background_image_resolution" => "background_image_resolution",
"_dompdf_image_resolution" => "image_resolution",
"_webkit_transform" => "transform",
"_webkit_transform_origin" => "transform_origin"
];
/**
* Default style values.
*
* @link https://www.w3.org/TR/CSS21/propidx.html
*
* @var array<string, mixed>
*/
protected static $_defaults = null;
/**
* Lookup table for properties that inherit by default.
*
* @link https://www.w3.org/TR/CSS21/propidx.html
*
* @var array<string, true>
*/
protected static $_inherited = [
"azimuth" => true,
"background_image_resolution" => true,
"border_collapse" => true,
"border_spacing" => true,
"caption_side" => true,
"color" => true,
"cursor" => true,
"direction" => true,
"elevation" => true,
"empty_cells" => true,
"font_family" => true,
"font_size" => true,
"font_style" => true,
"font_variant" => true,
"font_weight" => true,
"font" => true,
"image_resolution" => true,
"letter_spacing" => true,
"line_height" => true,
"list_style_image" => true,
"list_style_position" => true,
"list_style_type" => true,
"list_style" => true,
"orphans" => true,
"overflow_wrap" => true,
"pitch_range" => true,
"pitch" => true,
"quotes" => true,
"richness" => true,
"speak_header" => true,
"speak_numeral" => true,
"speak_punctuation" => true,
"speak" => true,
"speech_rate" => true,
"stress" => true,
"text_align" => true,
"text_indent" => true,
"text_transform" => true,
"visibility" => true,
"voice_family" => true,
"volume" => true,
"white_space" => true,
"widows" => true,
"word_break" => true,
"word_spacing" => true
];
/**
* @var array<string, string[]>
*/
protected static $_dependency_map = [
"border_top_style" => [
"border_top_width"
],
"border_bottom_style" => [
"border_bottom_width"
],
"border_left_style" => [
"border_left_width"
],
"border_right_style" => [
"border_right_width"
],
"direction" => [
"text_align"
],
"font_size" => [
"background_position",
"background_size",
"border_top_width",
"border_right_width",
"border_bottom_width",
"border_left_width",
"border_top_left_radius",
"border_top_right_radius",
"border_bottom_right_radius",
"border_bottom_left_radius",
"letter_spacing",
"line_height",
"margin_top",
"margin_right",
"margin_bottom",
"margin_left",
"outline_width",
"outline_offset",
"padding_top",
"padding_right",
"padding_bottom",
"padding_left",
"word_spacing",
"width",
"height",
"min-width",
"min-height",
"max-width",
"max-height"
],
"float" => [
"display"
],
"position" => [
"display"
],
"outline_style" => [
"outline_width"
]
];
/**
* Lookup table for dependent properties. Initially computed from the
* dependency map.
*
* @var array<string, true>
*/
protected static $_dependent_props = [];
/**
* Caches method_exists result
*
* @var array<string, bool>
*/
protected static $_methods_cache = [];
/**
* The stylesheet this style belongs to
*
* @var Stylesheet
*/
protected $_stylesheet;
/**
* Media queries attached to the style
*
* This is a two-dimensional array where the first dimension represents
* the media query grouping (logic-or) and the second dimension the
* media queries within the grouping.
*
* The structure of the actual query element is:
* - media query feature
* - media query value or condition
* - media query operator (e.g., not)
*
* @var array
*/
protected $_media_queries;
/**
* Properties set by an `!important` declaration.
*
* @var array<string, true>
*/
protected $_important_props = [];
/**
* Specified (or declared) values of the CSS properties.
*
* https://www.w3.org/TR/css-cascade-3/#value-stages
*
* @var array<string, mixed>
*/
protected $_props = [];
/**
* Used to track which CSS property were set directly versus
* those set via shorthand property
*
* @var array<string, true>
*/
protected $_props_specified = [];
/**
* Computed values of the CSS properties.
*
* @var array<string, mixed>
*/
protected $_props_computed = [];
/**
* Used values of the CSS properties.
*
* @var array<string, mixed>
*/
protected $_props_used = [];
/**
* Marks properties with non-final used values that should be cleared on
* style reset.
*
* @var array<string, true>
*/
protected $non_final_used = [];
/**
* Used to track CSS property assignment entry/exit in order to watch
* for circular dependencies.
*
* @var array<int, string>
*/
protected $_prop_stack = [];
/**
* Used to track CSS variable resolution entry/exit in order to watch
* for circular dependencies.
*
* @var array<int, string>
*/
protected $_var_stack = [];
/**
* Style of the parent element in document tree.
*
* @var Style
*/
protected $parent_style;
/**
* @var Frame|null
*/
protected $_frame;
/**
* The origin of the style
*
* @var int
*/
protected $_origin = Stylesheet::ORIG_AUTHOR;
/**
* The computed bottom spacing
*
* @var float|string|null
*/
private $_computed_bottom_spacing = null;
/**
* @var bool|null
*/
private $has_border_radius_cache = null;
/**
* @var array|null
*/
private $resolved_border_radius = null;
/**
* @var FontMetrics
*/
private $fontMetrics;
/**
* @param Stylesheet $stylesheet The stylesheet the style is associated with.
* @param int $origin
*/
public function __construct(Stylesheet $stylesheet, int $origin = Stylesheet::ORIG_AUTHOR)
{
$this->fontMetrics = $stylesheet->getFontMetrics();
$this->_stylesheet = $stylesheet;
$this->_media_queries = [];
$this->_origin = $origin;
$this->parent_style = null;
if (!isset(self::$_defaults)) {
// Shorthand
$d =& self::$_defaults;
// All CSS 2.1 properties, and their default values
// Some properties are specified with their computed value for
// efficiency; this only works if the computed value is not
// dependent on another property
$d["azimuth"] = "center";
$d["background_attachment"] = "scroll";
$d["background_color"] = "transparent";
$d["background_image"] = "none";
$d["background_image_resolution"] = "normal";
$d["background_position"] = [0.0, 0.0];
$d["background_repeat"] = "repeat";
$d["background"] = "";
$d["border_collapse"] = "separate";
$d["border_color"] = "";
$d["border_spacing"] = [0.0, 0.0];
$d["border_style"] = "";
$d["border_top"] = "";
$d["border_right"] = "";
$d["border_bottom"] = "";
$d["border_left"] = "";
$d["border_top_color"] = "currentcolor";
$d["border_right_color"] = "currentcolor";
$d["border_bottom_color"] = "currentcolor";
$d["border_left_color"] = "currentcolor";
$d["border_top_style"] = "none";
$d["border_right_style"] = "none";
$d["border_bottom_style"] = "none";
$d["border_left_style"] = "none";
$d["border_top_width"] = "medium";
$d["border_right_width"] = "medium";
$d["border_bottom_width"] = "medium";
$d["border_left_width"] = "medium";
$d["border_width"] = "";
$d["border_bottom_left_radius"] = 0.0;
$d["border_bottom_right_radius"] = 0.0;
$d["border_top_left_radius"] = 0.0;
$d["border_top_right_radius"] = 0.0;
$d["border_radius"] = "";
$d["border"] = "";
$d["bottom"] = "auto";
$d["caption_side"] = "top";
$d["clear"] = "none";
$d["clip"] = "auto";
$d["color"] = "#000000";
$d["content"] = "normal";
$d["counter_increment"] = "none";
$d["counter_reset"] = "none";
$d["cue_after"] = "none";
$d["cue_before"] = "none";
$d["cue"] = "";
$d["cursor"] = "auto";
$d["direction"] = "ltr";
$d["display"] = "inline";
$d["elevation"] = "level";
$d["empty_cells"] = "show";
$d["float"] = "none";
$d["font_family"] = $stylesheet->get_dompdf()->getOptions()->getDefaultFont();
$d["font_size"] = "medium";
$d["font_style"] = "normal";
$d["font_variant"] = "normal";
$d["font_weight"] = 400;
$d["font"] = "";
$d["height"] = "auto";
$d["image_resolution"] = "normal";
$d["inset"] = "";
$d["left"] = "auto";
$d["letter_spacing"] = "normal";
$d["line_height"] = "normal";
$d["list_style_image"] = "none";
$d["list_style_position"] = "outside";
$d["list_style_type"] = "disc";
$d["list_style"] = "";
$d["margin_right"] = 0.0;
$d["margin_left"] = 0.0;
$d["margin_top"] = 0.0;
$d["margin_bottom"] = 0.0;
$d["margin"] = "";
$d["max_height"] = "none";
$d["max_width"] = "none";
$d["min_height"] = "auto";
$d["min_width"] = "auto";
$d["orphans"] = 2;
$d["outline_color"] = "currentcolor"; // "invert" special color is not supported
$d["outline_style"] = "none";
$d["outline_width"] = "medium";
$d["outline_offset"] = 0.0;
$d["outline"] = "";
$d["overflow"] = "visible";
$d["overflow_wrap"] = "normal";
$d["padding_top"] = 0.0;
$d["padding_right"] = 0.0;
$d["padding_bottom"] = 0.0;
$d["padding_left"] = 0.0;
$d["padding"] = "";
$d["page_break_after"] = "auto";
$d["page_break_before"] = "auto";
$d["page_break_inside"] = "auto";
$d["pause_after"] = "0";
$d["pause_before"] = "0";
$d["pause"] = "";
$d["pitch_range"] = "50";
$d["pitch"] = "medium";
$d["play_during"] = "auto";
$d["position"] = "static";
$d["quotes"] = "auto";
$d["richness"] = "50";
$d["right"] = "auto";
$d["size"] = "auto"; // @page
$d["speak_header"] = "once";
$d["speak_numeral"] = "continuous";
$d["speak_punctuation"] = "none";
$d["speak"] = "normal";
$d["speech_rate"] = "medium";
$d["stress"] = "50";
$d["table_layout"] = "auto";
$d["text_align"] = "";
$d["text_decoration"] = "none";
$d["text_indent"] = 0.0;
$d["text_transform"] = "none";
$d["top"] = "auto";
$d["unicode_bidi"] = "normal";
$d["vertical_align"] = "baseline";
$d["visibility"] = "visible";
$d["voice_family"] = "";
$d["volume"] = "medium";
$d["white_space"] = "normal";
$d["widows"] = 2;
$d["width"] = "auto";
$d["word_break"] = "normal";
$d["word_spacing"] = "normal";
$d["z_index"] = "auto";
// CSS3
$d["opacity"] = 1.0;
$d["background_size"] = ["auto", "auto"];
$d["transform"] = [];
$d["transform_origin"] = ["50%", "50%", 0.0];
// for @font-face
$d["src"] = "";
$d["unicode_range"] = "";
// vendor-prefixed properties
$d["_dompdf_keep"] = "";
// Compute dependent props from dependency map
foreach (self::$_dependency_map as $props) {
foreach ($props as $prop) {
self::$_dependent_props[$prop] = true;
}
}
// Compute valid display-type lookup table
self::$valid_display_types = [
"none" => true,
"-dompdf-br" => true,
"-dompdf-image" => true,
"-dompdf-list-bullet" => true,
"-dompdf-page" => true
];
foreach (self::BLOCK_LEVEL_TYPES as $val) {
self::$valid_display_types[$val] = true;
}
foreach (self::INLINE_LEVEL_TYPES as $val) {
self::$valid_display_types[$val] = true;
}
foreach (self::TABLE_INTERNAL_TYPES as $val) {
self::$valid_display_types[$val] = true;
}
}
}
/**
* Clear all non-final used values.
*/
public function reset(): void
{
foreach (array_keys($this->non_final_used) as $prop) {
unset($this->_props_used[$prop]);
}
$this->non_final_used = [];
}
/**
* @param array $media_queries
*/
public function set_media_queries(array $media_queries): void
{
$this->_media_queries = $media_queries;
}
/**
* @return array
*/
public function get_media_queries(): array
{
return $this->_media_queries;
}
/**
* @param Frame $frame
*/
public function set_frame(Frame $frame): void
{
$this->_frame = $frame;
}
/**
* @return Frame|null
*/
public function get_frame(): ?Frame
{
return $this->_frame;
}
/**
* @param int $origin
*/
public function set_origin(int $origin): void
{
$this->_origin = $origin;
}
/**
* @return int
*/
public function get_origin(): int