React sync for revisions 1c2876d...7a3416f

Reviewed By: bvaughn

Differential Revision: D7526137

fbshipit-source-id: 9f9db8a6b56cb4ae581a7b8d28079ec38de2180f
This commit is contained in:
Héctor Ramos 2018-04-05 17:33:08 -07:00 committed by Facebook Github Bot
parent 9b9b6c845e
commit 445b0c7080
5 changed files with 326 additions and 296 deletions

View File

@ -1 +1 @@
1c2876d5b558b8591feb335d8d7204bc46f7da8a
7a3416f27532ac25849dfbc505300d469b43bbcc

View File

@ -4765,6 +4765,14 @@ var ReactStrictModeWarnings = {
var didWarnAboutDeprecatedLifecycles = new Set();
var didWarnAboutUnsafeLifecycles = new Set();
var setToSortedString = function(set) {
var array = [];
set.forEach(function(value) {
array.push(value);
});
return array.sort().join(", ");
};
ReactStrictModeWarnings.discardPendingWarnings = function() {
pendingComponentWillMountWarnings = [];
pendingComponentWillReceivePropsWarnings = [];
@ -4790,9 +4798,7 @@ var ReactStrictModeWarnings = {
var formatted = lifecycle.replace("UNSAFE_", "");
var suggestion = LIFECYCLE_SUGGESTIONS[lifecycle];
var sortedComponentNames = Array.from(componentNames)
.sort()
.join(", ");
var sortedComponentNames = setToSortedString(componentNames);
lifecyclesWarningMesages.push(
formatted +
@ -4844,9 +4850,7 @@ var ReactStrictModeWarnings = {
didWarnAboutDeprecatedLifecycles.add(fiber.type);
});
var sortedNames = Array.from(uniqueNames)
.sort()
.join(", ");
var sortedNames = setToSortedString(uniqueNames);
lowPriorityWarning$1(
false,
@ -4869,9 +4873,7 @@ var ReactStrictModeWarnings = {
didWarnAboutDeprecatedLifecycles.add(fiber.type);
});
var _sortedNames = Array.from(_uniqueNames)
.sort()
.join(", ");
var _sortedNames = setToSortedString(_uniqueNames);
lowPriorityWarning$1(
false,
@ -4893,9 +4895,7 @@ var ReactStrictModeWarnings = {
didWarnAboutDeprecatedLifecycles.add(fiber.type);
});
var _sortedNames2 = Array.from(_uniqueNames2)
.sort()
.join(", ");
var _sortedNames2 = setToSortedString(_uniqueNames2);
lowPriorityWarning$1(
false,
@ -6217,7 +6217,6 @@ var ReactFiberClassComponent = function(
if (
typeof instance.getSnapshotBeforeUpdate === "function" &&
typeof instance.componentDidUpdate !== "function" &&
typeof instance.componentDidUpdate !== "function" &&
!didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(type)
) {
didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(type);
@ -9199,6 +9198,10 @@ var ReactFiberBeginWork = function(
changedBits,
renderExpirationTime
);
} else if (oldProps === newProps) {
// Skip over a memoized parent with a bitmask bailout even
// if we began working on it because of a deeper matching child.
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
// There is no bailout on `children` equality because we expect people
// to often pass a bound method as a child, but it may reference

View File

@ -3656,33 +3656,40 @@ function ReactFiberBeginWork(
renderExpirationTime
);
case 12:
fn = workInProgress.type;
unmaskedContext = workInProgress.pendingProps;
var oldProps = workInProgress.memoizedProps;
props = fn._currentValue;
updateQueue = fn._changedBits;
if (
hasLegacyContextChanged() ||
0 !== updateQueue ||
oldProps !== unmaskedContext
) {
workInProgress.memoizedProps = unmaskedContext;
oldProps = unmaskedContext.unstable_observedBits;
if (void 0 === oldProps || null === oldProps) oldProps = 1073741823;
workInProgress.stateNode = oldProps;
0 !== (updateQueue & oldProps) &&
propagateContextChange(
workInProgress,
fn,
updateQueue,
renderExpirationTime
);
renderExpirationTime = unmaskedContext.children;
renderExpirationTime = renderExpirationTime(props);
reconcileChildren(current, workInProgress, renderExpirationTime);
current = workInProgress.child;
} else
current = bailoutOnAlreadyFinishedWork(current, workInProgress);
a: {
fn = workInProgress.type;
unmaskedContext = workInProgress.pendingProps;
updateQueue = workInProgress.memoizedProps;
props = fn._currentValue;
var changedBits = fn._changedBits;
if (
hasLegacyContextChanged() ||
0 !== changedBits ||
updateQueue !== unmaskedContext
) {
workInProgress.memoizedProps = unmaskedContext;
var observedBits = unmaskedContext.unstable_observedBits;
if (void 0 === observedBits || null === observedBits)
observedBits = 1073741823;
workInProgress.stateNode = observedBits;
if (0 !== (changedBits & observedBits))
propagateContextChange(
workInProgress,
fn,
changedBits,
renderExpirationTime
);
else if (updateQueue === unmaskedContext) {
current = bailoutOnAlreadyFinishedWork(current, workInProgress);
break a;
}
renderExpirationTime = unmaskedContext.children;
renderExpirationTime = renderExpirationTime(props);
reconcileChildren(current, workInProgress, renderExpirationTime);
current = workInProgress.child;
} else
current = bailoutOnAlreadyFinishedWork(current, workInProgress);
}
return current;
default:
invariant(

View File

@ -2995,6 +2995,75 @@ var TouchHistoryMath = {
var ReactVersion = "16.3.1";
var describeComponentFrame = function(name, source, ownerName) {
return (
"\n in " +
(name || "Unknown") +
(source
? " (at " +
source.fileName.replace(/^.*[\\\/]/, "") +
":" +
source.lineNumber +
")"
: ownerName ? " (created by " + ownerName + ")" : "")
);
};
function getComponentName(fiber) {
var type = fiber.type;
if (typeof type === "function") {
return type.displayName || type.name;
}
if (typeof type === "string") {
return type;
}
switch (type) {
case REACT_FRAGMENT_TYPE:
return "ReactFragment";
case REACT_PORTAL_TYPE:
return "ReactPortal";
case REACT_CALL_TYPE:
return "ReactCall";
case REACT_RETURN_TYPE:
return "ReactReturn";
}
return null;
}
function describeFiber(fiber) {
switch (fiber.tag) {
case IndeterminateComponent:
case FunctionalComponent:
case ClassComponent:
case HostComponent:
var owner = fiber._debugOwner;
var source = fiber._debugSource;
var name = getComponentName(fiber);
var ownerName = null;
if (owner) {
ownerName = getComponentName(owner);
}
return describeComponentFrame(name, source, ownerName);
default:
return "";
}
}
// This function can only be called with a work-in-progress fiber and
// only during begin or complete phase. Do not call it under any other
// circumstances.
function getStackAddendumByWorkInProgressFiber(workInProgress) {
var info = "";
var node = workInProgress;
do {
info += describeFiber(node);
// Otherwise this return pointer might point to the wrong tree:
node = node["return"];
} while (node);
return info;
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
@ -3589,28 +3658,6 @@ var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
var ReactCurrentOwner = ReactInternals.ReactCurrentOwner;
var ReactDebugCurrentFrame = ReactInternals.ReactDebugCurrentFrame;
function getComponentName(fiber) {
var type = fiber.type;
if (typeof type === "function") {
return type.displayName || type.name;
}
if (typeof type === "string") {
return type;
}
switch (type) {
case REACT_FRAGMENT_TYPE:
return "ReactFragment";
case REACT_PORTAL_TYPE:
return "ReactPortal";
case REACT_CALL_TYPE:
return "ReactCall";
case REACT_RETURN_TYPE:
return "ReactReturn";
}
return null;
}
// TODO: Share this module between Fabric and React Native renderers
// so that both can be used in the same tree.
@ -4878,53 +4925,6 @@ function onCommitUnmount(fiber) {
}
}
var describeComponentFrame = function(name, source, ownerName) {
return (
"\n in " +
(name || "Unknown") +
(source
? " (at " +
source.fileName.replace(/^.*[\\\/]/, "") +
":" +
source.lineNumber +
")"
: ownerName ? " (created by " + ownerName + ")" : "")
);
};
function describeFiber(fiber) {
switch (fiber.tag) {
case IndeterminateComponent:
case FunctionalComponent:
case ClassComponent:
case HostComponent:
var owner = fiber._debugOwner;
var source = fiber._debugSource;
var name = getComponentName(fiber);
var ownerName = null;
if (owner) {
ownerName = getComponentName(owner);
}
return describeComponentFrame(name, source, ownerName);
default:
return "";
}
}
// This function can only be called with a work-in-progress fiber and
// only during begin or complete phase. Do not call it under any other
// circumstances.
function getStackAddendumByWorkInProgressFiber(workInProgress) {
var info = "";
var node = workInProgress;
do {
info += describeFiber(node);
// Otherwise this return pointer might point to the wrong tree:
node = node["return"];
} while (node);
return info;
}
/**
* Forked from fbjs/warning:
* https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
@ -5019,6 +5019,14 @@ var ReactStrictModeWarnings = {
var didWarnAboutDeprecatedLifecycles = new Set();
var didWarnAboutUnsafeLifecycles = new Set();
var setToSortedString = function(set) {
var array = [];
set.forEach(function(value) {
array.push(value);
});
return array.sort().join(", ");
};
ReactStrictModeWarnings.discardPendingWarnings = function() {
pendingComponentWillMountWarnings = [];
pendingComponentWillReceivePropsWarnings = [];
@ -5044,9 +5052,7 @@ var ReactStrictModeWarnings = {
var formatted = lifecycle.replace("UNSAFE_", "");
var suggestion = LIFECYCLE_SUGGESTIONS[lifecycle];
var sortedComponentNames = Array.from(componentNames)
.sort()
.join(", ");
var sortedComponentNames = setToSortedString(componentNames);
lifecyclesWarningMesages.push(
formatted +
@ -5098,9 +5104,7 @@ var ReactStrictModeWarnings = {
didWarnAboutDeprecatedLifecycles.add(fiber.type);
});
var sortedNames = Array.from(uniqueNames)
.sort()
.join(", ");
var sortedNames = setToSortedString(uniqueNames);
lowPriorityWarning$1(
false,
@ -5123,9 +5127,7 @@ var ReactStrictModeWarnings = {
didWarnAboutDeprecatedLifecycles.add(fiber.type);
});
var _sortedNames = Array.from(_uniqueNames)
.sort()
.join(", ");
var _sortedNames = setToSortedString(_uniqueNames);
lowPriorityWarning$1(
false,
@ -5147,9 +5149,7 @@ var ReactStrictModeWarnings = {
didWarnAboutDeprecatedLifecycles.add(fiber.type);
});
var _sortedNames2 = Array.from(_uniqueNames2)
.sort()
.join(", ");
var _sortedNames2 = setToSortedString(_uniqueNames2);
lowPriorityWarning$1(
false,
@ -6475,7 +6475,6 @@ var ReactFiberClassComponent = function(
if (
typeof instance.getSnapshotBeforeUpdate === "function" &&
typeof instance.componentDidUpdate !== "function" &&
typeof instance.componentDidUpdate !== "function" &&
!didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(type)
) {
didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(type);
@ -9457,6 +9456,10 @@ var ReactFiberBeginWork = function(
changedBits,
renderExpirationTime
);
} else if (oldProps === newProps) {
// Skip over a memoized parent with a bitmask bailout even
// if we began working on it because of a deeper matching child.
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
// There is no bailout on `children` equality because we expect people
// to often pass a bound method as a child, but it may reference
@ -14707,6 +14710,14 @@ injectFindHostInstance(NativeRenderer.findHostInstance);
injection$2.injectRenderer(NativeRenderer);
function computeComponentStackForErrorReporting(reactTag) {
var fiber = getInstanceFromTag(reactTag);
if (!fiber) {
return "";
}
return getStackAddendumByWorkInProgressFiber(fiber);
}
var roots = new Map();
var ReactNativeRenderer = {
@ -14762,7 +14773,8 @@ var ReactNativeRenderer = {
ReactNativePropRegistry: ReactNativePropRegistry, // flattenStyle, Stylesheet
TouchHistoryMath: TouchHistoryMath, // PanResponder
createReactNativeComponentClass: createReactNativeComponentClass, // RCTText, RCTView, ReactNativeART
takeSnapshot: takeSnapshot
takeSnapshot: takeSnapshot, // react-native-implementation
computeComponentStackForErrorReporting: computeComponentStackForErrorReporting
}
};

View File

@ -1198,107 +1198,152 @@ function createPortal(children, containerInfo, implementation) {
};
}
var TouchHistoryMath = {
centroidDimension: function(
touchHistory,
touchesChangedAfter,
isXAxis,
ofCurrent
) {
var touchBank = touchHistory.touchBank,
total = 0,
count = 0;
touchHistory =
1 === touchHistory.numberActiveTouches
? touchHistory.touchBank[touchHistory.indexOfSingleActiveTouch]
: null;
if (null !== touchHistory)
touchHistory.touchActive &&
touchHistory.currentTimeStamp > touchesChangedAfter &&
centroidDimension: function(
touchHistory,
touchesChangedAfter,
isXAxis,
ofCurrent
) {
var touchBank = touchHistory.touchBank,
total = 0,
count = 0;
touchHistory =
1 === touchHistory.numberActiveTouches
? touchHistory.touchBank[touchHistory.indexOfSingleActiveTouch]
: null;
if (null !== touchHistory)
touchHistory.touchActive &&
touchHistory.currentTimeStamp > touchesChangedAfter &&
((total +=
ofCurrent && isXAxis
? touchHistory.currentPageX
: ofCurrent && !isXAxis
? touchHistory.currentPageY
: !ofCurrent && isXAxis
? touchHistory.previousPageX
: touchHistory.previousPageY),
(count = 1));
else
for (touchHistory = 0; touchHistory < touchBank.length; touchHistory++) {
var touchTrack = touchBank[touchHistory];
null !== touchTrack &&
void 0 !== touchTrack &&
touchTrack.touchActive &&
touchTrack.currentTimeStamp >= touchesChangedAfter &&
((total +=
ofCurrent && isXAxis
? touchHistory.currentPageX
? touchTrack.currentPageX
: ofCurrent && !isXAxis
? touchHistory.currentPageY
? touchTrack.currentPageY
: !ofCurrent && isXAxis
? touchHistory.previousPageX
: touchHistory.previousPageY),
(count = 1));
else
for (
touchHistory = 0;
touchHistory < touchBank.length;
touchHistory++
) {
var touchTrack = touchBank[touchHistory];
null !== touchTrack &&
void 0 !== touchTrack &&
touchTrack.touchActive &&
touchTrack.currentTimeStamp >= touchesChangedAfter &&
((total +=
ofCurrent && isXAxis
? touchTrack.currentPageX
: ofCurrent && !isXAxis
? touchTrack.currentPageY
: !ofCurrent && isXAxis
? touchTrack.previousPageX
: touchTrack.previousPageY),
count++);
}
return 0 < count ? total / count : TouchHistoryMath.noCentroid;
},
currentCentroidXOfTouchesChangedAfter: function(
touchHistory,
touchesChangedAfter
) {
return TouchHistoryMath.centroidDimension(
touchHistory,
touchesChangedAfter,
!0,
!0
);
},
currentCentroidYOfTouchesChangedAfter: function(
touchHistory,
touchesChangedAfter
) {
return TouchHistoryMath.centroidDimension(
touchHistory,
touchesChangedAfter,
!1,
!0
);
},
previousCentroidXOfTouchesChangedAfter: function(
touchHistory,
touchesChangedAfter
) {
return TouchHistoryMath.centroidDimension(
touchHistory,
touchesChangedAfter,
!0,
!1
);
},
previousCentroidYOfTouchesChangedAfter: function(
touchHistory,
touchesChangedAfter
) {
return TouchHistoryMath.centroidDimension(
touchHistory,
touchesChangedAfter,
!1,
!1
);
},
currentCentroidX: function(touchHistory) {
return TouchHistoryMath.centroidDimension(touchHistory, 0, !0, !0);
},
currentCentroidY: function(touchHistory) {
return TouchHistoryMath.centroidDimension(touchHistory, 0, !1, !0);
},
noCentroid: -1
? touchTrack.previousPageX
: touchTrack.previousPageY),
count++);
}
return 0 < count ? total / count : TouchHistoryMath.noCentroid;
},
objects = {},
currentCentroidXOfTouchesChangedAfter: function(
touchHistory,
touchesChangedAfter
) {
return TouchHistoryMath.centroidDimension(
touchHistory,
touchesChangedAfter,
!0,
!0
);
},
currentCentroidYOfTouchesChangedAfter: function(
touchHistory,
touchesChangedAfter
) {
return TouchHistoryMath.centroidDimension(
touchHistory,
touchesChangedAfter,
!1,
!0
);
},
previousCentroidXOfTouchesChangedAfter: function(
touchHistory,
touchesChangedAfter
) {
return TouchHistoryMath.centroidDimension(
touchHistory,
touchesChangedAfter,
!0,
!1
);
},
previousCentroidYOfTouchesChangedAfter: function(
touchHistory,
touchesChangedAfter
) {
return TouchHistoryMath.centroidDimension(
touchHistory,
touchesChangedAfter,
!1,
!1
);
},
currentCentroidX: function(touchHistory) {
return TouchHistoryMath.centroidDimension(touchHistory, 0, !0, !0);
},
currentCentroidY: function(touchHistory) {
return TouchHistoryMath.centroidDimension(touchHistory, 0, !1, !0);
},
noCentroid: -1
};
function getComponentName(fiber) {
fiber = fiber.type;
if ("function" === typeof fiber) return fiber.displayName || fiber.name;
if ("string" === typeof fiber) return fiber;
switch (fiber) {
case REACT_FRAGMENT_TYPE:
return "ReactFragment";
case REACT_PORTAL_TYPE:
return "ReactPortal";
case REACT_CALL_TYPE:
return "ReactCall";
case REACT_RETURN_TYPE:
return "ReactReturn";
}
return null;
}
function getStackAddendumByWorkInProgressFiber(workInProgress) {
var info = "";
do {
a: switch (workInProgress.tag) {
case 0:
case 1:
case 2:
case 5:
var owner = workInProgress._debugOwner,
source = workInProgress._debugSource;
var JSCompiler_inline_result = getComponentName(workInProgress);
var ownerName = null;
owner && (ownerName = getComponentName(owner));
owner = source;
JSCompiler_inline_result =
"\n in " +
(JSCompiler_inline_result || "Unknown") +
(owner
? " (at " +
owner.fileName.replace(/^.*[\\\/]/, "") +
":" +
owner.lineNumber +
")"
: ownerName ? " (created by " + ownerName + ")" : "");
break a;
default:
JSCompiler_inline_result = "";
}
info += JSCompiler_inline_result;
workInProgress = workInProgress["return"];
} while (workInProgress);
return info;
}
var objects = {},
uniqueID = 1,
emptyObject$2 = {},
ReactNativePropRegistry = (function() {
@ -1561,22 +1606,6 @@ function mountSafeCallback(context, callback) {
}
var ReactCurrentOwner =
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner;
function getComponentName(fiber) {
fiber = fiber.type;
if ("function" === typeof fiber) return fiber.displayName || fiber.name;
if ("string" === typeof fiber) return fiber;
switch (fiber) {
case REACT_FRAGMENT_TYPE:
return "ReactFragment";
case REACT_PORTAL_TYPE:
return "ReactPortal";
case REACT_CALL_TYPE:
return "ReactCall";
case REACT_RETURN_TYPE:
return "ReactReturn";
}
return null;
}
function findHostInstance() {
return null;
}
@ -1988,39 +2017,6 @@ function onCommitRoot(root) {
function onCommitUnmount(fiber) {
"function" === typeof onCommitFiberUnmount && onCommitFiberUnmount(fiber);
}
function getStackAddendumByWorkInProgressFiber(workInProgress) {
var info = "";
do {
a: switch (workInProgress.tag) {
case 0:
case 1:
case 2:
case 5:
var owner = workInProgress._debugOwner,
source = workInProgress._debugSource;
var JSCompiler_inline_result = getComponentName(workInProgress);
var ownerName = null;
owner && (ownerName = getComponentName(owner));
owner = source;
JSCompiler_inline_result =
"\n in " +
(JSCompiler_inline_result || "Unknown") +
(owner
? " (at " +
owner.fileName.replace(/^.*[\\\/]/, "") +
":" +
owner.lineNumber +
")"
: ownerName ? " (created by " + ownerName + ")" : "");
break a;
default:
JSCompiler_inline_result = "";
}
info += JSCompiler_inline_result;
workInProgress = workInProgress["return"];
} while (workInProgress);
return info;
}
var _require = require("ReactFeatureFlags"),
enableGetDerivedStateFromCatch = _require.enableGetDerivedStateFromCatch,
debugRenderPhaseSideEffects = _require.debugRenderPhaseSideEffects,
@ -3926,33 +3922,40 @@ function ReactFiberBeginWork(
renderExpirationTime
);
case 12:
fn = workInProgress.type;
unmaskedContext = workInProgress.pendingProps;
var oldProps = workInProgress.memoizedProps;
props = fn._currentValue;
updateQueue = fn._changedBits;
if (
hasLegacyContextChanged() ||
0 !== updateQueue ||
oldProps !== unmaskedContext
) {
workInProgress.memoizedProps = unmaskedContext;
oldProps = unmaskedContext.unstable_observedBits;
if (void 0 === oldProps || null === oldProps) oldProps = 1073741823;
workInProgress.stateNode = oldProps;
0 !== (updateQueue & oldProps) &&
propagateContextChange(
workInProgress,
fn,
updateQueue,
renderExpirationTime
);
renderExpirationTime = unmaskedContext.children;
renderExpirationTime = renderExpirationTime(props);
reconcileChildren(current, workInProgress, renderExpirationTime);
current = workInProgress.child;
} else
current = bailoutOnAlreadyFinishedWork(current, workInProgress);
a: {
fn = workInProgress.type;
unmaskedContext = workInProgress.pendingProps;
updateQueue = workInProgress.memoizedProps;
props = fn._currentValue;
var changedBits = fn._changedBits;
if (
hasLegacyContextChanged() ||
0 !== changedBits ||
updateQueue !== unmaskedContext
) {
workInProgress.memoizedProps = unmaskedContext;
var observedBits = unmaskedContext.unstable_observedBits;
if (void 0 === observedBits || null === observedBits)
observedBits = 1073741823;
workInProgress.stateNode = observedBits;
if (0 !== (changedBits & observedBits))
propagateContextChange(
workInProgress,
fn,
changedBits,
renderExpirationTime
);
else if (updateQueue === unmaskedContext) {
current = bailoutOnAlreadyFinishedWork(current, workInProgress);
break a;
}
renderExpirationTime = unmaskedContext.children;
renderExpirationTime = renderExpirationTime(props);
reconcileChildren(current, workInProgress, renderExpirationTime);
current = workInProgress.child;
} else
current = bailoutOnAlreadyFinishedWork(current, workInProgress);
}
return current;
default:
invariant(
@ -6554,6 +6557,11 @@ var roots = new Map(),
"window" !== view &&
(view = findNumericNodeHandleFiber(view) || "window");
return UIManager.__takeSnapshot(view, options);
},
computeComponentStackForErrorReporting: function(reactTag) {
return (reactTag = getInstanceFromTag(reactTag))
? getStackAddendumByWorkInProgressFiber(reactTag)
: "";
}
}
};