Rename parseColorParameters and clean up conditional
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Sep 2016 20:12:14 +0000 (20:12 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Sep 2016 20:12:14 +0000 (20:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=161941
<rdar://problem/28292750>

Reviewed by Dan Bates.

In preparation for adding color() support, rename the existing
parseColorParameters to parseRGBParameters.

Also clean up the logic in the parseColorFromValue function.

* css/parser/CSSParser.cpp:
(WebCore::CSSParser::parseRGBParameters):
(WebCore::CSSParser::parseColorFromValue):
(WebCore::CSSParser::parseColorParameters): Deleted.
* css/parser/CSSParser.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205924 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/css/parser/CSSParser.cpp
Source/WebCore/css/parser/CSSParser.h

index a706e1b..f47f78d 100644 (file)
@@ -1,3 +1,22 @@
+2016-09-13  Dean Jackson  <dino@apple.com>
+
+        Rename parseColorParameters and clean up conditional
+        https://bugs.webkit.org/show_bug.cgi?id=161941
+        <rdar://problem/28292750>
+
+        Reviewed by Dan Bates.
+
+        In preparation for adding color() support, rename the existing
+        parseColorParameters to parseRGBParameters.
+
+        Also clean up the logic in the parseColorFromValue function.
+
+        * css/parser/CSSParser.cpp:
+        (WebCore::CSSParser::parseRGBParameters):
+        (WebCore::CSSParser::parseColorFromValue):
+        (WebCore::CSSParser::parseColorParameters): Deleted.
+        * css/parser/CSSParser.h:
+
 2016-09-14  Chris Dumez  <cdumez@apple.com>
 
         Add support hr.color IDL attribute
index 9b25292..1d8b5cf 100644 (file)
@@ -7600,7 +7600,7 @@ inline int CSSParser::colorIntFromValue(ValueWithCalculation& valueWithCalculati
     return static_cast<int>(doubleValue);
 }
 
-bool CSSParser::parseColorParameters(CSSParserValue& value, int* colorArray, bool parseAlpha)
+bool CSSParser::parseRGBParameters(CSSParserValue& value, int* colorArray, bool parseAlpha)
 {
     CSSParserValueList* args = value.function->args.get();
     ValueWithCalculation firstArgumentWithCalculation(*args->current());
@@ -7699,37 +7699,35 @@ bool CSSParser::parseColorFromValue(CSSParserValue& value, RGBA32& c)
         && value.function->args->size() == 5 /* rgb + two commas */
         && equalLettersIgnoringASCIICase(value.function->name, "rgb(")) {
         int colorValues[3];
-        if (!parseColorParameters(value, colorValues, false))
+        if (!parseRGBParameters(value, colorValues, false))
             return false;
         c = makeRGB(colorValues[0], colorValues[1], colorValues[2]);
-    } else {
-        if (value.unit == CSSParserValue::Function
-            && value.function->args
-            && value.function->args->size() == 7 /* rgba + three commas */
-            && equalLettersIgnoringASCIICase(value.function->name, "rgba(")) {
-            int colorValues[4];
-            if (!parseColorParameters(value, colorValues, true))
-                return false;
-            c = makeRGBA(colorValues[0], colorValues[1], colorValues[2], colorValues[3]);
-        } else if (value.unit == CSSParserValue::Function
-            && value.function->args
-            && value.function->args->size() == 5 /* hsl + two commas */
-            && equalLettersIgnoringASCIICase(value.function->name, "hsl(")) {
-            double colorValues[3];
-            if (!parseHSLParameters(value, colorValues, false))
-                return false;
-            c = makeRGBAFromHSLA(colorValues[0], colorValues[1], colorValues[2], 1.0);
-        } else if (value.unit == CSSParserValue::Function
-            && value.function->args
-            && value.function->args->size() == 7 /* hsla + three commas */
-            && equalLettersIgnoringASCIICase(value.function->name, "hsla(")) {
-            double colorValues[4];
-            if (!parseHSLParameters(value, colorValues, true))
-                return false;
-            c = makeRGBAFromHSLA(colorValues[0], colorValues[1], colorValues[2], colorValues[3]);
-        } else
+    } else if (value.unit == CSSParserValue::Function
+        && value.function->args
+        && value.function->args->size() == 7 /* rgba + three commas */
+        && equalLettersIgnoringASCIICase(value.function->name, "rgba(")) {
+        int colorValues[4];
+        if (!parseRGBParameters(value, colorValues, true))
             return false;
-    }
+        c = makeRGBA(colorValues[0], colorValues[1], colorValues[2], colorValues[3]);
+    } else if (value.unit == CSSParserValue::Function
+        && value.function->args
+        && value.function->args->size() == 5 /* hsl + two commas */
+        && equalLettersIgnoringASCIICase(value.function->name, "hsl(")) {
+        double colorValues[3];
+        if (!parseHSLParameters(value, colorValues, false))
+            return false;
+        c = makeRGBAFromHSLA(colorValues[0], colorValues[1], colorValues[2], 1.0);
+    } else if (value.unit == CSSParserValue::Function
+        && value.function->args
+        && value.function->args->size() == 7 /* hsla + three commas */
+        && equalLettersIgnoringASCIICase(value.function->name, "hsla(")) {
+        double colorValues[4];
+        if (!parseHSLParameters(value, colorValues, true))
+            return false;
+        c = makeRGBAFromHSLA(colorValues[0], colorValues[1], colorValues[2], colorValues[3]);
+    } else
+        return false;
 
     return true;
 }
index cf97141..c09947f 100644 (file)
@@ -275,7 +275,7 @@ public:
     bool parseCounter(CSSPropertyID, int defaultValue, bool important);
     RefPtr<CSSPrimitiveValue> parseCounterContent(CSSParserValueList& args, bool counters);
 
-    bool parseColorParameters(CSSParserValue&, int* colorValues, bool parseAlpha);
+    bool parseRGBParameters(CSSParserValue&, int* colorValues, bool parseAlpha);
     bool parseHSLParameters(CSSParserValue&, double* colorValues, bool parseAlpha);
     RefPtr<CSSPrimitiveValue> parseColor(CSSParserValue* = nullptr);
     bool parseColorFromValue(CSSParserValue&, RGBA32&);