summaryrefslogtreecommitdiff
path: root/src/select/autogenerated_propset.h
blob: 94fc8878c30295b2b97f63ee9a0337c4c3416e24 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
/*
 * This file is part of LibCSS
 * Licensed under the MIT License,
 *                http://www.opensource.org/licenses/mit-license.php
 * Copyright 2017 The NetSurf Project
 */

/** Default values are 'initial value', unless the property is inherited,
 *  in which case it is 'inherit'. */
static const css_computed_uncommon default_uncommon = {
	.i = {
		.bits = {
			(CSS_BORDER_SPACING_SET << 21) | (
					CSS_OUTLINE_WIDTH_MEDIUM << 13) | (
					CSS_COLUMN_RULE_WIDTH_MEDIUM << 5) |
					CSS_CURSOR_AUTO,
			(CSS_COLUMN_WIDTH_AUTO << 25) | (CSS_COLUMN_GAP_NORMAL
					<< 18) | (CSS_LETTER_SPACING_NORMAL <<
					11) | (CSS_WORD_SPACING_NORMAL << 4) |
					CSS_BREAK_BEFORE_AUTO,
			(CSS_CLIP_AUTO << 6) | (CSS_COLUMN_RULE_STYLE_NONE <<
					2) |
					CSS_COLUMN_RULE_COLOR_CURRENT_COLOR,
			(CSS_BREAK_AFTER_AUTO << 28) | (CSS_BREAK_INSIDE_AUTO
					<< 24) | (CSS_CONTENT_NORMAL << 22) | (
					CSS_WRITING_MODE_HORIZONTAL_TB << 20) |
					(CSS_COLUMN_FILL_BALANCE << 18) | (
					CSS_COLUMN_SPAN_NONE << 16) | (
					CSS_COLUMN_COUNT_AUTO << 14) | (
					CSS_OUTLINE_COLOR_INVERT << 12) | (
					CSS_COUNTER_INCREMENT_NONE << 11) | (
					CSS_COUNTER_RESET_NONE << 10)
		},
		.border_spacing_a = 0,
		.border_spacing_b = 0,
		.clip_a = 0,
		.clip_b = 0,
		.clip_c = 0,
		.clip_d = 0,
		.column_count = 0,
		.column_gap = 0,
		.column_rule_color = 0,
		.column_rule_width = 0,
		.column_width = 0,
		.letter_spacing = 0,
		.outline_color = 0,
		.outline_width = 0,
		.word_spacing = 0
	},
	.content = NULL,
	.counter_increment = NULL,
	.counter_reset = NULL,
	.cursor = NULL,
	.next = NULL,
	.count = 0,
	.bin = UINT32_MAX
};

#define ENSURE_UNCOMMON do {						\
	if (style->i.uncommon == NULL) {				\
		style->i.uncommon = malloc(sizeof(			\
				css_computed_uncommon));		\
		if (style->i.uncommon == NULL)				\
			return CSS_NOMEM;				\
									\
		memcpy(style->i.uncommon, &default_uncommon, sizeof(	\
				css_computed_uncommon));		\
	}								\
} while(0)								\


#define BORDER_SPACING_INDEX 0
#define BORDER_SPACING_SHIFT 21
#define BORDER_SPACING_MASK 0xffe00000

static inline css_error set_border_spacing(css_computed_style *style, uint8_t
		type, css_fixed length_a, css_unit unit_a, css_fixed length_b,
		css_unit unit_b)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[BORDER_SPACING_INDEX];
	
	/* 11bits: aaaaabbbbbt : unit_a | unit_b | type */
	*bits = (*bits & ~BORDER_SPACING_MASK) | ((((uint32_t)type & 0x1) | (
			unit_b << 1) | (unit_a << 6)) << BORDER_SPACING_SHIFT);
	
	style->i.uncommon->i.border_spacing_a = length_a;
	
	style->i.uncommon->i.border_spacing_b = length_b;
	
	return CSS_OK;
}
#undef BORDER_SPACING_INDEX
#undef BORDER_SPACING_SHIFT
#undef BORDER_SPACING_MASK

#define BREAK_AFTER_INDEX 3
#define BREAK_AFTER_SHIFT 28
#define BREAK_AFTER_MASK 0xf0000000

static inline css_error set_break_after(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[BREAK_AFTER_INDEX];
	
	/* 4bits: tttt : type */
	*bits = (*bits & ~BREAK_AFTER_MASK) | (((uint32_t)type & 0xf) <<
			BREAK_AFTER_SHIFT);
	
	return CSS_OK;
}
#undef BREAK_AFTER_INDEX
#undef BREAK_AFTER_SHIFT
#undef BREAK_AFTER_MASK

#define BREAK_BEFORE_INDEX 1
#define BREAK_BEFORE_SHIFT 0
#define BREAK_BEFORE_MASK 0xf

static inline css_error set_break_before(css_computed_style *style, uint8_t
		type)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[BREAK_BEFORE_INDEX];
	
	/* 4bits: tttt : type */
	*bits = (*bits & ~BREAK_BEFORE_MASK) | (((uint32_t)type & 0xf) <<
			BREAK_BEFORE_SHIFT);
	
	return CSS_OK;
}
#undef BREAK_BEFORE_INDEX
#undef BREAK_BEFORE_SHIFT
#undef BREAK_BEFORE_MASK

#define BREAK_INSIDE_INDEX 3
#define BREAK_INSIDE_SHIFT 24
#define BREAK_INSIDE_MASK 0xf000000

static inline css_error set_break_inside(css_computed_style *style, uint8_t
		type)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[BREAK_INSIDE_INDEX];
	
	/* 4bits: tttt : type */
	*bits = (*bits & ~BREAK_INSIDE_MASK) | (((uint32_t)type & 0xf) <<
			BREAK_INSIDE_SHIFT);
	
	return CSS_OK;
}
#undef BREAK_INSIDE_INDEX
#undef BREAK_INSIDE_SHIFT
#undef BREAK_INSIDE_MASK

#define CLIP_INDEX 2
#define CLIP_SHIFT 6
#define CLIP_MASK 0xffffffc0
static inline css_error set_clip(
		css_computed_style *style, uint8_t type,
		css_computed_clip_rect *rect)
{
	uint32_t *bits;

	ENSURE_UNCOMMON;

	bits = &style->i.uncommon->i.bits[CLIP_INDEX];

	/*
	26bits: tt tttr rrrr bbbb blll llTR BLyy:
	units: top | right | bottom | left
	opcodes: top | right | bottom | left | type
	*/
	*bits = (*bits & ~CLIP_MASK) |
			((type & 0x3) << CLIP_SHIFT);

	if (type == CSS_CLIP_RECT) {
		*bits |= (((rect->top_auto ? 0x20 : 0) |
				(rect->right_auto ? 0x10 : 0) |
				(rect->bottom_auto ? 0x8 : 0) |
				(rect->left_auto ? 0x4 : 0)) << CLIP_SHIFT);

		*bits |= (((rect->tunit << 5) | rect->runit)
				<< (CLIP_SHIFT + 16));

		*bits |= (((rect->bunit << 5) | rect->lunit)
				<< (CLIP_SHIFT + 6));

		style->i.uncommon->i.clip_a = rect->top;
		style->i.uncommon->i.clip_b = rect->right;
		style->i.uncommon->i.clip_c = rect->bottom;
		style->i.uncommon->i.clip_d = rect->left;
	}

	return CSS_OK;
}
#undef CLIP_INDEX
#undef CLIP_SHIFT
#undef CLIP_MASK

#define COLUMN_COUNT_INDEX 3
#define COLUMN_COUNT_SHIFT 14
#define COLUMN_COUNT_MASK 0xc000

static inline css_error set_column_count(css_computed_style *style, uint8_t
		type, int32_t integer)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[COLUMN_COUNT_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~COLUMN_COUNT_MASK) | (((uint32_t)type & 0x3) <<
			COLUMN_COUNT_SHIFT);
	
	style->i.uncommon->i.column_count = integer;
	
	return CSS_OK;
}
#undef COLUMN_COUNT_INDEX
#undef COLUMN_COUNT_SHIFT
#undef COLUMN_COUNT_MASK

#define COLUMN_FILL_INDEX 3
#define COLUMN_FILL_SHIFT 18
#define COLUMN_FILL_MASK 0xc0000

static inline css_error set_column_fill(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[COLUMN_FILL_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~COLUMN_FILL_MASK) | (((uint32_t)type & 0x3) <<
			COLUMN_FILL_SHIFT);
	
	return CSS_OK;
}
#undef COLUMN_FILL_INDEX
#undef COLUMN_FILL_SHIFT
#undef COLUMN_FILL_MASK

#define COLUMN_GAP_INDEX 1
#define COLUMN_GAP_SHIFT 18
#define COLUMN_GAP_MASK 0x1fc0000

static inline css_error set_column_gap(css_computed_style *style, uint8_t type,
		css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[COLUMN_GAP_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~COLUMN_GAP_MASK) | ((((uint32_t)type & 0x3) | (unit
			<< 2)) << COLUMN_GAP_SHIFT);
	
	style->i.uncommon->i.column_gap = length;
	
	return CSS_OK;
}
#undef COLUMN_GAP_INDEX
#undef COLUMN_GAP_SHIFT
#undef COLUMN_GAP_MASK

#define COLUMN_RULE_COLOR_INDEX 2
#define COLUMN_RULE_COLOR_SHIFT 0
#define COLUMN_RULE_COLOR_MASK 0x3

static inline css_error set_column_rule_color(css_computed_style *style,
		uint8_t type, css_color color)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[COLUMN_RULE_COLOR_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~COLUMN_RULE_COLOR_MASK) | (((uint32_t)type & 0x3) <<
			COLUMN_RULE_COLOR_SHIFT);
	
	style->i.uncommon->i.column_rule_color = color;
	
	return CSS_OK;
}
#undef COLUMN_RULE_COLOR_INDEX
#undef COLUMN_RULE_COLOR_SHIFT
#undef COLUMN_RULE_COLOR_MASK

