| 13771 | } |
| 13772 | |
| 13773 | function addRootToSchedule(root, expirationTime) { |
| 13774 | // Add the root to the schedule. |
| 13775 | // Check if this root is already part of the schedule. |
| 13776 | if (root.nextScheduledRoot === null) { |
| 13777 | // This root is not already scheduled. Add it. |
| 13778 | root.remainingExpirationTime = expirationTime; |
| 13779 | if (lastScheduledRoot === null) { |
| 13780 | firstScheduledRoot = lastScheduledRoot = root; |
| 13781 | root.nextScheduledRoot = root; |
| 13782 | } else { |
| 13783 | lastScheduledRoot.nextScheduledRoot = root; |
| 13784 | lastScheduledRoot = root; |
| 13785 | lastScheduledRoot.nextScheduledRoot = firstScheduledRoot; |
| 13786 | } |
| 13787 | } else { |
| 13788 | // This root is already scheduled, but its priority may have increased. |
| 13789 | var remainingExpirationTime = root.remainingExpirationTime; |
| 13790 | if (remainingExpirationTime === NoWork || expirationTime < remainingExpirationTime) { |
| 13791 | // Update the priority. |
| 13792 | root.remainingExpirationTime = expirationTime; |
| 13793 | } |
| 13794 | } |
| 13795 | } |
| 13796 | |
| 13797 | function findHighestPriorityRoot() { |
| 13798 | var highestPriorityWork = NoWork; |