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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 { | 118 { |
| 119 m_input.advance(offset); | 119 m_input.advance(offset); |
| 120 } | 120 } |
| 121 | 121 |
| 122 CSSParserToken CSSTokenizer::whiteSpace(UChar cc) | 122 CSSParserToken CSSTokenizer::whiteSpace(UChar cc) |
| 123 { | 123 { |
| 124 m_input.advanceUntilNonWhitespace(); | 124 m_input.advanceUntilNonWhitespace(); |
| 125 return CSSParserToken(WhitespaceToken); | 125 return CSSParserToken(WhitespaceToken); |
| 126 } | 126 } |
| 127 | 127 |
| 128 static bool popIfBlockMatches(Vector<CSSParserTokenType>& blockStack, CSSParserT okenType type) | |
|
esprehn
2016/06/27 22:16:18
I merged this into the function so I don't need a
| |
| 129 { | |
| 130 if (!blockStack.isEmpty() && blockStack.last() == type) { | |
| 131 blockStack.removeLast(); | |
| 132 return true; | |
| 133 } | |
| 134 return false; | |
| 135 } | |
| 136 | |
| 137 CSSParserToken CSSTokenizer::blockStart(CSSParserTokenType type) | 128 CSSParserToken CSSTokenizer::blockStart(CSSParserTokenType type) |
| 138 { | 129 { |
| 139 m_blockStack.append(type); | 130 m_blockStack.append(type); |
| 140 return CSSParserToken(type, CSSParserToken::BlockStart); | 131 return CSSParserToken(type, CSSParserToken::BlockStart); |
| 141 } | 132 } |
| 142 | 133 |
| 143 CSSParserToken CSSTokenizer::blockStart(CSSParserTokenType blockType, CSSParserT okenType type, StringView name) | 134 CSSParserToken CSSTokenizer::blockStart(CSSParserTokenType blockType, CSSParserT okenType type, StringView name) |
| 144 { | 135 { |
| 145 m_blockStack.append(blockType); | 136 m_blockStack.append(blockType); |
| 146 return CSSParserToken(type, name, CSSParserToken::BlockStart); | 137 return CSSParserToken(type, name, CSSParserToken::BlockStart); |
| 147 } | 138 } |
| 148 | 139 |
| 149 CSSParserToken CSSTokenizer::blockEnd(CSSParserTokenType type, CSSParserTokenTyp e startType) | 140 CSSParserToken CSSTokenizer::blockEnd(CSSParserTokenType type, CSSParserTokenTyp e startType) |
| 150 { | 141 { |
| 151 if (popIfBlockMatches(m_blockStack, startType)) | 142 if (!m_blockStack.isEmpty() && m_blockStack.last() == type) { |
| 143 m_blockStack.removeLast(); | |
| 152 return CSSParserToken(type, CSSParserToken::BlockEnd); | 144 return CSSParserToken(type, CSSParserToken::BlockEnd); |
| 145 } | |
| 153 return CSSParserToken(type); | 146 return CSSParserToken(type); |
| 154 } | 147 } |
| 155 | 148 |
| 156 CSSParserToken CSSTokenizer::leftParenthesis(UChar cc) | 149 CSSParserToken CSSTokenizer::leftParenthesis(UChar cc) |
| 157 { | 150 { |
| 158 return blockStart(LeftParenthesisToken); | 151 return blockStart(LeftParenthesisToken); |
| 159 } | 152 } |
| 160 | 153 |
| 161 CSSParserToken CSSTokenizer::rightParenthesis(UChar cc) | 154 CSSParserToken CSSTokenizer::rightParenthesis(UChar cc) |
| 162 { | 155 { |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 765 return areIdentifier; | 758 return areIdentifier; |
| 766 } | 759 } |
| 767 | 760 |
| 768 StringView CSSTokenizer::registerString(const String& string) | 761 StringView CSSTokenizer::registerString(const String& string) |
| 769 { | 762 { |
| 770 m_scope.storeString(string); | 763 m_scope.storeString(string); |
| 771 return string; | 764 return string; |
| 772 } | 765 } |
| 773 | 766 |
| 774 } // namespace blink | 767 } // namespace blink |
| OLD | NEW |