mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-01-12 22:50:10 +08:00
Expose measureLayout in UIManagerBinding.cpp
Summary: This diff exposes the Legacy method UIManager.measureLayout as part of Fabric Reviewed By: shergin Differential Revision: D15103117 fbshipit-source-id: 4cf7ab3776f6a541cf0d6a00789420a0bb008fae
This commit is contained in:
committed by
Facebook Github Bot
parent
5eac8ca9b0
commit
5b73b6771e
@@ -314,6 +314,42 @@ jsi::Value UIManagerBinding::get(
|
||||
});
|
||||
}
|
||||
|
||||
// Legacy API
|
||||
if (methodName == "measureLayout") {
|
||||
return jsi::Function::createFromHostFunction(
|
||||
runtime,
|
||||
name,
|
||||
4,
|
||||
[&uiManager](
|
||||
jsi::Runtime &runtime,
|
||||
const jsi::Value &thisValue,
|
||||
const jsi::Value *arguments,
|
||||
size_t count) -> jsi::Value {
|
||||
auto layoutMetrics = uiManager.getRelativeLayoutMetrics(
|
||||
*shadowNodeFromValue(runtime, arguments[0]),
|
||||
shadowNodeFromValue(runtime, arguments[1]).get());
|
||||
|
||||
if (layoutMetrics == EmptyLayoutMetrics) {
|
||||
auto onFailFunction =
|
||||
arguments[2].getObject(runtime).getFunction(runtime);
|
||||
onFailFunction.call(runtime);
|
||||
return jsi::Value::undefined();
|
||||
}
|
||||
|
||||
auto onSuccessFunction =
|
||||
arguments[3].getObject(runtime).getFunction(runtime);
|
||||
auto frame = layoutMetrics.frame;
|
||||
|
||||
onSuccessFunction.call(
|
||||
runtime,
|
||||
{jsi::Value{runtime, (double)frame.origin.x},
|
||||
jsi::Value{runtime, (double)frame.origin.y},
|
||||
jsi::Value{runtime, (double)frame.size.width},
|
||||
jsi::Value{runtime, (double)frame.size.height}});
|
||||
return jsi::Value::undefined();
|
||||
});
|
||||
}
|
||||
|
||||
if (methodName == "setNativeProps") {
|
||||
return jsi::Function::createFromHostFunction(
|
||||
runtime,
|
||||
|
||||
Reference in New Issue
Block a user