Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(758)

Unified Diff: Source/core/svg/SVGPaint.cpp

Issue 189913012: Merge SVGColor into SVGPaint (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix system color test Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/svg/SVGPaint.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGPaint.cpp
diff --git a/Source/core/svg/SVGPaint.cpp b/Source/core/svg/SVGPaint.cpp
index 893c19c4d4675029c02030cf9473214ba4dddc8f..7eb67bda05a80de31037ebd405defa08caf59a1c 100644
--- a/Source/core/svg/SVGPaint.cpp
+++ b/Source/core/svg/SVGPaint.cpp
@@ -24,34 +24,13 @@
#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ExceptionState.h"
+#include "core/css/RGBColor.h"
+#include "core/css/parser/BisonCSSParser.h"
namespace WebCore {
-static inline SVGColor::SVGColorType colorTypeForPaintType(const SVGPaint::SVGPaintType& paintType)
-{
- switch (paintType) {
- case SVGPaint::SVG_PAINTTYPE_NONE:
- case SVGPaint::SVG_PAINTTYPE_UNKNOWN:
- case SVGPaint::SVG_PAINTTYPE_URI:
- case SVGPaint::SVG_PAINTTYPE_URI_NONE:
- return SVGColor::SVG_COLORTYPE_UNKNOWN;
- case SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR:
- case SVGPaint::SVG_PAINTTYPE_RGBCOLOR:
- return SVGColor::SVG_COLORTYPE_RGBCOLOR;
- case SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
- case SVGPaint::SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
- return SVGColor::SVG_COLORTYPE_RGBCOLOR_ICCCOLOR;
- case SVGPaint::SVG_PAINTTYPE_URI_CURRENTCOLOR:
- case SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR:
- return SVGColor::SVG_COLORTYPE_CURRENTCOLOR;
- }
-
- ASSERT_NOT_REACHED();
- return SVGColor::SVG_COLORTYPE_UNKNOWN;
-}
-
SVGPaint::SVGPaint(const SVGPaintType& paintType, const String& uri)
- : SVGColor(SVGPaintClass, colorTypeForPaintType(paintType))
+ : CSSValue(SVGPaintClass)
, m_paintType(paintType)
, m_uri(uri)
{
@@ -64,19 +43,18 @@ String SVGPaint::customCSSText() const
return String();
case SVG_PAINTTYPE_RGBCOLOR:
case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
+ return m_color.serializedAsCSSComponentValue();
case SVG_PAINTTYPE_CURRENTCOLOR:
- return SVGColor::customCSSText();
+ return "currentColor";
case SVG_PAINTTYPE_NONE:
return "none";
case SVG_PAINTTYPE_URI_NONE:
return m_uri + " none";
case SVG_PAINTTYPE_URI_CURRENTCOLOR:
+ return "url(" + m_uri + ") currentColor";
case SVG_PAINTTYPE_URI_RGBCOLOR:
case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: {
- String color = SVGColor::customCSSText();
- if (color.isEmpty())
- return m_uri;
- return "url(" + m_uri + ") " + color;
+ return "url(" + m_uri + ") " + m_color.serializedAsCSSComponentValue();
}
case SVG_PAINTTYPE_URI:
return "url(" + m_uri + ')';
@@ -87,8 +65,9 @@ String SVGPaint::customCSSText() const
}
SVGPaint::SVGPaint(const SVGPaint& cloneFrom)
- : SVGColor(SVGPaintClass, cloneFrom)
+ : CSSValue(SVGPaintClass, /*isCSSOMSafe*/ true)
, m_paintType(cloneFrom.m_paintType)
+ , m_color(cloneFrom.m_color)
, m_uri(cloneFrom.m_uri)
{
}
@@ -100,7 +79,17 @@ PassRefPtrWillBeRawPtr<SVGPaint> SVGPaint::cloneForCSSOM() const
bool SVGPaint::equals(const SVGPaint& other) const
{
- return m_paintType == other.m_paintType && m_uri == other.m_uri && SVGColor::equals(other);
+ return m_paintType == other.m_paintType && m_uri == other.m_uri && m_color == other.m_color;
+}
+
+StyleColor SVGPaint::colorFromRGBColorString(const String& colorString)
+{
+ // FIXME: Rework css parser so it is more SVG aware.
+ RGBA32 color;
+ if (BisonCSSParser::parseColor(color, colorString.stripWhiteSpace()))
+ return StyleColor(color);
+ // FIXME: This branch catches the string currentColor, but we should error if we have an illegal color value.
+ return StyleColor::currentColor();
}
}
« no previous file with comments | « Source/core/svg/SVGPaint.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698