mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: This diff reverts a revert of D22456266 (https://github.com/facebook/react-native/commit/0060b5de559cd9c785a2a2a6c66f58088fea4dd2) and fixes the reason why it was reverted. Reverted in D22532594 (https://github.com/facebook/react-native/commit/c0e7e1bd9cf050b4a77a20212603d3468826979c). For reason why it was introduced in the first place, please refer to D22456266 (https://github.com/facebook/react-native/commit/0060b5de559cd9c785a2a2a6c66f58088fea4dd2). Problem: `includeTransform` was not taken into account when calculating offset. I added a unit test covering this specific scenario. Reviewed By: shergin Differential Revision: D22763011 fbshipit-source-id: e7d88fc19608ad1a4c7b5e594a9cc48122a2799b
74 lines
1.8 KiB
C++
74 lines
1.8 KiB
C++
/*
|
|
* 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 <memory>
|
|
|
|
#include <folly/dynamic.h>
|
|
#include <react/components/view/ConcreteViewShadowNode.h>
|
|
#include <react/components/view/ViewEventEmitter.h>
|
|
#include <react/components/view/ViewProps.h>
|
|
#include <react/core/ConcreteComponentDescriptor.h>
|
|
#include <react/core/RawProps.h>
|
|
#include <react/core/ShadowNode.h>
|
|
|
|
using namespace facebook::react;
|
|
|
|
/**
|
|
* This defines a set of TestComponent classes: Props, ShadowNode,
|
|
* ComponentDescriptor. To be used for testing purpose.
|
|
*/
|
|
|
|
class TestState {
|
|
public:
|
|
int number;
|
|
};
|
|
|
|
static const char TestComponentName[] = "Test";
|
|
|
|
class TestProps : public ViewProps {
|
|
public:
|
|
using ViewProps::ViewProps;
|
|
|
|
TestProps(const TestProps &sourceProps, const RawProps &rawProps)
|
|
: ViewProps(sourceProps, rawProps) {}
|
|
};
|
|
|
|
using SharedTestProps = std::shared_ptr<const TestProps>;
|
|
|
|
class TestShadowNode;
|
|
|
|
using SharedTestShadowNode = std::shared_ptr<const TestShadowNode>;
|
|
|
|
class TestShadowNode : public ConcreteViewShadowNode<
|
|
TestComponentName,
|
|
TestProps,
|
|
ViewEventEmitter,
|
|
TestState> {
|
|
public:
|
|
using ConcreteViewShadowNode::ConcreteViewShadowNode;
|
|
|
|
Transform _transform{Transform::Identity()};
|
|
|
|
Transform getTransform() const override {
|
|
return _transform;
|
|
}
|
|
|
|
facebook::react::Point _contentOriginOffset{};
|
|
|
|
facebook::react::Point getContentOriginOffset() const override {
|
|
return _contentOriginOffset;
|
|
}
|
|
};
|
|
|
|
class TestComponentDescriptor
|
|
: public ConcreteComponentDescriptor<TestShadowNode> {
|
|
public:
|
|
using ConcreteComponentDescriptor::ConcreteComponentDescriptor;
|
|
};
|