OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 | 3 |
4 This library is free software; you can redistribute it and/or | 4 This library is free software; you can redistribute it and/or |
5 modify it under the terms of the GNU Library General Public | 5 modify it under the terms of the GNU Library General Public |
6 License as published by the Free Software Foundation; either | 6 License as published by the Free Software Foundation; either |
7 version 2 of the License, or (at your option) any later version. | 7 version 2 of the License, or (at your option) any later version. |
8 | 8 |
9 This library is distributed in the hope that it will be useful, | 9 This library is distributed in the hope that it will be useful, |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 return true; | 111 return true; |
112 } | 112 } |
113 | 113 |
114 UChar getCurrentChar8() { return *m_data.string8Ptr; } | 114 UChar getCurrentChar8() { return *m_data.string8Ptr; } |
115 | 115 |
116 UChar getCurrentChar16() { | 116 UChar getCurrentChar16() { |
117 return m_data.string16Ptr ? *m_data.string16Ptr : 0; | 117 return m_data.string16Ptr ? *m_data.string16Ptr : 0; |
118 } | 118 } |
119 | 119 |
120 UChar incrementAndGetCurrentChar8() { | 120 UChar incrementAndGetCurrentChar8() { |
121 ASSERT(m_data.string8Ptr); | 121 DCHECK(m_data.string8Ptr); |
122 return *++m_data.string8Ptr; | 122 return *++m_data.string8Ptr; |
123 } | 123 } |
124 | 124 |
125 UChar incrementAndGetCurrentChar16() { | 125 UChar incrementAndGetCurrentChar16() { |
126 ASSERT(m_data.string16Ptr); | 126 DCHECK(m_data.string16Ptr); |
127 return *++m_data.string16Ptr; | 127 return *++m_data.string16Ptr; |
128 } | 128 } |
129 | 129 |
130 String currentSubString(unsigned length) { | 130 String currentSubString(unsigned length) { |
131 int offset = m_string.length() - m_length; | 131 int offset = m_string.length() - m_length; |
132 return m_string.substring(offset, length); | 132 return m_string.substring(offset, length); |
133 } | 133 } |
134 | 134 |
135 ALWAYS_INLINE UChar getCurrentChar() { | 135 ALWAYS_INLINE UChar getCurrentChar() { |
136 ASSERT(m_length); | 136 DCHECK(m_length); |
137 if (is8Bit()) | 137 if (is8Bit()) |
138 return getCurrentChar8(); | 138 return getCurrentChar8(); |
139 return getCurrentChar16(); | 139 return getCurrentChar16(); |
140 } | 140 } |
141 | 141 |
142 ALWAYS_INLINE UChar incrementAndGetCurrentChar() { | 142 ALWAYS_INLINE UChar incrementAndGetCurrentChar() { |
143 ASSERT(m_length); | 143 DCHECK(m_length); |
144 if (is8Bit()) | 144 if (is8Bit()) |
145 return incrementAndGetCurrentChar8(); | 145 return incrementAndGetCurrentChar8(); |
146 return incrementAndGetCurrentChar16(); | 146 return incrementAndGetCurrentChar16(); |
147 } | 147 } |
148 | 148 |
149 ALWAYS_INLINE bool haveOneCharacterLeft() const { return m_length == 1; } | 149 ALWAYS_INLINE bool haveOneCharacterLeft() const { return m_length == 1; } |
150 | 150 |
151 ALWAYS_INLINE void decrementLength() { --m_length; } | 151 ALWAYS_INLINE void decrementLength() { --m_length; } |
152 | 152 |
153 ALWAYS_INLINE int length() const { return m_length; } | 153 ALWAYS_INLINE int length() const { return m_length; } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 advance(); | 263 advance(); |
264 } | 264 } |
265 | 265 |
266 void advanceAndASSERTIgnoringCase(UChar expectedCharacter) { | 266 void advanceAndASSERTIgnoringCase(UChar expectedCharacter) { |
267 DCHECK_EQ(WTF::Unicode::foldCase(currentChar()), | 267 DCHECK_EQ(WTF::Unicode::foldCase(currentChar()), |
268 WTF::Unicode::foldCase(expectedCharacter)); | 268 WTF::Unicode::foldCase(expectedCharacter)); |
269 advance(); | 269 advance(); |
270 } | 270 } |
271 | 271 |
272 void advancePastNonNewline() { | 272 void advancePastNonNewline() { |
273 ASSERT(currentChar() != '\n'); | 273 DCHECK_NE(currentChar(), '\n'); |
274 advance(); | 274 advance(); |
275 } | 275 } |
276 | 276 |
277 void advancePastNewlineAndUpdateLineNumber() { | 277 void advancePastNewlineAndUpdateLineNumber() { |
278 ASSERT(currentChar() == '\n'); | 278 DCHECK_EQ(currentChar(), '\n'); |
279 if (m_currentString.length() > 1) { | 279 if (m_currentString.length() > 1) { |
280 int newLineFlag = m_currentString.doNotExcludeLineNumbers(); | 280 int newLineFlag = m_currentString.doNotExcludeLineNumbers(); |
281 m_currentLine += newLineFlag; | 281 m_currentLine += newLineFlag; |
282 if (newLineFlag) | 282 if (newLineFlag) |
283 m_numberOfCharactersConsumedPriorToCurrentLine = | 283 m_numberOfCharactersConsumedPriorToCurrentLine = |
284 numberOfCharactersConsumed() + 1; | 284 numberOfCharactersConsumed() + 1; |
285 decrementAndCheckLength(); | 285 decrementAndCheckLength(); |
286 m_currentChar = m_currentString.incrementAndGetCurrentChar(); | 286 m_currentChar = m_currentString.incrementAndGetCurrentChar(); |
287 return; | 287 return; |
288 } | 288 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 void advanceAndUpdateLineNumber8(); | 329 void advanceAndUpdateLineNumber8(); |
330 void advanceAndUpdateLineNumber16(); | 330 void advanceAndUpdateLineNumber16(); |
331 void advanceSlowCase(); | 331 void advanceSlowCase(); |
332 void advanceAndUpdateLineNumberSlowCase(); | 332 void advanceAndUpdateLineNumberSlowCase(); |
333 void advanceEmpty(); | 333 void advanceEmpty(); |
334 void advanceSubstring(); | 334 void advanceSubstring(); |
335 | 335 |
336 void updateSlowCaseFunctionPointers(); | 336 void updateSlowCaseFunctionPointers(); |
337 | 337 |
338 void decrementAndCheckLength() { | 338 void decrementAndCheckLength() { |
339 ASSERT(m_currentString.length() > 1); | 339 DCHECK_GT(m_currentString.length(), 1); |
340 m_currentString.decrementLength(); | 340 m_currentString.decrementLength(); |
341 if (m_currentString.haveOneCharacterLeft()) | 341 if (m_currentString.haveOneCharacterLeft()) |
342 updateSlowCaseFunctionPointers(); | 342 updateSlowCaseFunctionPointers(); |
343 } | 343 } |
344 | 344 |
345 void updateAdvanceFunctionPointers() { | 345 void updateAdvanceFunctionPointers() { |
346 if (m_currentString.length() > 1) { | 346 if (m_currentString.length() > 1) { |
347 if (m_currentString.is8Bit()) { | 347 if (m_currentString.is8Bit()) { |
348 m_advanceFunc = &SegmentedString::advance8; | 348 m_advanceFunc = &SegmentedString::advance8; |
349 m_fastPathFlags = Use8BitAdvance; | 349 m_fastPathFlags = Use8BitAdvance; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 bool m_closed; | 415 bool m_closed; |
416 bool m_empty; | 416 bool m_empty; |
417 unsigned char m_fastPathFlags; | 417 unsigned char m_fastPathFlags; |
418 void (SegmentedString::*m_advanceFunc)(); | 418 void (SegmentedString::*m_advanceFunc)(); |
419 void (SegmentedString::*m_advanceAndUpdateLineNumberFunc)(); | 419 void (SegmentedString::*m_advanceAndUpdateLineNumberFunc)(); |
420 }; | 420 }; |
421 | 421 |
422 } // namespace blink | 422 } // namespace blink |
423 | 423 |
424 #endif | 424 #endif |
OLD | NEW |