| 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 4711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4954 if (start > end) | 4959 if (start > end) |
| 4955 return nullptr; | 4960 return nullptr; |
| 4956 values->append(CSSUnicodeRangeValue::create(start, end)); | 4961 values->append(CSSUnicodeRangeValue::create(start, end)); |
| 4957 m_valueList->next(); | 4962 m_valueList->next(); |
| 4958 } while (consumeComma(m_valueList)); | 4963 } while (consumeComma(m_valueList)); |
| 4959 | 4964 |
| 4960 return values.release(); | 4965 return values.release(); |
| 4961 } | 4966 } |
| 4962 | 4967 |
| 4963 | 4968 |
| 4964 bool CSSPropertyParser::isCalculation(CSSParserValue* value) | |
| 4965 { | |
| 4966 return (value->unit == CSSParserValue::Function) | |
| 4967 && (value->function->id == CSSValueCalc | |
| 4968 || value->function->id == CSSValueWebkitCalc); | |
| 4969 } | |
| 4970 | |
| 4971 inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v) | 4969 inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v) |
| 4972 { | 4970 { |
| 4973 bool isPercent; | 4971 bool isPercent; |
| 4974 double value; | 4972 double value; |
| 4975 | 4973 |
| 4976 if (m_parsedCalculation) { | 4974 if (m_parsedCalculation) { |
| 4977 isPercent = m_parsedCalculation->category() == CalcPercent; | 4975 isPercent = m_parsedCalculation->category() == CalcPercent; |
| 4978 value = m_parsedCalculation->doubleValue(); | 4976 value = m_parsedCalculation->doubleValue(); |
| 4979 m_parsedCalculation.release(); | 4977 m_parsedCalculation.release(); |
| 4980 } else { | 4978 } else { |
| (...skipping 2447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7428 return false; | 7426 return false; |
| 7429 | 7427 |
| 7430 addProperty(CSSPropertyFontVariantLigatures, ligatureValues.release(), impor
tant); | 7428 addProperty(CSSPropertyFontVariantLigatures, ligatureValues.release(), impor
tant); |
| 7431 return true; | 7429 return true; |
| 7432 } | 7430 } |
| 7433 | 7431 |
| 7434 bool CSSPropertyParser::parseCalculation(CSSParserValue* value, ValueRange range
) | 7432 bool CSSPropertyParser::parseCalculation(CSSParserValue* value, ValueRange range
) |
| 7435 { | 7433 { |
| 7436 ASSERT(isCalculation(value)); | 7434 ASSERT(isCalculation(value)); |
| 7437 | 7435 |
| 7438 CSSParserValueList* args = value->function->args.get(); | 7436 CSSParserTokenRange args = value->calcFunction->args; |
| 7439 if (!args || !args->size()) | |
| 7440 return false; | |
| 7441 | 7437 |
| 7442 ASSERT(!m_parsedCalculation); | 7438 ASSERT(!m_parsedCalculation); |
| 7443 m_parsedCalculation = CSSCalcValue::create(args, range); | 7439 m_parsedCalculation = CSSCalcValue::create(args, range); |
| 7444 | 7440 |
| 7445 if (!m_parsedCalculation) | 7441 if (!m_parsedCalculation) |
| 7446 return false; | 7442 return false; |
| 7447 | 7443 |
| 7448 return true; | 7444 return true; |
| 7449 } | 7445 } |
| 7450 | 7446 |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8158 } | 8154 } |
| 8159 } | 8155 } |
| 8160 | 8156 |
| 8161 if (!list->length()) | 8157 if (!list->length()) |
| 8162 return nullptr; | 8158 return nullptr; |
| 8163 | 8159 |
| 8164 return list.release(); | 8160 return list.release(); |
| 8165 } | 8161 } |
| 8166 | 8162 |
| 8167 } // namespace blink | 8163 } // namespace blink |
| OLD | NEW |