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 UnitType::Number in the CSSParserValue if
there are no non-numbers specified in the unitflags. | 181 // Always resolve calc() to a UnitType::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->setUnit(CSSPrimitiveValue::UnitType::Number); | 188 value->setUnit(CSSPrimitiveValue::UnitType::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->m_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::UnitType::Number: | 246 case CSSPrimitiveValue::UnitType::Number: |
242 if (unitflags & FNumber) | 247 if (unitflags & FNumber) |
(...skipping 4711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4954 UChar32 end = current->m_unicodeRange.end; | 4959 UChar32 end = current->m_unicodeRange.end; |
4955 if (start > end) | 4960 if (start > end) |
4956 return nullptr; | 4961 return nullptr; |
4957 values->append(CSSUnicodeRangeValue::create(start, end)); | 4962 values->append(CSSUnicodeRangeValue::create(start, end)); |
4958 m_valueList->next(); | 4963 m_valueList->next(); |
4959 } while (consumeComma(m_valueList)); | 4964 } while (consumeComma(m_valueList)); |
4960 | 4965 |
4961 return values.release(); | 4966 return values.release(); |
4962 } | 4967 } |
4963 | 4968 |
4964 | |
4965 bool CSSPropertyParser::isCalculation(CSSParserValue* value) | |
4966 { | |
4967 return (value->m_unit == CSSParserValue::Function) | |
4968 && (value->function->id == CSSValueCalc | |
4969 || value->function->id == CSSValueWebkitCalc); | |
4970 } | |
4971 | |
4972 inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v) | 4969 inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v) |
4973 { | 4970 { |
4974 bool isPercent; | 4971 bool isPercent; |
4975 double value; | 4972 double value; |
4976 | 4973 |
4977 if (m_parsedCalculation) { | 4974 if (m_parsedCalculation) { |
4978 isPercent = m_parsedCalculation->category() == CalcPercent; | 4975 isPercent = m_parsedCalculation->category() == CalcPercent; |
4979 value = m_parsedCalculation->doubleValue(); | 4976 value = m_parsedCalculation->doubleValue(); |
4980 m_parsedCalculation.release(); | 4977 m_parsedCalculation.release(); |
4981 } else { | 4978 } else { |
(...skipping 2453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7435 return false; | 7432 return false; |
7436 | 7433 |
7437 addProperty(CSSPropertyFontVariantLigatures, ligatureValues.release(), impor
tant); | 7434 addProperty(CSSPropertyFontVariantLigatures, ligatureValues.release(), impor
tant); |
7438 return true; | 7435 return true; |
7439 } | 7436 } |
7440 | 7437 |
7441 bool CSSPropertyParser::parseCalculation(CSSParserValue* value, ValueRange range
) | 7438 bool CSSPropertyParser::parseCalculation(CSSParserValue* value, ValueRange range
) |
7442 { | 7439 { |
7443 ASSERT(isCalculation(value)); | 7440 ASSERT(isCalculation(value)); |
7444 | 7441 |
7445 CSSParserValueList* args = value->function->args.get(); | 7442 CSSParserTokenRange args = value->calcFunction->args; |
7446 if (!args || !args->size()) | |
7447 return false; | |
7448 | 7443 |
7449 ASSERT(!m_parsedCalculation); | 7444 ASSERT(!m_parsedCalculation); |
7450 m_parsedCalculation = CSSCalcValue::create(args, range); | 7445 m_parsedCalculation = CSSCalcValue::create(args, range); |
7451 | 7446 |
7452 if (!m_parsedCalculation) | 7447 if (!m_parsedCalculation) |
7453 return false; | 7448 return false; |
7454 | 7449 |
7455 return true; | 7450 return true; |
7456 } | 7451 } |
7457 | 7452 |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8165 } | 8160 } |
8166 } | 8161 } |
8167 | 8162 |
8168 if (!list->length()) | 8163 if (!list->length()) |
8169 return nullptr; | 8164 return nullptr; |
8170 | 8165 |
8171 return list.release(); | 8166 return list.release(); |
8172 } | 8167 } |
8173 | 8168 |
8174 } // namespace blink | 8169 } // namespace blink |
OLD | NEW |