| 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 |
| 11 #include "core/css/parser/CSSParserIdioms.h" | 11 #include "core/css/parser/CSSParserIdioms.h" |
| 12 #include "core/css/parser/CSSParserObserverWrapper.h" | 12 #include "core/css/parser/CSSParserObserverWrapper.h" |
| 13 #include "core/css/parser/CSSParserTokenRange.h" | 13 #include "core/css/parser/CSSParserTokenRange.h" |
| 14 #include "core/css/parser/CSSTokenizerInputStream.h" | 14 #include "core/css/parser/CSSTokenizerInputStream.h" |
| 15 #include "core/html/parser/HTMLParserIdioms.h" | 15 #include "core/html/parser/HTMLParserIdioms.h" |
| 16 #include "wtf/text/CharacterNames.h" | 16 #include "wtf/text/CharacterNames.h" |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 | 19 |
| 20 CSSTokenizer::Scope::Scope(const String& string) : m_string(string) { | 20 CSSTokenizer::Scope::Scope(const String& string) : m_string(string) { |
| 21 // According to the spec, we should perform preprocessing here. | 21 // According to the spec, we should perform preprocessing here. |
| 22 // See: http://dev.w3.org/csswg/css-syntax/#input-preprocessing | 22 // See: http://dev.w3.org/csswg/css-syntax/#input-preprocessing |
| 23 // | 23 // |
| 24 // However, we can skip this step since: | 24 // However, we can skip this step since: |
| 25 // * We're using HTML spaces (which accept \r and \f as a valid white space) | 25 // * We're using HTML spaces (which accept \r and \f as a valid white space) |
| 26 // * Do not count white spaces | 26 // * Do not count white spaces |
| 27 // * CSSTokenizerInputStream::nextInputChar() replaces NULLs for replacement c
haracters | 27 // * CSSTokenizerInputStream::nextInputChar() replaces NULLs for replacement |
| 28 // characters |
| 28 | 29 |
| 29 if (string.isEmpty()) | 30 if (string.isEmpty()) |
| 30 return; | 31 return; |
| 31 | 32 |
| 32 // To avoid resizing we err on the side of reserving too much space. | 33 // To avoid resizing we err on the side of reserving too much space. |
| 33 // Most strings we tokenize have about 3.5 to 5 characters per token. | 34 // Most strings we tokenize have about 3.5 to 5 characters per token. |
| 34 m_tokens.reserveInitialCapacity(string.length() / 3); | 35 m_tokens.reserveInitialCapacity(string.length() / 3); |
| 35 | 36 |
| 36 CSSTokenizerInputStream input(string); | 37 CSSTokenizerInputStream input(string); |
| 37 CSSTokenizer tokenizer(input, *this); | 38 CSSTokenizer tokenizer(input, *this); |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 reconsume(first); | 684 reconsume(first); |
| 684 return areIdentifier; | 685 return areIdentifier; |
| 685 } | 686 } |
| 686 | 687 |
| 687 StringView CSSTokenizer::registerString(const String& string) { | 688 StringView CSSTokenizer::registerString(const String& string) { |
| 688 m_scope.storeString(string); | 689 m_scope.storeString(string); |
| 689 return string; | 690 return string; |
| 690 } | 691 } |
| 691 | 692 |
| 692 } // namespace blink | 693 } // namespace blink |
| OLD | NEW |