#define COLUMN_RULE_STYLE_INDEX 2
#define COLUMN_RULE_STYLE_SHIFT 2
#define COLUMN_RULE_STYLE_MASK 0x3c

static inline css_error set_column_rule_style(css_computed_style *style,
		uint8_t type)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[COLUMN_RULE_STYLE_INDEX];
	
	/* 4bits: tttt : type */
	*bits = (*bits & ~COLUMN_RULE_STYLE_MASK) | (((uint32_t)type & 0xf) <<
			COLUMN_RULE_STYLE_SHIFT);
	
	return CSS_OK;
}
#undef COLUMN_RULE_STYLE_INDEX
#undef COLUMN_RULE_STYLE_SHIFT
#undef COLUMN_RULE_STYLE_MASK

#define COLUMN_RULE_WIDTH_INDEX 0
#define COLUMN_RULE_WIDTH_SHIFT 5
#define COLUMN_RULE_WIDTH_MASK 0x1fe0

static inline css_error set_column_rule_width(css_computed_style *style,
		uint8_t type, css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[COLUMN_RULE_WIDTH_INDEX];
	
	/* 8bits: uuuuuttt : unit | type */
	*bits = (*bits & ~COLUMN_RULE_WIDTH_MASK) | ((((uint32_t)type & 0x7) | (
			unit << 3)) << COLUMN_RULE_WIDTH_SHIFT);
	
	style->i.uncommon->i.column_rule_width = length;
	
	return CSS_OK;
}
#undef COLUMN_RULE_WIDTH_INDEX
#undef COLUMN_RULE_WIDTH_SHIFT
#undef COLUMN_RULE_WIDTH_MASK

#define COLUMN_SPAN_INDEX 3
#define COLUMN_SPAN_SHIFT 16
#define COLUMN_SPAN_MASK 0x30000

static inline css_error set_column_span(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[COLUMN_SPAN_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~COLUMN_SPAN_MASK) | (((uint32_t)type & 0x3) <<
			COLUMN_SPAN_SHIFT);
	
	return CSS_OK;
}
#undef COLUMN_SPAN_INDEX
#undef COLUMN_SPAN_SHIFT
#undef COLUMN_SPAN_MASK

#define COLUMN_WIDTH_INDEX 1
#define COLUMN_WIDTH_SHIFT 25
#define COLUMN_WIDTH_MASK 0xfe000000

static inline css_error set_column_width(css_computed_style *style, uint8_t
		type, css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[COLUMN_WIDTH_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~COLUMN_WIDTH_MASK) | ((((uint32_t)type & 0x3) | (unit
			<< 2)) << COLUMN_WIDTH_SHIFT);
	
	style->i.uncommon->i.column_width = length;
	
	return CSS_OK;
}
#undef COLUMN_WIDTH_INDEX
#undef COLUMN_WIDTH_SHIFT
#undef COLUMN_WIDTH_MASK

#define CONTENT_INDEX 3
#define CONTENT_SHIFT 22
#define CONTENT_MASK 0xc00000
static inline css_error set_content(
		css_computed_style *style, uint8_t type,
		css_computed_content_item *content)
{
	uint32_t *bits;
	css_computed_content_item *oldcontent;
	css_computed_content_item *c;

	ENSURE_UNCOMMON;

	/* 2bits: type */
	bits = &style->i.uncommon->i.bits[CONTENT_INDEX];
	oldcontent = style->i.uncommon->content;

	*bits = (*bits & ~CONTENT_MASK) |
			((type & 0x3) << CONTENT_SHIFT);

	for (c = content; c != NULL &&
			c->type != CSS_COMPUTED_CONTENT_NONE; c++) {
		switch (c->type) {
		case CSS_COMPUTED_CONTENT_STRING:
			c->data.string = lwc_string_ref(c->data.string);
			break;
		case CSS_COMPUTED_CONTENT_URI:
			c->data.uri = lwc_string_ref(c->data.uri);
			break;
		case CSS_COMPUTED_CONTENT_ATTR:
			c->data.attr = lwc_string_ref(c->data.attr);
			break;
		case CSS_COMPUTED_CONTENT_COUNTER:
			c->data.counter.name =
				lwc_string_ref(c->data.counter.name);
			break;
		case CSS_COMPUTED_CONTENT_COUNTERS:
			c->data.counters.name =
				lwc_string_ref(c->data.counters.name);
			c->data.counters.sep =
				lwc_string_ref(c->data.counters.sep);
			break;
		default:
			break;
		}
	}

	style->i.uncommon->content = content;

	/* Free existing array */
	if (oldcontent != NULL) {
		for (c = oldcontent;
				c->type != CSS_COMPUTED_CONTENT_NONE; c++) {
			switch (c->type) {
			case CSS_COMPUTED_CONTENT_STRING:
				lwc_string_unref(c->data.string);
				break;
			case CSS_COMPUTED_CONTENT_URI:
				lwc_string_unref(c->data.uri);
				break;
			case CSS_COMPUTED_CONTENT_ATTR:
				lwc_string_unref(c->data.attr);
				break;
			case CSS_COMPUTED_CONTENT_COUNTER:
				lwc_string_unref(c->data.counter.name);
				break;
			case CSS_COMPUTED_CONTENT_COUNTERS:
				lwc_string_unref(c->data.counters.name);
				lwc_string_unref(c->data.counters.sep);
				break;
			default:
				break;
			}
		}

		if (oldcontent != content)
			free(oldcontent);
	}

	return CSS_OK;
}
#undef CONTENT_INDEX
#undef CONTENT_SHIFT
#undef CONTENT_MASK

#define COUNTER_INCREMENT_INDEX 3
#define COUNTER_INCREMENT_SHIFT 11
#define COUNTER_INCREMENT_MASK 0x800

static inline css_error set_counter_increment(css_computed_style *style,
		uint8_t type, css_computed_counter *counter_arr)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[COUNTER_INCREMENT_INDEX];
	
	/* 1bit: t : type */
	*bits = (*bits & ~COUNTER_INCREMENT_MASK) | (((uint32_t)type & 0x1) <<
			COUNTER_INCREMENT_SHIFT);
	
	css_computed_counter *old_counter_arr =
			style->i.uncommon->counter_increment;
	css_computed_counter *c;
	
	for (c = counter_arr; c != NULL && c->name != NULL; c++)
		c->name = lwc_string_ref(c->name);
	
	style->i.uncommon->counter_increment = counter_arr;
	
	/* Free existing array */
	if (old_counter_arr != NULL) {
		for (c = old_counter_arr; c->name != NULL; c++)
			lwc_string_unref(c->name);
		
		if (old_counter_arr != counter_arr)
			free(old_counter_arr);
	}
	
	return CSS_OK;
}
#undef COUNTER_INCREMENT_INDEX
#undef COUNTER_INCREMENT_SHIFT
#undef COUNTER_INCREMENT_MASK

#define COUNTER_RESET_INDEX 3
#define COUNTER_RESET_SHIFT 10
#define COUNTER_RESET_MASK 0x400

static inline css_error set_counter_reset(css_computed_style *style, uint8_t
		type, css_computed_counter *counter_arr)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[COUNTER_RESET_INDEX];
	
	/* 1bit: t : type */
	*bits = (*bits & ~COUNTER_RESET_MASK) | (((uint32_t)type & 0x1) <<
			COUNTER_RESET_SHIFT);
	
	css_computed_counter *old_counter_arr =
			style->i.uncommon->counter_reset;
	css_computed_counter *c;
	
	for (c = counter_arr; c != NULL && c->name != NULL; c++)
		c->name = lwc_string_ref(c->name);
	
	style->i.uncommon->counter_reset = counter_arr;
	
	/* Free existing array */
	if (old_counter_arr != NULL) {
		for (c = old_counter_arr; c->name != NULL; c++)
			lwc_string_unref(c->name);
		
		if (old_counter_arr != counter_arr)
			free(old_counter_arr);
	}
	
	return CSS_OK;
}
#undef COUNTER_RESET_INDEX
#undef COUNTER_RESET_SHIFT
#undef COUNTER_RESET_MASK

#define CURSOR_INDEX 0
#define CURSOR_SHIFT 0
#define CURSOR_MASK 0x1f

static inline css_error set_cursor(css_computed_style *style, uint8_t type,
		lwc_string **string_arr)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[CURSOR_INDEX];
	
	/* 5bits: ttttt : type */
	*bits = (*bits & ~CURSOR_MASK) | (((uint32_t)type & 0x1f) <<
			CURSOR_SHIFT);
	
	lwc_string **old_string_arr = style->i.uncommon->cursor;
	lwc_string **s;
	
	for (s = string_arr; s != NULL && *s != NULL; s++)
		*s = lwc_string_ref(*s);
	
	style->i.uncommon->cursor = string_arr;
	
	/* Free existing array */
	if (old_string_arr != NULL) {
		for (s = old_string_arr; *s != NULL; s++)
			lwc_string_unref(*s);
		
		if (old_string_arr != string_arr)
			free(old_string_arr);
	}
	
	return CSS_OK;
}
#undef CURSOR_INDEX
#undef CURSOR_SHIFT
#undef CURSOR_MASK

#define LETTER_SPACING_INDEX 1
#define LETTER_SPACING_SHIFT 11
#define LETTER_SPACING_MASK 0x3f800

static inline css_error set_letter_spacing(css_computed_style *style, uint8_t
		type, css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[LETTER_SPACING_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~LETTER_SPACING_MASK) | ((((uint32_t)type & 0x3) | (
			unit << 2)) << LETTER_SPACING_SHIFT);
	
	style->i.uncommon->i.letter_spacing = length;
	
	return CSS_OK;
}
#undef LETTER_SPACING_INDEX
#undef LETTER_SPACING_SHIFT
#undef LETTER_SPACING_MASK

#define OUTLINE_COLOR_INDEX 3
#define OUTLINE_COLOR_SHIFT 12
#define OUTLINE_COLOR_MASK 0x3000

