Index: third_party/WebKit/Source/core/css/parser/CSSParserTokenStream.cpp |
diff --git a/third_party/WebKit/Source/core/css/parser/CSSParserTokenStream.cpp b/third_party/WebKit/Source/core/css/parser/CSSParserTokenStream.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..377f21ad22a00b0befa9ec08587d0a174adf4bf9 |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/css/parser/CSSParserTokenStream.cpp |
@@ -0,0 +1,38 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "core/css/parser/CSSParserTokenStream.h" |
+ |
+namespace blink { |
+ |
+CSSParserTokenStream::~CSSParserTokenStream() { |
+ if (!m_isSubStream) |
+ return; |
+ |
+ // TODO(timloh): Should be using CSSTokenier::skipToBlockEnd() instead. |
Charlie Harrison
2017/01/09 21:35:07
s/CSSTokenier/CSSTokenizer
|
+ consumeUntilAtEndOrPeekedTypeIs<>(); |
+ |
+ if (m_tokenizer.m_tokens.size() == m_currentIndex) { |
Charlie Harrison
2017/01/09 21:35:07
could these conditions be re-written in terms of h
|
+ DCHECK(m_tokenizer.m_finishedTokenizing); |
+ m_tokenizer.m_tokens.remove(m_startIndex, m_currentIndex - m_startIndex); |
+ } else { |
+ DCHECK_EQ(m_tokenizer.m_tokens.size(), m_currentIndex + 1); |
+ DCHECK_EQ(m_tokenizer.m_tokens[m_currentIndex].getBlockType(), |
+ CSSParserToken::BlockEnd); |
+ m_tokenizer.m_tokens.remove(m_startIndex, |
+ m_currentIndex - m_startIndex + 1); |
+ } |
+} |
+ |
+const CSSParserToken& CSSParserTokenStream::peekInternal() { |
Charlie Harrison
2017/01/09 21:35:07
If tokenizeSingle() returned a token, this could b
|
+ DCHECK_LE(m_currentIndex, m_tokenizer.m_tokens.size()); |
+ if (m_currentIndex == m_tokenizer.m_tokens.size()) { |
+ m_tokenizer.tokenizeSingle(); |
+ if (m_tokenizer.m_finishedTokenizing) |
+ return staticEOFToken; |
+ } |
+ return m_tokenizer.m_tokens[m_currentIndex]; |
+} |
+ |
+} // namespace blink |