diff options
Diffstat (limited to 'WebKit/mac/WebView/WebTextIterator.mm')
-rw-r--r-- | WebKit/mac/WebView/WebTextIterator.mm | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/WebKit/mac/WebView/WebTextIterator.mm b/WebKit/mac/WebView/WebTextIterator.mm index 86db6d3..15eeb5f 100644 --- a/WebKit/mac/WebView/WebTextIterator.mm +++ b/WebKit/mac/WebView/WebTextIterator.mm @@ -27,30 +27,27 @@ #import "DOMNodeInternal.h" #import "DOMRangeInternal.h" +#import "WebTypesInternal.h" +#import <JavaScriptCore/Vector.h> #import <WebCore/TextIterator.h> -#import <wtf/Vector.h> +#import <WebCore/WebCoreObjCExtras.h> +using namespace JSC; using namespace WebCore; -@interface WebTextIteratorPrivate : NSObject -{ +@interface WebTextIteratorPrivate : NSObject { @public - TextIterator* m_textIterator; + OwnPtr<TextIterator> _textIterator; } @end @implementation WebTextIteratorPrivate -- (void)dealloc -{ - delete m_textIterator; - [super dealloc]; -} - -- (void)finalize ++ (void)initialize { - delete m_textIterator; - [super finalize]; +#ifndef BUILDING_ON_TIGER + WebCoreObjCFinalizeOnMainThread(self); +#endif } @end @@ -70,39 +67,47 @@ using namespace WebCore; return self; _private = [[WebTextIteratorPrivate alloc] init]; - _private->m_textIterator = new TextIterator([range _range], true, false); + _private->_textIterator.set(new TextIterator([range _range], true, false)); return self; } - (void)advance { - ASSERT(_private->m_textIterator); - - if (_private->m_textIterator->atEnd()) - return; - - _private->m_textIterator->advance(); + _private->_textIterator->advance(); } -- (DOMNode *)currentNode +- (BOOL)atEnd { - ASSERT(_private->m_textIterator); - - return [DOMNode _wrapNode:_private->m_textIterator->node()]; + return _private->_textIterator->atEnd(); } -- (NSString *)currentText +- (DOMRange *)currentRange { - ASSERT(_private->m_textIterator); - - return [NSString stringWithCharacters:_private->m_textIterator->characters() length:_private->m_textIterator->length()]; + return [DOMRange _wrapRange:_private->_textIterator->range().get()]; } -- (BOOL)atEnd +- (const unichar *)currentTextPointer { - ASSERT(_private->m_textIterator); - - return _private->m_textIterator->atEnd(); + return _private->_textIterator->characters(); +} + +- (NSUInteger)currentTextLength +{ + return _private->_textIterator->length(); +} + +@end + +@implementation WebTextIterator (WebTextIteratorDeprecated) + +- (DOMNode *)currentNode +{ + return [DOMNode _wrapNode:_private->_textIterator->node()]; +} + +- (NSString *)currentText +{ + return [NSString stringWithCharacters:_private->_textIterator->characters() length:_private->_textIterator->length()]; } @end |