From 6cbab69a1cef6af5257c84625a61da9c25376d11 Mon Sep 17 00:00:00 2001 From: "ted.mielczarek%gmail.com" Date: Sat, 14 Oct 2006 19:37:59 +0000 Subject: [PATCH] bug 329593, canvas returned .fillStyle string doesn't follow the spec when it's in rgba notation. Patch by asqueella@gmail.com, r+sr=vlad --- content/canvas/src/nsCanvasRenderingContext2D.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/content/canvas/src/nsCanvasRenderingContext2D.cpp b/content/canvas/src/nsCanvasRenderingContext2D.cpp index c8bdee8a5c2a..7ece7e781cf0 100644 --- a/content/canvas/src/nsCanvasRenderingContext2D.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp @@ -609,11 +609,14 @@ nsCanvasRenderingContext2D::StyleColorToString(const nscolor& aColor, nsAString& NS_GET_B(aColor)), aStr); } else { - CopyUTF8toUTF16(nsPrintfCString(100, "rgba(%d,%d,%d,%0.2f)", + // "%0.5f" in nsPrintfCString would use the locale-specific + // decimal separator. That's why we have to do this: + PRUint32 alpha = NS_GET_A(aColor) * 100000 / 255; + CopyUTF8toUTF16(nsPrintfCString(100, "rgba(%d, %d, %d, 0.%d)", NS_GET_R(aColor), NS_GET_G(aColor), NS_GET_B(aColor), - NS_GET_A(aColor) / 255.0f), + alpha), aStr); } }