mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-15 18:59:54 +00:00
Move validation code to ASLayoutValidation and add validation flag
This commit is contained in:
parent
f9e13545bf
commit
9ff7223b77
@ -26,11 +26,11 @@
|
||||
#import "ASEqualityHelpers.h"
|
||||
#import "ASRunLoopQueue.h"
|
||||
#import "ASEnvironmentInternal.h"
|
||||
#import "ASLayoutValidation.h"
|
||||
|
||||
#import "ASInternalHelpers.h"
|
||||
#import "ASLayout.h"
|
||||
#import "ASLayoutSpec.h"
|
||||
#import "ASLayoutValidation.h"
|
||||
#import "ASCellNode.h"
|
||||
|
||||
NSInteger const ASDefaultDrawingPriority = ASDefaultTransactionPriority;
|
||||
@ -855,17 +855,6 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
_pendingLayoutTransition = nil;
|
||||
}
|
||||
|
||||
#pragma mark - Layout Validation
|
||||
|
||||
- (void)validateLayout:(ASLayout *)layout
|
||||
{
|
||||
ASLayoutableValidation *validation = [[ASLayoutableValidation alloc] init];
|
||||
[validation registerValidator:[[ASLayoutableStaticValidator alloc] init]];
|
||||
[validation registerValidator:[[ASLayoutableStackValidator alloc] init]];
|
||||
[validation validateLayout:layout];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - _ASTransitionContextCompletionDelegate
|
||||
|
||||
- (void)transitionContext:(_ASTransitionContext *)context didComplete:(BOOL)didComplete
|
||||
@ -1920,8 +1909,8 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock)
|
||||
if (isRootLayout) {
|
||||
layout.position = CGPointZero;
|
||||
layout = [ASLayout layoutWithLayoutableObject:self constrainedSizeRange:constrainedSize size:layout.size sublayouts:@[layout]];
|
||||
#if DEBUG
|
||||
[self validateLayout:layout];
|
||||
#if LAYOUT_VALIDATION
|
||||
ASLayoutableValidateLayout(layout);
|
||||
#endif
|
||||
}
|
||||
return [layout flattenedLayoutUsingPredicateBlock:^BOOL(ASLayout *evaluatedLayout) {
|
||||
|
||||
@ -9,11 +9,17 @@
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AsyncDisplayKit/ASBaseDefines.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class ASLayout;
|
||||
|
||||
// Enable or disable automatic layout validation
|
||||
#define LAYOUT_VALIDATION 0
|
||||
|
||||
extern void ASLayoutableValidateLayout(ASLayout *layout);
|
||||
|
||||
#pragma mark - ASLayoutableValidator
|
||||
|
||||
@protocol ASLayoutableValidator <NSObject>
|
||||
@ -45,6 +51,9 @@ typedef void (^ASLayoutableBlockValidatorBlock)(id layout);
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
* Not in use at the moment
|
||||
*/
|
||||
@interface ASLayoutablePreferredSizeValidator : NSObject<ASLayoutableValidator>
|
||||
|
||||
@end
|
||||
|
||||
@ -17,6 +17,15 @@
|
||||
|
||||
#import <queue>
|
||||
|
||||
#pragma mark - Layout Validation
|
||||
|
||||
void ASLayoutableValidateLayout(ASLayout *layout) {
|
||||
ASLayoutableValidation *validation = [[ASLayoutableValidation alloc] init];
|
||||
[validation registerValidator:[[ASLayoutableStaticValidator alloc] init]];
|
||||
[validation registerValidator:[[ASLayoutableStackValidator alloc] init]];
|
||||
[validation validateLayout:layout];
|
||||
}
|
||||
|
||||
#pragma mark - Helpers
|
||||
|
||||
static NSString *ASLayoutValidationWrappingAssertMessage(SEL selector, id obj, Class cl) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user