OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * |
| 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are |
| 6 * met: |
| 7 * |
| 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above |
| 11 * copyright notice, this list of conditions and the following disclaimer |
| 12 * in the documentation and/or other materials provided with the |
| 13 * distribution. |
| 14 * * Neither the name of Google Inc. nor the names of its |
| 15 * contributors may be used to endorse or promote products derived from |
| 16 * this software without specific prior written permission. |
| 17 * |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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. |
| 29 */ |
| 30 |
| 31 #ifndef CSSToken_h |
| 32 #define CSSToken_h |
| 33 |
| 34 #include "core/css/CSSPrimitiveValue.h" |
| 35 #include "wtf/text/WTFString.h" |
| 36 |
| 37 namespace WebCore { |
| 38 |
| 39 enum CSSTokenType { |
| 40 IdentToken = 0, |
| 41 FunctionToken = 1, |
| 42 AtKeywordToken = 2, |
| 43 HashToken = 3, |
| 44 StringToken = 4, |
| 45 BadStringToken = 5, |
| 46 URLToken = 6, |
| 47 BadURLToken = 7, |
| 48 DelimToken = 8, |
| 49 NumberToken = 9, |
| 50 PercentageToken = 10, |
| 51 DimensionToken = 11, |
| 52 UnicodeRangeToken = 12, |
| 53 IncludeMatchToken = 13, |
| 54 DashMatchToken = 14, |
| 55 PrefixMatchToken = 15, |
| 56 SuffixMatchToken = 16, |
| 57 SubstringMatchToken = 17, |
| 58 ColumnToken = 18, |
| 59 WhitespaceToken = 19, |
| 60 CDOToken = 20, |
| 61 CDCToken = 21, |
| 62 ColonToken = 22, |
| 63 SemicolonToken = 23, |
| 64 CommaToken = 24, |
| 65 LeftBracketToken = 25, |
| 66 RightBracketToken = 26, |
| 67 LeftParenToken = 27, |
| 68 RightParenToken = 28, |
| 69 LeftBraceToken = 29, |
| 70 RightBraceToken = 30, |
| 71 EOFToken = 31, |
| 72 }; |
| 73 |
| 74 // Probably should just be rolled into TokenType. |
| 75 enum HashTokenType { |
| 76 IdHashToken, |
| 77 UnrestrictedHashToken, |
| 78 }; |
| 79 |
| 80 // Probably should just be rolled into TokenType. |
| 81 enum NumericValueType { |
| 82 IntegerValueType, |
| 83 NumberValueType, |
| 84 }; |
| 85 |
| 86 class CSSToken { |
| 87 public: |
| 88 CSSToken(CSSTokenType); |
| 89 CSSToken(CSSTokenType, String); |
| 90 |
| 91 CSSToken(CSSTokenType, UChar); // for DelimToken |
| 92 CSSToken(CSSTokenType, double, NumericValueType); // for NumberToken |
| 93 |
| 94 // Converts NumberToken to DimensionToken. |
| 95 void convertToDimensionWithUnit(String); |
| 96 |
| 97 // Converts NumberToken to PercentageToken. |
| 98 void convertToPercentage(); |
| 99 |
| 100 CSSTokenType type() const { return m_type; } |
| 101 String value() const { return m_value; } |
| 102 |
| 103 UChar delimiter() const { return m_delimiter; } |
| 104 NumericValueType numericValueType() const { return m_numericValueType; } |
| 105 double numericValue() const { return m_numericValue; } |
| 106 CSSPrimitiveValue::UnitTypes unitType() const { return m_unit; } |
| 107 |
| 108 private: |
| 109 CSSTokenType m_type; |
| 110 String m_value; |
| 111 |
| 112 UChar m_delimiter; // Could be rolled into m_value? |
| 113 |
| 114 NumericValueType m_numericValueType; |
| 115 double m_numericValue; |
| 116 CSSPrimitiveValue::UnitTypes m_unit; |
| 117 }; |
| 118 |
| 119 } |
| 120 |
| 121 #endif // CSSToken_h |
OLD | NEW |