static inline css_error set_outline_color(css_computed_style *style, uint8_t
		type, css_color color)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[OUTLINE_COLOR_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~OUTLINE_COLOR_MASK) | (((uint32_t)type & 0x3) <<
			OUTLINE_COLOR_SHIFT);
	
	style->i.uncommon->i.outline_color = color;
	
	return CSS_OK;
}
#undef OUTLINE_COLOR_INDEX
#undef OUTLINE_COLOR_SHIFT
#undef OUTLINE_COLOR_MASK

#define OUTLINE_WIDTH_INDEX 0
#define OUTLINE_WIDTH_SHIFT 13
#define OUTLINE_WIDTH_MASK 0x1fe000

static inline css_error set_outline_width(css_computed_style *style, uint8_t
		type, css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[OUTLINE_WIDTH_INDEX];
	
	/* 8bits: uuuuuttt : unit | type */
	*bits = (*bits & ~OUTLINE_WIDTH_MASK) | ((((uint32_t)type & 0x7) | (
			unit << 3)) << OUTLINE_WIDTH_SHIFT);
	
	style->i.uncommon->i.outline_width = length;
	
	return CSS_OK;
}
#undef OUTLINE_WIDTH_INDEX
#undef OUTLINE_WIDTH_SHIFT
#undef OUTLINE_WIDTH_MASK

#define WORD_SPACING_INDEX 1
#define WORD_SPACING_SHIFT 4
#define WORD_SPACING_MASK 0x7f0

static inline css_error set_word_spacing(css_computed_style *style, uint8_t
		type, css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[WORD_SPACING_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~WORD_SPACING_MASK) | ((((uint32_t)type & 0x3) | (unit
			<< 2)) << WORD_SPACING_SHIFT);
	
	style->i.uncommon->i.word_spacing = length;
	
	return CSS_OK;
}
#undef WORD_SPACING_INDEX
#undef WORD_SPACING_SHIFT
#undef WORD_SPACING_MASK

#define WRITING_MODE_INDEX 3
#define WRITING_MODE_SHIFT 20
#define WRITING_MODE_MASK 0x300000

static inline css_error set_writing_mode(css_computed_style *style, uint8_t
		type)
{
	uint32_t *bits;
	
	ENSURE_UNCOMMON;
	
	bits = &style->i.uncommon->i.bits[WRITING_MODE_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~WRITING_MODE_MASK) | (((uint32_t)type & 0x3) <<
			WRITING_MODE_SHIFT);
	
	return CSS_OK;
}
#undef WRITING_MODE_INDEX
#undef WRITING_MODE_SHIFT
#undef WRITING_MODE_MASK
static const css_computed_page default_page = {
	.bits = {
		(CSS_PAGE_BREAK_BEFORE_AUTO << 29) | (CSS_PAGE_BREAK_AFTER_AUTO
				<< 26) | (CSS_PAGE_BREAK_INSIDE_AUTO << 24) | (
				CSS_WIDOWS_SET << 23) | (CSS_ORPHANS_SET << 22)
	},
	.orphans = 2,
	.widows = 2
};

#define ENSURE_PAGE do {						\
	if (style->page == NULL) {					\
		style->page = malloc(sizeof(css_computed_page));	\
		if (style->page == NULL)				\
			return CSS_NOMEM;				\
									\
		memcpy(style->page, &default_page, sizeof(		\
				css_computed_page));			\
	}								\
} while(0)								\


#define ORPHANS_INDEX 0
#define ORPHANS_SHIFT 22
#define ORPHANS_MASK 0x400000

static inline css_error set_orphans(css_computed_style *style, uint8_t type,
		int32_t integer)
{
	uint32_t *bits;
	
	ENSURE_PAGE;
	
	bits = &style->page->bits[ORPHANS_INDEX];
	
	/* 1bit: t : type */
	*bits = (*bits & ~ORPHANS_MASK) | (((uint32_t)type & 0x1) <<
			ORPHANS_SHIFT);
	
	style->page->orphans = integer;
	
	return CSS_OK;
}
#undef ORPHANS_INDEX
#undef ORPHANS_SHIFT
#undef ORPHANS_MASK

#define PAGE_BREAK_AFTER_INDEX 0
#define PAGE_BREAK_AFTER_SHIFT 26
#define PAGE_BREAK_AFTER_MASK 0x1c000000

static inline css_error set_page_break_after(css_computed_style *style, uint8_t
		type)
{
	uint32_t *bits;
	
	ENSURE_PAGE;
	
	bits = &style->page->bits[PAGE_BREAK_AFTER_INDEX];
	
	/* 3bits: ttt : type */
	*bits = (*bits & ~PAGE_BREAK_AFTER_MASK) | (((uint32_t)type & 0x7) <<
			PAGE_BREAK_AFTER_SHIFT);
	
	return CSS_OK;
}
#undef PAGE_BREAK_AFTER_INDEX
#undef PAGE_BREAK_AFTER_SHIFT
#undef PAGE_BREAK_AFTER_MASK

#define PAGE_BREAK_BEFORE_INDEX 0
#define PAGE_BREAK_BEFORE_SHIFT 29
#define PAGE_BREAK_BEFORE_MASK 0xe0000000

static inline css_error set_page_break_before(css_computed_style *style,
		uint8_t type)
{
	uint32_t *bits;
	
	ENSURE_PAGE;
	
	bits = &style->page->bits[PAGE_BREAK_BEFORE_INDEX];
	
	/* 3bits: ttt : type */
	*bits = (*bits & ~PAGE_BREAK_BEFORE_MASK) | (((uint32_t)type & 0x7) <<
			PAGE_BREAK_BEFORE_SHIFT);
	
	return CSS_OK;
}
#undef PAGE_BREAK_BEFORE_INDEX
#undef PAGE_BREAK_BEFORE_SHIFT
#undef PAGE_BREAK_BEFORE_MASK

#define PAGE_BREAK_INSIDE_INDEX 0
#define PAGE_BREAK_INSIDE_SHIFT 24
#define PAGE_BREAK_INSIDE_MASK 0x3000000

static inline css_error set_page_break_inside(css_computed_style *style,
		uint8_t type)
{
	uint32_t *bits;
	
	ENSURE_PAGE;
	
	bits = &style->page->bits[PAGE_BREAK_INSIDE_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~PAGE_BREAK_INSIDE_MASK) | (((uint32_t)type & 0x3) <<
			PAGE_BREAK_INSIDE_SHIFT);
	
	return CSS_OK;
}
#undef PAGE_BREAK_INSIDE_INDEX
#undef PAGE_BREAK_INSIDE_SHIFT
#undef PAGE_BREAK_INSIDE_MASK

#define WIDOWS_INDEX 0
#define WIDOWS_SHIFT 23
#define WIDOWS_MASK 0x800000

static inline css_error set_widows(css_computed_style *style, uint8_t type,
		int32_t integer)
{
	uint32_t *bits;
	
	ENSURE_PAGE;
	
	bits = &style->page->bits[WIDOWS_INDEX];
	
	/* 1bit: t : type */
	*bits = (*bits & ~WIDOWS_MASK) | (((uint32_t)type & 0x1) <<
			WIDOWS_SHIFT);
	
	style->page->widows = integer;
	
	return CSS_OK;
}
#undef WIDOWS_INDEX
#undef WIDOWS_SHIFT
#undef WIDOWS_MASK

#define ALIGN_CONTENT_INDEX 8
#define ALIGN_CONTENT_SHIFT 14
#define ALIGN_CONTENT_MASK 0x1c000

static inline css_error set_align_content(css_computed_style *style, uint8_t
		type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[ALIGN_CONTENT_INDEX];
	
	/* 3bits: ttt : type */
	*bits = (*bits & ~ALIGN_CONTENT_MASK) | (((uint32_t)type & 0x7) <<
			ALIGN_CONTENT_SHIFT);
	
	return CSS_OK;
}
#undef ALIGN_CONTENT_INDEX
#undef ALIGN_CONTENT_SHIFT
#undef ALIGN_CONTENT_MASK

#define ALIGN_ITEMS_INDEX 8
#define ALIGN_ITEMS_SHIFT 23
#define ALIGN_ITEMS_MASK 0x3800000

static inline css_error set_align_items(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[ALIGN_ITEMS_INDEX];
	
	/* 3bits: ttt : type */
	*bits = (*bits & ~ALIGN_ITEMS_MASK) | (((uint32_t)type & 0x7) <<
			ALIGN_ITEMS_SHIFT);
	
	return CSS_OK;
}
#undef ALIGN_ITEMS_INDEX
#undef ALIGN_ITEMS_SHIFT
#undef ALIGN_ITEMS_MASK

#define ALIGN_SELF_INDEX 8
#define ALIGN_SELF_SHIFT 20
#define ALIGN_SELF_MASK 0x700000

static inline css_error set_align_self(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[ALIGN_SELF_INDEX];
	
	/* 3bits: ttt : type */
	*bits = (*bits & ~ALIGN_SELF_MASK) | (((uint32_t)type & 0x7) <<
			ALIGN_SELF_SHIFT);
	
	return CSS_OK;
}
#undef ALIGN_SELF_INDEX
#undef ALIGN_SELF_SHIFT
#undef ALIGN_SELF_MASK

#define BACKGROUND_ATTACHMENT_INDEX 9
#define BACKGROUND_ATTACHMENT_SHIFT 6
#define BACKGROUND_ATTACHMENT_MASK 0xc0

static inline css_error set_background_attachment(css_computed_style *style,
		uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BACKGROUND_ATTACHMENT_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~BACKGROUND_ATTACHMENT_MASK) | (((uint32_t)type & 0x3)
			<< BACKGROUND_ATTACHMENT_SHIFT);
	
	return CSS_OK;
}
#undef BACKGROUND_ATTACHMENT_INDEX
#undef BACKGROUND_ATTACHMENT_SHIFT
#undef BACKGROUND_ATTACHMENT_MASK

#define BACKGROUND_COLOR_INDEX 9
#define BACKGROUND_COLOR_SHIFT 14
#define BACKGROUND_COLOR_MASK 0xc000

