Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: Source/core/css/parser/CSSInputStream.h

Issue 171383002: A thread-safe Media Query Parser (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Refactored and passes tests Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CSSInputStream_h
6 #define CSSInputStream_h
7
8 #include "wtf/text/WTFString.h"
9
10 namespace WebCore {
11
12 // The CSS Syntax spec is written as a (fixed size) look-ahead
13 // tokenizer instead of a state-machine like HTML
14 // so we have our own input stream class. :(
15 class CSSInputStream {
16 WTF_MAKE_NONCOPYABLE(CSSInputStream);
17 WTF_MAKE_FAST_ALLOCATED;
18 public:
19 CSSInputStream(String input);
20
21 UChar currentInputChar();
22 UChar peek(unsigned);
23
24 void advance(unsigned = 1);
25 void pushBack(UChar);
26
27 unsigned long long getNumber(unsigned, unsigned);
28
29 template<bool characterPredicate(UChar)>
30 unsigned skipWhilePredicate(unsigned offset)
31 {
32 while ((m_offset + offset) < m_string.length() && characterPredicate(m_s tring[m_offset + offset]))
33 ++offset;
34 return offset;
35 }
36
37 private:
38 size_t m_offset;
39 String m_string;
40 };
41
42 } // namespace WebCore
43
44 #endif // CSSInputStream_h
45
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698