| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 Vector<unsigned, 1> m_words; | 80 Vector<unsigned, 1> m_words; |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 // Iterates through the DOM range, returning all the text, and 0-length boundari
es | 83 // Iterates through the DOM range, returning all the text, and 0-length boundari
es |
| 84 // at points where replaced elements break up the text flow. The text comes bac
k in | 84 // at points where replaced elements break up the text flow. The text comes bac
k in |
| 85 // chunks so as to optimize for performance of the iteration. | 85 // chunks so as to optimize for performance of the iteration. |
| 86 | 86 |
| 87 class TextIterator { | 87 class TextIterator { |
| 88 public: | 88 public: |
| 89 explicit TextIterator(const Range*, TextIteratorBehaviorFlags = TextIterator
DefaultBehavior); | 89 explicit TextIterator(const Range*, TextIteratorBehaviorFlags = TextIterator
DefaultBehavior); |
| 90 // [start, end] indicates the document range that the iteration should take
place within (both ends inclusive). |
| 91 TextIterator(const Position& start, const Position& end, TextIteratorBehavio
rFlags = TextIteratorDefaultBehavior); |
| 90 ~TextIterator(); | 92 ~TextIterator(); |
| 91 | 93 |
| 92 bool atEnd() const { return !m_positionNode || m_shouldStop; } | 94 bool atEnd() const { return !m_positionNode || m_shouldStop; } |
| 93 void advance(); | 95 void advance(); |
| 94 | 96 |
| 95 int length() const { return m_textLength; } | 97 int length() const { return m_textLength; } |
| 96 UChar characterAt(unsigned index) const; | 98 UChar characterAt(unsigned index) const; |
| 97 String substring(unsigned position, unsigned length) const; | 99 String substring(unsigned position, unsigned length) const; |
| 98 void appendTextToStringBuilder(StringBuilder&, unsigned position = 0, unsign
ed maxLength = UINT_MAX) const; | 100 void appendTextToStringBuilder(StringBuilder&, unsigned position = 0, unsign
ed maxLength = UINT_MAX) const; |
| 99 | 101 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 121 | 123 |
| 122 private: | 124 private: |
| 123 enum IterationProgress { | 125 enum IterationProgress { |
| 124 HandledNone, | 126 HandledNone, |
| 125 HandledAuthorShadowRoots, | 127 HandledAuthorShadowRoots, |
| 126 HandledUserAgentShadowRoot, | 128 HandledUserAgentShadowRoot, |
| 127 HandledNode, | 129 HandledNode, |
| 128 HandledChildren | 130 HandledChildren |
| 129 }; | 131 }; |
| 130 | 132 |
| 133 void initialize(const Position& start, const Position& end); |
| 134 |
| 131 int startOffset() const { return m_positionStartOffset; } | 135 int startOffset() const { return m_positionStartOffset; } |
| 132 const String& string() const { return m_text; } | 136 const String& string() const { return m_text; } |
| 133 void exitNode(); | 137 void exitNode(); |
| 134 bool shouldRepresentNodeOffsetZero(); | 138 bool shouldRepresentNodeOffsetZero(); |
| 135 bool shouldEmitSpaceBeforeAndAfterNode(Node*); | 139 bool shouldEmitSpaceBeforeAndAfterNode(Node*); |
| 136 void representNodeOffsetZero(); | 140 void representNodeOffsetZero(); |
| 137 bool handleTextNode(); | 141 bool handleTextNode(); |
| 138 bool handleReplacedElement(); | 142 bool handleReplacedElement(); |
| 139 bool handleNonTextNode(); | 143 bool handleNonTextNode(); |
| 140 void handleTextBox(); | 144 void handleTextBox(); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 Vector<UChar> m_buffer; | 367 Vector<UChar> m_buffer; |
| 364 // Did we have to look ahead in the textIterator to confirm the current chun
k? | 368 // Did we have to look ahead in the textIterator to confirm the current chun
k? |
| 365 bool m_didLookAhead; | 369 bool m_didLookAhead; |
| 366 RefPtr<Range> m_range; | 370 RefPtr<Range> m_range; |
| 367 TextIterator m_textIterator; | 371 TextIterator m_textIterator; |
| 368 }; | 372 }; |
| 369 | 373 |
| 370 } | 374 } |
| 371 | 375 |
| 372 #endif | 376 #endif |
| OLD | NEW |