Bug 552914 nsEditor::mFlags is never modified by SetFlags() r=smaug

This commit is contained in:
Masayuki Nakano
2010-04-12 11:35:18 +09:00
parent 133430fa10
commit db6dea9dfe
15 changed files with 250 additions and 279 deletions

View File

@@ -1103,7 +1103,8 @@ NS_IMETHODIMP nsHTMLEditor::PrepareHTMLTransferable(nsITransferable **aTransfera
{
// Create the desired DataFlavor for the type of data
// we want to get out of the transferable
if ((mFlags & eEditorPlaintextMask) == 0) // This should only happen in html editors, not plaintext
// This should only happen in html editors, not plaintext
if (!IsPlaintextEditor())
{
if (!aHavePrivFlavor)
{
@@ -1727,12 +1728,7 @@ nsHTMLEditor::PutDragDataInTransferable(nsITransferable **aTransferable)
nsAutoString buffer, parents, info;
// find out if we're a plaintext control or not
PRUint32 editorFlags = 0;
rv = GetFlags(&editorFlags);
if (NS_FAILED(rv)) return rv;
PRBool bIsPlainTextControl = ((editorFlags & eEditorPlaintextMask) != 0);
if (!bIsPlainTextControl)
if (!IsPlaintextEditor())
{
// encode the selection as html with contextual info
rv = docEncoder->EncodeToStringWithContext(parents, info, buffer);
@@ -1760,7 +1756,7 @@ nsHTMLEditor::PutDragDataInTransferable(nsITransferable **aTransferable)
nsCOMPtr<nsITransferable> trans = do_CreateInstance("@mozilla.org/widget/transferable;1");
NS_ENSURE_TRUE(trans, NS_ERROR_FAILURE);
if (bIsPlainTextControl)
if (IsPlaintextEditor())
{
// Add the unicode flavor to the transferable
rv = trans->AddDataFlavor(kUnicodeMime);
@@ -1999,14 +1995,11 @@ NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste)
nsresult rv;
nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
if (NS_FAILED(rv)) return rv;
PRUint32 editorFlags;
GetFlags(&editorFlags);
PRBool haveFlavors;
// Use the flavors depending on the current editor mask
if ((editorFlags & eEditorPlaintextMask))
if (IsPlaintextEditor())
rv = clipboard->HasDataMatchingFlavors(textEditorFlavors,
NS_ARRAY_LENGTH(textEditorFlavors),
aSelectionType, &haveFlavors);
@@ -2039,13 +2032,10 @@ NS_IMETHODIMP nsHTMLEditor::CanPasteTransferable(nsITransferable *aTransferable,
// Peek in |aTransferable| to see if it contains a supported MIME type.
PRUint32 editorFlags;
GetFlags(&editorFlags);
// Use the flavors depending on the current editor mask
const char ** flavors;
unsigned length;
if ((editorFlags & eEditorPlaintextMask)) {
if (IsPlaintextEditor()) {
flavors = textEditorFlavors;
length = NS_ARRAY_LENGTH(textEditorFlavors);
} else {
@@ -2075,7 +2065,7 @@ NS_IMETHODIMP nsHTMLEditor::CanPasteTransferable(nsITransferable *aTransferable,
//
NS_IMETHODIMP nsHTMLEditor::PasteAsQuotation(PRInt32 aSelectionType)
{
if (mFlags & eEditorPlaintextMask)
if (IsPlaintextEditor())
return PasteAsPlaintextQuotation(aSelectionType);
nsAutoString citation;
@@ -2281,7 +2271,7 @@ nsHTMLEditor::InsertTextWithQuotations(const nsAString &aStringToInsert)
NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsAString & aQuotedText,
nsIDOMNode **aNodeInserted)
{
if (mFlags & eEditorPlaintextMask)
if (IsPlaintextEditor())
return InsertAsPlaintextQuotation(aQuotedText, PR_TRUE, aNodeInserted);
nsAutoString citation;
@@ -2416,7 +2406,7 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsAString & aQuotedText,
nsIDOMNode **aNodeInserted)
{
// Don't let anyone insert html into a "plaintext" editor:
if (mFlags & eEditorPlaintextMask)
if (IsPlaintextEditor())
{
NS_ASSERTION(!aInsertHTML, "InsertAsCitedQuotation: trying to insert html into plaintext editor");
return InsertAsPlaintextQuotation(aQuotedText, PR_TRUE, aNodeInserted);