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

Unified Diff: Source/platform/graphics/Color.cpp

Issue 114373004: Remove the SVGColor and SVGPaint DOM interfaces (were deprecated). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: text diff fix Created 7 years 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/platform/graphics/Color.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/Color.cpp
diff --git a/Source/platform/graphics/Color.cpp b/Source/platform/graphics/Color.cpp
index 97b568a1a9eaf868f60b175dd7ebc29622cb72e0..17d2cc63b96b2a4a8af65872bd6c362be6ca58c4 100644
--- a/Source/platform/graphics/Color.cpp
+++ b/Source/platform/graphics/Color.cpp
@@ -200,6 +200,35 @@ Color::Color(const char* name)
}
}
+String Color::serializedAsCSSComponentValue() const
+{
+ StringBuilder result;
+ result.reserveCapacity(32);
+ bool colorHasAlpha = hasAlpha();
+ if (colorHasAlpha)
+ result.append("rgba(", 5);
+ else
+ result.append("rgb(", 4);
+
+ result.appendNumber(static_cast<unsigned char>(red()));
+ result.append(", ", 2);
+
+ result.appendNumber(static_cast<unsigned char>(green()));
+ result.append(", ", 2);
+
+ result.appendNumber(static_cast<unsigned char>(blue()));
+ if (colorHasAlpha) {
+ result.append(", ", 2);
+
+ NumberToStringBuffer buffer;
+ const char* alphaString = numberToFixedPrecisionString(alpha() / 255.0f, 6, buffer, true);
+ result.append(alphaString, strlen(alphaString));
+ }
+
+ result.append(')');
+ return result.toString();
+}
+
String Color::serialized() const
{
if (!hasAlpha()) {
« no previous file with comments | « Source/platform/graphics/Color.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698