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

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

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 #include "config.h"
6 #include "core/css/parser/MediaQueryInputStream.h"
7
8 #include "core/html/parser/InputStreamPreprocessor.h"
9
10 namespace WebCore {
11
12 MediaQueryInputStream::MediaQueryInputStream(String input)
13 : m_offset(0)
14 , m_string(input)
15 {
16 }
17
18 UChar MediaQueryInputStream::currentInputChar()
19 {
20 if (m_offset >= m_string.length())
21 return kEndOfFileMarker;
22 return m_string[m_offset];
23 }
24
25 UChar MediaQueryInputStream::peek(unsigned lookaheadOffset)
26 {
27 if ((m_offset + lookaheadOffset) >= m_string.length())
28 return kEndOfFileMarker;
29 return m_string[m_offset + lookaheadOffset];
30 }
31
32 void MediaQueryInputStream::advance(unsigned offset)
33 {
34 ASSERT(m_offset + offset <= m_string.length() + 1);
35 m_offset += offset;
36 }
37
38 void MediaQueryInputStream::pushBack(UChar cc)
39 {
40 --m_offset;
41 ASSERT(currentInputChar() == cc);
42 }
43
44 unsigned long long MediaQueryInputStream::getUInt(unsigned start, unsigned end)
45 {
46 ASSERT(start <= end && ((m_offset + end) <= m_string.length()));
47 bool isResultOK = false;
48 if (start < end) {
49 unsigned long long result;
50 if (m_string.is8Bit())
51 result = charactersToUInt64Strict(m_string.characters8() + m_offset + start, end - start, &isResultOK);
52 else
53 result = charactersToUInt64Strict(m_string.characters16() + m_offset + start, end - start, &isResultOK);
54 if (isResultOK)
55 return result;
56 }
57 return 0;
58 }
59
60 double MediaQueryInputStream::getDouble(unsigned start, unsigned end)
61 {
62 ASSERT(start <= end && ((m_offset + end) <= m_string.length()));
63 bool isResultOK = false;
64 if (start < end) {
65 double result;
66 if (m_string.is8Bit())
67 result = charactersToDouble(m_string.characters8() + m_offset + star t, end - start, &isResultOK);
68 else
69 result = charactersToDouble(m_string.characters16() + m_offset + sta rt, end - start, &isResultOK);
70 if (isResultOK)
71 return result;
72 }
73 return 0.0;
74 }
75
76 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698