Pass x and y to measure callback

Summary:
Changelog: [internal]

Previous implementation of "measure" in UIManagerBinding returned 0, 0 for x and y coordinates.

Reviewed By: shergin

Differential Revision: D25681586

fbshipit-source-id: fa69b6d4803f083a8299e00cae8bb59932c8bf78
This commit is contained in:
Samuel Susla
2020-12-23 04:45:55 -08:00
committed by Facebook GitHub Bot
parent a1e9a2d81e
commit da10179238
2 changed files with 17 additions and 10 deletions
@@ -74,6 +74,9 @@ class UIManager final : public ShadowTreeDelegate {
void registerCommitHook(UIManagerCommitHook const &commitHook) const;
void unregisterCommitHook(UIManagerCommitHook const &commitHook) const;
ShadowNode::Shared getNewestCloneOfShadowNode(
ShadowNode const &shadowNode) const;
#pragma mark - ShadowTreeDelegate
void shadowTreeDidFinishTransaction(
@@ -125,9 +128,6 @@ class UIManager final : public ShadowTreeDelegate {
ShadowNode::Shared const &shadowNode,
Point point) const;
ShadowNode::Shared getNewestCloneOfShadowNode(
ShadowNode const &shadowNode) const;
/*
* Returns layout metrics of given `shadowNode` relative to
* `ancestorShadowNode` (relative to the root node in case if provided
@@ -7,10 +7,10 @@
#include "UIManagerBinding.h"
#include <react/renderer/debug/SystraceSection.h>
#include <glog/logging.h>
#include <jsi/JSIDynamic.h>
#include <react/renderer/core/LayoutableShadowNode.h>
#include <react/renderer/debug/SystraceSection.h>
namespace facebook {
namespace react {
@@ -594,10 +594,9 @@ jsi::Value UIManagerBinding::get(
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
auto shadowNode = shadowNodeFromValue(runtime, arguments[0]);
auto layoutMetrics = uiManager->getRelativeLayoutMetrics(
*shadowNodeFromValue(runtime, arguments[0]),
nullptr,
{/* .includeTransform = */ true});
*shadowNode, nullptr, {/* .includeTransform = */ true});
auto onSuccessFunction =
arguments[1].getObject(runtime).getFunction(runtime);
@@ -605,12 +604,20 @@ jsi::Value UIManagerBinding::get(
onSuccessFunction.call(runtime, {0, 0, 0, 0, 0, 0});
return jsi::Value::undefined();
}
auto newestCloneOfShadowNode =
uiManager->getNewestCloneOfShadowNode(*shadowNode);
auto layoutableShadowNode = traitCast<LayoutableShadowNode const *>(
newestCloneOfShadowNode.get());
Point originRelativeToParent = layoutableShadowNode
? layoutableShadowNode->getLayoutMetrics().frame.origin
: Point();
auto frame = layoutMetrics.frame;
onSuccessFunction.call(
runtime,
{0,
0,
{jsi::Value{runtime, (double)originRelativeToParent.x},
jsi::Value{runtime, (double)originRelativeToParent.y},
jsi::Value{runtime, (double)frame.size.width},
jsi::Value{runtime, (double)frame.size.height},
jsi::Value{runtime, (double)frame.origin.x},