Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/css/parser/CSSTokenizer.h" | 5 #include "core/css/parser/CSSTokenizer.h" |
| 6 | 6 |
| 7 namespace blink { | 7 namespace blink { |
| 8 #include "core/CSSTokenizerCodepoints.cpp" | 8 #include "core/CSSTokenizerCodepoints.cpp" |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 660 } | 660 } |
| 661 return false; | 661 return false; |
| 662 } | 662 } |
| 663 | 663 |
| 664 // http://www.w3.org/TR/css3-syntax/#consume-a-name | 664 // http://www.w3.org/TR/css3-syntax/#consume-a-name |
| 665 StringView CSSTokenizer::consumeName() | 665 StringView CSSTokenizer::consumeName() |
| 666 { | 666 { |
| 667 // Names without escapes get handled without allocations | 667 // Names without escapes get handled without allocations |
| 668 for (unsigned size = 0; ; ++size) { | 668 for (unsigned size = 0; ; ++size) { |
| 669 UChar cc = m_input.peekWithoutReplacement(size); | 669 UChar cc = m_input.peekWithoutReplacement(size); |
| 670 if (cc == '\0' || cc == '\\') | 670 if (isNameCodePoint(cc)) |
| 671 continue; | |
| 672 // peekWithoutReplacement will return NUL when we hit the end of the | |
| 673 // input. In that case we want to still use the rangeAt() fast path | |
| 674 // below. | |
| 675 if (cc == '\0' && m_input.offset() + size < m_input.length()) | |
|
Timothy Loh
2016/06/27 00:14:25
good find!
| |
| 671 break; | 676 break; |
| 672 if (!isNameCodePoint(cc)) { | 677 if (cc == '\\') |
| 673 unsigned startOffset = m_input.offset(); | 678 break; |
| 674 m_input.advance(size); | 679 unsigned startOffset = m_input.offset(); |
| 675 return m_input.rangeAt(startOffset, size); | 680 m_input.advance(size); |
| 676 } | 681 return m_input.rangeAt(startOffset, size); |
| 677 } | 682 } |
| 678 | 683 |
| 679 StringBuilder result; | 684 StringBuilder result; |
| 680 while (true) { | 685 while (true) { |
| 681 UChar cc = consume(); | 686 UChar cc = consume(); |
| 682 if (isNameCodePoint(cc)) { | 687 if (isNameCodePoint(cc)) { |
| 683 result.append(cc); | 688 result.append(cc); |
| 684 continue; | 689 continue; |
| 685 } | 690 } |
| 686 if (twoCharsAreValidEscape(cc, m_input.nextInputChar())) { | 691 if (twoCharsAreValidEscape(cc, m_input.nextInputChar())) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 767 return areIdentifier; | 772 return areIdentifier; |
| 768 } | 773 } |
| 769 | 774 |
| 770 StringView CSSTokenizer::registerString(const String& string) | 775 StringView CSSTokenizer::registerString(const String& string) |
| 771 { | 776 { |
| 772 m_scope.storeString(string); | 777 m_scope.storeString(string); |
| 773 return string; | 778 return string; |
| 774 } | 779 } |
| 775 | 780 |
| 776 } // namespace blink | 781 } // namespace blink |
| OLD | NEW |