static inline css_error set_background_color(css_computed_style *style, uint8_t
		type, css_color color)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BACKGROUND_COLOR_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~BACKGROUND_COLOR_MASK) | (((uint32_t)type & 0x3) <<
			BACKGROUND_COLOR_SHIFT);
	
	style->i.background_color = color;
	
	return CSS_OK;
}
#undef BACKGROUND_COLOR_INDEX
#undef BACKGROUND_COLOR_SHIFT
#undef BACKGROUND_COLOR_MASK

#define BACKGROUND_IMAGE_INDEX 10
#define BACKGROUND_IMAGE_SHIFT 25
#define BACKGROUND_IMAGE_MASK 0x2000000

static inline css_error set_background_image(css_computed_style *style, uint8_t
		type, lwc_string *string)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BACKGROUND_IMAGE_INDEX];
	
	/* 1bit: t : type */
	*bits = (*bits & ~BACKGROUND_IMAGE_MASK) | (((uint32_t)type & 0x1) <<
			BACKGROUND_IMAGE_SHIFT);
	
	lwc_string *old_string = style->i.background_image;
	
	if (string != NULL) {
		style->i.background_image = lwc_string_ref(string);
	} else {
		style->i.background_image = NULL;
	}
	
	if (old_string != NULL)
		lwc_string_unref(old_string);
	
	return CSS_OK;
}
#undef BACKGROUND_IMAGE_INDEX
#undef BACKGROUND_IMAGE_SHIFT
#undef BACKGROUND_IMAGE_MASK

#define BACKGROUND_POSITION_INDEX 5
#define BACKGROUND_POSITION_SHIFT 21
#define BACKGROUND_POSITION_MASK 0xffe00000

static inline css_error set_background_position(css_computed_style *style,
		uint8_t type, css_fixed length_a, css_unit unit_a, css_fixed
		length_b, css_unit unit_b)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BACKGROUND_POSITION_INDEX];
	
	/* 11bits: aaaaabbbbbt : unit_a | unit_b | type */
	*bits = (*bits & ~BACKGROUND_POSITION_MASK) | ((((uint32_t)type & 0x1)
			| (unit_b << 1) | (unit_a << 6)) <<
			BACKGROUND_POSITION_SHIFT);
	
	style->i.background_position_a = length_a;
	
	style->i.background_position_b = length_b;
	
	return CSS_OK;
}
#undef BACKGROUND_POSITION_INDEX
#undef BACKGROUND_POSITION_SHIFT
#undef BACKGROUND_POSITION_MASK

#define BACKGROUND_REPEAT_INDEX 8
#define BACKGROUND_REPEAT_SHIFT 17
#define BACKGROUND_REPEAT_MASK 0xe0000

static inline css_error set_background_repeat(css_computed_style *style,
		uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BACKGROUND_REPEAT_INDEX];
	
	/* 3bits: ttt : type */
	*bits = (*bits & ~BACKGROUND_REPEAT_MASK) | (((uint32_t)type & 0x7) <<
			BACKGROUND_REPEAT_SHIFT);
	
	return CSS_OK;
}
#undef BACKGROUND_REPEAT_INDEX
#undef BACKGROUND_REPEAT_SHIFT
#undef BACKGROUND_REPEAT_MASK

#define BORDER_BOTTOM_COLOR_INDEX 9
#define BORDER_BOTTOM_COLOR_SHIFT 4
#define BORDER_BOTTOM_COLOR_MASK 0x30

static inline css_error set_border_bottom_color(css_computed_style *style,
		uint8_t type, css_color color)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BORDER_BOTTOM_COLOR_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~BORDER_BOTTOM_COLOR_MASK) | (((uint32_t)type & 0x3)
			<< BORDER_BOTTOM_COLOR_SHIFT);
	
	style->i.border_bottom_color = color;
	
	return CSS_OK;
}
#undef BORDER_BOTTOM_COLOR_INDEX
#undef BORDER_BOTTOM_COLOR_SHIFT
#undef BORDER_BOTTOM_COLOR_MASK

#define BORDER_BOTTOM_STYLE_INDEX 6
#define BORDER_BOTTOM_STYLE_SHIFT 6
#define BORDER_BOTTOM_STYLE_MASK 0x3c0

static inline css_error set_border_bottom_style(css_computed_style *style,
		uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BORDER_BOTTOM_STYLE_INDEX];
	
	/* 4bits: tttt : type */
	*bits = (*bits & ~BORDER_BOTTOM_STYLE_MASK) | (((uint32_t)type & 0xf)
			<< BORDER_BOTTOM_STYLE_SHIFT);
	
	return CSS_OK;
}
#undef BORDER_BOTTOM_STYLE_INDEX
#undef BORDER_BOTTOM_STYLE_SHIFT
#undef BORDER_BOTTOM_STYLE_MASK

#define BORDER_BOTTOM_WIDTH_INDEX 0
#define BORDER_BOTTOM_WIDTH_SHIFT 16
#define BORDER_BOTTOM_WIDTH_MASK 0xff0000

static inline css_error set_border_bottom_width(css_computed_style *style,
		uint8_t type, css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BORDER_BOTTOM_WIDTH_INDEX];
	
	/* 8bits: uuuuuttt : unit | type */
	*bits = (*bits & ~BORDER_BOTTOM_WIDTH_MASK) | ((((uint32_t)type & 0x7)
			| (unit << 3)) << BORDER_BOTTOM_WIDTH_SHIFT);
	
	style->i.border_bottom_width = length;
	
	return CSS_OK;
}
#undef BORDER_BOTTOM_WIDTH_INDEX
#undef BORDER_BOTTOM_WIDTH_SHIFT
#undef BORDER_BOTTOM_WIDTH_MASK

#define BORDER_COLLAPSE_INDEX 9
#define BORDER_COLLAPSE_SHIFT 26
#define BORDER_COLLAPSE_MASK 0xc000000

static inline css_error set_border_collapse(css_computed_style *style, uint8_t
		type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BORDER_COLLAPSE_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~BORDER_COLLAPSE_MASK) | (((uint32_t)type & 0x3) <<
			BORDER_COLLAPSE_SHIFT);
	
	return CSS_OK;
}
#undef BORDER_COLLAPSE_INDEX
#undef BORDER_COLLAPSE_SHIFT
#undef BORDER_COLLAPSE_MASK

#define BORDER_LEFT_COLOR_INDEX 9
#define BORDER_LEFT_COLOR_SHIFT 24
#define BORDER_LEFT_COLOR_MASK 0x3000000

static inline css_error set_border_left_color(css_computed_style *style,
		uint8_t type, css_color color)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BORDER_LEFT_COLOR_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~BORDER_LEFT_COLOR_MASK) | (((uint32_t)type & 0x3) <<
			BORDER_LEFT_COLOR_SHIFT);
	
	style->i.border_left_color = color;
	
	return CSS_OK;
}
#undef BORDER_LEFT_COLOR_INDEX
#undef BORDER_LEFT_COLOR_SHIFT
#undef BORDER_LEFT_COLOR_MASK

#define BORDER_LEFT_STYLE_INDEX 4
#define BORDER_LEFT_STYLE_SHIFT 0
#define BORDER_LEFT_STYLE_MASK 0xf

static inline css_error set_border_left_style(css_computed_style *style,
		uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BORDER_LEFT_STYLE_INDEX];
	
	/* 4bits: tttt : type */
	*bits = (*bits & ~BORDER_LEFT_STYLE_MASK) | (((uint32_t)type & 0xf) <<
			BORDER_LEFT_STYLE_SHIFT);
	
	return CSS_OK;
}
#undef BORDER_LEFT_STYLE_INDEX
#undef BORDER_LEFT_STYLE_SHIFT
#undef BORDER_LEFT_STYLE_MASK

#define BORDER_LEFT_WIDTH_INDEX 0
#define BORDER_LEFT_WIDTH_SHIFT 0
#define BORDER_LEFT_WIDTH_MASK 0xff

static inline css_error set_border_left_width(css_computed_style *style,
		uint8_t type, css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BORDER_LEFT_WIDTH_INDEX];
	
	/* 8bits: uuuuuttt : unit | type */
	*bits = (*bits & ~BORDER_LEFT_WIDTH_MASK) | ((((uint32_t)type & 0x7) | (
			unit << 3)) << BORDER_LEFT_WIDTH_SHIFT);
	
	style->i.border_left_width = length;
	
	return CSS_OK;
}
#undef BORDER_LEFT_WIDTH_INDEX
#undef BORDER_LEFT_WIDTH_SHIFT
#undef BORDER_LEFT_WIDTH_MASK

#define BORDER_RIGHT_COLOR_INDEX 9
#define BORDER_RIGHT_COLOR_SHIFT 30
#define BORDER_RIGHT_COLOR_MASK 0xc0000000

static inline css_error set_border_right_color(css_computed_style *style,
		uint8_t type, css_color color)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BORDER_RIGHT_COLOR_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~BORDER_RIGHT_COLOR_MASK) | (((uint32_t)type & 0x3) <<
			BORDER_RIGHT_COLOR_SHIFT);
	
	style->i.border_right_color = color;
	
	return CSS_OK;
}
#undef BORDER_RIGHT_COLOR_INDEX
#undef BORDER_RIGHT_COLOR_SHIFT
#undef BORDER_RIGHT_COLOR_MASK

#define BORDER_RIGHT_STYLE_INDEX 6
#define BORDER_RIGHT_STYLE_SHIFT 14
#define BORDER_RIGHT_STYLE_MASK 0x3c000

static inline css_error set_border_right_style(css_computed_style *style,
		uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BORDER_RIGHT_STYLE_INDEX];
	
	/* 4bits: tttt : type */
	*bits = (*bits & ~BORDER_RIGHT_STYLE_MASK) | (((uint32_t)type & 0xf) <<
			BORDER_RIGHT_STYLE_SHIFT);
	
	return CSS_OK;
}
#undef BORDER_RIGHT_STYLE_INDEX
#undef BORDER_RIGHT_STYLE_SHIFT
#undef BORDER_RIGHT_STYLE_MASK

