(root)
| 25032 | |
| 25033 | |
| 25034 | function ensureRootIsScheduled(root) { |
| 25035 | var lastExpiredTime = root.lastExpiredTime; |
| 25036 | |
| 25037 | if (lastExpiredTime !== NoWork) { |
| 25038 | // Special case: Expired work should flush synchronously. |
| 25039 | root.callbackExpirationTime = Sync; |
| 25040 | root.callbackPriority = ImmediatePriority; |
| 25041 | root.callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); |
| 25042 | return; |
| 25043 | } |
| 25044 | |
| 25045 | var expirationTime = getNextRootExpirationTimeToWorkOn(root); |
| 25046 | var existingCallbackNode = root.callbackNode; |
| 25047 | |
| 25048 | if (expirationTime === NoWork) { |
| 25049 | // There's nothing to work on. |
| 25050 | if (existingCallbackNode !== null) { |
| 25051 | root.callbackNode = null; |
| 25052 | root.callbackExpirationTime = NoWork; |
| 25053 | root.callbackPriority = NoPriority; |
| 25054 | } |
| 25055 | |
| 25056 | return; |
| 25057 | } // TODO: If this is an update, we already read the current time. Pass the |
| 25058 | // time as an argument. |
| 25059 | |
| 25060 | |
| 25061 | var currentTime = requestCurrentTimeForUpdate(); |
| 25062 | var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime); // If there's an existing render task, confirm it has the correct priority and |
| 25063 | // expiration time. Otherwise, we'll cancel it and schedule a new one. |
| 25064 | |
| 25065 | if (existingCallbackNode !== null) { |
| 25066 | var existingCallbackPriority = root.callbackPriority; |
| 25067 | var existingCallbackExpirationTime = root.callbackExpirationTime; |
| 25068 | |
| 25069 | if ( // Callback must have the exact same expiration time. |
| 25070 | existingCallbackExpirationTime === expirationTime && // Callback must have greater or equal priority. |
| 25071 | existingCallbackPriority >= priorityLevel) { |
| 25072 | // Existing callback is sufficient. |
| 25073 | return; |
| 25074 | } // Need to schedule a new task. |
| 25075 | // TODO: Instead of scheduling a new task, we should be able to change the |
| 25076 | // priority of the existing one. |
| 25077 | |
| 25078 | |
| 25079 | cancelCallback(existingCallbackNode); |
| 25080 | } |
| 25081 | |
| 25082 | root.callbackExpirationTime = expirationTime; |
| 25083 | root.callbackPriority = priorityLevel; |
| 25084 | var callbackNode; |
| 25085 | |
| 25086 | if (expirationTime === Sync) { |
| 25087 | // Sync React callbacks are scheduled on a special internal queue |
| 25088 | callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); |
| 25089 | } else { |
| 25090 | callbackNode = scheduleCallback(priorityLevel, performConcurrentWorkOnRoot.bind(null, root), // Compute a task timeout based on the expiration time. This also affects |
| 25091 | // ordering because tasks are processed in timeout order. |
no test coverage detected