Skip to content

Commit

Permalink
internalContextTag -> mode
Browse files Browse the repository at this point in the history
Change this now that we have a better name
  • Loading branch information
acdlite committed Jan 30, 2018
1 parent 3757ab6 commit 891d696
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 54 deletions.
24 changes: 12 additions & 12 deletions packages/react-reconciler/src/ReactChildFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ function ChildReconciler(shouldTrackSideEffects) {
// Insert
const created = createFiberFromText(
textContent,
returnFiber.internalContextTag,
returnFiber.mode,
expirationTime,
);
created.return = returnFiber;
Expand Down Expand Up @@ -351,7 +351,7 @@ function ChildReconciler(shouldTrackSideEffects) {
// Insert
const created = createFiberFromElement(
element,
returnFiber.internalContextTag,
returnFiber.mode,
expirationTime,
);
created.ref = coerceRef(current, element);
Expand All @@ -375,7 +375,7 @@ function ChildReconciler(shouldTrackSideEffects) {
// Insert
const created = createFiberFromPortal(
portal,
returnFiber.internalContextTag,
returnFiber.mode,
expirationTime,
);
created.return = returnFiber;
Expand All @@ -399,7 +399,7 @@ function ChildReconciler(shouldTrackSideEffects) {
// Insert
const created = createFiberFromFragment(
fragment,
returnFiber.internalContextTag,
returnFiber.mode,
expirationTime,
key,
);
Expand All @@ -424,7 +424,7 @@ function ChildReconciler(shouldTrackSideEffects) {
// node.
const created = createFiberFromText(
'' + newChild,
returnFiber.internalContextTag,
returnFiber.mode,
expirationTime,
);
created.return = returnFiber;
Expand All @@ -436,7 +436,7 @@ function ChildReconciler(shouldTrackSideEffects) {
case REACT_ELEMENT_TYPE: {
const created = createFiberFromElement(
newChild,
returnFiber.internalContextTag,
returnFiber.mode,
expirationTime,
);
created.ref = coerceRef(null, newChild);
Expand All @@ -446,7 +446,7 @@ function ChildReconciler(shouldTrackSideEffects) {
case REACT_PORTAL_TYPE: {
const created = createFiberFromPortal(
newChild,
returnFiber.internalContextTag,
returnFiber.mode,
expirationTime,
);
created.return = returnFiber;
Expand All @@ -457,7 +457,7 @@ function ChildReconciler(shouldTrackSideEffects) {
if (isArray(newChild) || getIteratorFn(newChild)) {
const created = createFiberFromFragment(
newChild,
returnFiber.internalContextTag,
returnFiber.mode,
expirationTime,
null,
);
Expand Down Expand Up @@ -1045,7 +1045,7 @@ function ChildReconciler(shouldTrackSideEffects) {
deleteRemainingChildren(returnFiber, currentFirstChild);
const created = createFiberFromText(
textContent,
returnFiber.internalContextTag,
returnFiber.mode,
expirationTime,
);
created.return = returnFiber;
Expand Down Expand Up @@ -1097,7 +1097,7 @@ function ChildReconciler(shouldTrackSideEffects) {
if (element.type === REACT_FRAGMENT_TYPE) {
const created = createFiberFromFragment(
element.props.children,
returnFiber.internalContextTag,
returnFiber.mode,
expirationTime,
element.key,
);
Expand All @@ -1106,7 +1106,7 @@ function ChildReconciler(shouldTrackSideEffects) {
} else {
const created = createFiberFromElement(
element,
returnFiber.internalContextTag,
returnFiber.mode,
expirationTime,
);
created.ref = coerceRef(currentFirstChild, element);
Expand Down Expand Up @@ -1152,7 +1152,7 @@ function ChildReconciler(shouldTrackSideEffects) {

const created = createFiberFromPortal(
portal,
returnFiber.internalContextTag,
returnFiber.mode,
expirationTime,
);
created.return = returnFiber;
Expand Down
49 changes: 22 additions & 27 deletions packages/react-reconciler/src/ReactFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import type {ReactElement, Source} from 'shared/ReactElementType';
import type {ReactPortal} from 'shared/ReactTypes';
import type {TypeOfWork} from 'shared/ReactTypeOfWork';
import type {TypeOfInternalContext} from './ReactTypeOfInternalContext';
import type {TypeOfMode} from './ReactTypeOfMode';
import type {TypeOfSideEffect} from 'shared/ReactTypeOfSideEffect';
import type {ExpirationTime} from './ReactFiberExpirationTime';
import type {UpdateQueue} from './ReactFiberUpdateQueue';
Expand All @@ -33,7 +33,7 @@ import {
import getComponentName from 'shared/getComponentName';

import {NoWork} from './ReactFiberExpirationTime';
import {NoContext, AsyncMode, StrictMode} from './ReactTypeOfInternalContext';
import {NoContext, AsyncMode, StrictMode} from './ReactTypeOfMode';
import {
REACT_FRAGMENT_TYPE,
REACT_RETURN_TYPE,
Expand Down Expand Up @@ -121,11 +121,11 @@ export type Fiber = {|

// Bitfield that describes properties about the fiber and its subtree. E.g.
// the AsyncMode flag indicates whether the subtree should be async-by-
// default. When a fiber is created, it inherits the internalContextTag of its
// default. When a fiber is created, it inherits the mode of its
// parent. Additional flags can be set at creation time, but after than the
// value should remain unchanged throughout the fiber's lifetime, particularly
// before its child fibers are created.
internalContextTag: TypeOfInternalContext,
mode: TypeOfMode,

// Effect
effectTag: TypeOfSideEffect,
Expand Down Expand Up @@ -168,7 +168,7 @@ function FiberNode(
tag: TypeOfWork,
pendingProps: mixed,
key: null | string,
internalContextTag: TypeOfInternalContext,
mode: TypeOfMode,
) {
// Instance
this.tag = tag;
Expand All @@ -189,7 +189,7 @@ function FiberNode(
this.updateQueue = null;
this.memoizedState = null;

this.internalContextTag = internalContextTag;
this.mode = mode;

// Effects
this.effectTag = NoEffect;
Expand Down Expand Up @@ -230,10 +230,10 @@ const createFiber = function(
tag: TypeOfWork,
pendingProps: mixed,
key: null | string,
internalContextTag: TypeOfInternalContext,
mode: TypeOfMode,
): Fiber {
// $FlowFixMe: the shapes are exact here but Flow doesn't like constructors
return new FiberNode(tag, pendingProps, key, internalContextTag);
return new FiberNode(tag, pendingProps, key, mode);
};

function shouldConstruct(Component) {
Expand All @@ -257,7 +257,7 @@ export function createWorkInProgress(
current.tag,
pendingProps,
current.key,
current.internalContextTag,
current.mode,
);
workInProgress.type = current.type;
workInProgress.stateNode = current.stateNode;
Expand Down Expand Up @@ -300,13 +300,13 @@ export function createWorkInProgress(
}

export function createHostRootFiber(isAsync): Fiber {
const internalContextTag = isAsync ? AsyncMode | StrictMode : NoContext;
return createFiber(HostRoot, null, null, internalContextTag);
const mode = isAsync ? AsyncMode | StrictMode : NoContext;
return createFiber(HostRoot, null, null, mode);
}

export function createFiberFromElement(
element: ReactElement,
internalContextTag: TypeOfInternalContext,
mode: TypeOfMode,
expirationTime: ExpirationTime,
): Fiber {
let owner = null;
Expand All @@ -329,17 +329,17 @@ export function createFiberFromElement(
case REACT_FRAGMENT_TYPE:
return createFiberFromFragment(
pendingProps.children,
internalContextTag,
mode,
expirationTime,
key,
);
case REACT_ASYNC_MODE_TYPE:
fiberTag = Mode;
internalContextTag |= AsyncMode | StrictMode;
mode |= AsyncMode | StrictMode;
break;
case REACT_STRICT_MODE_TYPE:
fiberTag = Mode;
internalContextTag |= StrictMode;
mode |= StrictMode;
break;
case REACT_CALL_TYPE:
fiberTag = CallComponent;
Expand Down Expand Up @@ -383,7 +383,7 @@ export function createFiberFromElement(
}
}

fiber = createFiber(fiberTag, pendingProps, key, internalContextTag);
fiber = createFiber(fiberTag, pendingProps, key, mode);
fiber.type = type;
fiber.expirationTime = expirationTime;

Expand Down Expand Up @@ -426,21 +426,21 @@ function throwOnInvalidElementType(type, owner) {

export function createFiberFromFragment(
elements: ReactFragment,
internalContextTag: TypeOfInternalContext,
mode: TypeOfMode,
expirationTime: ExpirationTime,
key: null | string,
): Fiber {
const fiber = createFiber(Fragment, elements, key, internalContextTag);
const fiber = createFiber(Fragment, elements, key, mode);
fiber.expirationTime = expirationTime;
return fiber;
}

export function createFiberFromText(
content: string,
internalContextTag: TypeOfInternalContext,
mode: TypeOfMode,
expirationTime: ExpirationTime,
): Fiber {
const fiber = createFiber(HostText, content, null, internalContextTag);
const fiber = createFiber(HostText, content, null, mode);
fiber.expirationTime = expirationTime;
return fiber;
}
Expand All @@ -453,16 +453,11 @@ export function createFiberFromHostInstanceForDeletion(): Fiber {

export function createFiberFromPortal(
portal: ReactPortal,
internalContextTag: TypeOfInternalContext,
mode: TypeOfMode,
expirationTime: ExpirationTime,
): Fiber {
const pendingProps = portal.children !== null ? portal.children : [];
const fiber = createFiber(
HostPortal,
pendingProps,
portal.key,
internalContextTag,
);
const fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
fiber.expirationTime = expirationTime;
fiber.stateNode = {
containerInfo: portal.containerInfo,
Expand Down
8 changes: 4 additions & 4 deletions packages/react-reconciler/src/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import {
} from './ReactFiberContext';
import {pushProvider} from './ReactFiberNewContext';
import {NoWork, Never} from './ReactFiberExpirationTime';
import {AsyncMode, StrictMode} from './ReactTypeOfInternalContext';
import {AsyncMode, StrictMode} from './ReactTypeOfMode';
import MAX_SIGNED_31_BIT_INT from './maxSigned31BitInt';

let didWarnAboutBadClass;
Expand Down Expand Up @@ -293,7 +293,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
if (
debugRenderPhaseSideEffects ||
(debugRenderPhaseSideEffectsForStrictMode &&
workInProgress.internalContextTag & StrictMode)
workInProgress.mode & StrictMode)
) {
instance.render();
}
Expand All @@ -302,7 +302,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
if (
debugRenderPhaseSideEffects ||
(debugRenderPhaseSideEffectsForStrictMode &&
workInProgress.internalContextTag & StrictMode)
workInProgress.mode & StrictMode)
) {
instance.render();
}
Expand Down Expand Up @@ -438,7 +438,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
// Check the host config to see if the children are offscreen/hidden.
if (
renderExpirationTime !== Never &&
workInProgress.internalContextTag & AsyncMode &&
workInProgress.mode & AsyncMode &&
shouldDeprioritizeSubtree(type, nextProps)
) {
// Down-prioritize the children.
Expand Down
8 changes: 4 additions & 4 deletions packages/react-reconciler/src/ReactFiberClassComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import invariant from 'fbjs/lib/invariant';
import warning from 'fbjs/lib/warning';

import {startPhaseTimer, stopPhaseTimer} from './ReactDebugFiberPerf';
import {StrictMode} from './ReactTypeOfInternalContext';
import {StrictMode} from './ReactTypeOfMode';
import {
cacheContext,
getMaskedContext,
Expand Down Expand Up @@ -394,7 +394,7 @@ export default function(
if (
debugRenderPhaseSideEffects ||
(debugRenderPhaseSideEffectsForStrictMode &&
workInProgress.internalContextTag & StrictMode)
workInProgress.mode & StrictMode)
) {
new ctor(props, context); // eslint-disable-line no-new
}
Expand Down Expand Up @@ -547,7 +547,7 @@ export default function(
if (
debugRenderPhaseSideEffects ||
(debugRenderPhaseSideEffectsForStrictMode &&
workInProgress.internalContextTag & StrictMode)
workInProgress.mode & StrictMode)
) {
// Invoke method an extra time to help detect side-effects.
type.getDerivedStateFromProps.call(
Expand Down Expand Up @@ -607,7 +607,7 @@ export default function(
}

if (__DEV__) {
if (workInProgress.internalContextTag & StrictMode) {
if (workInProgress.mode & StrictMode) {
ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(
workInProgress,
instance,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ import {
expirationTimeToMs,
computeExpirationBucket,
} from './ReactFiberExpirationTime';
import {AsyncMode} from './ReactTypeOfInternalContext';
import {AsyncMode} from './ReactTypeOfMode';
import {getUpdateExpirationTime} from './ReactFiberUpdateQueue';
import {resetContext as resetLegacyContext} from './ReactFiberContext';
import {resetProviderStack} from './ReactFiberNewContext';
Expand Down Expand Up @@ -1200,7 +1200,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
} else {
// No explicit expiration context was set, and we're not currently
// performing work. Calculate a new expiration time.
if (fiber.internalContextTag & AsyncMode) {
if (fiber.mode & AsyncMode) {
// This is an async update
expirationTime = computeAsyncExpiration();
} else {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberUpdateQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {Callback as CallbackEffect} from 'shared/ReactTypeOfSideEffect';
import {ClassComponent, HostRoot} from 'shared/ReactTypeOfWork';
import invariant from 'fbjs/lib/invariant';
import warning from 'fbjs/lib/warning';
import {StrictMode} from './ReactTypeOfInternalContext';
import {StrictMode} from './ReactTypeOfMode';

import {NoWork} from './ReactFiberExpirationTime';

Expand Down Expand Up @@ -278,7 +278,7 @@ export function processUpdateQueue<State>(
if (
debugRenderPhaseSideEffects ||
(debugRenderPhaseSideEffectsForStrictMode &&
workInProgress.internalContextTag & StrictMode)
workInProgress.mode & StrictMode)
) {
getStateFromUpdate(update, instance, state, props);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactStrictModeWarnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {Fiber} from './ReactFiber';

import getComponentName from 'shared/getComponentName';
import {getStackAddendumByWorkInProgressFiber} from 'shared/ReactFiberComponentTreeHook';
import {StrictMode} from './ReactTypeOfInternalContext';
import {StrictMode} from './ReactTypeOfMode';
import warning from 'fbjs/lib/warning';

type LIFECYCLE =
Expand Down Expand Up @@ -104,7 +104,7 @@ if (__DEV__) {
let maybeStrictRoot = null;

while (fiber !== null) {
if (fiber.internalContextTag & StrictMode) {
if (fiber.mode & StrictMode) {
maybeStrictRoot = fiber;
}

Expand Down

0 comments on commit 891d696

Please sign in to comment.