| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 #include "platform/FloatConversion.h" | 75 #include "platform/FloatConversion.h" |
| 76 #include "platform/RuntimeEnabledFeatures.h" | 76 #include "platform/RuntimeEnabledFeatures.h" |
| 77 #include "wtf/BitArray.h" | 77 #include "wtf/BitArray.h" |
| 78 #include "wtf/HexNumber.h" | 78 #include "wtf/HexNumber.h" |
| 79 #include "wtf/text/StringBuffer.h" | 79 #include "wtf/text/StringBuffer.h" |
| 80 #include "wtf/text/StringBuilder.h" | 80 #include "wtf/text/StringBuilder.h" |
| 81 #include "wtf/text/StringImpl.h" | 81 #include "wtf/text/StringImpl.h" |
| 82 #include "wtf/text/TextEncoding.h" | 82 #include "wtf/text/TextEncoding.h" |
| 83 #include <limits.h> | 83 #include <limits.h> |
| 84 | 84 |
| 85 using namespace std; | |
| 86 | |
| 87 namespace WebCore { | 85 namespace WebCore { |
| 88 | 86 |
| 89 static const double MAX_SCALE = 1000000; | 87 static const double MAX_SCALE = 1000000; |
| 90 static const unsigned minRepetitions = 10000; | 88 static const unsigned minRepetitions = 10000; |
| 91 | 89 |
| 92 template <unsigned N> | 90 template <unsigned N> |
| 93 static bool equal(const CSSParserString& a, const char (&b)[N]) | 91 static bool equal(const CSSParserString& a, const char (&b)[N]) |
| 94 { | 92 { |
| 95 unsigned length = N - 1; // Ignore the trailing null character | 93 unsigned length = N - 1; // Ignore the trailing null character |
| 96 if (a.length() != length) | 94 if (a.length() != length) |
| (...skipping 5188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5285 if (parseAlpha) { | 5283 if (parseAlpha) { |
| 5286 v = args->next(); | 5284 v = args->next(); |
| 5287 if (v->unit != CSSParserValue::Operator && v->iValue != ',') | 5285 if (v->unit != CSSParserValue::Operator && v->iValue != ',') |
| 5288 return false; | 5286 return false; |
| 5289 v = args->next(); | 5287 v = args->next(); |
| 5290 if (!validUnit(v, FNumber, HTMLStandardMode)) | 5288 if (!validUnit(v, FNumber, HTMLStandardMode)) |
| 5291 return false; | 5289 return false; |
| 5292 const double value = parsedDouble(v, ReleaseParsedCalcValue); | 5290 const double value = parsedDouble(v, ReleaseParsedCalcValue); |
| 5293 // Convert the floating pointer number of alpha to an integer in the ran
ge [0, 256), | 5291 // Convert the floating pointer number of alpha to an integer in the ran
ge [0, 256), |
| 5294 // with an equal distribution across all 256 values. | 5292 // with an equal distribution across all 256 values. |
| 5295 colorArray[3] = static_cast<int>(max(0.0, min(1.0, value)) * nextafter(2
56.0, 0.0)); | 5293 colorArray[3] = static_cast<int>(std::max(0.0, std::min(1.0, value)) * n
extafter(256.0, 0.0)); |
| 5296 } | 5294 } |
| 5297 return true; | 5295 return true; |
| 5298 } | 5296 } |
| 5299 | 5297 |
| 5300 // The CSS3 specification defines the format of a HSL color as | 5298 // The CSS3 specification defines the format of a HSL color as |
| 5301 // hsl(<number>, <percent>, <percent>) | 5299 // hsl(<number>, <percent>, <percent>) |
| 5302 // and with alpha, the format is | 5300 // and with alpha, the format is |
| 5303 // hsla(<number>, <percent>, <percent>, <number>) | 5301 // hsla(<number>, <percent>, <percent>, <number>) |
| 5304 // The first value, HUE, is in an angle with a value between 0 and 360 | 5302 // The first value, HUE, is in an angle with a value between 0 and 360 |
| 5305 bool CSSPropertyParser::parseHSLParameters(CSSParserValue* value, double* colorA
rray, bool parseAlpha) | 5303 bool CSSPropertyParser::parseHSLParameters(CSSParserValue* value, double* colorA
rray, bool parseAlpha) |
| 5306 { | 5304 { |
| 5307 CSSParserValueList* args = value->function->args.get(); | 5305 CSSParserValueList* args = value->function->args.get(); |
| 5308 CSSParserValue* v = args->current(); | 5306 CSSParserValue* v = args->current(); |
| 5309 // Get the first value | 5307 // Get the first value |
| 5310 if (!validUnit(v, FNumber, HTMLStandardMode)) | 5308 if (!validUnit(v, FNumber, HTMLStandardMode)) |
| 5311 return false; | 5309 return false; |
| 5312 // normalize the Hue value and change it to be between 0 and 1.0 | 5310 // normalize the Hue value and change it to be between 0 and 1.0 |
| 5313 colorArray[0] = (((static_cast<int>(parsedDouble(v, ReleaseParsedCalcValue))
% 360) + 360) % 360) / 360.0; | 5311 colorArray[0] = (((static_cast<int>(parsedDouble(v, ReleaseParsedCalcValue))
% 360) + 360) % 360) / 360.0; |
| 5314 for (int i = 1; i < 3; i++) { | 5312 for (int i = 1; i < 3; i++) { |
| 5315 v = args->next(); | 5313 v = args->next(); |
| 5316 if (v->unit != CSSParserValue::Operator && v->iValue != ',') | 5314 if (v->unit != CSSParserValue::Operator && v->iValue != ',') |
| 5317 return false; | 5315 return false; |
| 5318 v = args->next(); | 5316 v = args->next(); |
| 5319 if (!validUnit(v, FPercent, HTMLStandardMode)) | 5317 if (!validUnit(v, FPercent, HTMLStandardMode)) |
| 5320 return false; | 5318 return false; |
| 5321 colorArray[i] = max(0.0, min(100.0, parsedDouble(v, ReleaseParsedCalcVal
ue))) / 100.0; // needs to be value between 0 and 1.0 | 5319 colorArray[i] = std::max(0.0, std::min(100.0, parsedDouble(v, ReleasePar
sedCalcValue))) / 100.0; // needs to be value between 0 and 1.0 |
| 5322 } | 5320 } |
| 5323 if (parseAlpha) { | 5321 if (parseAlpha) { |
| 5324 v = args->next(); | 5322 v = args->next(); |
| 5325 if (v->unit != CSSParserValue::Operator && v->iValue != ',') | 5323 if (v->unit != CSSParserValue::Operator && v->iValue != ',') |
| 5326 return false; | 5324 return false; |
| 5327 v = args->next(); | 5325 v = args->next(); |
| 5328 if (!validUnit(v, FNumber, HTMLStandardMode)) | 5326 if (!validUnit(v, FNumber, HTMLStandardMode)) |
| 5329 return false; | 5327 return false; |
| 5330 colorArray[3] = max(0.0, min(1.0, parsedDouble(v, ReleaseParsedCalcValue
))); | 5328 colorArray[3] = std::max(0.0, std::min(1.0, parsedDouble(v, ReleaseParse
dCalcValue))); |
| 5331 } | 5329 } |
| 5332 return true; | 5330 return true; |
| 5333 } | 5331 } |
| 5334 | 5332 |
| 5335 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseColor(CSSParse
rValue* value) | 5333 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseColor(CSSParse
rValue* value) |
| 5336 { | 5334 { |
| 5337 RGBA32 c = Color::transparent; | 5335 RGBA32 c = Color::transparent; |
| 5338 if (!parseColorFromValue(value ? value : m_valueList->current(), c)) | 5336 if (!parseColorFromValue(value ? value : m_valueList->current(), c)) |
| 5339 return nullptr; | 5337 return nullptr; |
| 5340 return cssValuePool().createColorValue(c); | 5338 return cssValuePool().createColorValue(c); |
| (...skipping 3088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8429 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); | 8427 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); |
| 8430 if (!seenStroke) | 8428 if (!seenStroke) |
| 8431 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke)
); | 8429 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke)
); |
| 8432 if (!seenMarkers) | 8430 if (!seenMarkers) |
| 8433 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers
)); | 8431 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers
)); |
| 8434 | 8432 |
| 8435 return parsedValues.release(); | 8433 return parsedValues.release(); |
| 8436 } | 8434 } |
| 8437 | 8435 |
| 8438 } // namespace WebCore | 8436 } // namespace WebCore |
| OLD | NEW |