Fixed: optimization with layoutSubviews and viewWillLayout

This commit is contained in:
Alexandre Wilhelm
2015-10-06 14:41:01 -07:00
parent f8eab7d611
commit f062fda2f7
+14 -3
View File
@@ -128,7 +128,8 @@ var DOMElementPrototype = nil,
var CPViewFlags = { },
CPViewHasCustomDrawRect = 1 << 0,
CPViewHasCustomLayoutSubviews = 1 << 1;
CPViewHasCustomLayoutSubviews = 1 << 1,
CPViewHasCustomViewWillLayout = 1 << 2;
var CPViewHighDPIDrawingEnabled = YES;
@@ -317,6 +318,12 @@ var CPViewHighDPIDrawingEnabled = YES;
|| [theClass instanceMethodForSelector:@selector(viewWillDraw)] !== [CPView instanceMethodForSelector:@selector(viewWillDraw)])
flags |= CPViewHasCustomDrawRect;
if ([theClass instanceMethodForSelector:@selector(viewWillLayout)] !== [CPView instanceMethodForSelector:@selector(viewWillLayout)])
flags |= CPViewHasCustomViewWillLayout;
if ([theClass instanceMethodForSelector:@selector(layoutSubviews)] !== [CPView instanceMethodForSelector:@selector(layoutSubviews)])
flags |= CPViewHasCustomLayoutSubviews;
CPViewFlags[classUID] = flags;
}
@@ -2637,8 +2644,12 @@ setBoundsOrigin:
{
_needsLayout = NO;
[self viewWillLayout];
[self layoutSubviews];
if (_viewClassFlags & CPViewHasCustomViewWillLayout)
[self viewWillLayout];
if (_viewClassFlags & CPViewHasCustomLayoutSubviews)
[self layoutSubviews];
[self viewDidLayout];
}
}