From bcd5fc4014eae38cdf75ff07d26064b692383497 Mon Sep 17 00:00:00 2001 From: "peterv%propagandism.org" Date: Thu, 25 Aug 2005 11:51:04 +0000 Subject: [PATCH] Fix for bug 301490 (Rich text editor property useCSS changed meaning). r=brade, sr=brendan. git-svn-id: svn://10.0.0.236/trunk@178929 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/document/src/nsHTMLDocument.cpp | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 082fea2a421..4b222dcf6f3 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -3641,8 +3641,8 @@ static const struct MidasCommand gMidasCommandTable[] = { { "insertparagraph", "cmd_paragraphState", "p", PR_TRUE, PR_FALSE }, { "formatblock", "cmd_paragraphState", "", PR_FALSE, PR_FALSE }, { "heading", "cmd_paragraphState", "", PR_FALSE, PR_FALSE }, - { "useCSS", "cmd_setDocumentUseCSS", "", PR_FALSE, PR_TRUE }, - { "readonly", "cmd_setDocumentReadOnly", "", PR_FALSE, PR_TRUE }, + { "styleWithCSS", "cmd_setDocumentUseCSS", "", PR_FALSE, PR_TRUE }, + { "contentReadOnly", "cmd_setDocumentReadOnly", "", PR_FALSE, PR_TRUE }, { "insertBrOnReturn", "cmd_insertBrOnReturn", "", PR_FALSE, PR_TRUE }, { "enableObjectResizing", "cmd_enableObjectResizing", "", PR_FALSE, PR_TRUE }, { "enableInlineTableEditing", "cmd_enableInlineTableEditing", "", PR_FALSE, PR_TRUE }, @@ -3693,7 +3693,19 @@ nsHTMLDocument::ConvertToMidasInternalCommand(const nsAString & inCommandID, PRBool& outIsBoolean, PRBool& outBooleanValue) { - NS_ConvertUCS2toUTF8 convertedCommandID(inCommandID); + NS_ConvertUTF16toUTF8 convertedCommandID(inCommandID); + + // Hack to support old boolean commands that were backwards (see bug 301490). + PRBool invertBool = PR_FALSE; + if (convertedCommandID.LowerCaseEqualsLiteral("usecss")) { + convertedCommandID.Assign("styleWithCSS"); + invertBool = PR_TRUE; + } + else if (convertedCommandID.LowerCaseEqualsLiteral("readonly")) { + convertedCommandID.Assign("contentReadOnly"); + invertBool = PR_TRUE; + } + PRUint32 i; PRBool found = PR_FALSE; for (i = 0; i < MidasCommandCount; ++i) { @@ -3718,9 +3730,15 @@ nsHTMLDocument::ConvertToMidasInternalCommand(const nsAString & inCommandID, // handle checking of param passed in if (outIsBoolean) { // if this is a boolean value and it's not explicitly false - // (e.g. no value) we default to "true" - outBooleanValue = !inParam.LowerCaseEqualsLiteral("false"); - outParam.SetLength(0); + // (e.g. no value) we default to "true". For old backwards commands + // we invert the check (see bug 301490). + if (invertBool) { + outBooleanValue = inParam.LowerCaseEqualsLiteral("false"); + } + else { + outBooleanValue = !inParam.LowerCaseEqualsLiteral("false"); + } + outParam.Truncate(); } else { NS_ConvertUCS2toUTF8 convertedParam(inParam);