#define BORDER_RIGHT_WIDTH_INDEX 0
#define BORDER_RIGHT_WIDTH_SHIFT 8
#define BORDER_RIGHT_WIDTH_MASK 0xff00

static inline css_error set_border_right_width(css_computed_style *style,
		uint8_t type, css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BORDER_RIGHT_WIDTH_INDEX];
	
	/* 8bits: uuuuuttt : unit | type */
	*bits = (*bits & ~BORDER_RIGHT_WIDTH_MASK) | ((((uint32_t)type & 0x7) |
			(unit << 3)) << BORDER_RIGHT_WIDTH_SHIFT);
	
	style->i.border_right_width = length;
	
	return CSS_OK;
}
#undef BORDER_RIGHT_WIDTH_INDEX
#undef BORDER_RIGHT_WIDTH_SHIFT
#undef BORDER_RIGHT_WIDTH_MASK

#define BORDER_TOP_COLOR_INDEX 8
#define BORDER_TOP_COLOR_SHIFT 0
#define BORDER_TOP_COLOR_MASK 0x3

static inline css_error set_border_top_color(css_computed_style *style, uint8_t
		type, css_color color)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BORDER_TOP_COLOR_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~BORDER_TOP_COLOR_MASK) | (((uint32_t)type & 0x3) <<
			BORDER_TOP_COLOR_SHIFT);
	
	style->i.border_top_color = color;
	
	return CSS_OK;
}
#undef BORDER_TOP_COLOR_INDEX
#undef BORDER_TOP_COLOR_SHIFT
#undef BORDER_TOP_COLOR_MASK

#define BORDER_TOP_STYLE_INDEX 6
#define BORDER_TOP_STYLE_SHIFT 10
#define BORDER_TOP_STYLE_MASK 0x3c00

static inline css_error set_border_top_style(css_computed_style *style, uint8_t
		type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BORDER_TOP_STYLE_INDEX];
	
	/* 4bits: tttt : type */
	*bits = (*bits & ~BORDER_TOP_STYLE_MASK) | (((uint32_t)type & 0xf) <<
			BORDER_TOP_STYLE_SHIFT);
	
	return CSS_OK;
}
#undef BORDER_TOP_STYLE_INDEX
#undef BORDER_TOP_STYLE_SHIFT
#undef BORDER_TOP_STYLE_MASK

#define BORDER_TOP_WIDTH_INDEX 0
#define BORDER_TOP_WIDTH_SHIFT 24
#define BORDER_TOP_WIDTH_MASK 0xff000000

static inline css_error set_border_top_width(css_computed_style *style, uint8_t
		type, css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BORDER_TOP_WIDTH_INDEX];
	
	/* 8bits: uuuuuttt : unit | type */
	*bits = (*bits & ~BORDER_TOP_WIDTH_MASK) | ((((uint32_t)type & 0x7) | (
			unit << 3)) << BORDER_TOP_WIDTH_SHIFT);
	
	style->i.border_top_width = length;
	
	return CSS_OK;
}
#undef BORDER_TOP_WIDTH_INDEX
#undef BORDER_TOP_WIDTH_SHIFT
#undef BORDER_TOP_WIDTH_MASK

#define BOTTOM_INDEX 4
#define BOTTOM_SHIFT 11
#define BOTTOM_MASK 0x3f800

static inline css_error set_bottom(css_computed_style *style, uint8_t type,
		css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BOTTOM_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~BOTTOM_MASK) | ((((uint32_t)type & 0x3) | (unit <<
			2)) << BOTTOM_SHIFT);
	
	style->i.bottom = length;
	
	return CSS_OK;
}
#undef BOTTOM_INDEX
#undef BOTTOM_SHIFT
#undef BOTTOM_MASK

#define BOX_SIZING_INDEX 9
#define BOX_SIZING_SHIFT 12
#define BOX_SIZING_MASK 0x3000

static inline css_error set_box_sizing(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[BOX_SIZING_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~BOX_SIZING_MASK) | (((uint32_t)type & 0x3) <<
			BOX_SIZING_SHIFT);
	
	return CSS_OK;
}
#undef BOX_SIZING_INDEX
#undef BOX_SIZING_SHIFT
#undef BOX_SIZING_MASK

#define CAPTION_SIDE_INDEX 9
#define CAPTION_SIDE_SHIFT 20
#define CAPTION_SIDE_MASK 0x300000

static inline css_error set_caption_side(css_computed_style *style, uint8_t
		type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[CAPTION_SIDE_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~CAPTION_SIDE_MASK) | (((uint32_t)type & 0x3) <<
			CAPTION_SIDE_SHIFT);
	
	return CSS_OK;
}
#undef CAPTION_SIDE_INDEX
#undef CAPTION_SIDE_SHIFT
#undef CAPTION_SIDE_MASK

#define CLEAR_INDEX 8
#define CLEAR_SHIFT 2
#define CLEAR_MASK 0x1c

static inline css_error set_clear(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[CLEAR_INDEX];
	
	/* 3bits: ttt : type */
	*bits = (*bits & ~CLEAR_MASK) | (((uint32_t)type & 0x7) << CLEAR_SHIFT);
	
	return CSS_OK;
}
#undef CLEAR_INDEX
#undef CLEAR_SHIFT
#undef CLEAR_MASK

#define COLOR_INDEX 10
#define COLOR_SHIFT 24
#define COLOR_MASK 0x1000000

static inline css_error set_color(css_computed_style *style, uint8_t type,
		css_color color)
{
	uint32_t *bits;
	
	bits = &style->i.bits[COLOR_INDEX];
	
	/* 1bit: t : type */
	*bits = (*bits & ~COLOR_MASK) | (((uint32_t)type & 0x1) << COLOR_SHIFT);
	
	style->i.color = color;
	
	return CSS_OK;
}
#undef COLOR_INDEX
#undef COLOR_SHIFT
#undef COLOR_MASK

#define DIRECTION_INDEX 9
#define DIRECTION_SHIFT 22
#define DIRECTION_MASK 0xc00000

static inline css_error set_direction(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[DIRECTION_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~DIRECTION_MASK) | (((uint32_t)type & 0x3) <<
			DIRECTION_SHIFT);
	
	return CSS_OK;
}
#undef DIRECTION_INDEX
#undef DIRECTION_SHIFT
#undef DIRECTION_MASK

#define DISPLAY_INDEX 6
#define DISPLAY_SHIFT 27
#define DISPLAY_MASK 0xf8000000

static inline css_error set_display(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[DISPLAY_INDEX];
	
	/* 5bits: ttttt : type */
	*bits = (*bits & ~DISPLAY_MASK) | (((uint32_t)type & 0x1f) <<
			DISPLAY_SHIFT);
	
	return CSS_OK;
}
#undef DISPLAY_INDEX
#undef DISPLAY_SHIFT
#undef DISPLAY_MASK

#define EMPTY_CELLS_INDEX 9
#define EMPTY_CELLS_SHIFT 18
#define EMPTY_CELLS_MASK 0xc0000

static inline css_error set_empty_cells(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[EMPTY_CELLS_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~EMPTY_CELLS_MASK) | (((uint32_t)type & 0x3) <<
			EMPTY_CELLS_SHIFT);
	
	return CSS_OK;
}
#undef EMPTY_CELLS_INDEX
#undef EMPTY_CELLS_SHIFT
#undef EMPTY_CELLS_MASK

#define FLEX_BASIS_INDEX 2
#define FLEX_BASIS_SHIFT 11
#define FLEX_BASIS_MASK 0x3f800

static inline css_error set_flex_basis(css_computed_style *style, uint8_t type,
		css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[FLEX_BASIS_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~FLEX_BASIS_MASK) | ((((uint32_t)type & 0x3) | (unit
			<< 2)) << FLEX_BASIS_SHIFT);
	
	style->i.flex_basis = length;
	
	return CSS_OK;
}
#undef FLEX_BASIS_INDEX
#undef FLEX_BASIS_SHIFT
#undef FLEX_BASIS_MASK

#define FLEX_DIRECTION_INDEX 8
#define FLEX_DIRECTION_SHIFT 11
#define FLEX_DIRECTION_MASK 0x3800

static inline css_error set_flex_direction(css_computed_style *style, uint8_t
		type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[FLEX_DIRECTION_INDEX];
	
	/* 3bits: ttt : type */
	*bits = (*bits & ~FLEX_DIRECTION_MASK) | (((uint32_t)type & 0x7) <<
			FLEX_DIRECTION_SHIFT);
	
	return CSS_OK;
}
#undef FLEX_DIRECTION_INDEX
#undef FLEX_DIRECTION_SHIFT
#undef FLEX_DIRECTION_MASK

#define FLEX_GROW_INDEX 10
#define FLEX_GROW_SHIFT 21
#define FLEX_GROW_MASK 0x200000

static inline css_error set_flex_grow(css_computed_style *style, uint8_t type,
		css_fixed fixed)
{
	uint32_t *bits;
	
	bits = &style->i.bits[FLEX_GROW_INDEX];
	
	/* 1bit: t : type */
	*bits = (*bits & ~FLEX_GROW_MASK) | (((uint32_t)type & 0x1) <<
			FLEX_GROW_SHIFT);
	
	style->i.flex_grow = fixed;
	
	return CSS_OK;
}
#undef FLEX_GROW_INDEX
#undef FLEX_GROW_SHIFT
#undef FLEX_GROW_MASK

#define FLEX_SHRINK_INDEX 10
#define FLEX_SHRINK_SHIFT 23
#define FLEX_SHRINK_MASK 0x800000

static inline css_error set_flex_shrink(css_computed_style *style, uint8_t
		type, css_fixed fixed)
{
	uint32_t *bits;
	
	bits = &style->i.bits[FLEX_SHRINK_INDEX];
	
	/* 1bit: t : type */
	*bits = (*bits & ~FLEX_SHRINK_MASK) | (((uint32_t)type & 0x1) <<
			FLEX_SHRINK_SHIFT);
	
	style->i.flex_shrink = fixed;
	
	return CSS_OK;
}
#undef FLEX_SHRINK_INDEX
#undef FLEX_SHRINK_SHIFT
#undef FLEX_SHRINK_MASK

