| Index: Source/core/css/parser/MediaQueryTokenizer.h
|
| diff --git a/Source/core/css/parser/MediaQueryTokenizer.h b/Source/core/css/parser/MediaQueryTokenizer.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..cfa2f690ac61f9ec44a5a7d637d5d5b312325f02
|
| --- /dev/null
|
| +++ b/Source/core/css/parser/MediaQueryTokenizer.h
|
| @@ -0,0 +1,134 @@
|
| +/*
|
| + * Copyright (C) 2013 Google Inc. All rights reserved.
|
| + *
|
| + * Redistribution and use in source and binary forms, with or without
|
| + * modification, are permitted provided that the following conditions are
|
| + * met:
|
| + *
|
| + * * Redistributions of source code must retain the above copyright
|
| + * notice, this list of conditions and the following disclaimer.
|
| + * * Redistributions in binary form must reproduce the above
|
| + * copyright notice, this list of conditions and the following disclaimer
|
| + * in the documentation and/or other materials provided with the
|
| + * distribution.
|
| + * * Neither the name of Google Inc. nor the names of its
|
| + * contributors may be used to endorse or promote products derived from
|
| + * this software without specific prior written permission.
|
| + *
|
| + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| + */
|
| +
|
| +#ifndef MediaQueryTokenizer_h
|
| +#define MediaQueryTokenizer_h
|
| +
|
| +#include "core/css/parser/CSSToken.h"
|
| +#include "core/html/parser/InputStreamPreprocessor.h"
|
| +#include "wtf/text/WTFString.h"
|
| +
|
| +#define CODE_POINTS_NUM 128
|
| +
|
| +namespace WebCore {
|
| +
|
| +class CSSInputStream;
|
| +
|
| +class MediaQueryTokenizer {
|
| + WTF_MAKE_NONCOPYABLE(MediaQueryTokenizer);
|
| + WTF_MAKE_FAST_ALLOCATED;
|
| +public:
|
| + MediaQueryTokenizer();
|
| +
|
| + CSSToken nextToken(CSSInputStream&);
|
| + static void tokenize(String, Vector<CSSToken>&);
|
| +
|
| +private:
|
| + UChar consume();
|
| + void consume(unsigned);
|
| + void reconsume(UChar);
|
| +
|
| + CSSToken consumeNumericToken();
|
| + CSSToken consumeIdentLikeToken();
|
| + CSSToken consumeNumber();
|
| +
|
| + void consumeUntilNotWhitespace();
|
| +
|
| + bool consumeIfNext(UChar);
|
| + String consumeName();
|
| + UChar consumeEscape();
|
| +
|
| + bool nextTwoCharsAreValidEscape();
|
| + bool nextCharsAreNumber();
|
| + bool nextCharsAreIdentifier();
|
| +
|
| + typedef CSSToken (MediaQueryTokenizer::*CodePoint)(UChar);
|
| +
|
| + class CodePoints {
|
| + public:
|
| + CodePoint codePoints[CODE_POINTS_NUM];
|
| +
|
| + CodePoints()
|
| + {
|
| + memset(codePoints, 0, CODE_POINTS_NUM);
|
| + codePoints['\n'] = &MediaQueryTokenizer::whiteSpace;
|
| + codePoints['\r'] = &MediaQueryTokenizer::whiteSpace;
|
| + codePoints['\t'] = &MediaQueryTokenizer::whiteSpace;
|
| + codePoints[' '] = &MediaQueryTokenizer::whiteSpace;
|
| + codePoints['\f'] = &MediaQueryTokenizer::whiteSpace;
|
| + codePoints['('] = &MediaQueryTokenizer::leftParen;
|
| + codePoints[')'] = &MediaQueryTokenizer::rightParen;
|
| + codePoints['+'] = &MediaQueryTokenizer::plusOrFullStop;
|
| + codePoints['.'] = &MediaQueryTokenizer::plusOrFullStop;
|
| + codePoints[','] = &MediaQueryTokenizer::comma;
|
| + codePoints['-'] = &MediaQueryTokenizer::hyphenMinus;
|
| + codePoints['/'] = &MediaQueryTokenizer::solidus;
|
| + codePoints[':'] = &MediaQueryTokenizer::colon;
|
| + codePoints[';'] = &MediaQueryTokenizer::semiColon;
|
| + codePoints['\\'] = &MediaQueryTokenizer::reverseSolidus;
|
| + for (unsigned char digit = '0'; digit <= '9'; ++digit)
|
| + codePoints[digit] = &MediaQueryTokenizer::asciiDigit;
|
| + for (unsigned char alpha = 'a'; alpha <= 'z'; ++alpha)
|
| + codePoints[alpha] = &MediaQueryTokenizer::nameStart;
|
| + for (unsigned char alpha = 'A'; alpha <= 'Z'; ++alpha)
|
| + codePoints[alpha] = &MediaQueryTokenizer::nameStart;
|
| + codePoints['_'] = &MediaQueryTokenizer::nameStart;
|
| + codePoints[kEndOfFileMarker] = &MediaQueryTokenizer::endOfFile;
|
| + }
|
| + };
|
| +
|
| + CodePoints* getCodePoints()
|
| + {
|
| + static CodePoints codePoints;
|
| + return &codePoints;
|
| + }
|
| +
|
| + CSSToken whiteSpace(UChar);
|
| + CSSToken leftParen(UChar);
|
| + CSSToken rightParen(UChar);
|
| + CSSToken plusOrFullStop(UChar);
|
| + CSSToken comma(UChar);
|
| + CSSToken hyphenMinus(UChar);
|
| + CSSToken solidus(UChar);
|
| + CSSToken colon(UChar);
|
| + CSSToken semiColon(UChar);
|
| + CSSToken reverseSolidus(UChar);
|
| + CSSToken asciiDigit(UChar);
|
| + CSSToken nameStart(UChar);
|
| + CSSToken endOfFile(UChar);
|
| +
|
| + CSSInputStream* m_input;
|
| +};
|
| +
|
| +
|
| +
|
| +} // namespace WebCore
|
| +
|
| +#endif // MediaQueryTokenizer_h
|
|
|