| 13884 | } |
| 13885 | |
| 13886 | function addRootToSchedule(root, expirationTime) { |
| 13887 | // Add the root to the schedule. |
| 13888 | // Check if this root is already part of the schedule. |
| 13889 | if (root.nextScheduledRoot === null) { |
| 13890 | // This root is not already scheduled. Add it. |
| 13891 | root.remainingExpirationTime = expirationTime; |
| 13892 | if (lastScheduledRoot === null) { |
| 13893 | firstScheduledRoot = lastScheduledRoot = root; |
| 13894 | root.nextScheduledRoot = root; |
| 13895 | } else { |
| 13896 | lastScheduledRoot.nextScheduledRoot = root; |
| 13897 | lastScheduledRoot = root; |
| 13898 | lastScheduledRoot.nextScheduledRoot = firstScheduledRoot; |
| 13899 | } |
| 13900 | } else { |
| 13901 | // This root is already scheduled, but its priority may have increased. |
| 13902 | var remainingExpirationTime = root.remainingExpirationTime; |
| 13903 | if (remainingExpirationTime === NoWork || expirationTime < remainingExpirationTime) { |
| 13904 | // Update the priority. |
| 13905 | root.remainingExpirationTime = expirationTime; |
| 13906 | } |
| 13907 | } |
| 13908 | } |
| 13909 | |
| 13910 | function findHighestPriorityRoot() { |
| 13911 | var highestPriorityWork = NoWork; |