DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Implementation

Mercurial (c68fe15a81fc)

VCS Links

Line Code
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 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/* a presentation of a document, part 2 */


#ifndef mozilla_PresShell_h
#define mozilla_PresShell_h

#include "mozilla/PresShellForwards.h"


#include <stdio.h>  // for FILE definition
#include "FrameMetrics.h"
#include "GeckoProfiler.h"
#include "TouchManager.h"
#include "Units.h"
#include "Units.h"
#include "Visibility.h"
#include "gfxPoint.h"
#include "mozilla/ArenaObjectID.h"
#include "mozilla/Attributes.h"
#include "mozilla/EventForwards.h"
#include "mozilla/EventForwards.h"
#include "mozilla/FlushType.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/ScrollTypes.h"
#include "mozilla/ScrollTypes.h"
#include "mozilla/ServoStyleSet.h"
#include "mozilla/ServoStyleConsts.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/StyleSheet.h"
#include "mozilla/StyleSheet.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/WeakPtr.h"
#include "mozilla/dom/HTMLDocumentBinding.h"
#include "mozilla/layers/FocusTarget.h"
#include "mozilla/layout/LayoutTelemetryTools.h"
#include "mozilla/layout/LayoutTelemetryTools.h"
#include "nsChangeHint.h"
#include "nsClassHashtable.h"
#include "nsColor.h"
#include "nsCOMArray.h"
#include "nsCoord.h"
#include "nsCoord.h"
#include "nsDOMNavigationTiming.h"
#include "nsFrameManager.h"
#include "nsFrameState.h"
#include "nsHashKeys.h"
#include "nsIContent.h"
#include "nsIContent.h"
#include "nsIObserver.h"
#include "nsISelectionController.h"
#include "nsIWidget.h"
#include "nsQueryFrame.h"
#include "nsMargin.h"
#include "nsMargin.h"
#include "nsPresArena.h"
#include "nsPresContext.h"
#include "nsRect.h"
#include "nsRect.h"
#include "nsRefPtrHashtable.h"
#include "nsRefreshDriver.h"
#include "nsRegionFwd.h"
#include "nsStringFwd.h"
#include "nsStubDocumentObserver.h"
#include "nsStubDocumentObserver.h"
#include "nsTHashtable.h"
#include "nsThreadUtils.h"
#include "nsWeakReference.h"

class AutoPointerEventTargetUpdater;
class AutoPointerEventTargetUpdater;
class AutoWeakFrame;
class gfxContext;
class MobileViewportManager;
class MobileViewportManager;
#ifdef ACCESSIBILITY
#ifdef ACCESSIBILITY
class nsAccessibilityService;
#endif
class nsARefreshObserver;
class nsARefreshObserver;
class nsAutoCauseReflowNotifier;
class nsCanvasFrame;
class nsCaret;
class nsCSSFrameConstructor;
class nsDisplayList;
class nsDisplayList;
class nsDisplayListBuilder;
class nsDocShell;
class nsFrameSelection;
class nsIDocShell;
class nsIFrame;
class nsIFrame;
class nsILayoutHistoryState;
class nsINode;
class nsPageSequenceFrame;
class nsIReflowCallback;
class nsIScrollableFrame;
class nsIScrollableFrame;
class nsITimer;
class nsPIDOMWindowOuter;
class nsAPostRefreshObserver;
class nsPresShellEventCB;
class nsRange;
class nsRange;
class nsRefreshDriver;
class nsRegion;
class nsView;
class nsViewManager;
class nsWindowSizes;
class nsWindowSizes;
struct RangePaintInfo;
#ifdef MOZ_REFLOW_PERF
class ReflowCountMgr;
#endif
class WeakFrame;
class WeakFrame;
class ZoomConstraintsClient;

template <class E>
class nsCOMArray;

struct nsCallbackEventRequest;
struct nsPoint;
struct nsPoint;
struct nsRect;

