| 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 #ifndef CSSParserTokenRange_h | 5 #ifndef CSSParserTokenRange_h |
| 6 #define CSSParserTokenRange_h | 6 #define CSSParserTokenRange_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/css/parser/CSSParserToken.h" | 9 #include "core/css/parser/CSSParserToken.h" |
| 10 #include "core/css/parser/CSSTokenizer.h" |
| 10 #include "wtf/Vector.h" | 11 #include "wtf/Vector.h" |
| 11 | 12 |
| 12 namespace blink { | 13 namespace blink { |
| 13 | 14 |
| 14 CORE_EXPORT extern const CSSParserToken& staticEOFToken; | 15 CORE_EXPORT extern const CSSParserToken& staticEOFToken; |
| 15 | 16 |
| 16 // A CSSParserTokenRange is an iterator over a subrange of a vector of CSSParser
Tokens. | 17 // A CSSParserTokenRange is an iterator over a subrange of a vector of CSSParser
Tokens. |
| 17 // Accessing outside of the range will return an endless stream of EOF tokens. | 18 // Accessing outside of the range will return an endless stream of EOF tokens. |
| 18 // This class refers to half-open intervals [first, last). | 19 // This class refers to half-open intervals [first, last). |
| 19 class CORE_EXPORT CSSParserTokenRange { | 20 class CORE_EXPORT CSSParserTokenRange { |
| 20 public: | 21 public: |
| 21 CSSParserTokenRange(const Vector<CSSParserToken>& vector) | 22 CSSParserTokenRange(const Vector<CSSParserToken>& vector, const CSSTokenizer
::Scope* scope) |
| 22 : m_first(vector.begin()) | 23 : m_first(vector.begin()) |
| 23 , m_last(vector.end()) | 24 , m_last(vector.end()) |
| 25 , m_scope(scope) |
| 24 { | 26 { |
| 25 } | 27 } |
| 26 | 28 |
| 27 // This should be called on a range with tokens returned by that range. | 29 // This should be called on a range with tokens returned by that range. |
| 28 CSSParserTokenRange makeSubRange(const CSSParserToken* first, const CSSParse
rToken* last) const; | 30 CSSParserTokenRange makeSubRange(const CSSParserToken* first, const CSSParse
rToken* last) const; |
| 29 | 31 |
| 30 bool atEnd() const { return m_first == m_last; } | 32 bool atEnd() const { return m_first == m_last; } |
| 31 const CSSParserToken* end() const { return m_last; } | 33 const CSSParserToken* end() const { return m_last; } |
| 32 | 34 |
| 33 const CSSParserToken& peek(unsigned offset = 0) const | 35 const CSSParserToken& peek(unsigned offset = 0) const |
| (...skipping 23 matching lines...) Expand all Loading... |
| 57 void consumeComponentValue(); | 59 void consumeComponentValue(); |
| 58 | 60 |
| 59 void consumeWhitespace() | 61 void consumeWhitespace() |
| 60 { | 62 { |
| 61 while (peek().type() == WhitespaceToken) | 63 while (peek().type() == WhitespaceToken) |
| 62 ++m_first; | 64 ++m_first; |
| 63 } | 65 } |
| 64 | 66 |
| 65 String serialize() const; | 67 String serialize() const; |
| 66 | 68 |
| 69 const CSSTokenizer::Scope* scope() const { return m_scope; } |
| 70 |
| 67 // This is only for the inspector integration | 71 // This is only for the inspector integration |
| 68 const CSSParserToken* begin() const { return m_first; } | 72 const CSSParserToken* begin() const { return m_first; } |
| 69 | 73 |
| 70 static void initStaticEOFToken(); | 74 static void initStaticEOFToken(); |
| 71 | 75 |
| 72 private: | 76 private: |
| 73 CSSParserTokenRange(const CSSParserToken* first, const CSSParserToken* last) | 77 CSSParserTokenRange(const CSSParserToken* first, const CSSParserToken* last,
const CSSTokenizer::Scope* scope) |
| 74 : m_first(first) | 78 : m_first(first) |
| 75 , m_last(last) | 79 , m_last(last) |
| 80 , m_scope(scope) |
| 76 { } | 81 { } |
| 77 | 82 |
| 78 const CSSParserToken* m_first; | 83 const CSSParserToken* m_first; |
| 79 const CSSParserToken* m_last; | 84 const CSSParserToken* m_last; |
| 85 const CSSTokenizer::Scope* m_scope; |
| 80 }; | 86 }; |
| 81 | 87 |
| 82 } // namespace | 88 } // namespace |
| 83 | 89 |
| 84 #endif // CSSParserTokenRange_h | 90 #endif // CSSParserTokenRange_h |
| OLD | NEW |