Add HTML Document "ready state"
Initially it is set to "loading" and changed to "complete" when the parser finishes
This commit is contained in:
@@ -10,6 +10,13 @@
|
||||
#import "HTMLDocumentType.h"
|
||||
#import "HTMLQuirksMode.h"
|
||||
|
||||
typedef NS_ENUM(short, HTMLDocumentReadyState)
|
||||
{
|
||||
HTMLDocumentLoading,
|
||||
HTMLDocumentInteractive, // Not used
|
||||
HTMLDocumentComplete
|
||||
};
|
||||
|
||||
@interface HTMLDocument : HTMLNode
|
||||
|
||||
@property (nonatomic, strong) HTMLDocumentType *documentType;
|
||||
@@ -18,4 +25,6 @@
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *compatMode;
|
||||
|
||||
@property (nonatomic, assign, readonly) HTMLDocumentReadyState readyState;
|
||||
|
||||
@end
|
||||
|
||||
@@ -10,4 +10,13 @@
|
||||
|
||||
@implementation HTMLDocument
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super initWithName:@"#document" type:HTMLNodeDocument];
|
||||
if (self) {
|
||||
_readyState = HTMLDocumentLoading;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
#import "HTMLMarker.h"
|
||||
#import "NSString+HTMLKit.h"
|
||||
|
||||
|
||||
@interface HTMLDocument (Private)
|
||||
@property (nonatomic, assign) HTMLDocumentReadyState readyState;
|
||||
@end
|
||||
|
||||
@interface HTMLParser ()
|
||||
{
|
||||
HTMLTokenizer *_tokenizer;
|
||||
@@ -242,6 +247,9 @@
|
||||
- (id)parse
|
||||
{
|
||||
for (HTMLToken *token in _tokenizer) {
|
||||
if (_document.readyState == HTMLDocumentComplete) {
|
||||
break;
|
||||
}
|
||||
[self processToken:token];
|
||||
}
|
||||
return nil;
|
||||
@@ -340,7 +348,7 @@
|
||||
- (void)stopParsing
|
||||
{
|
||||
[_stackOfOpenElements popAll];
|
||||
#warning Finalize
|
||||
_document.readyState =HTMLDocumentComplete;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
Reference in New Issue
Block a user