Bug 1585765 - Make sure untagged cells/rows get the untagged CSS attribute. rs=Paenglab DONTBUILD
authorJorg K <jorgk@jorgk.com>
Thu, 24 Oct 2019 11:40:46 +0200
changeset 37348 5b350753533c68b9bf57d42d11790024bf2aefc1
parent 37347 d4dc1d4176db73e38512f752fe7c73e87c84983b
child 37349 ba97cb20859d6201a24039dc60ddd62abc4dd52b
push id396
push userclokep@gmail.com
push dateMon, 06 Jan 2020 23:11:57 +0000
reviewersPaenglab
bugs1585765
Bug 1585765 - Make sure untagged cells/rows get the untagged CSS attribute. rs=Paenglab DONTBUILD
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,