forked from MarisaKirisame/megatron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLayoutPQ_D.cpp
4906 lines (4903 loc) · 179 KB
/
LayoutPQ_D.cpp
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
#include "header.h"
enum class DEStringCase {
DEStringCaseDefault,
DSTRING_,
DSTRING_SLASHdocument,
DSTRING_SLASHshadow_root,
DSTRING_SLASHtext,
DSTRING_A,
DSTRING_ABBR,
DSTRING_ACTIVE_GLOBAL_BANNERS,
DSTRING_ARTICLE,
DSTRING_ASIDE,
DSTRING_AUDIO,
DSTRING_AUTO_CHECK,
DSTRING_Auto,
DSTRING_B,
DSTRING_BODY,
DSTRING_BR,
DSTRING_BUTTON,
DSTRING_CARD_SKEW,
DSTRING_CENTER,
DSTRING_COOKIE_CONSENT_LINK,
DSTRING_CUSTOM_SCOPES,
DSTRING_DD,
DSTRING_DIALOG_HELPER,
DSTRING_DIV,
DSTRING_DL,
DSTRING_DT,
DSTRING_EM,
DSTRING_FIGCAPTION,
DSTRING_FIGURE,
DSTRING_FONT,
DSTRING_FOOTER,
DSTRING_FORM,
DSTRING_FULLSTORY_CAPTURE,
DSTRING_GHCC_CONSENT,
DSTRING_GLOBAL_BANNER,
DSTRING_H1,
DSTRING_H2,
DSTRING_H3,
DSTRING_H4,
DSTRING_HEAD,
DSTRING_HEADER,
DSTRING_HTML,
DSTRING_I,
DSTRING_IFRAME,
DSTRING_IMG,
DSTRING_INCLUDE_FRAGMENT,
DSTRING_INPUT,
DSTRING_LABEL,
DSTRING_LI,
DSTRING_MAIN,
DSTRING_MODAL_DIALOG,
DSTRING_NAV,
DSTRING_NOSCRIPT,
DSTRING_OL,
DSTRING_P,
DSTRING_PICTURE,
DSTRING_QBSEARCH_INPUT,
DSTRING_QUERY_BUILDER,
DSTRING_REACT_PARTIAL,
DSTRING_SCROLLABLE_REGION,
DSTRING_SECTION,
DSTRING_SELECT,
DSTRING_SLOT,
DSTRING_SMALL,
DSTRING_SOURCE,
DSTRING_SPAN,
DSTRING_SUP,
DSTRING_TABLE,
DSTRING_TBODY,
DSTRING_TD,
DSTRING_TEXTAREA,
DSTRING_TIME,
DSTRING_TOOL_TIP,
DSTRING_TR,
DSTRING_U,
DSTRING_UL,
DSTRING_VIDEO,
DSTRING_absolute,
DSTRING_auto,
DSTRING_block,
DSTRING_column,
DSTRING_column_reverse,
DSTRING_contents,
DSTRING_fit_content,
DSTRING_flex,
DSTRING_grid,
DSTRING_inline,
DSTRING_inline_block,
DSTRING_inline_flex,
DSTRING_list_item,
DSTRING_max_content,
DSTRING_none,
DSTRING_row,
DSTRING_static,
DSTRING_svg,
DSTRING_table,
DSTRING_table_cell,
DSTRING_table_row,
DSTRING_table_row_group,
DHasSuffix_PERCENTAGE,
DHasSuffix_ch,
DHasSuffix_lh,
DHasSuffix_px,
DStringIsFloat,
DHasPrefix_calc,
};
struct DEStringRest {
double a0 = 0, a1 = 0, a2 = 0, a3 = 0;
};
struct DEString {
DEStringCase c;
DEStringRest r;
};
struct Meta {
bool bb_1_has_bb_time_table = false;
TotalOrder bb_1_bb_time_table;
bool bb_0_has_bb_time_table = false;
TotalOrder bb_0_bb_time_table;
bool bb_2_has_bb_time_table = false;
TotalOrder bb_2_bb_time_table;
bool pass_0_has_proc_time_table = false;
TotalOrder pass_0_proc_time_table;
bool pass_1_has_proc_time_table = false;
TotalOrder pass_1_proc_time_table;
bool alive = true;
};
struct Value {
std::variant<int64_t, double, bool, DEString> v;
};
DEString DEStringLit(DEStringCase c) {
DEString des;
des.c = c;
return des;
}
bool Asbool(const bool &b) { return b; }
bool Asbool(const Value &v) { return std::get<bool>(v.v); }
DEString AsDEString(const DEString &d) { return d; }
DEString AsDEString(const Value &v) { return std::get<DEString>(v.v); }
double Asdouble(const double &d) { return d; }
double Asdouble(const Value &v) { return std::get<double>(v.v); }
int64_t Asint64_t(const int64_t &i) { return i; }
int64_t Asint64_t(const Value &v) { return std::get<int64_t>(v.v); }
DEStringRest StringToDEStringRest(const std::string &str);
DEString StringToDEString(const std::string &str) {
if (str == "") {
return DEStringLit(DEStringCase::DSTRING_);
}
if (str == "#document") {
return DEStringLit(DEStringCase::DSTRING_SLASHdocument);
}
if (str == "#shadow-root") {
return DEStringLit(DEStringCase::DSTRING_SLASHshadow_root);
}
if (str == "#text") {
return DEStringLit(DEStringCase::DSTRING_SLASHtext);
}
if (str == "A") {
return DEStringLit(DEStringCase::DSTRING_A);
}
if (str == "ABBR") {
return DEStringLit(DEStringCase::DSTRING_ABBR);
}
if (str == "ACTIVE-GLOBAL-BANNERS") {
return DEStringLit(DEStringCase::DSTRING_ACTIVE_GLOBAL_BANNERS);
}
if (str == "ARTICLE") {
return DEStringLit(DEStringCase::DSTRING_ARTICLE);
}
if (str == "ASIDE") {
return DEStringLit(DEStringCase::DSTRING_ASIDE);
}
if (str == "AUDIO") {
return DEStringLit(DEStringCase::DSTRING_AUDIO);
}
if (str == "AUTO-CHECK") {
return DEStringLit(DEStringCase::DSTRING_AUTO_CHECK);
}
if (str == "Auto") {
return DEStringLit(DEStringCase::DSTRING_Auto);
}
if (str == "B") {
return DEStringLit(DEStringCase::DSTRING_B);
}
if (str == "BODY") {
return DEStringLit(DEStringCase::DSTRING_BODY);
}
if (str == "BR") {
return DEStringLit(DEStringCase::DSTRING_BR);
}
if (str == "BUTTON") {
return DEStringLit(DEStringCase::DSTRING_BUTTON);
}
if (str == "CARD-SKEW") {
return DEStringLit(DEStringCase::DSTRING_CARD_SKEW);
}
if (str == "CENTER") {
return DEStringLit(DEStringCase::DSTRING_CENTER);
}
if (str == "COOKIE-CONSENT-LINK") {
return DEStringLit(DEStringCase::DSTRING_COOKIE_CONSENT_LINK);
}
if (str == "CUSTOM-SCOPES") {
return DEStringLit(DEStringCase::DSTRING_CUSTOM_SCOPES);
}
if (str == "DD") {
return DEStringLit(DEStringCase::DSTRING_DD);
}
if (str == "DIALOG-HELPER") {
return DEStringLit(DEStringCase::DSTRING_DIALOG_HELPER);
}
if (str == "DIV") {
return DEStringLit(DEStringCase::DSTRING_DIV);
}
if (str == "DL") {
return DEStringLit(DEStringCase::DSTRING_DL);
}
if (str == "DT") {
return DEStringLit(DEStringCase::DSTRING_DT);
}
if (str == "EM") {
return DEStringLit(DEStringCase::DSTRING_EM);
}
if (str == "FIGCAPTION") {
return DEStringLit(DEStringCase::DSTRING_FIGCAPTION);
}
if (str == "FIGURE") {
return DEStringLit(DEStringCase::DSTRING_FIGURE);
}
if (str == "FONT") {
return DEStringLit(DEStringCase::DSTRING_FONT);
}
if (str == "FOOTER") {
return DEStringLit(DEStringCase::DSTRING_FOOTER);
}
if (str == "FORM") {
return DEStringLit(DEStringCase::DSTRING_FORM);
}
if (str == "FULLSTORY-CAPTURE") {
return DEStringLit(DEStringCase::DSTRING_FULLSTORY_CAPTURE);
}
if (str == "GHCC-CONSENT") {
return DEStringLit(DEStringCase::DSTRING_GHCC_CONSENT);
}
if (str == "GLOBAL-BANNER") {
return DEStringLit(DEStringCase::DSTRING_GLOBAL_BANNER);
}
if (str == "H1") {
return DEStringLit(DEStringCase::DSTRING_H1);
}
if (str == "H2") {
return DEStringLit(DEStringCase::DSTRING_H2);
}
if (str == "H3") {
return DEStringLit(DEStringCase::DSTRING_H3);
}
if (str == "H4") {
return DEStringLit(DEStringCase::DSTRING_H4);
}
if (str == "HEAD") {
return DEStringLit(DEStringCase::DSTRING_HEAD);
}
if (str == "HEADER") {
return DEStringLit(DEStringCase::DSTRING_HEADER);
}
if (str == "HTML") {
return DEStringLit(DEStringCase::DSTRING_HTML);
}
if (str == "I") {
return DEStringLit(DEStringCase::DSTRING_I);
}
if (str == "IFRAME") {
return DEStringLit(DEStringCase::DSTRING_IFRAME);
}
if (str == "IMG") {
return DEStringLit(DEStringCase::DSTRING_IMG);
}
if (str == "INCLUDE-FRAGMENT") {
return DEStringLit(DEStringCase::DSTRING_INCLUDE_FRAGMENT);
}
if (str == "INPUT") {
return DEStringLit(DEStringCase::DSTRING_INPUT);
}
if (str == "LABEL") {
return DEStringLit(DEStringCase::DSTRING_LABEL);
}
if (str == "LI") {
return DEStringLit(DEStringCase::DSTRING_LI);
}
if (str == "MAIN") {
return DEStringLit(DEStringCase::DSTRING_MAIN);
}
if (str == "MODAL-DIALOG") {
return DEStringLit(DEStringCase::DSTRING_MODAL_DIALOG);
}
if (str == "NAV") {
return DEStringLit(DEStringCase::DSTRING_NAV);
}
if (str == "NOSCRIPT") {
return DEStringLit(DEStringCase::DSTRING_NOSCRIPT);
}
if (str == "OL") {
return DEStringLit(DEStringCase::DSTRING_OL);
}
if (str == "P") {
return DEStringLit(DEStringCase::DSTRING_P);
}
if (str == "PICTURE") {
return DEStringLit(DEStringCase::DSTRING_PICTURE);
}
if (str == "QBSEARCH-INPUT") {
return DEStringLit(DEStringCase::DSTRING_QBSEARCH_INPUT);
}
if (str == "QUERY-BUILDER") {
return DEStringLit(DEStringCase::DSTRING_QUERY_BUILDER);
}
if (str == "REACT-PARTIAL") {
return DEStringLit(DEStringCase::DSTRING_REACT_PARTIAL);
}
if (str == "SCROLLABLE-REGION") {
return DEStringLit(DEStringCase::DSTRING_SCROLLABLE_REGION);
}
if (str == "SECTION") {
return DEStringLit(DEStringCase::DSTRING_SECTION);
}
if (str == "SELECT") {
return DEStringLit(DEStringCase::DSTRING_SELECT);
}
if (str == "SLOT") {
return DEStringLit(DEStringCase::DSTRING_SLOT);
}
if (str == "SMALL") {
return DEStringLit(DEStringCase::DSTRING_SMALL);
}
if (str == "SOURCE") {
return DEStringLit(DEStringCase::DSTRING_SOURCE);
}
if (str == "SPAN") {
return DEStringLit(DEStringCase::DSTRING_SPAN);
}
if (str == "SUP") {
return DEStringLit(DEStringCase::DSTRING_SUP);
}
if (str == "TABLE") {
return DEStringLit(DEStringCase::DSTRING_TABLE);
}
if (str == "TBODY") {
return DEStringLit(DEStringCase::DSTRING_TBODY);
}
if (str == "TD") {
return DEStringLit(DEStringCase::DSTRING_TD);
}
if (str == "TEXTAREA") {
return DEStringLit(DEStringCase::DSTRING_TEXTAREA);
}
if (str == "TIME") {
return DEStringLit(DEStringCase::DSTRING_TIME);
}
if (str == "TOOL-TIP") {
return DEStringLit(DEStringCase::DSTRING_TOOL_TIP);
}
if (str == "TR") {
return DEStringLit(DEStringCase::DSTRING_TR);
}
if (str == "U") {
return DEStringLit(DEStringCase::DSTRING_U);
}
if (str == "UL") {
return DEStringLit(DEStringCase::DSTRING_UL);
}
if (str == "VIDEO") {
return DEStringLit(DEStringCase::DSTRING_VIDEO);
}
if (str == "absolute") {
return DEStringLit(DEStringCase::DSTRING_absolute);
}
if (str == "auto") {
return DEStringLit(DEStringCase::DSTRING_auto);
}
if (str == "block") {
return DEStringLit(DEStringCase::DSTRING_block);
}
if (str == "column") {
return DEStringLit(DEStringCase::DSTRING_column);
}
if (str == "column-reverse") {
return DEStringLit(DEStringCase::DSTRING_column_reverse);
}
if (str == "contents") {
return DEStringLit(DEStringCase::DSTRING_contents);
}
if (str == "fit-content") {
return DEStringLit(DEStringCase::DSTRING_fit_content);
}
if (str == "flex") {
return DEStringLit(DEStringCase::DSTRING_flex);
}
if (str == "grid") {
return DEStringLit(DEStringCase::DSTRING_grid);
}
if (str == "inline") {
return DEStringLit(DEStringCase::DSTRING_inline);
}
if (str == "inline-block") {
return DEStringLit(DEStringCase::DSTRING_inline_block);
}
if (str == "inline-flex") {
return DEStringLit(DEStringCase::DSTRING_inline_flex);
}
if (str == "list-item") {
return DEStringLit(DEStringCase::DSTRING_list_item);
}
if (str == "max-content") {
return DEStringLit(DEStringCase::DSTRING_max_content);
}
if (str == "none") {
return DEStringLit(DEStringCase::DSTRING_none);
}
if (str == "row") {
return DEStringLit(DEStringCase::DSTRING_row);
}
if (str == "static") {
return DEStringLit(DEStringCase::DSTRING_static);
}
if (str == "svg") {
return DEStringLit(DEStringCase::DSTRING_svg);
}
if (str == "table") {
return DEStringLit(DEStringCase::DSTRING_table);
}
if (str == "table-cell") {
return DEStringLit(DEStringCase::DSTRING_table_cell);
}
if (str == "table-row") {
return DEStringLit(DEStringCase::DSTRING_table_row);
}
if (str == "table-row-group") {
return DEStringLit(DEStringCase::DSTRING_table_row_group);
}
if (std_has_suffix(str, "%")) {
return DEString{DEStringCase::DHasSuffix_PERCENTAGE, StringToDEStringRest(std_strip_suffix(str, "%"))};
}
if (std_has_suffix(str, "ch")) {
return DEString{DEStringCase::DHasSuffix_ch, StringToDEStringRest(std_strip_suffix(str, "ch"))};
}
if (std_has_suffix(str, "lh")) {
return DEString{DEStringCase::DHasSuffix_lh, StringToDEStringRest(std_strip_suffix(str, "lh"))};
}
if (std_has_suffix(str, "px")) {
return DEString{DEStringCase::DHasSuffix_px, StringToDEStringRest(std_strip_suffix(str, "px"))};
}
if (std_string_is_float(str)) {
return DEString{DEStringCase::DStringIsFloat, StringToDEStringRest(str)};
}
if (std_has_prefix(str, "calc")) {
return DEString{DEStringCase::DHasPrefix_calc, StringToDEStringRest(std_strip_prefix(str, "calc"))};
}
return DEStringLit(DEStringCase::DEStringCaseDefault);
}
Value JsonToValue(const json &j) {
if (j.is_string()) {
return Value(StringToDEString(JsonToString(j)));
} else if (j.is_number_integer()) {
return Value(JsonToInt(j));
} else {
std::cout << "JsonToValue:" << std::endl;
assert(false);
}
}
std::unordered_map<std::string, Value> JsonToDict(const json &j) {
std::unordered_map<std::string, Value> ret;
for (auto &[key, val] : j.items()) {
ret.insert({key, JsonToValue(val)});
}
return ret;
}
struct Content : std::enable_shared_from_this<Content> {
Content *parent = nullptr;
Content *prev = nullptr;
Content *next = nullptr;
Content *first = nullptr;
Content *last = nullptr;
int64_t extern_id;
List<Node> children;
DEString name;
Meta m;
Meta *meta = &m;
Content(const DEString &name, const std::unordered_map<std::string, Value> &attr,
const std::unordered_map<std::string, Value> &prop, int64_t extern_id, const List<Node> &children)
: name(name), extern_id(extern_id), children(children) {
if (attr.count("width") == 1) {
has_attr_width = true;
attr_width = AsDEString(attr.at("width"));
}
if (attr.count("image_height") == 1) {
has_attr_image_height = true;
attr_image_height = Asint64_t(attr.at("image_height"));
}
if (attr.count("image_width") == 1) {
has_attr_image_width = true;
attr_image_width = Asint64_t(attr.at("image_width"));
}
if (attr.count("height") == 1) {
has_attr_height = true;
attr_height = AsDEString(attr.at("height"));
}
if (attr.count("viewBox") == 1) {
has_attr_viewBox = true;
attr_viewBox = AsDEString(attr.at("viewBox"));
}
if (prop.count("width") == 1) {
has_prop_width = true;
prop_width = AsDEString(prop.at("width"));
}
if (prop.count("flex-grow") == 1) {
has_prop_flex_grow = true;
prop_flex_grow = AsDEString(prop.at("flex-grow"));
}
if (prop.count("height") == 1) {
has_prop_height = true;
prop_height = AsDEString(prop.at("height"));
}
if (prop.count("display") == 1) {
has_prop_display = true;
prop_display = AsDEString(prop.at("display"));
}
if (prop.count("position") == 1) {
has_prop_position = true;
prop_position = AsDEString(prop.at("position"));
}
if (prop.count("flex-shrink") == 1) {
has_prop_flex_shrink = true;
prop_flex_shrink = AsDEString(prop.at("flex-shrink"));
}
if (prop.count("flex-direction") == 1) {
has_prop_flex_direction = true;
prop_flex_direction = AsDEString(prop.at("flex-direction"));
}
}
bool var_visible;
bool has_var_visible = false;
bool var_inside_svg;
bool has_var_inside_svg = false;
DEString var_height_expr;
bool has_var_height_expr = false;
double var_flex_grow_sum;
bool has_var_flex_grow_sum = false;
double var_intrinsic_width_max;
bool has_var_intrinsic_width_max = false;
double var_x;
bool has_var_x = false;
double var_left_over;
bool has_var_left_over = false;
double var_y;
bool has_var_y = false;
bool var_is_svg_block;
bool has_var_is_svg_block = false;
double var_intrinsic_current_line_width;
bool has_var_intrinsic_current_line_width = false;
bool var_is_default_case;
bool has_var_is_default_case = false;
double var_finished_intrinsic_height_sum;
bool has_var_finished_intrinsic_height_sum = false;
double var_flex_grow;
bool has_var_flex_grow = false;
double var_flex_amount;
bool has_var_flex_amount = false;
double var_children_intrinsic_height;
bool has_var_children_intrinsic_height = false;
double var_height_internal;
bool has_var_height_internal = false;
double var_width_external;
bool has_var_width_external = false;
double var_intrinsic_current_line_height;
bool has_var_intrinsic_current_line_height = false;
double var_intrinsic_width_external;
bool has_var_intrinsic_width_external = false;
double var_flex_unit;
bool has_var_flex_unit = false;
DEString var_width_attr_expr;
bool has_var_width_attr_expr = false;
double var_intrinsic_height_internal;
bool has_var_intrinsic_height_internal = false;
DEString var_flex_direction;
bool has_var_flex_direction = false;
double var_children_intrinsic_width;
bool has_var_children_intrinsic_width = false;
double var_box_width;
bool has_var_box_width = false;
double var_intrinsic_height_sum;
bool has_var_intrinsic_height_sum = false;
bool var_intrinsic_height_is_height;
bool has_var_intrinsic_height_is_height = false;
bool var_intrinsic_width_is_width;
bool has_var_intrinsic_width_is_width = false;
DEString var_display;
bool has_var_display = false;
double var_box_height;
bool has_var_box_height = false;
bool var_is_flex_row;
bool has_var_is_flex_row = false;
double var_flex_shrink_sum;
bool has_var_flex_shrink_sum = false;
double var_intrinsic_width_sum;
bool has_var_intrinsic_width_sum = false;
double var_line_height;
bool has_var_line_height = false;
bool var_is_flex_column;
bool has_var_is_flex_column = false;
bool var_has_width_attr;
bool has_var_has_width_attr = false;
double var_width_internal;
bool has_var_width_internal = false;
bool var_line_break;
bool has_var_line_break = false;
double var_intrinsic_height_external;
bool has_var_intrinsic_height_external = false;
bool var_has_height_attr;
bool has_var_has_height_attr = false;
double var_flex_shrink;
bool has_var_flex_shrink = false;
bool var_disabled;
bool has_var_disabled = false;
DEString var_position;
bool has_var_position = false;
DEString var_height_attr_expr;
bool has_var_height_attr_expr = false;
double var_height_external;
bool has_var_height_external = false;
DEString var_width_expr;
bool has_var_width_expr = false;
double var_intrinsic_width_internal;
bool has_var_intrinsic_width_internal = false;
DEString attr_width;
bool has_attr_width = false;
int64_t attr_image_height;
bool has_attr_image_height = false;
int64_t attr_image_width;
bool has_attr_image_width = false;
DEString attr_height;
bool has_attr_height = false;
DEString attr_viewBox;
bool has_attr_viewBox = false;
DEString prop_width;
bool has_prop_width = false;
DEString prop_flex_grow;
bool has_prop_flex_grow = false;
DEString prop_height;
bool has_prop_height = false;
DEString prop_display;
bool has_prop_display = false;
DEString prop_position;
bool has_prop_position = false;
DEString prop_flex_shrink;
bool has_prop_flex_shrink = false;
DEString prop_flex_direction;
bool has_prop_flex_direction = false;
};
#include "header_continued.h"
Unit var_modified_x_4390(const auto &x_4392);
auto eval_expr_x_4387(const auto &x_4414);
Unit var_modified_x_4385(const auto &x_4491);
auto eval_expr_x_4382(const auto &x_4497);
Unit var_modified_x_4380(const auto &x_4514);
auto eval_expr_x_4377(const auto &x_4528);
Unit var_modified_x_4375(const auto &x_4533);
auto eval_expr_x_4372(const auto &x_4547);
Unit var_modified_x_4370(const auto &x_4556);
auto eval_expr_x_4367(const auto &x_4562);
Unit var_modified_x_4365(const auto &x_4563);
auto eval_expr_x_4362(const auto &x_4569);
Unit var_modified_x_4360(const auto &x_4574);
auto eval_expr_x_4357(const auto &x_4584);
Unit var_modified_x_4355(const auto &x_4595);
auto eval_expr_x_4352(const auto &x_4601);
Unit var_modified_x_4350(const auto &x_4606);
auto eval_expr_x_4347(const auto &x_4616);
Unit var_modified_x_4345(const auto &x_4627);
auto eval_expr_x_4342(const auto &x_4637);
Unit var_modified_x_4340(const auto &x_4662);
auto eval_expr_x_4337(const auto &x_4676);
Unit var_modified_x_4335(const auto &x_4701);
auto eval_expr_x_4332(const auto &x_4707);
Unit var_modified_x_4330(const auto &x_4710);
auto eval_expr_x_4327(const auto &x_4722);
Unit var_modified_x_4325(const auto &x_4731);
auto eval_expr_x_4322(const auto &x_4743);
Unit var_modified_x_4320(const auto &x_4752);
auto eval_expr_x_4317(const auto &x_4762);
Unit var_modified_x_4315(const auto &x_4765);
auto eval_expr_x_4312(const auto &x_4775);
Unit var_modified_x_4310(const auto &x_4778);
auto eval_expr_x_4307(const auto &x_4792);
Unit var_modified_x_4305(const auto &x_4795);
auto eval_expr_x_4302(const auto &x_4809);
Unit var_modified_x_4298(const auto &x_4812);
auto eval_expr_x_4295(const auto &x_4826);
Unit var_modified_x_4293(const auto &x_4855);
auto eval_expr_x_4290(const auto &x_4869);
Unit var_modified_x_4288(const auto &x_4882);
auto eval_expr_x_4285(const auto &x_4896);
Unit var_modified_x_4283(const auto &x_4905);
auto eval_expr_x_4280(const auto &x_4911);
Unit var_modified_x_4278(const auto &x_4920);
auto eval_expr_x_4275(const auto &x_4930);
Unit var_modified_x_4273(const auto &x_5075);
auto eval_expr_x_4270(const auto &x_5081);
Unit var_modified_x_4268(const auto &x_5130);
auto eval_expr_x_4265(const auto &x_5140);
Unit var_modified_x_4263(const auto &x_5143);
auto eval_expr_x_4260(const auto &x_5149);
Unit var_modified_x_4258(const auto &x_5158);
auto eval_expr_x_4255(const auto &x_5172);
Unit var_modified_x_4253(const auto &x_5181);
auto eval_expr_x_4250(const auto &x_5195);
Unit var_modified_x_4248(const auto &x_5204);
auto eval_expr_x_4245(const auto &x_5216);
Unit var_modified_x_4243(const auto &x_5229);
auto eval_expr_x_4240(const auto &x_5235);
Unit var_modified_x_4238(const auto &x_5244);
auto eval_expr_x_4235(const auto &x_5254);
Unit var_modified_x_4233(const auto &x_5407);
auto eval_expr_x_4230(const auto &x_5413);
Unit var_modified_x_4228(const auto &x_5418);
auto eval_expr_x_4225(const auto &x_5424);
Unit var_modified_x_4223(const auto &x_5473);
auto eval_expr_x_4220(const auto &x_5479);
Unit var_modified_x_4218(const auto &x_5492);
auto eval_expr_x_4215(const auto &x_5502);
Unit var_modified_x_4211(const auto &x_5505);
auto eval_expr_x_4208(const auto &x_5513);
Unit var_modified_x_4206(const auto &x_5530);
auto eval_expr_x_4203(const auto &x_5536);
Unit var_modified_x_4201(const auto &x_5545);
auto eval_expr_x_4198(const auto &x_5555);
Unit var_modified_x_4196(const auto &x_5608);
auto eval_expr_x_4193(const auto &x_5620);
Unit var_modified_x_4191(const auto &x_5645);
auto eval_expr_x_4188(const auto &x_5653);
Unit var_modified_x_4186(const auto &x_5662);
auto eval_expr_x_4183(const auto &x_5672);
Unit var_modified_x_4181(const auto &x_5725);
auto eval_expr_x_4178(const auto &x_5737);
Unit var_modified_x_4176(const auto &x_5758);
auto eval_expr_x_4173(const auto &x_5764);
Unit var_modified_x_4171(const auto &x_5785);
auto eval_expr_x_4168(const auto &x_5791);
Unit var_modified_x_4166(const auto &x_5804);
auto eval_expr_x_4163(const auto &x_5814);
Unit var_modified_x_4161(const auto &x_5835);
auto eval_expr_x_4158(const auto &x_5841);
Unit var_modified_x_4156(const auto &x_5846);
auto eval_expr_x_4153(const auto &x_5852);
Unit eval_stmts_x_4053(const auto &x_4151);
Unit eval_stmts_x_4052(const auto &x_4213);
Unit eval_stmts_x_4051(const auto &x_4300);
Unit x_3712(const auto &x_3713, const auto &x_3714, const auto &x_3715);
Unit x_3719(const auto &x_3720, const auto &x_3721, const auto &x_3722);
Unit x_3726(const auto &x_3727, const auto &x_3728, const auto &x_3729);
Unit x_3733(const auto &x_3734, const auto &x_3735, const auto &x_3736);
Unit x_3780(const auto &x_3781, const auto &x_3782, const auto &x_3783);
Unit x_3825(const auto &x_3826, const auto &x_3827, const auto &x_3828);
Unit x_3908(const auto &x_3909, const auto &x_3910, const auto &x_3911);
Unit x_3996(const auto &x_3997);
Unit x_4004(const auto &x_4005, const auto &x_4006, const auto &x_4007);
Unit x_4046(const auto &x_4047);
Unit x_4057(const auto &x_4058, const auto &x_4059, const auto &x_4060);
Unit x_4109(const auto &x_4110);
Unit eval_stmts_x_3685(const auto &x_4117);
Unit eval_stmts_x_3683(const auto &x_4122);
Unit x_4128(const auto &x_4129);
int64_t x_4136(const auto &x_4137);
int64_t x_4139(const auto &x_4140);
LayoutNode x_4142(const auto &x_4143);
Node x_4145(const auto &x_4146);
Node x_4148(const auto &x_4149);
Unit var_modified_x_4390(const auto &x_4392) {
return MetricRecordOverhead(Zro(Timed([&](const auto &x_4393) {
auto x_5857 = [&](const auto &x_4394) {
return MetricRecordOverhead(Zro(Timed([&](const auto &x_4395) {
if (x_4394->meta->bb_0_has_bb_time_table) {
auto x_4396 = x_4394->meta->bb_0_bb_time_table;
MetaWriteMetric();
return QueuePush(x_4396, x_4394, static_cast<int64_t>(1));
} else {
return MakeUnit();
}
})));
};
x_5857(x_4392);
MakeUnit();
auto x_5858 = [&](const auto &x_4400) {
return MetricRecordOverhead(Zro(Timed([&](const auto &x_4401) {
if (x_4400->meta->bb_0_has_bb_time_table) {
auto x_4402 = x_4400->meta->bb_0_bb_time_table;
MetaWriteMetric();
return QueuePush(x_4402, x_4400, static_cast<int64_t>(1));
} else {
return MakeUnit();
}
})));
};
OptionMatch(
x_4392->next, [&](const auto &x_4399) { return MakeUnit(); },
[&](const auto &x_4398) {
auto x_5861 = x_5858;
x_5861(x_4398);
return MakeUnit();
});
auto x_5859 = [&](const auto &x_4404) {
return MetricRecordOverhead(Zro(Timed([&](const auto &x_4405) {
if (x_4404->meta->bb_2_has_bb_time_table) {
auto x_4406 = x_4404->meta->bb_2_bb_time_table;
MetaWriteMetric();
return QueuePush(x_4406, x_4404, static_cast<int64_t>(2));
} else {
return MakeUnit();
}
})));
};
x_5859(x_4392);
MakeUnit();
auto x_5860 = [&](const auto &x_4410) {
return MetricRecordOverhead(Zro(Timed([&](const auto &x_4411) {
if (x_4410->meta->bb_2_has_bb_time_table) {
auto x_4412 = x_4410->meta->bb_2_bb_time_table;
MetaWriteMetric();
return QueuePush(x_4412, x_4410, static_cast<int64_t>(2));
} else {
return MakeUnit();
}
})));
};
OptionMatch(
x_4392->next, [&](const auto &x_4409) { return MakeUnit(); },
[&](const auto &x_4408) {
auto x_5862 = x_5860;
x_5862(x_4408);
return MakeUnit();
});
return MakeUnit();
})));
}
auto eval_expr_x_4387(const auto &x_4414) {
if (eq(x_4414->var_display, DEStringLit(DEStringCase::DSTRING_none))) {
return false;
} else {
if (eq(x_4414->var_position, DEStringLit(DEStringCase::DSTRING_absolute))) {
return false;
} else {
if ((x_4414->parent != nullptr) &&
(eq((x_4414->parent)->var_display, DEStringLit(DEStringCase::DSTRING_flex)) ||
eq((x_4414->parent)->var_display, DEStringLit(DEStringCase::DSTRING_inline_flex)))) {
return true;
} else {
if (eq(x_4414->var_display, DEStringLit(DEStringCase::DSTRING_block))) {
return true;
} else {
if (eq(x_4414->var_display, DEStringLit(DEStringCase::DSTRING_inline))) {
return false;
} else {
if (eq(x_4414->var_display, DEStringLit(DEStringCase::DSTRING_inline_block))) {
return false;
} else {
if (eq(x_4414->var_display, DEStringLit(DEStringCase::DSTRING_flex))) {
if (eq(x_4414->prop_flex_direction, DEStringLit(DEStringCase::DSTRING_row))) {
return false;
} else {
if (eq(x_4414->prop_flex_direction, DEStringLit(DEStringCase::DSTRING_column))) {
return true;
} else {
return true;
}
}
} else {
if (eq(x_4414->var_display, DEStringLit(DEStringCase::DSTRING_inline_flex))) {
return false;
} else {
if (eq(x_4414->var_display, DEStringLit(DEStringCase::DSTRING_contents))) {
return false;
} else {
if (eq(x_4414->var_display, DEStringLit(DEStringCase::DSTRING_table))) {
return true;
} else {
if (eq(x_4414->var_display, DEStringLit(DEStringCase::DSTRING_table_row_group))) {
return true;
} else {
if (eq(x_4414->var_display, DEStringLit(DEStringCase::DSTRING_table_row))) {
return true;
} else {
if (eq(x_4414->var_display, DEStringLit(DEStringCase::DSTRING_table_cell))) {
return false;
} else {
if (eq(x_4414->var_display, DEStringLit(DEStringCase::DSTRING_list_item))) {
return true;
} else {
return true;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
Unit var_modified_x_4385(const auto &x_4491) {
return MetricRecordOverhead(Zro(Timed([&](const auto &x_4492) {
ListIter(x_4491->children, [&](const auto &x_4493) {
return MetricRecordOverhead(Zro(Timed([&](const auto &x_4494) {
if (x_4493->meta->bb_1_has_bb_time_table) {
auto x_4495 = x_4493->meta->bb_1_bb_time_table;
MetaWriteMetric();
return QueuePush(x_4495, x_4493, static_cast<int64_t>(0));
} else {
return MakeUnit();
}
})));
});
return MakeUnit();
})));
}
auto eval_expr_x_4382(const auto &x_4497) {
return (((!(x_4497->parent != nullptr)) || (x_4497->parent)->var_visible) &&
(neq(x_4497->var_display, DEStringLit(DEStringCase::DSTRING_none)) &&
((!x_4497->var_inside_svg) && (!x_4497->var_disabled))));
}
Unit var_modified_x_4380(const auto &x_4514) {
return MetricRecordOverhead(Zro(Timed([&](const auto &x_4515) {
auto x_5863 = [&](const auto &x_4516) {
return MetricRecordOverhead(Zro(Timed([&](const auto &x_4517) {
if (x_4516->meta->bb_1_has_bb_time_table) {
auto x_4518 = x_4516->meta->bb_1_bb_time_table;
MetaWriteMetric();
return QueuePush(x_4518, x_4516, static_cast<int64_t>(0));
} else {
return MakeUnit();
}
})));
};
x_5863(x_4514);
MakeUnit();
ListIter(x_4514->children, [&](const auto &x_4520) {
return MetricRecordOverhead(Zro(Timed([&](const auto &x_4521) {
if (x_4520->meta->bb_1_has_bb_time_table) {
auto x_4522 = x_4520->meta->bb_1_bb_time_table;
MetaWriteMetric();
return QueuePush(x_4522, x_4520, static_cast<int64_t>(0));
} else {
return MakeUnit();
}
})));
});
auto x_5864 = [&](const auto &x_4524) {
return MetricRecordOverhead(Zro(Timed([&](const auto &x_4525) {
if (x_4524->meta->bb_0_has_bb_time_table) {
auto x_4526 = x_4524->meta->bb_0_bb_time_table;
MetaWriteMetric();
return QueuePush(x_4526, x_4524, static_cast<int64_t>(1));
} else {
return MakeUnit();
}
})));
};
x_5864(x_4514);
MakeUnit();
return MakeUnit();
})));
}
auto eval_expr_x_4377(const auto &x_4528) {
if (eq(x_4528->name, DEStringLit(DEStringCase::DSTRING_NOSCRIPT))) {
return true;
} else {
return ((x_4528->parent != nullptr) && (x_4528->parent)->var_disabled);
}
}
Unit var_modified_x_4375(const auto &x_4533) {
return MetricRecordOverhead(Zro(Timed([&](const auto &x_4534) {
auto x_5865 = [&](const auto &x_4535) {
return MetricRecordOverhead(Zro(Timed([&](const auto &x_4536) {
if (x_4535->meta->bb_1_has_bb_time_table) {
auto x_4537 = x_4535->meta->bb_1_bb_time_table;
MetaWriteMetric();
return QueuePush(x_4537, x_4535, static_cast<int64_t>(0));
} else {
return MakeUnit();
}
})));
};
x_5865(x_4533);