| 12957 | } |
| 12958 | |
| 12959 | function addRootToSchedule(root, expirationTime) { |
| 12960 | // Add the root to the schedule. |
| 12961 | // Check if this root is already part of the schedule. |
| 12962 | if (root.nextScheduledRoot === null) { |
| 12963 | // This root is not already scheduled. Add it. |
| 12964 | root.remainingExpirationTime = expirationTime; |
| 12965 | if (lastScheduledRoot === null) { |
| 12966 | firstScheduledRoot = lastScheduledRoot = root; |
| 12967 | root.nextScheduledRoot = root; |
| 12968 | } else { |
| 12969 | lastScheduledRoot.nextScheduledRoot = root; |
| 12970 | lastScheduledRoot = root; |
| 12971 | lastScheduledRoot.nextScheduledRoot = firstScheduledRoot; |
| 12972 | } |
| 12973 | } else { |
| 12974 | // This root is already scheduled, but its priority may have increased. |
| 12975 | var remainingExpirationTime = root.remainingExpirationTime; |
| 12976 | if (remainingExpirationTime === NoWork || expirationTime < remainingExpirationTime) { |
| 12977 | // Update the priority. |
| 12978 | root.remainingExpirationTime = expirationTime; |
| 12979 | } |
| 12980 | } |
| 12981 | } |
| 12982 | |
| 12983 | function findHighestPriorityRoot() { |
| 12984 | var highestPriorityWork = NoWork; |