Source/WebCore/ChangeLog

 12016-09-13 Dean Jackson <dino@apple.com>
 2
 3 Rename parseColorParameters and clean up conditional
 4 https://bugs.webkit.org/show_bug.cgi?id=161941
 5 <rdar://problem/28292750>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 In preparation for adding color() support, rename the existing
 10 parseColorParameters to parseRGBParameters.
 11
 12 Also clean up the logic in the parseColorFromValue function.
 13
 14 * css/parser/CSSParser.cpp:
 15 (WebCore::CSSParser::parseRGBParameters):
 16 (WebCore::CSSParser::parseColorFromValue):
 17 (WebCore::CSSParser::parseColorParameters): Deleted.
 18 * css/parser/CSSParser.h:
 19
1202016-09-12 Dean Jackson <dino@apple.com>
221
322 Replace RGBA32 with Color in member variables

Source/WebCore/css/parser/CSSParser.cpp

@@inline int CSSParser::colorIntFromValue(ValueWithCalculation& valueWithCalculati
76537653 return static_cast<int>(doubleValue);
76547654}
76557655
7656 bool CSSParser::parseColorParameters(CSSParserValue& value, int* colorArray, bool parseAlpha)
 7656bool CSSParser::parseRGBParameters(CSSParserValue& value, int* colorArray, bool parseAlpha)
76577657{
76587658 CSSParserValueList* args = value.function->args.get();
76597659 ValueWithCalculation firstArgumentWithCalculation(*args->current());

@@bool CSSParser::parseColorFromValue(CSSParserValue& value, RGBA32& c)
77527752 && value.function->args->size() == 5 /* rgb + two commas */
77537753 && equalLettersIgnoringASCIICase(value.function->name, "rgb(")) {
77547754 int colorValues[3];
7755  if (!parseColorParameters(value, colorValues, false))
 7755 if (!parseRGBParameters(value, colorValues, false))
77567756 return false;
77577757 c = makeRGB(colorValues[0], colorValues[1], colorValues[2]);
7758  } else {
7759  if (value.unit == CSSParserValue::Function
7760  && value.function->args
7761  && value.function->args->size() == 7 /* rgba + three commas */
7762  && equalLettersIgnoringASCIICase(value.function->name, "rgba(")) {
7763  int colorValues[4];
7764  if (!parseColorParameters(value, colorValues, true))
7765  return false;
7766  c = makeRGBA(colorValues[0], colorValues[1], colorValues[2], colorValues[3]);
7767  } else if (value.unit == CSSParserValue::Function
7768  && value.function->args
7769  && value.function->args->size() == 5 /* hsl + two commas */
7770  && equalLettersIgnoringASCIICase(value.function->name, "hsl(")) {
7771  double colorValues[3];
7772  if (!parseHSLParameters(value, colorValues, false))
7773  return false;
7774  c = makeRGBAFromHSLA(colorValues[0], colorValues[1], colorValues[2], 1.0);
7775  } else if (value.unit == CSSParserValue::Function
7776  && value.function->args
7777  && value.function->args->size() == 7 /* hsla + three commas */
7778  && equalLettersIgnoringASCIICase(value.function->name, "hsla(")) {
7779  double colorValues[4];
7780  if (!parseHSLParameters(value, colorValues, true))
7781  return false;
7782  c = makeRGBAFromHSLA(colorValues[0], colorValues[1], colorValues[2], colorValues[3]);
7783  } else
 7758 } else if (value.unit == CSSParserValue::Function
 7759 && value.function->args
 7760 && value.function->args->size() == 7 /* rgba + three commas */
 7761 && equalLettersIgnoringASCIICase(value.function->name, "rgba(")) {
 7762 int colorValues[4];
 7763 if (!parseRGBParameters(value, colorValues, true))
77847764 return false;
7785  }
 7765 c = makeRGBA(colorValues[0], colorValues[1], colorValues[2], colorValues[3]);
 7766 } else if (value.unit == CSSParserValue::Function
 7767 && value.function->args
 7768 && value.function->args->size() == 5 /* hsl + two commas */
 7769 && equalLettersIgnoringASCIICase(value.function->name, "hsl(")) {
 7770 double colorValues[3];
 7771 if (!parseHSLParameters(value, colorValues, false))
 7772 return false;
 7773 c = makeRGBAFromHSLA(colorValues[0], colorValues[1], colorValues[2], 1.0);
 7774 } else if (value.unit == CSSParserValue::Function
 7775 && value.function->args
 7776 && value.function->args->size() == 7 /* hsla + three commas */
 7777 && equalLettersIgnoringASCIICase(value.function->name, "hsla(")) {
 7778 double colorValues[4];
 7779 if (!parseHSLParameters(value, colorValues, true))
 7780 return false;
 7781 c = makeRGBAFromHSLA(colorValues[0], colorValues[1], colorValues[2], colorValues[3]);
 7782 } else
 7783 return false;
77867784
77877785 return true;
77887786}

Source/WebCore/css/parser/CSSParser.h

@@public:
276276 bool parseCounter(CSSPropertyID, int defaultValue, bool important);
277277 RefPtr<CSSPrimitiveValue> parseCounterContent(CSSParserValueList& args, bool counters);
278278
279  bool parseColorParameters(CSSParserValue&, int* colorValues, bool parseAlpha);
 279 bool parseRGBParameters(CSSParserValue&, int* colorValues, bool parseAlpha);
280280 bool parseHSLParameters(CSSParserValue&, double* colorValues, bool parseAlpha);
281281 RefPtr<CSSPrimitiveValue> parseColor(CSSParserValue* = nullptr);
282282 bool parseColorFromValue(CSSParserValue&, RGBA32&);