Title: [207539] trunk/Source/WebCore
Revision
207539
Author
hy...@apple.com
Date
2016-10-19 09:38:42 -0700 (Wed, 19 Oct 2016)

Log Message

[CSS Parser] Fix named color parsing
https://bugs.webkit.org/show_bug.cgi?id=163662

Reviewed by Zalan Bujtas.

Named color parsing in the old parser for extended colors relied on constructing a Color with the
name and doing a lookup that way.

The new parser allows the back end to hold a primitive identifier value for extended colors.

StyleColor contains a helper function for looking up the correct color.

This patch switches both the old and the new parsers over to the new StyleColor function.

Also remove some asserts from the CSSSelectorList, since the new parser allows it to be empty and
detects parsing failure that way.

* css/CSSSelectorList.cpp:
(WebCore::CSSSelectorList::CSSSelectorList):
(WebCore::CSSSelectorList::operator=):
* css/StyleColor.cpp:
(WebCore::StyleColor::isColorKeyword):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::colorFromPrimitiveValue):
(WebCore::colorForCSSValue): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (207538 => 207539)


--- trunk/Source/WebCore/ChangeLog	2016-10-19 16:33:03 UTC (rev 207538)
+++ trunk/Source/WebCore/ChangeLog	2016-10-19 16:38:42 UTC (rev 207539)
@@ -1,3 +1,31 @@
+2016-10-19  Dave Hyatt  <hy...@apple.com>
+
+        [CSS Parser] Fix named color parsing
+        https://bugs.webkit.org/show_bug.cgi?id=163662
+
+        Reviewed by Zalan Bujtas.
+
+        Named color parsing in the old parser for extended colors relied on constructing a Color with the
+        name and doing a lookup that way.
+
+        The new parser allows the back end to hold a primitive identifier value for extended colors.
+
+        StyleColor contains a helper function for looking up the correct color.
+
+        This patch switches both the old and the new parsers over to the new StyleColor function.
+
+        Also remove some asserts from the CSSSelectorList, since the new parser allows it to be empty and
+        detects parsing failure that way.
+
+        * css/CSSSelectorList.cpp:
+        (WebCore::CSSSelectorList::CSSSelectorList):
+        (WebCore::CSSSelectorList::operator=):
+        * css/StyleColor.cpp:
+        (WebCore::StyleColor::isColorKeyword):
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::colorFromPrimitiveValue):
+        (WebCore::colorForCSSValue): Deleted.
+
 2016-10-19  Youenn Fablet  <you...@apple.com>
 
         Remove SecurityOrigin::taintsCanvas

Modified: trunk/Source/WebCore/css/CSSSelectorList.cpp (207538 => 207539)


--- trunk/Source/WebCore/css/CSSSelectorList.cpp	2016-10-19 16:33:03 UTC (rev 207538)
+++ trunk/Source/WebCore/css/CSSSelectorList.cpp	2016-10-19 16:38:42 UTC (rev 207539)
@@ -45,7 +45,6 @@
 CSSSelectorList::CSSSelectorList(CSSSelectorList&& other)
     : m_selectorArray(other.m_selectorArray)
 {
-    ASSERT_WITH_SECURITY_IMPLICATION(componentCount());
     other.m_selectorArray = nullptr;
 }
 
@@ -102,7 +101,6 @@
     m_selectorArray = other.m_selectorArray;
     other.m_selectorArray = nullptr;
 
-    ASSERT_WITH_SECURITY_IMPLICATION(componentCount());
     return *this;
 }
 

Modified: trunk/Source/WebCore/css/StyleColor.cpp (207538 => 207539)


--- trunk/Source/WebCore/css/StyleColor.cpp	2016-10-19 16:33:03 UTC (rev 207538)
+++ trunk/Source/WebCore/css/StyleColor.cpp	2016-10-19 16:38:42 UTC (rev 207539)
@@ -48,7 +48,9 @@
 
 bool StyleColor::isColorKeyword(CSSValueID id)
 {
-    return (id >= CSSValueAlpha && id <= CSSValueWebkitText) || id == CSSValueMenu;
+    return (id >= CSSValueAlpha && id <= CSSValueWebkitText)
+        || (id >= CSSValueAliceblue && id <= CSSValueYellowgreen)
+        || id == CSSValueMenu;
 }
 
 bool StyleColor::isSystemColor(CSSValueID id)

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (207538 => 207539)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2016-10-19 16:33:03 UTC (rev 207538)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2016-10-19 16:38:42 UTC (rev 207539)
@@ -120,6 +120,7 @@
 #include "ShadowData.h"
 #include "ShadowRoot.h"
 #include "StyleBuilder.h"
+#include "StyleColor.h"
 #include "StyleCachedImage.h"
 #include "StyleFontSizeFunctions.h"
 #include "StyleGeneratedImage.h"
@@ -1777,43 +1778,6 @@
     fontDescription.setComputedSize(Style::computedFontSizeFromSpecifiedSize(size, fontDescription.isAbsoluteSize(), useSVGZoomRules(), m_state.style(), document()));
 }
 
-static Color colorForCSSValue(CSSValueID cssValueId)
-{
-    struct ColorValue {
-        CSSValueID cssValueId;
-        RGBA32 color;
-    };
-
-    static const ColorValue colorValues[] = {
-        { CSSValueAqua, 0xFF00FFFF },
-        { CSSValueBlack, 0xFF000000 },
-        { CSSValueBlue, 0xFF0000FF },
-        { CSSValueFuchsia, 0xFFFF00FF },
-        { CSSValueGray, 0xFF808080 },
-        { CSSValueGreen, 0xFF008000  },
-        { CSSValueGrey, 0xFF808080 },
-        { CSSValueLime, 0xFF00FF00 },
-        { CSSValueMaroon, 0xFF800000 },
-        { CSSValueNavy, 0xFF000080 },
-        { CSSValueOlive, 0xFF808000  },
-        { CSSValueOrange, 0xFFFFA500 },
-        { CSSValuePurple, 0xFF800080 },
-        { CSSValueRed, 0xFFFF0000 },
-        { CSSValueSilver, 0xFFC0C0C0 },
-        { CSSValueTeal, 0xFF008080  },
-        { CSSValueTransparent, 0x00000000 },
-        { CSSValueWhite, 0xFFFFFFFF },
-        { CSSValueYellow, 0xFFFFFF00 },
-        { CSSValueInvalid, CSSValueInvalid }
-    };
-
-    for (const ColorValue* col = colorValues; col->cssValueId; ++col) {
-        if (col->cssValueId == cssValueId)
-            return col->color;
-    }
-    return RenderTheme::defaultTheme()->systemColor(cssValueId);
-}
-
 bool StyleResolver::colorFromPrimitiveValueIsDerivedFromElement(const CSSPrimitiveValue& value)
 {
     int ident = value.valueID();
@@ -1848,9 +1812,10 @@
         return RenderTheme::focusRingColor();
     case CSSValueCurrentcolor:
         return state.style()->color();
-    default:
-        return colorForCSSValue(ident);
+    default: {
+        return StyleColor::colorFromKeyword(ident);
     }
+    }
 }
 
 void StyleResolver::addViewportDependentMediaQueryResult(const MediaQueryExpression& _expression_, bool result)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to