From 5b2ea6ec6ab8cecad35d6309ceec3853aa37b0a3 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Mon, 27 Jan 2020 13:17:01 -0800 Subject: [PATCH] Fabric: Remove const qualifier from all fields of `ViewProps` and `Props` Summary: This is a part of migration staterted in D19390813. There is no need to have those as `const`. The whole `*Props` object is usually `const` (and when it's not, props should not be too). Changelog: [Internal] Fabric-specific internal change. Reviewed By: mdvacca Differential Revision: D19583582 fbshipit-source-id: 9c680268f944cdf08669fce7e997b05f23a02667 --- .../fabric/components/view/ViewProps.h | 34 +++++++++---------- ReactCommon/fabric/core/shadownode/Props.h | 2 +- .../fabric/element/tests/ElementTest.cpp | 18 +++++----- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/ReactCommon/fabric/components/view/ViewProps.h b/ReactCommon/fabric/components/view/ViewProps.h index b6740b830f2..a185e84fafe 100644 --- a/ReactCommon/fabric/components/view/ViewProps.h +++ b/ReactCommon/fabric/components/view/ViewProps.h @@ -34,33 +34,33 @@ class ViewProps : public Props, #pragma mark - Props // Color - Float const opacity{1.0}; - SharedColor const foregroundColor{}; - SharedColor const backgroundColor{}; + Float opacity{1.0}; + SharedColor foregroundColor{}; + SharedColor backgroundColor{}; // Borders - CascadedBorderRadii const borderRadii{}; - CascadedBorderColors const borderColors{}; - CascadedBorderStyles const borderStyles{}; + CascadedBorderRadii borderRadii{}; + CascadedBorderColors borderColors{}; + CascadedBorderStyles borderStyles{}; // Shadow - SharedColor const shadowColor{}; - Size const shadowOffset{}; - Float const shadowOpacity{}; - Float const shadowRadius{}; + SharedColor shadowColor{}; + Size shadowOffset{}; + Float shadowOpacity{}; + Float shadowRadius{}; // Transform Transform transform{}; - BackfaceVisibility const backfaceVisibility{}; - bool const shouldRasterize{}; - int const zIndex{}; + BackfaceVisibility backfaceVisibility{}; + bool shouldRasterize{}; + int zIndex{}; // Events - PointerEventsMode const pointerEvents{}; - EdgeInsets const hitSlop{}; - bool const onLayout{}; + PointerEventsMode pointerEvents{}; + EdgeInsets hitSlop{}; + bool onLayout{}; - bool const collapsable{true}; + bool collapsable{true}; #pragma mark - Convenience Methods diff --git a/ReactCommon/fabric/core/shadownode/Props.h b/ReactCommon/fabric/core/shadownode/Props.h index 0816b1c49a5..340041448c7 100644 --- a/ReactCommon/fabric/core/shadownode/Props.h +++ b/ReactCommon/fabric/core/shadownode/Props.h @@ -31,7 +31,7 @@ class Props : public virtual Sealable, public virtual DebugStringConvertible { Props(Props const &sourceProps, RawProps const &rawProps); virtual ~Props() = default; - std::string const nativeId; + std::string nativeId; /* * Special value that represents generation number of `Props` object, which diff --git a/ReactCommon/fabric/element/tests/ElementTest.cpp b/ReactCommon/fabric/element/tests/ElementTest.cpp index 43f5d487c2a..8c838eb5c74 100644 --- a/ReactCommon/fabric/element/tests/ElementTest.cpp +++ b/ReactCommon/fabric/element/tests/ElementTest.cpp @@ -33,8 +33,8 @@ TEST(ElementTest, testNormalCases) { auto shadowNodeAB = std::shared_ptr{}; auto shadowNodeABA = std::shared_ptr{}; - auto propsAA = std::make_shared(); - const_cast(propsAA->nativeId) = "node AA"; + auto propsAA = std::make_shared(); + propsAA->nativeId = "node AA"; // clang-format off auto element = @@ -42,9 +42,9 @@ TEST(ElementTest, testNormalCases) { .reference(shadowNodeA) .tag(1) .props([]() { - auto props = std::make_shared(); - const_cast(props->zIndex) = 42; - const_cast(props->nativeId) = "node A"; + auto props = std::make_shared(); + props->zIndex = 42; + props->nativeId = "node A"; return props; }) .finalize([](ViewShadowNode &shadowNode){ @@ -59,8 +59,8 @@ TEST(ElementTest, testNormalCases) { .reference(shadowNodeAB) .tag(3) .props([]() { - auto props = std::make_shared(); - const_cast(props->nativeId) = "node AB"; + auto props = std::make_shared(); + props->nativeId = "node AB"; return props; }) .children({ @@ -68,8 +68,8 @@ TEST(ElementTest, testNormalCases) { .reference(shadowNodeABA) .tag(4) .props([]() { - auto props = std::make_shared(); - const_cast(props->nativeId) = "node ABA"; + auto props = std::make_shared(); + props->nativeId = "node ABA"; return props; }) })