Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move scheduler priority check into ReactDOM #20778

Merged
merged 2 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/react-dom/src/events/DOMEventNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export type DOMEventName =
| 'loadeddata'
| 'loadedmetadata'
| 'lostpointercapture'
| 'message'
| 'mousedown'
| 'mouseenter'
| 'mouseleave'
Expand Down
17 changes: 17 additions & 0 deletions packages/react-dom/src/events/ReactDOMEventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,18 @@ import {
DefaultLanePriority as DefaultLanePriority_old,
getCurrentUpdateLanePriority as getCurrentUpdateLanePriority_old,
setCurrentUpdateLanePriority as setCurrentUpdateLanePriority_old,
schedulerPriorityToLanePriority as schedulerPriorityToLanePriority_old,
} from 'react-reconciler/src/ReactFiberLane.old';
import {
InputDiscreteLanePriority as InputDiscreteLanePriority_new,
InputContinuousLanePriority as InputContinuousLanePriority_new,
DefaultLanePriority as DefaultLanePriority_new,
getCurrentUpdateLanePriority as getCurrentUpdateLanePriority_new,
setCurrentUpdateLanePriority as setCurrentUpdateLanePriority_new,
schedulerPriorityToLanePriority as schedulerPriorityToLanePriority_new,
} from 'react-reconciler/src/ReactFiberLane.new';
import {getCurrentPriorityLevel as getCurrentPriorityLevel_old} from 'react-reconciler/src/SchedulerWithReactIntegration.old';
import {getCurrentPriorityLevel as getCurrentPriorityLevel_new} from 'react-reconciler/src/SchedulerWithReactIntegration.new';

const InputDiscreteLanePriority = enableNewReconciler
? InputDiscreteLanePriority_new
Expand All @@ -79,6 +83,12 @@ const getCurrentUpdateLanePriority = enableNewReconciler
const setCurrentUpdateLanePriority = enableNewReconciler
? setCurrentUpdateLanePriority_new
: setCurrentUpdateLanePriority_old;
const schedulerPriorityToLanePriority = enableNewReconciler
? schedulerPriorityToLanePriority_new
: schedulerPriorityToLanePriority_old;
const getCurrentPriorityLevel = enableNewReconciler
? getCurrentPriorityLevel_new
: getCurrentPriorityLevel_old;

const {
unstable_UserBlockingPriority: UserBlockingPriority,
Expand Down Expand Up @@ -428,6 +438,13 @@ export function getEventPriority(domEventName: DOMEventName): * {
case 'mouseenter':
case 'mouseleave':
return InputContinuousLanePriority;
case 'message': {
// We might be in the Scheduler callback.
// Eventually this mechanism will be replaced by a check
// of the current priority on the native scheduler.
const schedulerPriority = getCurrentPriorityLevel();
return schedulerPriorityToLanePriority(schedulerPriority);
gaearon marked this conversation as resolved.
Show resolved Hide resolved
}
default:
return DefaultLanePriority;
}
Expand Down
10 changes: 1 addition & 9 deletions packages/react-reconciler/src/ReactFiberWorkLoop.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,15 +465,7 @@ export function requestUpdateLane(fiber: Fiber): Lane {
} else {
if (enableNativeEventPriorityInference) {
const eventLanePriority = getCurrentEventPriority();
if (eventLanePriority === DefaultLanePriority) {
// TODO: move this case into the ReactDOM host config.
const schedulerLanePriority = schedulerPriorityToLanePriority(
schedulerPriority,
);
lane = findUpdateLane(schedulerLanePriority, currentEventWipLanes);
} else {
lane = findUpdateLane(eventLanePriority, currentEventWipLanes);
}
lane = findUpdateLane(eventLanePriority, currentEventWipLanes);
} else {
const schedulerLanePriority = schedulerPriorityToLanePriority(
schedulerPriority,
Expand Down