#define FLEX_WRAP_INDEX 9
#define FLEX_WRAP_SHIFT 28
#define FLEX_WRAP_MASK 0x30000000

static inline css_error set_flex_wrap(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[FLEX_WRAP_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~FLEX_WRAP_MASK) | (((uint32_t)type & 0x3) <<
			FLEX_WRAP_SHIFT);
	
	return CSS_OK;
}
#undef FLEX_WRAP_INDEX
#undef FLEX_WRAP_SHIFT
#undef FLEX_WRAP_MASK

#define FLOAT_INDEX 9
#define FLOAT_SHIFT 8
#define FLOAT_MASK 0x300

static inline css_error set_float(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[FLOAT_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~FLOAT_MASK) | (((uint32_t)type & 0x3) << FLOAT_SHIFT);
	
	return CSS_OK;
}
#undef FLOAT_INDEX
#undef FLOAT_SHIFT
#undef FLOAT_MASK

#define FONT_FAMILY_INDEX 8
#define FONT_FAMILY_SHIFT 26
#define FONT_FAMILY_MASK 0x1c000000

static inline css_error set_font_family(css_computed_style *style, uint8_t
		type, lwc_string **string_arr)
{
	uint32_t *bits;
	
	bits = &style->i.bits[FONT_FAMILY_INDEX];
	
	/* 3bits: ttt : type */
	*bits = (*bits & ~FONT_FAMILY_MASK) | (((uint32_t)type & 0x7) <<
			FONT_FAMILY_SHIFT);
	
	lwc_string **old_string_arr = style->font_family;
	lwc_string **s;
	
	for (s = string_arr; s != NULL && *s != NULL; s++)
		*s = lwc_string_ref(*s);
	
	style->font_family = string_arr;
	
	/* Free existing array */
	if (old_string_arr != NULL) {
		for (s = old_string_arr; *s != NULL; s++)
			lwc_string_unref(*s);
		
		if (old_string_arr != string_arr)
			free(old_string_arr);
	}
	
	return CSS_OK;
}
#undef FONT_FAMILY_INDEX
#undef FONT_FAMILY_SHIFT
#undef FONT_FAMILY_MASK

#define FONT_SIZE_INDEX 5
#define FONT_SIZE_SHIFT 3
#define FONT_SIZE_MASK 0xff8

static inline css_error set_font_size(css_computed_style *style, uint8_t type,
		css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[FONT_SIZE_INDEX];
	
	/* 9bits: uuuuutttt : unit | type */
	*bits = (*bits & ~FONT_SIZE_MASK) | ((((uint32_t)type & 0xf) | (unit <<
			4)) << FONT_SIZE_SHIFT);
	
	style->i.font_size = length;
	
	return CSS_OK;
}
#undef FONT_SIZE_INDEX
#undef FONT_SIZE_SHIFT
#undef FONT_SIZE_MASK

#define FONT_STYLE_INDEX 7
#define FONT_STYLE_SHIFT 0
#define FONT_STYLE_MASK 0x3

static inline css_error set_font_style(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[FONT_STYLE_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~FONT_STYLE_MASK) | (((uint32_t)type & 0x3) <<
			FONT_STYLE_SHIFT);
	
	return CSS_OK;
}
#undef FONT_STYLE_INDEX
#undef FONT_STYLE_SHIFT
#undef FONT_STYLE_MASK

#define FONT_VARIANT_INDEX 9
#define FONT_VARIANT_SHIFT 10
#define FONT_VARIANT_MASK 0xc00

static inline css_error set_font_variant(css_computed_style *style, uint8_t
		type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[FONT_VARIANT_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~FONT_VARIANT_MASK) | (((uint32_t)type & 0x3) <<
			FONT_VARIANT_SHIFT);
	
	return CSS_OK;
}
#undef FONT_VARIANT_INDEX
#undef FONT_VARIANT_SHIFT
#undef FONT_VARIANT_MASK

#define FONT_WEIGHT_INDEX 3
#define FONT_WEIGHT_SHIFT 0
#define FONT_WEIGHT_MASK 0xf

static inline css_error set_font_weight(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[FONT_WEIGHT_INDEX];
	
	/* 4bits: tttt : type */
	*bits = (*bits & ~FONT_WEIGHT_MASK) | (((uint32_t)type & 0xf) <<
			FONT_WEIGHT_SHIFT);
	
	return CSS_OK;
}
#undef FONT_WEIGHT_INDEX
#undef FONT_WEIGHT_SHIFT
#undef FONT_WEIGHT_MASK

#define HEIGHT_INDEX 4
#define HEIGHT_SHIFT 4
#define HEIGHT_MASK 0x7f0

static inline css_error set_height(css_computed_style *style, uint8_t type,
		css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[HEIGHT_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~HEIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit <<
			2)) << HEIGHT_SHIFT);
	
	style->i.height = length;
	
	return CSS_OK;
}
#undef HEIGHT_INDEX
#undef HEIGHT_SHIFT
#undef HEIGHT_MASK

#define JUSTIFY_CONTENT_INDEX 8
#define JUSTIFY_CONTENT_SHIFT 8
#define JUSTIFY_CONTENT_MASK 0x700

static inline css_error set_justify_content(css_computed_style *style, uint8_t
		type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[JUSTIFY_CONTENT_INDEX];
	
	/* 3bits: ttt : type */
	*bits = (*bits & ~JUSTIFY_CONTENT_MASK) | (((uint32_t)type & 0x7) <<
			JUSTIFY_CONTENT_SHIFT);
	
	return CSS_OK;
}
#undef JUSTIFY_CONTENT_INDEX
#undef JUSTIFY_CONTENT_SHIFT
#undef JUSTIFY_CONTENT_MASK

#define LEFT_INDEX 4
#define LEFT_SHIFT 25
#define LEFT_MASK 0xfe000000

static inline css_error set_left(css_computed_style *style, uint8_t type,
		css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[LEFT_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~LEFT_MASK) | ((((uint32_t)type & 0x3) | (unit << 2))
			<< LEFT_SHIFT);
	
	style->i.left = length;
	
	return CSS_OK;
}
#undef LEFT_INDEX
#undef LEFT_SHIFT
#undef LEFT_MASK

#define LINE_HEIGHT_INDEX 1
#define LINE_HEIGHT_SHIFT 25
#define LINE_HEIGHT_MASK 0xfe000000

static inline css_error set_line_height(css_computed_style *style, uint8_t
		type, css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[LINE_HEIGHT_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~LINE_HEIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit
			<< 2)) << LINE_HEIGHT_SHIFT);
	
	style->i.line_height = length;
	
	return CSS_OK;
}
#undef LINE_HEIGHT_INDEX
#undef LINE_HEIGHT_SHIFT
#undef LINE_HEIGHT_MASK

#define LIST_STYLE_IMAGE_INDEX 10
#define LIST_STYLE_IMAGE_SHIFT 26
#define LIST_STYLE_IMAGE_MASK 0x4000000

static inline css_error set_list_style_image(css_computed_style *style, uint8_t
		type, lwc_string *string)
{
	uint32_t *bits;
	
	bits = &style->i.bits[LIST_STYLE_IMAGE_INDEX];
	
	/* 1bit: t : type */
	*bits = (*bits & ~LIST_STYLE_IMAGE_MASK) | (((uint32_t)type & 0x1) <<
			LIST_STYLE_IMAGE_SHIFT);
	
	lwc_string *old_string = style->i.list_style_image;
	
	if (string != NULL) {
		style->i.list_style_image = lwc_string_ref(string);
	} else {
		style->i.list_style_image = NULL;
	}
	
	if (old_string != NULL)
		lwc_string_unref(old_string);
	
	return CSS_OK;
}
#undef LIST_STYLE_IMAGE_INDEX
#undef LIST_STYLE_IMAGE_SHIFT
#undef LIST_STYLE_IMAGE_MASK

#define LIST_STYLE_POSITION_INDEX 9
#define LIST_STYLE_POSITION_SHIFT 2
#define LIST_STYLE_POSITION_MASK 0xc

static inline css_error set_list_style_position(css_computed_style *style,
		uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[LIST_STYLE_POSITION_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~LIST_STYLE_POSITION_MASK) | (((uint32_t)type & 0x3)
			<< LIST_STYLE_POSITION_SHIFT);
	
	return CSS_OK;
}
#undef LIST_STYLE_POSITION_INDEX
#undef LIST_STYLE_POSITION_SHIFT
#undef LIST_STYLE_POSITION_MASK

#define LIST_STYLE_TYPE_INDEX 6
#define LIST_STYLE_TYPE_SHIFT 18
#define LIST_STYLE_TYPE_MASK 0x3c0000

static inline css_error set_list_style_type(css_computed_style *style, uint8_t
		type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[LIST_STYLE_TYPE_INDEX];
	
	/* 4bits: tttt : type */
	*bits = (*bits & ~LIST_STYLE_TYPE_MASK) | (((uint32_t)type & 0xf) <<
			LIST_STYLE_TYPE_SHIFT);
	
	return CSS_OK;
}
#undef LIST_STYLE_TYPE_INDEX
#undef LIST_STYLE_TYPE_SHIFT
#undef LIST_STYLE_TYPE_MASK

#define MARGIN_BOTTOM_INDEX 3
#define MARGIN_BOTTOM_SHIFT 4
#define MARGIN_BOTTOM_MASK 0x7f0

static inline css_error set_margin_bottom(css_computed_style *style, uint8_t
		type, css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[MARGIN_BOTTOM_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~MARGIN_BOTTOM_MASK) | ((((uint32_t)type & 0x3) | (
			unit << 2)) << MARGIN_BOTTOM_SHIFT);
	
	style->i.margin_bottom = length;
	
	return CSS_OK;
}
#undef MARGIN_BOTTOM_INDEX
#undef MARGIN_BOTTOM_SHIFT
#undef MARGIN_BOTTOM_MASK

