forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fabric/Text: text module, rawtext part
Summary: <RawText> component represents a purely regular string object in React. Reviewed By: mdvacca Differential Revision: D7751850 fbshipit-source-id: 54afe43e0c1ac063862f109ea07f0e7de3593573
- Loading branch information
1 parent
05890a5
commit 02c3cd4
Showing
8 changed files
with
273 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
load("//configurations/buck/apple:flag_defs.bzl", "get_debug_preprocessor_flags", "get_fbobjc_enable_exception_lang_compiler_flags") | ||
load("//ReactNative:DEFS.bzl", "IS_OSS_BUILD", "react_native_xplat_target", "rn_xplat_cxx_library", "get_apple_inspector_flags", "APPLE") | ||
|
||
APPLE_COMPILER_FLAGS = [] | ||
|
||
if not IS_OSS_BUILD: | ||
load("@xplat//configurations/buck/apple:flag_defs.bzl", "get_static_library_ios_flags", "flags") | ||
APPLE_COMPILER_FLAGS = flags.get_flag_value(get_static_library_ios_flags(), 'compiler_flags') | ||
|
||
rn_xplat_cxx_library( | ||
name = "text", | ||
srcs = glob( | ||
["**/*.cpp"], | ||
excludes = glob(["tests/**/*.cpp"]), | ||
), | ||
headers = glob( | ||
["**/*.h"], | ||
excludes = glob(["tests/**/*.h"]), | ||
), | ||
header_namespace = "", | ||
exported_headers = subdir_glob( | ||
[ | ||
("", "*.h"), | ||
("paragraph", "*.h"), | ||
("text", "*.h"), | ||
("rawtext", "*.h"), | ||
], | ||
prefix = "fabric/text", | ||
), | ||
compiler_flags = [ | ||
"-fexceptions", | ||
"-frtti", | ||
"-std=c++14", | ||
"-Wall", | ||
], | ||
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, | ||
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(), | ||
fbobjc_tests = [ | ||
":tests", | ||
], | ||
force_static = True, | ||
macosx_tests_override = [], | ||
preprocessor_flags = [ | ||
"-DLOG_TAG=\"ReactNative\"", | ||
"-DWITH_FBSYSTRACE=1", | ||
], | ||
tests = [], | ||
visibility = ["PUBLIC"], | ||
deps = [ | ||
"xplat//fbsystrace:fbsystrace", | ||
"xplat//folly:headers_only", | ||
"xplat//folly:memory", | ||
"xplat//folly:molly", | ||
"xplat//third-party/glog:glog", | ||
react_native_xplat_target("fabric/attributedstring:attributedstring"), | ||
react_native_xplat_target("fabric/core:core"), | ||
react_native_xplat_target("fabric/debug:debug"), | ||
react_native_xplat_target("fabric/graphics:graphics"), | ||
react_native_xplat_target("fabric/textlayoutmanager:textlayoutmanager"), | ||
react_native_xplat_target("fabric/view:view"), | ||
], | ||
) | ||
|
||
if not IS_OSS_BUILD: | ||
load("@xplat//build_defs:fb_xplat_cxx_test.bzl", "fb_xplat_cxx_test") | ||
|
||
fb_xplat_cxx_test( | ||
name = "tests", | ||
srcs = glob(["tests/**/*.cpp"]), | ||
headers = glob(["tests/**/*.h"]), | ||
contacts = ["[email protected]"], | ||
compiler_flags = [ | ||
"-fexceptions", | ||
"-frtti", | ||
"-std=c++14", | ||
"-Wall", | ||
], | ||
platforms = APPLE, | ||
deps = [ | ||
"xplat//folly:molly", | ||
"xplat//third-party/gmock:gtest", | ||
":text", | ||
], | ||
) |
27 changes: 27 additions & 0 deletions
27
ReactCommon/fabric/text/rawtext/RawTextComponentDescriptor.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <fabric/core/ConcreteComponentDescriptor.h> | ||
#include <fabric/text/RawTextShadowNode.h> | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
/* | ||
* Descriptor for <RawText> component. | ||
*/ | ||
class RawTextComponentDescriptor: public ConcreteComponentDescriptor<RawTextShadowNode> { | ||
public: | ||
ComponentName getComponentName() const override { | ||
return "RawText"; | ||
} | ||
}; | ||
|
||
} // namespace react | ||
} // namespace facebook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include "RawTextProps.h" | ||
|
||
#include <fabric/core/propsConversions.h> | ||
#include <fabric/debug/DebugStringConvertibleItem.h> | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
void RawTextProps::apply(const RawProps &rawProps) { | ||
Props::apply(rawProps); | ||
|
||
applyRawProp(rawProps, "text", text_); | ||
} | ||
|
||
#pragma mark - Getters | ||
|
||
std::string RawTextProps::getText() const { | ||
return text_; | ||
} | ||
|
||
#pragma mark - DebugStringConvertible | ||
|
||
SharedDebugStringConvertibleList RawTextProps::getDebugProps() const { | ||
SharedDebugStringConvertibleList list = {}; | ||
list.push_back(std::make_shared<DebugStringConvertibleItem>("text", text_)); | ||
return list; | ||
} | ||
|
||
} // namespace react | ||
} // namespace facebook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <memory> | ||
|
||
#include <fabric/core/Props.h> | ||
#include <fabric/debug/DebugStringConvertible.h> | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
class RawTextProps; | ||
|
||
using SharedRawTextProps = std::shared_ptr<const RawTextProps>; | ||
|
||
class RawTextProps: | ||
public Props { | ||
|
||
public: | ||
|
||
void apply(const RawProps &rawProps) override; | ||
|
||
#pragma mark - Getters | ||
|
||
std::string getText() const; | ||
|
||
#pragma mark - DebugStringConvertible | ||
|
||
SharedDebugStringConvertibleList getDebugProps() const override; | ||
|
||
private: | ||
|
||
std::string text_ {""}; | ||
}; | ||
|
||
} // namespace react | ||
} // namespace facebook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include "RawTextShadowNode.h" | ||
|
||
#include <fabric/debug/DebugStringConvertibleItem.h> | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
ComponentName RawTextShadowNode::getComponentName() const { | ||
return ComponentName("RawText"); | ||
} | ||
|
||
} // namespace react | ||
} // namespace facebook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <memory> | ||
|
||
#include <fabric/core/ConcreteShadowNode.h> | ||
#include <fabric/core/ShadowNode.h> | ||
#include <fabric/text/RawTextProps.h> | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
class RawTextShadowNode; | ||
|
||
using SharedRawTextShadowNode = std::shared_ptr<const RawTextShadowNode>; | ||
|
||
/* | ||
* `ShadowNode` for <RawText> component, represents a purely regular string | ||
* object in React. In a code fragment `<Text>Hello!</Text>`, "Hello!" part | ||
* is represented as `<RawText text="Hello!"/>`. | ||
* <RawText> component must not have any children. | ||
*/ | ||
class RawTextShadowNode: | ||
public ConcreteShadowNode<RawTextProps> { | ||
|
||
public: | ||
using ConcreteShadowNode::ConcreteShadowNode; | ||
|
||
ComponentName getComponentName() const override; | ||
}; | ||
|
||
} // namespace react | ||
} // namespace facebook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include <memory> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
TEST(TextLayoutManagerTest, testSomething) { | ||
// TODO: | ||
} |