OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 10 matching lines...) Expand all Loading... | |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef URLRegistry_h | 31 #ifndef NewCSSTokenizer_h |
32 #define URLRegistry_h | 32 #define NewCSSTokenizer_h |
33 | 33 |
34 #include "core/css/parser/CSSToken.h" | |
35 #include "core/html/parser/InputStreamPreprocessor.h" | |
34 #include "wtf/text/WTFString.h" | 36 #include "wtf/text/WTFString.h" |
35 | 37 |
36 namespace WebCore { | 38 namespace WebCore { |
37 | 39 |
38 class KURL; | 40 // The CSS Syntax spec is written as a (fixed size) look-ahead |
39 class SecurityOrigin; | 41 // tokenizer instead of a state-machine like HTML |
40 class URLRegistry; | 42 // so we have our own input stream class. :( |
43 class CSSInputStream { | |
44 WTF_MAKE_NONCOPYABLE(CSSInputStream); | |
45 WTF_MAKE_FAST_ALLOCATED; | |
46 public: | |
47 CSSInputStream(String input); | |
41 | 48 |
42 class URLRegistrable { | 49 UChar currentInputChar(); |
43 public: | 50 UChar nextInputChar(); // peek1(); |
44 virtual ~URLRegistrable() { } | 51 UChar peek2(); |
45 virtual URLRegistry& registry() const = 0; | 52 UChar peek3(); // Needed? |
53 | |
54 void advance(); | |
55 void pushBack(UChar); | |
56 | |
57 private: | |
58 size_t m_offset; | |
59 String m_string; | |
abarth-chromium
2014/01/01 18:47:51
I would have expected you'd want to templatize thi
| |
46 }; | 60 }; |
47 | 61 |
48 class URLRegistry { | 62 |
63 class NewCSSTokenizer { | |
64 WTF_MAKE_NONCOPYABLE(NewCSSTokenizer); | |
49 WTF_MAKE_FAST_ALLOCATED; | 65 WTF_MAKE_FAST_ALLOCATED; |
50 public: | 66 public: |
51 virtual ~URLRegistry() { } | 67 NewCSSTokenizer(); |
52 virtual void registerURL(SecurityOrigin*, const KURL&, URLRegistrable*) = 0; | |
53 virtual void unregisterURL(const KURL&) = 0; | |
54 | 68 |
55 // This is an optional API | 69 CSSToken nextToken(CSSInputStream&); |
56 virtual URLRegistrable* lookup(const String&) { ASSERT_NOT_REACHED(); return 0; } | 70 |
71 private: | |
72 UChar consume(); | |
73 void reconsume(UChar); | |
74 | |
75 CSSToken consumeStringTokenUntil(UChar); | |
76 CSSToken consumeNumericToken(); | |
77 CSSToken consumeIdentLikeToken(); | |
78 CSSToken consumeNumber(); | |
79 CSSToken consumeURLToken(); | |
80 | |
81 void consumeUntilNotWhitespace(); | |
82 void consumeThroughCommentEndOrUntilEOF(); | |
83 | |
84 bool consumeIfNext(UChar); | |
85 bool consumeIfNext(String); | |
86 String consumeName(); | |
87 UChar consumeEscape(); | |
88 | |
89 bool nextIsValidEscape(); | |
90 bool nextCharIsName(); | |
91 bool nextTwoCharsAreValidEscape(); | |
92 bool nextCharsAreNumber(); | |
93 bool nextCharsAreIdentifier(); | |
94 | |
95 CSSInputStream* m_input; | |
57 }; | 96 }; |
58 | 97 |
59 } // namespace WebCore | 98 } // namespace WebCore |
60 | 99 |
61 #endif // URLRegistry_h | 100 #endif // NewCSSTokenizer_h |
OLD | NEW |