mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Only throw if ASLayoutElement style width or height are ASDimensionUnitFraction (#2484)
This commit is contained in:
committed by
Adlai Holler
parent
627d146a5a
commit
eb6cf0689d
@@ -257,12 +257,12 @@ do {\
|
||||
- (CGSize)preferredSize
|
||||
{
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
if (_size.width.unit != ASDimensionUnitPoints) {
|
||||
if (_size.width.unit == ASDimensionUnitFraction) {
|
||||
NSCAssert(NO, @"Cannot get preferredSize of element with fractional width. Width: %@.", NSStringFromASDimension(_size.width));
|
||||
return CGSizeZero;
|
||||
}
|
||||
|
||||
if (_size.height.unit != ASDimensionUnitPoints) {
|
||||
if (_size.height.unit == ASDimensionUnitFraction) {
|
||||
NSCAssert(NO, @"Cannot get preferredSize of element with fractional height. Height: %@.", NSStringFromASDimension(_size.height));
|
||||
return CGSizeZero;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,8 @@
|
||||
{
|
||||
ASLayoutElementStyle *style = [ASLayoutElementStyle new];
|
||||
|
||||
ASXCTAssertEqualSizes(style.preferredSize, CGSizeZero);
|
||||
|
||||
CGSize size = CGSizeMake(100, 100);
|
||||
|
||||
style.preferredSize = size;
|
||||
@@ -78,7 +80,7 @@
|
||||
{
|
||||
ASLayoutElementStyle *style = [ASLayoutElementStyle new];
|
||||
|
||||
XCTAssertThrows(style.preferredSize);
|
||||
XCTAssertNoThrow(style.preferredSize);
|
||||
|
||||
style.width = ASDimensionMake(ASDimensionUnitFraction, 0.5);
|
||||
XCTAssertThrows(style.preferredSize);
|
||||
|
||||
Reference in New Issue
Block a user