| 12994 | } |
| 12995 | |
| 12996 | function addRootToSchedule(root, expirationTime) { |
| 12997 | // Add the root to the schedule. |
| 12998 | // Check if this root is already part of the schedule. |
| 12999 | if (root.nextScheduledRoot === null) { |
| 13000 | // This root is not already scheduled. Add it. |
| 13001 | root.remainingExpirationTime = expirationTime; |
| 13002 | if (lastScheduledRoot === null) { |
| 13003 | firstScheduledRoot = lastScheduledRoot = root; |
| 13004 | root.nextScheduledRoot = root; |
| 13005 | } else { |
| 13006 | lastScheduledRoot.nextScheduledRoot = root; |
| 13007 | lastScheduledRoot = root; |
| 13008 | lastScheduledRoot.nextScheduledRoot = firstScheduledRoot; |
| 13009 | } |
| 13010 | } else { |
| 13011 | // This root is already scheduled, but its priority may have increased. |
| 13012 | var remainingExpirationTime = root.remainingExpirationTime; |
| 13013 | if (remainingExpirationTime === NoWork || expirationTime < remainingExpirationTime) { |
| 13014 | // Update the priority. |
| 13015 | root.remainingExpirationTime = expirationTime; |
| 13016 | } |
| 13017 | } |
| 13018 | } |
| 13019 | |
| 13020 | function findHighestPriorityRoot() { |
| 13021 | var highestPriorityWork = NoWork; |