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 "config.h" | 5 #include "config.h" |
6 #include "core/css/parser/CSSParserTokenRange.h" | 6 #include "core/css/parser/CSSParserTokenRange.h" |
7 | 7 |
8 #include "wtf/StaticConstructors.h" | 8 #include "wtf/StaticConstructors.h" |
9 #include "wtf/text/StringBuilder.h" | 9 #include "wtf/text/StringBuilder.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 DEFINE_GLOBAL(CSSParserToken, staticEOFToken); | 13 DEFINE_GLOBAL(CSSParserToken, staticEOFToken); |
14 | 14 |
15 void CSSParserTokenRange::initStaticEOFToken() | 15 void CSSParserTokenRange::initStaticEOFToken() |
16 { | 16 { |
17 new ((void*)&staticEOFToken) CSSParserToken(EOFToken); | 17 new ((void*)&staticEOFToken) CSSParserToken(EOFToken); |
18 } | 18 } |
19 | 19 |
20 CSSParserTokenRange CSSParserTokenRange::makeSubRange(const CSSParserToken* firs
t, const CSSParserToken* last) const | 20 CSSParserTokenRange CSSParserTokenRange::makeSubRange(const CSSParserToken* firs
t, const CSSParserToken* last) const |
21 { | 21 { |
22 if (first == &staticEOFToken) | 22 if (first == &staticEOFToken) |
23 first = m_last; | 23 first = m_last; |
24 if (last == &staticEOFToken) | 24 if (last == &staticEOFToken) |
25 last = m_last; | 25 last = m_last; |
26 ASSERT(first <= last); | 26 ASSERT(first <= last); |
27 return CSSParserTokenRange(first, last); | 27 return CSSParserTokenRange(first, last, m_scope); |
28 } | 28 } |
29 | 29 |
30 CSSParserTokenRange CSSParserTokenRange::consumeBlock() | 30 CSSParserTokenRange CSSParserTokenRange::consumeBlock() |
31 { | 31 { |
32 ASSERT(peek().blockType() == CSSParserToken::BlockStart); | 32 ASSERT(peek().blockType() == CSSParserToken::BlockStart); |
33 const CSSParserToken* start = &peek() + 1; | 33 const CSSParserToken* start = &peek() + 1; |
34 unsigned nestingLevel = 0; | 34 unsigned nestingLevel = 0; |
35 do { | 35 do { |
36 const CSSParserToken& token = consume(); | 36 const CSSParserToken& token = consume(); |
37 if (token.blockType() == CSSParserToken::BlockStart) | 37 if (token.blockType() == CSSParserToken::BlockStart) |
(...skipping 26 matching lines...) Expand all Loading... |
64 // We're supposed to insert comments between certain pairs of token types | 64 // We're supposed to insert comments between certain pairs of token types |
65 // as per spec, but since this is currently only used for @supports CSSOM | 65 // as per spec, but since this is currently only used for @supports CSSOM |
66 // we just get these cases wrong and avoid the additional complexity. | 66 // we just get these cases wrong and avoid the additional complexity. |
67 StringBuilder builder; | 67 StringBuilder builder; |
68 for (const CSSParserToken* it = m_first; it < m_last; ++it) | 68 for (const CSSParserToken* it = m_first; it < m_last; ++it) |
69 it->serialize(builder); | 69 it->serialize(builder); |
70 return builder.toString(); | 70 return builder.toString(); |
71 } | 71 } |
72 | 72 |
73 } // namespace blink | 73 } // namespace blink |
OLD | NEW |