Bug 1434575 - remove dead HTMLLinkElement processing since GetEmbeddedObjects() doesn't return them. r=mkmelin
authorJorg K <jorgk@jorgk.com>
Mon, 10 Sep 2018 12:02:10 +0200
changeset 33113 3c055eb08eb5b451158c54dfee74203c8dc5434f
parent 33112 fe6d8f59182d7efcda98f23ec9ccb41f1cbfa710
child 33114 2dfed3b880129ede14e468363acce324d36c8c11
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersmkmelin
bugs1434575
Bug 1434575 - remove dead HTMLLinkElement processing since GetEmbeddedObjects() doesn't return them. r=mkmelin
mailnews/compose/src/nsMsgCompose.cpp
mailnews/compose/src/nsMsgSend.cpp
--- a/mailnews/compose/src/nsMsgCompose.cpp
+++ b/mailnews/compose/src/nsMsgCompose.cpp
@@ -65,17 +65,16 @@
 #include "nsIAbManager.h"
 #include "nsCRT.h"
 #include "mozilla/Services.h"
 #include "mozilla/mailnews/MimeHeaderParser.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/HTMLAnchorElement.h"
 #include "mozilla/dom/HTMLImageElement.h"
-#include "mozilla/dom/HTMLLinkElement.h"
 #include "mozilla/dom/Selection.h"
 #include "nsStreamConverter.h"
 #include "nsIObserverService.h"
 #include "nsIProtocolHandler.h"
 #include "nsContentUtils.h"
 #include "nsIFileURL.h"
 #include "nsTextNode.h" // from dom/base
 