#define MARGIN_LEFT_INDEX 1
#define MARGIN_LEFT_SHIFT 4
#define MARGIN_LEFT_MASK 0x7f0

static inline css_error set_margin_left(css_computed_style *style, uint8_t
		type, css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[MARGIN_LEFT_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~MARGIN_LEFT_MASK) | ((((uint32_t)type & 0x3) | (unit
			<< 2)) << MARGIN_LEFT_SHIFT);
	
	style->i.margin_left = length;
	
	return CSS_OK;
}
#undef MARGIN_LEFT_INDEX
#undef MARGIN_LEFT_SHIFT
#undef MARGIN_LEFT_MASK

#define MARGIN_RIGHT_INDEX 2
#define MARGIN_RIGHT_SHIFT 18
#define MARGIN_RIGHT_MASK 0x1fc0000

static inline css_error set_margin_right(css_computed_style *style, uint8_t
		type, css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[MARGIN_RIGHT_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~MARGIN_RIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit
			<< 2)) << MARGIN_RIGHT_SHIFT);
	
	style->i.margin_right = length;
	
	return CSS_OK;
}
#undef MARGIN_RIGHT_INDEX
#undef MARGIN_RIGHT_SHIFT
#undef MARGIN_RIGHT_MASK

#define MARGIN_TOP_INDEX 3
#define MARGIN_TOP_SHIFT 18
#define MARGIN_TOP_MASK 0x1fc0000

static inline css_error set_margin_top(css_computed_style *style, uint8_t type,
		css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[MARGIN_TOP_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~MARGIN_TOP_MASK) | ((((uint32_t)type & 0x3) | (unit
			<< 2)) << MARGIN_TOP_SHIFT);
	
	style->i.margin_top = length;
	
	return CSS_OK;
}
#undef MARGIN_TOP_INDEX
#undef MARGIN_TOP_SHIFT
#undef MARGIN_TOP_MASK

#define MAX_HEIGHT_INDEX 2
#define MAX_HEIGHT_SHIFT 4
#define MAX_HEIGHT_MASK 0x7f0

static inline css_error set_max_height(css_computed_style *style, uint8_t type,
		css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[MAX_HEIGHT_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~MAX_HEIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit
			<< 2)) << MAX_HEIGHT_SHIFT);
	
	style->i.max_height = length;
	
	return CSS_OK;
}
#undef MAX_HEIGHT_INDEX
#undef MAX_HEIGHT_SHIFT
#undef MAX_HEIGHT_MASK

#define MAX_WIDTH_INDEX 2
#define MAX_WIDTH_SHIFT 25
#define MAX_WIDTH_MASK 0xfe000000

static inline css_error set_max_width(css_computed_style *style, uint8_t type,
		css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[MAX_WIDTH_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~MAX_WIDTH_MASK) | ((((uint32_t)type & 0x3) | (unit <<
			2)) << MAX_WIDTH_SHIFT);
	
	style->i.max_width = length;
	
	return CSS_OK;
}
#undef MAX_WIDTH_INDEX
#undef MAX_WIDTH_SHIFT
#undef MAX_WIDTH_MASK

#define MIN_HEIGHT_INDEX 3
#define MIN_HEIGHT_SHIFT 11
#define MIN_HEIGHT_MASK 0x3f800

static inline css_error set_min_height(css_computed_style *style, uint8_t type,
		css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[MIN_HEIGHT_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~MIN_HEIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit
			<< 2)) << MIN_HEIGHT_SHIFT);
	
	style->i.min_height = length;
	
	return CSS_OK;
}
#undef MIN_HEIGHT_INDEX
#undef MIN_HEIGHT_SHIFT
#undef MIN_HEIGHT_MASK

#define MIN_WIDTH_INDEX 1
#define MIN_WIDTH_SHIFT 11
#define MIN_WIDTH_MASK 0x3f800

static inline css_error set_min_width(css_computed_style *style, uint8_t type,
		css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[MIN_WIDTH_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~MIN_WIDTH_MASK) | ((((uint32_t)type & 0x3) | (unit <<
			2)) << MIN_WIDTH_SHIFT);
	
	style->i.min_width = length;
	
	return CSS_OK;
}
#undef MIN_WIDTH_INDEX
#undef MIN_WIDTH_SHIFT
#undef MIN_WIDTH_MASK

#define OPACITY_INDEX 10
#define OPACITY_SHIFT 22
#define OPACITY_MASK 0x400000

static inline css_error set_opacity(css_computed_style *style, uint8_t type,
		css_fixed fixed)
{
	uint32_t *bits;
	
	bits = &style->i.bits[OPACITY_INDEX];
	
	/* 1bit: t : type */
	*bits = (*bits & ~OPACITY_MASK) | (((uint32_t)type & 0x1) <<
			OPACITY_SHIFT);
	
	style->i.opacity = fixed;
	
	return CSS_OK;
}
#undef OPACITY_INDEX
#undef OPACITY_SHIFT
#undef OPACITY_MASK

#define ORDER_INDEX 10
#define ORDER_SHIFT 27
#define ORDER_MASK 0x8000000

static inline css_error set_order(css_computed_style *style, uint8_t type,
		int32_t integer)
{
	uint32_t *bits;
	
	bits = &style->i.bits[ORDER_INDEX];
	
	/* 1bit: t : type */
	*bits = (*bits & ~ORDER_MASK) | (((uint32_t)type & 0x1) << ORDER_SHIFT);
	
	style->i.order = integer;
	
	return CSS_OK;
}
#undef ORDER_INDEX
#undef ORDER_SHIFT
#undef ORDER_MASK

#define OUTLINE_STYLE_INDEX 1
#define OUTLINE_STYLE_SHIFT 0
#define OUTLINE_STYLE_MASK 0xf

static inline css_error set_outline_style(css_computed_style *style, uint8_t
		type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[OUTLINE_STYLE_INDEX];
	
	/* 4bits: tttt : type */
	*bits = (*bits & ~OUTLINE_STYLE_MASK) | (((uint32_t)type & 0xf) <<
			OUTLINE_STYLE_SHIFT);
	
	return CSS_OK;
}
#undef OUTLINE_STYLE_INDEX
#undef OUTLINE_STYLE_SHIFT
#undef OUTLINE_STYLE_MASK

#define OVERFLOW_X_INDEX 8
#define OVERFLOW_X_SHIFT 5
#define OVERFLOW_X_MASK 0xe0

static inline css_error set_overflow_x(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[OVERFLOW_X_INDEX];
	
	/* 3bits: ttt : type */
	*bits = (*bits & ~OVERFLOW_X_MASK) | (((uint32_t)type & 0x7) <<
			OVERFLOW_X_SHIFT);
	
	return CSS_OK;
}
#undef OVERFLOW_X_INDEX
#undef OVERFLOW_X_SHIFT
#undef OVERFLOW_X_MASK

#define OVERFLOW_Y_INDEX 8
#define OVERFLOW_Y_SHIFT 29
#define OVERFLOW_Y_MASK 0xe0000000

static inline css_error set_overflow_y(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[OVERFLOW_Y_INDEX];
	
	/* 3bits: ttt : type */
	*bits = (*bits & ~OVERFLOW_Y_MASK) | (((uint32_t)type & 0x7) <<
			OVERFLOW_Y_SHIFT);
	
	return CSS_OK;
}
#undef OVERFLOW_Y_INDEX
#undef OVERFLOW_Y_SHIFT
#undef OVERFLOW_Y_MASK

#define PADDING_BOTTOM_INDEX 7
#define PADDING_BOTTOM_SHIFT 20
#define PADDING_BOTTOM_MASK 0x3f00000

static inline css_error set_padding_bottom(css_computed_style *style, uint8_t
		type, css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[PADDING_BOTTOM_INDEX];
	
	/* 6bits: uuuuut : unit | type */
	*bits = (*bits & ~PADDING_BOTTOM_MASK) | ((((uint32_t)type & 0x1) | (
			unit << 1)) << PADDING_BOTTOM_SHIFT);
	
	style->i.padding_bottom = length;
	
	return CSS_OK;
}
#undef PADDING_BOTTOM_INDEX
#undef PADDING_BOTTOM_SHIFT
#undef PADDING_BOTTOM_MASK

#define PADDING_LEFT_INDEX 7
#define PADDING_LEFT_SHIFT 26
#define PADDING_LEFT_MASK 0xfc000000

static inline css_error set_padding_left(css_computed_style *style, uint8_t
		type, css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[PADDING_LEFT_INDEX];
	
	/* 6bits: uuuuut : unit | type */
	*bits = (*bits & ~PADDING_LEFT_MASK) | ((((uint32_t)type & 0x1) | (unit
			<< 1)) << PADDING_LEFT_SHIFT);
	
	style->i.padding_left = length;
	
	return CSS_OK;
}
#undef PADDING_LEFT_INDEX
#undef PADDING_LEFT_SHIFT
#undef PADDING_LEFT_MASK

#define PADDING_RIGHT_INDEX 7
#define PADDING_RIGHT_SHIFT 8
#define PADDING_RIGHT_MASK 0x3f00

static inline css_error set_padding_right(css_computed_style *style, uint8_t
		type, css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[PADDING_RIGHT_INDEX];
	
	/* 6bits: uuuuut : unit | type */
	*bits = (*bits & ~PADDING_RIGHT_MASK) | ((((uint32_t)type & 0x1) | (
			unit << 1)) << PADDING_RIGHT_SHIFT);
	
	style->i.padding_right = length;
	
	return CSS_OK;
}
#undef PADDING_RIGHT_INDEX
#undef PADDING_RIGHT_SHIFT
#undef PADDING_RIGHT_MASK

#define PADDING_TOP_INDEX 7
#define PADDING_TOP_SHIFT 14
#define PADDING_TOP_MASK 0xfc000

