| 12866 | } |
| 12867 | |
| 12868 | function addRootToSchedule(root, expirationTime) { |
| 12869 | // Add the root to the schedule. |
| 12870 | // Check if this root is already part of the schedule. |
| 12871 | if (root.nextScheduledRoot === null) { |
| 12872 | // This root is not already scheduled. Add it. |
| 12873 | root.remainingExpirationTime = expirationTime; |
| 12874 | if (lastScheduledRoot === null) { |
| 12875 | firstScheduledRoot = lastScheduledRoot = root; |
| 12876 | root.nextScheduledRoot = root; |
| 12877 | } else { |
| 12878 | lastScheduledRoot.nextScheduledRoot = root; |
| 12879 | lastScheduledRoot = root; |
| 12880 | lastScheduledRoot.nextScheduledRoot = firstScheduledRoot; |
| 12881 | } |
| 12882 | } else { |
| 12883 | // This root is already scheduled, but its priority may have increased. |
| 12884 | var remainingExpirationTime = root.remainingExpirationTime; |
| 12885 | if (remainingExpirationTime === NoWork || expirationTime < remainingExpirationTime) { |
| 12886 | // Update the priority. |
| 12887 | root.remainingExpirationTime = expirationTime; |
| 12888 | } |
| 12889 | } |
| 12890 | } |
| 12891 | |
| 12892 | function findHighestPriorityRoot() { |
| 12893 | var highestPriorityWork = NoWork; |