@@ -246,23 +245,20 @@ bool nsMsgCompose::IsEmbeddedObjectSafe(
   nsresult rv;
 
   nsAutoString objURL;
 
   if (!originalScheme || !originalPath) // Having a null host is OK.
     return false;
 
   RefPtr<HTMLImageElement>  image  = HTMLImageElement::FromNode(element);
-  RefPtr<HTMLLinkElement>   link   = HTMLLinkElement::FromNode(element);
   RefPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::FromNode(element);
 
   if (image)
     image->GetSrc(objURL);
-  else if (link)
-    link->GetHref(objURL);
   else if (anchor)
     anchor->GetHref(objURL);
   else
     return false;
 
   if (!objURL.IsEmpty())
   {
     nsCOMPtr<nsIURI> uri;
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -71,17 +71,16 @@
 #include "nsArrayUtils.h"
 #include "mozilla/Services.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/mailnews/MimeEncoder.h"
 #include "mozilla/mailnews/MimeHeaderParser.h"
 #include "mozilla/dom/HTMLAnchorElement.h"
 #include "mozilla/dom/HTMLBodyElement.h"
 #include "mozilla/dom/HTMLImageElement.h"
-#include "mozilla/dom/HTMLLinkElement.h"
 #include "nsIMutableArray.h"
 #include "nsIMsgFilterService.h"
 #include "nsIMsgProtocolInfo.h"
 #include "mozIDOMWindow.h"
 #include "mozilla/Preferences.h"
 #include "nsIURIMutator.h"
 
 using namespace mozilla;
@@ -1280,17 +1279,16 @@ nsMsgComposeAndSend::GetEmbeddedObjectIn
 
   // Only empty or moz-do-not-send="false" may be accepted later.
   if (!(mozDoNotSendAttr.IsEmpty() || mozDoNotSendAttr.LowerCaseEqualsLiteral("false")))
     return NS_OK;
 
   // We're only interested in body, image, link and anchors which are all
   // elements. Let's see what we have.
   RefPtr<HTMLImageElement>  image  = HTMLImageElement::FromNode(domElement);
-  RefPtr<HTMLLinkElement>   link   = HTMLLinkElement::FromNode(domElement);
   RefPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::FromNode(domElement);
   RefPtr<HTMLBodyElement>   body   = HTMLBodyElement::FromNode(domElement);
 
   // First, try to see if the body as a background image
   if (body)
   {
     nsString tUrl;
     body->GetBackground(tUrl);
@@ -1338,29 +1336,16 @@ nsMsgComposeAndSend::GetEmbeddedObjectIn
     isImage = true;
 
     image->GetName(tName);
 
     LossyCopyUTF16toASCII(tName, attachment->m_realName);
     image->GetLongDesc(tDesc);
     attachment->m_description = NS_LossyConvertUTF16toASCII(tDesc); // XXX i18n
   }
-  else if (link)        // Is this a link?
-  {
-    nsString    tUrl;
-
-    // Create the URI
-    link->GetHref(tUrl);
-    if (tUrl.IsEmpty())
-      return NS_OK;
-    nsAutoCString turlC;
-    CopyUTF16toUTF8(tUrl, turlC);
-    if (NS_FAILED(nsMsgNewURL(getter_AddRefs(attachment->m_url), turlC)))
-      return NS_OK;
-  }
   else if (anchor)
   {
     nsString    tUrl;
 
     // Create the URI
     anchor->GetHref(tUrl);
     if (tUrl.IsEmpty())
       return NS_OK;
@@ -1801,32 +1786,26 @@ nsMsgComposeAndSend::ProcessMultipartRel
     if (domSaveArray[j].element &&
         !m_attachments[duplicateOf == -1 ? i : duplicateOf]->m_contentId.IsEmpty())
     {
       nsString   newSpec(NS_LITERAL_STRING("cid:"));
       newSpec.AppendASCII(m_attachments[duplicateOf == -1 ? i : duplicateOf]->m_contentId.get());
 
       // We know the types of objects this element can be, let's see what we come up with.
       RefPtr<HTMLImageElement>  image  = HTMLImageElement::FromNode(domSaveArray[j].element);
-      RefPtr<HTMLLinkElement>   link   = HTMLLinkElement::FromNode(domSaveArray[j].element);
       RefPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::FromNode(domSaveArray[j].element);
       RefPtr<HTMLBodyElement>   body   = HTMLBodyElement::FromNode(domSaveArray[j].element);
 
       nsString domURL;
       IgnoredErrorResult rv2;
       if (anchor)
       {
         anchor->GetHref(domURL);
         anchor->SetHref(newSpec, rv2);
       }
-      else if (link)
-      {
-        link->GetHref(domURL);
-        link->SetHref(newSpec, rv2);
-      }
       else if (image)
       {
         image->GetSrc(domURL);
         image->SetSrc(newSpec, rv2);
       }
       else if (body)
       {
         body->GetBackground(domURL);
@@ -1847,27 +1826,24 @@ nsMsgComposeAndSend::ProcessMultipartRel
   //
   for (i = 0; i < multipartCount; i++)
   {
     if (!domSaveArray[i].element || !domSaveArray[i].url)
       continue;
 
     // We know the types of objects this element can be, let's see what we come up with.
     RefPtr<HTMLImageElement>  image  = HTMLImageElement::FromNode(domSaveArray[i].element);
-    RefPtr<HTMLLinkElement>   link   = HTMLLinkElement::FromNode(domSaveArray[i].element);
     RefPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::FromNode(domSaveArray[i].element);
     RefPtr<HTMLBodyElement>   body   = HTMLBodyElement::FromNode(domSaveArray[i].element);
 
       // STRING USE WARNING: hoisting the following conversion might save code-space, since it happens along every path
 
     IgnoredErrorResult rv2;
     if (anchor) {
       anchor->SetHref(NS_ConvertASCIItoUTF16(domSaveArray[i].url), rv2);
-    } else if (link) {
-      link->SetHref(NS_ConvertASCIItoUTF16(domSaveArray[i].url), rv2);
     } else if (image) {
       image->SetSrc(NS_ConvertASCIItoUTF16(domSaveArray[i].url), rv2);
     }
     else if (body) {
       body->SetBackground(NS_ConvertASCIItoUTF16(domSaveArray[i].url), rv2);
     }
 
     free(domSaveArray[i].url);