From ee3dc59fbfd9c8367aa8c255bfc35807701eb196 Mon Sep 17 00:00:00 2001 From: "glazman%netscape.com" Date: Fri, 13 Dec 2002 08:56:21 +0000 Subject: [PATCH] fixing regression in composer, it was impossible to set foreground and background color; b=184505, r=brade, sr=kin, q=is this my last checkin? git-svn-id: svn://10.0.0.236/trunk@135236 18797224-902f-48f8-a5cc-f745e15eee43 --- .../editor/libeditor/html/nsHTMLCSSUtils.cpp | 42 +++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/mozilla/editor/libeditor/html/nsHTMLCSSUtils.cpp b/mozilla/editor/libeditor/html/nsHTMLCSSUtils.cpp index 4509a636390..8f2cd7298ab 100644 --- a/mozilla/editor/libeditor/html/nsHTMLCSSUtils.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLCSSUtils.cpp @@ -54,6 +54,7 @@ #include "nsTextEditUtils.h" #include "nsUnicharUtils.h" #include "nsHTMLCSSUtils.h" +#include "nsColor.h" static void ProcessBValue(const nsAString * aInputString, nsAString & aOutputString, @@ -1194,9 +1195,40 @@ nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode, aIsSet = PRBool(ChangeCSSInlineStyleTxn::ValueIncludes(valueString, val, PR_FALSE)); } - else if ((nsIEditProperty::font == aHTMLProperty) && aHTMLAttribute - && aHTMLAttribute->Equals(NS_LITERAL_STRING("color"))) { - aIsSet = PR_TRUE; + else if (aHTMLAttribute && + ( (nsIEditProperty::font == aHTMLProperty && + aHTMLAttribute->Equals(NS_LITERAL_STRING("color"))) || + aHTMLAttribute->Equals(NS_LITERAL_STRING("bgcolor")))) { + if (htmlValueString.IsEmpty()) + aIsSet = PR_TRUE; + else { + nscolor rgba; + nsAutoString subStr; + htmlValueString.Right(subStr, htmlValueString.Length()-1); + if (NS_ColorNameToRGB(htmlValueString, &rgba) || + NS_HexToRGB(subStr, &rgba)) { + nsAutoString htmlColor, tmpStr; + htmlColor.Append(NS_LITERAL_STRING("rgb(")); + + NS_NAMED_LITERAL_STRING(comma, ", "); + + tmpStr.AppendInt(NS_GET_R(rgba), 10); + htmlColor.Append(tmpStr + comma); + + tmpStr.Truncate(); + tmpStr.AppendInt(NS_GET_G(rgba), 10); + htmlColor.Append(tmpStr + comma); + + tmpStr.Truncate(); + tmpStr.AppendInt(NS_GET_B(rgba), 10); + htmlColor.Append(tmpStr); + + htmlColor.Append(PRUnichar(')')); + aIsSet = htmlColor.EqualsIgnoreCase(valueString); + } + else + aIsSet = htmlValueString.EqualsIgnoreCase(valueString); + } } else if (nsIEditProperty::tt == aHTMLProperty) { @@ -1221,10 +1253,6 @@ nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode, } return NS_OK; } - else if (aHTMLAttribute && aHTMLAttribute - && aHTMLAttribute->Equals(NS_LITERAL_STRING("bgcolor"))) { - aIsSet = PR_TRUE; - } else if (aHTMLAttribute && aHTMLAttribute && aHTMLAttribute->Equals(NS_LITERAL_STRING("align"))) { aIsSet = PR_TRUE;