| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 UChar incrementAndGetCurrentChar8() { | 120 UChar incrementAndGetCurrentChar8() { |
| 121 ASSERT(m_data.string8Ptr); | 121 ASSERT(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 ASSERT(m_data.string16Ptr); |
| 127 return *++m_data.string16Ptr; | 127 return *++m_data.string16Ptr; |
| 128 } | 128 } |
| 129 | 129 |
| 130 UChar getCharByIndex8(unsigned index) { |
| 131 ASSERT(m_data.string8Ptr); |
| 132 m_data.string8Ptr += index; |
| 133 return *m_data.string8Ptr; |
| 134 } |
| 135 |
| 136 UChar getCharByIndex16(unsigned index) { |
| 137 ASSERT(m_data.string16Ptr); |
| 138 m_data.string16Ptr += index; |
| 139 return *m_data.string16Ptr; |
| 140 } |
| 141 |
| 130 String currentSubString(unsigned length) { | 142 String currentSubString(unsigned length) { |
| 131 int offset = m_string.length() - m_length; | 143 int offset = m_string.length() - m_length; |
| 132 return m_string.substring(offset, length); | 144 return m_string.substring(offset, length); |
| 133 } | 145 } |
| 134 | 146 |
| 147 String currentSubString(unsigned pos, unsigned length) { |
| 148 int offset = m_string.length() - m_length + pos; |
| 149 return m_string.substring(offset, length); |
| 150 } |
| 151 |
| 135 ALWAYS_INLINE UChar getCurrentChar() { | 152 ALWAYS_INLINE UChar getCurrentChar() { |
| 136 ASSERT(m_length); | 153 ASSERT(m_length); |
| 137 if (is8Bit()) | 154 if (is8Bit()) |
| 138 return getCurrentChar8(); | 155 return getCurrentChar8(); |
| 139 return getCurrentChar16(); | 156 return getCurrentChar16(); |
| 140 } | 157 } |
| 141 | 158 |
| 142 ALWAYS_INLINE UChar incrementAndGetCurrentChar() { | 159 ALWAYS_INLINE UChar incrementAndGetCurrentChar() { |
| 143 ASSERT(m_length); | 160 ASSERT(m_length); |
| 144 if (is8Bit()) | 161 if (is8Bit()) |
| 145 return incrementAndGetCurrentChar8(); | 162 return incrementAndGetCurrentChar8(); |
| 146 return incrementAndGetCurrentChar16(); | 163 return incrementAndGetCurrentChar16(); |
| 147 } | 164 } |
| 148 | 165 |
| 166 ALWAYS_INLINE UChar getCharByIndex(unsigned index) { |
| 167 ASSERT(m_length - index); |
| 168 if (is8Bit()) |
| 169 return getCharByIndex8(index); |
| 170 return getCharByIndex16(index); |
| 171 } |
| 172 |
| 149 ALWAYS_INLINE bool haveOneCharacterLeft() const { return m_length == 1; } | 173 ALWAYS_INLINE bool haveOneCharacterLeft() const { return m_length == 1; } |
| 150 | 174 |
| 151 ALWAYS_INLINE void decrementLength() { --m_length; } | 175 ALWAYS_INLINE void decrementLength() { --m_length; } |
| 152 | 176 |
| 153 ALWAYS_INLINE int length() const { return m_length; } | 177 ALWAYS_INLINE int length() const { return m_length; } |
| 154 | 178 |
| 155 private: | 179 private: |
| 156 union { | 180 union { |
| 157 const LChar* string8Ptr; | 181 const LChar* string8Ptr; |
| 158 const UChar* string16Ptr; | 182 const UChar* string16Ptr; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 int numberOfCharactersConsumed() const { | 320 int numberOfCharactersConsumed() const { |
| 297 int numberOfPushedCharacters = 0; | 321 int numberOfPushedCharacters = 0; |
| 298 return m_numberOfCharactersConsumedPriorToCurrentString + | 322 return m_numberOfCharactersConsumedPriorToCurrentString + |
| 299 m_currentString.numberOfCharactersConsumed() - | 323 m_currentString.numberOfCharactersConsumed() - |
| 300 numberOfPushedCharacters; | 324 numberOfPushedCharacters; |
| 301 } | 325 } |
| 302 | 326 |
| 303 String toString() const; | 327 String toString() const; |
| 304 | 328 |
| 305 UChar currentChar() const { return m_currentChar; } | 329 UChar currentChar() const { return m_currentChar; } |
| 330 SegmentedSubstring getCurrentString() const { return m_currentString; } |
| 331 |
| 332 String getCurrentSubstring(unsigned length) { |
| 333 return m_currentString.currentSubString(length); |
| 334 } |
| 335 |
| 336 String getCurrentSubstring(unsigned pos, unsigned length) { |
| 337 return m_currentString.currentSubString(pos, length); |
| 338 } |
| 339 |
| 340 bool isEqualToScriptStartTagTemplate(const String& str) { |
| 341 String stringTemplate("<script"); |
| 342 return equalPossiblyIgnoringCase(stringTemplate, str, true); |
| 343 } |
| 344 |
| 345 bool isEqualToScriptEndTagTemplate(const String& str) { |
| 346 String stringTemplate("</script>"); |
| 347 return equalPossiblyIgnoringCase(stringTemplate, str, true); |
| 348 } |
| 306 | 349 |
| 307 // The method is moderately slow, comparing to currentLine method. | 350 // The method is moderately slow, comparing to currentLine method. |
| 308 OrdinalNumber currentColumn() const; | 351 OrdinalNumber currentColumn() const; |
| 309 OrdinalNumber currentLine() const; | 352 OrdinalNumber currentLine() const; |
| 310 // Sets value of line/column variables. Column is specified indirectly by a | 353 // Sets value of line/column variables. Column is specified indirectly by a |
| 311 // parameter columnAftreProlog which is a value of column that we should get | 354 // parameter columnAftreProlog which is a value of column that we should get |
| 312 // after a prolog (first prologLength characters) has been consumed. | 355 // after a prolog (first prologLength characters) has been consumed. |
| 313 void setCurrentPosition(OrdinalNumber line, | 356 void setCurrentPosition(OrdinalNumber line, |
| 314 OrdinalNumber columnAftreProlog, | 357 OrdinalNumber columnAftreProlog, |
| 315 int prologLength); | 358 int prologLength); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 bool m_closed; | 458 bool m_closed; |
| 416 bool m_empty; | 459 bool m_empty; |
| 417 unsigned char m_fastPathFlags; | 460 unsigned char m_fastPathFlags; |
| 418 void (SegmentedString::*m_advanceFunc)(); | 461 void (SegmentedString::*m_advanceFunc)(); |
| 419 void (SegmentedString::*m_advanceAndUpdateLineNumberFunc)(); | 462 void (SegmentedString::*m_advanceAndUpdateLineNumberFunc)(); |
| 420 }; | 463 }; |
| 421 | 464 |
| 422 } // namespace blink | 465 } // namespace blink |
| 423 | 466 |
| 424 #endif | 467 #endif |
| OLD | NEW |