| 13668 | } |
| 13669 | |
| 13670 | function addRootToSchedule(root, expirationTime) { |
| 13671 | // Add the root to the schedule. |
| 13672 | // Check if this root is already part of the schedule. |
| 13673 | if (root.nextScheduledRoot === null) { |
| 13674 | // This root is not already scheduled. Add it. |
| 13675 | root.remainingExpirationTime = expirationTime; |
| 13676 | if (lastScheduledRoot === null) { |
| 13677 | firstScheduledRoot = lastScheduledRoot = root; |
| 13678 | root.nextScheduledRoot = root; |
| 13679 | } else { |
| 13680 | lastScheduledRoot.nextScheduledRoot = root; |
| 13681 | lastScheduledRoot = root; |
| 13682 | lastScheduledRoot.nextScheduledRoot = firstScheduledRoot; |
| 13683 | } |
| 13684 | } else { |
| 13685 | // This root is already scheduled, but its priority may have increased. |
| 13686 | var remainingExpirationTime = root.remainingExpirationTime; |
| 13687 | if (remainingExpirationTime === NoWork || expirationTime < remainingExpirationTime) { |
| 13688 | // Update the priority. |
| 13689 | root.remainingExpirationTime = expirationTime; |
| 13690 | } |
| 13691 | } |
| 13692 | } |
| 13693 | |
| 13694 | function findHighestPriorityRoot() { |
| 13695 | var highestPriorityWork = NoWork; |