Bug 1393088 - Port bug 1390209 to mailnews, follow-up: Correct parameters of [Get|Set]Background(). rs=bustage-fix
authorJorg K <jorgk@jorgk.com>
Wed, 23 Aug 2017 22:42:49 +0200
changeset 29609 e7173819d591a10f42d8570a34f10e68cfd54dff
parent 29608 e521a32d97d2a94f550e419ea6e52f601d377186
child 29610 a0f8d0262f8bf37ad096aee5f83c527dfba7ed32
push id378
push userclokep@gmail.com
push dateMon, 13 Nov 2017 18:45:35 +0000
reviewersbustage-fix
bugs1393088, 1390209
Bug 1393088 - Port bug 1390209 to mailnews, follow-up: Correct parameters of [Get|Set]Background(). rs=bustage-fix
mailnews/compose/src/nsMsgSend.cpp
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -1304,24 +1304,24 @@ nsMsgComposeAndSend::GetEmbeddedObjectIn
   RefPtr<mozilla::dom::HTMLImageElement> image =
     mozilla::dom::HTMLImageElement::FromContentOrNull(imageElement);
   nsCOMPtr<nsIDOMHTMLLinkElement>   link = do_QueryInterface(node);
   nsCOMPtr<nsIDOMHTMLAnchorElement> anchor = do_QueryInterface(node);
 
   // First, try to see if the body as a background image
   if (body)
   {
-    nsAutoString    tUrl;
-    if (NS_SUCCEEDED(body->GetBackground(tUrl)))
-    {
-      nsAutoCString turlC;
-      CopyUTF16toUTF8(tUrl, turlC);
-      if (NS_FAILED(nsMsgNewURL(getter_AddRefs(attachment->m_url), turlC.get())))
-        return NS_OK;
-    }
+    mozilla::dom::DOMString tUrl;
+    body->GetBackground(tUrl);
+    if (tUrl.AsAString().IsEmpty())
+      return NS_OK;
+    nsAutoCString turlC;
+    CopyUTF16toUTF8(tUrl.AsAString(), turlC);
+    if (NS_FAILED(nsMsgNewURL(getter_AddRefs(attachment->m_url), turlC.get())))
+      return NS_OK;
     isImage = true;
   }
   else if (image)        // Is this an image?
   {
     nsString    tUrl;
     nsString    tName;
     nsString    tDesc;
 
@@ -1859,18 +1859,21 @@ nsMsgComposeAndSend::ProcessMultipartRel
       else if (image)
       {
         image->GetSrc(domURL);
         IgnoredErrorResult rv2;
         image->SetSrc(newSpec, rv2);
       }
       else if (body)
       {
-        body->GetBackground(domURL);
-        body->SetBackground(newSpec);
+        mozilla::dom::DOMString background;
+        body->GetBackground(background);
+        domURL = background.AsAString();
+        IgnoredErrorResult rv2;
+        body->SetBackground(newSpec, rv2);
       }
 
       if (!domURL.IsEmpty())
         domSaveArray[j].url = ToNewCString(NS_LossyConvertUTF16toASCII(domURL));
     }
     i++;
   }
 
@@ -1900,18 +1903,20 @@ nsMsgComposeAndSend::ProcessMultipartRel
     if (anchor)
       anchor->SetHref(NS_ConvertASCIItoUTF16(domSaveArray[i].url));
     else if (link)
       link->SetHref(NS_ConvertASCIItoUTF16(domSaveArray[i].url));
     else if (image) {
       IgnoredErrorResult rv2;
       image->SetSrc(NS_ConvertASCIItoUTF16(domSaveArray[i].url), rv2);
     }
-    else if (body)
-      body->SetBackground(NS_ConvertASCIItoUTF16(domSaveArray[i].url));
+    else if (body) {
+      IgnoredErrorResult rv2;
+      body->SetBackground(NS_ConvertASCIItoUTF16(domSaveArray[i].url), rv2);
+    }
 
     free(domSaveArray[i].url);
   }
 
   PR_FREEIF(domSaveArray);
 
   //
   // Now, we have to create that first child node for the multipart