Skip to content

Commit

Permalink
ScrollView: Couple of unnecessary checks was removed from RCTCustomSc…
Browse files Browse the repository at this point in the history
…rollView

Summary:
* Now `setFrame:` is called by autoresizing masks, so it is safe.
* Nobody calls `setBounds:`, so it is also safe.

Reviewed By: javache

Differential Revision: D5414441

fbshipit-source-id: 6fc51c7598c4817301db51f627aa1e9840642fec
  • Loading branch information
shergin authored and facebook-github-bot committed Jul 18, 2017
1 parent 7da5ef3 commit f5d9b52
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions React/Views/RCTScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -301,30 +301,8 @@ - (void)setContentOffset:(CGPoint)contentOffset
super.contentOffset = contentOffset;
}

static inline BOOL isRectInvalid(CGRect rect) {
return isnan(rect.origin.x) || isinf(rect.origin.x) ||
isnan(rect.origin.y) || isinf(rect.origin.y) ||
isnan(rect.size.width) || isinf(rect.size.width) ||
isnan(rect.size.height) || isinf(rect.size.height);
}

- (void)setBounds:(CGRect)bounds
{
if (isRectInvalid(bounds)) {
RCTLogError(@"Attempted to set an invalid bounds to inner scrollview: %@", NSStringFromCGRect(bounds));
return;
}

[super setBounds:bounds];
}

- (void)setFrame:(CGRect)frame
{
if (isRectInvalid(frame)) {
RCTLogError(@"Attempted to set an invalid frame to inner scrollview: %@", NSStringFromCGRect(frame));
return;
}

// Preserving and revalidating `contentOffset`.
CGPoint originalOffset = self.contentOffset;

Expand Down

0 comments on commit f5d9b52

Please sign in to comment.