Add range attaching/detaching to the range’s lifecycle

This commit is contained in:
iska
2016-11-27 15:00:13 +01:00
parent 0d95ba33d1
commit ef672e1dbb
+14
View File
@@ -9,6 +9,13 @@
#import "HTMLRange.h"
#import "HTMLDocument.h"
#import "HTMLKitDOMExceptions.h"
#import "HTMLDocument+Private.h"
@interface HTMLRange ()
{
HTMLDocument *_ownerDocument;
}
@end
@implementation HTMLRange
@@ -18,12 +25,19 @@
{
self = [super init];
if (self) {
_ownerDocument = document;
[_ownerDocument attachRange:self];
[self setStartNode:document startOffset:0];
[self setEndNode:document endOffset:0];
}
return self;
}
- (void)dealloc
{
[_ownerDocument detachRange:self];
}
#pragma mark - Properties
- (BOOL)isCollapsed