Bug 613517 - Remove support for making links relative when pasting/dropping HTML data over an editable area; r=roc
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 30 Dec 2011 13:04:02 -0500
changeset 83584 0609a69f85a66fc6ea356482859dd8eed33994fa
parent 83583 aa47e51cbd8a84409b36979c6adae620a413a2e7
child 83585 3e7c2110dec8e42780710712b9fdf1d95c1109ea
push idunknown
push userunknown
push dateunknown
reviewersroc
bugs613517
milestone12.0a1
Bug 613517 - Remove support for making links relative when pasting/dropping HTML data over an editable area; r=roc
editor/libeditor/html/nsHTMLDataTransfer.cpp
editor/libeditor/html/nsHTMLEditor.h
--- a/editor/libeditor/html/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp
@@ -365,20 +365,16 @@ nsHTMLEditor::DoInsertHTMLWithContext(co
   res = CreateListOfNodesToPaste(fragmentAsNode, nodeList,
                                  streamStartParent, streamStartOffset,
                                  streamEndParent, streamEndOffset);
   NS_ENSURE_SUCCESS(res, res);
 
   if (nodeList.Count() == 0)
     return NS_OK;
 
-  // walk list of nodes; perform surgery on nodes (relativize) with _mozattr
-  res = RelativizeURIInFragmentList(nodeList, aFlavor, aSourceDoc, targetNode);
-  // ignore results from this call, try to paste/insert anyways
- 
   // are there any table elements in the list?  
   // node and offset for insertion
   nsCOMPtr<nsIDOMNode> parentNode;
   PRInt32 offsetOfNewNode;
   
   // check for table cell selection mode
   bool cellSelectionMode = false;
   nsCOMPtr<nsIDOMElement> cell;
@@ -890,102 +886,16 @@ nsHTMLEditor::GetAttributeToModifyOnNode
     aAttr = srcStr;
     return NS_OK;
   }
 
   return NS_OK;
 }
 
 nsresult
-nsHTMLEditor::RelativizeURIForNode(nsIDOMNode *aNode, nsIURL *aDestURL)
-{
-  nsAutoString attributeToModify;
-  GetAttributeToModifyOnNode(aNode, attributeToModify);
-  if (attributeToModify.IsEmpty())
-    return NS_OK;
-
-  nsCOMPtr<nsIDOMNamedNodeMap> attrMap;
-  nsresult rv = aNode->GetAttributes(getter_AddRefs(attrMap));
-  NS_ENSURE_SUCCESS(rv, NS_OK);
-  NS_ENSURE_TRUE(attrMap, NS_OK); // assume errors here shouldn't cancel insertion
-
-  nsCOMPtr<nsIDOMNode> attrNode;
-  rv = attrMap->GetNamedItem(attributeToModify, getter_AddRefs(attrNode));
-  NS_ENSURE_SUCCESS(rv, NS_OK); // assume errors here shouldn't cancel insertion
-
-  if (attrNode)
-  {
-    nsAutoString oldValue;
-    attrNode->GetNodeValue(oldValue);
-    if (!oldValue.IsEmpty())
-    {
-      NS_ConvertUTF16toUTF8 oldCValue(oldValue);
-      nsCOMPtr<nsIURI> currentNodeURI;
-      rv = NS_NewURI(getter_AddRefs(currentNodeURI), oldCValue);
-      if (NS_SUCCEEDED(rv))
-      {
-        nsCAutoString newRelativePath;
-        aDestURL->GetRelativeSpec(currentNodeURI, newRelativePath);
-        if (!newRelativePath.IsEmpty())
-        {
-          NS_ConvertUTF8toUTF16 newCValue(newRelativePath);
-          attrNode->SetNodeValue(newCValue);
-        }
-      }
-    }
-  }
-
-  return NS_OK;
-}
-
-nsresult
-nsHTMLEditor::RelativizeURIInFragmentList(const nsCOMArray<nsIDOMNode> &aNodeList,
-                                          const nsAString &aFlavor,
-                                          nsIDOMDocument *aSourceDoc,
-                                          nsIDOMNode *aTargetNode)
-{
-  // determine destination URL
-  nsCOMPtr<nsIDOMDocument> domDoc;
-  GetDocument(getter_AddRefs(domDoc));
-  NS_ENSURE_TRUE(domDoc, NS_ERROR_FAILURE);
-
-  nsCOMPtr<nsIDocument> destDoc = do_QueryInterface(domDoc);
-  NS_ENSURE_TRUE(destDoc, NS_ERROR_FAILURE);
-
-  nsCOMPtr<nsIURL> destURL = do_QueryInterface(destDoc->GetDocBaseURI());
-  NS_ENSURE_TRUE(destURL, NS_ERROR_FAILURE);
-
-  PRInt32 listCount = aNodeList.Count();
-  PRInt32 j;
-  for (j = 0; j < listCount; j++)
-  {
-    nsIDOMNode* somenode = aNodeList[j];
-
-    nsCOMPtr<nsIDOMTreeWalker> walker;
-    nsresult rv = domDoc->CreateTreeWalker(somenode,
-                                           nsIDOMNodeFilter::SHOW_ELEMENT,
-                                           nsnull, true,
-                                           getter_AddRefs(walker));
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    nsCOMPtr<nsIDOMNode> currentNode;
-    walker->GetCurrentNode(getter_AddRefs(currentNode));
-    while (currentNode)
-    {
-      rv = RelativizeURIForNode(currentNode, destURL);
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      walker->NextNode(getter_AddRefs(currentNode));
-    }
-  }
-
-  return NS_OK;
-}
-
-nsresult
 nsHTMLEditor::AddInsertionListener(nsIContentFilter *aListener)
 {
   NS_ENSURE_TRUE(aListener, NS_ERROR_NULL_POINTER);
 
   // don't let a listener be added more than once
   if (mContentFilters.IndexOfObject(aListener) == -1)
   {
     if (!mContentFilters.AppendObject(aListener))
--- a/editor/libeditor/html/nsHTMLEditor.h
+++ b/editor/libeditor/html/nsHTMLEditor.h
@@ -576,21 +576,16 @@ protected:
                                      nsIDOMNode **aFragmentAsNode,      
                                      nsIDOMNode **aFragStartNode,
                                      PRInt32 *aFragStartOffset,
                                      nsIDOMNode **aFragEndNode,
                                      PRInt32 *aFragEndOffset,
                                      nsIDOMNode **aTargetNode,       
                                      PRInt32 *aTargetOffset,   
                                      bool *aDoContinue);
-  nsresult   RelativizeURIInFragmentList(const nsCOMArray<nsIDOMNode> &aNodeList,
-                                        const nsAString &aFlavor,
-                                        nsIDOMDocument *aSourceDoc,
-                                        nsIDOMNode *aTargetNode);
-  nsresult   RelativizeURIForNode(nsIDOMNode *aNode, nsIURL *aDestURL);
   nsresult   GetAttributeToModifyOnNode(nsIDOMNode *aNode, nsAString &aAttrib);
 
   bool       IsInLink(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *outLink = nsnull);
   nsresult   StripFormattingNodes(nsIDOMNode *aNode, bool aOnlyList = false);
   nsresult   CreateDOMFragmentFromPaste(const nsAString & aInputString,
                                         const nsAString & aContextStr,
                                         const nsAString & aInfoStr,
                                         nsCOMPtr<nsIDOMNode> *outFragNode,