Do not measure the view if it is hidden.
Summary: If views are hidden on screen, we don't want to bother including them in layout calculations. Reviewed By: rnystrom Differential Revision: D4022992 fbshipit-source-id: 2e93eb911f26223f305ef7ce788f86d050b83e4a
This commit is contained in:
committed by
Facebook Github Bot
parent
89440f630f
commit
05ba3a2565
@@ -16,11 +16,24 @@
|
||||
|
||||
@implementation CSSLayoutTests
|
||||
|
||||
- (void)testSmoke
|
||||
- (void)testHiddenViewsAreNotMeasured
|
||||
{
|
||||
const CGSize firstSize = CGSizeMake(100, 100);
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[view css_setUsesFlexbox:YES];
|
||||
XCTAssertTrue([view css_usesFlexbox]);
|
||||
[view css_setWidth:firstSize.width];
|
||||
[view css_setHeight:firstSize.height];
|
||||
|
||||
[view css_applyLayout];
|
||||
XCTAssertTrue(CGSizeEqualToSize(firstSize, view.frame.size));
|
||||
|
||||
const CGSize newSize = CGSizeMake(200, 200);
|
||||
[view css_setWidth:newSize.width];
|
||||
[view css_setHeight:newSize.height];
|
||||
view.hidden = YES;
|
||||
|
||||
[view css_applyLayout];
|
||||
XCTAssertFalse(CGSizeEqualToSize(newSize, view.frame.size));
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -226,6 +226,10 @@ static void _updateFrameRecursive(UIView *view);
|
||||
@end
|
||||
|
||||
static void _attachNodesRecursive(UIView *view) {
|
||||
if (view.isHidden) {
|
||||
return;
|
||||
}
|
||||
|
||||
CSSNodeRef node = [view cssNode];
|
||||
const BOOL usesFlexbox = [view css_usesFlexbox];
|
||||
const BOOL isLeaf = !usesFlexbox || view.subviews.count == 0;
|
||||
@@ -258,6 +262,10 @@ static void _attachNodesRecursive(UIView *view) {
|
||||
}
|
||||
|
||||
static void _updateFrameRecursive(UIView *view) {
|
||||
if (view.isHidden) {
|
||||
return;
|
||||
}
|
||||
|
||||
CSSNodeRef node = [view cssNode];
|
||||
const BOOL usesFlexbox = [view css_usesFlexbox];
|
||||
const BOOL isLeaf = !usesFlexbox || view.subviews.count == 0;
|
||||
|
Reference in New Issue
Block a user