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

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

Issue 171383002: A thread-safe Media Query Parser (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added a fixme saying that a generic solution can replace this one Created 6 years, 9 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 MediaQueryInputStream_h
6 #define MediaQueryInputStream_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
eseidel 2014/03/08 22:08:07 Please remove this.
13 // tokenizer instead of a state-machine like HTML
14 // so we have our own input stream class. :(
15 class MediaQueryInputStream {
16 WTF_MAKE_NONCOPYABLE(MediaQueryInputStream);
17 WTF_MAKE_FAST_ALLOCATED;
18 public:
19 MediaQueryInputStream(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 getUInt(unsigned, unsigned);
28 double getDouble(unsigned, unsigned);
29
30 template<bool characterPredicate(UChar)>
31 unsigned skipWhilePredicate(unsigned offset)
32 {
33 while ((m_offset + offset) < m_string.length() && characterPredicate(m_s tring[m_offset + offset]))
34 ++offset;
35 return offset;
36 }
37
38 private:
39 size_t m_offset;
40 String m_string;
41 };
42
43 } // namespace WebCore
44
45 #endif // MediaQueryInputStream_h
46
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698