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 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550
|
/*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* (C) 2000 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
* rights reserved.
* Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_COMPUTED_STYLE_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_COMPUTED_STYLE_H_
#include <algorithm>
#include <memory>
#include "base/check_op.h"
#include "base/gtest_prod_util.h"
#include "base/memory/values_equivalent.h"
#include "base/types/pass_key.h"
#include "third_party/blink/public/mojom/css/preferred_color_scheme.mojom-blink-forward.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/css/color_scheme_flags.h"
#include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/core/css/properties/css_bitset.h"
#include "third_party/blink/renderer/core/css/properties/css_property.h"
#include "third_party/blink/renderer/core/css/resolver/matched_properties_cache.h"
#include "third_party/blink/renderer/core/css/style_auto_color.h"
#include "third_party/blink/renderer/core/css/style_color.h"
#include "third_party/blink/renderer/core/layout/geometry/box_sides.h"
#include "third_party/blink/renderer/core/layout/geometry/box_strut.h"
#include "third_party/blink/renderer/core/layout/geometry/logical_size.h"
#include "third_party/blink/renderer/core/layout/geometry/physical_rect.h"
#include "third_party/blink/renderer/core/layout/outline_type.h"
#include "third_party/blink/renderer/core/scroll/scroll_types.h"
#include "third_party/blink/renderer/core/style/border_edge.h"
#include "third_party/blink/renderer/core/style/computed_style_base.h"
#include "third_party/blink/renderer/core/style/computed_style_constants.h"
#include "third_party/blink/renderer/core/style/computed_style_initial_values.h"
#include "third_party/blink/renderer/core/style/cursor_list.h"
#include "third_party/blink/renderer/core/style/display_style.h"
#include "third_party/blink/renderer/core/style/filter_operations.h"
#include "third_party/blink/renderer/core/style/font_size_style.h"
#include "third_party/blink/renderer/core/style/gap_data_list.h"
#include "third_party/blink/renderer/core/style/style_cached_data.h"
#include "third_party/blink/renderer/core/style/style_highlight_data.h"
#include "third_party/blink/renderer/core/style/style_scrollbar_color.h"
#include "third_party/blink/renderer/core/style/transform_origin.h"
#include "third_party/blink/renderer/platform/geometry/length.h"
#include "third_party/blink/renderer/platform/geometry/length_box.h"
#include "third_party/blink/renderer/platform/geometry/length_point.h"
#include "third_party/blink/renderer/platform/geometry/length_size.h"
#include "third_party/blink/renderer/platform/geometry/path.h"
#include "third_party/blink/renderer/platform/graphics/color.h"
#include "third_party/blink/renderer/platform/graphics/touch_action.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/text/text_direction.h"
#include "third_party/blink/renderer/platform/text/writing_direction_mode.h"
#include "third_party/blink/renderer/platform/text/writing_mode_utils.h"
#include "third_party/blink/renderer/platform/transforms/transform_operations.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
#include "third_party/blink/renderer/platform/wtf/leak_annotations.h"
#include "third_party/blink/renderer/platform/wtf/ref_counted.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace gfx {
class Transform;
}
namespace blink {
using std::max;
class AppliedTextDecoration;
class ContentData;
class CounterDirectives;
class CSSAnimationData;
class CSSTransitionData;
class CSSVariableData;
class Font;
class Hyphenation;
class LayoutBox;
class LayoutTheme;
class Longhand;
class NinePieceImage;
class ShadowList;
class ShapeValue;
class StyleAdjuster;
class StyleDifference;
class StyleImage;
class StyleInheritedVariables;
class StyleRay;
class StyleResolver;
class StyleResolverState;
class StyleSelfAlignmentData;
namespace css_longhand {
class AccentColor;
class BackgroundColor;
class BorderBottomColor;
class BorderLeftColor;
class BorderRightColor;
class BorderTopColor;
class CaretColor;
class Color;
class ColumnRuleColor;
class Fill;
class FloodColor;
class InternalForcedBackgroundColor;
class InternalForcedBorderColor;
class InternalForcedColor;
class InternalForcedOutlineColor;
class InternalForcedVisitedColor;
class InternalVisitedBackgroundColor;
class InternalVisitedBorderBottomColor;
class InternalVisitedBorderLeftColor;
class InternalVisitedBorderRightColor;
class InternalVisitedBorderTopColor;
class InternalVisitedCaretColor;
class InternalVisitedColor;
class InternalVisitedColumnRuleColor;
class InternalVisitedFill;
class InternalVisitedOutlineColor;
class InternalVisitedStroke;
class InternalVisitedTextDecorationColor;
class InternalVisitedTextEmphasisColor;
class InternalVisitedTextFillColor;
class InternalVisitedTextStrokeColor;
class LightingColor;
class OutlineColor;
class StopColor;
class Stroke;
class TextDecorationColor;
class TextEmphasisColor;
class WebkitTapHighlightColor;
class WebkitTextFillColor;
class WebkitTextStrokeColor;
} // namespace css_longhand
// ComputedStyle stores the computed value [1] for every CSS property on an
// element and provides the interface between the style engine and the rest of
// Blink. It acts as a container where the computed value of every CSS property
// can be retrieved after its created using a builder.
//
// ComputedStyleBuilder builder(*ComputedStyle::GetInitialStyleSingleton());
// builder.SetDisplay(EDisplay::kNone); //'display' keyword property
// auto style = builder.TakeStyle();
// style->Display();
//
// In addition to storing the computed value of every CSS property,
// ComputedStyle also contains various internal style information. Examples
// include cached_pseudo_element_styles_ (for storing pseudo element styles) and
// has_simple_underline_ (cached indicator flag of text-decoration). These are
// stored on ComputedStyle for two reasons:
//
// 1) They share the same lifetime as ComputedStyle, so it is convenient to
// store them in the same object rather than a separate object that have to be
// passed around as well.
//
// 2) Many of these data members can be packed as bit fields, so we use less
// memory by packing them in this object with other bit fields.
//
// STORAGE:
//
// ComputedStyle is optimized for memory and performance. The data is not
// actually stored directly in ComputedStyle, but rather in a generated parent
// class ComputedStyleBase. This separation of concerns allows us to optimise
// the memory layout without affecting users of ComputedStyle. ComputedStyle
// inherits from ComputedStyleBase. For more about the memory layout, there is
// documentation in ComputedStyleBase and make_computed_style_base.py.
//
// INTERFACE:
//
// For most CSS properties, ComputedStyle provides a consistent interface which
// includes a getter, setter, and resetter (that resets the computed value to
// its initial value). Exceptions include vertical-align, which has a separate
// set of accessors for its length and its keyword components. Apart from
// accessors, ComputedStyle also has a wealth of helper functions.
//
// Because ComputedStyleBase defines simple accessors to every CSS property,
// ComputedStyle inherits these and so they are not redeclared in this file.
// This means that the interface to ComputedStyle is split between this file and
// ComputedStyleBase.h.
//
// [1] https://developer.mozilla.org/en-US/docs/Web/CSS/computed_value
//
// NOTE:
//
// Currently, some properties are stored in ComputedStyle and some in
// ComputedStyleBase. Eventually, the storage of all properties (except SVG
// ones) will be in ComputedStyleBase.
//
// Since this class is huge, do not mark all of it CORE_EXPORT. Instead,
// export only the methods you need below.
class ComputedStyle final : public ComputedStyleBase {
// Needed to allow access to private/protected getters of fields to allow diff
// generation
friend class ComputedStyleBase;
friend class ComputedStyleBuilder;
// Used by CSS animations. We can't allow them to animate based off visited
// colors.
friend class CSSPropertyEquality;
// Access Visibility()
friend class CSSVisibilityInterpolationType;
friend class InheritedVisibilityChecker;
// Accesses GetColor().
friend class ComputedStyleUtils;
// Color properties need access to private color utils.
friend class css_longhand::AccentColor;
friend class css_longhand::BackgroundColor;
friend class css_longhand::BackgroundImage;
friend class css_longhand::BorderBottomColor;
friend class css_longhand::BorderLeftColor;
friend class css_longhand::BorderRightColor;
friend class css_longhand::BorderTopColor;
friend class css_longhand::BoxShadow;
friend class css_longhand::CaretColor;
friend class css_longhand::Clear;
friend class css_longhand::Color;
friend class css_longhand::ColumnRuleColor;
friend class css_longhand::Fill;
friend class css_longhand::Float;
friend class css_longhand::FloodColor;
friend class css_longhand::InternalForcedBackgroundColor;
friend class css_longhand::InternalForcedBorderColor;
friend class css_longhand::InternalForcedColor;
friend class css_longhand::InternalForcedOutlineColor;
friend class css_longhand::InternalForcedVisitedColor;
friend class css_longhand::InternalVisitedBackgroundColor;
friend class css_longhand::InternalVisitedBorderBottomColor;
friend class css_longhand::InternalVisitedBorderLeftColor;
friend class css_longhand::InternalVisitedBorderRightColor;
friend class css_longhand::InternalVisitedBorderTopColor;
friend class css_longhand::InternalVisitedCaretColor;
friend class css_longhand::InternalVisitedColor;
friend class css_longhand::InternalVisitedColumnRuleColor;
friend class css_longhand::InternalVisitedFill;
friend class css_longhand::InternalVisitedOutlineColor;
friend class css_longhand::InternalVisitedStroke;
friend class css_longhand::InternalVisitedTextDecorationColor;
friend class css_longhand::InternalVisitedTextEmphasisColor;
friend class css_longhand::InternalVisitedTextFillColor;
friend class css_longhand::InternalVisitedTextStrokeColor;
friend class css_longhand::LightingColor;
friend class css_longhand::OutlineColor;
friend class css_longhand::Resize;
friend class css_longhand::RowRuleColor;
friend class css_longhand::StopColor;
friend class css_longhand::Stroke;
friend class css_longhand::TextDecorationColor;
friend class css_longhand::TextEmphasisColor;
friend class css_longhand::TextShadow;
friend class css_longhand::WebkitTapHighlightColor;
friend class css_longhand::WebkitTextFillColor;
friend class css_longhand::WebkitTextStrokeColor;
// Access to private Appearance() and HasAppearance().
friend class LayoutTheme;
friend class StyleAdjuster;
friend class StyleCascade;
// Editing has to only reveal unvisited info.
friend class EditingStyle;
// Saves Border/Background information for later comparison.
friend class CachedUAStyle;
// Accesses visited and unvisited colors.
friend class ColorPropertyFunctions;
// Accesses inset and sizing property values.
friend class LengthPropertyFunctions;
// Edits the background for media controls and accesses UserModify().
friend class StyleAdjuster;
// Access to GetCurrentColor().
friend class StyleResolver;
// Access to UserModify().
friend class MatchedPropertiesCache;
// Allows unit tests to access protected members.
friend class StyleResolverTest;
using ComputedStyleBase::Clear;
using ComputedStyleBase::Floating;
using ComputedStyleBase::Resize;
protected:
mutable Member<StyleCachedData> cached_data_;
StyleCachedData& EnsureCachedData() const;
bool HasCachedPseudoElementStyles() const;
CORE_EXPORT PseudoElementStyleCache* GetPseudoElementStyleCache() const;
PseudoElementStyleCache& EnsurePseudoElementStyleCache() const;
Vector<AtomicString>* GetVariableNamesCache() const;
Vector<AtomicString>& EnsureVariableNamesCache() const;
CORE_EXPORT base::RefCountedData<Vector<AppliedTextDecoration, 1>>*
EnsureAppliedTextDecorationsCache() const;
private:
// TODO(sashab): Move these private members to the bottom of ComputedStyle.
ALWAYS_INLINE ComputedStyle();
ALWAYS_INLINE ComputedStyle(const ComputedStyle& initial_style);
ALWAYS_INLINE explicit ComputedStyle(const ComputedStyleBuilder&);
public:
using PassKey = base::PassKey<ComputedStyle>;
using BuilderPassKey = base::PassKey<ComputedStyleBuilder>;
ALWAYS_INLINE ComputedStyle(BuilderPassKey,
const ComputedStyle& initial_style);
ALWAYS_INLINE ComputedStyle(BuilderPassKey, const ComputedStyleBuilder&);
ALWAYS_INLINE explicit ComputedStyle(PassKey);
void TraceAfterDispatch(Visitor* visitor) const {
visitor->Trace(cached_data_);
ComputedStyleBase::TraceAfterDispatch(visitor);
}
// Singletons to be used for StyleBuilder. The instances are
// context-independent and must always be used as `const` versions to avoid
// pollution of the style. Instances are allocated as per-thread singletons.
CORE_EXPORT static const ComputedStyle* GetInitialStyleSingleton();
CORE_EXPORT static const ComputedStyle* GetInitialStyleForImgSingleton();
static const ComputedStyle* NullifyEnsured(const ComputedStyle* style) {
if (!style) {
return nullptr;
}
if (style->IsEnsuredOutsideFlatTree()) {
return nullptr;
}
if (style->IsEnsuredInDisplayNone()) {
return nullptr;
}
return style;
}
static bool IsNullOrEnsured(const ComputedStyle* style) {
return !NullifyEnsured(style);
}
// Find out how two ComputedStyles differ. Used for figuring out if style
// recalc needs to propagate style changes down the tree. The constants are
// listed in increasing severity. E.g. kInherited also means we need to update
// pseudo elements (kPseudoElementStyle).
enum class Difference {
// The ComputedStyle objects have the same computed style. The might have
// some different extra flags which means we still need to replace the old
// with the new instance.
kEqual,
// Non-inherited properties differ which means we need to apply visual
// difference changes to the layout tree through LayoutObject::SetStyle().
kNonInherited,
// Pseudo element style is different which means we have to update pseudo
// element existence and computed style.
kPseudoElementStyle,
// Inherited properties are different which means we need to recalc style
// for children. Only independent properties changed which means we can
// inherit by cloning the exiting ComputedStyle for children an set modified
// properties directly without re-matching rules.
kIndependentInherited,
// Inherited properties are different which means we need to recalc style
// for children.
kInherited,
// Properties which can affect descendants changed. This can happen the
// following ways:
//
// Display type changes for flex/grid/custom layout affects computed style
// adjustments for descendants. For instance flex/grid items are blockified
// at computed style time and such items can be arbitrarily deep down the
// flat tree in the presence of display:contents.
//
// The container-name property affects which container is queried by
// rules matching descedant elements.
//
// If scroll-marker-group property changes from/to "none" on scroller, we
// should
// remove all ::scroll-marker pseudo elements from the scroller's subtree.
kDescendantAffecting,
};
CORE_EXPORT static Difference ComputeDifference(
const ComputedStyle* old_style,
const ComputedStyle* new_style);
// Returns true if the ComputedStyle change requires a LayoutObject re-attach.
static bool NeedsReattachLayoutTree(const Element& element,
const ComputedStyle* old_style,
const ComputedStyle* new_style);
StyleSelfAlignmentData ResolvedAlignSelf(
const StyleSelfAlignmentData& normal_value_behavior,
const ComputedStyle* parent_style = nullptr) const;
StyleSelfAlignmentData ResolvedJustifySelf(
const StyleSelfAlignmentData& normal_value_behavior,
const ComputedStyle* parent_style = nullptr) const;
CORE_EXPORT StyleDifference
VisualInvalidationDiff(const Document&, const ComputedStyle&) const;
CORE_EXPORT const ComputedStyle* GetCachedPseudoElementStyle(
PseudoId,
const AtomicString& pseudo_argument = g_null_atom) const;
const ComputedStyle* AddCachedPseudoElementStyle(const ComputedStyle*,
PseudoId,
const AtomicString&) const;
const ComputedStyle* ReplaceCachedPseudoElementStyle(
const ComputedStyle* pseudo_style,
PseudoId pseudo_id,
const AtomicString& pseudo_argument) const;
void ClearCachedPseudoElementStyles() const;
// If this ComputedStyle is affected by animation/transitions, then the
// unanimated "base" style can be retrieved with this function.
//
// If this function returns nullptr, then this ComputedStyle is not
// affected by animations, and *is* the base style.
CORE_EXPORT const ComputedStyle* GetBaseComputedStyle() const;
// Indicates which properties are !important in the base style.
CORE_EXPORT const CSSBitset* GetBaseImportantSet() const;
CORE_EXPORT const ComputedStyle* GetBaseComputedStyleOrThis() const {
if (auto* base = GetBaseComputedStyle()) {
return base;
}
return this;
}
HashSet<AtomicString>* CustomHighlightNames() const {
return CustomHighlightNamesInternal().get();
}
/**
* ComputedStyle properties
*
* Each property stored in ComputedStyle is made up of fields. Fields have
* getters and setters. A field is preferably a basic data type or enum,
* but can be any type. A set of fields should be preceded by the property
* the field is stored for.
*
* Field method naming should be done like so:
* // name-of-property
* int nameOfProperty() const;
* void SetNameOfProperty(int);
* If the property has multiple fields, add the field name to the end of the
* method name.
*
* Avoid nested types by splitting up fields where possible, e.g.:
* int getBorderTopWidth();
* int getBorderBottomWidth();
* int getBorderLeftWidth();
* int getBorderRightWidth();
* is preferable to:
* BorderWidths getBorderWidths();
*
* Utility functions should go in a separate section at the end of the
* class, and be kept to a minimum.
*/
// anchor-name
bool AnchorNameDataEquivalent(const ComputedStyle& o) const {
return base::ValuesEquivalent(AnchorName(), o.AnchorName());
}
// Regular (non-interleaved) style resolutions happen without an
// AnchorEvaluator, which means any anchor*() function will use
// the fallback. Since anchor*() functions resolve computed-value time,
// we can't distinguish e.g. left:10px and left:anchor(--a right,10px) during
// ComputedStyle diffing if the anchor() was evaluated with a null-
// AnchorEvaluator, yet we need to invalidate layout in this situation
// to enter interleaved style recalc with the *real* AnchorEvaluator.
bool HasAnchorFunctionsWithoutEvaluator() const {
return HasAnchorFunctions() && !HasAnchorEvaluator();
}
// For containing blocks, use |HasNonInitialBackdropFilter()| which includes
// will-change: backdrop-filter.
static bool HasBackdropFilter(const FilterOperations& backdrop_filter) {
return !backdrop_filter.Operations().empty();
}
bool HasBackdropFilter() const { return HasBackdropFilter(BackdropFilter()); }
// filter (aka -webkit-filter)
// For containing blocks, use |HasNonInitialFilter()| which includes
// will-change: filter.
bool HasFilter() const { return !Filter().Operations().empty(); }
// background-image
bool HasBackgroundImage() const {
return BackgroundInternal().AnyLayerHasImage();
}
bool HasFixedAttachmentBackgroundImage() const {
return BackgroundInternal().AnyLayerHasFixedAttachmentImage();
}
// background-clip
EFillBox BackgroundClip() const {
return static_cast<EFillBox>(BackgroundInternal().Clip());
}
// Returns true if the Element should stick to the viewport bottom as the URL
// bar hides.
bool IsFixedToBottom() const { return !Bottom().IsAuto() && Top().IsAuto(); }
// Border properties.
// border-image-slice
const LengthBox& BorderImageSlices() const {
return BorderImage().ImageSlices();
}
// border-image-source
StyleImage* BorderImageSource() const { return BorderImage().GetImage(); }
// border-image-width
const BorderImageLengthBox& BorderImageWidth() const {
return BorderImage().BorderSlices();
}
// border-image-outset
const BorderImageLengthBox& BorderImageOutset() const {
return BorderImage().Outset();
}
static int BorderWidth(EBorderStyle style, int width) {
if (style == EBorderStyle::kNone || style == EBorderStyle::kHidden) {
return 0;
}
return width;
}
static EBorderStyle CollapsedBorderStyle(EBorderStyle rule_style) {
// https://drafts.csswg.org/css-backgrounds-3/#border-style
// states that in the collapsing border model, outset is treated as groove
// and inset is treated as ridge
if (rule_style == EBorderStyle::kOutset) {
return EBorderStyle::kGroove;
}
if (rule_style == EBorderStyle::kInset) {
return EBorderStyle::kRidge;
}
return rule_style;
}
// Border width properties.
int BorderTopWidth() const {
return BorderWidth(BorderTopStyle(), BorderTopWidthInternal());
}
int BorderBottomWidth() const {
return BorderWidth(BorderBottomStyle(), BorderBottomWidthInternal());
}
int BorderLeftWidth() const {
return BorderWidth(BorderLeftStyle(), BorderLeftWidthInternal());
}
int BorderRightWidth() const {
return BorderWidth(BorderRightStyle(), BorderRightWidthInternal());
}
// clip-path
ClipPathOperation* ClipPath() const {
// This method is accessed frequently during SVG Hit Testing, but the
// cumulative cost of calling |ClipPathInternal| can be fairly high due to
// multiple rare data pointer indirections. |HasClipPath| was added as a way
// to reduce the cost of these expensive indirections by placing a bit
// in more easily accessible memory.
return HasClipPath() ? ClipPathInternal().Get() : nullptr;
}
// column-rule-width
GapDataList<int> ColumnRuleWidth() const {
// The legacy version of 'column-rule-width' behaved such that if
// 'column-rule-style' was not visible, we'd treat the width as 0. We will
// continue to apply this rule for 'column-rule-width' if a single value is
// provided for 'column-rule-width' and 'column-rule-style' for backwards
// compat. However, if one of the properties is a list of values, we will
// return the true computed value of the width as specified by the author
// (per CSSWG resolution [1]).
//
// [1]: https://github.com/w3c/csswg-drafts/issues/11494
const GapDataList<EBorderStyle> rule_style = ColumnRuleStyle();
if (rule_style.HasSingleValue() &&
ColumnRuleWidthInternal().HasSingleValue() &&
!BorderStyleIsVisible(rule_style.GetLegacyValue())) {
return GapDataList<int>(0);
}
return ColumnRuleWidthInternal();
}
// row-rule-width
const GapDataList<int>& RowRuleWidth() const {
return RowRuleWidthInternal();
}
// content
ContentData* GetContentData() const { return ContentInternal().Get(); }
// Returns the value of `line-clamp` or of `-webkit-line-clamp`, whichever
// applies (i.e. `-webkit-line-clamp` doesn't apply without specifying
// `display: -webkit-box`). To get the raw value of the properties, use
// `StandardLineClamp()` or `WebkitLineClamp()`.
int LineClamp() const {
if (HasAutoStandardLineClamp() || StandardLineClamp() != 0) {
DCHECK(RuntimeEnabledFeatures::CSSLineClampEnabled());
return StandardLineClamp();
}
if (IsSpecifiedDisplayWebkitBox()) {
DCHECK_EQ(BoxOrient(), EBoxOrient::kVertical);
return WebkitLineClamp();
}
return 0;
}
// Returns whether `line-clamp` or `-webkit-line-clamp` are set and apply.
bool HasLineClamp() const {
return HasAutoStandardLineClamp() || LineClamp() != 0;
}
// Outline properties.
bool OutlineVisuallyEqual(const ComputedStyle& other) const {
if (OutlineStyle() == EBorderStyle::kNone &&
other.OutlineStyle() == EBorderStyle::kNone) {
return true;
}
return OutlineWidthInternal() == other.OutlineWidthInternal() &&
ResolvedColor(OutlineColor()) ==
other.ResolvedColor(other.OutlineColor()) &&
OutlineStyle() == other.OutlineStyle() &&
OutlineOffset() == other.OutlineOffset() &&
OutlineStyleIsAuto() == other.OutlineStyleIsAuto();
}
// outline-width
int OutlineWidth() const {
if (OutlineStyle() == EBorderStyle::kNone) {
return 0;
}
return OutlineWidthInternal();
}
// For history and compatibility reasons, we draw outline:auto (for focus
// rings) and normal style outline differently.
// Focus rings enclose block ink overflows (of line boxes and descendants),
// while normal outlines don't.
OutlineType OutlineRectsShouldIncludeBlockInkOverflow() const {
return OutlineStyleIsAuto() ? OutlineType::kIncludeBlockInkOverflow
: OutlineType::kDontIncludeBlockInkOverflow;
}
// Scroll properties.
PhysicalToLogicalGetter<const Length&, ComputedStyle>
PhysicalScrollPaddingToLogicalGetter() const {
return PhysicalToLogicalGetter<const Length&, ComputedStyle>(
GetWritingDirection(), *this, &ComputedStyleBase::ScrollPaddingTop,
&ComputedStyleBase::ScrollPaddingRight,
&ComputedStyleBase::ScrollPaddingBottom,
&ComputedStyleBase::ScrollPaddingLeft);
}
// scroll-padding-block-start
const Length& ScrollPaddingBlockStart() const {
return PhysicalScrollPaddingToLogicalGetter().BlockStart();
}
// scroll-padding-block-end
const Length& ScrollPaddingBlockEnd() const {
return PhysicalScrollPaddingToLogicalGetter().BlockEnd();
}
// scroll-padding-inline-start
const Length& ScrollPaddingInlineStart() const {
return PhysicalScrollPaddingToLogicalGetter().InlineStart();
}
// scroll-padding-inline-end
const Length& ScrollPaddingInlineEnd() const {
return PhysicalScrollPaddingToLogicalGetter().InlineEnd();
}
// scrollbar-gutter
inline bool IsScrollbarGutterAuto() const {
return ScrollbarGutter() == kScrollbarGutterAuto;
}
inline bool IsScrollbarGutterStable() const {
return ScrollbarGutter() & kScrollbarGutterStable;
}
inline bool IsScrollbarGutterBothEdges() const {
return ScrollbarGutter() & kScrollbarGutterBothEdges;
}
bool UsesStandardScrollbarStyle() const {
return ScrollbarWidth() != EScrollbarWidth::kAuto || ScrollbarColor();
}
bool HasCustomScrollbarStyle(Element* element) const;
// Use UsedScrollbarWidth() instead of ScrollbarWidth() to get the used value.
EScrollbarWidth UsedScrollbarWidth() const;
// Use UsedScrollbarColor() instead of ScrollbarColor() to get the used value.
StyleScrollbarColor* UsedScrollbarColor() const;
// shape-outside (aka -webkit-shape-outside)
ShapeValue* ShapeOutside() const { return ShapeOutsideInternal().Get(); }
// vertical-align
EVerticalAlign VerticalAlign() const {
return static_cast<EVerticalAlign>(VerticalAlignInternal());
}
// This returns the z-index if it applies (i.e. positioned element or grid or
// flex children), and 0 otherwise. Note that for most situations,
// `EffectiveZIndex()` is what the code should use to determine how to stack
// the element. `ZIndex()` is still available and returns the value as
// specified in style (used for e.g. style comparisons and computed style
// reporting)
int EffectiveZIndex() const { return EffectiveZIndexZero() ? 0 : ZIndex(); }
// Mask properties.
// -webkit-mask-box-image-outset
bool HasMaskBoxImageOutsets() const {
return MaskBoxImageInternal().HasImage() && MaskBoxImageOutset().NonZero();
}
PhysicalBoxStrut MaskBoxImageOutsets() const {
return ImageOutsets(MaskBoxImageInternal());
}
const BorderImageLengthBox& MaskBoxImageOutset() const {
return MaskBoxImageInternal().Outset();
}
// -webkit-mask-box-image-slice
const LengthBox& MaskBoxImageSlices() const {
return MaskBoxImageInternal().ImageSlices();
}
// -webkit-mask-box-image-source
StyleImage* MaskBoxImageSource() const {
return MaskBoxImageInternal().GetImage();
}
// -webkit-mask-box-image-width
const BorderImageLengthBox& MaskBoxImageWidth() const {
return MaskBoxImageInternal().BorderSlices();
}
// Inherited properties.
// line-height
CORE_EXPORT Length LineHeight() const;
// List style properties.
// list-style-type
const AtomicString& ListStyleStringValue() const;
bool ListStyleTypeDataEquivalent(const ComputedStyle& other) const {
return base::ValuesEquivalent(ListStyleType(), other.ListStyleType());
}
// list-style-position
// Returns true if ::marker should be rendered inline.
// In some cases, it should be inline even if `list-style-position` property
// value is `outside`.
bool MarkerShouldBeInside(const Element& parent,
const DisplayStyle& marker_style) const;
// Text emphasis properties.
TextEmphasisMark GetTextEmphasisMark() const;
const AtomicString& TextEmphasisMarkString() const;
LineLogicalSide GetTextEmphasisLineLogicalSide() const;
CORE_EXPORT FontSizeStyle GetFontSizeStyle() const {
return FontSizeStyle(GetFont(), LineHeightInternal(), EffectiveZoom());
}
// Font properties.
CORE_EXPORT const FontDescription& GetFontDescription() const {
return GetFont()->GetFontDescription();
}
bool HasFontRelativeUnits() const {
return HasEmUnits() || HasRootFontRelativeUnits() ||
HasGlyphRelativeUnits();
}
bool HasAnyRelativeUnits() const {
return HasFontRelativeUnits() || HasContainerRelativeValue() ||
HasLogicalDirectionRelativeUnits() || HasViewportUnits();
}
// If true, the ComputedStyle must be recalculated when fonts are updated.
bool DependsOnFontMetrics() const {
return HasGlyphRelativeUnits() || HasFontSizeAdjust() ||
CustomStyleCallbackDependsOnFont();
}
template <typename Functor>
bool HasCachedPseudoElementStyle(Functor& func) const {
if (!func || !HasCachedPseudoElementStyles()) {
return false;
}
DCHECK_EQ(StyleType(), kPseudoIdNone);
for (const auto& pseudo_style : *GetPseudoElementStyleCache()) {
if (func(*pseudo_style)) {
return true;
}
}
return false;
}
bool HighlightPseudoElementStylesDependOnRelativeUnits() const;
bool HighlightPseudoElementStylesDependOnContainerUnits() const;
bool HighlightPseudoElementStylesDependOnViewportUnits() const;
bool HighlightPseudoElementStylesHaveVariableReferences() const;
// font-size
int FontSize() const { return GetFontDescription().ComputedPixelSize(); }
CORE_EXPORT float SpecifiedFontSize() const {
return GetFontDescription().SpecifiedSize();
}
CORE_EXPORT float ComputedFontSize() const {
return GetFontDescription().ComputedSize();
}
static inline LayoutUnit ComputedFontSizeAsFixed(const Font& font) {
return LayoutUnit::FromFloatRound(font.GetFontDescription().ComputedSize());
}
LayoutUnit ComputedFontSizeAsFixed() const {
return ComputedFontSizeAsFixed(*GetFont());
}
// font-size-adjust
blink::FontSizeAdjust FontSizeAdjust() const {
return GetFontDescription().SizeAdjust();
}
bool HasFontSizeAdjust() const {
return GetFontDescription().HasSizeAdjust();
}
// font-weight
CORE_EXPORT FontSelectionValue GetFontWeight() const {
return GetFontDescription().Weight();
}
// font-stretch
FontSelectionValue GetFontStretch() const {
return GetFontDescription().Stretch();
}
// font-style
FontSelectionValue GetFontStyle() const {
return GetFontDescription().Style();
}
// font-palette
const FontPalette* GetFontPalette() const {
return GetFontDescription().GetFontPalette();
}
// Child is aligned to the parent by matching the parent’s dominant baseline
// to the same baseline in the child.
CORE_EXPORT FontBaseline GetFontBaseline() const;
CORE_EXPORT FontHeight GetFontHeight(FontBaseline baseline) const;
CORE_EXPORT FontHeight GetFontHeight() const {
return GetFontHeight(GetFontBaseline());
}
// -webkit-locale
const AtomicString& Locale() const {
return LayoutLocale::LocaleString(GetFontDescription().Locale());
}
// letter-spacing
float LetterSpacing() const { return GetFontDescription().LetterSpacing(); }
// word-spacing
float WordSpacing() const { return GetFontDescription().WordSpacing(); }
// fill helpers
bool HasFill() const { return !FillPaint().IsNone(); }
bool IsFillColorCurrentColor() const {
return FillPaint().HasCurrentColor() ||
InternalVisitedFillPaint().HasCurrentColor();
}
// marker-* helpers
bool HasMarkers() const {
return MarkerStartResource() || MarkerMidResource() || MarkerEndResource();
}
// stroke helpers
bool HasStroke() const { return !StrokePaint().IsNone(); }
bool HasVisibleStroke() const {
return HasStroke() && !StrokeWidth().IsZero();
}
bool IsStrokeColorCurrentColor() const {
return StrokePaint().HasCurrentColor() ||
InternalVisitedStrokePaint().HasCurrentColor();
}
bool HasDashArray() const { return !StrokeDashArray()->data.empty(); }
// accent-color
// An empty optional means the accent-color is 'auto'
std::optional<blink::Color> AccentColorResolved() const;
// scrollbar-color
// An empty optional means the scrollbar-color is 'auto'
std::optional<blink::Color> ScrollbarThumbColorResolved() const;
std::optional<blink::Color> ScrollbarTrackColorResolved() const;
// Comparison operators
// FIXME: Replace callers of operator== wth a named method instead, e.g.
// inheritedEquals().
CORE_EXPORT bool operator==(const ComputedStyle& other) const;
bool operator!=(const ComputedStyle& other) const {
return !(*this == other);
}
bool InheritedEqual(const ComputedStyle&) const;
bool NonInheritedEqual(const ComputedStyle&) const;
inline bool IndependentInheritedEqual(const ComputedStyle&) const;
inline bool NonIndependentInheritedEqual(const ComputedStyle&) const;
bool InheritedDataShared(const ComputedStyle&) const;
bool HasChildDependentFlags() const { return ChildHasExplicitInheritance(); }
void CopyChildDependentFlagsFrom(const ComputedStyle&) const;
// Counters.
const CounterDirectiveMap* GetCounterDirectives() const;
const CounterDirectives GetCounterDirectives(
const AtomicString& identifier) const;
bool CounterDirectivesEqual(const ComputedStyle& other) const {
// If the counter directives change, trigger a relayout to re-calculate
// counter values and rebuild the counter node tree.
return base::ValuesEquivalent(CounterDirectivesInternal().get(),
other.CounterDirectivesInternal().get());
}
bool IsDeprecatedFlexbox() const {
return Display() == EDisplay::kWebkitBox ||
Display() == EDisplay::kWebkitInlineBox;
}
// Variables.
bool HasVariables() const;
CORE_EXPORT wtf_size_t GetVariableNamesCount() const;
CORE_EXPORT const Vector<AtomicString>& GetVariableNames() const;
CORE_EXPORT const StyleInheritedVariables* InheritedVariables() const;
CORE_EXPORT const StyleNonInheritedVariables* NonInheritedVariables() const;
// Handles both inherited and non-inherited variables
CORE_EXPORT CSSVariableData* GetVariableData(const AtomicString&) const;
CSSVariableData* GetVariableData(const AtomicString&,
bool is_inherited_property) const;
const CSSValue* GetVariableValue(const AtomicString&) const;
const CSSValue* GetVariableValue(const AtomicString&,
bool is_inherited_property) const;
// Animations.
const CSSAnimationData* Animations() const {
return AnimationsInternal().get();
}
// Transitions.
const CSSTransitionData* Transitions() const {
return TransitionsInternal().get();
}
// Column utility functions.
bool SpecifiesColumns() const {
return !HasAutoColumnCount() || !HasAutoColumnWidth() ||
!HasAutoColumnHeight();
}
bool ColumnRuleIsTransparent() const {
return GapRuleColorIsTransparent(ColumnRuleColor());
}
bool ColumnRuleEquivalent(const ComputedStyle& other_style) const;
bool HasColumnRule() const {
if (!SpecifiesColumns() && (Display() != EDisplay::kGrid &&
Display() != EDisplay::kFlex)) [[likely]] {
return false;
}
return HasRuleWidth(ColumnRuleWidth()) && !ColumnRuleIsTransparent() &&
BorderStyleIsVisible(ColumnRuleStyle());
}
bool RowRuleIsTransparent() const {
return GapRuleColorIsTransparent(RowRuleColor());
}
bool HasRowRule() const {
// `SpecifiesColumns()` signifies we are in a multicol context. Return false
// if we are not in a multicol, grid, or flex context.
if (!SpecifiesColumns() && (Display() != EDisplay::kGrid &&
Display() != EDisplay::kFlex)) [[likely]] {
return false;
}
return HasRuleWidth(RowRuleWidth()) && !RowRuleIsTransparent() &&
BorderStyleIsVisible(RowRuleStyle());
}
bool HasGapRule() const {
if (!MaybeHasGapDecorations()) {
return false;
}
return HasColumnRule() || HasRowRule();
}
// Flex utility functions.
bool ResolvedIsColumnFlexDirection() const {
if (IsDeprecatedFlexbox()) {
return BoxOrient() == EBoxOrient::kVertical;
}
return FlexDirection() == EFlexDirection::kColumn ||
FlexDirection() == EFlexDirection::kColumnReverse;
}
bool ResolvedIsReverseFlexDirection() const {
if (IsDeprecatedFlexbox()) {
return BoxDirection() == EBoxDirection::kReverse;
}
return FlexDirection() == EFlexDirection::kRowReverse ||
FlexDirection() == EFlexDirection::kColumnReverse;
}
bool ResolvedIsFlexWrapReverse() const {
if (IsDeprecatedFlexbox()) {
return false;
}
return FlexWrap().GetWrapMode() == FlexWrapMode::kWrapReverse;
}
bool ResolvedIsFlexNowrap() const {
if (IsDeprecatedFlexbox()) {
return true;
}
return FlexWrap().GetWrapMode() == FlexWrapMode::kNowrap;
}
std::optional<wtf_size_t> ResolvedFlexBalanceMinLineCount() const {
if (IsDeprecatedFlexbox() || !FlexWrap().IsBalanced()) {
return std::nullopt;
}
return FlexWrap().MinLineCount();
}
float ResolvedFlexGrow(const ComputedStyle& box_style) const {
if (box_style.IsDeprecatedFlexbox()) {
return BoxFlex() > 0 ? BoxFlex() : 0.0f;
}
return FlexGrow();
}
float ResolvedFlexShrink(const ComputedStyle& box_style) const {
if (box_style.IsDeprecatedFlexbox()) {
return BoxFlex() > 0 ? BoxFlex() : 0.0f;
}
return FlexShrink();
}
// Mask utility functions.
bool HasMask() const {
return MaskInternal().AnyLayerHasImage() ||
MaskBoxImageInternal().HasImage();
}
const FillLayer& MaskLayers() const { return MaskInternal(); }
const NinePieceImage& MaskBoxImage() const { return MaskBoxImageInternal(); }
bool MaskBoxImageSlicesFill() const { return MaskBoxImageInternal().Fill(); }
// Text-combine utility functions.
bool HasTextCombine() const { return TextCombine() != ETextCombine::kNone; }
// Grid utility functions.
GridAutoFlow GetGridAutoFlow() const { return GridAutoFlowInternal(); }
bool IsGridAutoFlowDirectionRow() const {
return (GridAutoFlowInternal() &
static_cast<int>(kInternalAutoFlowDirectionRow)) ==
kInternalAutoFlowDirectionRow;
}
bool IsGridAutoFlowDirectionColumn() const {
return (GridAutoFlowInternal() &
static_cast<int>(kInternalAutoFlowDirectionColumn)) ==
kInternalAutoFlowDirectionColumn;
}
bool IsGridAutoFlowAlgorithmSparse() const {
return (GridAutoFlowInternal() &
static_cast<int>(kInternalAutoFlowAlgorithmSparse)) ==
kInternalAutoFlowAlgorithmSparse;
}
bool IsGridAutoFlowAlgorithmDense() const {
return (GridAutoFlowInternal() &
static_cast<int>(kInternalAutoFlowAlgorithmDense)) ==
kInternalAutoFlowAlgorithmDense;
}
// Masonry utility functions.
GridTrackSizingDirection MasonryTrackSizingDirection() const {
switch (MasonryDirection()) {
case EMasonryDirection::kColumn:
case EMasonryDirection::kColumnReverse:
return kForColumns;
case EMasonryDirection::kRow:
case EMasonryDirection::kRowReverse:
return kForRows;
}
NOTREACHED();
}
// Grid axis utility functions, usable in Grid and Masonry.
const NGGridTrackList& AutoTracks(
GridTrackSizingDirection track_direction) const {
return (track_direction == kForColumns) ? GridAutoColumns()
: GridAutoRows();
}
const ComputedGridTrackList& TemplateTracks(
GridTrackSizingDirection track_direction) const {
return (track_direction == kForColumns) ? GridTemplateColumns()
: GridTemplateRows();
}
const GridPosition& TrackStart(
GridTrackSizingDirection track_direction) const {
return (track_direction == kForColumns) ? GridColumnStart()
: GridRowStart();
}
const GridPosition& TrackEnd(GridTrackSizingDirection track_direction) const {
return (track_direction == kForColumns) ? GridColumnEnd() : GridRowEnd();
}
// Writing mode utility functions.
WritingDirectionMode GetWritingDirection() const {
return {GetWritingMode(), Direction()};
}
bool IsHorizontalWritingMode() const {
return blink::IsHorizontalWritingMode(GetWritingMode());
}
bool IsVerticalWritingMode() const {
return blink::IsVerticalWritingMode(GetWritingMode());
}
bool IsHorizontalTypographicMode() const {
return blink::IsHorizontalTypographicMode(GetWritingMode());
}
bool IsFlippedLinesWritingMode() const {
return blink::IsFlippedLinesWritingMode(GetWritingMode());
}
bool IsFlippedBlocksWritingMode() const {
return blink::IsFlippedBlocksWritingMode(GetWritingMode());
}
// Will-change utility functions.
bool HasWillChangeCompositingHint() const;
bool HasWillChangeOpacityHint() const {
return WillChangeProperties().Contains(CSSPropertyID::kOpacity) ||
WillChangeProperties().Contains(CSSPropertyID::kAliasWebkitOpacity);
}
// Do we have a will-change hint for transform, perspective, or
// transform-style?
// TODO(dbaron): It's not clear that perspective and transform-style belong
// here any more than they belong for scale, rotate, translate, or offset-*.
bool HasWillChangeTransformHint() const;
bool HasWillChangeScaleHint() const {
return WillChangeProperties().Contains(CSSPropertyID::kScale);
}
bool HasWillChangeRotateHint() const {
return WillChangeProperties().Contains(CSSPropertyID::kRotate);
}
bool HasWillChangeTranslateHint() const {
return WillChangeProperties().Contains(CSSPropertyID::kTranslate);
}
bool HasWillChangeOffsetHint() const {
return WillChangeProperties().Contains(CSSPropertyID::kOffsetPath) ||
WillChangeProperties().Contains(CSSPropertyID::kOffsetPosition);
}
// The union of the above five functions (but faster).
bool HasWillChangeHintForAnyTransformProperty() const;
bool HasWillChangeFilterHint() const {
return WillChangeProperties().Contains(CSSPropertyID::kFilter) ||
WillChangeProperties().Contains(CSSPropertyID::kAliasWebkitFilter);
}
bool HasWillChangeBackdropFilterHint() const {
return WillChangeProperties().Contains(CSSPropertyID::kBackdropFilter);
}
bool HasWillChangeClipPathHint() const {
return WillChangeProperties().Contains(CSSPropertyID::kClipPath);
}
bool HasWillChangeMixBlendModeHint() const {
return WillChangeProperties().Contains(CSSPropertyID::kMixBlendMode);
}
// Hyphen utility functions.
Hyphenation* GetHyphenation() const;
Hyphenation* GetHyphenationWithLimits() const;
const AtomicString& HyphenString() const;
// text-align utility functions.
using ComputedStyleBase::GetTextAlign;
ETextAlign GetTextAlign(bool is_last_line) const;
// text-transform utility functions.
[[nodiscard]] String ApplyTextTransform(
const String&,
UChar previous_character = ' ',
TextOffsetMap* offset_map = nullptr) const;
// Line-height utility functions.
const Length& SpecifiedLineHeight() const { return LineHeightInternal(); }
static float ComputedLineHeight(const Length& line_height, const Font&);
float ComputedLineHeight() const;
CORE_EXPORT LayoutUnit ComputedLineHeightAsFixed() const;
LayoutUnit ComputedLineHeightAsFixed(const Font& font) const;
const Length& LogicalWidth() const {
return IsHorizontalWritingMode() ? Width() : Height();
}
const Length& LogicalHeight() const {
return IsHorizontalWritingMode() ? Height() : Width();
}
const Length& LogicalMaxWidth() const {
return IsHorizontalWritingMode() ? MaxWidth() : MaxHeight();
}
const Length& LogicalMaxHeight() const {
return IsHorizontalWritingMode() ? MaxHeight() : MaxWidth();
}
const Length& LogicalMinWidth() const {
return IsHorizontalWritingMode() ? MinWidth() : MinHeight();
}
const Length& LogicalMinHeight() const {
return IsHorizontalWritingMode() ? MinHeight() : MinWidth();
}
const StyleIntrinsicLength& ContainIntrinsicInlineSize() const {
return IsHorizontalWritingMode() ? ContainIntrinsicWidth()
: ContainIntrinsicHeight();
}
const StyleIntrinsicLength& ContainIntrinsicBlockSize() const {
return IsHorizontalWritingMode() ? ContainIntrinsicHeight()
: ContainIntrinsicWidth();
}
// Margin utility functions.
bool HasMarginBlockStartQuirk() const {
return MayHaveMargin() && MarginBlockStart().Quirk();
}
bool HasMarginBlockEndQuirk() const {
return MayHaveMargin() && MarginBlockEnd().Quirk();
}
const Length& MarginBlockStart() const {
return MarginBlockStartUsing(*this);
}
const Length& MarginBlockEnd() const { return MarginBlockEndUsing(*this); }
const Length& MarginInlineStart() const {
return MarginInlineStartUsing(*this);
}
const Length& MarginInlineEnd() const { return MarginInlineEndUsing(*this); }
const Length& MarginInlineStartUsing(const ComputedStyle& other) const {
return PhysicalMarginToLogical(other).InlineStart();
}
const Length& MarginInlineEndUsing(const ComputedStyle& other) const {
return PhysicalMarginToLogical(other).InlineEnd();
}
const Length& MarginBlockStartUsing(const ComputedStyle& other) const {
return PhysicalMarginToLogical(other).BlockStart();
}
const Length& MarginBlockEndUsing(const ComputedStyle& other) const {
return PhysicalMarginToLogical(other).BlockEnd();
}
// Padding utility functions.
const Length& PaddingBlockStart() const {
return PhysicalPaddingToLogical().BlockStart();
}
const Length& PaddingBlockEnd() const {
return PhysicalPaddingToLogical().BlockEnd();
}
const Length& PaddingInlineStart() const {
return PhysicalPaddingToLogical().InlineStart();
}
const Length& PaddingInlineEnd() const {
return PhysicalPaddingToLogical().InlineEnd();
}
bool PaddingEqual(const ComputedStyle& other) const {
return PaddingTop() == other.PaddingTop() &&
PaddingLeft() == other.PaddingLeft() &&
PaddingRight() == other.PaddingRight() &&
PaddingBottom() == other.PaddingBottom();
}
bool PaddingEqual(const LengthBox& other) const {
return PaddingTop() == other.Top() && PaddingLeft() == other.Left() &&
PaddingRight() == other.Right() && PaddingBottom() == other.Bottom();
}
// Border utility functions
PhysicalBoxStrut ImageOutsets(const NinePieceImage&) const;
bool HasBorderImageOutsets() const {
return BorderImage().HasImage() && BorderImage().Outset().NonZero();
}
PhysicalBoxStrut BorderImageOutsets() const {
return ImageOutsets(BorderImage());
}
bool BorderImageSlicesFill() const { return BorderImage().Fill(); }
bool BorderSizeEquals(const ComputedStyle& o) const {
return BorderLeftWidth() == o.BorderLeftWidth() &&
BorderTopWidth() == o.BorderTopWidth() &&
BorderRightWidth() == o.BorderRightWidth() &&
BorderBottomWidth() == o.BorderBottomWidth();
}
int BorderBlockEndWidth() const {
return PhysicalBorderWidthToLogical().BlockEnd();
}
int BorderBlockStartWidth() const {
return PhysicalBorderWidthToLogical().BlockStart();
}
int BorderInlineEndWidth() const {
return PhysicalBorderWidthToLogical().InlineEnd();
}
int BorderInlineStartWidth() const {
return PhysicalBorderWidthToLogical().InlineStart();
}
bool HasBorder() const {
return BorderLeftWidth() || BorderRightWidth() || BorderTopWidth() ||
BorderBottomWidth();
}
bool HasBorderDecoration() const {
return HasBorder() || BorderImage().HasImage();
}
bool HasBorderRadius() const {
if (!BorderTopLeftRadius().Width().IsZero()) {
return true;
}
if (!BorderTopRightRadius().Width().IsZero()) {
return true;
}
if (!BorderBottomLeftRadius().Width().IsZero()) {
return true;
}
if (!BorderBottomRightRadius().Width().IsZero()) {
return true;
}
return false;
}
bool BorderVisuallyEqual(const ComputedStyle& o) const {
auto BorderSideVisuallyEqual =
[&](const StyleColor& color, const StyleColor& other_color,
EBorderStyle style, EBorderStyle other_style, int width,
int other_width) -> bool {
if (style == EBorderStyle::kNone && other_style == EBorderStyle::kNone) {
return true;
}
if (style == EBorderStyle::kHidden &&
other_style == EBorderStyle::kHidden) {
return true;
}
return width == other_width && style == other_style &&
ResolvedColor(color) == o.ResolvedColor(other_color);
};
return BorderSideVisuallyEqual(BorderTopColor(), o.BorderTopColor(),
BorderTopStyle(), o.BorderTopStyle(),
BorderTopWidthInternal(),
o.BorderTopWidthInternal()) &&
BorderSideVisuallyEqual(BorderRightColor(), o.BorderRightColor(),
BorderRightStyle(), o.BorderRightStyle(),
BorderRightWidthInternal(),
o.BorderRightWidthInternal()) &&
BorderSideVisuallyEqual(BorderBottomColor(), o.BorderBottomColor(),
BorderBottomStyle(), o.BorderBottomStyle(),
BorderBottomWidthInternal(),
o.BorderBottomWidthInternal()) &&
BorderSideVisuallyEqual(BorderLeftColor(), o.BorderLeftColor(),
BorderLeftStyle(), o.BorderLeftStyle(),
BorderLeftWidthInternal(),
o.BorderLeftWidthInternal()) &&
BorderImage() == o.BorderImage();
}
bool BorderVisualOverflowEqual(const ComputedStyle& o) const {
return BorderImage().Outset() == o.BorderImage().Outset();
}
bool CanRenderBorderImage() const;
// Float utility functions.
bool IsFloating() const { return Floating() != EFloat::kNone; }
EFloat UnresolvedFloating() const { return Floating(); }
EFloat Floating(const ComputedStyle& cb_style) const {
return Floating(cb_style.Direction());
}
EFloat Floating(TextDirection cb_direction) const {
const EFloat value = Floating();
switch (value) {
case EFloat::kInlineStart:
return IsLtr(cb_direction) ? EFloat::kLeft : EFloat::kRight;
case EFloat::kInlineEnd:
return IsLtr(cb_direction) ? EFloat::kRight : EFloat::kLeft;
default:
return value;
}
}
// Mix-blend-mode utility functions.
bool HasBlendMode() const { return GetBlendMode() != BlendMode::kNormal; }
// Motion utility functions.
bool HasOffset() const {
return (!OffsetPosition().X().IsAuto() && !OffsetPosition().X().IsNone()) ||
OffsetPath();
}
// Direction utility functions.
bool IsLeftToRightDirection() const {
return Direction() == TextDirection::kLtr;
}
// Perspective utility functions.
bool HasPerspective() const { return Perspective() >= 0; }
float UsedPerspective() const {
DCHECK(HasPerspective());
return std::max(1.0f, Perspective());
}
// Outline utility functions.
// HasOutline is insufficient to determine whether Node has an outline.
// Use HasPaintedOutline() instead.
bool HasOutline() const {
return OutlineWidth() > 0 && OutlineStyle() > EBorderStyle::kHidden;
}
bool HasOutlineWithCurrentColor() const {
return HasOutline() && OutlineColor().DependsOnCurrentColor();
}
// Position utility functions.
static bool HasOutOfFlowPosition(EPosition position) {
return position == EPosition::kAbsolute || position == EPosition::kFixed;
}
bool HasOutOfFlowPosition() const {
return HasOutOfFlowPosition(GetPosition());
}
bool HasInFlowPosition() const {
return GetPosition() == EPosition::kRelative ||
GetPosition() == EPosition::kSticky;
}
bool HasStickyConstrainedPosition() const {
return GetPosition() == EPosition::kSticky &&
(!Top().IsAuto() || !Left().IsAuto() || !Right().IsAuto() ||
!Bottom().IsAuto());
}
static EPosition GetPosition(EDisplay display, EPosition position_internal) {
// Applied sticky position is static for table columns and column groups.
if (position_internal == EPosition::kSticky &&
(display == EDisplay::kTableColumnGroup ||
display == EDisplay::kTableColumn)) {
return EPosition::kStatic;
}
return position_internal;
}
EPosition GetPosition() const {
return GetPosition(Display(), PositionInternal());
}
// Clear utility functions.
bool HasClear() const { return Clear() != EClear::kNone; }
EClear UnresolvedClear() const { return Clear(); }
EClear Clear(const ComputedStyle& cb_style) const {
return Clear(cb_style.Direction());
}
EClear Clear(TextDirection cb_direction) const {
const EClear value = Clear();
switch (value) {
case EClear::kInlineStart:
return IsLtr(cb_direction) ? EClear::kLeft : EClear::kRight;
case EClear::kInlineEnd:
return IsLtr(cb_direction) ? EClear::kRight : EClear::kLeft;
default:
return value;
}
}
// Clip utility functions.
const Length& ClipLeft() const { return Clip().Left(); }
const Length& ClipRight() const { return Clip().Right(); }
const Length& ClipTop() const { return Clip().Top(); }
const Length& ClipBottom() const { return Clip().Bottom(); }
// Whether or not a positioned element requires normal flow x/y to be computed
// to determine its position.
bool HasAutoLeftAndRightIgnoringPositionArea() const {
return Left().IsAuto() && Right().IsAuto();
}
bool HasAutoTopAndBottomIgnoringPositionArea() const {
return Top().IsAuto() && Bottom().IsAuto();
}
// Whether an inset is considered 'auto' for anchor-positioning position
// fallback calculation purposes.
// https://drafts.csswg.org/css-anchor-position-1/#determine-the-position-fallback-styles
bool IsTopInsetNonAuto() const {
return !Top().IsAuto() || (PositionAreaOffsets() &&
!PositionAreaOffsets()->behaves_as_auto.top);
}
bool IsRightInsetNonAuto() const {
return !Right().IsAuto() || (PositionAreaOffsets() &&
!PositionAreaOffsets()->behaves_as_auto.right);
}
bool IsBottomInsetNonAuto() const {
return !Bottom().IsAuto() ||
(PositionAreaOffsets() &&
!PositionAreaOffsets()->behaves_as_auto.bottom);
}
bool IsLeftInsetNonAuto() const {
return !Left().IsAuto() || (PositionAreaOffsets() &&
!PositionAreaOffsets()->behaves_as_auto.left);
}
// Content utility functions.
bool ContentDataEquivalent(const ComputedStyle& other) const {
return base::ValuesEquivalent(GetContentData(), other.GetContentData());
}
// Contain utility functions.
//
// Containment can be enabled from a variety of sources, not just the
// 'contain' property itself. The "effective containment" represents whether
// or not we should enable containment of a given type, taking those
// different sources into account.
//
// Note that even a certain type of containment appears to be in effect from
// the perspective of ComputedStyle, containment may still not be applied if
// the LayoutObject is ineligible for the given containment type. See
// |LayoutObject::IsEligibleForSizeContainment| and similar functions.
static unsigned EffectiveContainment(unsigned contain,
unsigned container_type,
EContentVisibility content_visibility,
bool skips_contents) {
unsigned effective = contain;
if (container_type & kContainerTypeInlineSize) {
effective |= kContainsStyle;
if (!RuntimeEnabledFeatures::ContainerTypeNoLayoutContainmentEnabled()) {
effective |= kContainsLayout;
}
effective |= kContainsInlineSize;
}
if (container_type & kContainerTypeBlockSize) {
effective |= kContainsStyle;
if (!RuntimeEnabledFeatures::ContainerTypeNoLayoutContainmentEnabled()) {
effective |= kContainsLayout;
}
effective |= kContainsBlockSize;
}
if (container_type & kContainerTypeAnchored) {
effective |= kContainsStyle;
}
if (!IsContentVisibilityVisible(content_visibility)) {
effective |= kContainsStyle;
effective |= kContainsLayout;
effective |= kContainsPaint;
}
if (skips_contents) {
effective |= kContainsSize;
}
return effective;
}
unsigned EffectiveContainment() const {
return ComputedStyle::EffectiveContainment(
Contain(), ContainerType(), ContentVisibility(), SkipsContents());
}
bool ContainsStyle() const { return EffectiveContainment() & kContainsStyle; }
bool ContainsPaint() const { return EffectiveContainment() & kContainsPaint; }
bool ContainsLayout() const {
return EffectiveContainment() & kContainsLayout;
}
bool ContainsSize() const {
return (EffectiveContainment() & kContainsSize) == kContainsSize;
}
bool ContainsInlineSize() const {
return EffectiveContainment() & kContainsInlineSize;
}
bool ContainsBlockSize() const {
return EffectiveContainment() & kContainsBlockSize;
}
bool ContainsAnySize() const {
return EffectiveContainment() & kContainsSize;
}
CORE_EXPORT static bool ShouldApplyAnyContainment(
const Element& element,
const DisplayStyle&,
unsigned effective_containment);
CORE_EXPORT bool ShouldApplyAnyContainment(const Element& element) const {
return ShouldApplyAnyContainment(element, GetDisplayStyle(),
EffectiveContainment());
}
// Return true if an element can match size container queries. In addition to
// checking if it has a size container-type, we check if we are never able to
// reach BlockNode::Layout() for legacy layout objects or SVG elements.
bool CanMatchSizeContainerQueries(const Element& element) const;
bool IsContainerForSizeContainerQueries() const {
return IsInlineOrBlockSizeContainer() && StyleType() == kPseudoIdNone;
}
bool IsContainerForScrollStateContainerQueries() const {
return IsScrollStateContainer() && StyleType() == kPseudoIdNone;
}
bool IsContainerForAnchoredContainerQueries() const {
return IsAnchoredContainer() && StyleType() == kPseudoIdNone;
}
bool DependsOnContainerQueries() const {
return DependsOnSizeContainerQueries() ||
DependsOnStyleContainerQueries() ||
DependsOnScrollStateContainerQueries() ||
DependsOnAnchoredContainerQueries();
}
static bool IsContentVisibilityVisible(
EContentVisibility content_visibility) {
return content_visibility == EContentVisibility::kVisible;
}
bool IsContentVisibilityVisible() const {
return IsContentVisibilityVisible(ContentVisibility());
}
// Interleaving roots are elements that may require layout to fully update
// the style of their descendants.
static bool IsInterleavingRoot(const ComputedStyle*);
// Display utility functions.
bool IsDisplayReplacedType() const {
return IsDisplayReplacedType(Display());
}
bool IsDisplayInlineType() const { return IsDisplayInlineType(Display()); }
bool IsDisplayBlockContainer() const {
return IsDisplayBlockContainer(Display());
}
bool IsDisplayListItem() const { return IsDisplayListItem(Display()); }
static bool IsDisplayListItem(EDisplay display) {
return display == EDisplay::kListItem ||
display == EDisplay::kInlineListItem ||
display == EDisplay::kFlowRootListItem ||
display == EDisplay::kInlineFlowRootListItem;
}
bool IsDisplayTableBox() const { return IsDisplayTableBox(Display()); }
bool IsDisplayFlexibleBox() const { return IsDisplayFlexibleBox(Display()); }
bool IsDisplayGridBox() const { return IsDisplayGridBox(Display()); }
bool IsDisplayMasonryBox() const { return IsDisplayMasonryBox(Display()); }
bool IsDisplayFlexibleOrGridBox() const {
return IsDisplayFlexibleBox(Display()) || IsDisplayGridBox(Display());
}
bool IsDisplayLayoutCustomBox() const {
return IsDisplayLayoutCustomBox(Display());
}
bool IsDisplayTableType() const { return IsDisplayTableType(Display()); }
bool IsDisplayMathType() const { return IsDisplayMathBox(Display()); }
bool BlockifiesChildren() const {
return IsDisplayFlexibleOrGridBox() || IsDisplayMathType() ||
IsDisplayLayoutCustomBox() ||
(Display() == EDisplay::kContents && IsInBlockifyingDisplay());
}
bool InlinifiesChildren() const {
EDisplay display = Display();
// https://drafts.csswg.org/css-ruby-1/#anon-gen-inlinize
if (display == EDisplay::kRuby || display == EDisplay::kBlockRuby ||
display == EDisplay::kRubyText) {
return true;
}
// https://drafts.csswg.org/css-display-4/#inlinify
// If an inline box (inline flow) is inlinified, it recursively inlinifies
// all of its in-flow children
return IsInInlinifyingDisplay() &&
(display == EDisplay::kContents || display == EDisplay::kInline ||
display == EDisplay::kInlineListItem);
}
// Return true if an element with this computed style requires LayoutNG
// (i.e. has no legacy layout implementation).
bool DisplayTypeRequiresLayoutNG() const {
return IsDisplayMathType() || IsDisplayLayoutCustomBox();
}
// Isolation utility functions.
bool HasIsolation() const { return Isolation() != EIsolation::kAuto; }
DisplayStyle GetDisplayStyle() const {
return DisplayStyle(Display(), StyleType(), GetContentData());
}
// Content utility functions.
bool ContentBehavesAsNormal() const {
return GetDisplayStyle().ContentBehavesAsNormal();
}
bool ContentPreventsBoxGeneration() const {
return GetDisplayStyle().ContentPreventsBoxGeneration();
}
// Cursor utility functions.
CursorList* Cursors() const { return CursorDataInternal().Get(); }
// Resize utility functions.
bool HasResize() const {
return StyleType() == kPseudoIdNone && Resize() != EResize::kNone;
}
EResize UnresolvedResize() const { return Resize(); }
EResize UsedResize() const {
EResize value = Resize();
switch (value) {
case EResize::kBlock:
return IsHorizontalWritingMode() ? EResize::kVertical
: EResize::kHorizontal;
case EResize::kInline:
return IsHorizontalWritingMode() ? EResize::kHorizontal
: EResize::kVertical;
default:
return value;
}
}
// Pointer-events utility functions.
EPointerEvents UsedPointerEvents() const {
if (IsInert()) {
return EPointerEvents::kNone;
}
return PointerEvents();
}
// User modify utility functions.
EUserModify UsedUserModify() const {
if (IsInert()) {
return EUserModify::kReadOnly;
}
return UserModify();
}
// User select utility functions.
EUserSelect UsedUserSelect() const {
if (IsInert()) {
return EUserSelect::kNone;
}
return UserSelect();
}
bool IsSelectable() const {
return !IsInert() && !(UserSelect() == EUserSelect::kNone &&
UserModify() == EUserModify::kReadOnly);
}
bool IsFocusable() const {
// TODO: `visibility: hidden` shouldn't prevent focusability, see
// https://html.spec.whatwg.org/multipage/interaction.html#focusable-area
return !IsEnsuredInDisplayNone() && !IsInert() &&
Visibility() == EVisibility::kVisible &&
(Display() != EDisplay::kContents ||
RuntimeEnabledFeatures::DisplayContentsFocusableEnabled());
}
// `text-box-trim` utility functions.
bool ShouldTextBoxTrimStart() const {
const ETextBoxTrim text_box_trim = TextBoxTrim();
return text_box_trim == ETextBoxTrim::kTrimStart ||
text_box_trim == ETextBoxTrim::kTrimBoth;
}
bool ShouldTextBoxTrimEnd() const {
const ETextBoxTrim text_box_trim = TextBoxTrim();
return text_box_trim == ETextBoxTrim::kTrimEnd ||
text_box_trim == ETextBoxTrim::kTrimBoth;
}
// Text decoration utility functions.
bool TextDecorationVisualOverflowChanged(const ComputedStyle& o) const;
CORE_EXPORT TextDecorationLine TextDecorationsInEffect() const;
CORE_EXPORT const Vector<AppliedTextDecoration, 1>& AppliedTextDecorations()
const;
CORE_EXPORT base::RefCountedData<Vector<AppliedTextDecoration, 1>>*
AppliedTextDecorationData() const {
return IsDecoratingBox() ? EnsureAppliedTextDecorationsCache()
: BaseTextDecorationDataInternal().get();
}
const Vector<AppliedTextDecoration, 1>* BaseAppliedTextDecorations() const {
const auto base = BaseTextDecorationDataInternal();
return base ? &base->data : nullptr;
}
// Returns true if this a "decorating box".
// https://drafts.csswg.org/css-text-decor-3/#decorating-box
bool IsDecoratingBox() const {
if (GetTextDecorationLine() == TextDecorationLine::kNone) {
return false;
}
if (Display() == EDisplay::kContents) {
return false;
}
return true;
}
// Returns true if there are any text decorations.
bool HasAppliedTextDecorations() const {
if (IsDecoratingBox()) {
return true;
}
if (BaseTextDecorationDataInternal()) {
DCHECK(!BaseTextDecorationDataInternal()->data.empty());
return true;
}
return false;
}
// Returns (by value) the last text decoration, if any.
std::optional<AppliedTextDecoration> LastAppliedTextDecoration() const {
if (HasAppliedTextDecorations()) {
return AppliedTextDecorations().back();
}
return std::nullopt;
}
// Overflow utility functions.
EOverflow OverflowInlineDirection() const {
return IsHorizontalWritingMode() ? OverflowX() : OverflowY();
}
EOverflow OverflowBlockDirection() const {
return IsHorizontalWritingMode() ? OverflowY() : OverflowX();
}
// Returns true if 'overflow' is 'visible' along both axes. When 'clip' is
// used the other axis may be 'visible'. In other words, if one axis is
// 'visible' the other axis is not necessarily 'visible.'
bool IsOverflowVisibleAlongBothAxes() const {
// Overflip clip and overflow visible may be used along different axis.
return OverflowX() == EOverflow::kVisible &&
OverflowY() == EOverflow::kVisible;
}
// Returns true if 'overflow' is 'visible' or 'clip' along both axes.
bool IsOverflowVisibleOrClip() const {
bool overflow_x =
OverflowX() == EOverflow::kVisible || OverflowX() == EOverflow::kClip;
DCHECK(!overflow_x || OverflowY() == EOverflow::kVisible ||
OverflowY() == EOverflow::kClip);
return overflow_x;
}
// An overflow value of visible or clip is not a scroll container, all other
// values result in a scroll container. Also note that if visible or clip is
// set on one axis, then the other axis must also be visible or clip. For
// example, "overflow-x: clip; overflow-y: visible" is allowed, but
// "overflow-x: clip; overflow-y: hidden" is not.
bool IsScrollContainer() const {
return OverflowX() != EOverflow::kVisible &&
OverflowX() != EOverflow::kClip;
}
// Returns true if object-fit, object-position and object-view-box would avoid
// replaced contents overflow.
bool ObjectPropertiesPreventReplacedOverflow() const {
if (GetObjectFit() == EObjectFit::kNone ||
GetObjectFit() == EObjectFit::kCover) {
return false;
}
if (ObjectPosition() !=
LengthPoint(Length::Percent(50.0), Length::Percent(50.0))) {
return false;
}
if (ObjectViewBox()) {
return false;
}
return true;
}
static bool HasAutoScroll(EOverflow overflow) {
return overflow == EOverflow::kAuto || overflow == EOverflow::kOverlay;
}
static bool ScrollsOverflow(EOverflow overflow) {
return overflow == EOverflow::kScroll || HasAutoScroll(overflow);
}
bool HasAutoHorizontalScroll() const {
return ComputedStyle::HasAutoScroll(OverflowX());
}
bool HasAutoVerticalScroll() const {
return ComputedStyle::HasAutoScroll(OverflowY());
}
bool ScrollsOverflowX() const {
return ComputedStyle::ScrollsOverflow(OverflowX());
}
bool ScrollsOverflowY() const {
return ComputedStyle::ScrollsOverflow(OverflowY());
}
bool ScrollsOverflow() const {
return ScrollsOverflowX() || ScrollsOverflowY();
}
// Returns true if the element is HTML inert, or if 'interactivity' computes
// to 'inert'.
bool IsInert() const { return IsHTMLInert() || IsCSSInert(); }
// Visibility utility functions.
bool VisibleToHitTesting() const {
return Visibility() == EVisibility::kVisible &&
UsedPointerEvents() != EPointerEvents::kNone;
}
// Animation utility functions.
bool HasCurrentTransformRelatedAnimation() const {
return HasCurrentTransformAnimation() || HasCurrentScaleAnimation() ||
HasCurrentRotateAnimation() || HasCurrentTranslateAnimation();
}
bool HasCurrentCompositableAnimation() const {
return HasCurrentOpacityAnimation() ||
HasCurrentTransformRelatedAnimation() ||
HasCurrentFilterAnimation() || HasCurrentBackdropFilterAnimation() ||
(RuntimeEnabledFeatures::CompositeBGColorAnimationEnabled() &&
HasCurrentBackgroundColorAnimation());
}
bool ShouldCompositeForCurrentAnimations() const {
return HasCurrentOpacityAnimation() ||
HasCurrentTransformRelatedAnimation() ||
HasCurrentFilterAnimation() || HasCurrentBackdropFilterAnimation();
}
bool RequiresPropertyNodeForAnimation() const {
return IsRunningOpacityAnimationOnCompositor() ||
IsRunningTransformAnimationOnCompositor() ||
IsRunningScaleAnimationOnCompositor() ||
IsRunningRotateAnimationOnCompositor() ||
IsRunningTranslateAnimationOnCompositor() ||
IsRunningFilterAnimationOnCompositor() ||
IsRunningBackdropFilterAnimationOnCompositor();
}
// Opacity utility functions.
bool HasOpacity() const { return Opacity() < 1.0f; }
// Table layout utility functions.
bool IsFixedTableLayout() const {
if (RuntimeEnabledFeatures::TableIsAutoFixedLayoutEnabled()) {
// https://github.com/w3c/csswg-drafts/issues/10937
return TableLayout() == ETableLayout::kFixed && !LogicalWidth().IsAuto();
}
// https://www.w3.org/TR/css-tables-3/#table-layout-property
return TableLayout() == ETableLayout::kFixed &&
(!LogicalWidth().HasAuto() && !LogicalWidth().HasMaxContent());
}
LogicalSize TableBorderSpacing() const {
if (BorderCollapse() == EBorderCollapse::kCollapse) {
return LogicalSize();
}
return LogicalSize(LayoutUnit(HorizontalBorderSpacing()),
LayoutUnit(VerticalBorderSpacing()));
}
// Returns true if the computed style contains a 3D transform operation. This
// can be individual operations from the transform property, or individual
// values from translate/rotate/scale properties. Perspective is omitted since
// it does not, by itself, specify a 3D transform.
bool Has3DTransformOperation() const {
return Transform().HasNonPerspective3DOperation() ||
(Translate() && Translate()->Z() != 0) ||
(Rotate() && (Rotate()->X() != 0 || Rotate()->Y() != 0)) ||
(Scale() && Scale()->Z() != 1);
}
bool HasTransform() const {
return HasTransformOperations() || HasOffset() ||
HasCurrentTransformRelatedAnimation() || Translate() || Rotate() ||
Scale();
}
bool HasTransformOperations() const {
return !Transform().Operations().empty();
}
ETransformStyle3D UsedTransformStyle3D() const {
if (TransformStyle3D() == ETransformStyle3D::kFlat) {
return ETransformStyle3D::kFlat;
}
// Even if the user specified transform-style: preserves-3d (which is
// non-default), it could be overridden by a number of other properties.
// These checks are fairly expensive (since there are so many of them),
// so we only bother going through them if needed.
DCHECK_EQ(TransformStyle3D(), ETransformStyle3D::kPreserve3d);
return HasGroupingPropertyForUsedTransformStyle3D()
? ETransformStyle3D::kFlat
: ETransformStyle3D::kPreserve3d;
}
bool Preserves3D() const {
return UsedTransformStyle3D() != ETransformStyle3D::kFlat;
}
enum ApplyTransformOrigin {
kIncludeTransformOrigin,
kExcludeTransformOrigin
};
enum ApplyMotionPath { kIncludeMotionPath, kExcludeMotionPath };
enum ApplyIndependentTransformProperties {
kIncludeIndependentTransformProperties,
kExcludeIndependentTransformProperties
};
enum ApplyTransformOperations {
kIncludeTransformOperations,
kExcludeTransformOperations
};
void ApplyTransform(gfx::Transform&,
const LayoutBox* box,
const PhysicalRect& reference_box,
ApplyTransformOperations,
ApplyTransformOrigin,
ApplyMotionPath,
ApplyIndependentTransformProperties) const;
void ApplyTransform(gfx::Transform&,
const LayoutBox* box,
const gfx::RectF& reference_box,
ApplyTransformOperations,
ApplyTransformOrigin,
ApplyMotionPath,
ApplyIndependentTransformProperties) const;
enum class TransformBoxContext {
kLayoutBox, // For elements with an associated CSS layout box.
kSvg, // For SVG elements without an associated CSS layout box.
};
ETransformBox UsedTransformBox(TransformBoxContext) const;
bool HasBoxReflect() const { return BoxReflect(); }
// Returns |true| if any property that renders using filter operations is
// used (including, but not limited to, 'filter' and 'box-reflect').
bool HasFilterInducingProperty() const {
return HasNonInitialFilter() || HasBoxReflect();
}
// Returns |true| if filter should be considered to have non-initial value
// for the purposes of containing blocks.
bool HasNonInitialFilter() const {
return HasFilter() || HasWillChangeFilterHint();
}
// Returns |true| if backdrop-filter should be considered to have non-initial
// value for the purposes of containing blocks.
bool HasNonInitialBackdropFilter() const {
return HasBackdropFilter() || HasWillChangeBackdropFilterHint();
}
// Returns |true| if opacity should be considered to have non-initial value
// for the purpose of creating stacking contexts.
bool HasNonInitialOpacity() const {
return HasOpacity() || HasWillChangeOpacityHint() ||
HasCurrentOpacityAnimation();
}
// Returns whether this style contains any grouping property as defined by
// https://drafts.csswg.org/css-transforms-2/#grouping-property-values.
//
// |has_box_reflection| is a parameter instead of checking |BoxReflect()|
// because box reflection styles only apply for some objects (see:
// |LayoutObject::HasReflection()|).
bool HasGroupingProperty(bool has_box_reflection) const {
if (HasStackingGroupingProperty(has_box_reflection)) {
return true;
}
// TODO(pdr): Also check for overflow because the spec requires "overflow:
// any value other than visible or clip."
if (!HasAutoClip() && HasOutOfFlowPosition()) {
return true;
}
return false;
}
// This is the subset of grouping properties (see: |HasGroupingProperty|) that
// also create stacking contexts.
bool HasStackingGroupingProperty(bool has_box_reflection) const {
if (HasNonInitialOpacity()) {
return true;
}
if (HasNonInitialFilter()) {
return true;
}
if (has_box_reflection) {
return true;
}
if (HasClipPath()) {
return true;
}
if (HasIsolation()) {
return true;
}
if (HasMask()) {
return true;
}
if (HasBlendMode()) {
return true;
}
if (HasNonInitialBackdropFilter()) {
return true;
}
if (ViewTransitionName() || ElementIsViewTransitionParticipant()) {
return true;
}
return false;
}
// Grouping requires creating a flattened representation of the descendant
// elements before they can be applied, and therefore force the element to
// have a used style of flat for preserve-3d.
CORE_EXPORT bool HasGroupingPropertyForUsedTransformStyle3D() const {
return HasGroupingProperty(BoxReflect()) ||
!IsOverflowVisibleAlongBothAxes();
}
// Return true if any transform related property (currently
// transform/motionPath, transformStyle3D, perspective, or
// will-change:transform) indicates that we are transforming.
// will-change:transform should result in the same rendering behavior as
// having a transform, including the creation of a containing block for fixed
// position descendants.
bool HasTransformRelatedProperty() const {
return HasTransform() || Preserves3D() || HasPerspective() ||
HasWillChangeHintForAnyTransformProperty();
}
bool HasTransformRelatedPropertyForSVG() const {
return HasTransform() || HasWillChangeHintForAnyTransformProperty();
}
// Return true if this style has properties ('filter', 'clip-path' and 'mask')
// that applies an effect to SVG elements.
bool HasSVGEffect() const {
return HasFilter() || HasClipPath() || HasMask();
}
// Returns true if any property has an <image> value that is a CSS paint
// function that is using a given custom property.
bool HasCSSPaintImagesUsingCustomProperty(
const AtomicString& custom_property_name,
const Document&) const;
// FIXME: reflections should belong to this helper function but they are
// currently handled through their self-painting layers. So the layout code
// doesn't account for them.
bool HasVisualOverflowingEffect() const {
return BoxShadow() || HasBorderImageOutsets() || HasOutline() ||
HasMaskBoxImageOutsets() || HasGapRule();
}
bool IsStackedWithoutContainment() const {
return IsStackingContextWithoutContainment() ||
GetPosition() != EPosition::kStatic;
}
// Pseudo element styles.
static bool HasPseudoElementStyle(unsigned pseudo_styles, PseudoId pseudo) {
DCHECK(pseudo >= kFirstPublicPseudoId);
DCHECK(pseudo <= kLastTrackedPublicPseudoId);
return (1 << (pseudo - kFirstPublicPseudoId)) & pseudo_styles;
}
bool HasAnyPseudoElementStyles() const;
bool HasAnyHighlightPseudoElementStyles() const;
bool HasPseudoElementStyle(PseudoId pseudo) const {
return ComputedStyle::HasPseudoElementStyle(PseudoElementStylesInternal(),
pseudo);
}
// This function may return values not defined as the enum values. See
// `EWhiteSpace`. Prefer using semantic functions below.
EWhiteSpace WhiteSpace() const {
return ToWhiteSpace(GetWhiteSpaceCollapse(), GetTextWrapMode());
}
// Semantic functions for the `white-space` property and its longhands.
bool ShouldPreserveWhiteSpaces() const {
return blink::ShouldPreserveWhiteSpaces(GetWhiteSpaceCollapse());
}
bool ShouldCollapseWhiteSpaces() const {
return blink::ShouldCollapseWhiteSpaces(GetWhiteSpaceCollapse());
}
bool ShouldPreserveBreaks() const {
return blink::ShouldPreserveBreaks(GetWhiteSpaceCollapse());
}
bool ShouldCollapseBreaks() const {
return blink::ShouldCollapseBreaks(GetWhiteSpaceCollapse());
}
bool IsCollapsibleWhiteSpace(UChar c) const {
switch (c) {
case ' ':
case '\t':
return ShouldCollapseWhiteSpaces();
case '\n':
return ShouldCollapseBreaks();
}
return false;
}
bool ShouldWrapLine() const {
return blink::ShouldWrapLine(GetTextWrapMode());
}
bool ShouldWrapLineGreedy() const {
return blink::ShouldWrapLineGreedy(GetTextWrapStyle());
}
bool ShouldBreakSpaces() const {
return blink::ShouldBreakSpaces(GetWhiteSpaceCollapse());
}
bool ShouldBreakOnlyAfterWhiteSpace() const {
return (ShouldPreserveWhiteSpaces() && ShouldWrapLine()) ||
GetLineBreak() == LineBreak::kAfterWhiteSpace;
}
bool NeedsTrailingSpace() const {
return ShouldBreakOnlyAfterWhiteSpace() && ShouldWrapLine();
}
bool ShouldBreakWords() const {
return (WordBreak() == EWordBreak::kBreakWord ||
OverflowWrap() != EOverflowWrap::kNormal) &&
ShouldWrapLine();
}
// Text direction utility functions.
bool ShouldPlaceBlockDirectionScrollbarOnLogicalLeft() const {
return !IsLeftToRightDirection() && IsHorizontalWritingMode();
}
// Border utility functions.
static bool BorderStyleIsVisible(EBorderStyle style) {
return style != EBorderStyle::kNone && style != EBorderStyle::kHidden;
}
// Rule utility functions.
static bool BorderStyleIsVisible(const GapDataList<EBorderStyle>& styles) {
for (const auto& style : styles.GetGapDataList()) {
if (!style.IsRepeaterData()) {
// Simple single value, check directly.
if (BorderStyleIsVisible(style.GetValue())) {
return true;
}
} else {
// Repeater value, check each repeated value.
for (const auto& repeated_style :
style.GetValueRepeater()->RepeatedValues()) {
if (BorderStyleIsVisible(repeated_style)) {
return true;
}
}
}
}
return false;
}
static bool HasRuleWidth(const GapDataList<int>& widths) {
for (const auto& width : widths.GetGapDataList()) {
if (!width.IsRepeaterData()) {
// Simple single value, check directly.
if (width.GetValue() != 0) {
return true;
}
} else {
// Repeater value, check each repeated value.
for (const auto& repeated_width :
width.GetValueRepeater()->RepeatedValues()) {
if (repeated_width != 0) {
return true;
}
}
}
}
return false;
}
bool BorderObscuresBackground() const;
void GetBorderEdgeInfo(
BorderEdgeArray& edges,
PhysicalBoxSides sides_to_include = PhysicalBoxSides()) const;
bool HasBoxDecorations() const {
return HasBorderDecoration() || HasBorderRadius() || HasOutline() ||
HasEffectiveAppearance() || BoxShadow() ||
HasFilterInducingProperty() || HasNonInitialBackdropFilter() ||
HasResize();
}
// "Box decoration background" includes all box decorations and backgrounds
// that are painted as the background of the object. It includes borders,
// box-shadows, background-color and background-image, etc.
bool HasBoxDecorationBackground() const {
return HasBackground() || HasBorderDecoration() ||
HasEffectiveAppearance() || BoxShadow();
}
PhysicalBoxStrut BoxDecorationOutsets() const;
// Background utility functions.
const FillLayer& BackgroundLayers() const { return BackgroundInternal(); }
bool HasBackgroundRelatedColorReferencingCurrentColor() const {
if (BackgroundColor().IsCurrentColor() ||
InternalVisitedBackgroundColor().IsCurrentColor() ||
InternalForcedBackgroundColor().IsCurrentColor()) {
return true;
}
if (!BoxShadow()) {
return false;
}
return ShadowListHasCurrentColor(BoxShadow());
}
CORE_EXPORT bool HasBackground() const;
// Color utility functions.
CORE_EXPORT blink::Color VisitedDependentColor(
const Longhand& color_property,
bool* is_current_color = nullptr) const;
// Used to resolve gap decoration colors for painting.
CORE_EXPORT blink::Color VisitedDependentGapColor(const StyleColor& gap_color,
const ComputedStyle& style,
bool is_column_rule) const;
// Used to resolve 'context-fill' and 'context-stroke' paints
CORE_EXPORT blink::Color VisitedDependentContextFill(
const SVGPaint& context_paint,
const ComputedStyle& context_style) const;
CORE_EXPORT blink::Color VisitedDependentContextStroke(
const SVGPaint& context_paint,
const ComputedStyle& context_style) const;
// A faster version of VisitedDependentColor() that specializes on the
// concrete property class; for the common case of not being inside a link,
// can inline the question in function directly. However, it uses more code
// space, so only use it on code paths that are actually hot.
template <class Property>
blink::Color VisitedDependentColorFast(
const Property& color_property,
bool* is_current_color = nullptr) const {
DCHECK(!Property().IsVisited());
if (InsideLink() != EInsideLink::kInsideVisitedLink) {
blink::Color color =
color_property.ColorIncludingFallback(false, *this,
/*is_current_color=*/nullptr);
DCHECK(color == VisitedDependentColor(color_property, is_current_color));
return color;
} else {
return VisitedDependentColor(color_property, is_current_color);
}
}
// -webkit-appearance utility functions.
static bool HasEffectiveAppearance(AppearanceValue effective_appearance) {
return effective_appearance != AppearanceValue::kNone;
}
bool HasEffectiveAppearance() const {
return HasEffectiveAppearance(EffectiveAppearance());
}
// Other utility functions.
bool RequireTransformOrigin(ApplyTransformOrigin apply_origin,
ApplyMotionPath) const;
InterpolationQuality GetInterpolationQuality() const;
bool CanGeneratePseudoElement(PseudoId pseudo) const {
if (Display() == EDisplay::kNone) {
return false;
}
if (IsEnsuredInDisplayNone()) {
return false;
}
if (pseudo == kPseudoIdMarker) {
return IsDisplayListItem();
}
if (pseudo == kPseudoIdBackdrop && Overlay() == EOverlay::kNone) {
return false;
}
if (pseudo == kPseudoIdScrollMarkerGroupBefore) {
return ScrollMarkerGroup() == EScrollMarkerGroup::kBefore &&
IsScrollContainer();
}
if (pseudo == kPseudoIdScrollMarkerGroupAfter) {
return ScrollMarkerGroup() == EScrollMarkerGroup::kAfter &&
IsScrollContainer();
}
if (pseudo == kPseudoIdScrollButtonBlockStart ||
pseudo == kPseudoIdScrollButtonInlineStart ||
pseudo == kPseudoIdScrollButtonInlineEnd ||
pseudo == kPseudoIdScrollButtonBlockEnd) {
return HasPseudoElementStyle(kPseudoIdScrollButton);
}
if (!HasPseudoElementStyle(pseudo)) {
return false;
}
if (Display() != EDisplay::kContents) {
return true;
}
// For display: contents elements, we still need to generate ::before and
// ::after, but the rest of the pseudo-elements should only be used for
// elements with an actual layout object.
return pseudo == kPseudoIdCheckMark || pseudo == kPseudoIdBefore ||
pseudo == kPseudoIdAfter || pseudo == kPseudoIdPickerIcon;
}
bool HasScrollMarkerGroupBefore() const {
return ScrollMarkerGroup() == EScrollMarkerGroup::kBefore;
}
bool HasScrollMarkerGroupAfter() const {
return ScrollMarkerGroup() == EScrollMarkerGroup::kAfter;
}
bool ScrollMarkerGroupNone() const {
return ScrollMarkerGroup() == EScrollMarkerGroup::kNone;
}
bool ScrollMarkerGroupEqual(const ComputedStyle& other) const {
return ScrollMarkerGroup() == other.ScrollMarkerGroup();
}
bool ScrollMarkerContainNone() const {
return ScrollMarkerContain() == EScrollMarkerContain::kNone;
}
PhysicalBoxStrut ScrollMarginStrut() const {
return {LayoutUnit(ScrollMarginTop()), LayoutUnit(ScrollMarginRight()),
LayoutUnit(ScrollMarginBottom()), LayoutUnit(ScrollMarginLeft())};
}
// Returns true if the element is rendered in the top layer. That is the case
// when the overlay property computes to 'auto', or when the element is a
// ::backdrop pseudo.
bool IsRenderedInTopLayer(const Element& element) const;
// Load the images of CSS properties that were deferred by LazyLoad.
void LoadDeferredImages(Document&) const;
static mojom::blink::ColorScheme UsedColorScheme(bool is_dark_color_scheme) {
return is_dark_color_scheme ? mojom::blink::ColorScheme::kDark
: mojom::blink::ColorScheme::kLight;
}
mojom::blink::ColorScheme UsedColorScheme() const {
return UsedColorScheme(DarkColorScheme());
}
bool GeneratesMarkerImage() const {
return IsDisplayListItem() && ListStyleImage() &&
!ListStyleImage()->ErrorOccurred() &&
(ListStyleImage()->IsLoading() || ListStyleImage()->IsLoaded());
}
LogicalSize LogicalAspectRatio() const {
DCHECK_NE(AspectRatio().GetType(), EAspectRatioType::kAuto);
return ToLogicalSize(AspectRatio().GetLayoutRatio(), GetWritingMode());
}
EBoxSizing BoxSizingForAspectRatio() const {
if (AspectRatio().GetType() == EAspectRatioType::kRatio) {
return BoxSizing();
}
return EBoxSizing::kContentBox;
}
bool ForceDark() const { return DarkColorScheme() && ColorSchemeForced(); }
bool HasStaticViewportUnits() const {
return ViewportUnitFlags() &
static_cast<unsigned>(ViewportUnitFlag::kStatic);
}
bool HasDynamicViewportUnits() const {
return ViewportUnitFlags() &
static_cast<unsigned>(ViewportUnitFlag::kDynamic);
}
bool HasViewportUnits() const { return ViewportUnitFlags(); }
bool OverflowClipMarginHasAnEffect() const {
return OverflowClipMargin() &&
(OverflowClipMargin()->GetReferenceBox() !=
StyleOverflowClipMargin::ReferenceBox::kPaddingBox ||
OverflowClipMargin()->GetMargin() != LayoutUnit());
}
// Field-sizing utility function:
// Returns true if field-sizing:fixed or node's owner form control is
// autofilled.
bool ApplyControlFixedSize(const Node* node) const;
bool HasPositionVisibility(PositionVisibility visibility) const {
return (static_cast<int>(GetPositionVisibility()) &
static_cast<int>(visibility)) == static_cast<int>(visibility);
}
private:
bool IsInlineSizeContainer() const {
return ContainerType() & kContainerTypeInlineSize;
}
bool IsBlockSizeContainer() const {
return ContainerType() & kContainerTypeBlockSize;
}
bool IsInlineOrBlockSizeContainer() const {
return ContainerType() & kContainerTypeSize;
}
bool IsSizeContainer() const {
return (ContainerType() & kContainerTypeSize) == kContainerTypeSize;
}
bool IsScrollStateContainer() const {
return ContainerType() & kContainerTypeScrollState;
}
bool IsAnchoredContainer() const {
return ContainerType() & kContainerTypeAnchored;
}
static bool IsDisplayBlockContainer(EDisplay display) {
return display == EDisplay::kBlock || display == EDisplay::kListItem ||
display == EDisplay::kInlineBlock ||
display == EDisplay::kFlowRoot ||
display == EDisplay::kFlowRootListItem ||
display == EDisplay::kInlineFlowRootListItem ||
display == EDisplay::kTableCell ||
display == EDisplay::kTableCaption;
}
static bool IsDisplayTableBox(EDisplay display) {
return display == EDisplay::kTable || display == EDisplay::kInlineTable;
}
static bool IsDisplayFlexibleBox(EDisplay display) {
return display == EDisplay::kFlex || display == EDisplay::kInlineFlex;
}
static bool IsDisplayGridBox(EDisplay display) {
return display == EDisplay::kGrid || display == EDisplay::kInlineGrid;
}
static bool IsDisplayMasonryBox(EDisplay display) {
return display == EDisplay::kMasonry || display == EDisplay::kInlineMasonry;
}
static bool IsDisplayMathBox(EDisplay display) {
return display == EDisplay::kMath || display == EDisplay::kBlockMath;
}
static bool IsDisplayLayoutCustomBox(EDisplay display) {
return display == EDisplay::kLayoutCustom ||
display == EDisplay::kInlineLayoutCustom;
}
static bool IsDisplayReplacedType(EDisplay display) {
return display == EDisplay::kInlineBlock ||
display == EDisplay::kInlineFlex ||
display == EDisplay::kInlineFlowRootListItem ||
display == EDisplay::kInlineGrid ||
display == EDisplay::kInlineLayoutCustom ||
display == EDisplay::kInlineMasonry ||
display == EDisplay::kInlineTable || display == EDisplay::kMath ||
display == EDisplay::kWebkitInlineBox;
}
static bool IsDisplayInlineType(EDisplay display) {
return display == EDisplay::kInline ||
display == EDisplay::kInlineListItem || display == EDisplay::kRuby ||
IsDisplayReplacedType(display);
}
static bool IsDisplayTableType(EDisplay display) {
return display == EDisplay::kTable || display == EDisplay::kInlineTable ||
display == EDisplay::kTableRowGroup ||
display == EDisplay::kTableHeaderGroup ||
display == EDisplay::kTableFooterGroup ||
display == EDisplay::kTableRow ||
display == EDisplay::kTableColumnGroup ||
display == EDisplay::kTableColumn ||
display == EDisplay::kTableCell ||
display == EDisplay::kTableCaption;
}
[[nodiscard]] bool HasPropertyDependingOnCurrentColor() const;
bool BorderOutlineVisitedColorChanged(const ComputedStyle& other) const {
// Only invalidate if the border/outline is present.
if (BorderTopWidth() && InternalVisitedBorderTopColor() !=
other.InternalVisitedBorderTopColor()) {
return true;
}
if (BorderRightWidth() && InternalVisitedBorderRightColor() !=
other.InternalVisitedBorderRightColor()) {
return true;
}
if (BorderBottomWidth() && InternalVisitedBorderBottomColor() !=
other.InternalVisitedBorderBottomColor()) {
return true;
}
if (BorderLeftWidth() && InternalVisitedBorderLeftColor() !=
other.InternalVisitedBorderLeftColor()) {
return true;
}
if (OutlineWidth() &&
InternalVisitedOutlineColor() != other.InternalVisitedOutlineColor()) {
return true;
}
return false;
}
StyleColor DecorationColorIncludingFallback(bool visited_link) const;
bool HasAppearance() const { return Appearance() != AppearanceValue::kNone; }
void ApplyMotionPathTransform(float origin_x,
float origin_y,
const LayoutBox* box,
const gfx::RectF& bounding_box,
gfx::Transform&) const;
PointAndTangent CalculatePointAndTangentOnBasicShape(
const BasicShape& shape,
const gfx::PointF& starting_point,
const gfx::SizeF& reference_box_size) const;
PointAndTangent CalculatePointAndTangentOnRay(
const StyleRay& ray,
const LayoutBox* box,
const gfx::PointF& starting_point,
const gfx::SizeF& reference_box_size) const;
PointAndTangent CalculatePointAndTangentOnPath(const Path& path) const;
bool DiffNeedsFullLayoutAndPaintInvalidation(const ComputedStyle& other,
uint64_t field_diff) const;
bool DiffNeedsFullLayout(const Document&,
const ComputedStyle& other,
uint64_t field_diff) const;
bool DiffNeedsFullLayoutForLayoutCustom(const Document&,
const ComputedStyle& other) const;
bool DiffNeedsFullLayoutForLayoutCustomChild(
const Document&,
const ComputedStyle& other) const;
bool DiffNeedsNormalPaintInvalidation(const Document&,
const ComputedStyle& other,
uint64_t field_diff) const;
bool DiffNeedsPaintInvalidationForPaintImage(const StyleImage&,
const ComputedStyle& other,
const Document&) const;
bool DiffNeedsRecomputeVisualOverflow(const ComputedStyle& other,
uint64_t field_diff) const;
bool DiffCompositingReasonsChanged(const ComputedStyle& other,
uint64_t field_diff) const;
bool PotentialCompositingReasonsFor3DTransformChanged(
const ComputedStyle& other) const;
bool PropertiesEqual(const Vector<CSSPropertyID>& properties,
const ComputedStyle& other) const;
CORE_EXPORT bool CustomPropertiesEqual(const Vector<AtomicString>& properties,
const ComputedStyle& other) const;
CORE_EXPORT blink::Color GetCurrentColor(
bool* is_current_color = nullptr) const;
blink::Color GetInternalVisitedCurrentColor(
bool* is_current_color = nullptr) const;
blink::Color GetInternalForcedCurrentColor(
bool* is_current_color = nullptr) const;
blink::Color GetInternalForcedVisitedCurrentColor(
bool* is_current_color = nullptr) const;
blink::Color VisitedDependentContextPaint(
const SVGPaint& context_paint,
const SVGPaint& context_visited_paint) const;
// Helper for resolving a StyleColor which may contain currentColor or a
// system color keyword. This is intended for cases where a given property
// consists of a StyleColor plus additional information. For <color>
// properties, prefer VisitedDependentColor() or
// Longhand::ColorIncludingFallback() instead.
blink::Color ResolvedColor(const StyleColor& color,
bool* is_current_color = nullptr) const;
static bool ShadowListHasCurrentColor(const ShadowList*);
PhysicalToLogical<const Length&> PhysicalMarginToLogical(
const ComputedStyle& other) const {
return PhysicalToLogical<const Length&>(other.GetWritingDirection(),
MarginTop(), MarginRight(),
MarginBottom(), MarginLeft());
}
PhysicalToLogical<const Length&> PhysicalPaddingToLogical() const {
return PhysicalToLogical<const Length&>(GetWritingDirection(), PaddingTop(),
PaddingRight(), PaddingBottom(),
PaddingLeft());
}
PhysicalToLogical<int> PhysicalBorderWidthToLogical() const {
return PhysicalToLogical<int>(GetWritingDirection(), BorderTopWidth(),
BorderRightWidth(), BorderBottomWidth(),
BorderLeftWidth());
}
PhysicalToLogical<EBorderStyle> PhysicalBorderStyleToLogical() const {
return PhysicalToLogical<EBorderStyle>(
GetWritingDirection(), BorderTopStyle(), BorderRightStyle(),
BorderBottomStyle(), BorderLeftStyle());
}
PhysicalToLogical<const Length&> PhysicalBoundsToLogical() const {
return PhysicalToLogical<const Length&>(GetWritingDirection(), Top(),
Right(), Bottom(), Left());
}
static Difference ComputeDifferenceIgnoringInheritedFirstLineStyle(
const ComputedStyle& old_style,
const ComputedStyle& new_style);
static bool ShouldForceColor(bool in_forced_colors_mode,
EForcedColorAdjust forced_color_adjust,
const StyleColor& unforced_color) {
return in_forced_colors_mode &&
forced_color_adjust == EForcedColorAdjust::kAuto &&
!unforced_color.IsSystemColorIncludingDeprecated();
}
bool ShouldForceColor(const StyleColor& unforced_color) const {
// If any other properties are added that are affected by ForcedColors mode,
// adjust EditingStyle::RemoveForcedColorsIfNeeded and
// EditingStyle::MergeStyleFromRulesForSerialization accordingly.
return ShouldForceColor(InForcedColorsMode(), ForcedColorAdjust(),
unforced_color);
}
// Returns true if the value for "display" is "none" on the scrollbar
// pseudo-element.
bool ScrollbarIsHiddenByCustomStyle(Element* element) const;
// Derived flags:
bool CalculateIsStackingContextWithoutContainment() const;
CORE_EXPORT bool GapRuleColorIsTransparent(
const GapDataList<StyleColor>& gap_rule_color) const;
FRIEND_TEST_ALL_PREFIXES(ComputedStyleTest, CustomPropertiesEqual_Values);
FRIEND_TEST_ALL_PREFIXES(ComputedStyleTest, CustomPropertiesEqual_Data);
FRIEND_TEST_ALL_PREFIXES(StyleCascadeTest, ForcedVisitedBackgroundColor);
FRIEND_TEST_ALL_PREFIXES(StyleEngineTest, ScrollbarStyleNoExcessiveCaching);
FRIEND_TEST_ALL_PREFIXES(PermissionShadowElementTest,
PropagateCSSPropertyInnerElement);
};
inline bool ComputedStyle::HasAnyPseudoElementStyles() const {
return !!PseudoElementStylesInternal();
}
inline bool ComputedStyle::HasAnyHighlightPseudoElementStyles() const {
static_assert(kPseudoIdSelection >= kFirstPublicPseudoId &&
kPseudoIdSelection <= kLastTrackedPublicPseudoId,
"kPseudoIdSelection must be public");
static_assert(kPseudoIdSearchText >= kFirstPublicPseudoId &&
kPseudoIdSearchText <= kLastTrackedPublicPseudoId,
"kPseudoIdSearchText must be public");
static_assert(kPseudoIdTargetText >= kFirstPublicPseudoId &&
kPseudoIdTargetText <= kLastTrackedPublicPseudoId,
"kPseudoIdTargetText must be public");
static_assert(kPseudoIdSpellingError >= kFirstPublicPseudoId &&
kPseudoIdSpellingError <= kLastTrackedPublicPseudoId,
"kPseudoIdSpellingError must be public");
static_assert(kPseudoIdGrammarError >= kFirstPublicPseudoId &&
kPseudoIdGrammarError <= kLastTrackedPublicPseudoId,
"kPseudoIdGrammarError must be public");
static_assert(kPseudoIdHighlight >= kFirstPublicPseudoId &&
kPseudoIdHighlight <= kLastTrackedPublicPseudoId,
"kPseudoIdHighlight must be public");
const unsigned mask = (1 << (kPseudoIdSelection - kFirstPublicPseudoId)) |
(1 << (kPseudoIdSearchText - kFirstPublicPseudoId)) |
(1 << (kPseudoIdTargetText - kFirstPublicPseudoId)) |
(1 << (kPseudoIdSpellingError - kFirstPublicPseudoId)) |
(1 << (kPseudoIdGrammarError - kFirstPublicPseudoId)) |
(1 << (kPseudoIdHighlight - kFirstPublicPseudoId));
return mask & PseudoElementStylesInternal();
}
class ComputedStyleBuilder final : public ComputedStyleBuilderBase {
STACK_ALLOCATED();
public:
friend class ColorPropertyFunctions;
// Access to Appearance().
friend class LayoutTheme;
friend class StyleAdjuster;
friend class StyleResolverState;
friend class StyleResolver;
// Access to UserModify().
friend class MatchedPropertiesCache;
// Creates a new ComputedStyle based on the given initial style.
CORE_EXPORT explicit ComputedStyleBuilder(const ComputedStyle& style);
// Creates a new ComputedStyle based on the given initial style,
// but with all inheritable properties from the given parent style.
CORE_EXPORT ComputedStyleBuilder(
const ComputedStyle& initial_style,
const ComputedStyle& parent_style,
IsAtShadowBoundary is_at_shadow_boundary = kNotAtShadowBoundary);
ComputedStyleBuilder(const ComputedStyleBuilder& builder) = delete;
ComputedStyleBuilder(ComputedStyleBuilder&&) = default;
ComputedStyleBuilder& operator=(const ComputedStyleBuilder&) = delete;
ComputedStyleBuilder& operator=(ComputedStyleBuilder&&) = default;
CORE_EXPORT const ComputedStyle* TakeStyle();
// NOTE: Prefer `TakeStyle()` if possible.
CORE_EXPORT const ComputedStyle* CloneStyle() const;
// Copies the values of any independent inherited properties from the parent
// that are not explicitly set in this style.
void PropagateIndependentInheritedProperties(
const ComputedStyle& parent_style);
// Pseudo-elements
bool HasPseudoElementStyle(PseudoId pseudo) const {
return ComputedStyle::HasPseudoElementStyle(PseudoElementStylesInternal(),
pseudo);
}
// animations
const CSSAnimationData* Animations() const {
return AnimationsInternal().get();
}
CORE_EXPORT CSSAnimationData& AccessAnimations() {
std::unique_ptr<CSSAnimationData>& animations = MutableAnimationsInternal();
if (!animations) {
animations = std::make_unique<CSSAnimationData>();
}
return *animations;
}
// appearance
bool HasEffectiveAppearance() const {
return ComputedStyle::HasEffectiveAppearance(EffectiveAppearance());
}
bool HasBaseSelectAppearance() const {
return Appearance() == AppearanceValue::kBaseSelect;
}
// backdrop-filter
FilterOperations::FilterOperationVector& MutableBackdropFilterOperations() {
return MutableBackdropFilterInternal().Operations();
}
bool HasBackdropFilter() const {
return ComputedStyle::HasBackdropFilter(BackdropFilter());
}
// background
FillLayer& AccessBackgroundLayers() { return MutableBackgroundInternal(); }
void AdjustBackgroundLayers() {
if (BackgroundInternal().Next()) {
AccessBackgroundLayers().CullEmptyLayers();
AccessBackgroundLayers().FillUnsetProperties();
}
}
bool HasUrlBackgroundImage() const {
return BackgroundInternal().AnyLayerHasUrlImage();
}
void ClearBackgroundImage();
// border-*-color
void SetBorderColorFrom(const ComputedStyle& other) {
SetBorderBottomColor(other.BorderBottomColor());
SetBorderLeftColor(other.BorderLeftColor());
SetBorderRightColor(other.BorderRightColor());
SetBorderTopColor(other.BorderTopColor());
}
// border-*-width
int BorderTopWidth() const {
return ComputedStyle::BorderWidth(BorderTopStyle(),
BorderTopWidthInternal());
}
int BorderBottomWidth() const {
return ComputedStyle::BorderWidth(BorderBottomStyle(),
BorderBottomWidthInternal());
}
int BorderLeftWidth() const {
return ComputedStyle::BorderWidth(BorderLeftStyle(),
BorderLeftWidthInternal());
}
int BorderRightWidth() const {
return ComputedStyle::BorderWidth(BorderRightStyle(),
BorderRightWidthInternal());
}
// border-image-*
void SetBorderImageOutset(const BorderImageLengthBox& outset) {
if (BorderImage().Outset() == outset) {
return;
}
MutableBorderImageInternal().SetOutset(outset);
}
void SetBorderImageSlices(const LengthBox& slices) {
if (BorderImage().ImageSlices() == slices) {
return;
}
MutableBorderImageInternal().SetImageSlices(slices);
}
void SetBorderImageSlicesFill(bool fill) {
if (BorderImage().Fill() == fill) {
return;
}
MutableBorderImageInternal().SetFill(fill);
}
void SetBorderImageSource(StyleImage* image) {
if (BorderImage().GetImage() == image) {
return;
}
MutableBorderImageInternal().SetImage(image);
}
void SetBorderImageWidth(const BorderImageLengthBox& slices) {
if (BorderImage().BorderSlices() == slices) {
return;
}
MutableBorderImageInternal().SetBorderSlices(slices);
}
// clip
void SetClip(const LengthBox& box) {
SetHasAutoClipInternal(false);
SetClipInternal(box);
}
void SetHasAutoClip() {
SetHasAutoClipInternal(true);
SetClipInternal(ComputedStyleInitialValues::InitialClip());
}
// clip-path
void SetClipPath(ClipPathOperation* clip_path) {
SetHasClipPath(clip_path);
SetClipPathInternal(clip_path);
}
ClipPathOperation* MutableClipPath() { return ClipPathInternal().Get(); }
// color
blink::Color GetCurrentColor() const {
return Color().Resolve(blink::Color(), UsedColorScheme());
}
// column-count
void SetColumnCount(uint16_t c) {
SetHasAutoColumnCountInternal(false);
SetColumnCountInternal(ClampTo<uint16_t>(c, 1));
}
void SetHasAutoColumnCount() {
SetHasAutoColumnCountInternal(true);
SetColumnCountInternal(ComputedStyleInitialValues::InitialColumnCount());
}
// column-rule-color
void SetColumnRuleColor(const GapDataList<StyleColor>& colors) {
SetMaybeHasGapDecorations();
SetColumnRuleColorInternal(colors);
}
// row-rule-color
void SetRowRuleColor(const GapDataList<StyleColor>& colors) {
SetMaybeHasGapDecorations();
SetRowRuleColorInternal(colors);
}
// column-rule-style
void SetColumnRuleStyle(const GapDataList<EBorderStyle>& styles) {
SetMaybeHasGapDecorations();
SetColumnRuleStyleInternal(styles);
}
// row-rule-style
void SetRowRuleStyle(const GapDataList<EBorderStyle>& styles) {
SetMaybeHasGapDecorations();
SetRowRuleStyleInternal(styles);
}
// column-rule-width
void SetColumnRuleWidth(const GapDataList<int>& widths) {
SetMaybeHasGapDecorations();
SetColumnRuleWidthInternal(widths);
}
// row-rule-width
void SetRowRuleWidth(const GapDataList<int>& widths) {
SetMaybeHasGapDecorations();
SetRowRuleWidthInternal(widths);
}
// column-width
void SetColumnWidth(float f) {
SetHasAutoColumnWidthInternal(false);
SetColumnWidthInternal(f);
}
void SetHasAutoColumnWidth() {
SetHasAutoColumnWidthInternal(true);
SetColumnWidthInternal(0);
}
// column-height
void SetColumnHeight(float f) {
SetHasAutoColumnHeightInternal(false);
SetColumnHeightInternal(f);
}
void SetHasAutoColumnHeight() {
SetHasAutoColumnHeightInternal(true);
SetColumnHeightInternal(0);
}
// contain
bool ShouldApplyAnyContainment(const Element& element) const {
unsigned effective_containment = ComputedStyle::EffectiveContainment(
Contain(), ContainerType(), ContentVisibility(), SkipsContents());
return ComputedStyle::ShouldApplyAnyContainment(element, GetDisplayStyle(),
effective_containment);
}
// content
ContentData* GetContentData() const { return ContentInternal().Get(); }
// counter-*
CounterDirectiveMap& AccessCounterDirectives() {
std::unique_ptr<CounterDirectiveMap>& map =
MutableCounterDirectivesInternal();
if (!map) {
map = std::make_unique<CounterDirectiveMap>();
}
return *map;
}
void ClearIncrementDirectives() {
if (const auto& map = MutableCounterDirectivesInternal()) {
for (auto& value_pair : *map) {
value_pair.value.ClearIncrement();
}
}
}
void ClearResetDirectives() {
if (const auto& map = MutableCounterDirectivesInternal()) {
for (auto& value_pair : *map) {
value_pair.value.ClearReset();
}
}
}
void ClearSetDirectives() {
if (const auto& map = MutableCounterDirectivesInternal()) {
for (auto& value_pair : *map) {
value_pair.value.ClearSet();
}
}
}
// cursor
void AddCursor(StyleImage* image,
bool hot_spot_specified,
const gfx::Point& hot_spot = gfx::Point()) {
if (!CursorDataInternal()) {
SetCursorDataInternal(MakeGarbageCollected<CursorList>());
}
MutableCursorDataInternal()->push_back(
CursorData(image, hot_spot_specified, hot_spot));
}
void SetCursorList(CursorList* list) { SetCursorDataInternal(list); }
void ClearCursorList() {
if (CursorDataInternal()) {
SetCursorDataInternal(nullptr);
}
}
CursorList* Cursors() const { return CursorDataInternal().Get(); }
// display
bool IsDisplayInlineType() const {
return ComputedStyle::IsDisplayInlineType(Display());
}
bool IsDisplayReplacedType() const {
return ComputedStyle::IsDisplayReplacedType(Display());
}
bool IsDisplayMathType() const {
return ComputedStyle::IsDisplayMathBox(Display());
}
bool IsDisplayTableBox() const {
return ComputedStyle::IsDisplayTableBox(Display());
}
bool IsDisplayTableRowOrColumnType() const {
return Display() == EDisplay::kTableRow ||
Display() == EDisplay::kTableRowGroup ||
Display() == EDisplay::kTableColumn ||
Display() == EDisplay::kTableColumnGroup;
}
DisplayStyle GetDisplayStyle() const {
return DisplayStyle(Display(), StyleType(), GetContentData());
}
// filter
FilterOperations::FilterOperationVector& MutableFilterOperations() {
return MutableFilterInternal().Operations();
}
// float
bool IsFloating() const { return Floating() != EFloat::kNone; }
// font
void SetFontDescription(const FontDescription& v) {
if (GetFont()->GetFontDescription() != v) {
SetFont(MakeGarbageCollected<Font>(v, GetFont()->GetFontSelector()));
}
}
const FontDescription& GetFontDescription() const {
return GetFont()->GetFontDescription();
}
int FontSize() const { return GetFontDescription().ComputedPixelSize(); }
LayoutUnit FontHeight() const {
if (const SimpleFontData* font_data = GetFont()->PrimaryFont()) {
return LayoutUnit(font_data->GetFontMetrics().Height());
}
return LayoutUnit();
}
FontOrientation ComputeFontOrientation() const;
void UpdateFontOrientation();
FontSizeStyle GetFontSizeStyle() const {
return FontSizeStyle(GetFont(), LineHeightInternal(), EffectiveZoom());
}
// letter-spacing
void SetLetterSpacing(float letter_spacing) {
FontDescription description(GetFontDescription());
description.SetLetterSpacing(letter_spacing);
SetFontDescription(description);
}
// line-clamp
void SetHasAutoStandardLineClamp() {
SetHasAutoStandardLineClampInternal(true);
SetStandardLineClampInternal(0);
}
void SetStandardLineClamp(int v) {
SetHasAutoStandardLineClampInternal(false);
SetStandardLineClampInternal(v);
}
// line-height
bool HasInitialLineHeight() const {
return LineHeightInternal() ==
ComputedStyleInitialValues::InitialLineHeight();
}
const Length& LineHeight() const { return LineHeightInternal(); }
// margin-*
void SetMarginTop(const Length& v) {
if (MarginTop() != v) {
if (!v.IsZero() || v.IsAuto()) {
SetMayHaveMargin();
}
MutableMarginTopInternal() = v;
}
}
void SetMarginRight(const Length& v) {
if (MarginRight() != v) {
if (!v.IsZero() || v.IsAuto()) {
SetMayHaveMargin();
}
MutableMarginRightInternal() = v;
}
}
void SetMarginBottom(const Length& v) {
if (MarginBottom() != v) {
if (!v.IsZero() || v.IsAuto()) {
SetMayHaveMargin();
}
MutableMarginBottomInternal() = v;
}
}
void SetMarginLeft(const Length& v) {
if (MarginLeft() != v) {
if (!v.IsZero() || v.IsAuto()) {
SetMayHaveMargin();
}
MutableMarginLeftInternal() = v;
}
}
// mask
FillLayer& AccessMaskLayers() { return MutableMaskInternal(); }
void AdjustMaskLayers() {
if (MaskInternal().Next()) {
AccessMaskLayers().CullEmptyLayers();
AccessMaskLayers().FillUnsetProperties();
}
}
// mask-box-image-*
const NinePieceImage& MaskBoxImage() const { return MaskBoxImageInternal(); }
void SetMaskBoxImage(const NinePieceImage& b) { SetMaskBoxImageInternal(b); }
void SetMaskBoxImageOutset(const BorderImageLengthBox& outset) {
MutableMaskBoxImageInternal().SetOutset(outset);
}
void SetMaskBoxImageSlices(const LengthBox& slices) {
MutableMaskBoxImageInternal().SetImageSlices(slices);
}
void SetMaskBoxImageSlicesFill(bool fill) {
MutableMaskBoxImageInternal().SetFill(fill);
}
void SetMaskBoxImageSource(StyleImage* v) {
MutableMaskBoxImageInternal().SetImage(v);
}
void SetMaskBoxImageWidth(const BorderImageLengthBox& slices) {
MutableMaskBoxImageInternal().SetBorderSlices(slices);
}
StyleImage* MaskBoxImageSource() const {
return MaskBoxImageInternal().GetImage();
}
// opacity
void SetOpacity(float f) {
float v = ClampTo<float>(f, 0, 1);
SetOpacityInternal(v);
}
// orphans
void SetOrphans(int16_t o) { SetOrphansInternal(ClampTo<int16_t>(o, 1)); }
// overflow
bool ScrollsOverflow() const {
return ComputedStyle::ScrollsOverflow(OverflowX()) ||
ComputedStyle::ScrollsOverflow(OverflowY());
}
// padding-*
void SetPaddingTop(const Length& v) {
if (PaddingTop() != v) {
if (!v.IsZero()) {
SetMayHavePadding();
}
MutablePaddingTopInternal() = v;
}
}
void SetPaddingRight(const Length& v) {
if (PaddingRight() != v) {
if (!v.IsZero()) {
SetMayHavePadding();
}
MutablePaddingRightInternal() = v;
}
}
void SetPaddingBottom(const Length& v) {
if (PaddingBottom() != v) {
if (!v.IsZero()) {
SetMayHavePadding();
}
MutablePaddingBottomInternal() = v;
}
}
void SetPaddingLeft(const Length& v) {
if (PaddingLeft() != v) {
if (!v.IsZero()) {
SetMayHavePadding();
}
MutablePaddingLeftInternal() = v;
}
}
// perspective-origin
void SetPerspectiveOriginX(const Length& v) {
SetPerspectiveOrigin(LengthPoint(v, PerspectiveOrigin().Y()));
}
void SetPerspectiveOriginY(const Length& v) {
SetPerspectiveOrigin(LengthPoint(PerspectiveOrigin().X(), v));
}
// position
EPosition GetPosition() const {
return ComputedStyle::GetPosition(Display(), PositionInternal());
}
bool HasOutOfFlowPosition() const {
return ComputedStyle::HasOutOfFlowPosition(GetPosition());
}
// shape-image-threshold
void SetShapeImageThreshold(float shape_image_threshold) {
float clamped_shape_image_threshold =
ClampTo<float>(shape_image_threshold, 0, 1);
SetShapeImageThresholdInternal(clamped_shape_image_threshold);
}
// shape-outside
ShapeValue* ShapeOutside() const { return ShapeOutsideInternal().Get(); }
// tab-size
void SetTabSize(const TabSize& t) {
if (t.GetPixelSize(1) < 0) {
if (t.IsSpaces()) {
SetTabSizeInternal(TabSize(0, TabSizeValueType::kSpace));
} else {
SetTabSizeInternal(TabSize(0, TabSizeValueType::kLength));
}
} else {
SetTabSizeInternal(t);
}
}
// transform-origin
void SetTransformOriginX(const Length& v) {
SetTransformOrigin(
TransformOrigin(v, GetTransformOrigin().Y(), GetTransformOrigin().Z()));
}
void SetTransformOriginY(const Length& v) {
SetTransformOrigin(
TransformOrigin(GetTransformOrigin().X(), v, GetTransformOrigin().Z()));
}
void SetTransformOriginZ(float f) {
SetTransformOrigin(
TransformOrigin(GetTransformOrigin().X(), GetTransformOrigin().Y(), f));
}
// transitions
const CSSTransitionData* Transitions() const {
return TransitionsInternal().get();
}
CORE_EXPORT CSSTransitionData& AccessTransitions() {
std::unique_ptr<CSSTransitionData>& transitions =
MutableTransitionsInternal();
if (!transitions) {
transitions = std::make_unique<CSSTransitionData>();
}
return *transitions;
}
// -webkit-box-ordinal-group
void SetBoxOrdinalGroup(unsigned ordinal_group) {
SetBoxOrdinalGroupInternal(
std::min(std::numeric_limits<unsigned>::max() - 1, ordinal_group));
}
// vertical-align
void SetVerticalAlign(EVerticalAlign v) {
SetVerticalAlignInternal(static_cast<unsigned>(v));
}
void SetVerticalAlignLength(const Length& length) {
SetVerticalAlignInternal(static_cast<unsigned>(EVerticalAlign::kLength));
SetVerticalAlignLengthInternal(length);
}
// widows
void SetWidows(int16_t w) { SetWidowsInternal(ClampTo<int16_t>(w, 1)); }
// word-spacing
void SetWordSpacing(float word_spacing) {
FontDescription description(GetFontDescription());
description.SetWordSpacing(word_spacing);
SetFontDescription(description);
}
// z-index
void SetZIndex(int v) {
SetHasAutoZIndexInternal(false);
SetZIndexInternal(v);
}
void SetHasAutoZIndex() {
SetHasAutoZIndexInternal(true);
SetZIndexInternal(0);
}
// zoom
CORE_EXPORT bool SetEffectiveZoom(float);
// BaseData
const ComputedStyle* GetBaseComputedStyle() const {
if (auto* base_data = BaseData()) {
return base_data->GetBaseComputedStyle();
}
return nullptr;
}
/// CallbackSelector
void AddCallbackSelector(const String& selector) {
if (!CallbackSelectors().Contains(selector)) {
MutableCallbackSelectorsInternal().push_back(selector);
}
}
// DocumentRulesSelectors
void AddDocumentRulesSelector(StyleRule* selector) {
if (!DocumentRulesSelectors()) {
MutableDocumentRulesSelectorsInternal() =
MakeGarbageCollected<GCedHeapHashSet<WeakMember<StyleRule>>>();
}
DocumentRulesSelectors()->insert(selector);
}
// ::selection, etc
StyleHighlightData& AccessHighlightData() {
return MutableHighlightDataInternal();
}
// CustomHighlightNames
void SetCustomHighlightNames(
const HashSet<AtomicString>& custom_highlight_names) {
SetCustomHighlightNamesInternal(
std::make_unique<HashSet<AtomicString>>(custom_highlight_names));
}
// PaintImage
void AddPaintImage(StyleImage* image) {
if (!PaintImagesInternal()) {
MutablePaintImagesInternal() = MakeGarbageCollected<PaintImages>();
}
MutablePaintImagesInternal()->Images().push_back(image);
}
// TextAutosizingMultiplier
CORE_EXPORT void SetTextAutosizingMultiplier(float);
// ColorScheme and ForcedColors
bool ShouldPreserveParentColor() const {
return InForcedColorsMode() &&
ForcedColorAdjust() == EForcedColorAdjust::kPreserveParentColor;
}
bool ShouldForceColor(const StyleColor& unforced_color) const {
return ComputedStyle::ShouldForceColor(InForcedColorsMode(),
ForcedColorAdjust(), unforced_color);
}
StyleColor InitialColorForColorScheme() const {
// TODO(crbug.com/1046753, crbug.com/929098): The initial value of the color
// property should be canvastext, but since we do not yet ship color-scheme
// aware system colors, we use this method instead. This should be replaced
// by default_value:"canvastext" in css_properties.json5.
return StyleColor(DarkColorScheme() ? Color::kWhite : Color::kBlack);
}
// Helper method to adjust used values for color-scheme on the current
// computed color-scheme passed in as flags. The computed value should
// already have been set by the Apply* methods on the ColorScheme class, or
// as the initial value.
void SetUsedColorScheme(
ColorSchemeFlags flags,
mojom::blink::PreferredColorScheme preferred_color_scheme,
bool force_dark);
mojom::blink::ColorScheme UsedColorScheme() const {
return ComputedStyle::UsedColorScheme(DarkColorScheme());
}
// Variables
const StyleInheritedVariables* InheritedVariables() const {
return InheritedVariablesInternal().Get();
}
const StyleNonInheritedVariables* NonInheritedVariables() const {
return NonInheritedVariablesInternal().Get();
}
CSSVariableData* GetVariableData(const AtomicString&,
bool is_inherited_property) const;
CORE_EXPORT StyleInheritedVariables& MutableInheritedVariables();
CORE_EXPORT StyleNonInheritedVariables& MutableNonInheritedVariables();
void SetInheritedVariablesFrom(const ComputedStyle*);
void SetNonInheritedVariablesFrom(const ComputedStyle*);
CORE_EXPORT void SetVariableData(const AtomicString& name,
CSSVariableData* value,
bool is_inherited_property) {
if (is_inherited_property) {
MutableInheritedVariables().SetData(name, value);
} else {
MutableNonInheritedVariables().SetData(name, value);
}
}
CORE_EXPORT void SetVariableValue(const AtomicString& name,
const CSSValue* value,
bool is_inherited_property) {
if (is_inherited_property) {
MutableInheritedVariables().SetValue(name, value);
} else {
MutableNonInheritedVariables().SetValue(name, value);
}
}
EWhiteSpace WhiteSpace() const {
return ToWhiteSpace(GetWhiteSpaceCollapse(), GetTextWrapMode());
}
void SetWhiteSpace(EWhiteSpace whitespace) {
SetWhiteSpaceCollapse(ToWhiteSpaceCollapse(whitespace));
SetTextWrapMode(ToTextWrapMode(whitespace));
}
// WritingMode
WritingDirectionMode GetWritingDirection() const {
return {GetWritingMode(), Direction()};
}
void SetHasStaticViewportUnits() {
SetViewportUnitFlags(ViewportUnitFlags() |
static_cast<unsigned>(ViewportUnitFlag::kStatic));
}
void SetHasDynamicViewportUnits() {
SetViewportUnitFlags(ViewportUnitFlags() |
static_cast<unsigned>(ViewportUnitFlag::kDynamic));
}
// ContainIntrinsicSize
void SetContainIntrinsicSizeAuto() {
StyleIntrinsicLength width = ContainIntrinsicWidth();
width.SetHasAuto();
SetContainIntrinsicWidth(width);
StyleIntrinsicLength height = ContainIntrinsicHeight();
height.SetHasAuto();
SetContainIntrinsicHeight(height);
}
private:
mutable bool has_own_inherited_variables_ = false;
mutable bool has_own_non_inherited_variables_ = false;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_COMPUTED_STYLE_H_
|