From 8ceb8089373bcdac1a23470baa59defa9c133fe9 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Mon, 29 Jun 2020 15:51:22 -0700 Subject: [PATCH] Fabric: Removing `LayoutContext::absolutePosition` Summary: Here is why: * It was with us from the very beginning but we never use it. * The main purpose of this - snap-to-pixel layout - was moved to Yoga, where it should be. * The current implementation has a bug. * It's not really correct conceptually because the value becomes incorrect when an immutable subtree is being reused as part of a new tree. * It over-complicates a new feature I am working on. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D22284645 fbshipit-source-id: c4c2df8d24e8fe924725b465e04e8154d097d226 --- React/Base/Surface/RCTSurfaceRootShadowView.m | 1 - .../fabric/components/text/paragraph/ParagraphShadowNode.cpp | 1 - ReactCommon/fabric/core/layout/LayoutContext.h | 5 ----- ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp | 3 --- 4 files changed, 10 deletions(-) diff --git a/React/Base/Surface/RCTSurfaceRootShadowView.m b/React/Base/Surface/RCTSurfaceRootShadowView.m index 97525cba479fbd..455af97b1ac215 100644 --- a/React/Base/Surface/RCTSurfaceRootShadowView.m +++ b/React/Base/Surface/RCTSurfaceRootShadowView.m @@ -46,7 +46,6 @@ - (void)layoutWithAffectedShadowViews:(NSHashTable *)affectedSh NSHashTable *other = [NSHashTable new]; RCTLayoutContext layoutContext = {}; - layoutContext.absolutePosition = CGPointZero; layoutContext.affectedShadowViews = affectedShadowViews; layoutContext.other = other; diff --git a/ReactCommon/fabric/components/text/paragraph/ParagraphShadowNode.cpp b/ReactCommon/fabric/components/text/paragraph/ParagraphShadowNode.cpp index 7e1ffc641f107c..c81e1c1b4f0e93 100644 --- a/ReactCommon/fabric/components/text/paragraph/ParagraphShadowNode.cpp +++ b/ReactCommon/fabric/components/text/paragraph/ParagraphShadowNode.cpp @@ -206,7 +206,6 @@ void ParagraphShadowNode::layout(LayoutContext layoutContext) { auto attachmentOrigin = roundToPixel<&round>( attachmentFrame.origin, layoutMetrics.pointScaleFactor); auto attachmentLayoutContext = layoutContext; - attachmentLayoutContext.absolutePosition += attachmentOrigin; auto attachmentLayoutConstrains = LayoutConstraints{ attachmentSize, attachmentSize, layoutConstraints.layoutDirection}; diff --git a/ReactCommon/fabric/core/layout/LayoutContext.h b/ReactCommon/fabric/core/layout/LayoutContext.h index c0b6ed0af43361..42b011fca7fcf3 100644 --- a/ReactCommon/fabric/core/layout/LayoutContext.h +++ b/ReactCommon/fabric/core/layout/LayoutContext.h @@ -20,11 +20,6 @@ namespace react { * layout approaches. */ struct LayoutContext { - /* - * Compound absolute position of the node relative to the root node. - */ - Point absolutePosition{0, 0}; - /* * Reflects the scale factor needed to convert from the logical coordinate * space into the device coordinate space of the physical screen. diff --git a/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp b/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp index 203fe8a2bb433b..35524cad1f186a 100644 --- a/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp +++ b/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp @@ -219,9 +219,6 @@ void LayoutableShadowNode::layout(LayoutContext layoutContext) { continue; } - auto childLayoutContext = LayoutContext(layoutContext); - childLayoutContext.absolutePosition += childLayoutMetrics.frame.origin; - child->layout(layoutContext); } }