forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add C++ AndroidTextInput component for backwards-compatible Fabric su…
…pport of TextInput on Android Summary: Support existing, backwards-compatible AndroidTextInput component for minimal support of TextInput on Android. Reviewed By: shergin, mdvacca Differential Revision: D17086758 fbshipit-source-id: 25726f22229e0d5dfe96eb36b386a5317601283d
- Loading branch information
1 parent
8981245
commit 5abe584
Showing
13 changed files
with
1,200 additions
and
5 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
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
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,98 @@ | ||
load("@fbsource//tools/build_defs/apple:flag_defs.bzl", "get_debug_preprocessor_flags") | ||
load( | ||
"//tools/build_defs/oss:rn_defs.bzl", | ||
"ANDROID", | ||
"APPLE", | ||
"CXX", | ||
"YOGA_CXX_TARGET", | ||
"fb_xplat_cxx_test", | ||
"get_apple_compiler_flags", | ||
"get_apple_inspector_flags", | ||
"react_native_xplat_target", | ||
"rn_xplat_cxx_library", | ||
"subdir_glob", | ||
) | ||
|
||
APPLE_COMPILER_FLAGS = get_apple_compiler_flags() | ||
|
||
rn_xplat_cxx_library( | ||
name = "androidtextinput", | ||
srcs = glob( | ||
["**/*.cpp"], | ||
exclude = glob(["tests/**/*.cpp"]), | ||
), | ||
headers = glob( | ||
["**/*.h"], | ||
exclude = glob(["tests/**/*.h"]), | ||
), | ||
header_namespace = "", | ||
exported_headers = subdir_glob( | ||
[ | ||
("", "*.h"), | ||
("androidtextinput", "*.h"), | ||
], | ||
prefix = "react/components/androidtextinput", | ||
), | ||
compiler_flags = [ | ||
"-fexceptions", | ||
"-frtti", | ||
"-std=c++14", | ||
"-Wall", | ||
], | ||
cxx_tests = [":tests"], | ||
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, | ||
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(), | ||
force_static = True, | ||
platforms = (ANDROID, APPLE, CXX), | ||
preprocessor_flags = [ | ||
"-DLOG_TAG=\"ReactNative\"", | ||
"-DWITH_FBSYSTRACE=1", | ||
], | ||
visibility = ["PUBLIC"], | ||
deps = [ | ||
"fbsource//xplat/fbsystrace:fbsystrace", | ||
"fbsource//xplat/folly:evicting_cache_map", | ||
"fbsource//xplat/folly:headers_only", | ||
"fbsource//xplat/folly:memory", | ||
"fbsource//xplat/folly:molly", | ||
"fbsource//xplat/third-party/glog:glog", | ||
YOGA_CXX_TARGET, | ||
react_native_xplat_target("utils:utils"), | ||
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/components/text:text"), | ||
react_native_xplat_target("fabric/components/view:view"), | ||
react_native_xplat_target("fabric/components/image:image"), | ||
react_native_xplat_target("fabric/uimanager:uimanager"), | ||
react_native_xplat_target("fabric/imagemanager:imagemanager"), | ||
], | ||
) | ||
|
||
fb_xplat_cxx_test( | ||
name = "tests", | ||
srcs = glob(["tests/**/*.cpp"]), | ||
headers = glob(["tests/**/*.h"]), | ||
compiler_flags = [ | ||
"-fexceptions", | ||
"-frtti", | ||
"-std=c++14", | ||
"-Wall", | ||
], | ||
contacts = ["oncall+react_native@xmail.facebook.com"], | ||
platforms = ( | ||
# `Apple` and `Android` flavors are disabled because the module depends on `textlayoutmanager` which requires real an Emulator/Simulator to run. | ||
# At the same time, the code of tests does not rely on the simulator capabilities and it would be wasteful to add `fbandroid_use_instrumentation_test = True`. | ||
# (Beware of this option though.) | ||
# ANDROID, | ||
# APPLE, | ||
CXX | ||
), | ||
deps = [ | ||
"fbsource//xplat/folly:molly", | ||
"fbsource//xplat/third-party/gmock:gtest", | ||
":androidtextinput", | ||
], | ||
) |
46 changes: 46 additions & 0 deletions
46
...Common/fabric/components/textinput/androidtextinput/AndroidTextInputComponentDescriptor.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,46 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* 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 <react/core/ConcreteComponentDescriptor.h> | ||
#include "AndroidTextInputShadowNode.h" | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
/* | ||
* Descriptor for <AndroidTextInput> component. | ||
*/ | ||
class AndroidTextInputComponentDescriptor final | ||
: public ConcreteComponentDescriptor<AndroidTextInputShadowNode> { | ||
public: | ||
AndroidTextInputComponentDescriptor( | ||
EventDispatcher::Shared eventDispatcher, | ||
const ContextContainer::Shared &contextContainer) | ||
: ConcreteComponentDescriptor<AndroidTextInputShadowNode>( | ||
eventDispatcher, | ||
contextContainer) {} | ||
|
||
protected: | ||
void adopt(UnsharedShadowNode shadowNode) const override { | ||
assert(std::dynamic_pointer_cast<AndroidTextInputShadowNode>(shadowNode)); | ||
auto concreteShadowNode = | ||
std::static_pointer_cast<AndroidTextInputShadowNode>(shadowNode); | ||
|
||
concreteShadowNode->setContextContainer( | ||
const_cast<ContextContainer *>(getContextContainer().get())); | ||
|
||
concreteShadowNode->dirtyLayout(); | ||
concreteShadowNode->enableMeasurement(); | ||
|
||
ConcreteComponentDescriptor::adopt(shadowNode); | ||
} | ||
}; | ||
|
||
} // namespace react | ||
} // namespace facebook |
Oops, something went wrong.