static inline css_error set_padding_top(css_computed_style *style, uint8_t
		type, css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[PADDING_TOP_INDEX];
	
	/* 6bits: uuuuut : unit | type */
	*bits = (*bits & ~PADDING_TOP_MASK) | ((((uint32_t)type & 0x1) | (unit
			<< 1)) << PADDING_TOP_SHIFT);
	
	style->i.padding_top = length;
	
	return CSS_OK;
}
#undef PADDING_TOP_INDEX
#undef PADDING_TOP_SHIFT
#undef PADDING_TOP_MASK

#define POSITION_INDEX 5
#define POSITION_SHIFT 0
#define POSITION_MASK 0x7

static inline css_error set_position(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[POSITION_INDEX];
	
	/* 3bits: ttt : type */
	*bits = (*bits & ~POSITION_MASK) | (((uint32_t)type & 0x7) <<
			POSITION_SHIFT);
	
	return CSS_OK;
}
#undef POSITION_INDEX
#undef POSITION_SHIFT
#undef POSITION_MASK

#define QUOTES_INDEX 10
#define QUOTES_SHIFT 20
#define QUOTES_MASK 0x100000

static inline css_error set_quotes(css_computed_style *style, uint8_t type,
		lwc_string **string_arr)
{
	uint32_t *bits;
	
	bits = &style->i.bits[QUOTES_INDEX];
	
	/* 1bit: t : type */
	*bits = (*bits & ~QUOTES_MASK) | (((uint32_t)type & 0x1) <<
			QUOTES_SHIFT);
	
	lwc_string **old_string_arr = style->quotes;
	lwc_string **s;
	
	for (s = string_arr; s != NULL && *s != NULL; s++)
		*s = lwc_string_ref(*s);
	
	style->quotes = string_arr;
	
	/* Free existing array */
	if (old_string_arr != NULL) {
		for (s = old_string_arr; *s != NULL; s++)
			lwc_string_unref(*s);
		
		if (old_string_arr != string_arr)
			free(old_string_arr);
	}
	
	return CSS_OK;
}
#undef QUOTES_INDEX
#undef QUOTES_SHIFT
#undef QUOTES_MASK

#define RIGHT_INDEX 1
#define RIGHT_SHIFT 18
#define RIGHT_MASK 0x1fc0000

static inline css_error set_right(css_computed_style *style, uint8_t type,
		css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[RIGHT_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~RIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit << 2))
			<< RIGHT_SHIFT);
	
	style->i.right = length;
	
	return CSS_OK;
}
#undef RIGHT_INDEX
#undef RIGHT_SHIFT
#undef RIGHT_MASK

#define TABLE_LAYOUT_INDEX 9
#define TABLE_LAYOUT_SHIFT 0
#define TABLE_LAYOUT_MASK 0x3

static inline css_error set_table_layout(css_computed_style *style, uint8_t
		type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[TABLE_LAYOUT_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~TABLE_LAYOUT_MASK) | (((uint32_t)type & 0x3) <<
			TABLE_LAYOUT_SHIFT);
	
	return CSS_OK;
}
#undef TABLE_LAYOUT_INDEX
#undef TABLE_LAYOUT_SHIFT
#undef TABLE_LAYOUT_MASK

#define TEXT_ALIGN_INDEX 2
#define TEXT_ALIGN_SHIFT 0
#define TEXT_ALIGN_MASK 0xf

static inline css_error set_text_align(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[TEXT_ALIGN_INDEX];
	
	/* 4bits: tttt : type */
	*bits = (*bits & ~TEXT_ALIGN_MASK) | (((uint32_t)type & 0xf) <<
			TEXT_ALIGN_SHIFT);
	
	return CSS_OK;
}
#undef TEXT_ALIGN_INDEX
#undef TEXT_ALIGN_SHIFT
#undef TEXT_ALIGN_MASK

#define TEXT_DECORATION_INDEX 6
#define TEXT_DECORATION_SHIFT 22
#define TEXT_DECORATION_MASK 0x7c00000

static inline css_error set_text_decoration(css_computed_style *style, uint8_t
		type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[TEXT_DECORATION_INDEX];
	
	/* 5bits: ttttt : type */
	*bits = (*bits & ~TEXT_DECORATION_MASK) | (((uint32_t)type & 0x1f) <<
			TEXT_DECORATION_SHIFT);
	
	return CSS_OK;
}
#undef TEXT_DECORATION_INDEX
#undef TEXT_DECORATION_SHIFT
#undef TEXT_DECORATION_MASK

#define TEXT_INDENT_INDEX 7
#define TEXT_INDENT_SHIFT 2
#define TEXT_INDENT_MASK 0xfc

static inline css_error set_text_indent(css_computed_style *style, uint8_t
		type, css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[TEXT_INDENT_INDEX];
	
	/* 6bits: uuuuut : unit | type */
	*bits = (*bits & ~TEXT_INDENT_MASK) | ((((uint32_t)type & 0x1) | (unit
			<< 1)) << TEXT_INDENT_SHIFT);
	
	style->i.text_indent = length;
	
	return CSS_OK;
}
#undef TEXT_INDENT_INDEX
#undef TEXT_INDENT_SHIFT
#undef TEXT_INDENT_MASK

#define TEXT_TRANSFORM_INDEX 6
#define TEXT_TRANSFORM_SHIFT 3
#define TEXT_TRANSFORM_MASK 0x38

static inline css_error set_text_transform(css_computed_style *style, uint8_t
		type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[TEXT_TRANSFORM_INDEX];
	
	/* 3bits: ttt : type */
	*bits = (*bits & ~TEXT_TRANSFORM_MASK) | (((uint32_t)type & 0x7) <<
			TEXT_TRANSFORM_SHIFT);
	
	return CSS_OK;
}
#undef TEXT_TRANSFORM_INDEX
#undef TEXT_TRANSFORM_SHIFT
#undef TEXT_TRANSFORM_MASK

#define TOP_INDEX 3
#define TOP_SHIFT 25
#define TOP_MASK 0xfe000000

static inline css_error set_top(css_computed_style *style, uint8_t type,
		css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[TOP_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~TOP_MASK) | ((((uint32_t)type & 0x3) | (unit << 2))
			<< TOP_SHIFT);
	
	style->i.top = length;
	
	return CSS_OK;
}
#undef TOP_INDEX
#undef TOP_SHIFT
#undef TOP_MASK

#define UNICODE_BIDI_INDEX 9
#define UNICODE_BIDI_SHIFT 16
#define UNICODE_BIDI_MASK 0x30000

static inline css_error set_unicode_bidi(css_computed_style *style, uint8_t
		type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[UNICODE_BIDI_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~UNICODE_BIDI_MASK) | (((uint32_t)type & 0x3) <<
			UNICODE_BIDI_SHIFT);
	
	return CSS_OK;
}
#undef UNICODE_BIDI_INDEX
#undef UNICODE_BIDI_SHIFT
#undef UNICODE_BIDI_MASK

#define VERTICAL_ALIGN_INDEX 5
#define VERTICAL_ALIGN_SHIFT 12
#define VERTICAL_ALIGN_MASK 0x1ff000

static inline css_error set_vertical_align(css_computed_style *style, uint8_t
		type, css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[VERTICAL_ALIGN_INDEX];
	
	/* 9bits: uuuuutttt : unit | type */
	*bits = (*bits & ~VERTICAL_ALIGN_MASK) | ((((uint32_t)type & 0xf) | (
			unit << 4)) << VERTICAL_ALIGN_SHIFT);
	
	style->i.vertical_align = length;
	
	return CSS_OK;
}
#undef VERTICAL_ALIGN_INDEX
#undef VERTICAL_ALIGN_SHIFT
#undef VERTICAL_ALIGN_MASK

#define VISIBILITY_INDEX 10
#define VISIBILITY_SHIFT 28
#define VISIBILITY_MASK 0x30000000

static inline css_error set_visibility(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[VISIBILITY_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~VISIBILITY_MASK) | (((uint32_t)type & 0x3) <<
			VISIBILITY_SHIFT);
	
	return CSS_OK;
}
#undef VISIBILITY_INDEX
#undef VISIBILITY_SHIFT
#undef VISIBILITY_MASK

#define WHITE_SPACE_INDEX 6
#define WHITE_SPACE_SHIFT 0
#define WHITE_SPACE_MASK 0x7

static inline css_error set_white_space(css_computed_style *style, uint8_t type)
{
	uint32_t *bits;
	
	bits = &style->i.bits[WHITE_SPACE_INDEX];
	
	/* 3bits: ttt : type */
	*bits = (*bits & ~WHITE_SPACE_MASK) | (((uint32_t)type & 0x7) <<
			WHITE_SPACE_SHIFT);
	
	return CSS_OK;
}
#undef WHITE_SPACE_INDEX
#undef WHITE_SPACE_SHIFT
#undef WHITE_SPACE_MASK

#define WIDTH_INDEX 4
#define WIDTH_SHIFT 18
#define WIDTH_MASK 0x1fc0000

static inline css_error set_width(css_computed_style *style, uint8_t type,
		css_fixed length, css_unit unit)
{
	uint32_t *bits;
	
	bits = &style->i.bits[WIDTH_INDEX];
	
	/* 7bits: uuuuutt : unit | type */
	*bits = (*bits & ~WIDTH_MASK) | ((((uint32_t)type & 0x3) | (unit << 2))
			<< WIDTH_SHIFT);
	
	style->i.width = length;
	
	return CSS_OK;
}
#undef WIDTH_INDEX
#undef WIDTH_SHIFT
#undef WIDTH_MASK

#define Z_INDEX_INDEX 10
#define Z_INDEX_SHIFT 30
#define Z_INDEX_MASK 0xc0000000

static inline css_error set_z_index(css_computed_style *style, uint8_t type,
		int32_t integer)
{
	uint32_t *bits;
	
	bits = &style->i.bits[Z_INDEX_INDEX];
	
	/* 2bits: tt : type */
	*bits = (*bits & ~Z_INDEX_MASK) | (((uint32_t)type & 0x3) <<
			Z_INDEX_SHIFT);
	
	style->i.z_index = integer;
	
	return CSS_OK;
}
#undef Z_INDEX_INDEX
#undef Z_INDEX_SHIFT
#undef Z_INDEX_MASK