OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CSSParserObserverWrapper_h | |
6 #define CSSParserObserverWrapper_h | |
7 | |
8 #include "core/css/parser/CSSParserObserver.h" | |
9 #include "wtf/Allocator.h" | |
10 | |
11 namespace blink { | |
12 | |
13 class CSSParserToken; | |
14 class CSSParserTokenRange; | |
15 | |
16 class CSSParserObserverWrapper { | |
17 STACK_ALLOCATED(); | |
18 | |
19 public: | |
20 explicit CSSParserObserverWrapper(CSSParserObserver& observer) | |
21 : m_observer(observer) {} | |
22 | |
23 unsigned startOffset(const CSSParserTokenRange&); | |
24 unsigned previousTokenStartOffset(const CSSParserTokenRange&); | |
25 unsigned endOffset(const CSSParserTokenRange&); // Includes trailing comments | |
26 | |
27 void skipCommentsBefore(const CSSParserTokenRange&, bool leaveDirectlyBefore); | |
28 void yieldCommentsBefore(const CSSParserTokenRange&); | |
29 | |
30 CSSParserObserver& observer() { return m_observer; } | |
31 void addComment(unsigned startOffset, | |
32 unsigned endOffset, | |
33 unsigned tokensBefore) { | |
34 CommentPosition position = {startOffset, endOffset, tokensBefore}; | |
35 m_commentOffsets.push_back(position); | |
36 } | |
37 void addToken(unsigned startOffset) { m_tokenOffsets.push_back(startOffset); } | |
38 void finalizeConstruction(CSSParserToken* firstParserToken) { | |
39 m_firstParserToken = firstParserToken; | |
40 m_commentIterator = m_commentOffsets.begin(); | |
41 } | |
42 | |
43 private: | |
44 CSSParserObserver& m_observer; | |
45 Vector<unsigned> m_tokenOffsets; | |
46 CSSParserToken* m_firstParserToken; | |
47 | |
48 struct CommentPosition { | |
49 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
50 unsigned startOffset; | |
51 unsigned endOffset; | |
52 unsigned tokensBefore; | |
53 }; | |
54 | |
55 Vector<CommentPosition> m_commentOffsets; | |
56 Vector<CommentPosition>::iterator m_commentIterator; | |
57 }; | |
58 | |
59 } // namespace blink | |
60 | |
61 #endif // CSSParserObserverWrapper_h | |
OLD | NEW |