Skip to content

Commit

Permalink
Fabric: Removing LayoutContext::absolutePosition
Browse files Browse the repository at this point in the history
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
  • Loading branch information
shergin authored and facebook-github-bot committed Jun 29, 2020
1 parent 559c60c commit 8ceb808
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 10 deletions.
1 change: 0 additions & 1 deletion React/Base/Surface/RCTSurfaceRootShadowView.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ - (void)layoutWithAffectedShadowViews:(NSHashTable<RCTShadowView *> *)affectedSh
NSHashTable<NSString *> *other = [NSHashTable new];

RCTLayoutContext layoutContext = {};
layoutContext.absolutePosition = CGPointZero;
layoutContext.affectedShadowViews = affectedShadowViews;
layoutContext.other = other;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
5 changes: 0 additions & 5 deletions ReactCommon/fabric/core/layout/LayoutContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,6 @@ void LayoutableShadowNode::layout(LayoutContext layoutContext) {
continue;
}

auto childLayoutContext = LayoutContext(layoutContext);
childLayoutContext.absolutePosition += childLayoutMetrics.frame.origin;

child->layout(layoutContext);
}
}
Expand Down

0 comments on commit 8ceb808

Please sign in to comment.