Bug 1585765 - Make sure untagged cells/rows get the untagged CSS attribute. rs=Paenglab a=jorgk
authorJorg K <jorgk@jorgk.com>
Thu, 24 Oct 2019 11:40:46 +0200
changeset 37213 28e678851cfa4e43dbca06e3492898cc72686cb6
parent 37212 1acfb376f132d28c5082b73a5b737e6dbe27b444
child 37214 f2111552b87430e6c217b03ff405646bef4ee5e2
push id395
push userclokep@gmail.com
push dateMon, 02 Dec 2019 19:38:57 +0000
reviewersPaenglab, jorgk
bugs1585765
Bug 1585765 - Make sure untagged cells/rows get the untagged CSS attribute. rs=Paenglab a=jorgk
mailnews/base/src/nsMsgDBView.cpp
mailnews/base/src/nsMsgDBView.h
--- a/mailnews/base/src/nsMsgDBView.cpp
+++ b/mailnews/base/src/nsMsgDBView.cpp
@@ -228,32 +228,35 @@ nsresult nsMsgDBView::GetPrefLocalizedSt
       aPrefName, NS_GET_IID(nsIPrefLocalizedString), getter_AddRefs(pls));
   NS_ENSURE_SUCCESS(rv, rv);
   pls->ToString(getter_Copies(ucsval));
   aResult = ucsval.get();
   return rv;
 }
 
 nsresult nsMsgDBView::AppendKeywordProperties(const nsACString &keywords,
-                                              nsAString &properties) {
+                                              nsAString &properties,
+                                              bool *tagAdded) {
+  *tagAdded = false;
   // Get the top most keyword's CSS selector and append that as a property.
   nsresult rv;
   if (!mTagService) {
     mTagService = do_GetService(NS_MSGTAGSERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   nsCString topKey;
   rv = mTagService->GetTopKey(keywords, topKey);
   NS_ENSURE_SUCCESS(rv, rv);
   if (topKey.IsEmpty()) return NS_OK;
 
   nsString selector;
   rv = mTagService->GetSelectorForKey(topKey, selector);
   if (NS_SUCCEEDED(rv)) {
+    *tagAdded = true;
     properties.Append(' ');
     properties.Append(selector);
   }
   return rv;
 }
 
 ///////////////////////////////////////////////////////////////////////////
 // nsITreeView Implementation Methods (and helper methods)
@@ -1210,21 +1213,24 @@ nsMsgDBView::GetRowProperties(int32_t in
 
   if (NS_FAILED(rv) || !msgHdr) {
     ClearHdrCache();
     return NS_MSG_INVALID_DBVIEW_INDEX;
   }
 
   nsCString keywordProperty;
   FetchRowKeywords(index, msgHdr, keywordProperty);
-  if (keywordProperty.IsEmpty()) {
-    properties.AppendLiteral(" untagged");
+  bool tagAdded = false;
+  if (!keywordProperty.IsEmpty()) {
+    AppendKeywordProperties(keywordProperty, properties, &tagAdded);
+  }
+  if (tagAdded) {
+    properties.AppendLiteral(" tagged");
   } else {
-    AppendKeywordProperties(keywordProperty, properties);
-    properties.AppendLiteral(" tagged");
+    properties.AppendLiteral(" untagged");
   }
 
   // Give the custom column handlers a chance to style the row.
   for (int i = 0; i < m_customColumnHandlers.Count(); i++) {
     nsString extra;
     m_customColumnHandlers[i]->GetRowProperties(index, extra);
     if (!extra.IsEmpty()) {
       properties.Append(' ');
@@ -1328,21 +1334,24 @@ nsMsgDBView::GetCellProperties(int32_t a
     else
       properties.AppendLiteral(" notjunk");
 
     NS_ASSERTION(NS_SUCCEEDED(rv), "Converting junkScore to integer failed.");
   }
 
   nsCString keywords;
   FetchRowKeywords(aRow, msgHdr, keywords);
-  if (keywords.IsEmpty()) {
-    properties.AppendLiteral(" untagged");
+  bool tagAdded = false;
+  if (!keywords.IsEmpty()) {
+    AppendKeywordProperties(keywords, properties, &tagAdded);
+  }
+  if (tagAdded) {
+    properties.AppendLiteral(" tagged");
   } else {
-    AppendKeywordProperties(keywords, properties);
-    properties.AppendLiteral(" tagged");
+    properties.AppendLiteral(" untagged");
   }
 
   // This is a double fetch of the keywords property since we also fetch
   // it for the tags - do we want to do this?
   // I'm not sure anyone uses the kw- property, though it could be nice
   // for people wanting to extend the thread pane.
   nsCString keywordProperty;
   msgHdr->GetStringProperty("keywords", getter_Copies(keywordProperty));
--- a/mailnews/base/src/nsMsgDBView.h
+++ b/mailnews/base/src/nsMsgDBView.h
@@ -392,17 +392,17 @@ class nsMsgDBView : public nsIMsgDBView,
   nsresult ToggleMessageKilled(nsMsgViewIndex *indices, int32_t numIndices,
                                nsMsgViewIndex *resultIndex,
                                bool *resultToggleState);
   bool OfflineMsgSelected(nsMsgViewIndex *indices, int32_t numIndices);
   bool NonDummyMsgSelected(nsMsgViewIndex *indices, int32_t numIndices);
   char16_t *GetString(const char16_t *aStringName);
   nsresult GetPrefLocalizedString(const char *aPrefName, nsString &aResult);
   nsresult AppendKeywordProperties(const nsACString &keywords,
-                                   nsAString &properties);
+                                   nsAString &properties, bool *tagAdded);
   nsresult InitLabelStrings(void);
   nsresult CopyDBView(nsMsgDBView *aNewMsgDBView,
                       nsIMessenger *aMessengerInstance,
                       nsIMsgWindow *aMsgWindow,
                       nsIMsgDBViewCommandUpdater *aCmdUpdater);
   void InitializeLiterals();
   virtual int32_t FindLevelInThread(nsIMsgDBHdr *msgHdr,
                                     nsMsgViewIndex startOfThread,