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 *data_.string8_ptr; } | 114 UChar GetCurrentChar8() { return *data_.string8_ptr; } |
115 | 115 |
116 UChar GetCurrentChar16() { | 116 UChar GetCurrentChar16() { |
117 return data_.string16_ptr ? *data_.string16_ptr : 0; | 117 return data_.string16_ptr ? *data_.string16_ptr : 0; |
118 } | 118 } |
119 | 119 |
120 UChar IncrementAndGetCurrentChar8() { | 120 UChar IncrementAndGetCurrentChar8() { |
121 ASSERT(data_.string8_ptr); | 121 DCHECK(data_.string8_ptr); |
122 return *++data_.string8_ptr; | 122 return *++data_.string8_ptr; |
123 } | 123 } |
124 | 124 |
125 UChar IncrementAndGetCurrentChar16() { | 125 UChar IncrementAndGetCurrentChar16() { |
126 ASSERT(data_.string16_ptr); | 126 DCHECK(data_.string16_ptr); |
127 return *++data_.string16_ptr; | 127 return *++data_.string16_ptr; |
128 } | 128 } |
129 | 129 |
130 String CurrentSubString(unsigned length) { | 130 String CurrentSubString(unsigned length) { |
131 int offset = string_.length() - length_; | 131 int offset = string_.length() - length_; |
132 return string_.Substring(offset, length); | 132 return string_.Substring(offset, length); |
133 } | 133 } |
134 | 134 |
135 ALWAYS_INLINE UChar GetCurrentChar() { | 135 ALWAYS_INLINE UChar GetCurrentChar() { |
136 ASSERT(length_); | 136 DCHECK(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(length_); | 143 DCHECK(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 length_ == 1; } | 149 ALWAYS_INLINE bool HaveOneCharacterLeft() const { return length_ == 1; } |
150 | 150 |
151 ALWAYS_INLINE void DecrementLength() { --length_; } | 151 ALWAYS_INLINE void DecrementLength() { --length_; } |
152 | 152 |
153 ALWAYS_INLINE int length() const { return length_; } | 153 ALWAYS_INLINE int length() const { return 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 expected_character) { | 266 void AdvanceAndASSERTIgnoringCase(UChar expected_character) { |
267 DCHECK_EQ(WTF::Unicode::FoldCase(CurrentChar()), | 267 DCHECK_EQ(WTF::Unicode::FoldCase(CurrentChar()), |
268 WTF::Unicode::FoldCase(expected_character)); | 268 WTF::Unicode::FoldCase(expected_character)); |
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 (current_string_.length() > 1) { | 279 if (current_string_.length() > 1) { |
280 int new_line_flag = current_string_.DoNotExcludeLineNumbers(); | 280 int new_line_flag = current_string_.DoNotExcludeLineNumbers(); |
281 current_line_ += new_line_flag; | 281 current_line_ += new_line_flag; |
282 if (new_line_flag) | 282 if (new_line_flag) |
283 number_of_characters_consumed_prior_to_current_line_ = | 283 number_of_characters_consumed_prior_to_current_line_ = |
284 NumberOfCharactersConsumed() + 1; | 284 NumberOfCharactersConsumed() + 1; |
285 DecrementAndCheckLength(); | 285 DecrementAndCheckLength(); |
286 current_char_ = current_string_.IncrementAndGetCurrentChar(); | 286 current_char_ = current_string_.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(current_string_.length() > 1); | 339 DCHECK_GT(current_string_.length(), 1); |
340 current_string_.DecrementLength(); | 340 current_string_.DecrementLength(); |
341 if (current_string_.HaveOneCharacterLeft()) | 341 if (current_string_.HaveOneCharacterLeft()) |
342 UpdateSlowCaseFunctionPointers(); | 342 UpdateSlowCaseFunctionPointers(); |
343 } | 343 } |
344 | 344 |
345 void UpdateAdvanceFunctionPointers() { | 345 void UpdateAdvanceFunctionPointers() { |
346 if (current_string_.length() > 1) { | 346 if (current_string_.length() > 1) { |
347 if (current_string_.Is8Bit()) { | 347 if (current_string_.Is8Bit()) { |
348 advance_func_ = &SegmentedString::Advance8; | 348 advance_func_ = &SegmentedString::Advance8; |
349 fast_path_flags_ = kUse8BitAdvance; | 349 fast_path_flags_ = kUse8BitAdvance; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 bool closed_; | 415 bool closed_; |
416 bool empty_; | 416 bool empty_; |
417 unsigned char fast_path_flags_; | 417 unsigned char fast_path_flags_; |
418 void (SegmentedString::*advance_func_)(); | 418 void (SegmentedString::*advance_func_)(); |
419 void (SegmentedString::*advance_and_update_line_number_func_)(); | 419 void (SegmentedString::*advance_and_update_line_number_func_)(); |
420 }; | 420 }; |
421 | 421 |
422 } // namespace blink | 422 } // namespace blink |
423 | 423 |
424 #endif | 424 #endif |
OLD | NEW |