Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add way to compile out ASTextNode + TextKit dependencies #1242

Merged
merged 2 commits into from
Nov 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Source/ASExperimentalFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import <Foundation/Foundation.h>
#import <AsyncDisplayKit/ASAvailability.h>
#import <AsyncDisplayKit/ASBaseDefines.h>

NS_ASSUME_NONNULL_BEGIN
Expand All @@ -16,7 +17,9 @@ NS_ASSUME_NONNULL_BEGIN
*/
typedef NS_OPTIONS(NSUInteger, ASExperimentalFeatures) {
ASExperimentalGraphicsContexts = 1 << 0, // exp_graphics_contexts
#if AS_ENABLE_TEXTNODE
ASExperimentalTextNode = 1 << 1, // exp_text_node
#endif
ASExperimentalInterfaceStateCoalescing = 1 << 2, // exp_interface_state_coalesce
ASExperimentalUnfairLock = 1 << 3, // exp_unfair_lock
ASExperimentalLayerDefaults = 1 << 4, // exp_infer_layer_defaults
Expand Down
10 changes: 10 additions & 0 deletions Source/ASTextNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@
//

#import <AsyncDisplayKit/ASAvailability.h>

#import <AsyncDisplayKit/ASControlNode.h>
#import <AsyncDisplayKit/ASTextNodeCommon.h>

#if (!AS_ENABLE_TEXTNODE)

// Pull in ASTextNode2 to replace ASTextNode with ASTextNode2
#import <AsyncDisplayKit/ASTextNode2.h>

#else

NS_ASSUME_NONNULL_BEGIN

/**
Expand Down Expand Up @@ -251,3 +259,5 @@ NS_ASSUME_NONNULL_BEGIN
@end

NS_ASSUME_NONNULL_END

#endif
5 changes: 5 additions & 0 deletions Source/ASTextNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
//

#import <AsyncDisplayKit/ASTextNode.h>

#if AS_ENABLE_TEXTNODE

#import <AsyncDisplayKit/ASTextNode2.h>

#import <AsyncDisplayKit/ASTextNode+Beta.h>
Expand Down Expand Up @@ -1427,3 +1430,5 @@ - (NSAttributedString *)truncationAttributedString
}

@end

#endif
13 changes: 13 additions & 0 deletions Source/ASTextNode2.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ NS_ASSUME_NONNULL_BEGIN
@abstract Draws interactive rich text.
@discussion Backed by the code in TextExperiment folder, on top of CoreText.
*/
#if AS_ENABLE_TEXTNODE
@interface ASTextNode2 : ASControlNode
#else
@interface ASTextNode : ASControlNode
#endif

/**
@abstract The styled text displayed by the node.
Expand Down Expand Up @@ -215,14 +219,23 @@ NS_ASSUME_NONNULL_BEGIN

@end

#if AS_ENABLE_TEXTNODE
@interface ASTextNode2 (Unavailable)
#else
@interface ASTextNode (Unavailable)
#endif

- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE;

- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE;

@end

#if (!AS_ENABLE_TEXTNODE)
// For the time beeing remap ASTextNode2 to ASTextNode
#define ASTextNode2 ASTextNode
#endif

NS_ASSUME_NONNULL_END


8 changes: 8 additions & 0 deletions Source/ASTextNode2.mm
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,19 @@ @implementation ASTextCacheValue
static const CGFloat ASTextNodeHighlightDarkOpacity = 0.22;
static NSString *ASTextNodeTruncationTokenAttributeName = @"ASTextNodeTruncationAttribute";

#if AS_ENABLE_TEXTNODE
@interface ASTextNode2 () <UIGestureRecognizerDelegate>
#else
@interface ASTextNode () <UIGestureRecognizerDelegate>
#endif

@end

#if AS_ENABLE_TEXTNODE
@implementation ASTextNode2 {
#else
@implementation ASTextNode {
#endif
ASTextContainer *_textContainer;

CGSize _shadowOffset;
Expand Down
2 changes: 2 additions & 0 deletions Source/ASTextNodeCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#import <Foundation/Foundation.h>

#import <AsyncDisplayKit/ASAvailability.h>

@class ASTextNode;

#define AS_TEXT_ALERT_UNIMPLEMENTED_FEATURE() { \
Expand Down
4 changes: 4 additions & 0 deletions Source/Base/ASAvailability.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#define AS_TLS_AVAILABLE 1
#endif

#ifndef AS_ENABLE_TEXTNODE
#define AS_ENABLE_TEXTNODE 1 // Enable old TextNode by default
#endif

// This needs to stay in sync with Weaver
#ifndef AS_USE_VIDEO
#define AS_USE_VIDEO 0
Expand Down
7 changes: 7 additions & 0 deletions Source/TextKit/ASTextKitAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
#pragma once

#import <UIKit/UIKit.h>

#import <AsyncDisplayKit/ASAvailability.h>

#if AS_ENABLE_TEXTNODE

#import <AsyncDisplayKit/ASEqualityHelpers.h>

AS_EXTERN NSString *const ASTextKitTruncationAttributeName;
Expand Down Expand Up @@ -119,3 +124,5 @@ struct ASTextKitAttributes {

size_t hash() const;
};

#endif
4 changes: 4 additions & 0 deletions Source/TextKit/ASTextKitAttributes.mm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#import <AsyncDisplayKit/ASTextKitAttributes.h>

#if AS_ENABLE_TEXTNODE

#import <AsyncDisplayKit/ASHashing.h>

NSString *const ASTextKitTruncationAttributeName = @"ck_truncation";
Expand Down Expand Up @@ -44,3 +46,5 @@
};
return ASHashBytes(&data, sizeof(data));
}

#endif
1 change: 1 addition & 0 deletions Source/TextKit/ASTextKitComponents.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//

#import <UIKit/UIKit.h>

#import <AsyncDisplayKit/ASBaseDefines.h>

NS_ASSUME_NONNULL_BEGIN
Expand Down
7 changes: 7 additions & 0 deletions Source/TextKit/ASTextKitContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
//

#import <UIKit/UIKit.h>

#import <AsyncDisplayKit/ASAvailability.h>

#if AS_ENABLE_TEXTNODE

#import <AsyncDisplayKit/ASBaseDefines.h>

/**
Expand Down Expand Up @@ -44,3 +49,5 @@ AS_SUBCLASSING_RESTRICTED
NSTextContainer *textContainer))block;

@end

#endif
5 changes: 5 additions & 0 deletions Source/TextKit/ASTextKitContext.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
//

#import <AsyncDisplayKit/ASTextKitContext.h>

#if AS_ENABLE_TEXTNODE

#import <AsyncDisplayKit/ASLayoutManager.h>
#import <AsyncDisplayKit/ASThread.h>

Expand Down Expand Up @@ -73,3 +76,5 @@ - (void)performBlockWithLockedTextKitComponents:(NS_NOESCAPE void (^)(NSLayoutMa
}

@end

#endif
7 changes: 6 additions & 1 deletion Source/TextKit/ASTextKitCoreTextAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#import <AsyncDisplayKit/ASAvailability.h>

#if AS_ENABLE_TEXTNODE

#import <AsyncDisplayKit/ASBaseDefines.h>

NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -82,3 +85,5 @@ AS_EXTERN NSAttributedString *ASCleanseAttributedStringOfCoreTextAttributes(NSAt
@end

NS_ASSUME_NONNULL_END

#endif
4 changes: 4 additions & 0 deletions Source/TextKit/ASTextKitCoreTextAdditions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#import <AsyncDisplayKit/ASTextKitCoreTextAdditions.h>

#if AS_ENABLE_TEXTNODE

#import <CoreText/CTFont.h>
#import <CoreText/CTStringAttributes.h>

Expand Down Expand Up @@ -333,3 +335,5 @@ + (NSParagraphStyle *)paragraphStyleWithCTParagraphStyle:(CTParagraphStyleRef)co
}

@end

#endif
7 changes: 7 additions & 0 deletions Source/TextKit/ASTextKitEntityAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
//

#import <Foundation/Foundation.h>

#import <AsyncDisplayKit/ASAvailability.h>

#if AS_ENABLE_TEXTNODE

#import <AsyncDisplayKit/ASBaseDefines.h>

/**
Expand All @@ -27,3 +32,5 @@ AS_SUBCLASSING_RESTRICTED
- (instancetype)initWithEntity:(id<NSObject>)entity;

@end

#endif
4 changes: 4 additions & 0 deletions Source/TextKit/ASTextKitEntityAttribute.mm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#import <AsyncDisplayKit/ASTextKitEntityAttribute.h>

#if AS_ENABLE_TEXTNODE

@implementation ASTextKitEntityAttribute

- (instancetype)initWithEntity:(id<NSObject>)entity
Expand Down Expand Up @@ -37,3 +39,5 @@ - (BOOL)isEqual:(id)object
}

@end

#endif
8 changes: 7 additions & 1 deletion Source/TextKit/ASTextKitFontSizeAdjuster.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
//

#import <UIKit/UIKit.h>

#import <AsyncDisplayKit/ASAvailability.h>

#if AS_ENABLE_TEXTNODE

#import <AsyncDisplayKit/ASTextKitAttributes.h>
#import <AsyncDisplayKit/ASBaseDefines.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -50,3 +54,5 @@ AS_SUBCLASSING_RESTRICTED
@end

NS_ASSUME_NONNULL_END

#endif
4 changes: 4 additions & 0 deletions Source/TextKit/ASTextKitFontSizeAdjuster.mm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#import <AsyncDisplayKit/ASTextKitFontSizeAdjuster.h>

#if AS_ENABLE_TEXTNODE

#import <tgmath.h>
#import <mutex>

Expand Down Expand Up @@ -235,3 +237,5 @@ - (CGFloat)scaleFactor
}

@end

#endif
4 changes: 4 additions & 0 deletions Source/TextKit/ASTextKitRenderer+Positioning.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#import <AsyncDisplayKit/ASTextKitRenderer.h>

#if AS_ENABLE_TEXTNODE

typedef void (^as_text_component_index_block_t)(NSUInteger characterIndex,
CGRect glyphBoundingRect,
BOOL *stop);
Expand Down Expand Up @@ -100,3 +102,5 @@ typedef NS_ENUM(NSUInteger, ASTextKitRendererMeasureOption) {
- (CGRect)trailingRect;

@end

#endif
4 changes: 4 additions & 0 deletions Source/TextKit/ASTextKitRenderer+Positioning.mm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#import <AsyncDisplayKit/ASTextKitRenderer+Positioning.h>

#if AS_ENABLE_TEXTNODE

#import <CoreText/CoreText.h>
#import <tgmath.h>

Expand Down Expand Up @@ -380,3 +382,5 @@ - (CGRect)frameForTextRange:(NSRange)textRange
}

@end

#endif
4 changes: 4 additions & 0 deletions Source/TextKit/ASTextKitRenderer+TextChecking.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#import <AsyncDisplayKit/ASTextKitRenderer.h>

#if AS_ENABLE_TEXTNODE

/**
Application extensions to NSTextCheckingType. We're allowed to do this (see NSTextCheckingAllCustomTypes).
*/
Expand All @@ -26,3 +28,5 @@ static uint64_t const ASTextKitTextCheckingTypeTruncation = 1ULL << 34
- (NSTextCheckingResult *)textCheckingResultAtPoint:(CGPoint)point;

@end

#endif
4 changes: 4 additions & 0 deletions Source/TextKit/ASTextKitRenderer+TextChecking.mm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#import <AsyncDisplayKit/ASTextKitRenderer+TextChecking.h>

#if AS_ENABLE_TEXTNODE

#import <AsyncDisplayKit/ASTextKitEntityAttribute.h>
#import <AsyncDisplayKit/ASTextKitRenderer+Positioning.h>
#import <AsyncDisplayKit/ASTextKitTailTruncater.h>
Expand Down Expand Up @@ -98,3 +100,5 @@ - (NSTextCheckingResult *)textCheckingResultAtPoint:(CGPoint)point
}

@end

#endif
10 changes: 8 additions & 2 deletions Source/TextKit/ASTextKitRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
//

#import <vector>

#import <UIKit/UIKit.h>

#import <AsyncDisplayKit/ASAvailability.h>

#if AS_ENABLE_TEXTNODE

#import <AsyncDisplayKit/ASTextKitAttributes.h>

#import <vector>

@class ASTextKitContext;
@class ASTextKitShadower;
@class ASTextKitFontSizeAdjuster;
Expand Down Expand Up @@ -100,3 +104,5 @@
@property (nonatomic, readonly) NSRange firstVisibleRange;

@end

#endif
Loading