From afaa8ff67dfcb64895c90449bdedb5b4764e8cb3 Mon Sep 17 00:00:00 2001 From: "syd%netscape.com" Date: Sat, 22 Mar 2003 04:55:45 +0000 Subject: [PATCH] http://bugzilla.mozilla.org/show_bug.cgi?id=195655 Add support for 9 new smilies, and clean up code a bit (part of multiple checkins) r/sr = sspitzer, r=brade git-svn-id: svn://10.0.0.236/trunk@140043 18797224-902f-48f8-a5cc-f745e15eee43 --- .../converters/mozTXTToHTMLConv.cpp | 278 +++++++++--------- .../streamconv/converters/mozTXTToHTMLConv.h | 8 +- .../classic/editor/editorFormatToolbar.css | 38 +++ .../themes/classic/messenger/messageBody.css | 61 +++- .../modern/editor/editorFormatToolbar.css | 37 +++ .../themes/modern/messenger/messageBody.css | 60 +++- 6 files changed, 339 insertions(+), 143 deletions(-) diff --git a/mozilla/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp b/mozilla/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp index adb8e66cc55..5fe3f3b5d19 100644 --- a/mozilla/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp +++ b/mozilla/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp @@ -667,14 +667,19 @@ mozTXTToHTMLConv::StructPhraseHit(const PRUnichar * aInString, PRInt32 aInString return PR_FALSE; } + PRBool mozTXTToHTMLConv::SmilyHit(const PRUnichar * aInString, PRInt32 aLength, PRBool col0, - const PRUnichar* tagTXT, PRInt32 aTagTxtLength, const char* tagHTML, + const char* tagTXT, const char* imageName, nsString& outputHTML, PRInt32& glyphTextLen) { - PRInt32 tagLen = nsCRT::strlen(tagTXT); + if ( !aInString || !tagTXT || !imageName ) + return PR_FALSE; + PRInt32 tagLen = nsCRT::strlen(tagTXT); + PRUint32 delim = (col0 ? 0 : 1) + tagLen; + if ( (col0 || IsSpace(aInString[0])) @@ -688,31 +693,34 @@ mozTXTToHTMLConv::SmilyHit(const PRUnichar * aInString, PRInt32 aLength, PRBool aInString[delim] == '.' || aInString[delim] == ',' || aInString[delim] == ';' || + aInString[delim] == '8' || + aInString[delim] == '>' || aInString[delim] == '!' || aInString[delim] == '?' ) && IsSpace(aInString[delim + 1]) ) - && ItMatchesDelimited(aInString, aLength, tagTXT, aTagTxtLength, + && ItMatchesDelimited(aInString, aLength, NS_ConvertASCIItoUCS2(tagTXT).get(), tagLen, col0 ? LT_IGNORE : LT_DELIMITER, LT_IGNORE) // Note: tests at different pos for LT_IGNORE and LT_DELIMITER ) { - if (col0) - { - outputHTML.AssignWithConversion(tagHTML); - } - else + if (!col0) { outputHTML.Truncate(); outputHTML.Append(PRUnichar(' ')); - outputHTML.AppendWithConversion(tagHTML); } + + outputHTML += NS_LITERAL_STRING("\"")"); glyphTextLen = (col0 ? 0 : 1) + tagLen; return PR_TRUE; } - else - return PR_FALSE; + + return PR_FALSE; } // the glyph is appended to aOutputString instead of the original string... @@ -724,144 +732,144 @@ mozTXTToHTMLConv::GlyphHit(const PRUnichar * aInString, PRInt32 aInLength, PRBoo PRUnichar text0 = aInString[0]; PRUnichar text1 = aInString[1]; + PRUnichar firstChar = (col0 ? text0 : text1); // temporary variable used to store the glyph html text nsAutoString outputHTML; + PRBool bTestSmilie; + PRBool bArg; + int i; - if - ( - ( // Performance increase - (col0 ? text0 : text1) == ':' || - (col0 ? text0 : text1) == ';' - ) - && - ( - SmilyHit(aInString, aInLength, col0, - NS_LITERAL_STRING(":-)").get(), 3, - "\":-)\"", - outputHTML, glyphTextLen) || - - SmilyHit(aInString, aInLength, col0, - NS_LITERAL_STRING(":)").get(), 2, - "\":)\"", - outputHTML, glyphTextLen) || - - SmilyHit(aInString, aInLength, col0, - NS_LITERAL_STRING(":-D").get(), 3, - "\":-D\"", - outputHTML, glyphTextLen) || - - SmilyHit(aInString, aInLength, col0, - NS_LITERAL_STRING(":-(").get(), 3, - "\":-(\"", - outputHTML, glyphTextLen) || - - SmilyHit(aInString, aInLength, col0, - NS_LITERAL_STRING(":(").get(), 2, - "\":(\"", - outputHTML, glyphTextLen) || - - SmilyHit(aInString, aInLength, col0, - NS_LITERAL_STRING(":-[").get(), 3, - "\":-[\"", + // refactor some of this mess to avoid code duplication and speed execution a bit + // there are two cases that need to be tried one after another. To avoid a lot of + // duplicate code, rolling into a loop + + i = 0; + while ( i < 2 ) + { + bTestSmilie = PR_FALSE; + if ( !i && (firstChar == ':' || firstChar == ';' || firstChar == '=' || firstChar == '>' || firstChar == '8' || firstChar == 'O')) + { + // first test passed + + bTestSmilie = PR_TRUE; + bArg = col0; + } + if ( i && col0 && ( text1 == ':' || text1 == ';' || text1 == '=' || text1 == '>' || text1 == '8' || text1 == 'O' ) ) + { + // second test passed + + bTestSmilie = PR_TRUE; + bArg = PR_FALSE; + } + if ( bTestSmilie && ( + SmilyHit(aInString, aInLength, bArg, + ":-)", + "smile_n.gif", + outputHTML, glyphTextLen) || + + SmilyHit(aInString, aInLength, bArg, + ":)", + "smile_n.gif", outputHTML, glyphTextLen) || - SmilyHit(aInString, aInLength, col0, - NS_LITERAL_STRING(";-)").get(), 3, - "\";-)\"", - outputHTML, glyphTextLen) || - SmilyHit(aInString, aInLength, col0, - NS_LITERAL_STRING(";)").get(), 2, - "\";)\"", - outputHTML, glyphTextLen) || - - SmilyHit(aInString, aInLength, col0, - NS_LITERAL_STRING(":-\\").get(), 3, - "\":-\\\"", - outputHTML, glyphTextLen) || - - SmilyHit(aInString, aInLength, col0, - NS_LITERAL_STRING(":-P").get(), 3, - "\":-P\"", - outputHTML, glyphTextLen) - - - ) - ) - { - aOutputString.Append(outputHTML); - MOZ_TIMER_STOP(mGlyphHitTimer); - return PR_TRUE; - } - if // XXX Hotfix - ( - ( // Performance increase - col0 - && - ( - text1 == ':' || - text1 == ';' - ) - ) - && - ( - SmilyHit(aInString, aInLength, PR_FALSE, - NS_LITERAL_STRING(":-)").get(), 3, - "\":-)\"", - outputHTML, glyphTextLen) || - - SmilyHit(aInString, aInLength, PR_FALSE, - NS_LITERAL_STRING(":)").get(), 2, - "\":)\"", - outputHTML, glyphTextLen) || - - SmilyHit(aInString, aInLength, PR_FALSE, - NS_LITERAL_STRING(":-D").get(), 3, - "\":-D\"", - outputHTML, glyphTextLen) || - - SmilyHit(aInString, aInLength, PR_FALSE, - NS_LITERAL_STRING(":-(").get(), 3, - "\":-(\"", - outputHTML, glyphTextLen) || - - SmilyHit(aInString, aInLength, PR_FALSE, - NS_LITERAL_STRING(":(").get(), 2, - "\":(\"", - outputHTML, glyphTextLen) || - - SmilyHit(aInString, aInLength, PR_FALSE, - NS_LITERAL_STRING(":-[").get(), 3, - "\":-[\"", + SmilyHit(aInString, aInLength, bArg, + ":-D", + "laughing_n.gif", outputHTML, glyphTextLen) || - SmilyHit(aInString, aInLength, PR_FALSE, - NS_LITERAL_STRING(";-)").get(), 3, - "\";-)\"", - outputHTML, glyphTextLen) || + SmilyHit(aInString, aInLength, bArg, + ":-(", + "frown_n.gif", + outputHTML, glyphTextLen) || - SmilyHit(aInString, aInLength, PR_FALSE, - NS_LITERAL_STRING(";)").get(), 2, - "\";)\"", - outputHTML, glyphTextLen) || + SmilyHit(aInString, aInLength, bArg, + ":(", + "frown_n.gif", + outputHTML, glyphTextLen) || - SmilyHit(aInString, aInLength, PR_FALSE, - NS_LITERAL_STRING(":-\\").get(), 3, - "\":-\\\"", - outputHTML, glyphTextLen) || - - SmilyHit(aInString, aInLength, PR_FALSE, - NS_LITERAL_STRING(":-P").get(), 3, - "\":-P\"", - outputHTML, glyphTextLen) + SmilyHit(aInString, aInLength, bArg, + ":-[", + "embarrassed_n.gif", + outputHTML, glyphTextLen) || + SmilyHit(aInString, aInLength, bArg, + ";-)", + "wink_n.gif", + outputHTML, glyphTextLen) || + SmilyHit(aInString, aInLength, col0, + ";)", + "wink_n.gif", + outputHTML, glyphTextLen) || + + SmilyHit(aInString, aInLength, bArg, + ":-\\", + "undecided_n.gif", + outputHTML, glyphTextLen) || + + SmilyHit(aInString, aInLength, bArg, + ":-P", + "tongue_n.gif", + outputHTML, glyphTextLen) || + + SmilyHit(aInString, aInLength, bArg, + "=-O", + "surprise_n.gif", + outputHTML, glyphTextLen) || + + SmilyHit(aInString, aInLength, bArg, + ":-*", + "kiss_n.gif", + outputHTML, glyphTextLen) || + + SmilyHit(aInString, aInLength, bArg, + ">:o", + "yell_n.gif", + outputHTML, glyphTextLen) || + + SmilyHit(aInString, aInLength, bArg, + ">:-o", + "yell_n.gif", + outputHTML, glyphTextLen) || + + SmilyHit(aInString, aInLength, bArg, + "8-)", + "cool_n.gif", + outputHTML, glyphTextLen) || + + SmilyHit(aInString, aInLength, bArg, + ":-$", + "money_n.gif", + outputHTML, glyphTextLen) || + + SmilyHit(aInString, aInLength, bArg, + ":-!", + "foot_n.gif", + outputHTML, glyphTextLen) || + + SmilyHit(aInString, aInLength, bArg, + "O:-)", + "innocent_n.gif", + outputHTML, glyphTextLen) || + + SmilyHit(aInString, aInLength, bArg, + ":'(", + "cry_n.gif", + outputHTML, glyphTextLen) || + + SmilyHit(aInString, aInLength, bArg, + ":-X", + "sealed_n.gif", + outputHTML, glyphTextLen) ) ) - { - aOutputString.Append(outputHTML); - MOZ_TIMER_STOP(mGlyphHitTimer); - return PR_TRUE; + { + aOutputString.Append(outputHTML); + MOZ_TIMER_STOP(mGlyphHitTimer); + return PR_TRUE; + } + i++; } if (text0 == '+' || text1 == '+') { diff --git a/mozilla/netwerk/streamconv/converters/mozTXTToHTMLConv.h b/mozilla/netwerk/streamconv/converters/mozTXTToHTMLConv.h index effe6802e63..9370f9f72af 100644 --- a/mozilla/netwerk/streamconv/converters/mozTXTToHTMLConv.h +++ b/mozilla/netwerk/streamconv/converters/mozTXTToHTMLConv.h @@ -289,13 +289,13 @@ private: /** @param text (in), col0 (in): see GlyphHit @param tagTXT (in): Smily, see also StructPhraseHit - @param aTagTxtLen (in): length of tagTXT - @param tagHTML (in): see StructPhraseHit + @param imageName (in): the basename of the file that contains the image for this smilie @param outputHTML (out): new string containing the html for the smily @param glyphTextLen (out): see GlyphHit */ - PRBool SmilyHit(const PRUnichar * aInString, PRInt32 aLength, PRBool col0, - const PRUnichar* tagTXT, PRInt32 aTagTxtLen, const char* tagHTML, + PRBool + SmilyHit(const PRUnichar * aInString, PRInt32 aLength, PRBool col0, + const char* tagTXT, const char* imageName, nsString& outputHTML, PRInt32& glyphTextLen); /** diff --git a/mozilla/themes/classic/editor/editorFormatToolbar.css b/mozilla/themes/classic/editor/editorFormatToolbar.css index e018481d80e..77cf1461ac2 100644 --- a/mozilla/themes/classic/editor/editorFormatToolbar.css +++ b/mozilla/themes/classic/editor/editorFormatToolbar.css @@ -445,6 +445,44 @@ list-style-image: url("chrome://editor/content/images/undecided_n.gif"); } +.insert-surprise > .menu-iconic-left { + list-style-image: url("chrome://editor/content/images/surprise_n.gif"); +} + +.insert-kiss > .menu-iconic-left { + list-style-image: url("chrome://editor/content/images/kiss_n.gif"); +} + +.insert-yell > .menu-iconic-left { + list-style-image: url("chrome://editor/content/images/yell_n.gif"); +} + +.insert-cool > .menu-iconic-left { + list-style-image: url("chrome://editor/content/images/cool_n.gif"); +} + +.insert-undecided > .menu-iconic-left { + list-style-image: url("chrome://editor/content/images/undecided_n.gif"); +} + +.insert-money > .menu-iconic-left { + list-style-image: url("chrome://editor/content/images/money_n.gif"); +} + +.insert-foot > .menu-iconic-left { + list-style-image: url("chrome://editor/content/images/foot_n.gif"); +} + +.insert-innocent > .menu-iconic-left { + list-style-image: url("chrome://editor/content/images/innocent_n.gif"); +} + +.insert-sealed > .menu-iconic-left { + list-style-image: url("chrome://editor/content/images/sealed_n.gif"); +} + + + /* ::::: fg/bg color picker ::::: */ .ColorPickerLabel { diff --git a/mozilla/themes/classic/messenger/messageBody.css b/mozilla/themes/classic/messenger/messageBody.css index e29b5570b91..6d8463603a8 100644 --- a/mozilla/themes/classic/messenger/messageBody.css +++ b/mozilla/themes/classic/messenger/messageBody.css @@ -150,7 +150,18 @@ span.moz-smiley-s3, span.moz-smiley-s4, span.moz-smiley-s5, span.moz-smiley-s6, -span.moz-smiley-s7 { +span.moz-smiley-s7, +span.moz-smiley-s8, +span.moz-smiley-s9, +span.moz-smiley-s10, +span.moz-smiley-s11, +span.moz-smiley-s12, +span.moz-smiley-s13, +span.moz-smiley-s14, +span.moz-smiley-s15, +span.moz-smiley-s16 + +{ min-height: 17px; margin-left: 2px; margin-top: 2px; padding-left: 20px; background-repeat: no-repeat; @@ -163,7 +174,17 @@ span.moz-smiley-s3 > span, span.moz-smiley-s4 > span, span.moz-smiley-s5 > span, span.moz-smiley-s6 > span, -span.moz-smiley-s7 > span { +span.moz-smiley-s7 > span, +span.moz-smiley-s8 > span, +span.moz-smiley-s9 > span, +span.moz-smiley-s10 > span, +span.moz-smiley-s11 > span, +span.moz-smiley-s12 > span, +span.moz-smiley-s13 > span, +span.moz-smiley-s14 > span, +span.moz-smiley-s15 > span, +span.moz-smiley-s16 > span +{ display: none; } @@ -194,3 +215,39 @@ span.moz-smiley-s6 { span.moz-smiley-s7 { background-image: url("chrome://editor/content/images/undecided_n.gif"); } + +span.moz-smiley-s8 { + background-image: url("chrome://editor/content/images/surprise_n.gif"); +} + +span.moz-smiley-s9 { + background-image: url("chrome://editor/content/images/kiss_n.gif"); +} + +span.moz-smiley-s10 { + background-image: url("chrome://editor/content/images/yell_n.gif"); +} + +span.moz-smiley-s11 { + background-image: url("chrome://editor/content/images/cool_n.gif"); +} + +span.moz-smiley-s12 { + background-image: url("chrome://editor/content/images/money_n.gif"); +} + +span.moz-smiley-s13 { + background-image: url("chrome://editor/content/images/foot_n.gif"); +} + +span.moz-smiley-s14 { + background-image: url("chrome://editor/content/images/innocent_n.gif"); +} + +span.moz-smiley-s15 { + background-image: url("chrome://editor/content/images/cry_n.gif"); +} + +span.moz-smiley-s16 { + background-image: url("chrome://editor/content/images/sealed_n.gif"); +} diff --git a/mozilla/themes/modern/editor/editorFormatToolbar.css b/mozilla/themes/modern/editor/editorFormatToolbar.css index 140ce33538e..31187c183e3 100644 --- a/mozilla/themes/modern/editor/editorFormatToolbar.css +++ b/mozilla/themes/modern/editor/editorFormatToolbar.css @@ -472,6 +472,43 @@ list-style-image: url("chrome://editor/content/images/undecided_n.gif"); } +.insert-surprise > .menu-iconic-left { + list-style-image: url("chrome://editor/content/images/surprise_n.gif"); +} + +.insert-kiss > .menu-iconic-left { + list-style-image: url("chrome://editor/content/images/kiss_n.gif"); +} + +.insert-yell > .menu-iconic-left { + list-style-image: url("chrome://editor/content/images/yell_n.gif"); +} + +.insert-cool > .menu-iconic-left { + list-style-image: url("chrome://editor/content/images/cool_n.gif"); +} + +.insert-money > .menu-iconic-left { + list-style-image: url("chrome://editor/content/images/money_n.gif"); +} + +.insert-foot > .menu-iconic-left { + list-style-image: url("chrome://editor/content/images/foot_n.gif"); +} + +.insert-innocent > .menu-iconic-left { + list-style-image: url("chrome://editor/content/images/innocent_n.gif"); +} + +.insert-cry > .menu-iconic-left { + list-style-image: url("chrome://editor/content/images/cry_n.gif"); +} + +.insert-sealed > .menu-iconic-left { + list-style-image: url("chrome://editor/content/images/sealed_n.gif"); +} + + /* ::::: fg/bg color picker ::::: */ .color-button { diff --git a/mozilla/themes/modern/messenger/messageBody.css b/mozilla/themes/modern/messenger/messageBody.css index d0f143c8384..804096f7878 100644 --- a/mozilla/themes/modern/messenger/messageBody.css +++ b/mozilla/themes/modern/messenger/messageBody.css @@ -150,7 +150,17 @@ span.moz-smiley-s3, span.moz-smiley-s4, span.moz-smiley-s5, span.moz-smiley-s6, -span.moz-smiley-s7 { +span.moz-smiley-s7, +span.moz-smiley-s8, +span.moz-smiley-s9, +span.moz-smiley-s10, +span.moz-smiley-s11, +span.moz-smiley-s12, +span.moz-smiley-s13, +span.moz-smiley-s14, +span.moz-smiley-s15, +span.moz-smiley-s16 +{ min-height: 17px; margin-left: 2px; margin-top: 2px; padding-left: 20px; background-repeat: no-repeat; @@ -163,7 +173,17 @@ span.moz-smiley-s3 > span, span.moz-smiley-s4 > span, span.moz-smiley-s5 > span, span.moz-smiley-s6 > span, -span.moz-smiley-s7 > span { +span.moz-smiley-s7 > span, +span.moz-smiley-s8 > span, +span.moz-smiley-s9 > span, +span.moz-smiley-s10 > span, +span.moz-smiley-s11 > span, +span.moz-smiley-s12 > span, +span.moz-smiley-s13 > span, +span.moz-smiley-s14 > span, +span.moz-smiley-s15 > span, +span.moz-smiley-s16 > span +{ display: none; } @@ -194,3 +214,39 @@ span.moz-smiley-s6 { span.moz-smiley-s7 { background-image: url("chrome://editor/content/images/undecided_n.gif"); } + +span.moz-smiley-s8 { + background-image: url("chrome://editor/content/images/surprise_n.gif"); +} + +span.moz-smiley-s9 { + background-image: url("chrome://editor/content/images/kiss_n.gif"); +} + +span.moz-smiley-s10 { + background-image: url("chrome://editor/content/images/yell_n.gif"); +} + +span.moz-smiley-s11 { + background-image: url("chrome://editor/content/images/cool_n.gif"); +} + +span.moz-smiley-s12 { + background-image: url("chrome://editor/content/images/money_n.gif"); +} + +span.moz-smiley-s13 { + background-image: url("chrome://editor/content/images/foot_n.gif"); +} + +span.moz-smiley-s14 { + background-image: url("chrome://editor/content/images/innocent_n.gif"); +} + +span.moz-smiley-s15 { + background-image: url("chrome://editor/content/images/cry_n.gif"); +} + +span.moz-smiley-s16 { + background-image: url("chrome://editor/content/images/sealed_n.gif"); +}