namespace mozilla {
class AccessibleCaretEventHub;
class EventStates;
class EventStates;
class GeckoMVMContext;
class OverflowChangedTracker;
class StyleSheet;

#ifdef ACCESSIBILITY
namespace a11y {
class DocAccessible;
}  // namespace a11y
#endif
#endif

namespace dom {
class Document;
class Element;
class Event;
class Event;
class HTMLSlotElement;
class Selection;
}  // namespace dom

namespace gfx {
namespace gfx {
class SourceSurface;
}  // namespace gfx

namespace layers {
class LayerManager;
}  // namespace layers


namespace layout {
class ScrollAnchorContainer;
}  // namespace layout

// 039d8ffc-fa55-42d7-a53a-388cb129b052
// 039d8ffc-fa55-42d7-a53a-388cb129b052
#define NS_PRESSHELL_IID                             \
  {                                                  \
    0x039d8ffc, 0xfa55, 0x42d7, {                    \
      0xa5, 0x3a, 0x38, 0x8c, 0xb1, 0x29, 0xb0, 0x52 \
    }                                                \
    }                                                \
  }

#undef NOISY_INTERRUPTIBLE_REFLOW
#undef NOISY_INTERRUPTIBLE_REFLOW

/**
 * Presentation shell. Presentation shells are the controlling point for
 * managing the presentation of a document.  The presentation shell holds a
 * live reference to the document, the presentation context, the style
 * live reference to the document, the presentation context, the style
 * manager, the style set and the root frame.
 *
 * When this object is Release'd, it will release the document, the
 * presentation context, the style manager, the style set and the root frame.
 */
 */

class PresShell final : public nsStubDocumentObserver,
                        public nsISelectionController,
                        public nsIObserver,
                        public nsIObserver,
                        public nsSupportsWeakReference {
  typedef dom::Document Document;
  typedef dom::Element Element;
  typedef gfx::SourceSurface SourceSurface;
  typedef layers::FocusTarget FocusTarget;
  typedef layers::FocusTarget FocusTarget;
  typedef layers::FrameMetrics FrameMetrics;
  typedef layers::LayerManager LayerManager;

  // A set type for tracking visible frames, for use by the visibility code in
  // PresShell. The set contains nsIFrame* pointers.
  // PresShell. The set contains nsIFrame* pointers.
  typedef nsTHashtable<nsPtrHashKey<nsIFrame>> VisibleFrames;

 public:
  explicit PresShell(Document* aDocument);


  // nsISupports
  NS_DECL_ISUPPORTS
  NS_DECL_ISUPPORTS

  NS_DECLARE_STATIC_IID_ACCESSOR(NS_PRESSHELL_IID)

  static bool AccessibleCaretEnabled(nsIDocShell* aDocShell);


  /**
   * Return the active content currently capturing the mouse if any.
   */
  static nsIContent* GetCapturingContent() {
    return sCapturingContentInfo.mContent;
    return sCapturingContentInfo.mContent;
  }

  /**
   * Allow or disallow mouse capturing.
   */
   */
  static void AllowMouseCapture(bool aAllowed) {
    sCapturingContentInfo.mAllowed = aAllowed;
  }

  /**
  /**
   * Returns true if there is an active mouse capture that wants to prevent
   * drags.
   */
  static bool IsMouseCapturePreventingDrag() {
    return sCapturingContentInfo.mPreventDrag && sCapturingContentInfo.mContent;
    return sCapturingContentInfo.mPreventDrag && sCapturingContentInfo.mContent;
  }

  static void ClearMouseCaptureOnView(nsView* aView);

  // If a frame in the subtree rooted at aFrame is capturing the mouse then
  // clears that capture.
  static void ClearMouseCapture(nsIFrame* aFrame);

#ifdef ACCESSIBILITY
#ifdef ACCESSIBILITY
  /**
   * Return the document accessible for this PresShell if there is one.
   */
  a11y::DocAccessible* GetDocAccessible() const { return mDocAccessible; }

  /**
   * Set the document accessible for this PresShell.
   * Set the document accessible for this PresShell.
   */
  void SetDocAccessible(a11y::DocAccessible* aDocAccessible) {
    mDocAccessible = aDocAccessible;
  }


  /**
   * Return true if accessibility is active.
   */
  static bool IsAccessibilityActive();


  /**
   * Return accessibility service if accessibility is active.
   */
  static nsAccessibilityService* GetAccessibilityService();
#endif  // #ifdef ACCESSIBILITY
#endif  // #ifdef ACCESSIBILITY

  void Init(nsPresContext*, nsViewManager*);

  /**
   * All callers are responsible for calling |Destroy| after calling
   * All callers are responsible for calling |Destroy| after calling
   * |EndObservingDocument|.  It needs to be separate only because form
   * controls incorrectly store their data in the frames rather than the
   * content model and printing calls |EndObservingDocument| multiple
   * times to make form controls behave nicely when printed.
   * times to make form controls behave nicely when printed.
   */
  void Destroy();

  bool IsDestroying() { return mIsDestroying; }


  /**
   * All frames owned by the shell are allocated from an arena.  They
   * are also recycled using free lists.  Separate free lists are
   * maintained for each frame type (aID), which must always correspond
   * to the same aSize value.  AllocateFrame is infallible and will abort
   * to the same aSize value.  AllocateFrame is infallible and will abort
   * on out-of-memory.
   */
  void* AllocateFrame(nsQueryFrame::FrameIID aID, size_t aSize) {
#define FRAME_ID(classname, ...)                                  \
  static_assert(size_t(nsQueryFrame::FrameIID::classname##_id) == \
  static_assert(size_t(nsQueryFrame::FrameIID::classname##_id) == \
                    size_t(eArenaObjectID_##classname),           \
                "");
#define ABSTRACT_FRAME_ID(classname)                              \
  static_assert(size_t(nsQueryFrame::FrameIID::classname##_id) == \
                    size_t(eArenaObjectID_##classname),           \
                    size_t(eArenaObjectID_##classname),           \
                "");
#include "mozilla/FrameIdList.h"
#undef FRAME_ID
#undef ABSTRACT_FRAME_ID
    return AllocateByObjectID(ArenaObjectID(size_t(aID)), aSize);
    return AllocateByObjectID(ArenaObjectID(size_t(aID)), aSize);
  }

  void FreeFrame(nsQueryFrame::FrameIID aID, void* aPtr) {
    return FreeByObjectID(ArenaObjectID(size_t(aID)), aPtr);
  }


  void* AllocateByObjectID(ArenaObjectID aID, size_t aSize) {
    void* result = mFrameArena.Allocate(aID, aSize);
    RecordAlloc(result);
    return result;
  }
  }

  void FreeByObjectID(ArenaObjectID aID, void* aPtr) {
    RecordFree(aPtr);
    if (!mIsDestroying) {
      mFrameArena.Free(aID, aPtr);
      mFrameArena.Free(aID, aPtr);
    }
  }

  Document* GetDocument() const { return mDocument; }


  nsPresContext* GetPresContext() const { return mPresContext; }

  nsViewManager* GetViewManager() const { return mViewManager; }

  nsRefreshDriver* GetRefreshDriver() const;
  nsRefreshDriver* GetRefreshDriver() const;

  nsCSSFrameConstructor* FrameConstructor() const {
    return mFrameConstructor.get();
  }

  /**
   * FrameSelection will return the Frame based selection API.
   * FrameSelection will return the Frame based selection API.
   * You cannot go back and forth anymore with QI between nsIDOM sel and
   * nsIFrame sel.
   */
  already_AddRefed<nsFrameSelection> FrameSelection();

  /**
   * ConstFrameSelection returns an object which methods are safe to use for
   * ConstFrameSelection returns an object which methods are safe to use for
   * example in nsIFrame code.
   */
  const nsFrameSelection* ConstFrameSelection() const { return mSelection; }

  // Start receiving notifications from our document. If called after Destroy,
  // Start receiving notifications from our document. If called after Destroy,
  // this will be ignored.
  void BeginObservingDocument();

  // Stop receiving notifications from our document. If called after Destroy,
  // Stop receiving notifications from our document. If called after Destroy,
  // this will be ignored.
  void EndObservingDocument();

  bool IsObservingDocument() const { return mIsObservingDocument; }


  /**
   * Return whether Initialize() was previously called.
   */
  bool DidInitialize() const { return mDidInitialize; }


  /**
   * Perform initialization. Constructs the frame for the root content
   * object and then enqueues a reflow of the frame model.
   *
   * Callers of this method must hold a reference to this shell that
   * Callers of this method must hold a reference to this shell that
   * is guaranteed to survive through arbitrary script execution.
   * Calling Initialize can execute arbitrary script.
   */
  MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult Initialize();


  /**
   * Reflow the frame model into a new width and height.  The
   * coordinates for aWidth and aHeight must be in standard nscoord's.
   */
  MOZ_CAN_RUN_SCRIPT nsresult
  MOZ_CAN_RUN_SCRIPT nsresult
  ResizeReflow(nscoord aWidth, nscoord aHeight,
               ResizeReflowOptions = ResizeReflowOptions::NoOption);
  MOZ_CAN_RUN_SCRIPT nsresult ResizeReflowIgnoreOverride(nscoord aWidth,
                                                         nscoord aHeight,
                                                         nscoord aHeight,
                                                         ResizeReflowOptions);

  /**
   * Add this pres shell to the refresh driver to be observed for resize
   * event if applicable.
   * event if applicable.
   */
  void AddResizeEventFlushObserverIfNeeded();

  /**
  /**
   * Returns true if the document hosted by this presShell is in a devtools
   * Responsive Design Mode browsing context.
   */
  bool InRDMPane();


 private:
  /**
   * This is what ResizeReflowIgnoreOverride does when not shrink-wrapping (that
   * is, when ResizeReflowOptions::BSizeLimit is not specified).
   */
   */
  void SimpleResizeReflow(nscoord aWidth, nscoord aHeight, ResizeReflowOptions);

 public:
  /**
   * Returns true if this document has a potentially zoomable viewport,
   * allowing for its layout and visual viewports to diverge.
   * Note that the assumptions that determine whether we have a potentially
   */
  bool GetIsViewportOverridden() const {
    return (mMobileViewportManager != nullptr);
  }

  /**
  /**
   * Note that the assumptions that determine whether we have a potentially
   * zoomable viewport may have changed.
   */
  void UpdateViewportOverridden(bool aAfterInitialization);
   * mobile viewport sizing, as with desktop zooming we can have a

  /**
   * Returns true if this document uses mobile viewport sizing (including
   * processing of <meta name="viewport"> tags).
   */
   *
   * Note that having a MobileViewportManager does not necessarily mean using
   * mobile viewport sizing, as with desktop zooming we can have a
   * MobileViewportManager on desktop, but we only want to do mobile viewport
   * sizing on mobile. (TODO: Rename MobileViewportManager to reflect its more
   * viewport. Will return null in situations where we don't have a mobile
   * general role.)
   */
  bool UsesMobileViewportSizing() const;

  /**
  /**
   * Get the MobileViewportManager used to manage the document's mobile
   * viewport. Will return null in situations where we don't have a mobile
   * viewport, and for documents that are not the root content document.
   */
  RefPtr<MobileViewportManager> GetMobileViewportManager() const;

  /**
   * Return true if the presshell expects layout flush.
   * Called when document load completes.
   */
  bool IsLayoutFlushObserver() {
    return GetPresContext()->RefreshDriver()->IsLayoutFlushObserver(this);
  }

  /**
   */
   * Called when document load completes.
   */
  void LoadComplete();
  /**
   * This calls through to the frame manager to get the root frame.
   */
   */
  nsIFrame* GetRootFrame() const { return mFrameManager->GetRootFrame(); }

  /*
   * Get root scroll frame from FrameManager()->GetRootFrame().
   */
   */
  nsIFrame* GetRootScrollFrame() const;

  /*
   * The same as GetRootScrollFrame, but returns an nsIScrollableFrame
   * target for scrolling.
   */
  nsIScrollableFrame* GetRootScrollFrameAsScrollable() const;

  /**
   * Get the current focused content or DOM selection that should be the
   * target for scrolling.
   */
   */
  already_AddRefed<nsIContent> GetContentForScrolling() const;

  /**
   * Get the DOM selection that should be the target for scrolling, if there
   * is scrollable with overflow:scroll or overflow:auto in some direction when
   * is no focused content.
   */
  already_AddRefed<nsIContent> GetSelectedContentForScrolling() const;

  /**
      nsIContent* aContent, ScrollableDirection aDirection);
   * Gets nearest scrollable frame from the specified content node. The frame
   * is scrollable with overflow:scroll or overflow:auto in some direction when
   * aDirection is eEither.  Otherwise, this returns a nearest frame that is
   * scrollable in the specified direction.
   */
   * overflow:scroll or overflow:auto in some direction when aDirection is
  nsIScrollableFrame* GetScrollableFrameToScrollForContent(
      nsIContent* aContent, ScrollableDirection aDirection);

  /**
   * Gets nearest scrollable frame from current focused content or DOM
      ScrollableDirection aDirection);
   * selection if there is no focused content. The frame is scrollable with
   * overflow:scroll or overflow:auto in some direction when aDirection is
   * eEither.  Otherwise, this returns a nearest frame that is scrollable in
   * the specified direction.
   */
   * aDirection is eEither.  Otherwise, this returns a nearest frame that is
  nsIScrollableFrame* GetScrollableFrameToScroll(
      ScrollableDirection aDirection);

  /**
   * Gets nearest ancestor scrollable frame from aFrame.  The frame is
   * scrollable with overflow:scroll or overflow:auto in some direction when
   * aDirection is eEither.  Otherwise, this returns a nearest frame that is
   * scrollable in the specified direction.
   * Returns the page sequence frame associated with the frame hierarchy.
   */
  nsIScrollableFrame* GetNearestScrollableFrame(nsIFrame* aFrame,
                                                ScrollableDirection aDirection);

  /**
  /**
   * Returns the page sequence frame associated with the frame hierarchy.
   * Returns nullptr if not a paginated view.
   */
  nsPageSequenceFrame* GetPageSequenceFrame() const;


  /**
   * Returns the canvas frame associated with the frame hierarchy.
   * Returns nullptr if is XUL document.
   */
      layout::ScrollAnchorContainer* aContainer);
  nsCanvasFrame* GetCanvasFrame() const;

  void PostPendingScrollAnchorSelection(
      layout::ScrollAnchorContainer* aContainer);
  void FlushPendingScrollAnchorSelections();
  MOZ_CAN_RUN_SCRIPT_BOUNDARY void NotifyCounterStylesAreDirty();
  void PostPendingScrollAnchorAdjustment(
      layout::ScrollAnchorContainer* aContainer);

  void CancelAllPendingReflows();

   * Destroy the frames for aElement, and reconstruct them asynchronously if
  MOZ_CAN_RUN_SCRIPT_BOUNDARY void NotifyCounterStylesAreDirty();

  bool FrameIsAncestorOfDirtyRoot(nsIFrame* aFrame) const;

  void DestroyFramesForAndRestyle(Element* aElement);
  /**
   * Destroy the frames for aElement, and reconstruct them asynchronously if
   * needed.
   *
   * Note that this may destroy frames for an ancestor instead.
   *
   */
  void DestroyFramesForAndRestyle(Element* aElement);

   */
  /**
   * Handles all the layout stuff needed when the slot assignment for an element
   * is about to change.
   *
   * Only called when the slot attribute of the element changes, the rest of
  void PostRecreateFramesFor(Element*);
   * the changes should be handled in ShadowRoot.
   */
  void SlotAssignmentWillChange(Element& aElement,
                                dom::HTMLSlotElement* aOldSlot,
                                dom::HTMLSlotElement* aNewSlot);
   */

  void PostRecreateFramesFor(Element*);
  void RestyleForAnimation(Element*, RestyleHint);

  /**
   * flushing style and layout.
   * Determine if it is safe to flush all pending notifications.
   */
  bool IsSafeToFlush() const;

  /**
   * Informs the document's FontFaceSet that the refresh driver ticked,
   * flushing style and layout.
   */
  void NotifyFontFaceSetOnRefresh();
  // lists after calling this, but before calling StartObservingRefreshDriver

  // Removes ourself from the list of layout / style / and resize refresh driver
  // observers.
  //
  // Right now this is only used for documents in the BFCache, so if you want to
  // use this for anything else you need to ensure we don't end up in those
  // lists after calling this, but before calling StartObservingRefreshDriver
  // Callers are responsible of manually calling StartObservingRefreshDriver
  // again.
  //
  // That is handled by the mDocument->GetBFCacheEntry checks in
  // DoObserve*Flushes functions, though that could conceivably become a boolean
  // member in the shell if needed.
  bool ObservingStyleFlushes() const { return mObservingStyleFlushes; }
  //
  // Callers are responsible of manually calling StartObservingRefreshDriver
  // again.
  void StopObservingRefreshDriver();
  void StartObservingRefreshDriver();
      DoObserveStyleFlushes();

  bool ObservingStyleFlushes() const { return mObservingStyleFlushes; }
  bool ObservingLayoutFlushes() const { return mObservingLayoutFlushes; }

  void ObserveStyleFlushes() {
  /**
    if (!ObservingStyleFlushes()) {
      DoObserveStyleFlushes();
    }
  }

  void CancelReflowCallback(nsIReflowCallback* aCallback);
  /**
   * Callbacks will be called even if reflow itself fails for
   * some reason.
   */
  nsresult PostReflowCallback(nsIReflowCallback* aCallback);
  void ClearFrameRefs(nsIFrame* aFrame);
  void CancelReflowCallback(nsIReflowCallback* aCallback);

  void ScheduleBeforeFirstPaint();
  void UnsuppressAndInvalidate();
  // Clears and repaint mFocusedFrameSelection if it matches the argument.

  void ClearFrameRefs(nsIFrame* aFrame);

  // Clears the selection of the older focused frame selection if any.
  void FrameSelectionWillTakeFocus(nsFrameSelection&);
   * Get a reference rendering context. This is a context that should not

  // Clears and repaint mFocusedFrameSelection if it matches the argument.
  void FrameSelectionWillLoseFocus(nsFrameSelection&);

  /**

   * Get a reference rendering context. This is a context that should not
   * be rendered to, but is suitable for measuring text and performing
   * other non-rendering operations. Guaranteed to return non-null.
   */
  already_AddRefed<gfxContext> CreateReferenceRenderingContext();

   * @param aHorizontal see ScrollContentIntoView and ScrollAxis
  /**
   * Scrolls the view of the document so that the given area of a frame
   * is visible, if possible. Layout is not flushed before scrolling.
   *
   * @param aRect relative to aFrame
   * even if overflow:hidden is specified in that direction; otherwise
   * @param aVertical see ScrollContentIntoView and ScrollAxis
   * @param aHorizontal see ScrollContentIntoView and ScrollAxis
   * @param aScrollFlags if SCROLL_FIRST_ANCESTOR_ONLY is set, only the
   * nearest scrollable ancestor is scrolled, otherwise all
   * scrollable ancestors may be scrolled if necessary
   * contain this document in a iframe or the like.
   * if SCROLL_OVERFLOW_HIDDEN is set then we may scroll in a direction
   * even if overflow:hidden is specified in that direction; otherwise
   * we will not scroll in that direction when overflow:hidden is
   * set for that direction
   * If SCROLL_NO_PARENT_FRAMES is set then we only scroll
   * nodes in this document, not in any parent documents which
   * contain this document in a iframe or the like.
   * If SCROLL_IGNORE_SCROLL_MARGIN_AND_PADDING is set we ignore scroll-margin
   * value specified for |aFrame| and scroll-padding value for the scroll
  bool ScrollFrameRectIntoView(nsIFrame* aFrame, const nsRect& aRect,
   * container. This option is typically used to locate poped-up frames into
   * view.
   * @return true if any scrolling happened, false if no scrolling happened
   */
  MOZ_CAN_RUN_SCRIPT
   * Suppress notification of the frame manager that frames are
  bool ScrollFrameRectIntoView(nsIFrame* aFrame, const nsRect& aRect,
                               ScrollAxis aVertical, ScrollAxis aHorizontal,
                               ScrollFlags aScrollFlags);

  /**
   * Suppress notification of the frame manager that frames are
   */
   * being destroyed.
   */
  void SetIgnoreFrameDestruction(bool aIgnore);

  /**
   */
   * Get the AccessibleCaretEventHub, if it exists. AddRefs it.
   */
  already_AddRefed<AccessibleCaretEventHub> GetAccessibleCaretEventHub() const;

  /**
   */
   * Get the caret, if it exists. AddRefs it.
   */
  already_AddRefed<nsCaret> GetCaret() const;

  /**
   * Set the current caret to a new caret. To undo this, call RestoreCaret.
   * with.
   */
  void SetCaret(nsCaret* aNewCaret);


  /**
   * Restore the caret to the original caret that this pres shell was created
   * with.
   */
   * the frame selection that's visible to the user.
  void RestoreCaret();

  dom::Selection* GetCurrentSelection(SelectionType aSelectionType);

  /**
   * Gets the last selection that took focus in this document. This is basically
   * the frame selection that's visible to the user.
   */
   */
  nsFrameSelection* GetLastFocusedFrameSelection();

  /**
   * Interface to dispatch events via the presshell
   * @note The caller must have a strong reference to the PresShell.
                                 bool aIsHandlingNativeEvent = false,
   */
  MOZ_CAN_RUN_SCRIPT
  nsresult HandleEventWithTarget(WidgetEvent* aEvent, nsIFrame* aFrame,
                                 nsIContent* aContent,
    return eventHandler.HandleEventWithTarget(
                                 nsEventStatus* aEventStatus,
                                 bool aIsHandlingNativeEvent = false,
                                 nsIContent** aTargetContent = nullptr,
                                 nsIContent* aOverrideClickTarget = nullptr) {
    MOZ_ASSERT(aEvent);
  /**
    EventHandler eventHandler(*this);
    return eventHandler.HandleEventWithTarget(
        aEvent, aFrame, aContent, aEventStatus, aIsHandlingNativeEvent,
        aTargetContent, aOverrideClickTarget);
  }
                                    WidgetEvent* aEvent,

  /**

   * Dispatch event to content only (NOT full processing)
   */
  MOZ_CAN_RUN_SCRIPT
  nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent,
                                    WidgetEvent* aEvent,
  nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent,
                                    nsEventStatus* aStatus);

  /**
   * Dispatch event to content only (NOT full processing)
   */
  MOZ_CAN_RUN_SCRIPT
   */
  nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent,
                                    dom::Event* aEvent, nsEventStatus* aStatus);

  /**
   * Return whether or not the event is valid to be dispatched
   */
   */
  bool CanDispatchEvent(const WidgetGUIEvent* aEvent = nullptr) const;

  /**
   * Gets the current target event frame from the PresShell
   */
   */
  nsIFrame* GetCurrentEventFrame();

  /**
   * Gets the current target event frame from the PresShell
   */
   */
  already_AddRefed<nsIContent> GetEventTargetContent(WidgetEvent* aEvent);

  /**
   * Get and set the history state for the current document
   * returns true if reflow is locked, false otherwise
   */
  bool IsReflowLocked() const { return mIsReflowing; }
  nsresult CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState);

  /**
   * Determine if reflow is currently locked
   * returns true if reflow is locked, false otherwise
   * we don't recur into our children.
   */
  bool IsReflowLocked() const { return mIsReflowing; }

  /**
   * Called to find out if painting is suppressed for this presshell.  If it is
   * Pause painting by freezing the refresh driver of this and all parent
   * suppressd, we don't allow the painting of any layer but the background, and
   * we don't recur into our children.
   */
  bool IsPaintingSuppressed() const { return mPaintingSuppressed; }


  /**
   * Pause painting by freezing the refresh driver of this and all parent
   * presentations. This may not have the desired effect if this pres shell
   * has its own refresh driver.
   */
   * has its own refresh driver.
  void PausePainting();

  /**
   * Resume painting by thawing the refresh driver of this and all parent
   * Unsuppress painting.
   * presentations. This may not have the desired effect if this pres shell
   * has its own refresh driver.
   */
  void ResumePainting();

   * Reconstruct frames for all elements in the document
  /**
   * Unsuppress painting.
   */
  void UnsuppressPainting();

  /**
   * Reconstruct frames for all elements in the document
   * "verifyreflow:1" to your MOZ_LOG environment variable (any non-zero
   */
  MOZ_CAN_RUN_SCRIPT void ReconstructFrames();

  /**
   * See if reflow verification is enabled. To enable reflow verification add
  /**
   * "verifyreflow:1" to your MOZ_LOG environment variable (any non-zero
   * debug level will work). Or, call SetVerifyReflowEnable with true.
   */
  static bool GetVerifyReflowEnable();

  nsIFrame* GetAbsoluteContainingBlock(nsIFrame* aFrame);
  /**
   * Set the verify-reflow enable flag.
   */
  static void SetVerifyReflowEnable(bool aEnabled);

  void PaintCount(const char* aName, gfxContext* aRenderingContext,
  nsIFrame* GetAbsoluteContainingBlock(nsIFrame* aFrame);

#ifdef MOZ_REFLOW_PERF
  void DumpReflows();
  void CountReflows(const char* aName, nsIFrame* aFrame);
  void PaintCount(const char* aName, gfxContext* aRenderingContext,
#ifdef DEBUG
                  nsPresContext* aPresContext, nsIFrame* aFrame,
                  const nsPoint& aOffset, uint32_t aColor);
  void SetPaintFrameCount(bool aOn);
  bool IsPaintingFrameCounts();
#endif  // #ifdef MOZ_REFLOW_PERF

  // Debugging hooks
  /**
#ifdef DEBUG
  void ListComputedStyles(FILE* out, int32_t aIndent = 0);
#endif
#if defined(DEBUG) || defined(MOZ_LAYOUT_DEBUGGER)
  void ListStyleSheets(FILE* out, int32_t aIndent = 0);
   */
#endif

  /**
   * Stop all active elements (plugins and the caret) in this presentation and
   * in the presentations of subdocuments.  Resets painting to a suppressed
   * Restarts active elements (plugins) in this presentation and in the
   * state.
   * XXX this should include image animations
   */
  void Freeze();
  bool IsFrozen() { return mFrozen; }


  /**
   * Restarts active elements (plugins) in this presentation and in the
   * presentations of subdocuments, then do a full invalidate of the content
   * area.
   */
   * lose our container pointer.  However, we'd still like to be able to target
  void Thaw();

   */
  void FireOrClearDelayedEvents(bool aFireEvents);

  void SetForwardingContainer(const WeakPtr<nsDocShell>& aContainer);
  /**
   * When this shell is disconnected from its containing docshell, we
   * Render the document into an arbitrary gfxContext
   * lose our container pointer.  However, we'd still like to be able to target
   * Designed for getting a picture of a document or a piece of a document
   * user events at the docshell's parent.  This pointer allows us to do that.
   * It should not be used for any other purpose.
   */
  void SetForwardingContainer(const WeakPtr<nsDocShell>& aContainer);

  /**
   * or in the root scrolled frame's coordinate system
   * Render the document into an arbitrary gfxContext
   * Designed for getting a picture of a document or a piece of a document
   * Note that callers will generally want to call FlushPendingNotifications
   * to get an up-to-date view of the document
   * @param aRect is the region to capture into the offscreen buffer, in the
   * sensitive widgets such as the file name in a file upload widget, and we
   * root frame's coordinate system (if aIgnoreViewportScrolling is false)
   * or in the root scrolled frame's coordinate system
   * (if aIgnoreViewportScrolling is true). The coordinates are in appunits.
   * @param aFlags see below;
   *  visible (by default the caret is never drawn)
   *   set RenderDocumentFlags::IsUntrusted if the contents may be passed to
   * malicious agents. E.g. we might choose not to paint the contents of
   * sensitive widgets such as the file name in a file upload widget, and we
   * might choose not to paint themes.
   *   set RenderDocumentFlags::IgnoreViewportScrolling to ignore clipping and
   *  scrollbar painting due to scrolling in the viewport
   * slow everything down if the area rendered does not correspond to the
   *   set RenderDocumentFlags::DrawCaret to draw the caret if one would be
   *  visible (by default the caret is never drawn)
   *   set RenderDocumentFlags::UseWidgetLayers to force rendering to go
   *  through the layer manager for the window. This may be unexpectedly slow
   * (if the layer manager must read back data from the GPU) or low-quality
   *   set RenderDocumentFlags::DocumentRelative to render the document as if
   * (if the layer manager reads back pixel data and scales it
   * instead of rendering using the appropriate scaling). It may also
   * slow everything down if the area rendered does not correspond to the
   * normal visible area of the window.
   *   set RenderDocumentFlags::AsyncDecodeImages to avoid having images
   * ignore viewport scrolling mode
   * synchronously decoded during rendering.
   * (by default images decode synchronously with RenderDocument)
   *   set RenderDocumentFlags::DocumentRelative to render the document as if
   * there has been no scrolling and interpret |aRect| relative to the document
   * one CSS pixel in the source document is rendered to one unit in the current
   * instead of the CSS viewport. Only considered if
   * RenderDocumentFlags::IgnoreViewportScrolling is set or the document is in
   * ignore viewport scrolling mode
   * (PresShell::SetIgnoreViewportScrolling/IgnoringViewportScrolling).
   * @param aBackgroundColor a background color to render onto
                          gfxContext* aRenderedContext);
   * @param aRenderedContext the gfxContext to render to. We render so that
   * one CSS pixel in the source document is rendered to one unit in the current
   * transform.
   */
  nsresult RenderDocument(const nsRect& aRect, RenderDocumentFlags aFlags,
   * edge of the presshell area. The aPoint, aScreenRect and aFlags arguments
                          nscolor aBackgroundColor,
                          gfxContext* aRenderedContext);

  /**
   * Renders a node aNode to a surface and returns it. The aRegion may be used
                                             const LayoutDeviceIntPoint aPoint,
   * to clip the rendering. This region is measured in CSS pixels from the
   * edge of the presshell area. The aPoint, aScreenRect and aFlags arguments
   * function in a similar manner as RenderSelection.
   */
  already_AddRefed<SourceSurface> RenderNode(nsINode* aNode,
   * Renders a selection to a surface and returns it. This method is primarily
                                             const Maybe<CSSIntRegion>& aRegion,
                                             const LayoutDeviceIntPoint aPoint,
                                             LayoutDeviceIntRect* aScreenRect,
                                             RenderImageFlags aFlags);

  /**
   * Renders a selection to a surface and returns it. This method is primarily
   * case as a reference point when determining the new screen rectangle after
   * intended to create the drag feedback when dragging a selection.
   *
   * aScreenRect will be filled in with the bounding rectangle of the
   * selection area on screen.
   *
   * frames.
   * If the area of the selection is large and the RenderImageFlags::AutoScale
   * is set, the image will be scaled down. The argument aPoint is used in this
   * case as a reference point when determining the new screen rectangle after
   * scaling. Typically, this will be the mouse position, so that the screen
      LayoutDeviceIntRect* aScreenRect, RenderImageFlags aFlags);
   * rectangle is positioned such that the mouse is over the same point in the
   * scaled image as in the original. When scaling does not occur, the mouse
   * point isn't used because the position can be determined from the displayed
   * frames.
   */
  void RemoveAutoWeakFrame(AutoWeakFrame* aWeakFrame);
  already_AddRefed<SourceSurface> RenderSelection(
      dom::Selection* aSelection, const LayoutDeviceIntPoint aPoint,
      LayoutDeviceIntRect* aScreenRect, RenderImageFlags aFlags);

  void AddAutoWeakFrame(AutoWeakFrame* aWeakFrame);
   * presShells.
  void AddWeakFrame(WeakFrame* aWeakFrame);

  void RemoveAutoWeakFrame(AutoWeakFrame* aWeakFrame);
  void RemoveWeakFrame(WeakFrame* aWeakFrame);

  void DisableNonTestMouseEvents(bool aDisable);
  /**
   * Stop or restart non synthetic test mouse event handling on *all*
   * presShells.
   *
   * @param aDisable If true, disable all non synthetic test mouse
   * events on all presShells.  Otherwise, enable them.
   */
   * PresShell::PaintDefaultBackground, and nsDocShell::SetupNewViewer;
  void DisableNonTestMouseEvents(bool aDisable);

  /**
   * Record the background color of the most recently drawn canvas. This color
   * is composited on top of the user's default background color and then used

   * to draw the background color of the canvas. See PresShell::Paint,
   * PresShell::PaintDefaultBackground, and nsDocShell::SetupNewViewer;
   * bug 488242, bug 476557 and other bugs mentioned there.
   */
  void SetCanvasBackground(nscolor aColor) { mCanvasBackgroundColor = aColor; }
  nscolor GetCanvasBackground() { return mCanvasBackgroundColor; }
  /**

  /**
   * Use the current frame tree (if it exists) to update the background
   * color of the most recently drawn canvas.
   */
  void AddPrintPreviewBackgroundItem(nsDisplayListBuilder* aBuilder,
  void UpdateCanvasBackground();

  /**
   * Add a solid color item to the bottom of aList with frame aFrame and
   * bounds aBounds representing the dark grey background behind the page of a
   * Computes the backstop color for the view: transparent if in a transparent
   * print preview presentation.
   */
  void AddPrintPreviewBackgroundItem(nsDisplayListBuilder* aBuilder,
                                     nsDisplayList* aList, nsIFrame* aFrame,
  nscolor ComputeBackstopColor(nsView* aDisplayRoot);
                                     const nsRect& aBounds);

  /**
   * Computes the backstop color for the view: transparent if in a transparent
   * widget, otherwise the PresContext default background color. This color is
   * only visible if the contents of the view as a whole are translucent.
  bool ObservesNativeAnonMutationsForPrint() {
   */
  nscolor ComputeBackstopColor(nsView* aDisplayRoot);

  void ObserveNativeAnonMutationsForPrint(bool aObserve) {
    mObservesMutationsForPrint = aObserve;

  }
  bool ObservesNativeAnonMutationsForPrint() {
    return mObservesMutationsForPrint;
  }

  nsresult SetIsActive(bool aIsActive);
  uint64_t GetPaintCount() { return mPaintCount; }

  bool IsActive() { return mIsActive; }

  /**
   * Keep track of how many times this presshell has been rendered to
   */
   * a window.
   */
  uint64_t GetPaintCount() { return mPaintCount; }
  void IncrementPaintCount() { ++mPaintCount; }

   * I.e., when we are deactive, this returns the *last* focused DOM window.
  /**
   * Get the root DOM window of this presShell.
   */
  already_AddRefed<nsPIDOMWindowOuter> GetRootWindow();

   * Get the focused content under this window.
  /**
   */
   * This returns the focused DOM window under our top level window.
   * I.e., when we are deactive, this returns the *last* focused DOM window.
   */
  already_AddRefed<nsPIDOMWindowOuter> GetFocusedDOMWindowInOurWindow();

  /**
   * one.
   * Get the focused content under this window.
   */
  already_AddRefed<nsIContent> GetFocusedContentInOurWindow() const;

  /**
   * Return true iff there is a widget rendering this presShell and that
   * Get the layer manager for the widget of the root view, if it has
   * one.
   */
  LayerManager* GetLayerManager();

  /**
   * of painting.  If we are ignoring, then layers aren't clipped to
   * Return true iff there is a widget rendering this presShell and that
   * widget is APZ-enabled.
   */
  bool AsyncPanZoomEnabled();

              RenderingStateFlags::IgnoringViewportScrolling);
  /**
   * Track whether we're ignoring viewport scrolling for the purposes
   * of painting.  If we are ignoring, then layers aren't clipped to
   * the CSS viewport and scrollbars aren't drawn.
   */

  bool IgnoringViewportScrolling() const {
    return !!(mRenderingStateFlags &
              RenderingStateFlags::IgnoringViewportScrolling);
  }

  float GetResolution() const { return mResolution.valueOr(1.0); }
  float GetCumulativeResolution();

  /**
  /**
   * Accessors for a flag that tracks whether the most recent change to
   * the pres shell's resolution was originated by the main thread.
   */
  bool IsResolutionUpdated() const { return mResolutionUpdated; }
  /**
  void SetResolutionUpdated(bool aUpdated) { mResolutionUpdated = aUpdated; }

  /**
   * Returns true if the resolution has ever been changed by APZ.
   */
                            LayoutDeviceIntSize aDisplaySize);
  bool IsResolutionUpdatedByApz() const { return mResolutionUpdatedByApz; }

  /**
   * Used by session restore code to restore a resolution before the first
   * paint.
   */
  void SetRestoreResolution(float aResolution,
                            LayoutDeviceIntSize aDisplaySize);
    return !!(mRenderingStateFlags &

  /**
   * Returns whether we are in a DrawWindow() call that used the
   * DRAWWINDOW_DO_NOT_FLUSH flag.
   */
   * Set the isFirstPaint flag.
  bool InDrawWindowNotFlushing() const {
    return !!(mRenderingStateFlags &
              RenderingStateFlags::DrawWindowNotFlushing);
  }

   * Get the isFirstPaint flag.
  /**
   * Set the isFirstPaint flag.

   */
  void SetIsFirstPaint(bool aIsFirstPaint) { mIsFirstPaint = aIsFirstPaint; }

  /**
   * Get the isFirstPaint flag.
   */
   * this PresShell is visible. This is used when the contents of the page
  bool GetIsFirstPaint() const { return mIsFirstPaint; }

  uint32_t GetPresShellId() { return mPresShellId; }

  /**
  MOZ_CAN_RUN_SCRIPT
   * Dispatch a mouse move event based on the most recent mouse position if
   * this PresShell is visible. This is used when the contents of the page
   * moved (aFromScroll is false) or scrolled (aFromScroll is true).
   */
  void SynthesizeMouseMove(bool aFromScroll);

   * This is issued at a time when it's safe to modify widget geometry.
  MOZ_CAN_RUN_SCRIPT
  nsresult HandleEvent(nsIFrame* aFrame, WidgetGUIEvent* aEvent,
                       bool aDontRetargetEvents, nsEventStatus* aEventStatus);
  bool ShouldIgnoreInvalidation();
  /**
   * Fires on the presshell for the painted widget.
   * Notify that we're going to call Paint with PaintFlags::PaintComposite.
   * Fires on the presshell for the painted widget.
   * This is issued at a time when it's safe to modify widget geometry.
   */
  MOZ_CAN_RUN_SCRIPT void WillPaintWindow();
  bool IsVisible() const;
  /**
   * Notify that we called Paint with PaintFlags::PaintComposite.
   * Fires on the presshell for the painted widget.
   * This is issued at a time when it's safe to modify widget geometry.
   */
  MOZ_CAN_RUN_SCRIPT void DidPaintWindow();

  bool IsVisible() const;
  bool IsUnderHiddenEmbedderElement() const {
    return mUnderHiddenEmbedderElement;
   * trigger a repaint once suppression is disabled. Without that
  }
  void SetIsUnderHiddenEmbedderElement(bool aUnderHiddenEmbedderElement);
  MOZ_CAN_RUN_SCRIPT
  void DispatchSynthMouseMove(WidgetGUIEvent* aEvent);


  /* Temporarily ignore the Displayport for better paint performance. We
   * trigger a repaint once suppression is disabled. Without that
   * the displayport may get left at the suppressed size for an extended
   * period of time and result in unnecessary checkerboarding (see bug
   * 1255054). */
  void RespectDisplayportSuppression(bool aEnabled);
  void SuppressDisplayport(bool aEnabled);

  /* Whether or not displayport suppression should be turned on. Note that
   * this only affects the return value of |IsDisplayportSuppressed()|, and
   * doesn't change the value of the internal counter.
  void AddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const;
   */
  void RespectDisplayportSuppression(bool aEnabled);

  /* Whether or not the displayport is currently suppressed. */
  bool IsDisplayportSuppressed();
  uint32_t FontSizeInflationEmPerLine() const {

  void AddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const;

  /**
   * Methods that retrieve the cached font inflation preferences.
   */

  uint32_t FontSizeInflationEmPerLine() const {
    return mFontSizeInflationEmPerLine;
  }

  uint32_t FontSizeInflationMinTwips() const {

    return mFontSizeInflationMinTwips;
  }

  uint32_t FontSizeInflationLineThreshold() const {
    return mFontSizeInflationLineThreshold;
  bool FontSizeInflationDisabledInMasterProcess() const {
  }

  bool FontSizeInflationForceEnabled() const {
    return mFontSizeInflationForceEnabled;
  }


  bool FontSizeInflationDisabledInMasterProcess() const {
    return mFontSizeInflationDisabledInMasterProcess;
  }


  bool FontSizeInflationEnabled() const { return mFontSizeInflationEnabled; }

  /**
   * Recomputes whether font-size inflation is enabled.
   */

  void RecomputeFontSizeInflationEnabled();

  /**
   * Return true if the most recent interruptible reflow was interrupted.
   */
  bool SuppressInterruptibleReflows() const {
  bool IsReflowInterrupted() const { return mWasLastReflowInterrupted; }

  /**
   * Return true if the the interruptible reflows have to be suppressed.
  // Approximate frame visibility tracking public API.
   * This may happen only if if the most recent reflow was interrupted.
   */
  bool SuppressInterruptibleReflows() const {
    return mWasLastReflowInterrupted;
  }
   * This lets the refresh driver know that we want a visibility update in the

  //////////////////////////////////////////////////////////////////////////////
  // Approximate frame visibility tracking public API.
  //////////////////////////////////////////////////////////////////////////////


  /**
   * Schedule an update of the list of approximately visible frames "soon".
   * This lets the refresh driver know that we want a visibility update in the
   * near future. The refresh driver applies its own heuristics and throttling
   * to decide when to actually perform the visibility update.
   */
  void ScheduleApproximateFrameVisibilityUpdateSoon();
  void ScheduleApproximateFrameVisibilityUpdateNow();

  /**
   * Schedule an update of the list of approximately visible frames "now". The
   * update runs asynchronously, but it will be posted to the event loop
   * immediately. Prefer the "soon" variation of this method when possible, as
   * this variation ignores the refresh driver's heuristics.
   */
   */
  void ScheduleApproximateFrameVisibilityUpdateNow();

                                         bool aRemoveOnly = false);
  /**
   * Clears the current list of approximately visible frames on this pres shell
   * and replaces it with frames that are in the display list @aList.
   */
   */
  void RebuildApproximateFrameVisibilityDisplayList(const nsDisplayList& aList);
  void RebuildApproximateFrameVisibility(nsRect* aRect = nullptr,
                                         bool aRemoveOnly = false);

  /**

   * Ensures @aFrame is in the list of approximately visible frames.
   */
  void EnsureFrameInApproximatelyVisibleList(nsIFrame* aFrame);

  /// Removes @aFrame from the list of approximately visible frames if present.
   * Returns whether the document's style set's rule processor for the
  void RemoveFrameFromApproximatelyVisibleList(nsIFrame* aFrame);

  /// Whether we should assume all frames are visible.
  bool AssumeAllFramesVisible();

  nsresult HasRuleProcessorUsedByMultipleStyleSets(uint32_t aSheetType,
  /**
   * Returns whether the document's style set's rule processor for the
   * specified level of the cascade is shared by multiple style sets.
   *
   */
   * @param aSheetType One of the nsIStyleSheetService.*_SHEET constants.
   */
  nsresult HasRuleProcessorUsedByMultipleStyleSets(uint32_t aSheetType,
                                                   bool* aRetVal);

  void NativeAnonymousContentRemoved(nsIContent* aAnonContent);
  /**
   * Returns whether or not the document has ever handled user input
   */
  bool HasHandledUserInput() const { return mHasHandledUserInput; }

  MOZ_CAN_RUN_SCRIPT void FireResizeEvent();

    mForceUseLegacyKeyCodeAndCharCodeValues |=
  void NativeAnonymousContentRemoved(nsIContent* aAnonContent);

  /**
   * See HTMLDocument.setKeyPressEventModel() in HTMLDocument.webidl for the
   * detail.
  bool AddRefreshObserver(nsARefreshObserver* aObserver, FlushType aFlushType);
   */
  void SetKeyPressEventModel(uint16_t aKeyPressEventModel) {
    mForceUseLegacyKeyCodeAndCharCodeValues |=
        aKeyPressEventModel ==
        dom::Document_Binding::KEYPRESS_EVENT_MODEL_SPLIT;
  }
  bool RemovePostRefreshObserver(nsAPostRefreshObserver* aObserver);

  bool AddRefreshObserver(nsARefreshObserver* aObserver, FlushType aFlushType);
  bool RemoveRefreshObserver(nsARefreshObserver* aObserver,
                             FlushType aFlushType);

  struct VisualScrollUpdate {
  bool AddPostRefreshObserver(nsAPostRefreshObserver* aObserver);
  bool RemovePostRefreshObserver(nsAPostRefreshObserver* aObserver);

  };
  // Represents an update to the visual scroll offset that will be sent to APZ.
  // The update type is used to determine priority compared to other scroll
  // updates.
  struct VisualScrollUpdate {
    nsPoint mVisualScrollOffset;
  // internally triggers scrolling; scrolling triggered explicitly by web
    FrameMetrics::ScrollOffsetUpdateType mUpdateType;
    bool mAcknowledged = false;
  };

  // Ask APZ in the next transaction to scroll to the given visual viewport
  // offset (relative to the document).
  // This is intended to be used when desired in cases where the browser
  // internally triggers scrolling; scrolling triggered explicitly by web
  //   * Be sure to call ScrollTo*() first, as a subsequent layout scroll
  // content (such as via window.scrollTo() should scroll the layout viewport
  // only).
  // If scrolling "far away", i.e. not just within the existing layout
  // viewport, it's recommended to use both nsIScrollableFrame.ScrollTo*()
  // (via window.scrollTo if calling from JS) *and* this function; otherwise,
  //     need to be used.
  // temporary checkerboarding may result. If doing this:
  //   * Be sure to call ScrollTo*() first, as a subsequent layout scroll
  //     in the same transaction will cancel the pending visual scroll.
  //   * Keep in mind that ScrollTo*() can tear down the pres shell and
  //     frame tree. Depending on how the pres shell is obtained for the
  void AcknowledgePendingVisualScrollUpdate();
  //     subsequent ScrollToVisual() call, AutoWeakFrame or similar may
  //     need to be used.
  // Please request APZ review if adding a new call site.
  void ScrollToVisual(const nsPoint& aVisualViewportOffset,
                      FrameMetrics::ScrollOffsetUpdateType aUpdateType,

                      ScrollMode aMode);
  void AcknowledgePendingVisualScrollUpdate();
  void ClearPendingVisualScrollUpdate();
  const Maybe<VisualScrollUpdate>& GetPendingVisualScrollUpdate() const {
    return mPendingVisualScrollUpdate;
   * Documents belonging to an invisible DocShell must not be painted ever.
  }

  nsPoint GetLayoutViewportOffset() const;
  nsSize GetLayoutViewportSize() const;
    mIsNeverPainting = aNeverPainting;

  /**
   * Documents belonging to an invisible DocShell must not be painted ever.
   */
  bool IsNeverPainting() { return mIsNeverPainting; }

  void SetNeverPainting(bool aNeverPainting) {
    mIsNeverPainting = aNeverPainting;
  }
  }

  /**
   * True if a reflow event has been scheduled, or is going to be scheduled
   * to run in the future.
   */

  bool HasPendingReflow() const {
    return mObservingLayoutFlushes || mReflowContinueTimer;
  }

  void SyncWindowProperties(nsView* aView);
    }

  Document* GetPrimaryContentDocument();

  struct MOZ_RAII AutoAssertNoFlush {
    explicit AutoAssertNoFlush(PresShell& aPresShell)
    const bool mOldForbidden;
        : mPresShell(aPresShell), mOldForbidden(mPresShell.mForbiddenToFlush) {
      mPresShell.mForbiddenToFlush = true;
    }

    ~AutoAssertNoFlush() { mPresShell.mForbiddenToFlush = mOldForbidden; }
  dom::Selection* GetSelection(RawSelectionType aRawSelectionType) override;

    PresShell& mPresShell;
    const bool mOldForbidden;
  };
  NS_IMETHOD ScrollSelectionIntoView(RawSelectionType aRawSelectionType,

  NS_IMETHOD GetSelectionFromScript(RawSelectionType aRawSelectionType,
                                    dom::Selection** aSelection) override;
  dom::Selection* GetSelection(RawSelectionType aRawSelectionType) override;

  void SelectionWillTakeFocus() override;
  NS_IMETHOD SetDisplaySelection(int16_t aToggle) override;
  NS_IMETHOD GetDisplaySelection(int16_t* aToggle) override;
  NS_IMETHOD ScrollSelectionIntoView(RawSelectionType aRawSelectionType,
                                     SelectionRegion aRegion,
   * allocate more or fewer pixels for rescalable content by a factor
                                     int16_t aFlags) override;
  NS_IMETHOD RepaintSelection(RawSelectionType aRawSelectionType) override;
  void SelectionWillTakeFocus() override;
  void SelectionWillLoseFocus() override;

   * Also increase the scale of the content by the same amount
  /**
   * Set a "resolution" for the document, which if not 1.0 will
   * allocate more or fewer pixels for rescalable content by a factor
   * of |resolution| in both dimensions.  Return NS_OK iff the
   * resolution bounds are sane, and the resolution of this was
   * actually updated.
   *
   * the main thread, use pass ResolutionChangeOrigin::MainThread (similar
   * Also increase the scale of the content by the same amount
   * (that's the "AndScaleTo" part).
   *
   * The resolution defaults to 1.0.
   *

   * |aOrigin| specifies who originated the resolution change. For changes
   * sent by APZ, pass ResolutionChangeOrigin::Apz. For changes sent by
   * the main thread, use pass ResolutionChangeOrigin::MainThread (similar
   * to the |aOrigin| parameter of nsIScrollableFrame::ScrollToCSSPixels()).
   */
  void BackingScaleFactorChanged() { mPresContext->UIResolutionChangedSync(); }
  nsresult SetResolutionAndScaleTo(float aResolution,
                                   ResolutionChangeOrigin aOrigin);

  // Widget notificiations
  void WindowSizeMoveDone();
  void ThemeChanged() { mPresContext->ThemeChanged(); }
  void BackingScaleFactorChanged() { mPresContext->UIResolutionChangedSync(); }
   * Notify that we're going to call Paint with PaintFlags::PaintLayers

  MOZ_CAN_RUN_SCRIPT
  void Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
             PaintFlags aFlags);

   */
  /**
   * Notify that we're going to call Paint with PaintFlags::PaintLayers
   * on the pres shell for a widget (which might not be this one, since
   * WillPaint is called on all presshells in the same toplevel window as the
   * painted widget). This is issued at a time when it's safe to modify
   * manager flush on the next tick.
   * widget geometry.
   */
  MOZ_CAN_RUN_SCRIPT void WillPaint();

  /**
   */
   * Ensures that the refresh driver is running, and schedules a view
   * manager flush on the next tick.
   *
   * @param aType PaintType::DelayedCompress : Schedule a paint to be executed
   * after a delay, and put FrameLayerBuilder in 'compressed' mode that avoids
  NS_IMETHOD SetCaretEnabled(bool aInEnable) override;
   * short cut optimizations.
   */
  void ScheduleViewManagerFlush(PaintType aType = PaintType::Default);

  // caret handling

  NS_IMETHOD SetCaretEnabled(bool aInEnable) override;
  NS_IMETHOD SetCaretReadOnly(bool aReadOnly) override;
  NS_IMETHOD GetCaretEnabled(bool* aOutEnabled) override;
  NS_IMETHOD SetCaretVisibilityDuringSelection(bool aVisibility) override;
  NS_IMETHOD GetCaretVisible(bool* _retval) override;
   *

  /**
   * Should the images have borders etc.  Actual visual effects are determined
   * by the frames.  Visual effects may not effect layout, only display.
   * Takes effect on next repaint, does not force a repaint itself.

   *
   * @param aFlags may be multiple of nsISelectionDisplay::DISPLAY_*.
   */
  NS_IMETHOD SetSelectionFlags(int16_t aFlags) override;
  NS_IMETHOD GetSelectionFlags(int16_t* aFlags) override;
   */

  /**
   * Gets the current state of non text selection effects
   * @return   current state of non text selection,
   *           as set by SetDisplayNonTextSelection
  NS_IMETHOD PhysicalMove(int16_t aDirection, int16_t aAmount,
   */
  int16_t GetSelectionFlags() const { return mSelectionFlags; }

  // nsISelectionController
  NS_IMETHOD LineMove(bool aForward, bool aExtend) override;

  NS_IMETHOD PhysicalMove(int16_t aDirection, int16_t aAmount,
                          bool aExtend) override;
  NS_IMETHOD CharacterMove(bool aForward, bool aExtend) override;
  NS_IMETHOD WordMove(bool aForward, bool aExtend) override;
  NS_IMETHOD ScrollLine(bool aForward) override;
  NS_IMETHOD LineMove(bool aForward, bool aExtend) override;
  NS_IMETHOD ScrollCharacter(bool aRight) override;
  NS_IMETHOD IntraLineMove(bool aForward, bool aExtend) override;
  MOZ_CAN_RUN_SCRIPT
  NS_IMETHOD PageMove(bool aForward, bool aExtend) override;
  NS_IMETHOD ScrollPage(bool aForward) override;
  NS_IMETHOD ScrollLine(bool aForward) override;
                             int16_t EndOffset, bool* _retval) override;
  NS_IMETHOD ScrollCharacter(bool aRight) override;
  NS_IMETHOD CompleteScroll(bool aForward) override;
  NS_IMETHOD CompleteMove(bool aForward, bool aExtend) override;
  NS_IMETHOD SelectAll() override;
  NS_IMETHOD CheckVisibility(nsINode* node, int16_t startOffset,
  void DocumentStatesChanged(EventStates);
                             int16_t EndOffset, bool* _retval) override;
  nsresult CheckVisibilityContent(nsIContent* aNode, int16_t aStartOffset,
                                  int16_t aEndOffset, bool* aRetval) override;

  // Notifies that the state of the document has changed.
  NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED
  void DocumentStatesChanged(EventStates);

  // nsIDocumentObserver
  NS_DECL_NSIDOCUMENTOBSERVER_BEGINLOAD
  NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD
  NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
  NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED

  // nsIMutationObserver

  NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
  NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTEWILLCHANGE
  NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
  NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
  NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
  NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
  inline void SetNeedStyleFlush();

  NS_DECL_NSIOBSERVER

  // Inline methods defined in PresShellInlines.h
  inline void EnsureStyleFlush();
  inline void SetNeedStyleFlush();
   * Whether we might need a flush for the given flush type.  If this
  inline void SetNeedLayoutFlush();
  inline void SetNeedThrottledAnimationFlush();
  inline ServoStyleSet* StyleSet() const;

  /**
   *   animation flush is required.
   * Whether we might need a flush for the given flush type.  If this
   * function returns false, we definitely don't need to flush.
   *
   * @param aFlushType The flush type to check.  This must be
   *   >= FlushType::Style.  This also returns true if a throttled
    // we could end up missing needed flushes, since we clear the mNeedXXXFlush
   *   animation flush is required.
   */
  bool NeedFlush(FlushType aType) const {
    // We check mInFlush to handle re-entrant calls to FlushPendingNotifications
    // by reporting that we always need a flush in that case.  Otherwise,
           aType >= FlushType::Display || mNeedThrottledAnimationFlush ||
    // we could end up missing needed flushes, since we clear the mNeedXXXFlush
    // flags at the top of FlushPendingNotifications.
    MOZ_ASSERT(aType >= FlushType::Style);
  /**
    return mNeedStyleFlush ||
           (mNeedLayoutFlush && aType >= FlushType::InterruptibleLayout) ||
           aType >= FlushType::Display || mNeedThrottledAnimationFlush ||
           mInFlush;
  }
  bool NeedLayoutFlush() const { return mNeedLayoutFlush; }

  /**
   * Returns true if we might need to flush layout, even if we haven't scheduled

   * one yet (as opposed to HasPendingReflow, which returns true if a flush is
   * scheduled or will soon be scheduled).
   */
  bool NeedLayoutFlush() const { return mNeedLayoutFlush; }

  bool NeedStyleFlush() const { return mNeedStyleFlush; }
   * than the document itself) should probably be calling

  /**
   * Flush pending notifications of the type specified.  This method
   * will not affect the content model; it'll just affect style and
   * frames. Callers that actually want up-to-date presentation (other
   * itself will ensure it lives up until the method returns, but callers who
   * than the document itself) should probably be calling
   * Document::FlushPendingNotifications.
   *
   * This method can execute script, which can destroy this presshell object
   * unless someone is holding a reference to it on the stack.  The presshell
   */
   * itself will ensure it lives up until the method returns, but callers who
   * plan to use the presshell after this call should hold a strong ref
   * themselves!
   *
   * @param aType the type of notifications to flush
    }
   */
  MOZ_CAN_RUN_SCRIPT
  void FlushPendingNotifications(FlushType aType) {
    if (!NeedFlush(aType)) {
  MOZ_CAN_RUN_SCRIPT
      return;
    }

    DoFlushPendingNotifications(aType);
  }


  MOZ_CAN_RUN_SCRIPT
  void FlushPendingNotifications(ChangesToFlush aType) {
    if (!NeedFlush(aType.mFlushType)) {
      return;
    }
   * Tell the pres shell that a frame needs to be marked dirty and needs

    DoFlushPendingNotifications(aType);
  }

  /**
   * or nsFrameState(0); passing 0 means that dirty bits won't be set on the
   * Tell the pres shell that a frame needs to be marked dirty and needs
   * Reflow.  It's OK if this is an ancestor of the frame needing reflow as
   * long as the ancestor chain between them doesn't cross a reflow root.
   *
   * The bit to add should be NS_FRAME_IS_DIRTY, NS_FRAME_HAS_DIRTY_CHILDREN
  void FrameNeedsReflow(
   * or nsFrameState(0); passing 0 means that dirty bits won't be set on the
   * frame or its ancestors/descendants, but that intrinsic widths will still
   * be marked dirty.  Passing aIntrinsicDirty = eResize and aBitToAdd = 0
   * would result in no work being done, so don't do that.
   * Calls FrameNeedsReflow on all fixed position children of the root frame.
   */
  void FrameNeedsReflow(
      nsIFrame* aFrame, IntrinsicDirty aIntrinsicDirty, nsFrameState aBitToAdd,
      ReflowRootHandling aRootHandling = ReflowRootHandling::InferFromBitToAdd);

  // or reset.
  /**
   * Calls FrameNeedsReflow on all fixed position children of the root frame.
   */
  void MarkFixedFramesForReflow(IntrinsicDirty aIntrinsicDirty);

   */
  // This function handles all the work after VisualViewportSize is set
  // or reset.
  void CompleteChangeToVisualViewportSize();

  nsPoint GetVisualViewportOffset() const {
  /**
   * The return value indicates whether the offset actually changed.
   */
  bool SetVisualViewportOffset(const nsPoint& aScrollOffset,
                               const nsPoint& aPrevLayoutScrollPos);
  }

  nsPoint GetVisualViewportOffset() const {
    return mVisualViewportOffset.valueOr(nsPoint());
  }
  bool IsVisualViewportOffsetSet() const {
  nsSize GetVisualViewportSize() {
    return mVisualViewportOffset.isSome();
  }

  void SetVisualViewportSize(nscoord aWidth, nscoord aHeight);
  void ResetVisualViewportSize();

  bool IsVisualViewportSizeSet() { return mVisualViewportSizeSet; }
  nsSize GetVisualViewportSize() {
    NS_ASSERTION(mVisualViewportSizeSet,
                 "asking for visual viewport size when its not set?");
    return mVisualViewportSize;
    if (!mPresContext) {
  }

  nsPoint GetVisualViewportOffsetRelativeToLayoutViewport() const;

  // Returns state of the dynamic toolbar.
  }
  DynamicToolbarState GetDynamicToolbarState() const {
    if (!mPresContext) {
      return DynamicToolbarState::None;
    }

  /* Enable/disable author style level. Disabling author style disables the
    return mPresContext->GetDynamicToolbarState();
  }
  // Returns the visual viewport size during the dynamic toolbar is being
  // shown/hidden.
  nsSize GetVisualViewportSizeUpdatedByDynamicToolbar() const;

  void SetAuthorStyleDisabled(bool aDisabled);
  /* Enable/disable author style level. Disabling author style disables the
   * entire author level of the cascade, including the HTML preshint level.
   */
  // XXX these could easily be inlined, but there is a circular #include
  // problem with nsStyleSet.
   * affect document styling.
  void SetAuthorStyleDisabled(bool aDisabled);
  bool GetAuthorStyleDisabled() const;

  /**
   * Update the style set somehow to take into account changed prefs which
  void NotifyStyleSheetServiceSheetAdded(StyleSheet* aSheet,
   * affect document styling.
   */
  void UpdatePreferenceStyles();

  // aSheetType is one of the nsIStyleSheetService *_SHEET constants.
  // DoReflow returns whether the reflow finished without interruption
  void NotifyStyleSheetServiceSheetAdded(StyleSheet* aSheet,
                                         uint32_t aSheetType);
  void NotifyStyleSheetServiceSheetRemoved(StyleSheet* aSheet,
                                           uint32_t aSheetType);


  // DoReflow returns whether the reflow finished without interruption
  // If aFrame is not the root frame, the caller must pass a non-null
   * aBounds. Checks first if this needs to be done by checking if aFrame is a
  // aOverflowTracker.
  bool DoReflow(nsIFrame* aFrame, bool aInterruptible,
   * canvas frame (if the AddCanvasBackgroundColorFlags::ForceDraw is passed
                OverflowChangedTracker* aOverflowTracker);

   *
  /**
   * Add a solid color item to the bottom of aList with frame aFrame and bounds
   * aBounds. Checks first if this needs to be done by checking if aFrame is a
   * canvas frame (if the AddCanvasBackgroundColorFlags::ForceDraw is passed
   * then this check is skipped). aBackstopColor is composed behind the
   *
   * background color of the canvas, it is transparent by default.
   *
   * We attempt to make the background color part of the scrolled canvas (to
   * reduce transparent layers), and if async scrolling is enabled (and the
   * background is opaque) then we add a second, unscrolled item to handle the
   *
   * checkerboarding case.
   *
   * AddCanvasBackgroundColorFlags::AddSubDocument should be specified when
   * calling this for a subdocument, and LayoutUseContainersForRootFrame might
   * cause the whole list to be scrolled. In that case the second unscrolled
  void AddCanvasBackgroundColorItem(
   * item will be elided.
   *
   * AddCanvasBackgroundColorFlags::AppendUnscrolledOnly only attempts to add
   * the unscrolled item, so that we can add it manually after
   * LayoutUseContainersForRootFrame has built the scrolling ContainerLayer.

   */
  void AddCanvasBackgroundColorItem(
      nsDisplayListBuilder* aBuilder, nsDisplayList* aList, nsIFrame* aFrame,
      const nsRect& aBounds, nscolor aBackstopColor = NS_RGBA(0, 0, 0, 0),
      AddCanvasBackgroundColorFlags aFlags =
          AddCanvasBackgroundColorFlags::None);

  size_t SizeOfTextRuns(MallocSizeOf aMallocSizeOf) const;
  static PresShell* GetShellForTouchEvent(WidgetGUIEvent* aEvent);

  void SetNextPaintCompressed() { mNextPaintCompressed = true; }

   * Informs the pres shell that the document is now at the anchor with
  static PresShell* GetShellForEventTarget(nsIFrame* aFrame,
                                           nsIContent* aContent);
  static PresShell* GetShellForTouchEvent(WidgetGUIEvent* aEvent);

  /**
   * be false.  If |aAdditionalScrollFlags| is ScrollFlags::ScrollSmoothAuto
   * Informs the pres shell that the document is now at the anchor with
   * the given name.  If |aScroll| is true, scrolls the view of the
   * document so that the anchor with the specified name is displayed at
   * the top of the window.  If |aAnchorName| is empty, then this informs
   * the pres shell that there is no current target, and |aScroll| must
                      ScrollFlags aAdditionalScrollFlags = ScrollFlags::None);
   * be false.  If |aAdditionalScrollFlags| is ScrollFlags::ScrollSmoothAuto
   * and |aScroll| is true, the scrolling may be performed with an animation.
   */
  MOZ_CAN_RUN_SCRIPT
  nsresult GoToAnchor(const nsAString& aAnchorName, bool aScroll,
   * position has not changed since the last GoToAnchor (modulo scroll anchoring
                      ScrollFlags aAdditionalScrollFlags = ScrollFlags::None);

  /**
   * Tells the presshell to scroll again to the last anchor scrolled to by
  MOZ_CAN_RUN_SCRIPT nsresult ScrollToAnchor();
   * GoToAnchor, if any. This scroll only happens if the scroll
   * position has not changed since the last GoToAnchor (modulo scroll anchoring
   * adjustments). This is called by nsDocumentViewer::LoadComplete. This clears
   * the last anchor scrolled to by GoToAnchor (we don't want to keep it alive
   * if it's removed from the DOM), so don't call this more than once.
   */
  MOZ_CAN_RUN_SCRIPT nsresult ScrollToAnchor();

   * we have a more direct target. If the id-ref points to something that cannot
  /**
   * When scroll anchoring adjusts positions in the root frame during page load,
   * it may move our scroll position in the root frame.
   *
   * While that's generally desirable, when scrolling to an anchor via an id-ref
   * we have a more direct target. If the id-ref points to something that cannot
   * On page load, the document viewer will call ScrollToAnchor(), and will only
   * be selected as a scroll anchor container (like an image or an inline), we
   * may select a node following it as a scroll anchor, and if then stuff is
   * inserted on top, we may end up moving the id-ref element offscreen to the
   * top inadvertently.
   *
    if (mLastAnchorScrolledTo) {
   * On page load, the document viewer will call ScrollToAnchor(), and will only
   * scroll to the anchor again if the scroll position is not changed. We don't
   * want scroll anchoring adjustments to prevent this, so account for them.
   */
  void RootScrollFrameAdjusted(nscoord aYAdjustment) {
  /**
    if (mLastAnchorScrolledTo) {
      mLastAnchorScrollPositionY += aYAdjustment;
    }
  }
   *                  scrolled into view.

  /**
   * Scrolls the view of the document so that the primary frame of the content
   * is displayed in the window. Layout is flushed before scrolling.
   *
   * @param aContent  The content object of which primary frame should be
   *                  scrolled into view.
   *                      otherwise all scrollable ancestors may be scrolled
   * @param aVertical How to align the frame vertically and when to do so.
   *                  This is a ScrollAxis of Where and When.
   * @param aHorizontal How to align the frame horizontally and when to do so.
   *                  This is a ScrollAxis of Where and When.
   * @param aScrollFlags  If ScrollFlags::ScrollFirstAncestorOnly is set,
   *                      only the nearest scrollable ancestor is scrolled,
   *                      otherwise all scrollable ancestors may be scrolled
   *                      only scroll nodes in this document, not in any
   *                      if necessary.  If ScrollFlags::ScrollOverflowHidden
   *                      is set then we may scroll in a direction even if
   *                      overflow:hidden is specified in that direction;
   *                      otherwise we will not scroll in that direction when
   *                      overflow:hidden is set for that direction.  If
   *                      nsIScrollableFrame::ScrollMode::SMOOTH_MSD;
   *                      ScrollFlags::ScrollNoParentFrames is set then we
   *                      only scroll nodes in this document, not in any
   *                      parent documents which contain this document in a
   *                      iframe or the like.  If ScrollFlags::ScrollSmooth
   *                      is set and CSSOM-VIEW scroll-behavior is enabled,
   *                      scroll-behavior is enabled, we will scroll smoothly
   *                      we will scroll smoothly using
   *                      nsIScrollableFrame::ScrollMode::SMOOTH_MSD;
   *                      otherwise, nsIScrollableFrame::ScrollMode::INSTANT
   *                      will be used.  If ScrollFlags::ScrollSmoothAuto is
   *                      will be used.
   */
   *                      set, the CSSOM-View scroll-behavior attribute is
   *                      set to 'smooth' on the scroll frame, and CSSOM-VIEW
   *                      scroll-behavior is enabled, we will scroll smoothly
   *                      using nsIScrollableFrame::ScrollMode::SMOOTH_MSD;
                                 ScrollAxis aHorizontal,
   *                      otherwise, nsIScrollableFrame::ScrollMode::INSTANT
   *                      will be used.
   */
  MOZ_CAN_RUN_SCRIPT
  nsresult ScrollContentIntoView(nsIContent* aContent, ScrollAxis aVertical,
   * them at this content node. If capturing is not allowed
                                 ScrollAxis aHorizontal,
                                 ScrollFlags aScrollFlags);

  /**
   * When capturing content is set, it traps all mouse events and retargets
   * them at this content node. If capturing is not allowed
   * (gCaptureInfo.mAllowed is false), then capturing is not set. However, if
   * the CaptureFlags::IgnoreAllowedState is set, the allowed state is ignored
   * aContent or its descendants. That is, descendants of aContent receive
   * and capturing is set regardless. To disable capture, pass null for the
   * value of aContent.
   *
   * If CaptureFlags::RetargetedToElement is set, all mouse events are
   * starting while this capture is active.
   * targeted at aContent only. Otherwise, mouse events are targeted at
   * aContent or its descendants. That is, descendants of aContent receive
   * mouse events as they normally would, but mouse events outside of aContent
   * are retargeted to aContent.
   *
   * won't unlock unless CaptureFlags::PointerLock is set again).
   * If CaptureFlags::PreventDragStart is set then drags are prevented from
   * starting while this capture is active.
   *
   * If CaptureFlags::PointerLock is set, similar to

   * CaptureFlags::RetargetToElement, then events are targeted at aContent,
  /**
   * but capturing is held more strongly (i.e., calls to SetCapturingContent()
   * won't unlock unless CaptureFlags::PointerLock is set again).
   */
   */
  static void SetCapturingContent(nsIContent* aContent, CaptureFlags aFlags);

  /**
   * Alias for SetCapturingContent(nullptr, CaptureFlags::None) for making
  // Called at the end of nsLayoutUtils::PaintFrame().
   * callers what they do clearer.
   */
  static void ReleaseCapturingContent() {
    PresShell::SetCapturingContent(nullptr, CaptureFlags::None);
  }
  /**

  // Called at the end of nsLayoutUtils::PaintFrame() if we were painting to
  // the widget.
  // This is used to clear any pending visual scroll updates that have been
  // acknowledged, to make sure they don't stick around for the next paint.
   * to be done immediately after reflow of the current reflow root completes.
  void EndPaint();

  /**
   * Tell the presshell that the given frame's reflow was interrupted.  This
   * will mark as having dirty children a path from the given frame (inclusive)
   */
   * to the nearest ancestor with a dirty subtree, or to the reflow root
   * currently being reflowed if no such ancestor exists (inclusive).  This is
   * to be done immediately after reflow of the current reflow root completes.
   * This method must only be called during reflow, and the frame it's being
   * called on must be in the process of being reflowed when it's called.  This
   * method doesn't mark any intrinsic widths dirty and doesn't add any bits
   * other than NS_FRAME_HAS_DIRTY_CHILDREN.
   */
   */
  void FrameNeedsToContinueReflow(nsIFrame* aFrame);

  /**
   * Notification sent by a frame informing the pres shell that it is about to
   * be destroyed.
#endif
   * This allows any outstanding references to the frame to be cleaned up
   */
  void NotifyDestroyingFrame(nsIFrame* aFrame);

#ifdef DEBUG
  /**
  nsIFrame* GetDrawEventTargetFrame() { return mDrawEventTargetFrame; }
#endif

 private:
  void DoObserveLayoutFlushes();
  ~PresShell();

  /**
   * Refresh observer management.
   */
   */
  void DoObserveStyleFlushes();
  void DoObserveLayoutFlushes();

  /**
    MOZ_DIAGNOSTIC_ASSERT(!mAllocatedPointers.Contains(aPtr));
   * Does the actual work of figuring out the current state of font size
   * inflation.
   */
  bool DetermineFontSizeInflationState();

  void RecordFree(void* aPtr) {
  void RecordAlloc(void* aPtr) {
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
    MOZ_DIAGNOSTIC_ASSERT(!mAllocatedPointers.Contains(aPtr));
    mAllocatedPointers.PutEntry(aPtr);
#endif
  }
  }

  void RecordFree(void* aPtr) {
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
  nsIContent* GetCurrentEventContent();
    MOZ_DIAGNOSTIC_ASSERT(mAllocatedPointers.Contains(aPtr));
    mAllocatedPointers.RemoveEntry(aPtr);
#endif
  }

  void PushCurrentEventInfo(nsIFrame* aFrame, nsIContent* aContent);
  void WillCauseReflow();
  void PopCurrentEventInfo();
  nsIContent* GetCurrentEventContent();
  void CancelPostedReflowCallbacks();

  friend class ::nsRefreshDriver;
  friend class ::nsAutoCauseReflowNotifier;

  void WillCauseReflow();
      FrameMetrics::ScrollOffsetUpdateType aUpdateType);
  MOZ_CAN_RUN_SCRIPT void DidCauseReflow();

  void CancelPostedReflowCallbacks();
  void FlushPendingScrollAnchorAdjustments();


  void SetPendingVisualScrollUpdate(
      const nsPoint& aVisualViewportOffset,
      FrameMetrics::ScrollOffsetUpdateType aUpdateType);

#ifdef MOZ_REFLOW_PERF
  UniquePtr<ReflowCountMgr> mReflowCountMgr;
  struct ScrollIntoViewData {
#endif

  void WillDoReflow();

  // This data is stored as a content property (nsGkAtoms::scrolling) on

  // mContentToScrollTo when we have a pending ScrollIntoView.
  struct ScrollIntoViewData {
    ScrollAxis mContentScrollVAxis;
    ScrollAxis mContentScrollHAxis;
    ScrollFlags mContentToScrollToFlags;
  // The callback for the mReflowContinueTimer timer.
  };

  static LazyLogModule gLog;

  DOMHighResTimeStamp GetPerformanceNowUnclamped();
  // called off a timer, otherwise it is called directly.

  // The callback for the mReflowContinueTimer timer.
  static void sReflowContinueCallback(nsITimer* aTimer, void* aPresShell);
  bool ScheduleReflowOffTimer();
  // MaybeScheduleReflow checks if posting a reflow is needed, then checks if
  void ScheduleReflow();
  // the last reflow was interrupted. In the interrupted case ScheduleReflow is
  // called off a timer, otherwise it is called directly.
  void MaybeScheduleReflow();
  // Actually schedules a reflow.  This should only be called by
  // without interruptions.
  // MaybeScheduleReflow and the reflow timer ScheduleReflowOffTimer
  // sets up.
  void ScheduleReflow();

  friend class ::AutoPointerEventTargetUpdater;

  // ProcessReflowCommands returns whether we processed all our dirty roots
  // without interruptions.
   */
  MOZ_CAN_RUN_SCRIPT bool ProcessReflowCommands(bool aInterruptible);

  /**
   * Callback handler for whether reflow happened.
   *
  /**
   * @param aInterruptible Whether or not reflow interruption is allowed.
   */
  MOZ_CAN_RUN_SCRIPT void DidDoReflow(bool aInterruptible);

  MOZ_CAN_RUN_SCRIPT void HandlePostedReflowCallbacks(bool aInterruptible);
  /**

  /**
   * Helper for ScrollContentIntoView()
   */
  MOZ_CAN_RUN_SCRIPT void DoScrollContentIntoView();
  void AddAgentSheet(StyleSheet*);

  /**
   * Methods to handle changes to user and UA sheet lists that we get
   * notified about.
   */
  void AddUserSheet(StyleSheet*);
   *
  void AddAgentSheet(StyleSheet*);
  void AddAuthorSheet(StyleSheet*);
  void RemovePreferenceStyles();

  /**
  void SetupFontInflation();
   * Initialize cached font inflation preference values and do an initial
   * computation to determine if font inflation is enabled.
   *
   * @see nsLayoutUtils::sFontSizeInflationEmPerLine
   * @see nsLayoutUtils::sFontSizeInflationMinTwips
  MOZ_CAN_RUN_SCRIPT void DoFlushPendingNotifications(FlushType aType);
   * @see nsLayoutUtils::sFontSizeInflationLineThreshold
   */
  void SetupFontInflation();

    explicit RenderingState(PresShell* aPresShell)
  /**
   * Implementation methods for FlushPendingNotifications.
   */
  MOZ_CAN_RUN_SCRIPT void DoFlushPendingNotifications(FlushType aType);
  MOZ_CAN_RUN_SCRIPT void DoFlushPendingNotifications(ChangesToFlush aType);
  };

  struct RenderingState {
    explicit RenderingState(PresShell* aPresShell)
        : mResolution(aPresShell->mResolution),
          mRenderingStateFlags(aPresShell->mRenderingStateFlags) {}

    Maybe<float> mResolution;
    RenderingStateFlags mRenderingStateFlags;
  };

  struct AutoSaveRestoreRenderingState {
    explicit AutoSaveRestoreRenderingState(PresShell* aPresShell)
        : mPresShell(aPresShell), mOldState(aPresShell) {}

  };
    ~AutoSaveRestoreRenderingState() {
      mPresShell->mRenderingStateFlags = mOldState.mRenderingStateFlags;
      mPresShell->mResolution = mOldState.mResolution;
    }

  // methods for painting a range to an offscreen buffer
    PresShell* mPresShell;
    RenderingState mOldState;
  };
  void SetRenderingState(const RenderingState& aState);

                         nsRange* aRange);
  friend class ::nsPresShellEventCB;

  // methods for painting a range to an offscreen buffer

  // given a display list, clip the items within the list to
                                                 nsRect& aSurfaceRect,
  // the range
  nsRect ClipListToRange(nsDisplayListBuilder* aBuilder, nsDisplayList* aList,
                         nsRange* aRange);

  // create a RangePaintInfo for the range aRange containing the
  // display list needed to paint the range to a surface
  UniquePtr<RangePaintInfo> CreateRangePaintInfo(nsRange* aRange,
                                                 nsRect& aSurfaceRect,
                                                 bool aForPrimarySelection);
   * aPoint - reference point, typically the mouse position

  /*
   * Paint the items to a new surface and return it.
   *
   * aSelection - selection being painted, if any
   * aRegion - clip region, if any
   * aArea - area that the surface occupies, relative to the root frame
  already_AddRefed<SourceSurface> PaintRangePaintInfo(
   * aPoint - reference point, typically the mouse position
   * aScreenRect - [out] set to the area of the screen the painted area should
   *               be displayed at
   * aFlags - set RenderImageFlags::AutoScale to scale down large images, but

   * it must not be set if a custom image was specified
   */
  already_AddRefed<SourceSurface> PaintRangePaintInfo(
      const nsTArray<UniquePtr<RangePaintInfo>>& aItems,
      dom::Selection* aSelection, const Maybe<CSSIntRegion>& aRegion,
  void RestoreRootScrollPosition();
      nsRect aArea, const LayoutDeviceIntPoint aPoint,
      LayoutDeviceIntRect* aScreenRect, RenderImageFlags aFlags);

  // Hide a view if it is a popup
  void HideViewIfPopup(nsView* aView);
   public:

  // Utility method to restore the root scrollframe state
  void RestoreRootScrollPosition();

  void MaybeReleaseCapturingContent();


  class DelayedEvent {
   public:
    virtual ~DelayedEvent() = default;
    virtual void Dispatch() {}
    virtual bool IsKeyPressEvent() { return false; }
  };

  class DelayedInputEvent : public DelayedEvent {
    WidgetInputEvent* mEvent;
   public:
    void Dispatch() override;

   protected:
    DelayedInputEvent();
    ~DelayedInputEvent() override;


    WidgetInputEvent* mEvent;
  };

  class DelayedMouseEvent : public DelayedInputEvent {
    explicit DelayedKeyEvent(WidgetKeyboardEvent* aEvent);
    bool IsKeyPressEvent() override;
   public:
    explicit DelayedMouseEvent(WidgetMouseEvent* aEvent);
  };

  // Check if aEvent is a mouse event and record the mouse location for later
  class DelayedKeyEvent : public DelayedInputEvent {
   public:
    explicit DelayedKeyEvent(WidgetKeyboardEvent* aEvent);
    bool IsKeyPressEvent() override;
  };
   public:

  // Check if aEvent is a mouse event and record the mouse location for later
  // synth mouse moves.
  void RecordMouseLocation(WidgetGUIEvent* aEvent);
  inline bool MouseLocationWasSetBySynthesizedMouseEventForTests() const;

  class nsSynthMouseMoveEvent final : public nsARefreshObserver {
   public:
    nsSynthMouseMoveEvent(PresShell* aPresShell, bool aFromScroll)
        : mPresShell(aPresShell), mFromScroll(aFromScroll) {
      NS_ASSERTION(mPresShell, "null parameter");
   public:
    }

   private:
    // Private destructor, to discourage deletion outside of Release():
    ~nsSynthMouseMoveEvent() { Revoke(); }

   public:
    NS_INLINE_DECL_REFCOUNTING(nsSynthMouseMoveEvent, override)
      }

    void Revoke() {
      if (mPresShell) {
        mPresShell->GetPresContext()->RefreshDriver()->RemoveRefreshObserver(
            this, FlushType::Display);
        mPresShell = nullptr;
      }
      }
    }
    MOZ_CAN_RUN_SCRIPT
    void WillRefresh(TimeStamp aTime) override {
      if (mPresShell) {
    bool mFromScroll;
        RefPtr<PresShell> shell = mPresShell;
        shell->ProcessSynthMouseMoveEvent(mFromScroll);
      }
    }

  nsresult UpdateImageLockingState();
   private:
    PresShell* mPresShell;
    bool mFromScroll;
  };
  MOZ_CAN_RUN_SCRIPT void ProcessSynthMouseMoveEvent(bool aFromScroll);
   * EventHandler is implementation of PresShell::HandleEvent().

  void QueryIsActive();
  nsresult UpdateImageLockingState();

  already_AddRefed<PresShell> GetParentPresShellForEventHandling();

    EventHandler(const EventHandler& aOther) = delete;
  /**
   * EventHandler is implementation of PresShell::HandleEvent().
   */
  class MOZ_STACK_CLASS EventHandler final {
   public:
    EventHandler() = delete;
    /**
    EventHandler(const EventHandler& aOther) = delete;
    explicit EventHandler(PresShell& aPresShell)
        : mPresShell(aPresShell), mCurrentEventInfoSetter(nullptr) {}
    explicit EventHandler(RefPtr<PresShell>&& aPresShell)
     * event info of mPresShell and calls HandleEventWithCurrentEventInfo()
        : mPresShell(std::move(aPresShell)), mCurrentEventInfoSetter(nullptr) {}

    /**
     * HandleEvent() may dispatch aGUIEvent.  This may redirect the event to
     * another PresShell, or the event may be handled by other classes like
     *                                  Otherwise, a frame which contains the
     * AccessibleCaretEventHub, or discarded.  Otherwise, this sets current
     * event info of mPresShell and calls HandleEventWithCurrentEventInfo()
     * to dispatch the event into the DOM tree.
     *
     * @param aFrameForPresShell        The frame for PresShell.  If PresShell
     *                                  event.
     *                                  has root frame, it should be set.
     *                                  Otherwise, a frame which contains the
     *                                  PresShell should be set instead.  I.e.,
     *                                  in the latter case, the frame is in
     * @param aEventStatus              [in/out] EventStatus of aGUIEvent.
     *                                  a parent document.
     * @param aGUIEvent                 Event to be handled.  Must be a trusted
     *                                  event.
     * @param aDontRetargetEvents       true if this shouldn't redirect the
     *                                  event to different PresShell.
                         nsEventStatus* aEventStatus);
     *                                  false if this can redirect the event to
     *                                  different PresShell.
     * @param aEventStatus              [in/out] EventStatus of aGUIEvent.
     */
     * setting current event target content to aNewEventContent and current
    MOZ_CAN_RUN_SCRIPT
    nsresult HandleEvent(nsIFrame* aFrameForPresShell,
                         WidgetGUIEvent* aGUIEvent, bool aDontRetargetEvents,
                         nsEventStatus* aEventStatus);

     * @param aEvent                    Event to be dispatched.  Must be a
    /**
     * HandleEventWithTarget() tries to dispatch aEvent on aContent after
     * setting current event target content to aNewEventContent and current
     * event frame to aNewEventFrame temporarily.  Note that this supports
     * @param aEventStatus              [in/out] EventStuatus of aEvent.
     * WidgetEvent, not WidgetGUIEvent.  So, you can dispatch a simple event
     * with this.
     *
     * @param aEvent                    Event to be dispatched.  Must be a
     *                                  trusted event.
     *                                  PresShell::mPointerEventTarget is
     * @param aNewEventFrame            Temporal new event frame.
     * @param aNewEventContent          Temporal new event content.
     * @param aEventStatus              [in/out] EventStuatus of aEvent.
     * @param aIsHandlingNativeEvent    true if aEvent represents a native
     *                                  event.
    MOZ_CAN_RUN_SCRIPT
     * @param aTargetContent            This is used only when aEvent is a
     *                                  pointer event.  If
     *                                  PresShell::mPointerEventTarget is
     *                                  changed during dispatching aEvent,
     *                                  this is set to the new target.
                                   bool aIsHandlingNativeEvent,
     * @param aOverrideClickTarget      Override click event target.
     */
    MOZ_CAN_RUN_SCRIPT
    nsresult HandleEventWithTarget(WidgetEvent* aEvent,
                                   nsIFrame* aNewEventFrame,
     * OnPresShellDestroy() is called when every PresShell instance is being
                                   nsIContent* aNewEventContent,
                                   nsEventStatus* aEventStatus,
                                   bool aIsHandlingNativeEvent,
                                   nsIContent** aTargetContent,
                                   nsIContent* aOverrideClickTarget);
   private:

    /**
     * OnPresShellDestroy() is called when every PresShell instance is being
     * destroyed.
     */

    static inline void OnPresShellDestroy(Document* aDocument);

   private:
    static bool InZombieDocument(nsIContent* aContent);
    static nsIFrame* GetNearestFrameContainingPresShell(PresShell* aPresShell);
     * @param aFrameForPresShell        The frame for PresShell.  See
    static nsIPrincipal* GetDocumentPrincipalToCompareWithBlacklist(
        PresShell& aPresShell);

    /**
     * HandleEventUsingCoordinates() handles aGUIEvent whose
     * @param aEventStatus              The status of aGUIEvent.
     * IsUsingCoordinates() returns true with the following helper methods.
     *
     * @param aFrameForPresShell        The frame for PresShell.  See
     *                                  explanation of HandleEvent() for the
     *                                  details.
    nsresult HandleEventUsingCoordinates(nsIFrame* aFrameForPresShell,
     * @param aGUIEvent                 The handling event.  Make sure that
     *                                  its IsUsingCoordinates() returns true.
     * @param aEventStatus              The status of aGUIEvent.
     * @param aDontRetargetEvents       true if we've already retarget document.
     *                                  Otherwise, false.
     */
    MOZ_CAN_RUN_SCRIPT
    nsresult HandleEventUsingCoordinates(nsIFrame* aFrameForPresShell,
                                         WidgetGUIEvent* aGUIEvent,
     */
                                         nsEventStatus* aEventStatus,
                                         bool aDontRetargetEvents);

    /**
        SetFrameAndComputePresShell(aFrameToHandleEvent);
     * EventTargetData struct stores a set of a PresShell (event handler),
     * a frame (to handle the event) and a content (event target for the frame).
     */
    struct MOZ_STACK_CLASS EventTargetData final {
      EventTargetData() = delete;
                                                 WidgetGUIEvent* aGUIEvent);
      EventTargetData(const EventTargetData& aOther) = delete;
      explicit EventTargetData(nsIFrame* aFrameToHandleEvent) {
        SetFrameAndComputePresShell(aFrameToHandleEvent);
      }

      void SetFrameAndComputePresShell(nsIFrame* aFrameToHandleEvent);
      void SetFrameAndComputePresShellAndContent(nsIFrame* aFrameToHandleEvent,
                                                 WidgetGUIEvent* aGUIEvent);
      void SetContentForEventFromFrame(WidgetGUIEvent* aGUIEvent);
      }

      nsPresContext* GetPresContext() const {
        return mPresShell ? mPresShell->GetPresContext() : nullptr;
      };
      EventStateManager* GetEventStateManager() const {
        nsPresContext* presContext = GetPresContext();

        return presContext ? presContext->EventStateManager() : nullptr;
      }
      Document* GetDocument() const {
        return mPresShell ? mPresShell->GetDocument() : nullptr;
      }
      nsIContent* GetFrameContent() const;
       * @return                true if retargetted.

      /**
       * MaybeRetargetToActiveDocument() tries retarget aGUIEvent into
       * active document if there is.  Note that this does not support to
       * retarget mContent.  Make sure it is nullptr before calling this.
       * ComputeElementFromFrame() computes mContent for aGUIEvent.  If
       *
       * @param aGUIEvent       The handling event.
       * @return                true if retargetted.
       */
      bool MaybeRetargetToActiveDocument(WidgetGUIEvent* aGUIEvent);
       * @return                true if caller can keep handling the event.

      /**
       * ComputeElementFromFrame() computes mContent for aGUIEvent.  If
       * mContent is set by this method, mContent is always nullptr or an
       * Element.
      bool ComputeElementFromFrame(WidgetGUIEvent* aGUIEvent);
       *
       * @param aGUIEvent       The handling event.
       * @return                true if caller can keep handling the event.
       *                        Otherwise, false.
       *                        Note that even if this returns true, mContent
       *                        may be nullptr.
       *
       */
      bool ComputeElementFromFrame(WidgetGUIEvent* aGUIEvent);

      /**
       * UpdateTouchEventTarget() updates mFrame, mPresShell and mContent if

       * aGUIEvent is a touch event and there is new proper target.
       *
       * @param aGUIEvent       The handled event.  If it's not a touch event,
       *                        this method does nothing.
       */
    };
      void UpdateTouchEventTarget(WidgetGUIEvent* aGUIEvent);

      RefPtr<PresShell> mPresShell;
      nsIFrame* mFrame = nullptr;
     *
      nsCOMPtr<nsIContent> mContent;
      nsCOMPtr<nsIContent> mOverrideClickTarget;
    };

    /**
     * MaybeFlushPendingNotifications() maybe flush pending notifications if
     * aGUIEvent should be handled with the latest layout.
    bool MaybeFlushPendingNotifications(WidgetGUIEvent* aGUIEvent);
     *
     * @param aGUIEvent                 The handling event.
     * @return                          true if this actually flushes pending
     *                                  layout and that has caused changing the
     *                                  layout.
     *
     */
    MOZ_CAN_RUN_SCRIPT
    bool MaybeFlushPendingNotifications(WidgetGUIEvent* aGUIEvent);

    /**
     * GetFrameToHandleNonTouchEvent() returns a frame to handle the event.
     *                                  stop handling the event.
     * This may flush pending layout if the target is in child PresShell.
     *
     * @param aRootFrameToHandleEvent   The root frame to handle the event.
     * @param aGUIEvent                 The handling event.
     * @return                          The frame which should handle the

     *                                  event.  nullptr if the caller should
     *                                  stop handling the event.
     */
    MOZ_CAN_RUN_SCRIPT
    nsIFrame* GetFrameToHandleNonTouchEvent(nsIFrame* aRootFrameToHandleEvent,
     *
                                            WidgetGUIEvent* aGUIEvent);

    /**
     * ComputeEventTargetFrameAndPresShellAtEventPoint() computes event
     * target frame at the event point of aGUIEvent and set it to
     * @return                          true if the caller can handle the
     * aEventTargetData.
     *
     * @param aRootFrameToHandleEvent   The root frame to handle aGUIEvent.
     * @param aGUIEvent                 The handling event.
     * @param aEventTargetData          [out] Its frame and PresShell will
        nsIFrame* aRootFrameToHandleEvent, WidgetGUIEvent* aGUIEvent,
     *                                  be set.
     * @return                          true if the caller can handle the
     *                                  event.  Otherwise, false.
     */
    MOZ_CAN_RUN_SCRIPT
     * aGUIEvent if Pointer Events is enabled.
    bool ComputeEventTargetFrameAndPresShellAtEventPoint(
        nsIFrame* aRootFrameToHandleEvent, WidgetGUIEvent* aGUIEvent,
        EventTargetData* aEventTargetData);

     *                                  details.
    /**
     * DispatchPrecedingPointerEvent() dispatches preceding pointer event for
     * aGUIEvent if Pointer Events is enabled.
     *
     * @param aFrameForPresShell        The frame for PresShell.  See
     *                                  HandleEvent() which called this method.
     *                                  explanation of HandleEvent() for the
     *                                  details.
     * @param aGUIEvent                 The handled event.
     * @param aPointerCapturingContent  The content which is capturing pointer
     *                                  events if there is.  Otherwise, nullptr.
     * @param aDontRetargetEvents       Set aDontRetargetEvents of
     *                                  HandleEvent() which called this method.
     */
     * @param aEventTargetData          [in/out] Event target data of
     *                                  aGUIEvent.  If pointer event listeners
     *                                  change the DOM tree or reframe the
     *                                  target, updated by this method.
     * @param aEventStatus              [in/out] The event status of aGUIEvent.
                                       bool aDontRetargetEvents,
     * @return                          true if the caller can handle the
     *                                  event.  Otherwise, false.
     */
    MOZ_CAN_RUN_SCRIPT
    bool DispatchPrecedingPointerEvent(nsIFrame* aFrameForPresShell,
     * MaybeDiscardEvent() checks whether it's safe to handle aGUIEvent right
                                       WidgetGUIEvent* aGUIEvent,
                                       nsIContent* aPointerCapturingContent,
                                       bool aDontRetargetEvents,
                                       EventTargetData* aEventTargetData,
                                       nsEventStatus* aEventStatus);
     * @return            true if it's not safe to handle the event.

    /**
     * MaybeDiscardEvent() checks whether it's safe to handle aGUIEvent right
     * now.  If it's not safe, this may notify somebody of discarding event if
     * necessary.
     * GetCapturingContentFor() returns capturing content for aGUIEvent.
     *
     * @param aGUIEvent   Handling event.
     * @return            true if it's not safe to handle the event.
     */
    bool MaybeDiscardEvent(WidgetGUIEvent* aGUIEvent);

    /**
     * GetCapturingContentFor() returns capturing content for aGUIEvent.
     *
     * If aGUIEvent is not related to capturing, this returns nullptr.
     */
    static nsIContent* GetCapturingContentFor(WidgetGUIEvent* aGUIEvent);

    /**
     */
     * GetRetargetEventDocument() returns a document if aGUIEvent should be
     * handled in another document.
     *
     * @param aGUIEvent                 Handling event.
     * @param aRetargetEventDocument    Document which should handle aGUIEvent.
     * GetFrameForHandlingEventWith() returns a frame which should be used as
     * @return                          true if caller can keep handling
     *                                  aGUIEvent.
     */
    bool GetRetargetEventDocument(WidgetGUIEvent* aGUIEvent,
                                  Document** aRetargetEventDocument);
     *                                  fired on.  Typically, should be result

    /**
     * GetFrameForHandlingEventWith() returns a frame which should be used as
     * aFrameForPresShell of HandleEvent().  See @return for the details.
     *
     * @return                          nullptr if caller should stop handling
     * @param aGUIEvent                 Handling event.
     * @param aRetargetDocument         Document which aGUIEvent should be
     *                                  fired on.  Typically, should be result
     *                                  of GetRetargetEventDocument().
     * @param aFrameForPresShell        The frame for PresShell.  See
     *                                  another PresShell which is result of
     *                                  explanation of HandleEvent() for the
     *                                  details.
     * @return                          nullptr if caller should stop handling
    nsIFrame* GetFrameForHandlingEventWith(WidgetGUIEvent* aGUIEvent,
     *                                  the event.
     *                                  aFrameForPresShell if caller should
     *                                  keep handling the event by itself.
     *                                  Otherwise, caller should handle it with
     *                                  another PresShell which is result of
     *                                  nsIFrame::PresContext()->GetPresShell().
     * MaybeHandleEventWithAnotherPresShell() may handle aGUIEvent with another
     */
    nsIFrame* GetFrameForHandlingEventWith(WidgetGUIEvent* aGUIEvent,
                                           Document* aRetargetDocument,
     *                                  explanation of HandleEvent() for the
                                           nsIFrame* aFrameForPresShell);

    /**
     * MaybeHandleEventWithAnotherPresShell() may handle aGUIEvent with another
     * PresShell.
     *                                  error handling the event.
     *
     * @param aFrameForPresShell        The frame for PresShell.  See
     *                                  explanation of HandleEvent() for the
     *                                  details.
     * @param aGUIEvent                 Handling event.
     *                                  can handle the event, this returns true.
     * @param aEventStatus              [in/out] EventStatus of aGUIEvent.
     * @param aRv                       [out] Returns error if this gets an
     *                                  error handling the event.
     * @return                          false if caller needs to keep handling
     *                                  the event by itself.
                                              nsEventStatus* aEventStatus,
     *                                  true if caller shouldn't keep handling
     *                                  the event.  Note that when no PresShell
     *                                  can handle the event, this returns true.
     */
    MOZ_CAN_RUN_SCRIPT
                                   nsEventStatus* aEventStatus);
    bool MaybeHandleEventWithAnotherPresShell(nsIFrame* aFrameForPresShell,
                                              WidgetGUIEvent* aGUIEvent,
                                              nsEventStatus* aEventStatus,
                                              nsresult* aRv);

    MOZ_CAN_RUN_SCRIPT
     * @param aFrameForPresShell The frame for PresShell. See explanation of
    nsresult RetargetEventToParent(WidgetGUIEvent* aGUIEvent,
                                   nsEventStatus* aEventStatus);

    /**
     * MaybeHandleEventWithAccessibleCaret() may handle aGUIEvent with
     *                          event and caller shouldn't keep handling it.
     * AccessibleCaretEventHub if it's necessary.
     *
     * @param aFrameForPresShell The frame for PresShell. See explanation of
     *                           HandleEvent() for the details.
     * @param aGUIEvent         Event may be handled by AccessibleCaretEventHub.
                                             nsEventStatus* aEventStatus);
     * @param aEventStatus      [in/out] EventStatus of aGUIEvent.
     * @return                  true if AccessibleCaretEventHub handled the
     *                          event and caller shouldn't keep handling it.
     */
    MOZ_CAN_RUN_SCRIPT
     * If aGUIEvent is not a keyboard event, this does nothing.
    bool MaybeHandleEventWithAccessibleCaret(nsIFrame* aFrameForPresShell,
                                             WidgetGUIEvent* aGUIEvent,
                                             nsEventStatus* aEventStatus);

    /**
     */
     * MaybeDiscardOrDelayKeyboardEvent() may discared or put aGUIEvent into
     * the delayed event queue if it's a keyboard event and if we should do so.
     * If aGUIEvent is not a keyboard event, this does nothing.
     *
     * @param aGUIEvent         The handling event.
     * @return                  true if this method discard the event or
     * If aGUIEvent is not a mouse event, this does nothing.
     *                          put it into the delayed event queue.
     */
    bool MaybeDiscardOrDelayKeyboardEvent(WidgetGUIEvent* aGUIEvent);

    /**
     * @param aFrameToHandleEvent       The frame to handle aGUIEvent.
     * MaybeDiscardOrDelayMouseEvent() may discard or put aGUIEvent into the
     * delayed event queue if it's a mouse event and if we should do so.
     * If aGUIEvent is not a mouse event, this does nothing.
     * If there is suppressed event listener like debugger of devtools, this
     * notifies it of the event after discard or put it into the delayed
    bool MaybeDiscardOrDelayMouseEvent(nsIFrame* aFrameToHandleEvent,
     * event queue.
     *
     * @param aFrameToHandleEvent       The frame to handle aGUIEvent.
     * @param aGUIEvent                 The handling event.
     * @return                          true if this method discard the event
     * flushed and then aFrameForPresShell is destroyed, returns new frame
     *                                  or put it into the delayed event queue.
     */
    bool MaybeDiscardOrDelayMouseEvent(nsIFrame* aFrameToHandleEvent,
                                       WidgetGUIEvent* aGUIEvent);

     *                                  details.  This can be nullptr.
    /**
     * MaybeFlushThrottledStyles() tries to flush pending animation.  If it's
     * flushed and then aFrameForPresShell is destroyed, returns new frame
     * which contains mPresShell.
     *
     */
     * @param aFrameForPresShell        The frame for PresShell.  See
     *                                  explanation of HandleEvent() for the
     *                                  details.  This can be nullptr.
     * @return                          Maybe new frame for mPresShell.
     *                                  If aFrameForPresShell is not nullptr
     *                                  and hasn't been destroyed, returns
     * For example, if there is a popup, this returns the popup frame.
     *                                  aFrameForPresShell as-is.
     */
    MOZ_CAN_RUN_SCRIPT
    nsIFrame* MaybeFlushThrottledStyles(nsIFrame* aFrameForPresShell);

     *                                          explanation of HandleEvent() for
    /**
     * ComputeRootFrameToHandleEvent() returns root frame to handle the event.
     * For example, if there is a popup, this returns the popup frame.
     * If there is capturing content and it's in a scrolled frame, returns
     * the scrolled frame.
     * @param aIsCapturingContentIgnored        [out] true if aCapturingContent
     *
     * @param aFrameForPresShell                The frame for PresShell.  See
     *                                          explanation of HandleEvent() for
     *                                          the details.
     * @param aGUIEvent                         The handling event.
     *                                          retargeted.
     * @param aCapturingContent                 Capturing content if there is.
     *                                          nullptr, otherwise.
     * @param aIsCapturingContentIgnored        [out] true if aCapturingContent
     *                                          is not nullptr but it should be
     *                                          ignored to handle the event.
                                            nsIContent* aCapturingContent,
     * @param aIsCaptureRetargeted              [out] true if aCapturingContent
     *                                          is not nullptr but it's
     *                                          retargeted.
     * @return                                  Root frame to handle the event.
     */
     * ComputeRootFrameToHandleEventWithPopup() returns popup frame if there
    nsIFrame* ComputeRootFrameToHandleEvent(nsIFrame* aFrameForPresShell,
                                            WidgetGUIEvent* aGUIEvent,
                                            nsIContent* aCapturingContent,
                                            bool* aIsCapturingContentIgnored,
                                            bool* aIsCaptureRetargeted);

    /**
     * @param aCapturingContent                 Capturing content if there is.
     * ComputeRootFrameToHandleEventWithPopup() returns popup frame if there
     * is a popup and we should handle the event in it.  Otherwise, returns
     * aRootFrameToHandleEvent.
     *
     * @param aRootFrameToHandleEvent           Candidate root frame to handle
     *                                          ignored to handle the event.
     *                                          the event.
     * @param aGUIEvent                         The handling event.
     * @param aCapturingContent                 Capturing content if there is.
     *                                          nullptr, otherwise.
     *                                          I.e., never returns nullptr.
     * @param aIsCapturingContentIgnored        [out] true if aCapturingContent
     *                                          is not nullptr but it should be
     *                                          ignored to handle the event.
     * @return                                  A popup frame if there is a
     *                                          popup and we should handle the

     *                                          event in it.  Otherwise,
     *                                          aRootFrameToHandleEvent.
     *                                          I.e., never returns nullptr.
     */
    nsIFrame* ComputeRootFrameToHandleEventWithPopup(
     *
        nsIFrame* aRootFrameToHandleEvent, WidgetGUIEvent* aGUIEvent,
        nsIContent* aCapturingContent, bool* aIsCapturingContentIgnored);

    /**
     * ComputeRootFrameToHandleEventWithCapturingContent() returns root frame
     * @param aIsCapturingContentIgnored        [out] true if aCapturingContent
     * to handle event for the capturing content, or aRootFrameToHandleEvent
     * if it should be ignored.
     *
     * @param aRootFrameToHandleEvent           Candidate root frame to handle
     *                                          the event.
     *                                          is not nullptr but it's
     * @param aCapturingContent                 Capturing content.  nullptr is
     *                                          not allowed.
     * @param aIsCapturingContentIgnored        [out] true if aCapturingContent
     *                                          is not nullptr but it should be
     *                                          aRootFrameToHandleEvent.
     *                                          ignored to handle the event.
     * @param aIsCaptureRetargeted              [out] true if aCapturingContent
     *                                          is not nullptr but it's
     *                                          retargeted.
     * @return                                  A popup frame if there is a
     *                                          popup and we should handle the
        bool* aIsCapturingContentIgnored, bool* aIsCaptureRetargeted);
     *                                          event in it.  Otherwise,
     *                                          aRootFrameToHandleEvent.
     *                                          I.e., never returns nullptr.
     */
    nsIFrame* ComputeRootFrameToHandleEventWithCapturingContent(
     * frame.
        nsIFrame* aRootFrameToHandleEvent, nsIContent* aCapturingContent,
        bool* aIsCapturingContentIgnored, bool* aIsCaptureRetargeted);

    /**
     * HandleEventWithPointerCapturingContentWithoutItsFrame() handles
     * @param aGUIEvent                 The handling event.
     * aGUIEvent with aPointerCapturingContent when it does not have primary
     * frame.
     *
     * @param aFrameForPresShell        The frame for PresShell.  See
     *                                  explanation of HandleEvent() for the
     *                                  HandeEventWithTraget().
     *                                  details.
     * @param aGUIEvent                 The handling event.
     * @param aPointerCapturingContent  Current pointer capturing content.
     *                                  Must not be nullptr.
     * @param aEventStatus              [in/out] The event status of aGUIEvent.
        nsIContent* aPointerCapturingContent, nsEventStatus* aEventStatus);
     * @return                          Basically, result of
     *                                  HandeEventWithTraget().