Bug 596300 - Element Attributes dropped when dragging and dropping in DesignMode/ContentEditable sections; r=bzbarsky a=blocking-betaN,1.9.2.11,1.9.1.14

This commit is contained in:
Ehsan Akhgari 2010-09-27 13:28:54 -04:00
Родитель a51eb769a7
Коммит 017374cd2f
1 изменённых файлов: 24 добавлений и 4 удалений

Просмотреть файл

@ -128,6 +128,7 @@
#include "plbase64.h"
#include "prmem.h"
#include "nsStreamUtils.h"
#include "nsIPrincipal.h"
const PRUnichar nbsp = 160;
@ -1303,6 +1304,25 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable
#ifdef DEBUG_clipboard
printf("Got flavor [%s]\n", bestFlavor.get());
#endif
// Try to determine whether we should use a sanitizing fragment sink
PRBool isSafe = PR_FALSE;
if (aSourceDoc) {
nsCOMPtr<nsIDOMDocument> destdomdoc;
rv = GetDocument(getter_AddRefs(destdomdoc));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> destdoc = do_QueryInterface(destdomdoc);
NS_ASSERTION(destdoc, "Where is our destination doc?");
nsCOMPtr<nsIDocument> srcdoc = do_QueryInterface(aSourceDoc);
NS_ASSERTION(srcdoc, "Where is our source doc?");
nsIPrincipal* srcPrincipal = srcdoc->NodePrincipal();
nsIPrincipal* destPrincipal = destdoc->NodePrincipal();
NS_ASSERTION(srcPrincipal && destPrincipal, "How come we don't have a principal?");
rv = srcPrincipal->Subsumes(destPrincipal, &isSafe);
NS_ENSURE_SUCCESS(rv, rv);
}
if (0 == nsCRT::strcmp(bestFlavor, kNativeHTMLMime))
{
// note cf_html uses utf8, hence use length = len, not len/2 as in flavors below
@ -1323,7 +1343,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable
aSourceDoc,
aDestinationNode, aDestOffset,
aDoDeleteSelection,
PR_FALSE);
isSafe);
}
}
}
@ -1342,7 +1362,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable
aSourceDoc,
aDestinationNode, aDestOffset,
aDoDeleteSelection,
PR_FALSE);
isSafe);
}
}
else if (0 == nsCRT::strcmp(bestFlavor, kUnicodeMime) ||
@ -1413,7 +1433,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable
aSourceDoc,
aDestinationNode, aDestOffset,
aDoDeleteSelection,
PR_FALSE);
isSafe);
}
}
}
@ -1443,7 +1463,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable
aSourceDoc,
aDestinationNode, aDestOffset,
aDoDeleteSelection,
PR_FALSE);
isSafe);
PR_Free(base64);
}
}