Skip to content

Commit

Permalink
Move schedulerPriorityToLanePriority
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Mar 8, 2021
1 parent 3b739ec commit 494538b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 45 deletions.
42 changes: 35 additions & 7 deletions packages/react-dom/src/events/ReactDOMEventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
*/

import type {AnyNativeEvent} from '../events/PluginModuleType';
import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
import type {
FiberRoot,
ReactPriorityLevel,
} from 'react-reconciler/src/ReactInternalTypes';
import type {Container, SuspenseInstance} from '../client/ReactDOMHostConfig';
import type {DOMEventName} from '../events/DOMEventNames';

Expand Down Expand Up @@ -50,18 +53,27 @@ 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,
SyncLanePriority,
IdleLanePriority,
NoLanePriority,
} 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';
import {
getCurrentPriorityLevel as getCurrentPriorityLevel_new,
IdlePriority as IdleSchedulerPriority,
ImmediatePriority as ImmediateSchedulerPriority,
LowPriority as LowSchedulerPriority,
NormalPriority as NormalSchedulerPriority,
UserBlockingPriority as UserBlockingSchedulerPriority,
} from 'react-reconciler/src/SchedulerWithReactIntegration.new';
import type {LanePriority} from 'react-reconciler/src/ReactFiberLane.new';

const InputDiscreteLanePriority = enableNewReconciler
? InputDiscreteLanePriority_new
Expand All @@ -78,13 +90,29 @@ const getCurrentUpdateLanePriority = enableNewReconciler
const setCurrentUpdateLanePriority = enableNewReconciler
? setCurrentUpdateLanePriority_new
: setCurrentUpdateLanePriority_old;
const schedulerPriorityToLanePriority = enableNewReconciler
? schedulerPriorityToLanePriority_new
: schedulerPriorityToLanePriority_old;
const getCurrentPriorityLevel = enableNewReconciler
? getCurrentPriorityLevel_new
: getCurrentPriorityLevel_old;

function schedulerPriorityToLanePriority(
schedulerPriorityLevel: ReactPriorityLevel,
): LanePriority {
switch (schedulerPriorityLevel) {
case ImmediateSchedulerPriority:
return SyncLanePriority;
case UserBlockingSchedulerPriority:
return InputContinuousLanePriority;
case NormalSchedulerPriority:
case LowSchedulerPriority:
// TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration.
return DefaultLanePriority;
case IdleSchedulerPriority:
return IdleLanePriority;
default:
return NoLanePriority;
}
}

// TODO: can we stop exporting these?
export let _enabled = true;

Expand Down
19 changes: 0 additions & 19 deletions packages/react-reconciler/src/ReactFiberLane.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,25 +275,6 @@ function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
}
}

export function schedulerPriorityToLanePriority(
schedulerPriorityLevel: ReactPriorityLevel,
): LanePriority {
switch (schedulerPriorityLevel) {
case ImmediateSchedulerPriority:
return SyncLanePriority;
case UserBlockingSchedulerPriority:
return InputContinuousLanePriority;
case NormalSchedulerPriority:
case LowSchedulerPriority:
// TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration.
return DefaultLanePriority;
case IdleSchedulerPriority:
return IdleLanePriority;
default:
return NoLanePriority;
}
}

export function lanePriorityToSchedulerPriority(
lanePriority: LanePriority,
): ReactPriorityLevel {
Expand Down
19 changes: 0 additions & 19 deletions packages/react-reconciler/src/ReactFiberLane.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,25 +275,6 @@ function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
}
}

export function schedulerPriorityToLanePriority(
schedulerPriorityLevel: ReactPriorityLevel,
): LanePriority {
switch (schedulerPriorityLevel) {
case ImmediateSchedulerPriority:
return SyncLanePriority;
case UserBlockingSchedulerPriority:
return InputContinuousLanePriority;
case NormalSchedulerPriority:
case LowSchedulerPriority:
// TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration.
return DefaultLanePriority;
case IdleSchedulerPriority:
return IdleLanePriority;
default:
return NoLanePriority;
}
}

export function lanePriorityToSchedulerPriority(
lanePriority: LanePriority,
): ReactPriorityLevel {
Expand Down

0 comments on commit 494538b

Please sign in to comment.