OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. | 9 * Copyright (C) 2012 Intel Corporation. All rights reserved. |
10 * | 10 * |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 if (!b && (unitflags & (FInteger | FPositiveInteger)) && m_parsedCalcula
tion->isInt()) | 177 if (!b && (unitflags & (FInteger | FPositiveInteger)) && m_parsedCalcula
tion->isInt()) |
178 b = true; | 178 b = true; |
179 if (b && mustBeNonNegative && m_parsedCalculation->isNegative()) | 179 if (b && mustBeNonNegative && m_parsedCalculation->isNegative()) |
180 b = false; | 180 b = false; |
181 // Always resolve calc() to a CSS_NUMBER in the CSSParserValue if there
are no non-numbers specified in the unitflags. | 181 // Always resolve calc() to a CSS_NUMBER in the CSSParserValue if there
are no non-numbers specified in the unitflags. |
182 if (b && !(unitflags & ~(FInteger | FNumber | FPositiveInteger | FNonNeg
))) { | 182 if (b && !(unitflags & ~(FInteger | FNumber | FPositiveInteger | FNonNeg
))) { |
183 double number = m_parsedCalculation->doubleValue(); | 183 double number = m_parsedCalculation->doubleValue(); |
184 if ((unitflags & FPositiveInteger) && number <= 0) { | 184 if ((unitflags & FPositiveInteger) && number <= 0) { |
185 b = false; | 185 b = false; |
186 } else { | 186 } else { |
187 delete value->function; | 187 delete value->calcFunction; |
188 value->unit = CSSPrimitiveValue::CSS_NUMBER; | 188 value->unit = CSSPrimitiveValue::CSS_NUMBER; |
189 value->fValue = number; | 189 value->fValue = number; |
190 value->isInt = m_parsedCalculation->isInt(); | 190 value->isInt = m_parsedCalculation->isInt(); |
191 } | 191 } |
192 m_parsedCalculation.release(); | 192 m_parsedCalculation.release(); |
193 return b; | 193 return b; |
194 } | 194 } |
195 break; | 195 break; |
196 case CalcPercent: | 196 case CalcPercent: |
197 b = (unitflags & FPercent); | 197 b = (unitflags & FPercent); |
(...skipping 25 matching lines...) Expand all Loading... |
223 | 223 |
224 inline bool CSSPropertyParser::shouldAcceptUnitLessValues(CSSParserValue* value,
Units unitflags, CSSParserMode cssParserMode) | 224 inline bool CSSPropertyParser::shouldAcceptUnitLessValues(CSSParserValue* value,
Units unitflags, CSSParserMode cssParserMode) |
225 { | 225 { |
226 // Quirks mode for certain properties and presentation attributes accept uni
t-less values for certain units. | 226 // Quirks mode for certain properties and presentation attributes accept uni
t-less values for certain units. |
227 return (unitflags & (FLength | FAngle)) | 227 return (unitflags & (FLength | FAngle)) |
228 && (!value->fValue // 0 can always be unitless. | 228 && (!value->fValue // 0 can always be unitless. |
229 || isUnitLessLengthParsingEnabledForMode(cssParserMode) // HTML and
SVG attribute values can always be unitless. | 229 || isUnitLessLengthParsingEnabledForMode(cssParserMode) // HTML and
SVG attribute values can always be unitless. |
230 || (cssParserMode == HTMLQuirksMode && (unitflags & FUnitlessQuirk))
); | 230 || (cssParserMode == HTMLQuirksMode && (unitflags & FUnitlessQuirk))
); |
231 } | 231 } |
232 | 232 |
| 233 inline bool isCalculation(CSSParserValue* value) |
| 234 { |
| 235 return value->unit == CSSParserValue::CalcFunction; |
| 236 } |
| 237 |
233 bool CSSPropertyParser::validUnit(CSSParserValue* value, Units unitflags, CSSPar
serMode cssParserMode, ReleaseParsedCalcValueCondition releaseCalc) | 238 bool CSSPropertyParser::validUnit(CSSParserValue* value, Units unitflags, CSSPar
serMode cssParserMode, ReleaseParsedCalcValueCondition releaseCalc) |
234 { | 239 { |
235 if (isCalculation(value)) | 240 if (isCalculation(value)) |
236 return validCalculationUnit(value, unitflags, releaseCalc); | 241 return validCalculationUnit(value, unitflags, releaseCalc); |
237 | 242 |
238 if (unitflags & FNonNeg && value->fValue < 0) | 243 if (unitflags & FNonNeg && value->fValue < 0) |
239 return false; | 244 return false; |
240 switch (value->unit) { | 245 switch (value->unit) { |
241 case CSSPrimitiveValue::CSS_NUMBER: | 246 case CSSPrimitiveValue::CSS_NUMBER: |
242 if (unitflags & FNumber) | 247 if (unitflags & FNumber) |
(...skipping 4705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4948 if (start > end) | 4953 if (start > end) |
4949 return nullptr; | 4954 return nullptr; |
4950 values->append(CSSUnicodeRangeValue::create(start, end)); | 4955 values->append(CSSUnicodeRangeValue::create(start, end)); |
4951 m_valueList->next(); | 4956 m_valueList->next(); |
4952 } while (consumeComma(m_valueList)); | 4957 } while (consumeComma(m_valueList)); |
4953 | 4958 |
4954 return values.release(); | 4959 return values.release(); |
4955 } | 4960 } |
4956 | 4961 |
4957 | 4962 |
4958 bool CSSPropertyParser::isCalculation(CSSParserValue* value) | |
4959 { | |
4960 return (value->unit == CSSParserValue::Function) | |
4961 && (value->function->id == CSSValueCalc | |
4962 || value->function->id == CSSValueWebkitCalc); | |
4963 } | |
4964 | |
4965 inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v) | 4963 inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v) |
4966 { | 4964 { |
4967 bool isPercent; | 4965 bool isPercent; |
4968 double value; | 4966 double value; |
4969 | 4967 |
4970 if (m_parsedCalculation) { | 4968 if (m_parsedCalculation) { |
4971 isPercent = m_parsedCalculation->category() == CalcPercent; | 4969 isPercent = m_parsedCalculation->category() == CalcPercent; |
4972 value = m_parsedCalculation->doubleValue(); | 4970 value = m_parsedCalculation->doubleValue(); |
4973 m_parsedCalculation.release(); | 4971 m_parsedCalculation.release(); |
4974 } else { | 4972 } else { |
(...skipping 2447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7422 return false; | 7420 return false; |
7423 | 7421 |
7424 addProperty(CSSPropertyFontVariantLigatures, ligatureValues.release(), impor
tant); | 7422 addProperty(CSSPropertyFontVariantLigatures, ligatureValues.release(), impor
tant); |
7425 return true; | 7423 return true; |
7426 } | 7424 } |
7427 | 7425 |
7428 bool CSSPropertyParser::parseCalculation(CSSParserValue* value, ValueRange range
) | 7426 bool CSSPropertyParser::parseCalculation(CSSParserValue* value, ValueRange range
) |
7429 { | 7427 { |
7430 ASSERT(isCalculation(value)); | 7428 ASSERT(isCalculation(value)); |
7431 | 7429 |
7432 CSSParserValueList* args = value->function->args.get(); | 7430 CSSParserTokenRange args = value->calcFunction->args; |
7433 if (!args || !args->size()) | |
7434 return false; | |
7435 | 7431 |
7436 ASSERT(!m_parsedCalculation); | 7432 ASSERT(!m_parsedCalculation); |
7437 m_parsedCalculation = CSSCalcValue::create(args, range); | 7433 m_parsedCalculation = CSSCalcValue::create(args, range); |
7438 | 7434 |
7439 if (!m_parsedCalculation) | 7435 if (!m_parsedCalculation) |
7440 return false; | 7436 return false; |
7441 | 7437 |
7442 return true; | 7438 return true; |
7443 } | 7439 } |
7444 | 7440 |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8152 } | 8148 } |
8153 } | 8149 } |
8154 | 8150 |
8155 if (!list->length()) | 8151 if (!list->length()) |
8156 return nullptr; | 8152 return nullptr; |
8157 | 8153 |
8158 return list.release(); | 8154 return list.release(); |
8159 } | 8155 } |
8160 | 8156 |
8161 } // namespace blink | 8157 } // namespace blink |
OLD | NEW |