Skip to content

Commit

Permalink
Align event group constant naming with lane naming (#20744)
Browse files Browse the repository at this point in the history
* Rename ContinuousEvent to DefaultEvent

* Rename UserBlockingEvent to ContinuousEvent
  • Loading branch information
gaearon committed Feb 8, 2021
1 parent bbb2ba8 commit b5bac18
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 39 deletions.
6 changes: 3 additions & 3 deletions packages/react-dom/src/client/ReactDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
flushPassiveEffects,
IsThisRendererActing,
attemptSynchronousHydration,
attemptUserBlockingHydration,
attemptDiscreteHydration,
attemptContinuousHydration,
attemptHydrationAtCurrentPriority,
runWithPriority,
Expand All @@ -56,7 +56,7 @@ import {
import {restoreControlledState} from './ReactDOMComponent';
import {
setAttemptSynchronousHydration,
setAttemptUserBlockingHydration,
setAttemptDiscreteHydration,
setAttemptContinuousHydration,
setAttemptHydrationAtCurrentPriority,
queueExplicitHydrationTarget,
Expand All @@ -71,7 +71,7 @@ import {
} from '../events/ReactDOMControlledComponent';

setAttemptSynchronousHydration(attemptSynchronousHydration);
setAttemptUserBlockingHydration(attemptUserBlockingHydration);
setAttemptDiscreteHydration(attemptDiscreteHydration);
setAttemptContinuousHydration(attemptContinuousHydration);
setAttemptHydrationAtCurrentPriority(attemptHydrationAtCurrentPriority);
setGetCurrentUpdatePriority(getCurrentUpdateLanePriority);
Expand Down
24 changes: 10 additions & 14 deletions packages/react-dom/src/events/DOMEventProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ import {
ANIMATION_START,
TRANSITION_END,
} from './DOMEventNames';
import {
DiscreteEvent,
UserBlockingEvent,
ContinuousEvent,
} from 'shared/ReactTypes';
import {DiscreteEvent, ContinuousEvent, DefaultEvent} from 'shared/ReactTypes';

import {enableCreateEventHandleAPI} from 'shared/ReactFeatureFlags';

Expand Down Expand Up @@ -97,7 +93,7 @@ if (enableCreateEventHandleAPI) {
}

// prettier-ignore
const userBlockingPairsForSimpleEventPlugin: Array<string | DOMEventName> = [
const continuousPairsForSimpleEventPlugin: Array<string | DOMEventName> = [
('drag': DOMEventName), 'drag',
('dragenter': DOMEventName), 'dragEnter',
('dragexit': DOMEventName), 'dragExit',
Expand All @@ -116,7 +112,7 @@ const userBlockingPairsForSimpleEventPlugin: Array<string | DOMEventName> = [
];

// prettier-ignore
const continuousPairsForSimpleEventPlugin: Array<string | DOMEventName> = [
const defaultPairsForSimpleEventPlugin: Array<string | DOMEventName> = [
('abort': DOMEventName), 'abort',
(ANIMATION_END: DOMEventName), 'animationEnd',
(ANIMATION_ITERATION: DOMEventName), 'animationIteration',
Expand Down Expand Up @@ -190,10 +186,10 @@ export function getEventPriorityForPluginSystem(
domEventName: DOMEventName,
): EventPriority {
const priority = eventPriorities.get(domEventName);
// Default to a ContinuousEvent. Note: we might
// Default to a DefaultEvent. Note: we might
// want to warn if we can't detect the priority
// for the event.
return priority === undefined ? ContinuousEvent : priority;
return priority === undefined ? DefaultEvent : priority;
}

export function getEventPriorityForListenerSystem(
Expand All @@ -210,21 +206,21 @@ export function getEventPriorityForListenerSystem(
type,
);
}
return ContinuousEvent;
return DefaultEvent;
}

export function registerSimpleEvents() {
registerSimplePluginEventsAndSetTheirPriorities(
discreteEventPairsForSimpleEventPlugin,
DiscreteEvent,
);
registerSimplePluginEventsAndSetTheirPriorities(
userBlockingPairsForSimpleEventPlugin,
UserBlockingEvent,
);
registerSimplePluginEventsAndSetTheirPriorities(
continuousPairsForSimpleEventPlugin,
ContinuousEvent,
);
registerSimplePluginEventsAndSetTheirPriorities(
defaultPairsForSimpleEventPlugin,
DefaultEvent,
);
setEventPriorities(otherDiscreteEvents, DiscreteEvent);
}
14 changes: 5 additions & 9 deletions packages/react-dom/src/events/ReactDOMEventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ import {
decoupleUpdatePriorityFromScheduler,
enableNewReconciler,
} from 'shared/ReactFeatureFlags';
import {
UserBlockingEvent,
ContinuousEvent,
DiscreteEvent,
} from 'shared/ReactTypes';
import {ContinuousEvent, DefaultEvent, DiscreteEvent} from 'shared/ReactTypes';
import {getEventPriorityForPluginSystem} from './DOMEventProperties';
import {dispatchEventForPluginEventSystem} from './DOMPluginEventSystem';
import {
Expand Down Expand Up @@ -118,10 +114,10 @@ export function createEventListenerWrapperWithPriority(
case DiscreteEvent:
listenerWrapper = dispatchDiscreteEvent;
break;
case UserBlockingEvent:
listenerWrapper = dispatchUserBlockingUpdate;
break;
case ContinuousEvent:
listenerWrapper = dispatchContinuousEvent;
break;
case DefaultEvent:
default:
listenerWrapper = dispatchEvent;
break;
Expand Down Expand Up @@ -157,7 +153,7 @@ function dispatchDiscreteEvent(
);
}

function dispatchUserBlockingUpdate(
function dispatchContinuousEvent(
domEventName,
eventSystemFlags,
container,
Expand Down
8 changes: 4 additions & 4 deletions packages/react-dom/src/events/ReactDOMEventReplaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ export function setAttemptSynchronousHydration(fn: (fiber: Object) => void) {
attemptSynchronousHydration = fn;
}

let attemptUserBlockingHydration: (fiber: Object) => void;
let attemptDiscreteHydration: (fiber: Object) => void;

export function setAttemptUserBlockingHydration(fn: (fiber: Object) => void) {
attemptUserBlockingHydration = fn;
export function setAttemptDiscreteHydration(fn: (fiber: Object) => void) {
attemptDiscreteHydration = fn;
}

let attemptContinuousHydration: (fiber: Object) => void;
Expand Down Expand Up @@ -489,7 +489,7 @@ function replayUnblockedEvents() {
// the next discrete event.
const fiber = getInstanceFromNode(nextDiscreteEvent.blockedOn);
if (fiber !== null) {
attemptUserBlockingHydration(fiber);
attemptDiscreteHydration(fiber);
}
break;
}
Expand Down
10 changes: 5 additions & 5 deletions packages/react-reconciler/src/ReactFiberReconciler.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
IsThisRendererActing as IsThisRendererActing_old,
getPublicRootInstance as getPublicRootInstance_old,
attemptSynchronousHydration as attemptSynchronousHydration_old,
attemptUserBlockingHydration as attemptUserBlockingHydration_old,
attemptDiscreteHydration as attemptDiscreteHydration_old,
attemptContinuousHydration as attemptContinuousHydration_old,
attemptHydrationAtCurrentPriority as attemptHydrationAtCurrentPriority_old,
findHostInstance as findHostInstance_old,
Expand Down Expand Up @@ -69,7 +69,7 @@ import {
IsThisRendererActing as IsThisRendererActing_new,
getPublicRootInstance as getPublicRootInstance_new,
attemptSynchronousHydration as attemptSynchronousHydration_new,
attemptUserBlockingHydration as attemptUserBlockingHydration_new,
attemptDiscreteHydration as attemptDiscreteHydration_new,
attemptContinuousHydration as attemptContinuousHydration_new,
attemptHydrationAtCurrentPriority as attemptHydrationAtCurrentPriority_new,
findHostInstance as findHostInstance_new,
Expand Down Expand Up @@ -134,9 +134,9 @@ export const getPublicRootInstance = enableNewReconciler
export const attemptSynchronousHydration = enableNewReconciler
? attemptSynchronousHydration_new
: attemptSynchronousHydration_old;
export const attemptUserBlockingHydration = enableNewReconciler
? attemptUserBlockingHydration_new
: attemptUserBlockingHydration_old;
export const attemptDiscreteHydration = enableNewReconciler
? attemptDiscreteHydration_new
: attemptDiscreteHydration_old;
export const attemptContinuousHydration = enableNewReconciler
? attemptContinuousHydration_new
: attemptContinuousHydration_old;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberReconciler.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ function markRetryLaneIfNotHydrated(fiber: Fiber, retryLane: Lane) {
}
}

export function attemptUserBlockingHydration(fiber: Fiber): void {
export function attemptDiscreteHydration(fiber: Fiber): void {
if (fiber.tag !== SuspenseComponent) {
// We ignore HostRoots here because we can't increase
// their priority and they should not suspend on I/O,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberReconciler.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ function markRetryLaneIfNotHydrated(fiber: Fiber, retryLane: Lane) {
}
}

export function attemptUserBlockingHydration(fiber: Fiber): void {
export function attemptDiscreteHydration(fiber: Fiber): void {
if (fiber.tag !== SuspenseComponent) {
// We ignore HostRoots here because we can't increase
// their priority and they should not suspend on I/O,
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/ReactTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ export type RefObject = {|
export type EventPriority = 0 | 1 | 2;

export const DiscreteEvent: EventPriority = 0;
export const UserBlockingEvent: EventPriority = 1;
export const ContinuousEvent: EventPriority = 2;
export const ContinuousEvent: EventPriority = 1;
export const DefaultEvent: EventPriority = 2;

export type ReactScope = {|
$$typeof: Symbol | number,
Expand Down

0 comments on commit b5bac18

Please sign in to comment.