mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Add more clang tidy rules
Summary: changelog: [internal] Add more clang tidy rules to prevent common class of bugs. Reviewed By: javache Differential Revision: D39245194 fbshipit-source-id: 5521c5c4653d7005b96ebba494e810ba5075afbc
This commit is contained in:
1 parent
010cdcdc19
commit
ce50c43986
73 files changed
+411
-330
No files matched your search
@@ -40,5 +40,147 @@ performance-noexcept-move-constructor,
|
||||
performance-type-promotion-in-math-fn,
|
||||
performance-unnecessary-copy-initialization,
|
||||
performance-unnecessary-value-param,
|
||||
cppcoreguidelines-macro-usage,
|
||||
cppcoreguidelines-narrowing-conversions,
|
||||
cppcoreguidelines-no-malloc,
|
||||
cppcoreguidelines-pro-bounds-pointer-arithmetic,
|
||||
cppcoreguidelines-pro-type-const-cast,
|
||||
cppcoreguidelines-pro-type-cstyle-cast,
|
||||
cppcoreguidelines-pro-type-member-init,
|
||||
cppcoreguidelines-pro-type-reinterpret-cast,
|
||||
cppcoreguidelines-pro-type-union-access,
|
||||
cppcoreguidelines-pro-type-vararg,
|
||||
cppcoreguidelines-slicing,
|
||||
cppcoreguidelines-special-member-functions,
|
||||
readability-avoid-const-params-in-decls,
|
||||
readability-braces-around-statements,
|
||||
readability-const-return-type,
|
||||
readability-container-size-empty,
|
||||
readability-deleted-default,
|
||||
readability-delete-null-pointer,
|
||||
readability-implicit-bool-conversion,
|
||||
readability-inconsistent-declaration-parameter-name,
|
||||
readability-isolate-declaration,
|
||||
readability-misplaced-array-index,
|
||||
readability-named-parameter,
|
||||
readability-non-const-parameter,
|
||||
readability-redundant-control-flow,
|
||||
readability-redundant-declaration,
|
||||
readability-redundant-function-ptr-dereference,
|
||||
readability-redundant-preprocessor,
|
||||
readability-redundant-smartptr-get,
|
||||
readability-redundant-string-cstr,
|
||||
readability-redundant-string-init,
|
||||
readability-simplify-boolean-expr,
|
||||
readability-simplify-subscript-expr,
|
||||
readability-static-accessed-through-instance,
|
||||
readability-static-definition-in-anonymous-namespace,
|
||||
readability-string-compare,
|
||||
readability-uniqueptr-delete-release,
|
||||
misc-definitions-in-headers,
|
||||
misc-new-delete-overloads,
|
||||
misc-non-copyable-objects,
|
||||
misc-static-assert,
|
||||
misc-throw-by-value-catch-by-reference,
|
||||
misc-unconventional-assign-operator,
|
||||
misc-uniqueptr-reset-release,
|
||||
misc-unused-alias-decls,
|
||||
misc-unused-parameters,
|
||||
misc-unused-using-decls,
|
||||
bugprone-argument-comment,
|
||||
bugprone-assert-side-effect,
|
||||
bugprone-bool-pointer-implicit-conversion,
|
||||
bugprone-copy-constructor-init,
|
||||
bugprone-dangling-handle,
|
||||
bugprone-exception-escape,
|
||||
bugprone-fold-init-type,
|
||||
bugprone-forward-declaration-namespace,
|
||||
bugprone-forwarding-reference-overload,
|
||||
bugprone-inaccurate-erase,
|
||||
bugprone-incorrect-roundings,
|
||||
bugprone-integer-division,
|
||||
bugprone-macro-parentheses,
|
||||
bugprone-macro-repeated-side-effects,
|
||||
bugprone-misplaced-operator-in-strlen-in-alloc,
|
||||
bugprone-misplaced-widening-cast,
|
||||
bugprone-move-forwarding-reference,
|
||||
bugprone-multiple-statement-macro,
|
||||
bugprone-parent-virtual-call,
|
||||
bugprone-sizeof-container,
|
||||
bugprone-sizeof-expression,
|
||||
bugprone-string-constructor,
|
||||
bugprone-string-integer-assignment,
|
||||
bugprone-string-literal-with-embedded-nul,
|
||||
bugprone-suspicious-enum-usage,
|
||||
bugprone-suspicious-memset-usage,
|
||||
bugprone-suspicious-missing-comma,
|
||||
bugprone-suspicious-semicolon,
|
||||
bugprone-suspicious-string-compare,
|
||||
bugprone-swapped-arguments,
|
||||
bugprone-terminating-continue,
|
||||
bugprone-throw-keyword-missing,
|
||||
bugprone-too-small-loop-variable,
|
||||
bugprone-undefined-memory-manipulation,
|
||||
bugprone-undelegated-constructor,
|
||||
bugprone-unused-return-value,
|
||||
bugprone-use-after-move,
|
||||
bugprone-virtual-near-miss,
|
||||
clang-analyzer-apiModeling.StdCLibraryFunctions,
|
||||
clang-analyzer-apiModeling.TrustNonnull,
|
||||
clang-analyzer-apiModeling.google.GTest,
|
||||
clang-analyzer-core.CallAndMessage,
|
||||
clang-analyzer-core.DivideZero,
|
||||
clang-analyzer-core.DynamicTypePropagation,
|
||||
clang-analyzer-core.NonNullParamChecker,
|
||||
clang-analyzer-core.NonnilStringConstants,
|
||||
clang-analyzer-core.NullDereference,
|
||||
clang-analyzer-core.StackAddressEscape,
|
||||
clang-analyzer-core.UndefinedBinaryOperatorResult,
|
||||
clang-analyzer-core.VLASize,
|
||||
clang-analyzer-core.builtin.BuiltinFunctions,
|
||||
clang-analyzer-core.builtin.NoReturnFunctions,
|
||||
clang-analyzer-core.uninitialized.ArraySubscript,
|
||||
clang-analyzer-core.uninitialized.Assign,
|
||||
clang-analyzer-core.uninitialized.Branch,
|
||||
clang-analyzer-core.uninitialized.CapturedBlockVariable,
|
||||
clang-analyzer-core.uninitialized.UndefReturn,
|
||||
clang-analyzer-cplusplus.InnerPointer,
|
||||
clang-analyzer-cplusplus.Move,
|
||||
clang-analyzer-cplusplus.NewDelete,
|
||||
clang-analyzer-cplusplus.NewDeleteLeaks,
|
||||
clang-analyzer-cplusplus.SelfAssignment,
|
||||
clang-analyzer-deadcode.DeadStores,
|
||||
clang-analyzer-optin.cplusplus.VirtualCall,
|
||||
clang-analyzer-optin.mpi.MPI-Checker,
|
||||
clang-analyzer-optin.performance.GCDAntipattern,
|
||||
clang-analyzer-optin.performance.Padding,
|
||||
clang-analyzer-optin.portability.UnixAPI,
|
||||
clang-analyzer-nullability.NullPassedToNonnull,
|
||||
clang-analyzer-nullability.NullReturnedFromNonnull,
|
||||
clang-analyzer-nullability.NullableDereferenced,
|
||||
clang-analyzer-nullability.NullablePassedToNonnull,
|
||||
clang-analyzer-nullability.NullableReturnedFromNonnull,
|
||||
clang-analyzer-security.FloatLoopCounter,
|
||||
clang-analyzer-security.insecureAPI.UncheckedReturn,
|
||||
clang-analyzer-security.insecureAPI.bcmp,
|
||||
clang-analyzer-security.insecureAPI.bcopy,
|
||||
clang-analyzer-security.insecureAPI.bzero,
|
||||
clang-analyzer-security.insecureAPI.getpw,
|
||||
clang-analyzer-security.insecureAPI.gets,
|
||||
clang-analyzer-security.insecureAPI.mkstemp,
|
||||
clang-analyzer-security.insecureAPI.mktemp,
|
||||
clang-analyzer-security.insecureAPI.rand,
|
||||
clang-analyzer-security.insecureAPI.strcpy,
|
||||
clang-analyzer-security.insecureAPI.vfork,
|
||||
clang-analyzer-unix.API,
|
||||
clang-analyzer-unix.Malloc,
|
||||
clang-analyzer-unix.MallocSizeof,
|
||||
clang-analyzer-unix.MismatchedDeallocator,
|
||||
clang-analyzer-unix.Vfork,
|
||||
clang-analyzer-unix.cstring.BadSizeArg,
|
||||
clang-analyzer-unix.cstring.NullArg,
|
||||
clang-analyzer-valist.CopyToSelf,
|
||||
clang-analyzer-valist.Uninitialized,
|
||||
clang-analyzer-valist.Unterminated,
|
||||
'
|
||||
...
|
||||
@@ -1183,11 +1183,11 @@ void LayoutAnimationKeyFrameManager::queueFinalMutationsForCompletedKeyFrame(
|
||||
AnimationKeyFrame const &keyframe,
|
||||
ShadowViewMutation::List &mutationsList,
|
||||
bool interrupted,
|
||||
const std::string &logPrefix) const {
|
||||
const std::string & /*logPrefix*/) const {
|
||||
if (skipInvalidatedKeyFrames_ && keyframe.invalidated) {
|
||||
return;
|
||||
}
|
||||
if (keyframe.finalMutationsForKeyFrame.size() > 0) {
|
||||
if (!keyframe.finalMutationsForKeyFrame.empty()) {
|
||||
// TODO: modularize this segment, it is repeated 2x in KeyFrameManager
|
||||
// as well.
|
||||
ShadowView prev = keyframe.viewPrev;
|
||||
|
||||
@@ -64,7 +64,7 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations(
|
||||
|
||||
// Create a RuntimeExecutor
|
||||
RuntimeExecutor runtimeExecutor =
|
||||
[](std::function<void(jsi::Runtime &)> const &) {};
|
||||
[](std::function<void(jsi::Runtime &)> const & /*unused*/) {};
|
||||
|
||||
// Create component descriptor registry for animation driver
|
||||
auto providerRegistry =
|
||||
@@ -158,7 +158,7 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations(
|
||||
// If tree randomization produced no changes in the form of mutations,
|
||||
// don't bother trying to animate because this violates a bunch of our
|
||||
// assumptions in this test
|
||||
if (originalMutations.size() == 0) {
|
||||
if (originalMutations.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ namespace facebook {
|
||||
namespace react {
|
||||
|
||||
void ComponentDescriptorProviderRegistry::add(
|
||||
ComponentDescriptorProvider provider) const {
|
||||
const ComponentDescriptorProvider &provider) const {
|
||||
std::unique_lock<butter::shared_mutex> lock(mutex_);
|
||||
|
||||
/*
|
||||
|
||||
@@ -33,7 +33,7 @@ class ComponentDescriptorProviderRegistry final {
|
||||
* `ComponentDescriptorRegistry`s accordingly.
|
||||
* The methods can be called on any thread.
|
||||
*/
|
||||
void add(ComponentDescriptorProvider provider) const;
|
||||
void add(const ComponentDescriptorProvider &provider) const;
|
||||
|
||||
/*
|
||||
* ComponenDescriptorRegistry will call the `request` in case if a component
|
||||
|
||||
@@ -50,7 +50,7 @@ void ComponentDescriptorRegistry::add(
|
||||
}
|
||||
|
||||
void ComponentDescriptorRegistry::registerComponentDescriptor(
|
||||
SharedComponentDescriptor componentDescriptor) const {
|
||||
const SharedComponentDescriptor &componentDescriptor) const {
|
||||
ComponentHandle componentHandle = componentDescriptor->getComponentHandle();
|
||||
_registryByHandle[componentHandle] = componentDescriptor;
|
||||
|
||||
@@ -119,11 +119,7 @@ bool ComponentDescriptorRegistry::hasComponentDescriptorAt(
|
||||
std::shared_lock<butter::shared_mutex> lock(mutex_);
|
||||
|
||||
auto iterator = _registryByHandle.find(componentHandle);
|
||||
if (iterator == _registryByHandle.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return iterator != _registryByHandle.end();
|
||||
}
|
||||
|
||||
ShadowNode::Shared ComponentDescriptorRegistry::createNode(
|
||||
@@ -136,8 +132,7 @@ ShadowNode::Shared ComponentDescriptorRegistry::createNode(
|
||||
auto const &componentDescriptor = this->at(unifiedComponentName);
|
||||
|
||||
auto const fragment = ShadowNodeFamilyFragment{tag, surfaceId, nullptr};
|
||||
auto family =
|
||||
componentDescriptor.createFamily(fragment, std::move(eventTarget));
|
||||
auto family = componentDescriptor.createFamily(fragment, eventTarget);
|
||||
auto const props = componentDescriptor.cloneProps(
|
||||
PropsParserContext{surfaceId, *contextContainer_.get()},
|
||||
nullptr,
|
||||
@@ -155,7 +150,7 @@ ShadowNode::Shared ComponentDescriptorRegistry::createNode(
|
||||
}
|
||||
|
||||
void ComponentDescriptorRegistry::setFallbackComponentDescriptor(
|
||||
SharedComponentDescriptor descriptor) {
|
||||
const SharedComponentDescriptor &descriptor) {
|
||||
_fallbackComponentDescriptor = descriptor;
|
||||
registerComponentDescriptor(descriptor);
|
||||
}
|
||||
|
||||
@@ -62,14 +62,15 @@ class ComponentDescriptorRegistry {
|
||||
folly::dynamic const &props,
|
||||
SharedEventTarget const &eventTarget) const;
|
||||
|
||||
void setFallbackComponentDescriptor(SharedComponentDescriptor descriptor);
|
||||
void setFallbackComponentDescriptor(
|
||||
const SharedComponentDescriptor &descriptor);
|
||||
ComponentDescriptor::Shared getFallbackComponentDescriptor() const;
|
||||
|
||||
private:
|
||||
friend class ComponentDescriptorProviderRegistry;
|
||||
|
||||
void registerComponentDescriptor(
|
||||
SharedComponentDescriptor componentDescriptor) const;
|
||||
const SharedComponentDescriptor &componentDescriptor) const;
|
||||
|
||||
/*
|
||||
* Creates a `ComponentDescriptor` using specified
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ namespace react {
|
||||
*/
|
||||
NativeComponentRegistryBinding::NativeComponentRegistryBinding(
|
||||
const HasComponentProviderFunctionType &&hasComponentProvider)
|
||||
: hasComponentProvider_(std::move(hasComponentProvider)) {}
|
||||
: hasComponentProvider_(hasComponentProvider) {}
|
||||
|
||||
void NativeComponentRegistryBinding::install(
|
||||
jsi::Runtime &runtime,
|
||||
@@ -61,7 +61,7 @@ jsi::Value NativeComponentRegistryBinding::jsProxy(
|
||||
|
||||
bool result = hasComponent(moduleName);
|
||||
|
||||
return jsi::Value(result);
|
||||
return {result};
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ void AndroidProgressBarShadowNode::setAndroidProgressBarMeasurementsManager(
|
||||
#pragma mark - LayoutableShadowNode
|
||||
|
||||
Size AndroidProgressBarShadowNode::measureContent(
|
||||
LayoutContext const &layoutContext,
|
||||
LayoutContext const & /*layoutContext*/,
|
||||
LayoutConstraints const &layoutConstraints) const {
|
||||
return measurementsManager_->measure(
|
||||
getSurfaceId(), getConcreteProps(), layoutConstraints);
|
||||
|
||||
@@ -26,8 +26,8 @@ RootProps::RootProps(
|
||||
// If that's a problem and the context is necesary here, refactor RootShadowNode
|
||||
// first.
|
||||
RootProps::RootProps(
|
||||
const PropsParserContext &context,
|
||||
RootProps const &sourceProps,
|
||||
const PropsParserContext & /*context*/,
|
||||
RootProps const & /*sourceProps*/,
|
||||
LayoutConstraints const &layoutConstraints,
|
||||
LayoutContext const &layoutContext)
|
||||
: ViewProps(),
|
||||
|
||||
@@ -84,7 +84,7 @@ ImageSource SliderShadowNode::getThumbImageSource() const {
|
||||
#pragma mark - LayoutableShadowNode
|
||||
|
||||
Size SliderShadowNode::measureContent(
|
||||
LayoutContext const &layoutContext,
|
||||
LayoutContext const & /*layoutContext*/,
|
||||
LayoutConstraints const &layoutConstraints) const {
|
||||
if (SliderMeasurementsManager::shouldMeasureSlider()) {
|
||||
return measurementsManager_->measure(getSurfaceId(), layoutConstraints);
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ void AndroidSwitchShadowNode::setAndroidSwitchMeasurementsManager(
|
||||
#pragma mark - LayoutableShadowNode
|
||||
|
||||
Size AndroidSwitchShadowNode::measureContent(
|
||||
LayoutContext const &layoutContext,
|
||||
LayoutContext const & /*layoutContext*/,
|
||||
LayoutConstraints const &layoutConstraints) const {
|
||||
return measurementsManager_->measure(getSurfaceId(), layoutConstraints);
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ BaseTextProps::BaseTextProps(
|
||||
void BaseTextProps::setProp(
|
||||
const PropsParserContext &context,
|
||||
RawPropsPropNameHash hash,
|
||||
const char *propName,
|
||||
const char * /*propName*/,
|
||||
RawValue const &value) {
|
||||
static auto defaults = TextAttributes{};
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ void BaseTextShadowNode::buildAttributedString(
|
||||
// RawShadowNode
|
||||
auto rawTextShadowNode =
|
||||
traitCast<RawTextShadowNode const *>(childNode.get());
|
||||
if (rawTextShadowNode) {
|
||||
if (rawTextShadowNode != nullptr) {
|
||||
auto fragment = AttributedString::Fragment{};
|
||||
fragment.string = rawTextShadowNode->getConcreteProps().text;
|
||||
fragment.textAttributes = baseTextAttributes;
|
||||
@@ -50,7 +50,7 @@ void BaseTextShadowNode::buildAttributedString(
|
||||
|
||||
// TextShadowNode
|
||||
auto textShadowNode = traitCast<TextShadowNode const *>(childNode.get());
|
||||
if (textShadowNode) {
|
||||
if (textShadowNode != nullptr) {
|
||||
auto localTextAttributes = baseTextAttributes;
|
||||
localTextAttributes.apply(
|
||||
textShadowNode->getConcreteProps().textAttributes);
|
||||
|
||||
+1
-1
@@ -168,7 +168,7 @@ void AndroidTextInputShadowNode::updateStateIfNeeded() {
|
||||
#pragma mark - LayoutableShadowNode
|
||||
|
||||
Size AndroidTextInputShadowNode::measureContent(
|
||||
LayoutContext const &layoutContext,
|
||||
LayoutContext const & /*layoutContext*/,
|
||||
LayoutConstraints const &layoutConstraints) const {
|
||||
if (getStateData().cachedAttributedStringId != 0) {
|
||||
return textLayoutManager_
|
||||
|
||||
+2
-2
@@ -45,8 +45,8 @@ class TextInputEventEmitter : public ViewEventEmitter {
|
||||
void onSelectionChange(TextInputMetrics const &textInputMetrics) const;
|
||||
void onEndEditing(TextInputMetrics const &textInputMetrics) const;
|
||||
void onSubmitEditing(TextInputMetrics const &textInputMetrics) const;
|
||||
void onKeyPress(KeyPressMetrics const &textInputMetrics) const;
|
||||
void onKeyPressSync(KeyPressMetrics const &textInputMetrics) const;
|
||||
void onKeyPress(KeyPressMetrics const &keyPressMetrics) const;
|
||||
void onKeyPressSync(KeyPressMetrics const &keyPressMetrics) const;
|
||||
void onScroll(TextInputMetrics const &textInputMetrics) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace react {
|
||||
|
||||
#ifdef ANDROID
|
||||
TextInputState::TextInputState(
|
||||
TextInputState const &previousState,
|
||||
folly::dynamic const &data){};
|
||||
TextInputState const & /*previousState*/,
|
||||
folly::dynamic const & /*data*/){};
|
||||
|
||||
/*
|
||||
* Empty implementation for Android because it doesn't use this class.
|
||||
|
||||
@@ -194,7 +194,7 @@ AccessibilityProps::AccessibilityProps(
|
||||
void AccessibilityProps::setProp(
|
||||
const PropsParserContext &context,
|
||||
RawPropsPropNameHash hash,
|
||||
const char *propName,
|
||||
const char * /*propName*/,
|
||||
RawValue const &value) {
|
||||
switch (hash) {
|
||||
RAW_SET_PROP_SWITCH_CASE_BASIC(accessible, false);
|
||||
@@ -217,7 +217,7 @@ void AccessibilityProps::setProp(
|
||||
RAW_SET_PROP_SWITCH_CASE(testId, "testID", std::string{""});
|
||||
case CONSTEXPR_RAW_PROPS_KEY_HASH("accessibilityRole"): {
|
||||
AccessibilityTraits traits = AccessibilityTraits::None;
|
||||
std::string roleString = "";
|
||||
std::string roleString;
|
||||
if (value.hasValue()) {
|
||||
fromRawValue(context, value, traits);
|
||||
fromRawValue(context, value, roleString);
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace react {
|
||||
|
||||
#if RN_DEBUG_STRING_CONVERTIBLE
|
||||
|
||||
std::string getDebugName(PointerEvent const &pointerEvent) {
|
||||
std::string getDebugName(PointerEvent const & /*pointerEvent*/) {
|
||||
return "PointerEvent";
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace react {
|
||||
|
||||
#if RN_DEBUG_STRING_CONVERTIBLE
|
||||
|
||||
std::string getDebugName(Touch const &touch) {
|
||||
std::string getDebugName(Touch const & /*touch*/) {
|
||||
return "Touch";
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ using Touches = std::unordered_set<Touch, Touch::Hasher, Touch::Comparator>;
|
||||
|
||||
std::string getDebugName(Touch const &touch);
|
||||
std::vector<DebugStringConvertibleObject> getDebugProps(
|
||||
Touch const &object,
|
||||
Touch const &touch,
|
||||
DebugStringConvertibleOptions options);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace react {
|
||||
|
||||
#if RN_DEBUG_STRING_CONVERTIBLE
|
||||
|
||||
std::string getDebugName(TouchEvent const &touchEvent) {
|
||||
std::string getDebugName(TouchEvent const & /*touchEvent*/) {
|
||||
return "TouchEvent";
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ ValueFactory EventEmitter::defaultPayloadFactory() {
|
||||
|
||||
EventEmitter::EventEmitter(
|
||||
SharedEventTarget eventTarget,
|
||||
Tag tag,
|
||||
Tag /*tag*/,
|
||||
EventDispatcher::Weak eventDispatcher)
|
||||
: eventTarget_(std::move(eventTarget)),
|
||||
eventDispatcher_(std::move(eventDispatcher)) {}
|
||||
|
||||
@@ -46,7 +46,7 @@ void EventTarget::retain(jsi::Runtime &runtime) const {
|
||||
// react_native_assert(!strongInstanceHandle_.isUndefined());
|
||||
}
|
||||
|
||||
void EventTarget::release(jsi::Runtime &runtime) const {
|
||||
void EventTarget::release(jsi::Runtime & /*runtime*/) const {
|
||||
// The method does not use `jsi::Runtime` reference.
|
||||
// It takes it only to ensure thread-safety (if the caller has the reference,
|
||||
// we are on a proper thread).
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace react {
|
||||
|
||||
#if RN_DEBUG_STRING_CONVERTIBLE
|
||||
|
||||
std::string getDebugName(LayoutMetrics const &object) {
|
||||
std::string getDebugName(LayoutMetrics const & /*object*/) {
|
||||
return "LayoutMetrics";
|
||||
}
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ LayoutableShadowNode::getLayoutableChildNodes() const {
|
||||
Size LayoutableShadowNode::measureContent(
|
||||
LayoutContext const &layoutContext,
|
||||
LayoutConstraints const &layoutConstraints) const {
|
||||
return Size();
|
||||
return {};
|
||||
}
|
||||
|
||||
Size LayoutableShadowNode::measure(
|
||||
|
||||
@@ -41,7 +41,7 @@ Props::Props(
|
||||
void Props::setProp(
|
||||
const PropsParserContext &context,
|
||||
RawPropsPropNameHash hash,
|
||||
const char *propName,
|
||||
const char * /*propName*/,
|
||||
RawValue const &value) {
|
||||
switch (hash) {
|
||||
case CONSTEXPR_RAW_PROPS_KEY_HASH("nativeID"):
|
||||
|
||||
@@ -48,8 +48,9 @@ RawProps::RawProps(folly::dynamic const &dynamic) noexcept {
|
||||
dynamic_ = dynamic;
|
||||
}
|
||||
|
||||
void RawProps::parse(RawPropsParser const &parser, const PropsParserContext &)
|
||||
const noexcept {
|
||||
void RawProps::parse(
|
||||
RawPropsParser const &parser,
|
||||
const PropsParserContext & /*unused*/) const noexcept {
|
||||
react_native_assert(parser_ == nullptr && "A parser was already assigned.");
|
||||
parser_ = &parser;
|
||||
parser.preparse(*this);
|
||||
|
||||
@@ -118,7 +118,7 @@ class RawProps final {
|
||||
mutable Mode mode_;
|
||||
|
||||
// Case 1: Source data is represented as `jsi::Object`.
|
||||
jsi::Runtime *runtime_;
|
||||
jsi::Runtime *runtime_{};
|
||||
jsi::Value value_;
|
||||
|
||||
// Case 2: Source data is represented as `folly::dynamic`.
|
||||
|
||||
@@ -22,7 +22,7 @@ void RawPropsKey::render(char *buffer, RawPropsPropNameLength *length)
|
||||
*length = 0;
|
||||
|
||||
// Prefix
|
||||
if (prefix) {
|
||||
if (prefix != nullptr) {
|
||||
auto prefixLength =
|
||||
static_cast<RawPropsPropNameLength>(std::strlen(prefix));
|
||||
std::memcpy(buffer, prefix, prefixLength);
|
||||
@@ -35,7 +35,7 @@ void RawPropsKey::render(char *buffer, RawPropsPropNameLength *length)
|
||||
*length += nameLength;
|
||||
|
||||
// Suffix
|
||||
if (suffix) {
|
||||
if (suffix != nullptr) {
|
||||
auto suffixLength =
|
||||
static_cast<RawPropsPropNameLength>(std::strlen(suffix));
|
||||
std::memcpy(buffer + *length, suffix, suffixLength);
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace react {
|
||||
|
||||
Sealable::Sealable() : sealed_(false) {}
|
||||
|
||||
Sealable::Sealable(const Sealable &other) : sealed_(false){};
|
||||
Sealable::Sealable(const Sealable & /*other*/) : sealed_(false){};
|
||||
|
||||
Sealable::Sealable(Sealable &&other) noexcept : sealed_(false) {
|
||||
other.ensureUnsealed();
|
||||
@@ -37,7 +37,7 @@ Sealable::Sealable(Sealable &&other) noexcept : sealed_(false) {
|
||||
|
||||
Sealable::~Sealable() noexcept = default;
|
||||
|
||||
Sealable &Sealable::operator=(const Sealable &other) {
|
||||
Sealable &Sealable::operator=(const Sealable & /*other*/) {
|
||||
ensureUnsealed();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ AncestorList ShadowNodeFamily::getAncestors(
|
||||
auto ancestorFamily = ancestorShadowNode.family_.get();
|
||||
|
||||
auto family = this;
|
||||
while (family && family != ancestorFamily) {
|
||||
while ((family != nullptr) && family != ancestorFamily) {
|
||||
families.push_back(family);
|
||||
family = family->parent_.lock().get();
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ class EventQueueProcessorTest : public testing::Test {
|
||||
runtime_ = facebook::hermes::makeHermesRuntime();
|
||||
|
||||
auto eventPipe = [this](
|
||||
jsi::Runtime &runtime,
|
||||
const EventTarget *eventTarget,
|
||||
jsi::Runtime & /*runtime*/,
|
||||
const EventTarget * /*eventTarget*/,
|
||||
const std::string &type,
|
||||
ReactEventPriority priority,
|
||||
const ValueFactory &payloadFactory) {
|
||||
const ValueFactory & /*payloadFactory*/) {
|
||||
eventTypes_.push_back(type);
|
||||
eventPriorities_.push_back(priority);
|
||||
};
|
||||
|
||||
@@ -188,7 +188,7 @@ TEST(RawPropsTest, handleRawPropsSingleFloat) {
|
||||
parser.prepare<PropsSingleFloat>();
|
||||
raw.parse(parser, parserContext);
|
||||
|
||||
float value = (float)*raw.at("floatValue", nullptr, nullptr);
|
||||
auto value = (float)*raw.at("floatValue", nullptr, nullptr);
|
||||
|
||||
EXPECT_NEAR(value, 42.42, 0.00001);
|
||||
}
|
||||
@@ -203,7 +203,7 @@ TEST(RawPropsTest, handleRawPropsSingleDouble) {
|
||||
parser.prepare<PropsSingleDouble>();
|
||||
raw.parse(parser, parserContext);
|
||||
|
||||
double value = (double)*raw.at("doubleValue", nullptr, nullptr);
|
||||
auto value = (double)*raw.at("doubleValue", nullptr, nullptr);
|
||||
|
||||
EXPECT_NEAR(value, 42.42, 0.00001);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ std::string DebugStringConvertible::getDebugChildrenDescription(
|
||||
options.depth++;
|
||||
|
||||
auto trailing = options.format ? std::string{"\n"} : std::string{""};
|
||||
auto childrenString = std::string{""};
|
||||
std::string childrenString;
|
||||
|
||||
for (auto const &child : getDebugChildren()) {
|
||||
if (!child) {
|
||||
@@ -50,7 +50,7 @@ std::string DebugStringConvertible::getDebugPropsDescription(
|
||||
|
||||
options.depth++;
|
||||
|
||||
auto propsString = std::string{""};
|
||||
std::string propsString;
|
||||
|
||||
for (auto const &prop : getDebugProps()) {
|
||||
if (!prop) {
|
||||
@@ -116,11 +116,11 @@ std::string DebugStringConvertible::getDebugValue() const {
|
||||
|
||||
SharedDebugStringConvertibleList DebugStringConvertible::getDebugChildren()
|
||||
const {
|
||||
return SharedDebugStringConvertibleList();
|
||||
return {};
|
||||
}
|
||||
|
||||
SharedDebugStringConvertibleList DebugStringConvertible::getDebugProps() const {
|
||||
return SharedDebugStringConvertibleList();
|
||||
return {};
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -279,28 +279,40 @@ Transform Transform::operator*(Transform const &rhs) const {
|
||||
auto result = Transform{};
|
||||
for (const auto &op : this->operations) {
|
||||
if (op.type == TransformOperationType::Identity &&
|
||||
result.operations.size() > 0) {
|
||||
!result.operations.empty()) {
|
||||
continue;
|
||||
}
|
||||
result.operations.push_back(op);
|
||||
}
|
||||
for (const auto &op : rhs.operations) {
|
||||
if (op.type == TransformOperationType::Identity &&
|
||||
result.operations.size() > 0) {
|
||||
!result.operations.empty()) {
|
||||
continue;
|
||||
}
|
||||
result.operations.push_back(op);
|
||||
}
|
||||
|
||||
auto lhs00 = lhs.matrix[0], lhs01 = lhs.matrix[1], lhs02 = lhs.matrix[2],
|
||||
lhs03 = lhs.matrix[3], lhs10 = lhs.matrix[4], lhs11 = lhs.matrix[5],
|
||||
lhs12 = lhs.matrix[6], lhs13 = lhs.matrix[7], lhs20 = lhs.matrix[8],
|
||||
lhs21 = lhs.matrix[9], lhs22 = lhs.matrix[10], lhs23 = lhs.matrix[11],
|
||||
lhs30 = lhs.matrix[12], lhs31 = lhs.matrix[13], lhs32 = lhs.matrix[14],
|
||||
lhs33 = lhs.matrix[15];
|
||||
auto lhs00 = lhs.matrix[0];
|
||||
auto lhs01 = lhs.matrix[1];
|
||||
auto lhs02 = lhs.matrix[2];
|
||||
auto lhs03 = lhs.matrix[3];
|
||||
auto lhs10 = lhs.matrix[4];
|
||||
auto lhs11 = lhs.matrix[5];
|
||||
auto lhs12 = lhs.matrix[6];
|
||||
auto lhs13 = lhs.matrix[7];
|
||||
auto lhs20 = lhs.matrix[8];
|
||||
auto lhs21 = lhs.matrix[9];
|
||||
auto lhs22 = lhs.matrix[10];
|
||||
auto lhs23 = lhs.matrix[11];
|
||||
auto lhs30 = lhs.matrix[12];
|
||||
auto lhs31 = lhs.matrix[13];
|
||||
auto lhs32 = lhs.matrix[14];
|
||||
auto lhs33 = lhs.matrix[15];
|
||||
|
||||
auto rhs0 = rhs.matrix[0], rhs1 = rhs.matrix[1], rhs2 = rhs.matrix[2],
|
||||
rhs3 = rhs.matrix[3];
|
||||
auto rhs0 = rhs.matrix[0];
|
||||
auto rhs1 = rhs.matrix[1];
|
||||
auto rhs2 = rhs.matrix[2];
|
||||
auto rhs3 = rhs.matrix[3];
|
||||
result.matrix[0] = rhs0 * lhs00 + rhs1 * lhs10 + rhs2 * lhs20 + rhs3 * lhs30;
|
||||
result.matrix[1] = rhs0 * lhs01 + rhs1 * lhs11 + rhs2 * lhs21 + rhs3 * lhs31;
|
||||
result.matrix[2] = rhs0 * lhs02 + rhs1 * lhs12 + rhs2 * lhs22 + rhs3 * lhs32;
|
||||
|
||||
@@ -112,9 +112,9 @@ struct Transform {
|
||||
/*
|
||||
* Returns a transform that rotates by `angle` radians along the given axis.
|
||||
*/
|
||||
static Transform RotateX(Float angle);
|
||||
static Transform RotateY(Float angle);
|
||||
static Transform RotateZ(Float angle);
|
||||
static Transform RotateX(Float radians);
|
||||
static Transform RotateY(Float radians);
|
||||
static Transform RotateZ(Float radians);
|
||||
static Transform Rotate(Float angleX, Float angleY, Float angleZ);
|
||||
|
||||
/**
|
||||
@@ -145,8 +145,8 @@ struct Transform {
|
||||
/*
|
||||
* Matrix subscript.
|
||||
*/
|
||||
Float &at(int x, int y);
|
||||
Float const &at(int x, int y) const;
|
||||
Float &at(int i, int j);
|
||||
Float const &at(int i, int j) const;
|
||||
|
||||
/*
|
||||
* Concatenates (multiplies) transform matrices.
|
||||
|
||||
@@ -20,11 +20,11 @@ bool isColorMeaningful(SharedColor const &color) noexcept {
|
||||
|
||||
SharedColor colorFromComponents(ColorComponents components) {
|
||||
float ratio = 255;
|
||||
return SharedColor(
|
||||
return {
|
||||
((int)round(components.alpha * ratio) & 0xff) << 24 |
|
||||
((int)round(components.red * ratio) & 0xff) << 16 |
|
||||
((int)round(components.green * ratio) & 0xff) << 8 |
|
||||
((int)round(components.blue * ratio) & 0xff));
|
||||
((int)round(components.blue * ratio) & 0xff)};
|
||||
}
|
||||
|
||||
ColorComponents colorComponentsFromColor(SharedColor const &sharedColor) {
|
||||
|
||||
@@ -33,7 +33,7 @@ class ImageManager {
|
||||
const;
|
||||
|
||||
private:
|
||||
void *self_;
|
||||
void *self_{};
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
||||
+4
-3
@@ -10,7 +10,8 @@
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
ImageManager::ImageManager(ContextContainer::Shared const &contextContainer) {
|
||||
ImageManager::ImageManager(
|
||||
ContextContainer::Shared const & /*contextContainer*/) {
|
||||
// Silence unused-private-field warning.
|
||||
(void)self_;
|
||||
// Not implemented.
|
||||
@@ -22,9 +23,9 @@ ImageManager::~ImageManager() {
|
||||
|
||||
ImageRequest ImageManager::requestImage(
|
||||
const ImageSource &imageSource,
|
||||
SurfaceId surfaceId) const {
|
||||
SurfaceId /*surfaceId*/) const {
|
||||
// Not implemented.
|
||||
return ImageRequest(imageSource, nullptr);
|
||||
return {imageSource, nullptr};
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
|
||||
@@ -32,7 +32,7 @@ class LeakChecker final {
|
||||
RuntimeExecutor const runtimeExecutor_{};
|
||||
|
||||
WeakFamilyRegistry registry_{};
|
||||
SurfaceId previouslyStoppedSurface_;
|
||||
SurfaceId previouslyStoppedSurface_{};
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
||||
@@ -28,9 +28,8 @@ WeakFamilyRegistry::WeakFamilies WeakFamilyRegistry::weakFamiliesForSurfaceId(
|
||||
std::lock_guard<std::mutex> lock(familiesMutex_);
|
||||
if (families_.find(surfaceId) != families_.end()) {
|
||||
return families_[surfaceId];
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
|
||||
@@ -90,7 +90,7 @@ std::string MapBuffer::getString(Key key) const {
|
||||
uint8_t const *stringPtr =
|
||||
bytes_.data() + dynamicDataOffset + offset + sizeof(int);
|
||||
|
||||
return std::string(stringPtr, stringPtr + stringLength);
|
||||
return {stringPtr, stringPtr + stringLength};
|
||||
}
|
||||
|
||||
MapBuffer MapBuffer::getMapBuffer(Key key) const {
|
||||
|
||||
@@ -164,7 +164,7 @@ TEST(MapBufferTest, testMapListEntries) {
|
||||
mapBufferList.push_back(builder2.build());
|
||||
|
||||
auto builder3 = MapBufferBuilder();
|
||||
builder3.putMapBufferList(5, std::move(mapBufferList));
|
||||
builder3.putMapBufferList(5, mapBufferList);
|
||||
auto map = builder3.build();
|
||||
|
||||
std::vector<MapBuffer> mapBufferList2 = map.getMapBufferList(5);
|
||||
|
||||
@@ -336,7 +336,6 @@ static_assert(
|
||||
"`ShadowViewNodePair::NonOwningList` must be `move assignable`.");
|
||||
|
||||
static void calculateShadowViewMutationsV2(
|
||||
BREADCRUMB_TYPE breadcrumb,
|
||||
ViewNodePairScope &scope,
|
||||
ShadowViewMutation::List &mutations,
|
||||
ShadowView const &parentShadowView,
|
||||
@@ -355,18 +354,15 @@ struct OrderedMutationInstructionContainer {
|
||||
};
|
||||
|
||||
static void updateMatchedPairSubtrees(
|
||||
BREADCRUMB_TYPE breadcrumb,
|
||||
ViewNodePairScope &scope,
|
||||
OrderedMutationInstructionContainer &mutationContainer,
|
||||
TinyMap<Tag, ShadowViewNodePair *> &newRemainingPairs,
|
||||
ShadowViewNodePair::NonOwningList &oldChildPairs,
|
||||
ShadowViewNodePair::NonOwningList &newChildPairs,
|
||||
ShadowView const &parentShadowView,
|
||||
ShadowViewNodePair const &oldPair,
|
||||
ShadowViewNodePair const &newPair);
|
||||
|
||||
static void updateMatchedPair(
|
||||
BREADCRUMB_TYPE breadcrumb,
|
||||
OrderedMutationInstructionContainer &mutationContainer,
|
||||
bool oldNodeFoundInOrder,
|
||||
bool newNodeFoundInOrder,
|
||||
@@ -375,12 +371,11 @@ static void updateMatchedPair(
|
||||
ShadowViewNodePair const &newPair);
|
||||
|
||||
static void calculateShadowViewMutationsFlattener(
|
||||
BREADCRUMB_TYPE breadcrumb,
|
||||
ViewNodePairScope &scope,
|
||||
ReparentMode reparentMode,
|
||||
OrderedMutationInstructionContainer &mutationContainer,
|
||||
ShadowView const &parentShadowView,
|
||||
TinyMap<Tag, ShadowViewNodePair *> &unvisitedFlattenedNodes,
|
||||
TinyMap<Tag, ShadowViewNodePair *> &unvisitedOtherNodes,
|
||||
ShadowViewNodePair const &node,
|
||||
TinyMap<Tag, ShadowViewNodePair *> *parentSubVisitedOtherNewNodes = nullptr,
|
||||
TinyMap<Tag, ShadowViewNodePair *> *parentSubVisitedOtherOldNodes =
|
||||
@@ -395,12 +390,10 @@ static void calculateShadowViewMutationsFlattener(
|
||||
* the ViewNodePairScope used within.
|
||||
*/
|
||||
static void updateMatchedPairSubtrees(
|
||||
BREADCRUMB_TYPE breadcrumb,
|
||||
ViewNodePairScope &scope,
|
||||
OrderedMutationInstructionContainer &mutationContainer,
|
||||
TinyMap<Tag, ShadowViewNodePair *> &newRemainingPairs,
|
||||
ShadowViewNodePair::NonOwningList &oldChildPairs,
|
||||
ShadowViewNodePair::NonOwningList &newChildPairs,
|
||||
ShadowView const &parentShadowView,
|
||||
ShadowViewNodePair const &oldPair,
|
||||
ShadowViewNodePair const &newPair) {
|
||||
@@ -427,9 +420,6 @@ static void updateMatchedPairSubtrees(
|
||||
// children are visited, so we reuse the `newRemainingPairs`
|
||||
// map.
|
||||
calculateShadowViewMutationsFlattener(
|
||||
DIFF_BREADCRUMB(
|
||||
"Flatten tree " + std::to_string(parentShadowView.tag) +
|
||||
" into list " + std::to_string(oldPair.shadowView.tag)),
|
||||
scope,
|
||||
ReparentMode::Flatten,
|
||||
mutationContainer,
|
||||
@@ -460,9 +450,6 @@ static void updateMatchedPairSubtrees(
|
||||
|
||||
// Unflatten old list into new tree
|
||||
calculateShadowViewMutationsFlattener(
|
||||
DIFF_BREADCRUMB(
|
||||
"Unflatten old list " + std::to_string(parentShadowView.tag) +
|
||||
" into new tree " + std::to_string(newPair.shadowView.tag)),
|
||||
scope,
|
||||
ReparentMode::Unflatten,
|
||||
mutationContainer,
|
||||
@@ -502,8 +489,6 @@ static void updateMatchedPairSubtrees(
|
||||
auto newGrandChildPairs =
|
||||
sliceChildShadowNodeViewPairsFromViewNodePair(newPair, innerScope);
|
||||
calculateShadowViewMutationsV2(
|
||||
DIFF_BREADCRUMB(
|
||||
"Non-trivial update " + std::to_string(oldPair.shadowView.tag)),
|
||||
innerScope,
|
||||
*(newGrandChildPairs.size()
|
||||
? &mutationContainer.downwardMutations
|
||||
@@ -523,7 +508,6 @@ static void updateMatchedPairSubtrees(
|
||||
* correct ordering of INSERT and REMOVE mutations.
|
||||
*/
|
||||
static void updateMatchedPair(
|
||||
BREADCRUMB_TYPE breadcrumb,
|
||||
OrderedMutationInstructionContainer &mutationContainer,
|
||||
bool oldNodeFoundInOrder,
|
||||
bool newNodeFoundInOrder,
|
||||
@@ -618,7 +602,6 @@ static void updateMatchedPair(
|
||||
* **after this function is called**, by the caller.
|
||||
*/
|
||||
static void calculateShadowViewMutationsFlattener(
|
||||
BREADCRUMB_TYPE breadcrumb,
|
||||
ViewNodePairScope &scope,
|
||||
ReparentMode reparentMode,
|
||||
OrderedMutationInstructionContainer &mutationContainer,
|
||||
@@ -845,9 +828,6 @@ static void calculateShadowViewMutationsFlattener(
|
||||
if (oldTreeNodePair.shadowNode != newTreeNodePair.shadowNode) {
|
||||
ViewNodePairScope innerScope{};
|
||||
calculateShadowViewMutationsV2(
|
||||
DIFF_BREADCRUMB(
|
||||
"(Un)Flattener trivial update of " +
|
||||
std::to_string(newTreeNodePair.shadowView.tag)),
|
||||
innerScope,
|
||||
mutationContainer.downwardMutations,
|
||||
newTreeNodePair.shadowView,
|
||||
@@ -867,17 +847,6 @@ static void calculateShadowViewMutationsFlattener(
|
||||
// This is a flatten-flatten, or unflatten-unflatten.
|
||||
if (childReparentMode == reparentMode) {
|
||||
calculateShadowViewMutationsFlattener(
|
||||
DIFF_BREADCRUMB(
|
||||
std::string(
|
||||
reparentMode == ReparentMode::Flatten
|
||||
? "Flatten-Flatten"
|
||||
: "Unflatten-Unflatten") +
|
||||
" new:" +
|
||||
std::to_string(
|
||||
reparentMode == ReparentMode::Flatten
|
||||
? parentShadowView.tag
|
||||
: newTreeNodePair.shadowView.tag) +
|
||||
" old:" + std::to_string(treeChildPair.shadowView.tag)),
|
||||
scope,
|
||||
childReparentMode,
|
||||
mutationContainer,
|
||||
@@ -919,13 +888,6 @@ static void calculateShadowViewMutationsFlattener(
|
||||
// At the end of this loop we still want to know which of these
|
||||
// children are visited, so we reuse the `newRemainingPairs` map.
|
||||
calculateShadowViewMutationsFlattener(
|
||||
DIFF_BREADCRUMB(
|
||||
std::string("Flatten old tree into new list; new:") +
|
||||
std::to_string(
|
||||
reparentMode == ReparentMode::Flatten
|
||||
? parentShadowView.tag
|
||||
: newTreeNodePair.shadowView.tag) +
|
||||
" old:" + std::to_string(oldTreeNodePair.shadowView.tag)),
|
||||
scope,
|
||||
ReparentMode::Flatten,
|
||||
mutationContainer,
|
||||
@@ -941,13 +903,6 @@ static void calculateShadowViewMutationsFlattener(
|
||||
else {
|
||||
// Unflatten old list into new tree
|
||||
calculateShadowViewMutationsFlattener(
|
||||
DIFF_BREADCRUMB(
|
||||
"Unflatten old list into new tree; old:" +
|
||||
std::to_string(
|
||||
reparentMode == ReparentMode::Flatten
|
||||
? parentShadowView.tag
|
||||
: newTreeNodePair.shadowView.tag) +
|
||||
" new:" + std::to_string(newTreeNodePair.shadowView.tag)),
|
||||
scope,
|
||||
ReparentMode::Unflatten,
|
||||
mutationContainer,
|
||||
@@ -1049,9 +1004,6 @@ static void calculateShadowViewMutationsFlattener(
|
||||
if (!treeChildPair.flattened) {
|
||||
ViewNodePairScope innerScope{};
|
||||
calculateShadowViewMutationsV2(
|
||||
DIFF_BREADCRUMB(
|
||||
"Recursively delete tree child pair (flatten case): " +
|
||||
std::to_string(treeChildPair.shadowView.tag)),
|
||||
innerScope,
|
||||
mutationContainer.destructiveDownwardMutations,
|
||||
treeChildPair.shadowView,
|
||||
@@ -1066,9 +1018,6 @@ static void calculateShadowViewMutationsFlattener(
|
||||
if (!treeChildPair.flattened) {
|
||||
ViewNodePairScope innerScope{};
|
||||
calculateShadowViewMutationsV2(
|
||||
DIFF_BREADCRUMB(
|
||||
"Recursively delete tree child pair (unflatten case): " +
|
||||
std::to_string(treeChildPair.shadowView.tag)),
|
||||
innerScope,
|
||||
mutationContainer.downwardMutations,
|
||||
treeChildPair.shadowView,
|
||||
@@ -1081,7 +1030,6 @@ static void calculateShadowViewMutationsFlattener(
|
||||
}
|
||||
|
||||
static void calculateShadowViewMutationsV2(
|
||||
BREADCRUMB_TYPE breadcrumb,
|
||||
ViewNodePairScope &scope,
|
||||
ShadowViewMutation::List &mutations,
|
||||
ShadowView const &parentShadowView,
|
||||
@@ -1177,9 +1125,6 @@ static void calculateShadowViewMutationsV2(
|
||||
auto newGrandChildPairs = sliceChildShadowNodeViewPairsFromViewNodePair(
|
||||
newChildPair, innerScope);
|
||||
calculateShadowViewMutationsV2(
|
||||
DIFF_BREADCRUMB(
|
||||
"Stage 1: Recurse on " +
|
||||
std::to_string(oldChildPair.shadowView.tag)),
|
||||
innerScope,
|
||||
*(newGrandChildPairs.size()
|
||||
? &mutationContainer.downwardMutations
|
||||
@@ -1246,8 +1191,6 @@ static void calculateShadowViewMutationsV2(
|
||||
// subtree starting from the removed view.
|
||||
ViewNodePairScope innerScope{};
|
||||
calculateShadowViewMutationsV2(
|
||||
DIFF_BREADCRUMB(
|
||||
"Trivial delete " + std::to_string(oldChildPair.shadowView.tag)),
|
||||
innerScope,
|
||||
mutationContainer.destructiveDownwardMutations,
|
||||
oldChildPair.shadowView,
|
||||
@@ -1282,8 +1225,6 @@ static void calculateShadowViewMutationsV2(
|
||||
|
||||
ViewNodePairScope innerScope{};
|
||||
calculateShadowViewMutationsV2(
|
||||
DIFF_BREADCRUMB(
|
||||
"Trivial create " + std::to_string(newChildPair.shadowView.tag)),
|
||||
innerScope,
|
||||
mutationContainer.downwardMutations,
|
||||
newChildPair.shadowView,
|
||||
@@ -1304,9 +1245,10 @@ static void calculateShadowViewMutationsV2(
|
||||
// Walk through both lists at the same time
|
||||
// We will perform updates, create+insert, remove+delete, remove+insert
|
||||
// (move) here.
|
||||
size_t oldIndex = lastIndexAfterFirstStage,
|
||||
newIndex = lastIndexAfterFirstStage, newSize = newChildPairs.size(),
|
||||
oldSize = oldChildPairs.size();
|
||||
size_t oldIndex = lastIndexAfterFirstStage;
|
||||
size_t newIndex = lastIndexAfterFirstStage;
|
||||
size_t newSize = newChildPairs.size();
|
||||
size_t oldSize = oldChildPairs.size();
|
||||
while (newIndex < newSize || oldIndex < oldSize) {
|
||||
bool haveNewPair = newIndex < newSize;
|
||||
bool haveOldPair = oldIndex < oldSize;
|
||||
@@ -1333,9 +1275,6 @@ static void calculateShadowViewMutationsV2(
|
||||
});
|
||||
|
||||
updateMatchedPair(
|
||||
DIFF_BREADCRUMB(
|
||||
"Update Matched Pairs (1): " +
|
||||
std::to_string(oldChildPair.shadowView.tag)),
|
||||
mutationContainer,
|
||||
true,
|
||||
true,
|
||||
@@ -1344,14 +1283,10 @@ static void calculateShadowViewMutationsV2(
|
||||
newChildPair);
|
||||
|
||||
updateMatchedPairSubtrees(
|
||||
DIFF_BREADCRUMB(
|
||||
"Update Matched Pair Subtrees (1): " +
|
||||
std::to_string(oldChildPair.shadowView.tag)),
|
||||
scope,
|
||||
mutationContainer,
|
||||
newRemainingPairs,
|
||||
oldChildPairs,
|
||||
newChildPairs,
|
||||
parentShadowView,
|
||||
oldChildPair,
|
||||
newChildPair);
|
||||
@@ -1378,9 +1313,6 @@ static void calculateShadowViewMutationsV2(
|
||||
auto const &newChildPair = *insertedIt->second;
|
||||
|
||||
updateMatchedPair(
|
||||
DIFF_BREADCRUMB(
|
||||
"Update Matched Pairs (2): " +
|
||||
std::to_string(oldChildPair.shadowView.tag)),
|
||||
mutationContainer,
|
||||
true,
|
||||
false,
|
||||
@@ -1389,14 +1321,10 @@ static void calculateShadowViewMutationsV2(
|
||||
newChildPair);
|
||||
|
||||
updateMatchedPairSubtrees(
|
||||
DIFF_BREADCRUMB(
|
||||
"Update Matched Pair Subtrees (2): " +
|
||||
std::to_string(oldChildPair.shadowView.tag)),
|
||||
scope,
|
||||
mutationContainer,
|
||||
newRemainingPairs,
|
||||
oldChildPairs,
|
||||
newChildPairs,
|
||||
parentShadowView,
|
||||
oldChildPair,
|
||||
newChildPair);
|
||||
@@ -1534,9 +1462,6 @@ static void calculateShadowViewMutationsV2(
|
||||
// entire subtree starting from the removed view.
|
||||
ViewNodePairScope innerScope{};
|
||||
calculateShadowViewMutationsV2(
|
||||
DIFF_BREADCRUMB(
|
||||
"Non-trivial delete " +
|
||||
std::to_string(oldChildPair.shadowView.tag)),
|
||||
innerScope,
|
||||
mutationContainer.destructiveDownwardMutations,
|
||||
oldChildPair.shadowView,
|
||||
@@ -1581,9 +1506,6 @@ static void calculateShadowViewMutationsV2(
|
||||
|
||||
ViewNodePairScope innerScope{};
|
||||
calculateShadowViewMutationsV2(
|
||||
DIFF_BREADCRUMB(
|
||||
"Non-trivial create " +
|
||||
std::to_string(newChildPair.shadowView.tag)),
|
||||
innerScope,
|
||||
mutationContainer.downwardMutations,
|
||||
newChildPair.shadowView,
|
||||
@@ -1707,7 +1629,6 @@ ShadowViewMutation::List calculateShadowViewMutations(
|
||||
}
|
||||
|
||||
calculateShadowViewMutationsV2(
|
||||
CREATE_DIFF_BREADCRUMB(oldRootShadowView.tag),
|
||||
innerViewNodePairScope,
|
||||
mutations,
|
||||
ShadowView(oldRootShadowNode),
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
MountingCoordinator::MountingCoordinator(ShadowTreeRevision baseRevision)
|
||||
MountingCoordinator::MountingCoordinator(const ShadowTreeRevision &baseRevision)
|
||||
: surfaceId_(baseRevision.rootShadowNode->getSurfaceId()),
|
||||
baseRevision_(baseRevision),
|
||||
telemetryController_(*this) {
|
||||
@@ -68,7 +68,7 @@ bool MountingCoordinator::waitForTransaction(
|
||||
|
||||
void MountingCoordinator::updateBaseRevision(
|
||||
ShadowTreeRevision const &baseRevision) const {
|
||||
baseRevision_ = std::move(baseRevision);
|
||||
baseRevision_ = baseRevision;
|
||||
}
|
||||
|
||||
void MountingCoordinator::resetLatestRevision() const {
|
||||
|
||||
@@ -40,7 +40,7 @@ class MountingCoordinator final {
|
||||
* The constructor is meant to be used only inside `ShadowTree`, and it's
|
||||
* `public` only to enable using with `std::make_shared<>`.
|
||||
*/
|
||||
MountingCoordinator(ShadowTreeRevision baseRevision);
|
||||
MountingCoordinator(const ShadowTreeRevision &baseRevision);
|
||||
|
||||
/*
|
||||
* Returns the id of the surface that the coordinator belongs to.
|
||||
|
||||
@@ -296,8 +296,8 @@ MountingCoordinator::Shared ShadowTree::getMountingCoordinator() const {
|
||||
}
|
||||
|
||||
CommitStatus ShadowTree::commit(
|
||||
ShadowTreeCommitTransaction transaction,
|
||||
CommitOptions commitOptions) const {
|
||||
const ShadowTreeCommitTransaction &transaction,
|
||||
const CommitOptions &commitOptions) const {
|
||||
SystraceSection s("ShadowTree::commit");
|
||||
|
||||
int attempts = 0;
|
||||
@@ -317,8 +317,8 @@ CommitStatus ShadowTree::commit(
|
||||
}
|
||||
|
||||
CommitStatus ShadowTree::tryCommit(
|
||||
ShadowTreeCommitTransaction transaction,
|
||||
CommitOptions commitOptions) const {
|
||||
const ShadowTreeCommitTransaction &transaction,
|
||||
const CommitOptions &commitOptions) const {
|
||||
SystraceSection s("ShadowTree::tryCommit");
|
||||
|
||||
auto telemetry = TransactionTelemetry{};
|
||||
|
||||
@@ -95,15 +95,15 @@ class ShadowTree final {
|
||||
* The `transaction` function can cancel commit returning `nullptr`.
|
||||
*/
|
||||
CommitStatus tryCommit(
|
||||
ShadowTreeCommitTransaction transaction,
|
||||
CommitOptions commitOptions = {false}) const;
|
||||
const ShadowTreeCommitTransaction &transaction,
|
||||
const CommitOptions &commitOptions = {false}) const;
|
||||
|
||||
/*
|
||||
* Calls `tryCommit` in a loop until it finishes successfully.
|
||||
*/
|
||||
CommitStatus commit(
|
||||
ShadowTreeCommitTransaction transaction,
|
||||
CommitOptions commitOptions = {false}) const;
|
||||
const ShadowTreeCommitTransaction &transaction,
|
||||
const CommitOptions &commitOptions = {false}) const;
|
||||
|
||||
/*
|
||||
* Returns a `ShadowTreeRevision` representing the momentary state of
|
||||
|
||||
@@ -16,8 +16,9 @@ namespace react {
|
||||
static LayoutMetrics layoutMetricsFromShadowNode(ShadowNode const &shadowNode) {
|
||||
auto layoutableShadowNode =
|
||||
traitCast<LayoutableShadowNode const *>(&shadowNode);
|
||||
return layoutableShadowNode ? layoutableShadowNode->getLayoutMetrics()
|
||||
: EmptyLayoutMetrics;
|
||||
return layoutableShadowNode != nullptr
|
||||
? layoutableShadowNode->getLayoutMetrics()
|
||||
: EmptyLayoutMetrics;
|
||||
}
|
||||
|
||||
ShadowView::ShadowView(const ShadowNode &shadowNode)
|
||||
|
||||
@@ -148,19 +148,19 @@ std::vector<DebugStringConvertibleObject> getDebugProps(
|
||||
ShadowViewMutation const &mutation,
|
||||
DebugStringConvertibleOptions options) {
|
||||
return {
|
||||
mutation.oldChildShadowView.componentHandle
|
||||
mutation.oldChildShadowView.componentHandle != 0
|
||||
? DebugStringConvertibleObject{"oldChild",
|
||||
getDebugDescription(
|
||||
mutation.oldChildShadowView,
|
||||
options)}
|
||||
: DebugStringConvertibleObject{},
|
||||
mutation.newChildShadowView.componentHandle
|
||||
mutation.newChildShadowView.componentHandle != 0
|
||||
? DebugStringConvertibleObject{"newChild",
|
||||
getDebugDescription(
|
||||
mutation.newChildShadowView,
|
||||
options)}
|
||||
: DebugStringConvertibleObject{},
|
||||
mutation.parentShadowView.componentHandle
|
||||
mutation.parentShadowView.componentHandle != 0
|
||||
? DebugStringConvertibleObject{"parent",
|
||||
getDebugDescription(
|
||||
mutation.parentShadowView,
|
||||
|
||||
@@ -125,9 +125,9 @@ using ShadowViewMutationList = std::vector<ShadowViewMutation>;
|
||||
|
||||
#if RN_DEBUG_STRING_CONVERTIBLE
|
||||
|
||||
std::string getDebugName(ShadowViewMutation const &object);
|
||||
std::string getDebugName(ShadowViewMutation const &mutation);
|
||||
std::vector<DebugStringConvertibleObject> getDebugProps(
|
||||
ShadowViewMutation const &object,
|
||||
ShadowViewMutation const &mutation,
|
||||
DebugStringConvertibleOptions options);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -67,7 +67,7 @@ bool operator!=(StubView const &lhs, StubView const &rhs) {
|
||||
std::string getDebugName(StubView const &stubView) {
|
||||
return std::string{"Stub"} +
|
||||
std::string{
|
||||
stubView.componentHandle ? stubView.componentName : "[invalid]"};
|
||||
stubView.componentHandle != 0 ? stubView.componentName : "[invalid]"};
|
||||
}
|
||||
|
||||
std::vector<DebugStringConvertibleObject> getDebugProps(
|
||||
@@ -85,7 +85,7 @@ std::vector<DebugStringConvertibleObject> getDebugProps(
|
||||
|
||||
std::vector<StubView> getDebugChildren(
|
||||
StubView const &stubView,
|
||||
DebugStringConvertibleOptions options) {
|
||||
DebugStringConvertibleOptions /*options*/) {
|
||||
std::vector<StubView> result;
|
||||
for (auto const &child : stubView.children) {
|
||||
result.push_back(*child);
|
||||
|
||||
@@ -25,8 +25,8 @@ using namespace facebook::react;
|
||||
class DummyShadowTreeDelegate : public ShadowTreeDelegate {
|
||||
public:
|
||||
RootShadowNode::Unshared shadowTreeWillCommit(
|
||||
ShadowTree const &shadowTree,
|
||||
RootShadowNode::Shared const &oldRootShadowNode,
|
||||
ShadowTree const & /*shadowTree*/,
|
||||
RootShadowNode::Shared const & /*oldRootShadowNode*/,
|
||||
RootShadowNode::Unshared const &newRootShadowNode) const override {
|
||||
return newRootShadowNode;
|
||||
};
|
||||
@@ -108,7 +108,7 @@ TEST(StateReconciliationTest, testStateReconciliation) {
|
||||
contextContainer};
|
||||
|
||||
shadowTree.commit(
|
||||
[&](RootShadowNode const &oldRootShadowNode) {
|
||||
[&](RootShadowNode const & /*oldRootShadowNode*/) {
|
||||
return std::static_pointer_cast<RootShadowNode>(rootShadowNodeState1);
|
||||
},
|
||||
{true});
|
||||
@@ -133,7 +133,7 @@ TEST(StateReconciliationTest, testStateReconciliation) {
|
||||
findDescendantNode(*rootShadowNodeState2, family)->getState(), state2);
|
||||
|
||||
shadowTree.commit(
|
||||
[&](RootShadowNode const &oldRootShadowNode) {
|
||||
[&](RootShadowNode const & /*oldRootShadowNode*/) {
|
||||
return std::static_pointer_cast<RootShadowNode>(rootShadowNodeState2);
|
||||
},
|
||||
{true});
|
||||
@@ -156,7 +156,7 @@ TEST(StateReconciliationTest, testStateReconciliation) {
|
||||
findDescendantNode(*rootShadowNodeState3, family)->getState(), state3);
|
||||
|
||||
shadowTree.commit(
|
||||
[&](RootShadowNode const &oldRootShadowNode) {
|
||||
[&](RootShadowNode const & /*oldRootShadowNode*/) {
|
||||
return std::static_pointer_cast<RootShadowNode>(rootShadowNodeState3);
|
||||
},
|
||||
{true});
|
||||
@@ -171,7 +171,7 @@ TEST(StateReconciliationTest, testStateReconciliation) {
|
||||
// Here we commit the old tree but we expect that the state associated with
|
||||
// the node will stay the same (newer that the old tree has).
|
||||
shadowTree.commit(
|
||||
[&](RootShadowNode const &oldRootShadowNode) {
|
||||
[&](RootShadowNode const & /*oldRootShadowNode*/) {
|
||||
return std::static_pointer_cast<RootShadowNode>(rootShadowNodeState2);
|
||||
},
|
||||
{true});
|
||||
|
||||
@@ -116,7 +116,7 @@ jsi::Value RuntimeSchedulerBinding::get(
|
||||
jsi::Value const *,
|
||||
size_t) noexcept -> jsi::Value {
|
||||
auto shouldYield = runtimeScheduler_->getShouldYield();
|
||||
return jsi::Value(shouldYield);
|
||||
return {shouldYield};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ jsi::Value RuntimeSchedulerBinding::get(
|
||||
auto asDouble =
|
||||
std::chrono::duration<double, std::milli>(now.time_since_epoch())
|
||||
.count();
|
||||
return jsi::Value(asDouble);
|
||||
return {asDouble};
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -52,17 +52,17 @@ class RuntimeSchedulerTest : public testing::Test {
|
||||
jsi::PropNameID::forUtf8(*runtime_, ""),
|
||||
3,
|
||||
[this, callback = std::move(callback)](
|
||||
jsi::Runtime &,
|
||||
jsi::Value const &,
|
||||
jsi::Runtime & /*unused*/,
|
||||
jsi::Value const & /*unused*/,
|
||||
jsi::Value const *arguments,
|
||||
size_t) -> jsi::Value {
|
||||
size_t /*unused*/) -> jsi::Value {
|
||||
++hostFunctionCallCount_;
|
||||
auto didUserCallbackTimeout = arguments[0].getBool();
|
||||
return callback(didUserCallbackTimeout);
|
||||
});
|
||||
}
|
||||
|
||||
uint hostFunctionCallCount_;
|
||||
uint hostFunctionCallCount_{};
|
||||
|
||||
std::unique_ptr<facebook::hermes::HermesRuntime> runtime_;
|
||||
std::unique_ptr<StubClock> stubClock_;
|
||||
@@ -160,8 +160,8 @@ TEST_F(RuntimeSchedulerTest, taskExpiration) {
|
||||
|
||||
TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithSamePriority) {
|
||||
uint firstTaskCallOrder = 0;
|
||||
auto callbackOne =
|
||||
createHostFunctionFromLambda([this, &firstTaskCallOrder](bool) {
|
||||
auto callbackOne = createHostFunctionFromLambda(
|
||||
[this, &firstTaskCallOrder](bool /*unused*/) {
|
||||
firstTaskCallOrder = hostFunctionCallCount_;
|
||||
return jsi::Value::undefined();
|
||||
});
|
||||
@@ -170,8 +170,8 @@ TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithSamePriority) {
|
||||
SchedulerPriority::NormalPriority, std::move(callbackOne));
|
||||
|
||||
uint secondTaskCallOrder;
|
||||
auto callbackTwo =
|
||||
createHostFunctionFromLambda([this, &secondTaskCallOrder](bool) {
|
||||
auto callbackTwo = createHostFunctionFromLambda(
|
||||
[this, &secondTaskCallOrder](bool /*unused*/) {
|
||||
secondTaskCallOrder = hostFunctionCallCount_;
|
||||
return jsi::Value::undefined();
|
||||
});
|
||||
@@ -193,8 +193,8 @@ TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithSamePriority) {
|
||||
|
||||
TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithDifferentPriorities) {
|
||||
uint lowPriorityTaskCallOrder = 0;
|
||||
auto callbackOne =
|
||||
createHostFunctionFromLambda([this, &lowPriorityTaskCallOrder](bool) {
|
||||
auto callbackOne = createHostFunctionFromLambda(
|
||||
[this, &lowPriorityTaskCallOrder](bool /*unused*/) {
|
||||
lowPriorityTaskCallOrder = hostFunctionCallCount_;
|
||||
return jsi::Value::undefined();
|
||||
});
|
||||
@@ -204,7 +204,7 @@ TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithDifferentPriorities) {
|
||||
|
||||
uint userBlockingPriorityTaskCallOrder;
|
||||
auto callbackTwo = createHostFunctionFromLambda(
|
||||
[this, &userBlockingPriorityTaskCallOrder](bool) {
|
||||
[this, &userBlockingPriorityTaskCallOrder](bool /*unused*/) {
|
||||
userBlockingPriorityTaskCallOrder = hostFunctionCallCount_;
|
||||
return jsi::Value::undefined();
|
||||
});
|
||||
@@ -226,7 +226,7 @@ TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithDifferentPriorities) {
|
||||
|
||||
TEST_F(RuntimeSchedulerTest, cancelTask) {
|
||||
bool didRunTask = false;
|
||||
auto callback = createHostFunctionFromLambda([&didRunTask](bool) {
|
||||
auto callback = createHostFunctionFromLambda([&didRunTask](bool /*unused*/) {
|
||||
didRunTask = true;
|
||||
return jsi::Value::undefined();
|
||||
});
|
||||
@@ -249,16 +249,16 @@ TEST_F(RuntimeSchedulerTest, continuationTask) {
|
||||
bool didRunTask = false;
|
||||
bool didContinuationTask = false;
|
||||
|
||||
auto callback = createHostFunctionFromLambda([&](bool) {
|
||||
auto callback = createHostFunctionFromLambda([&](bool /*unused*/) {
|
||||
didRunTask = true;
|
||||
return jsi::Function::createFromHostFunction(
|
||||
*runtime_,
|
||||
jsi::PropNameID::forUtf8(*runtime_, ""),
|
||||
1,
|
||||
[&](jsi::Runtime &runtime,
|
||||
jsi::Value const &,
|
||||
jsi::Value const *arguments,
|
||||
size_t) noexcept -> jsi::Value {
|
||||
[&](jsi::Runtime & /*runtime*/,
|
||||
jsi::Value const & /*unused*/,
|
||||
jsi::Value const * /*arguments*/,
|
||||
size_t /*unused*/) noexcept -> jsi::Value {
|
||||
didContinuationTask = true;
|
||||
return jsi::Value::undefined();
|
||||
});
|
||||
@@ -279,7 +279,7 @@ TEST_F(RuntimeSchedulerTest, continuationTask) {
|
||||
|
||||
TEST_F(RuntimeSchedulerTest, getCurrentPriorityLevel) {
|
||||
auto callback =
|
||||
createHostFunctionFromLambda([this](bool didUserCallbackTimeout) {
|
||||
createHostFunctionFromLambda([this](bool /*didUserCallbackTimeout*/) {
|
||||
EXPECT_EQ(
|
||||
runtimeScheduler_->getCurrentPriorityLevel(),
|
||||
SchedulerPriority::ImmediatePriority);
|
||||
@@ -299,12 +299,13 @@ TEST_F(RuntimeSchedulerTest, getCurrentPriorityLevel) {
|
||||
runtimeScheduler_->getCurrentPriorityLevel(),
|
||||
SchedulerPriority::NormalPriority);
|
||||
|
||||
callback = createHostFunctionFromLambda([this](bool didUserCallbackTimeout) {
|
||||
EXPECT_EQ(
|
||||
runtimeScheduler_->getCurrentPriorityLevel(),
|
||||
SchedulerPriority::IdlePriority);
|
||||
return jsi::Value::undefined();
|
||||
});
|
||||
callback =
|
||||
createHostFunctionFromLambda([this](bool /*didUserCallbackTimeout*/) {
|
||||
EXPECT_EQ(
|
||||
runtimeScheduler_->getCurrentPriorityLevel(),
|
||||
SchedulerPriority::IdlePriority);
|
||||
return jsi::Value::undefined();
|
||||
});
|
||||
|
||||
runtimeScheduler_->scheduleTask(
|
||||
SchedulerPriority::IdlePriority, std::move(callback));
|
||||
@@ -319,7 +320,7 @@ TEST_F(RuntimeSchedulerTest, getCurrentPriorityLevel) {
|
||||
TEST_F(RuntimeSchedulerTest, scheduleWorkWithYielding) {
|
||||
bool wasCalled = false;
|
||||
runtimeScheduler_->scheduleWork(
|
||||
[&](jsi::Runtime const &) { wasCalled = true; });
|
||||
[&](jsi::Runtime const & /*unused*/) { wasCalled = true; });
|
||||
|
||||
EXPECT_FALSE(wasCalled);
|
||||
|
||||
@@ -338,7 +339,7 @@ TEST_F(RuntimeSchedulerTest, normalTaskYieldsToPlatformEvent) {
|
||||
bool didRunJavaScriptTask = false;
|
||||
bool didRunPlatformWork = false;
|
||||
|
||||
auto callback = createHostFunctionFromLambda([&](bool) {
|
||||
auto callback = createHostFunctionFromLambda([&](bool /*unused*/) {
|
||||
didRunJavaScriptTask = true;
|
||||
EXPECT_TRUE(didRunPlatformWork);
|
||||
return jsi::Value::undefined();
|
||||
@@ -347,7 +348,7 @@ TEST_F(RuntimeSchedulerTest, normalTaskYieldsToPlatformEvent) {
|
||||
runtimeScheduler_->scheduleTask(
|
||||
SchedulerPriority::NormalPriority, std::move(callback));
|
||||
|
||||
runtimeScheduler_->scheduleWork([&](jsi::Runtime const &) {
|
||||
runtimeScheduler_->scheduleWork([&](jsi::Runtime const & /*unused*/) {
|
||||
didRunPlatformWork = true;
|
||||
EXPECT_FALSE(didRunJavaScriptTask);
|
||||
EXPECT_FALSE(runtimeScheduler_->getShouldYield());
|
||||
@@ -365,7 +366,7 @@ TEST_F(RuntimeSchedulerTest, expiredTaskDoesntYieldToPlatformEvent) {
|
||||
bool didRunJavaScriptTask = false;
|
||||
bool didRunPlatformWork = false;
|
||||
|
||||
auto callback = createHostFunctionFromLambda([&](bool) {
|
||||
auto callback = createHostFunctionFromLambda([&](bool /*unused*/) {
|
||||
didRunJavaScriptTask = true;
|
||||
EXPECT_FALSE(didRunPlatformWork);
|
||||
return jsi::Value::undefined();
|
||||
@@ -374,7 +375,7 @@ TEST_F(RuntimeSchedulerTest, expiredTaskDoesntYieldToPlatformEvent) {
|
||||
runtimeScheduler_->scheduleTask(
|
||||
SchedulerPriority::NormalPriority, std::move(callback));
|
||||
|
||||
runtimeScheduler_->scheduleWork([&](jsi::Runtime const &) {
|
||||
runtimeScheduler_->scheduleWork([&](jsi::Runtime const & /*unused*/) {
|
||||
didRunPlatformWork = true;
|
||||
EXPECT_TRUE(didRunJavaScriptTask);
|
||||
});
|
||||
@@ -393,7 +394,7 @@ TEST_F(RuntimeSchedulerTest, immediateTaskDoesntYieldToPlatformEvent) {
|
||||
bool didRunJavaScriptTask = false;
|
||||
bool didRunPlatformWork = false;
|
||||
|
||||
auto callback = createHostFunctionFromLambda([&](bool) {
|
||||
auto callback = createHostFunctionFromLambda([&](bool /*unused*/) {
|
||||
didRunJavaScriptTask = true;
|
||||
EXPECT_FALSE(didRunPlatformWork);
|
||||
return jsi::Value::undefined();
|
||||
@@ -402,7 +403,7 @@ TEST_F(RuntimeSchedulerTest, immediateTaskDoesntYieldToPlatformEvent) {
|
||||
runtimeScheduler_->scheduleTask(
|
||||
SchedulerPriority::ImmediatePriority, std::move(callback));
|
||||
|
||||
runtimeScheduler_->scheduleWork([&](jsi::Runtime const &) {
|
||||
runtimeScheduler_->scheduleWork([&](jsi::Runtime const & /*unused*/) {
|
||||
didRunPlatformWork = true;
|
||||
EXPECT_TRUE(didRunJavaScriptTask);
|
||||
});
|
||||
@@ -451,11 +452,12 @@ TEST_F(RuntimeSchedulerTest, scheduleTaskFromTask) {
|
||||
|
||||
TEST_F(RuntimeSchedulerTest, handlingError) {
|
||||
bool didRunTask = false;
|
||||
auto firstCallback = createHostFunctionFromLambda([this, &didRunTask](bool) {
|
||||
didRunTask = true;
|
||||
throw jsi::JSError(*runtime_, "Test error");
|
||||
return jsi::Value::undefined();
|
||||
});
|
||||
auto firstCallback =
|
||||
createHostFunctionFromLambda([this, &didRunTask](bool /*unused*/) {
|
||||
didRunTask = true;
|
||||
throw jsi::JSError(*runtime_, "Test error");
|
||||
return jsi::Value::undefined();
|
||||
});
|
||||
|
||||
runtimeScheduler_->scheduleTask(
|
||||
SchedulerPriority::NormalPriority, std::move(firstCallback));
|
||||
@@ -474,7 +476,7 @@ TEST_F(RuntimeSchedulerTest, basicSameThreadExecution) {
|
||||
bool didRunSynchronousTask = false;
|
||||
std::thread t1([this, &didRunSynchronousTask]() {
|
||||
runtimeScheduler_->executeNowOnTheSameThread(
|
||||
[this, &didRunSynchronousTask](jsi::Runtime &rt) {
|
||||
[this, &didRunSynchronousTask](jsi::Runtime & /*rt*/) {
|
||||
EXPECT_TRUE(runtimeScheduler_->getIsSynchronous());
|
||||
didRunSynchronousTask = true;
|
||||
});
|
||||
@@ -584,11 +586,11 @@ TEST_F(RuntimeSchedulerTest, twoThreadsRequestAccessToTheRuntime) {
|
||||
bool didRunWork = false;
|
||||
|
||||
runtimeScheduler_->scheduleWork(
|
||||
[&didRunWork](jsi::Runtime &) { didRunWork = true; });
|
||||
[&didRunWork](jsi::Runtime & /*unused*/) { didRunWork = true; });
|
||||
|
||||
std::thread t1([this, &didRunSynchronousTask]() {
|
||||
runtimeScheduler_->executeNowOnTheSameThread(
|
||||
[&didRunSynchronousTask](jsi::Runtime &runtime) {
|
||||
[&didRunSynchronousTask](jsi::Runtime & /*runtime*/) {
|
||||
didRunSynchronousTask = true;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ AsynchronousEventBeat::AsynchronousEventBeat(
|
||||
|
||||
void AsynchronousEventBeat::activityDidChange(
|
||||
RunLoopObserver::Delegate const *delegate,
|
||||
RunLoopObserver::Activity) const noexcept {
|
||||
RunLoopObserver::Activity /*activity*/) const noexcept {
|
||||
react_native_assert(delegate == this);
|
||||
induce();
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ Scheduler::Scheduler(
|
||||
runtime, eventTarget, type, priority, payloadFactory);
|
||||
},
|
||||
runtime);
|
||||
if (runtimeScheduler) {
|
||||
if (runtimeScheduler != nullptr) {
|
||||
runtimeScheduler->callExpiredTasks(runtime);
|
||||
}
|
||||
};
|
||||
@@ -295,14 +295,14 @@ void Scheduler::uiManagerDidFinishTransaction(
|
||||
MountingCoordinator::Shared const &mountingCoordinator) {
|
||||
SystraceSection s("Scheduler::uiManagerDidFinishTransaction");
|
||||
|
||||
if (delegate_) {
|
||||
if (delegate_ != nullptr) {
|
||||
delegate_->schedulerDidFinishTransaction(mountingCoordinator);
|
||||
}
|
||||
}
|
||||
void Scheduler::uiManagerDidCreateShadowNode(const ShadowNode &shadowNode) {
|
||||
SystraceSection s("Scheduler::uiManagerDidCreateShadowNode");
|
||||
|
||||
if (delegate_) {
|
||||
if (delegate_ != nullptr) {
|
||||
delegate_->schedulerDidRequestPreliminaryViewAllocation(
|
||||
shadowNode.getSurfaceId(), shadowNode);
|
||||
}
|
||||
@@ -313,7 +313,7 @@ void Scheduler::uiManagerDidCloneShadowNode(
|
||||
const ShadowNode &newShadowNode) {
|
||||
SystraceSection s("Scheduler::uiManagerDidCloneShadowNode");
|
||||
|
||||
if (delegate_) {
|
||||
if (delegate_ != nullptr) {
|
||||
delegate_->schedulerDidCloneShadowNode(
|
||||
newShadowNode.getSurfaceId(), oldShadowNode, newShadowNode);
|
||||
}
|
||||
@@ -325,7 +325,7 @@ void Scheduler::uiManagerDidDispatchCommand(
|
||||
folly::dynamic const &args) {
|
||||
SystraceSection s("Scheduler::uiManagerDispatchCommand");
|
||||
|
||||
if (delegate_) {
|
||||
if (delegate_ != nullptr) {
|
||||
auto shadowView = ShadowView(*shadowNode);
|
||||
delegate_->schedulerDidDispatchCommand(shadowView, commandName, args);
|
||||
}
|
||||
@@ -336,7 +336,7 @@ void Scheduler::uiManagerDidSendAccessibilityEvent(
|
||||
std::string const &eventType) {
|
||||
SystraceSection s("Scheduler::uiManagerDidSendAccessibilityEvent");
|
||||
|
||||
if (delegate_) {
|
||||
if (delegate_ != nullptr) {
|
||||
auto shadowView = ShadowView(*shadowNode);
|
||||
delegate_->schedulerDidSendAccessibilityEvent(shadowView, eventType);
|
||||
}
|
||||
@@ -349,7 +349,7 @@ void Scheduler::uiManagerDidSetIsJSResponder(
|
||||
ShadowNode::Shared const &shadowNode,
|
||||
bool isJSResponder,
|
||||
bool blockNativeResponder) {
|
||||
if (delegate_) {
|
||||
if (delegate_ != nullptr) {
|
||||
delegate_->schedulerDidSetIsJSResponder(
|
||||
ShadowView(*shadowNode), isJSResponder, blockNativeResponder);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ class Scheduler final : public UIManagerDelegate {
|
||||
const ShadowNode::Shared &shadowNode,
|
||||
std::string const &eventType) override;
|
||||
void uiManagerDidSetIsJSResponder(
|
||||
ShadowNode::Shared const &shadowView,
|
||||
ShadowNode::Shared const &shadowNode,
|
||||
bool isJSResponder,
|
||||
bool blockNativeResponder) override;
|
||||
|
||||
|
||||
@@ -283,10 +283,12 @@ void SurfaceHandler::applyDisplayMode(DisplayMode displayMode) const noexcept {
|
||||
link_.shadowTree->setCommitMode(ShadowTree::CommitMode::Suspended);
|
||||
// Committing the current revision back. It will be mounted only when
|
||||
// `DisplayMode` is changed back to `Normal`.
|
||||
link_.shadowTree->commit([&](RootShadowNode const &oldRootShadowNode) {
|
||||
return std::static_pointer_cast<RootShadowNode>(
|
||||
revision.rootShadowNode->ShadowNode::clone(ShadowNodeFragment{}));
|
||||
});
|
||||
link_.shadowTree->commit(
|
||||
[&](RootShadowNode const & /*oldRootShadowNode*/) {
|
||||
return std::static_pointer_cast<RootShadowNode>(
|
||||
revision.rootShadowNode->ShadowNode::clone(
|
||||
ShadowNodeFragment{}));
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -302,7 +304,8 @@ void SurfaceHandler::setUIManager(UIManager const *uiManager) const noexcept {
|
||||
}
|
||||
|
||||
link_.uiManager = uiManager;
|
||||
link_.status = uiManager ? Status::Registered : Status::Unregistered;
|
||||
link_.status =
|
||||
uiManager != nullptr ? Status::Registered : Status::Unregistered;
|
||||
}
|
||||
|
||||
SurfaceHandler::~SurfaceHandler() noexcept {
|
||||
|
||||
@@ -67,7 +67,7 @@ class SurfaceHandler {
|
||||
/*
|
||||
* Movable-only.
|
||||
*/
|
||||
SurfaceHandler(SurfaceHandler &&SurfaceHandler) noexcept;
|
||||
SurfaceHandler(SurfaceHandler &&other) noexcept;
|
||||
SurfaceHandler(SurfaceHandler const &SurfaceHandler) noexcept = delete;
|
||||
SurfaceHandler &operator=(SurfaceHandler &&other) noexcept;
|
||||
SurfaceHandler &operator=(SurfaceHandler const &other) noexcept = delete;
|
||||
|
||||
@@ -28,7 +28,7 @@ SynchronousEventBeat::SynchronousEventBeat(
|
||||
|
||||
void SynchronousEventBeat::activityDidChange(
|
||||
RunLoopObserver::Delegate const *delegate,
|
||||
RunLoopObserver::Activity activity) const noexcept {
|
||||
RunLoopObserver::Activity /*activity*/) const noexcept {
|
||||
react_native_assert(delegate == this);
|
||||
lockExecutorAndBeat();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class UITemplateProcessor {
|
||||
public:
|
||||
static ShadowNode::Shared buildShadowTree(
|
||||
const std::string &jsonStr,
|
||||
int rootTag,
|
||||
int surfaceId,
|
||||
const folly::dynamic ¶ms,
|
||||
const ComponentDescriptorRegistry &componentDescriptorRegistry,
|
||||
const NativeModuleRegistry &nativeModuleRegistry,
|
||||
@@ -55,7 +55,7 @@ class UITemplateProcessor {
|
||||
private:
|
||||
static ShadowNode::Shared runCommand(
|
||||
const folly::dynamic &command,
|
||||
Tag rootTag,
|
||||
Tag surfaceId,
|
||||
std::vector<ShadowNode::Shared> &nodes,
|
||||
std::vector<folly::dynamic> ®isters,
|
||||
const ComponentDescriptorRegistry &componentDescriptorRegistry,
|
||||
|
||||
@@ -48,7 +48,8 @@ NativeModuleRegistry buildNativeModuleRegistry();
|
||||
NativeModuleRegistry buildNativeModuleRegistry() {
|
||||
NativeModuleRegistry nMR;
|
||||
nMR.registerModule(
|
||||
"MobileConfig", [&](const std::string &, const folly::dynamic &) {
|
||||
"MobileConfig",
|
||||
[&](const std::string & /*unused*/, const folly::dynamic & /*unused*/) {
|
||||
return mockSimpleTestValue_;
|
||||
});
|
||||
return nMR;
|
||||
@@ -57,19 +58,19 @@ NativeModuleRegistry buildNativeModuleRegistry() {
|
||||
class MockReactNativeConfig : public ReactNativeConfig {
|
||||
public:
|
||||
MockReactNativeConfig() = default;
|
||||
bool getBool(const std::string ¶m) const override {
|
||||
bool getBool(const std::string & /*param*/) const override {
|
||||
return mockSimpleTestValue_;
|
||||
}
|
||||
|
||||
std::string getString(const std::string &) const override {
|
||||
std::string getString(const std::string & /*param*/) const override {
|
||||
return "";
|
||||
}
|
||||
|
||||
int64_t getInt64(const std::string &) const override {
|
||||
int64_t getInt64(const std::string & /*param*/) const override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
double getDouble(const std::string &) const override {
|
||||
double getDouble(const std::string & /*param*/) const override {
|
||||
return 0.0;
|
||||
}
|
||||
};
|
||||
|
||||
+3
-3
@@ -166,9 +166,9 @@ TextMeasurement TextLayoutManager::measure(
|
||||
|
||||
auto measurement = measureCache_.get(
|
||||
{attributedString, paragraphAttributes, layoutConstraints},
|
||||
[&](TextMeasureCacheKey const &key) {
|
||||
[&](TextMeasureCacheKey const & /*key*/) {
|
||||
auto telemetry = TransactionTelemetry::threadLocalTelemetry();
|
||||
if (telemetry) {
|
||||
if (telemetry != nullptr) {
|
||||
telemetry->willMeasureText();
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ TextMeasurement TextLayoutManager::measure(
|
||||
: doMeasure(
|
||||
attributedString, paragraphAttributes, layoutConstraints);
|
||||
|
||||
if (telemetry) {
|
||||
if (telemetry != nullptr) {
|
||||
telemetry->didMeasureText();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@ class TextLayoutManager {
|
||||
ParagraphAttributes const ¶graphAttributes,
|
||||
Size size) const;
|
||||
|
||||
void *self_;
|
||||
void *self_{};
|
||||
ContextContainer::Shared contextContainer_;
|
||||
bool mapBufferSerializationEnabled_;
|
||||
TextMeasureCache measureCache_;
|
||||
|
||||
@@ -31,7 +31,7 @@ void Timeline::pause() const noexcept {
|
||||
void Timeline::resume() const noexcept {
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
if (snapshots_.size() > 0) {
|
||||
if (!snapshots_.empty()) {
|
||||
rewind(snapshots_.at(snapshots_.size() - 1));
|
||||
}
|
||||
|
||||
@@ -66,8 +66,8 @@ void Timeline::rewind(TimelineFrame const &frame) const noexcept {
|
||||
}
|
||||
|
||||
RootShadowNode::Unshared Timeline::shadowTreeWillCommit(
|
||||
ShadowTree const &shadowTree,
|
||||
RootShadowNode::Shared const &oldRootShadowNode,
|
||||
ShadowTree const & /*shadowTree*/,
|
||||
RootShadowNode::Shared const & /*oldRootShadowNode*/,
|
||||
RootShadowNode::Unshared const &newRootShadowNode) const noexcept {
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
@@ -107,7 +107,8 @@ void Timeline::rewind(TimelineSnapshot const &snapshot) const noexcept {
|
||||
auto rootShadowNode = snapshot.getRootShadowNode();
|
||||
|
||||
shadowTree_->commit(
|
||||
[&](RootShadowNode const &oldRootShadowNode) -> RootShadowNode::Unshared {
|
||||
[&](RootShadowNode const & /*oldRootShadowNode*/)
|
||||
-> RootShadowNode::Unshared {
|
||||
return std::static_pointer_cast<RootShadowNode>(
|
||||
rootShadowNode->ShadowNode::clone({}));
|
||||
});
|
||||
|
||||
@@ -49,7 +49,7 @@ void TimelineController::commitHookWasRegistered(
|
||||
}
|
||||
|
||||
void TimelineController::commitHookWasUnregistered(
|
||||
UIManager const &uiManager) const noexcept {
|
||||
UIManager const & /*uiManager*/) const noexcept {
|
||||
uiManager_ = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ void TimelineHandler::release() noexcept {
|
||||
}
|
||||
|
||||
void TimelineHandler::ensureNotEmpty() const noexcept {
|
||||
if (!timeline_) {
|
||||
if (timeline_ == nullptr) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class TimelineHandler final {
|
||||
/*
|
||||
* Movable, not copyable.
|
||||
*/
|
||||
TimelineHandler(TimelineHandler &&timelineHandler) noexcept;
|
||||
TimelineHandler(TimelineHandler &&other) noexcept;
|
||||
TimelineHandler(TimelineHandler const &timelineHandler) = delete;
|
||||
TimelineHandler &operator=(TimelineHandler &&other) noexcept;
|
||||
TimelineHandler &operator=(TimelineHandler const &other) = delete;
|
||||
@@ -73,7 +73,7 @@ class TimelineHandler final {
|
||||
|
||||
void ensureNotEmpty() const noexcept;
|
||||
|
||||
Timeline const *timeline_;
|
||||
Timeline const *timeline_{};
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
||||
@@ -90,7 +90,7 @@ ShadowNode::Shared UIManager::createNode(
|
||||
},
|
||||
family);
|
||||
|
||||
if (delegate_) {
|
||||
if (delegate_ != nullptr) {
|
||||
delegate_->uiManagerDidCreateShadowNode(*shadowNode);
|
||||
}
|
||||
if (leakChecker_) {
|
||||
@@ -114,13 +114,14 @@ ShadowNode::Shared UIManager::cloneNode(
|
||||
shadowNode,
|
||||
{
|
||||
/* .props = */
|
||||
rawProps ? componentDescriptor.cloneProps(
|
||||
propsParserContext, shadowNode.getProps(), *rawProps)
|
||||
: ShadowNodeFragment::propsPlaceholder(),
|
||||
rawProps != nullptr
|
||||
? componentDescriptor.cloneProps(
|
||||
propsParserContext, shadowNode.getProps(), *rawProps)
|
||||
: ShadowNodeFragment::propsPlaceholder(),
|
||||
/* .children = */ children,
|
||||
});
|
||||
|
||||
if (delegate_) {
|
||||
if (delegate_ != nullptr) {
|
||||
delegate_->uiManagerDidCloneShadowNode(shadowNode, *clonedShadowNode);
|
||||
}
|
||||
|
||||
@@ -160,7 +161,7 @@ void UIManager::setIsJSResponder(
|
||||
ShadowNode::Shared const &shadowNode,
|
||||
bool isJSResponder,
|
||||
bool blockNativeResponder) const {
|
||||
if (delegate_) {
|
||||
if (delegate_ != nullptr) {
|
||||
delegate_->uiManagerDidSetIsJSResponder(
|
||||
shadowNode, isJSResponder, blockNativeResponder);
|
||||
}
|
||||
@@ -260,7 +261,7 @@ LayoutMetrics UIManager::getRelativeLayoutMetrics(
|
||||
// that the node is not deallocated during method execution lifetime.
|
||||
auto owningAncestorShadowNode = ShadowNode::Shared{};
|
||||
|
||||
if (!ancestorShadowNode) {
|
||||
if (ancestorShadowNode == nullptr) {
|
||||
shadowTreeRegistry_.visit(
|
||||
shadowNode.getSurfaceId(), [&](ShadowTree const &shadowTree) {
|
||||
owningAncestorShadowNode =
|
||||
@@ -278,7 +279,7 @@ LayoutMetrics UIManager::getRelativeLayoutMetrics(
|
||||
auto layoutableAncestorShadowNode =
|
||||
traitCast<LayoutableShadowNode const *>(ancestorShadowNode);
|
||||
|
||||
if (!layoutableAncestorShadowNode) {
|
||||
if (layoutableAncestorShadowNode == nullptr) {
|
||||
return EmptyLayoutMetrics;
|
||||
}
|
||||
|
||||
@@ -328,7 +329,7 @@ void UIManager::dispatchCommand(
|
||||
const ShadowNode::Shared &shadowNode,
|
||||
std::string const &commandName,
|
||||
folly::dynamic const &args) const {
|
||||
if (delegate_) {
|
||||
if (delegate_ != nullptr) {
|
||||
delegate_->uiManagerDidDispatchCommand(shadowNode, commandName, args);
|
||||
}
|
||||
}
|
||||
@@ -336,7 +337,7 @@ void UIManager::dispatchCommand(
|
||||
void UIManager::sendAccessibilityEvent(
|
||||
const ShadowNode::Shared &shadowNode,
|
||||
std::string const &eventType) {
|
||||
if (delegate_) {
|
||||
if (delegate_ != nullptr) {
|
||||
delegate_->uiManagerDidSendAccessibilityEvent(shadowNode, eventType);
|
||||
}
|
||||
}
|
||||
@@ -346,7 +347,7 @@ void UIManager::configureNextLayoutAnimation(
|
||||
RawValue const &config,
|
||||
jsi::Value const &successCallback,
|
||||
jsi::Value const &failureCallback) const {
|
||||
if (animationDelegate_) {
|
||||
if (animationDelegate_ != nullptr) {
|
||||
animationDelegate_->uiManagerDidConfigureNextLayoutAnimation(
|
||||
runtime,
|
||||
config,
|
||||
@@ -420,11 +421,11 @@ RootShadowNode::Unshared UIManager::shadowTreeWillCommit(
|
||||
}
|
||||
|
||||
void UIManager::shadowTreeDidFinishTransaction(
|
||||
ShadowTree const &shadowTree,
|
||||
ShadowTree const & /*shadowTree*/,
|
||||
MountingCoordinator::Shared const &mountingCoordinator) const {
|
||||
SystraceSection s("UIManager::shadowTreeDidFinishTransaction");
|
||||
|
||||
if (delegate_) {
|
||||
if (delegate_ != nullptr) {
|
||||
delegate_->uiManagerDidFinishTransaction(mountingCoordinator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ class UIManager final : public ShadowTreeDelegate {
|
||||
jsi::Value const &failureCallback) const;
|
||||
|
||||
SharedComponentDescriptorRegistry componentDescriptorRegistry_;
|
||||
UIManagerDelegate *delegate_;
|
||||
UIManagerDelegate *delegate_{};
|
||||
UIManagerAnimationDelegate *animationDelegate_{nullptr};
|
||||
RuntimeExecutor const runtimeExecutor_{};
|
||||
ShadowTreeRegistry shadowTreeRegistry_{};
|
||||
|
||||
@@ -107,7 +107,7 @@ void UIManagerBinding::dispatchEvent(
|
||||
return;
|
||||
}
|
||||
|
||||
auto instanceHandle = eventTarget
|
||||
auto instanceHandle = eventTarget != nullptr
|
||||
? [&]() {
|
||||
auto instanceHandle = eventTarget->getInstanceHandle(runtime);
|
||||
if (instanceHandle.isUndefined()) {
|
||||
@@ -187,9 +187,9 @@ jsi::Value UIManagerBinding::get(
|
||||
5,
|
||||
[uiManager](
|
||||
jsi::Runtime &runtime,
|
||||
jsi::Value const &thisValue,
|
||||
jsi::Value const & /*thisValue*/,
|
||||
jsi::Value const *arguments,
|
||||
size_t count) noexcept -> jsi::Value {
|
||||
size_t /*count*/) noexcept -> jsi::Value {
|
||||
auto eventTarget =
|
||||
eventTargetFromValue(runtime, arguments[4], arguments[0]);
|
||||
if (!eventTarget) {
|
||||
@@ -215,9 +215,9 @@ jsi::Value UIManagerBinding::get(
|
||||
1,
|
||||
[uiManager](
|
||||
jsi::Runtime &runtime,
|
||||
jsi::Value const &thisValue,
|
||||
jsi::Value const & /*thisValue*/,
|
||||
jsi::Value const *arguments,
|
||||
size_t count) noexcept -> jsi::Value {
|
||||
size_t /*count*/) noexcept -> jsi::Value {
|
||||
return valueFromShadowNode(
|
||||
runtime,
|
||||
uiManager->cloneNode(
|
||||
@@ -232,9 +232,9 @@ jsi::Value UIManagerBinding::get(
|
||||
2,
|
||||
[uiManager](
|
||||
jsi::Runtime &runtime,
|
||||
jsi::Value const &thisValue,
|
||||
jsi::Value const & /*thisValue*/,
|
||||
jsi::Value const *arguments,
|
||||
size_t count) noexcept -> jsi::Value {
|
||||
size_t /*count*/) noexcept -> jsi::Value {
|
||||
uiManager->setIsJSResponder(
|
||||
shadowNodeFromValue(runtime, arguments[0]),
|
||||
arguments[1].getBool(),
|
||||
@@ -251,9 +251,9 @@ jsi::Value UIManagerBinding::get(
|
||||
2,
|
||||
[uiManager](
|
||||
jsi::Runtime &runtime,
|
||||
jsi::Value const &thisValue,
|
||||
jsi::Value const & /*thisValue*/,
|
||||
jsi::Value const *arguments,
|
||||
size_t count) noexcept -> jsi::Value {
|
||||
size_t /*count*/) noexcept -> jsi::Value {
|
||||
auto node = shadowNodeFromValue(runtime, arguments[0]);
|
||||
auto locationX = (Float)arguments[1].getNumber();
|
||||
auto locationY = (Float)arguments[2].getNumber();
|
||||
@@ -282,9 +282,9 @@ jsi::Value UIManagerBinding::get(
|
||||
1,
|
||||
[uiManager](
|
||||
jsi::Runtime &runtime,
|
||||
jsi::Value const &thisValue,
|
||||
jsi::Value const & /*thisValue*/,
|
||||
jsi::Value const *arguments,
|
||||
size_t count) noexcept -> jsi::Value {
|
||||
size_t /*count*/) noexcept -> jsi::Value {
|
||||
return valueFromShadowNode(
|
||||
runtime,
|
||||
uiManager->cloneNode(
|
||||
@@ -301,9 +301,9 @@ jsi::Value UIManagerBinding::get(
|
||||
2,
|
||||
[uiManager](
|
||||
jsi::Runtime &runtime,
|
||||
jsi::Value const &thisValue,
|
||||
jsi::Value const & /*thisValue*/,
|
||||
jsi::Value const *arguments,
|
||||
size_t count) noexcept -> jsi::Value {
|
||||
size_t /*count*/) noexcept -> jsi::Value {
|
||||
auto const &rawProps = RawProps(runtime, arguments[1]);
|
||||
return valueFromShadowNode(
|
||||
runtime,
|
||||
@@ -322,9 +322,9 @@ jsi::Value UIManagerBinding::get(
|
||||
2,
|
||||
[uiManager](
|
||||
jsi::Runtime &runtime,
|
||||
jsi::Value const &thisValue,
|
||||
jsi::Value const & /*thisValue*/,
|
||||
jsi::Value const *arguments,
|
||||
size_t count) noexcept -> jsi::Value {
|
||||
size_t /*count*/) noexcept -> jsi::Value {
|
||||
auto const &rawProps = RawProps(runtime, arguments[1]);
|
||||
return valueFromShadowNode(
|
||||
runtime,
|
||||
@@ -342,9 +342,9 @@ jsi::Value UIManagerBinding::get(
|
||||
2,
|
||||
[uiManager](
|
||||
jsi::Runtime &runtime,
|
||||
jsi::Value const &thisValue,
|
||||
jsi::Value const & /*thisValue*/,
|
||||
jsi::Value const *arguments,
|
||||
size_t count) noexcept -> jsi::Value {
|
||||
size_t /*count*/) noexcept -> jsi::Value {
|
||||
uiManager->appendChild(
|
||||
shadowNodeFromValue(runtime, arguments[0]),
|
||||
shadowNodeFromValue(runtime, arguments[1]));
|
||||
@@ -358,9 +358,9 @@ jsi::Value UIManagerBinding::get(
|
||||
name,
|
||||
1,
|
||||
[](jsi::Runtime &runtime,
|
||||
jsi::Value const &thisValue,
|
||||
jsi::Value const *arguments,
|
||||
size_t count) noexcept -> jsi::Value {
|
||||
jsi::Value const & /*thisValue*/,
|
||||
jsi::Value const * /*arguments*/,
|
||||
size_t /*count*/) noexcept -> jsi::Value {
|
||||
auto shadowNodeList = std::make_shared<ShadowNode::ListOfShared>(
|
||||
ShadowNode::ListOfShared({}));
|
||||
return valueFromShadowNodeList(runtime, shadowNodeList);
|
||||
@@ -373,9 +373,9 @@ jsi::Value UIManagerBinding::get(
|
||||
name,
|
||||
2,
|
||||
[](jsi::Runtime &runtime,
|
||||
jsi::Value const &thisValue,
|
||||
jsi::Value const & /*thisValue*/,
|
||||
jsi::Value const *arguments,
|
||||
size_t count) noexcept -> jsi::Value {
|
||||
size_t /*count*/) noexcept -> jsi::Value {
|
||||
auto shadowNodeList = shadowNodeListFromValue(runtime, arguments[0]);
|
||||
auto shadowNode = shadowNodeFromValue(runtime, arguments[1]);
|
||||
shadowNodeList->push_back(shadowNode);
|
||||
@@ -393,9 +393,9 @@ jsi::Value UIManagerBinding::get(
|
||||
2,
|
||||
[weakUIManager, uiManager](
|
||||
jsi::Runtime &runtime,
|
||||
jsi::Value const &thisValue,
|
||||
jsi::Value const & /*thisValue*/,
|
||||
jsi::Value const *arguments,
|
||||
size_t count) noexcept -> jsi::Value {
|
||||
size_t /*count*/) noexcept -> jsi::Value {
|
||||
auto runtimeSchedulerBinding =
|
||||
RuntimeSchedulerBinding::getBinding(runtime);
|
||||
auto surfaceId = surfaceIdFromValue(runtime, arguments[0]);
|
||||
@@ -449,9 +449,9 @@ jsi::Value UIManagerBinding::get(
|
||||
1,
|
||||
[this](
|
||||
jsi::Runtime &runtime,
|
||||
jsi::Value const &thisValue,
|
||||
jsi::Value const & /*thisValue*/,
|
||||
jsi::Value const *arguments,
|
||||
size_t count) noexcept -> jsi::Value {
|
||||
size_t /*count*/) noexcept -> jsi::Value {
|
||||
auto eventHandler =
|
||||
arguments[0].getObject(runtime).getFunction(runtime);
|
||||
eventHandler_ =
|
||||
@@ -467,9 +467,9 @@ jsi::Value UIManagerBinding::get(
|
||||
2,
|
||||
[uiManager](
|
||||
jsi::Runtime &runtime,
|
||||
jsi::Value const &thisValue,
|
||||
jsi::Value const & /*thisValue*/,
|
||||
jsi::Value const *arguments,
|
||||
size_t count) noexcept -> jsi::Value {
|
||||
size_t /*count*/) noexcept -> jsi::Value {
|
||||
auto layoutMetrics = uiManager->getRelativeLayoutMetrics(
|
||||
*shadowNodeFromValue(runtime, arguments[0]),
|
||||
shadowNodeFromValue(runtime, arguments[1]).get(),
|
||||
@@ -491,9 +491,9 @@ jsi::Value UIManagerBinding::get(
|
||||
3,
|
||||
[uiManager](
|
||||
jsi::Runtime &runtime,
|
||||
jsi::Value const &thisValue,
|
||||
jsi::Value const & /*thisValue*/,
|
||||
jsi::Value const *arguments,
|
||||
size_t count) noexcept -> jsi::Value {
|
||||
size_t /*count*/) noexcept -> jsi::Value {
|
||||
auto shadowNode = shadowNodeFromValue(runtime, arguments[0]);
|
||||
if (shadowNode) {
|
||||
uiManager->dispatchCommand(
|
||||
@@ -513,9 +513,9 @@ jsi::Value UIManagerBinding::get(
|
||||
4,
|
||||
[uiManager](
|
||||
jsi::Runtime &runtime,
|
||||
jsi::Value const &thisValue,
|
||||
jsi::Value const & /*thisValue*/,
|
||||
jsi::Value const *arguments,
|
||||
size_t count) noexcept -> jsi::Value {
|
||||
size_t /*count*/) noexcept -> jsi::Value {
|
||||
auto layoutMetrics = uiManager->getRelativeLayoutMetrics(
|
||||
*shadowNodeFromValue(runtime, arguments[0]),
|
||||
shadowNodeFromValue(runtime, arguments[1]).get(),
|
||||
@@ -549,9 +549,9 @@ jsi::Value UIManagerBinding::get(
|
||||
2,
|
||||
[uiManager](
|
||||
jsi::Runtime &runtime,
|
||||
jsi::Value const &thisValue,
|
||||
jsi::Value const & /*thisValue*/,
|
||||
jsi::Value const *arguments,
|
||||
size_t count) noexcept -> jsi::Value {
|
||||
size_t /*count*/) noexcept -> jsi::Value {
|
||||
auto shadowNode = shadowNodeFromValue(runtime, arguments[0]);
|
||||
auto layoutMetrics = uiManager->getRelativeLayoutMetrics(
|
||||
*shadowNode, nullptr, {/* .includeTransform = */ true});
|
||||
@@ -567,7 +567,7 @@ jsi::Value UIManagerBinding::get(
|
||||
|
||||
auto layoutableShadowNode = traitCast<LayoutableShadowNode const *>(
|
||||
newestCloneOfShadowNode.get());
|
||||
Point originRelativeToParent = layoutableShadowNode
|
||||
Point originRelativeToParent = layoutableShadowNode != nullptr
|
||||
? layoutableShadowNode->getLayoutMetrics().frame.origin
|
||||
: Point();
|
||||
|
||||
@@ -591,9 +591,9 @@ jsi::Value UIManagerBinding::get(
|
||||
2,
|
||||
[uiManager](
|
||||
jsi::Runtime &runtime,
|
||||
jsi::Value const &thisValue,
|
||||
jsi::Value const & /*thisValue*/,
|
||||
jsi::Value const *arguments,
|
||||
size_t count) noexcept -> jsi::Value {
|
||||
size_t /*count*/) noexcept -> jsi::Value {
|
||||
auto layoutMetrics = uiManager->getRelativeLayoutMetrics(
|
||||
*shadowNodeFromValue(runtime, arguments[0]),
|
||||
nullptr,
|
||||
@@ -626,9 +626,9 @@ jsi::Value UIManagerBinding::get(
|
||||
2,
|
||||
[uiManager](
|
||||
jsi::Runtime &runtime,
|
||||
jsi::Value const &thisValue,
|
||||
jsi::Value const & /*thisValue*/,
|
||||
jsi::Value const *arguments,
|
||||
size_t count) noexcept -> jsi::Value {
|
||||
size_t /*count*/) noexcept -> jsi::Value {
|
||||
uiManager->sendAccessibilityEvent(
|
||||
shadowNodeFromValue(runtime, arguments[0]),
|
||||
stringFromValue(runtime, arguments[1]));
|
||||
@@ -644,9 +644,9 @@ jsi::Value UIManagerBinding::get(
|
||||
3,
|
||||
[uiManager](
|
||||
jsi::Runtime &runtime,
|
||||
jsi::Value const &thisValue,
|
||||
jsi::Value const & /*thisValue*/,
|
||||
jsi::Value const *arguments,
|
||||
size_t count) noexcept -> jsi::Value {
|
||||
size_t /*count*/) noexcept -> jsi::Value {
|
||||
uiManager->configureNextLayoutAnimation(
|
||||
runtime,
|
||||
// TODO: pass in JSI value instead of folly::dynamic to RawValue
|
||||
@@ -667,16 +667,16 @@ jsi::Value UIManagerBinding::get(
|
||||
jsi::Value const &,
|
||||
jsi::Value const *,
|
||||
size_t) noexcept -> jsi::Value {
|
||||
return jsi::Value(serialize(currentEventPriority_));
|
||||
return {serialize(currentEventPriority_)};
|
||||
});
|
||||
}
|
||||
|
||||
if (methodName == "unstable_DefaultEventPriority") {
|
||||
return jsi::Value(serialize(ReactEventPriority::Default));
|
||||
return {serialize(ReactEventPriority::Default)};
|
||||
}
|
||||
|
||||
if (methodName == "unstable_DiscreteEventPriority") {
|
||||
return jsi::Value(serialize(ReactEventPriority::Discrete));
|
||||
return {serialize(ReactEventPriority::Discrete)};
|
||||
}
|
||||
|
||||
return jsi::Value::undefined();
|
||||
|
||||
Reference in new issue
Block a user