18e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/*
2635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved.
38e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
48e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Redistribution and use in source and binary forms, with or without
58e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * modification, are permitted provided that the following conditions
68e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * are met:
78e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 1. Redistributions of source code must retain the above copyright
88e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *    notice, this list of conditions and the following disclaimer.
98e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 2. Redistributions in binary form must reproduce the above copyright
108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *    notice, this list of conditions and the following disclaimer in the
118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *    documentation and/or other materials provided with the distribution.
128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#import <Foundation/Foundation.h>
278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
28635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
29635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#define WebNSUInteger unsigned int
30635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#else
31635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#define WebNSUInteger NSUInteger
32635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#endif
338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project@class DOMRange;
358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project@class DOMNode;
368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project@class WebTextIteratorPrivate;
378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
38635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project@interface WebTextIterator : NSObject {
398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project@private
408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    WebTextIteratorPrivate *_private;
418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project}
428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project- (id)initWithRange:(DOMRange *)range;
448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/*!
46635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project @method advance
47563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark @abstract Moves the WebTextIterator to the next bit of text or boundary between runs of text.
48563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark The iterator can break up runs of text however it finds convenient, so clients need to handle
49563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark text runs that are broken up into arbitrary pieces.
508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project- (void)advance;
528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/*!
54635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project @method atEnd
55635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project @result YES if the WebTextIterator has reached the end of the DOMRange.
568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
57635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project- (BOOL)atEnd;
588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/*!
60563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark @method currentTextLength
61563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark @result Length of the current text. Length of zero means that the iterator is at a boundary,
62563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark such as an image, that separates runs of text.
638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
64563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark- (WebNSUInteger)currentTextLength;
658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/*!
67635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project @method currentTextPointer
68563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark @result A pointer to the current text. Like the WebTextIterator itself, the pointer becomes
69563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark invalid after any modification is made to the document; it must be used before the document
70563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark is changed or the iterator is advanced.
718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
72635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project- (const unichar *)currentTextPointer;
73635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project
74635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project/*!
75563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark @method currentRange
76563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark @abstract A function that identifies the specific document range that text corresponds to.
77563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark This can be quite costly to compute for non-text items, so when possible this should only
78563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark be called once the caller has determined that the text is text it wants to process. If you
79563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark call currentRange every time you advance the iterator, performance will be extremely slow
80563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark due to the cost of computing a DOM range.
81563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark @result A DOM range indicating the position within the document of the current text.
82635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project */
83563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark- (DOMRange *)currentRange;
84635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project
85635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project@end
86635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project
87635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project@interface WebTextIterator (WebTextIteratorDeprecated)
888e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
89635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project/*!
90635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project @method currentNode
91635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project @abstract A convenience method that finds the first node in currentRange; it's almost always better to use currentRange instead.
92635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project @result The current DOMNode in the WebTextIterator
93635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project */
94635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project- (DOMNode *)currentNode;
95635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project
96635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project/*!
97635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project @method currentText
98635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project @abstract A convenience method that makes an NSString out of the current text; it's almost always better to use currentTextPointer and currentTextLength instead.
99635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project @result The current text in the WebTextIterator.
100635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project */
101635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project- (NSString *)currentText;
1028e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
1038e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project@end
104635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project
105635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#undef WebNSUInteger
106