Skip to content

Commit

Permalink
Leverage existing displayType field rather than introducing a new `…
Browse files Browse the repository at this point in the history
…isHiddenDueToClipping` field
  • Loading branch information
Adam Comella committed Nov 15, 2018
1 parent 471ec84 commit e8500ef
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 3 additions & 1 deletion Libraries/Text/Text/RCTTextShadowView.m
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ - (void)layoutSubviewsWithContext:(RCTLayoutContext)layoutContext

RCTLayoutMetrics localLayoutMetrics = shadowView.layoutMetrics;
localLayoutMetrics.frame.origin = frame.origin; // Reinforcing a proper frame origin for the Shadow View.
localLayoutMetrics.isHiddenDueToClipping = viewIsTruncated;
if (viewIsTruncated) {
localLayoutMetrics.displayType = RCTDisplayTypeNone;
}
[shadowView layoutWithMetrics:localLayoutMetrics layoutContext:localLayoutContext];
}
];
Expand Down
10 changes: 5 additions & 5 deletions React/Modules/RCTUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ - (RCTViewManagerUIBlock)uiBlockWithLayoutUpdateForRootView:(RCTRootShadowView *
UIUserInterfaceLayoutDirection layoutDirection;
BOOL isNew;
BOOL parentIsNew;
BOOL isHiddenDueToClipping;
RCTDisplayType displayType;
} RCTFrameData;

// Construct arrays then hand off to main thread
Expand All @@ -506,7 +506,7 @@ - (RCTViewManagerUIBlock)uiBlockWithLayoutUpdateForRootView:(RCTRootShadowView *
layoutMetrics.layoutDirection,
shadowView.isNewView,
shadowView.superview.isNewView,
layoutMetrics.isHiddenDueToClipping
layoutMetrics.displayType
};
}
}
Expand Down Expand Up @@ -568,7 +568,7 @@ - (RCTViewManagerUIBlock)uiBlockWithLayoutUpdateForRootView:(RCTRootShadowView *
RCTLayoutAnimation *updatingLayoutAnimation = isNew ? nil : layoutAnimationGroup.updatingLayoutAnimation;
BOOL shouldAnimateCreation = isNew && !frameData.parentIsNew;
RCTLayoutAnimation *creatingLayoutAnimation = shouldAnimateCreation ? layoutAnimationGroup.creatingLayoutAnimation : nil;
BOOL isHiddenDueToClipping = frameData.isHiddenDueToClipping;
BOOL isHidden = frameData.displayType == RCTDisplayTypeNone;

void (^completion)(BOOL) = ^(BOOL finished) {
completionsCalled++;
Expand All @@ -585,8 +585,8 @@ - (RCTViewManagerUIBlock)uiBlockWithLayoutUpdateForRootView:(RCTRootShadowView *
view.reactLayoutDirection = layoutDirection;
}

if (view.isHidden != isHiddenDueToClipping) {
view.hidden = isHiddenDueToClipping;
if (view.isHidden != isHidden) {
view.hidden = isHidden;
}

if (creatingLayoutAnimation) {
Expand Down
4 changes: 1 addition & 3 deletions React/Views/RCTLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ struct RCTLayoutMetrics {
UIEdgeInsets borderWidth;
RCTDisplayType displayType;
UIUserInterfaceLayoutDirection layoutDirection;
BOOL isHiddenDueToClipping;
};
typedef struct CG_BOXABLE RCTLayoutMetrics RCTLayoutMetrics;

Expand All @@ -44,8 +43,7 @@ static inline BOOL RCTLayoutMetricsEqualToLayoutMetrics(RCTLayoutMetrics a, RCTL
CGRectEqualToRect(a.contentFrame, b.contentFrame) &&
UIEdgeInsetsEqualToEdgeInsets(a.borderWidth, b.borderWidth) &&
a.displayType == b.displayType &&
a.layoutDirection == b.layoutDirection &&
a.isHiddenDueToClipping == b.isHiddenDueToClipping;
a.layoutDirection == b.layoutDirection;
}

RCT_EXTERN RCTLayoutMetrics RCTLayoutMetricsFromYogaNode(YGNodeRef yogaNode);
Expand Down

0 comments on commit e8500ef

Please sign in to comment.