Add nullability annotations throughout the code base
This commit is contained in:
@@ -9,8 +9,12 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "CSSSelectors.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface CSSNthExpressionParser : NSObject
|
||||
|
||||
+ (CSSNthExpression)parseExpression:(NSString *)expression;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
#pragma mark - Attribute Selector Type
|
||||
|
||||
typedef NS_ENUM(NSUInteger, CSSAttributeSelectorType)
|
||||
@@ -48,3 +50,5 @@ extern NSString * _Nonnull NSStringFromNthExpression(CSSNthExpression expression
|
||||
- (BOOL)acceptElement:(HTMLElement *)element;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class CSSSelector;
|
||||
|
||||
@interface CSSSelectorParser : NSObject
|
||||
@@ -15,3 +17,5 @@
|
||||
+ (CSSSelector *)parseSelector:(NSString *)string error:(NSError **)error;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#import "HTMLNode.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface HTMLComment : HTMLNode
|
||||
|
||||
@property (nonatomic, copy) NSString *data;
|
||||
@@ -15,3 +17,5 @@
|
||||
- (instancetype)initWithData:(NSString *)data;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
return [self initWithData:nil];
|
||||
return [self initWithData:@""];
|
||||
}
|
||||
|
||||
- (instancetype)initWithData:(NSString *)data
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#import "HTMLDocumentType.h"
|
||||
#import "HTMLQuirksMode.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM(short, HTMLDocumentReadyState)
|
||||
{
|
||||
HTMLDocumentLoading,
|
||||
@@ -19,7 +21,7 @@ typedef NS_ENUM(short, HTMLDocumentReadyState)
|
||||
|
||||
@interface HTMLDocument : HTMLNode
|
||||
|
||||
@property (nonatomic, strong) HTMLDocumentType *documentType;
|
||||
@property (nonatomic, strong, nullable) HTMLDocumentType *documentType;
|
||||
|
||||
@property (nonatomic, assign) HTMLQuirksMode quirksMode;
|
||||
|
||||
@@ -27,13 +29,13 @@ typedef NS_ENUM(short, HTMLDocumentReadyState)
|
||||
|
||||
@property (nonatomic, assign, readonly) HTMLDocumentReadyState readyState;
|
||||
|
||||
@property (nonatomic, strong) HTMLElement *rootElement;
|
||||
@property (nonatomic, strong, nullable) HTMLElement *rootElement;
|
||||
|
||||
@property (nonatomic, strong) HTMLElement *documentElement;
|
||||
@property (nonatomic, strong, nullable) HTMLElement *documentElement;
|
||||
|
||||
@property (nonatomic, strong) HTMLElement *head;
|
||||
@property (nonatomic, strong, nullable) HTMLElement *head;
|
||||
|
||||
@property (nonatomic, strong) HTMLElement *body;
|
||||
@property (nonatomic, strong, nullable) HTMLElement *body;
|
||||
|
||||
+ (instancetype)documentWithString:(NSString *)string;
|
||||
|
||||
@@ -42,3 +44,5 @@ typedef NS_ENUM(short, HTMLDocumentReadyState)
|
||||
- (HTMLDocument *)associatedInertTemplateDocument;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -8,8 +8,12 @@
|
||||
|
||||
#import "HTMLNode.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface HTMLDocumentFragment : HTMLNode
|
||||
|
||||
- (instancetype)initWithDocument:(HTMLDocument *)document;
|
||||
- (instancetype)initWithDocument:(nullable HTMLDocument *)document;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#import "HTMLNode.h"
|
||||
#import "HTMLQuirksMode.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface HTMLDocumentType : HTMLNode
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *publicIdentifier;
|
||||
@@ -16,10 +18,12 @@
|
||||
@property (nonatomic, copy, readonly) NSString *systemIdentifier;
|
||||
|
||||
- (instancetype)initWithName:(NSString *)name
|
||||
publicIdentifier:(NSString *)publicIdentifier
|
||||
systemIdentifier:(NSString *)systemIdentifier;
|
||||
publicIdentifier:(nullable NSString *)publicIdentifier
|
||||
systemIdentifier:(nullable NSString *)systemIdentifier;
|
||||
|
||||
- (BOOL)isValid;
|
||||
- (HTMLQuirksMode)quirksMode;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#import "HTMLNamespaces.h"
|
||||
#import "HTMLNode.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface HTMLElement : HTMLNode
|
||||
|
||||
@property (nonatomic, assign, readonly) HTMLNamespace htmlNamespace;
|
||||
@@ -27,8 +29,10 @@
|
||||
- (instancetype)initWithTagName:(NSString *)tagName namespace:(HTMLNamespace)htmlNamespace attributes:(NSDictionary *)attributes;
|
||||
|
||||
- (BOOL)hasAttribute:(NSString *)name;
|
||||
- (NSString *)objectForKeyedSubscript:(NSString *)name;
|
||||
- (nullable NSString *)objectForKeyedSubscript:(NSString *)name;
|
||||
- (void)setObject:(NSString *)value forKeyedSubscript:(NSString *)attribute;
|
||||
- (void)removeAttribute:(NSString *)name;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
return [self initWithTagName:nil];
|
||||
return [self initWithTagName:@""];
|
||||
}
|
||||
|
||||
- (instancetype)initWithTagName:(NSString *)tagName
|
||||
{
|
||||
return [self initWithTagName:tagName attributes:nil];
|
||||
return [self initWithTagName:tagName attributes:@{}];
|
||||
}
|
||||
|
||||
- (instancetype)initWithTagName:(NSString *)tagName attributes:(NSDictionary *)attributes
|
||||
|
||||
+10
-3
@@ -9,6 +9,8 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "HTMLNodeIterator.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM(short, HTMLNodeType)
|
||||
{
|
||||
HTMLNodeElement = 1,
|
||||
@@ -102,7 +104,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
|
||||
- (void)appendNodes:(NSArray *)nodes;
|
||||
|
||||
- (HTMLNode *)insertNode:(HTMLNode *)node beforeChildNode:(HTMLNode *)child;
|
||||
- (HTMLNode *)insertNode:(HTMLNode *)node beforeChildNode:(nullable HTMLNode *)child;
|
||||
|
||||
- (HTMLNode *)replaceChildNode:(HTMLNode *)node withNode:(HTMLNode *)replacement;
|
||||
|
||||
@@ -128,13 +130,18 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
|
||||
- (HTMLNodeIterator *)nodeIterator;
|
||||
- (HTMLNodeIterator *)nodeIteratorWithShowOptions:(HTMLNodeFilterShowOptions)showOptions
|
||||
filter:(id<HTMLNodeFilter>)filter;
|
||||
filter:(nullable id<HTMLNodeFilter>)filter;
|
||||
- (HTMLNodeIterator *)nodeIteratorWithShowOptions:(HTMLNodeFilterShowOptions)showOptions
|
||||
filterBlock:(HTMLNodeFilterValue (^)(HTMLNode *node))filter;
|
||||
|
||||
- (HTMLElement *)firstElementMatchingSelector:(CSSSelector *)selector;
|
||||
- (nullable HTMLElement *)querySelector:(NSString *)selector;
|
||||
- (NSArray<HTMLElement *> *)querySelectorAll:(NSString *)selector;
|
||||
|
||||
- (nullable HTMLElement *)firstElementMatchingSelector:(CSSSelector *)selector;
|
||||
- (NSArray<HTMLElement *> *)elementsMatchingSelector:(CSSSelector *)selector;
|
||||
|
||||
- (NSString *)treeDescription;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM(unsigned short, HTMLNodeFilterValue)
|
||||
{
|
||||
HTMLNodeFilterAccept = 1,
|
||||
@@ -54,3 +56,5 @@ typedef NS_OPTIONS(unsigned long, HTMLNodeFilterShowOptions)
|
||||
+ (instancetype)filterWithSelector:(CSSSelector *)selector;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "HTMLNodeFilter.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class HTMLNode;
|
||||
|
||||
@interface HTMLNodeIterator : NSEnumerator
|
||||
@@ -21,16 +23,18 @@
|
||||
|
||||
+ (instancetype)iteratorWithNode:(HTMLNode *)node
|
||||
showOptions:(HTMLNodeFilterShowOptions)showOptions
|
||||
filter:(HTMLNodeFilterValue (^)(HTMLNode *node))filter;
|
||||
filter:(nullable HTMLNodeFilterValue (^)(HTMLNode *node))filter;
|
||||
|
||||
- (instancetype)initWithNode:(HTMLNode *)node;
|
||||
- (instancetype)initWithNode:(HTMLNode *)node
|
||||
filter:(id<HTMLNodeFilter>)filter;
|
||||
filter:(nullable id<HTMLNodeFilter>)filter;
|
||||
- (instancetype)initWithNode:(HTMLNode *)node
|
||||
showOptions:(HTMLNodeFilterShowOptions)showOptions
|
||||
filter:(id<HTMLNodeFilter>)filter;
|
||||
filter:(nullable id<HTMLNodeFilter>)filter;
|
||||
|
||||
- (HTMLNode *)nextNode;
|
||||
- (HTMLNode *)previousNode;
|
||||
- (nullable HTMLNode *)nextNode;
|
||||
- (nullable HTMLNode *)previousNode;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "HTMLElement.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface HTMLParser : NSObject
|
||||
|
||||
@property (nonatomic, strong, readonly) NSArray *parseErrors;
|
||||
@@ -20,3 +22,5 @@
|
||||
- (NSArray *)parseFragmentWithContextElement:(HTMLElement *)contextElement;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -9,8 +9,12 @@
|
||||
#import "HTMLElement.h"
|
||||
#import "HTMLDocumentFragment.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface HTMLTemplate : HTMLElement
|
||||
|
||||
@property (nonatomic, strong) HTMLDocumentFragment *content;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#import "HTMLNode.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface HTMLText : HTMLNode
|
||||
|
||||
@property (nonatomic, copy) NSMutableString *data;
|
||||
@@ -17,3 +19,5 @@
|
||||
- (void)appendString:(NSString *)string;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
+14
-10
@@ -9,28 +9,32 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "HTMLNodeFilter.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class HTMLNode;
|
||||
|
||||
@interface HTMLTreeWalker : NSObject
|
||||
|
||||
@property (nonatomic, strong, readonly) HTMLNode *root;
|
||||
@property (nonatomic, assign, readonly) HTMLNodeFilterShowOptions whatToShow;
|
||||
@property (nonatomic, strong, readonly) id<HTMLNodeFilter> filter;
|
||||
@property (nonatomic, strong, readonly, nullable) id<HTMLNodeFilter> filter;
|
||||
@property (nonatomic, strong) HTMLNode *currentNode;
|
||||
|
||||
- (instancetype)initWithNode:(HTMLNode *)node;
|
||||
- (instancetype)initWithNode:(HTMLNode *)node
|
||||
filter:(id<HTMLNodeFilter>)filter;
|
||||
filter:(nullable id<HTMLNodeFilter>)filter;
|
||||
- (instancetype)initWithNode:(HTMLNode *)node
|
||||
showOptions:(HTMLNodeFilterShowOptions)showOptions
|
||||
filter:(id<HTMLNodeFilter>)filter;
|
||||
filter:(nullable id<HTMLNodeFilter>)filter;
|
||||
|
||||
- (HTMLNode *)parentNode;
|
||||
- (HTMLNode *)firstChild;
|
||||
- (HTMLNode *)lastChild;
|
||||
- (HTMLNode *)previousSibling;
|
||||
- (HTMLNode *)nextSibling;
|
||||
- (HTMLNode *)previousNode;
|
||||
- (HTMLNode *)nextNode;
|
||||
- (nullable HTMLNode *)parentNode;
|
||||
- (nullable HTMLNode *)firstChild;
|
||||
- (nullable HTMLNode *)lastChild;
|
||||
- (nullable HTMLNode *)previousSibling;
|
||||
- (nullable HTMLNode *)nextSibling;
|
||||
- (nullable HTMLNode *)previousNode;
|
||||
- (nullable HTMLNode *)nextNode;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NSCharacterSet (HTMLKit)
|
||||
|
||||
+ (instancetype)HTMLWhitespaceCharacterSet;
|
||||
@@ -15,3 +17,5 @@
|
||||
+ (instancetype)CSSNthExpressionCharacterSet;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NSString (HTMLKit)
|
||||
|
||||
- (BOOL)isEqualToStringIgnoringCase:(NSString *)aString;
|
||||
@@ -17,3 +19,5 @@
|
||||
- (NSUInteger)leadingHTMLWhitespaceLength;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
Reference in New Issue
Block a user