Add HTML Document "ready state"

Initially it is set to "loading" and changed to "complete" when the parser finishes
This commit is contained in:
iska
2015-03-15 21:03:54 +01:00
parent ba0cf5d7f6
commit 48de37dc3d
3 changed files with 27 additions and 1 deletions
+9
View File
@@ -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
+9
View File
@@ -10,4 +10,13 @@
@implementation HTMLDocument
- (instancetype)init
{
self = [super initWithName:@"#document" type:HTMLNodeDocument];
if (self) {
_readyState = HTMLDocumentLoading;
}
return self;
}
@end
+9 -1
View File
@@ -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 -