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/html/parser/HTMLParserIdioms.h" | 14 #include "core/html/parser/HTMLParserIdioms.h" |
15 #include "wtf/text/CharacterNames.h" | 15 #include "wtf/text/CharacterNames.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 | 18 |
19 CSSTokenizer::CSSTokenizer(const String& string) : input_(string) { | 19 CSSTokenizer::CSSTokenizer(const String& string) : input_(string) { |
20 // According to the spec, we should perform preprocessing here. | 20 // According to the spec, we should perform preprocessing here. |
21 // See: http://dev.w3.org/csswg/css-syntax/#input-preprocessing | 21 // See: http://dev.w3.org/csswg/css-syntax/#input-preprocessing |
22 // | 22 // |
23 // However, we can skip this step since: | 23 // However, we can skip this step since: |
24 // * We're using HTML spaces (which accept \r and \f as a valid white space) | 24 // * We're using HTML spaces (which accept \r and \f as a valid white space) |
25 // * Do not count white spaces | 25 // * Do not count white spaces |
26 // * CSSTokenizerInputStream::nextInputChar() replaces NULLs for replacement | 26 // * CSSTokenizerInputStream::NextInputChar() replaces NULLs for replacement |
27 // characters | 27 // characters |
28 | 28 |
29 if (string.IsEmpty()) | 29 if (string.IsEmpty()) |
30 return; | 30 return; |
31 | 31 |
32 // To avoid resizing we err on the side of reserving too much space. | 32 // 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. | 33 // Most strings we tokenize have about 3.5 to 5 characters per token. |
34 tokens_.ReserveInitialCapacity(string.length() / 3); | 34 tokens_.ReserveInitialCapacity(string.length() / 3); |
35 | 35 |
36 while (true) { | 36 while (true) { |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 Reconsume(first); | 677 Reconsume(first); |
678 return are_identifier; | 678 return are_identifier; |
679 } | 679 } |
680 | 680 |
681 StringView CSSTokenizer::RegisterString(const String& string) { | 681 StringView CSSTokenizer::RegisterString(const String& string) { |
682 string_pool_.push_back(string); | 682 string_pool_.push_back(string); |
683 return string; | 683 return string; |
684 } | 684 } |
685 | 685 |
686 } // namespace blink | 686 } // namespace blink |
OLD | NEW |