diff options
Diffstat (limited to 'WebCore/editing/TextIterator.h')
-rw-r--r-- | WebCore/editing/TextIterator.h | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/WebCore/editing/TextIterator.h b/WebCore/editing/TextIterator.h index f00bea4..44af3e5 100644 --- a/WebCore/editing/TextIterator.h +++ b/WebCore/editing/TextIterator.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2004, 2006, 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -49,6 +49,21 @@ String plainText(const Range*); UChar* plainTextToMallocAllocatedBuffer(const Range*, unsigned& bufferLength, bool isDisplayString); PassRefPtr<Range> findPlainText(const Range*, const String&, bool forward, bool caseSensitive); +class BitStack { +public: + BitStack(); + + void push(bool); + void pop(); + + bool top() const; + unsigned size() const; + +private: + unsigned m_size; + Vector<unsigned, 1> m_words; +}; + // Iterates through the DOM range, returning all the text, and 0-length boundaries // at points where replaced elements break up the text flow. The text comes back in // chunks so as to optimize for performance of the iteration. @@ -80,27 +95,27 @@ private: bool handleReplacedElement(); bool handleNonTextNode(); void handleTextBox(); - void emitCharacter(UChar, Node *textNode, Node *offsetBaseNode, int textStartOffset, int textEndOffset); - void emitText(Node *textNode, int textStartOffset, int textEndOffset); + void emitCharacter(UChar, Node* textNode, Node* offsetBaseNode, int textStartOffset, int textEndOffset); + void emitText(Node* textNode, int textStartOffset, int textEndOffset); // Current position, not necessarily of the text being returned, but position // as we walk through the DOM tree. - Node *m_node; + Node* m_node; int m_offset; bool m_handledNode; bool m_handledChildren; - bool m_inShadowContent; + BitStack m_fullyClippedStack; // The range. - Node *m_startContainer; + Node* m_startContainer; int m_startOffset; - Node *m_endContainer; + Node* m_endContainer; int m_endOffset; - Node *m_pastEndNode; + Node* m_pastEndNode; // The current text and its position, in the form to be returned from the iterator. - Node *m_positionNode; - mutable Node *m_positionOffsetBaseNode; + Node* m_positionNode; + mutable Node* m_positionOffsetBaseNode; mutable int m_positionStartOffset; mutable int m_positionEndOffset; const UChar* m_textCharacters; @@ -109,10 +124,10 @@ private: // Used when there is still some pending text from the current node; when these // are false and 0, we go back to normal iterating. bool m_needAnotherNewline; - InlineTextBox *m_textBox; + InlineTextBox* m_textBox; // Used to do the whitespace collapsing logic. - Node *m_lastTextNode; + Node* m_lastTextNode; bool m_lastTextNodeEndedWithCollapsedSpace; UChar m_lastCharacter; @@ -135,12 +150,12 @@ private: }; // Iterates through the DOM range, returning all the text, and 0-length boundaries -// at points where replaced elements break up the text flow. The text comes back in +// at points where replaced elements break up the text flow. The text comes back in // chunks so as to optimize for performance of the iteration. class SimplifiedBackwardsTextIterator { public: SimplifiedBackwardsTextIterator(); - explicit SimplifiedBackwardsTextIterator(const Range *); + explicit SimplifiedBackwardsTextIterator(const Range*); bool atEnd() const { return !m_positionNode; } void advance(); @@ -155,7 +170,7 @@ private: bool handleTextNode(); bool handleReplacedElement(); bool handleNonTextNode(); - void emitCharacter(UChar, Node *Node, int startOffset, int endOffset); + void emitCharacter(UChar, Node*, int startOffset, int endOffset); // Current position, not necessarily of the text being returned, but position // as we walk through the DOM tree. @@ -163,7 +178,8 @@ private: int m_offset; bool m_handledNode; bool m_handledChildren; - + BitStack m_fullyClippedStack; + // End of the range. Node* m_startNode; int m_startOffset; @@ -194,7 +210,7 @@ private: class CharacterIterator { public: CharacterIterator(); - explicit CharacterIterator(const Range* r, bool emitCharactersBetweenAllVisiblePositions = false, bool enterTextControls = false); + explicit CharacterIterator(const Range*, bool emitCharactersBetweenAllVisiblePositions = false, bool enterTextControls = false); void advance(int numCharacters); @@ -240,7 +256,7 @@ private: class WordAwareIterator { public: WordAwareIterator(); - explicit WordAwareIterator(const Range *r); + explicit WordAwareIterator(const Range*); bool atEnd() const { return !m_didLookAhead && m_textIterator.atEnd(); } void advance(); |