| 13506 | } |
| 13507 | |
| 13508 | function addRootToSchedule(root, expirationTime) { |
| 13509 | // Add the root to the schedule. |
| 13510 | // Check if this root is already part of the schedule. |
| 13511 | if (root.nextScheduledRoot === null) { |
| 13512 | // This root is not already scheduled. Add it. |
| 13513 | root.remainingExpirationTime = expirationTime; |
| 13514 | if (lastScheduledRoot === null) { |
| 13515 | firstScheduledRoot = lastScheduledRoot = root; |
| 13516 | root.nextScheduledRoot = root; |
| 13517 | } else { |
| 13518 | lastScheduledRoot.nextScheduledRoot = root; |
| 13519 | lastScheduledRoot = root; |
| 13520 | lastScheduledRoot.nextScheduledRoot = firstScheduledRoot; |
| 13521 | } |
| 13522 | } else { |
| 13523 | // This root is already scheduled, but its priority may have increased. |
| 13524 | var remainingExpirationTime = root.remainingExpirationTime; |
| 13525 | if (remainingExpirationTime === NoWork || expirationTime < remainingExpirationTime) { |
| 13526 | // Update the priority. |
| 13527 | root.remainingExpirationTime = expirationTime; |
| 13528 | } |
| 13529 | } |
| 13530 | } |
| 13531 | |
| 13532 | function findHighestPriorityRoot() { |
| 13533 | var highestPriorityWork = NoWork; |