Skip to content

Commit 0310f00

Browse files
Soe Lynnfacebook-github-bot
authored andcommitted
Measure with transform bugfix
Summary: - This is just draft. Still fixing the content offset calculation issue Differential Revision: D58197918
1 parent 138d50f commit 0310f00

5 files changed

Lines changed: 157 additions & 186 deletions

File tree

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1951,7 +1951,6 @@ public class com/facebook/react/common/network/OkHttpCallUtil {
19511951
}
19521952

19531953
public class com/facebook/react/config/ReactFeatureFlags {
1954-
public static field calculateTransformedFramesEnabled Z
19551954
public static field dispatchPointerEvents Z
19561955
public static field enableBridgelessArchitecture Z
19571956
public static field enableCppPropsIteratorSetter Z

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ public class ReactFeatureFlags {
7272
/** Feature flag to configure eager attachment of the root view/initialisation of the JS code */
7373
public static boolean enableEagerRootViewAttachment = false;
7474

75-
/** Enables or disables calculation of Transformed Frames */
76-
public static boolean calculateTransformedFramesEnabled = false;
77-
7875
public static boolean dispatchPointerEvents = false;
7976

8077
/**

packages/react-native/ReactAndroid/src/main/jni/react/fabric/Binding.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,6 @@ void Binding::installFabricUIManager(
396396
// Keep reference to config object and cache some feature flags here
397397
reactNativeConfig_ = config;
398398

399-
contextContainer->insert(
400-
"CalculateTransformedFramesEnabled",
401-
getFeatureFlagValue("calculateTransformedFramesEnabled"));
402-
403399
CoreFeatures::enablePropIteratorSetter =
404400
getFeatureFlagValue("enableCppPropsIteratorSetter");
405401
CoreFeatures::excludeYogaFromRawProps =

packages/react-native/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp

Lines changed: 2 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -19,57 +19,6 @@ namespace facebook::react {
1919
template <class T>
2020
using LayoutableSmallVector = std::vector<T>;
2121

22-
static LayoutableSmallVector<Rect> calculateTransformedFrames(
23-
const LayoutableSmallVector<const ShadowNode*>& shadowNodeList,
24-
LayoutableShadowNode::LayoutInspectingPolicy policy) {
25-
auto size = shadowNodeList.size();
26-
auto transformedFrames = LayoutableSmallVector<Rect>{size};
27-
auto transformation = Transform::Identity();
28-
29-
for (auto i = size; i > 0; --i) {
30-
auto currentShadowNode =
31-
dynamic_cast<const LayoutableShadowNode*>(shadowNodeList.at(i - 1));
32-
auto currentFrame = currentShadowNode->getLayoutMetrics().frame;
33-
34-
if (policy.includeTransform) {
35-
if (Transform::isVerticalInversion(transformation)) {
36-
auto parentShadowNode =
37-
dynamic_cast<const LayoutableShadowNode*>(shadowNodeList.at(i));
38-
currentFrame.origin.y =
39-
parentShadowNode->getLayoutMetrics().frame.size.height -
40-
currentFrame.size.height - currentFrame.origin.y;
41-
}
42-
43-
if (Transform::isHorizontalInversion(transformation)) {
44-
auto parentShadowNode =
45-
dynamic_cast<const LayoutableShadowNode*>(shadowNodeList.at(i));
46-
currentFrame.origin.x =
47-
parentShadowNode->getLayoutMetrics().frame.size.width -
48-
currentFrame.size.width - currentFrame.origin.x;
49-
}
50-
51-
if (i != size) {
52-
auto parentShadowNode =
53-
dynamic_cast<const LayoutableShadowNode*>(shadowNodeList.at(i));
54-
auto contentOriginOffset = parentShadowNode->getContentOriginOffset();
55-
if (Transform::isVerticalInversion(transformation)) {
56-
contentOriginOffset.y = -contentOriginOffset.y;
57-
}
58-
if (Transform::isHorizontalInversion(transformation)) {
59-
contentOriginOffset.x = -contentOriginOffset.x;
60-
}
61-
currentFrame.origin += contentOriginOffset;
62-
}
63-
64-
transformation = transformation * currentShadowNode->getTransform();
65-
}
66-
67-
transformedFrames[i - 1] = currentFrame;
68-
}
69-
70-
return transformedFrames;
71-
}
72-
7322
LayoutableShadowNode::LayoutableShadowNode(
7423
const ShadowNodeFragment& fragment,
7524
const ShadowNodeFamily::Shared& family,
@@ -157,22 +106,6 @@ LayoutMetrics LayoutableShadowNode::computeRelativeLayoutMetrics(
157106
return EmptyLayoutMetrics;
158107
}
159108

160-
// ------------------------------
161-
// TODO: T127619309 remove after validating that T127619309 is fixed
162-
auto optionalCalculateTransformedFrames =
163-
descendantNode->getContextContainer()
164-
? descendantNode->getContextContainer()->find<bool>(
165-
"CalculateTransformedFramesEnabled")
166-
: std::optional<bool>(false);
167-
168-
bool shouldCalculateTransformedFrames =
169-
optionalCalculateTransformedFrames.has_value()
170-
? optionalCalculateTransformedFrames.value()
171-
: false;
172-
173-
auto transformedFrames = shouldCalculateTransformedFrames
174-
? calculateTransformedFrames(shadowNodeList, policy)
175-
: LayoutableSmallVector<Rect>();
176109
auto layoutMetrics = descendantLayoutableNode->getLayoutMetrics();
177110
auto& resultFrame = layoutMetrics.frame;
178111
resultFrame.origin = {0, 0};
@@ -194,9 +127,7 @@ LayoutMetrics LayoutableShadowNode::computeRelativeLayoutMetrics(
194127
return EmptyLayoutMetrics;
195128
}
196129

197-
auto currentFrame = shouldCalculateTransformedFrames
198-
? transformedFrames[i]
199-
: currentShadowNode->getLayoutMetrics().frame;
130+
auto currentFrame = currentShadowNode->getLayoutMetrics().frame;
200131
if (i == size - 1) {
201132
// If it's the last element, its origin is irrelevant.
202133
currentFrame.origin = {0, 0};
@@ -219,8 +150,7 @@ LayoutMetrics LayoutableShadowNode::computeRelativeLayoutMetrics(
219150
resultFrame, currentFrame.getCenter());
220151
}
221152

222-
if (!shouldCalculateTransformedFrames && i != 0 &&
223-
policy.includeTransform) {
153+
if (i != 0 && policy.includeTransform) {
224154
resultFrame.origin += currentShadowNode->getContentOriginOffset();
225155
}
226156

0 commit comments

Comments
 (0)