66318 r= kin, sr=kin tested by ducarozz ,phil chofmann approved..changing APIS to be idl so we can use in embedding land... lots of string changes too to nsAStrings

This commit is contained in:
mjudge%netscape.com 2001-04-07 00:45:26 +00:00
Родитель da2106f186
Коммит 0d5b00ec9a
92 изменённых файлов: 2058 добавлений и 1916 удалений

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

@ -35,8 +35,8 @@ ChangeAttributeTxn::~ChangeAttributeTxn()
NS_IMETHODIMP ChangeAttributeTxn::Init(nsIEditor *aEditor, NS_IMETHODIMP ChangeAttributeTxn::Init(nsIEditor *aEditor,
nsIDOMElement *aElement, nsIDOMElement *aElement,
const nsString& aAttribute, const nsAReadableString& aAttribute,
const nsString& aValue, const nsAReadableString& aValue,
PRBool aRemoveAttribute) PRBool aRemoveAttribute)
{ {
NS_ASSERTION(aEditor && aElement, "bad arg"); NS_ASSERTION(aEditor && aElement, "bad arg");
@ -58,7 +58,7 @@ NS_IMETHODIMP ChangeAttributeTxn::DoTransaction(void)
if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; } if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; }
// need to get the current value of the attribute and save it, and set mAttributeWasSet // need to get the current value of the attribute and save it, and set mAttributeWasSet
nsresult result = mEditor->GetAttributeValue(mElement, mAttribute, mUndoValue, mAttributeWasSet); nsresult result = mEditor->GetAttributeValue(mElement, mAttribute, mUndoValue, &mAttributeWasSet);
// XXX: hack until attribute-was-set code is implemented // XXX: hack until attribute-was-set code is implemented
if (PR_FALSE==mUndoValue.IsEmpty()) if (PR_FALSE==mUndoValue.IsEmpty())
mAttributeWasSet=PR_TRUE; mAttributeWasSet=PR_TRUE;

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

@ -54,8 +54,8 @@ public:
*/ */
NS_IMETHOD Init(nsIEditor *aEditor, NS_IMETHOD Init(nsIEditor *aEditor,
nsIDOMElement *aNode, nsIDOMElement *aNode,
const nsString& aAttribute, const nsAReadableString& aAttribute,
const nsString& aValue, const nsAReadableString& aValue,
PRBool aRemoveAttribute); PRBool aRemoveAttribute);
private: private:

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

@ -43,7 +43,7 @@ CreateElementTxn::CreateElementTxn()
} }
NS_IMETHODIMP CreateElementTxn::Init(nsEditor *aEditor, NS_IMETHODIMP CreateElementTxn::Init(nsEditor *aEditor,
const nsString &aTag, const nsAReadableString &aTag,
nsIDOMNode *aParent, nsIDOMNode *aParent,
PRUint32 aOffsetInParent) PRUint32 aOffsetInParent)
{ {

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

@ -52,7 +52,7 @@ public:
* if eAppend, the new element is appended as the last child * if eAppend, the new element is appended as the last child
*/ */
NS_IMETHOD Init(nsEditor *aEditor, NS_IMETHOD Init(nsEditor *aEditor,
const nsString& aTag, const nsAReadableString& aTag,
nsIDOMNode *aParent, nsIDOMNode *aParent,
PRUint32 aOffsetInParent); PRUint32 aOffsetInParent);

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

@ -65,7 +65,7 @@ NS_IMETHODIMP IMETextTxn::Init(nsIDOMCharacterData *aElement,
PRUint32 aOffset, PRUint32 aOffset,
PRUint32 aReplaceLength, PRUint32 aReplaceLength,
nsIPrivateTextRangeList *aTextRangeList, nsIPrivateTextRangeList *aTextRangeList,
const nsString &aStringToInsert, const nsAReadableString &aStringToInsert,
nsWeakPtr aSelConWeak) nsWeakPtr aSelConWeak)
{ {
NS_ASSERTION(aElement, "illegal value- null ptr- aElement"); NS_ASSERTION(aElement, "illegal value- null ptr- aElement");

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

@ -65,7 +65,7 @@ public:
PRUint32 aOffset, PRUint32 aOffset,
PRUint32 aReplaceLength, PRUint32 aReplaceLength,
nsIPrivateTextRangeList* aTextRangeList, nsIPrivateTextRangeList* aTextRangeList,
const nsString& aString, const nsAReadableString& aString,
nsWeakPtr aSelCon); nsWeakPtr aSelCon);
private: private:

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

@ -60,7 +60,7 @@ InsertTextTxn::~InsertTextTxn()
NS_IMETHODIMP InsertTextTxn::Init(nsIDOMCharacterData *aElement, NS_IMETHODIMP InsertTextTxn::Init(nsIDOMCharacterData *aElement,
PRUint32 aOffset, PRUint32 aOffset,
const nsString &aStringToInsert, const nsAReadableString &aStringToInsert,
nsIEditor *aEditor) nsIEditor *aEditor)
{ {
#if 0 //def DEBUG_cmanske #if 0 //def DEBUG_cmanske

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

@ -59,7 +59,7 @@ public:
*/ */
NS_IMETHOD Init(nsIDOMCharacterData *aElement, NS_IMETHOD Init(nsIDOMCharacterData *aElement,
PRUint32 aOffset, PRUint32 aOffset,
const nsString& aString, const nsAReadableString& aString,
nsIEditor *aEditor); nsIEditor *aEditor);
private: private:

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

@ -38,7 +38,7 @@ SetDocTitleTxn::SetDocTitleTxn()
} }
NS_IMETHODIMP SetDocTitleTxn::Init(nsIHTMLEditor *aEditor, NS_IMETHODIMP SetDocTitleTxn::Init(nsIHTMLEditor *aEditor,
const nsString *aValue) const nsAReadableString *aValue)
{ {
NS_ASSERTION(aEditor && aValue, "null args"); NS_ASSERTION(aEditor && aValue, "null args");
@ -72,7 +72,7 @@ NS_IMETHODIMP SetDocTitleTxn::RedoTransaction(void)
return SetDocTitle(mValue); return SetDocTitle(mValue);
} }
nsresult SetDocTitleTxn::SetDocTitle(nsString& aTitle) nsresult SetDocTitleTxn::SetDocTitle(const nsAReadableString& aTitle)
{ {
NS_ASSERTION(mEditor, "bad state"); NS_ASSERTION(mEditor, "bad state");
if (!mEditor) return NS_ERROR_NOT_INITIALIZED; if (!mEditor) return NS_ERROR_NOT_INITIALIZED;
@ -89,7 +89,7 @@ nsresult SetDocTitleTxn::SetDocTitle(nsString& aTitle)
return HTMLDoc->SetTitle(aTitle); return HTMLDoc->SetTitle(aTitle);
} }
nsresult SetDocTitleTxn::SetDomTitle(nsString& aTitle) nsresult SetDocTitleTxn::SetDomTitle(const nsAReadableString& aTitle)
{ {
nsCOMPtr<nsIDOMDocument> domDoc; nsCOMPtr<nsIDOMDocument> domDoc;
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor); nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);

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

@ -53,11 +53,11 @@ public:
* @param aValue the new value for document title * @param aValue the new value for document title
*/ */
NS_IMETHOD Init(nsIHTMLEditor *aEditor, NS_IMETHOD Init(nsIHTMLEditor *aEditor,
const nsString *aValue); const nsAReadableString *aValue);
private: private:
SetDocTitleTxn(); SetDocTitleTxn();
nsresult SetDocTitle(nsString& aTitle); nsresult SetDocTitle(const nsAReadableString& aTitle);
nsresult SetDomTitle(nsString& aTitle); nsresult SetDomTitle(const nsAReadableString& aTitle);
public: public:
NS_IMETHOD DoTransaction(void); NS_IMETHOD DoTransaction(void);

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

@ -71,13 +71,13 @@ nsresult TextEditorTest::RunUnitTest(PRInt32 *outNumTests, PRInt32 *outNumTestsF
// shouldn't we just bail on error here? // shouldn't we just bail on error here?
// insert some simple text // insert some simple text
result = mTextEditor->InsertText(NS_LITERAL_STRING("1234567890abcdefghij1234567890").get()); result = mTextEditor->InsertText(NS_LITERAL_STRING("1234567890abcdefghij1234567890"));
TEST_RESULT(result); TEST_RESULT(result);
(*outNumTests)++; (*outNumTests)++;
(*outNumTestsFailed) += (NS_FAILED(result) != NS_OK); (*outNumTestsFailed) += (NS_FAILED(result) != NS_OK);
// insert some more text // insert some more text
result = mTextEditor->InsertText(NS_LITERAL_STRING("Moreover, I am cognizant of the interrelatedness of all communities and states. I cannot sit idly by in Atlanta and not be concerned about what happens in Birmingham. Injustice anywhere is a threat to justice everywhere").get()); result = mTextEditor->InsertText(NS_LITERAL_STRING("Moreover, I am cognizant of the interrelatedness of all communities and states. I cannot sit idly by in Atlanta and not be concerned about what happens in Birmingham. Injustice anywhere is a threat to justice everywhere"));
TEST_RESULT(result); TEST_RESULT(result);
(*outNumTests)++; (*outNumTests)++;
(*outNumTestsFailed) += (NS_FAILED(result) != NS_OK); (*outNumTestsFailed) += (NS_FAILED(result) != NS_OK);
@ -174,14 +174,14 @@ nsresult TextEditorTest::TestTextProperties()
PRBool all = PR_FALSE; PRBool all = PR_FALSE;
PRBool first=PR_FALSE; PRBool first=PR_FALSE;
result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all); result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all);
TEST_RESULT(result); TEST_RESULT(result);
NS_ASSERTION(PR_FALSE==first, "first should be false"); NS_ASSERTION(PR_FALSE==first, "first should be false");
NS_ASSERTION(PR_FALSE==any, "any should be false"); NS_ASSERTION(PR_FALSE==any, "any should be false");
NS_ASSERTION(PR_FALSE==all, "all should be false"); NS_ASSERTION(PR_FALSE==all, "all should be false");
result = htmlEditor->SetInlineProperty(nsIEditProperty::b, nsnull, nsnull); result = htmlEditor->SetInlineProperty(nsIEditProperty::b, nsString(), nsString());
TEST_RESULT(result); TEST_RESULT(result);
result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all); result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all);
TEST_RESULT(result); TEST_RESULT(result);
NS_ASSERTION(PR_TRUE==first, "first should be true"); NS_ASSERTION(PR_TRUE==first, "first should be true");
NS_ASSERTION(PR_TRUE==any, "any should be true"); NS_ASSERTION(PR_TRUE==any, "any should be true");
@ -190,9 +190,9 @@ nsresult TextEditorTest::TestTextProperties()
// remove the bold we just set // remove the bold we just set
printf("set the whole first text node to not bold\n"); printf("set the whole first text node to not bold\n");
result = htmlEditor->RemoveInlineProperty(nsIEditProperty::b, nsnull); result = htmlEditor->RemoveInlineProperty(nsIEditProperty::b, nsString());
TEST_RESULT(result); TEST_RESULT(result);
result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all); result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all);
TEST_RESULT(result); TEST_RESULT(result);
NS_ASSERTION(PR_FALSE==first, "first should be false"); NS_ASSERTION(PR_FALSE==first, "first should be false");
NS_ASSERTION(PR_FALSE==any, "any should be false"); NS_ASSERTION(PR_FALSE==any, "any should be false");
@ -203,23 +203,23 @@ nsresult TextEditorTest::TestTextProperties()
printf("set the first text node (1, length-1) to bold and italic, and (2, length-1) to underline.\n"); printf("set the first text node (1, length-1) to bold and italic, and (2, length-1) to underline.\n");
selection->Collapse(textNode, 1); selection->Collapse(textNode, 1);
selection->Extend(textNode, length-1); selection->Extend(textNode, length-1);
result = htmlEditor->SetInlineProperty(nsIEditProperty::b, nsnull, nsnull); result = htmlEditor->SetInlineProperty(nsIEditProperty::b, nsString(), nsString());
TEST_RESULT(result); TEST_RESULT(result);
result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all); result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all);
TEST_RESULT(result); TEST_RESULT(result);
NS_ASSERTION(PR_TRUE==first, "first should be true"); NS_ASSERTION(PR_TRUE==first, "first should be true");
NS_ASSERTION(PR_TRUE==any, "any should be true"); NS_ASSERTION(PR_TRUE==any, "any should be true");
NS_ASSERTION(PR_TRUE==all, "all should be true"); NS_ASSERTION(PR_TRUE==all, "all should be true");
mEditor->DebugDumpContent(); mEditor->DebugDumpContent();
// make all that same text italic // make all that same text italic
result = htmlEditor->SetInlineProperty(nsIEditProperty::i, nsnull, nsnull); result = htmlEditor->SetInlineProperty(nsIEditProperty::i, nsString(), nsString());
TEST_RESULT(result); TEST_RESULT(result);
result = htmlEditor->GetInlineProperty(nsIEditProperty::i, nsnull, nsnull, first, any, all); result = htmlEditor->GetInlineProperty(nsIEditProperty::i, nsString(), nsString(), &first, &any, &all);
TEST_RESULT(result); TEST_RESULT(result);
NS_ASSERTION(PR_TRUE==first, "first should be true"); NS_ASSERTION(PR_TRUE==first, "first should be true");
NS_ASSERTION(PR_TRUE==any, "any should be true"); NS_ASSERTION(PR_TRUE==any, "any should be true");
NS_ASSERTION(PR_TRUE==all, "all should be true"); NS_ASSERTION(PR_TRUE==all, "all should be true");
result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all); result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all);
TEST_RESULT(result); TEST_RESULT(result);
NS_ASSERTION(PR_TRUE==first, "first should be true"); NS_ASSERTION(PR_TRUE==first, "first should be true");
NS_ASSERTION(PR_TRUE==any, "any should be true"); NS_ASSERTION(PR_TRUE==any, "any should be true");
@ -240,9 +240,9 @@ nsresult TextEditorTest::TestTextProperties()
NS_ASSERTION(length==915, "wrong text node"); NS_ASSERTION(length==915, "wrong text node");
selection->Collapse(textNode, 1); selection->Collapse(textNode, 1);
selection->Extend(textNode, length-2); selection->Extend(textNode, length-2);
result = htmlEditor->SetInlineProperty(nsIEditProperty::u, nsnull, nsnull); result = htmlEditor->SetInlineProperty(nsIEditProperty::u, nsString(), nsString());
TEST_RESULT(result); TEST_RESULT(result);
result = htmlEditor->GetInlineProperty(nsIEditProperty::u, nsnull, nsnull, first, any, all); result = htmlEditor->GetInlineProperty(nsIEditProperty::u, nsString(), nsString(), &first, &any, &all);
TEST_RESULT(result); TEST_RESULT(result);
NS_ASSERTION(PR_TRUE==first, "first should be true"); NS_ASSERTION(PR_TRUE==first, "first should be true");
NS_ASSERTION(PR_TRUE==any, "any should be true"); NS_ASSERTION(PR_TRUE==any, "any should be true");

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

@ -62,51 +62,53 @@ nsAOLCiter::QueryInterface(REFNSIID aIID, void** aInstancePtr)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsAOLCiter::GetCiteString(const nsString& aInString, nsString& aOutString) nsAOLCiter::GetCiteString(const nsAReadableString& aInString, nsAWritableString& aOutString)
{ {
aOutString.AssignWithConversion("\n\n>> "); aOutString = NS_LITERAL_STRING("\n\n>> ");
aOutString += aInString; aOutString += aInString;
// See if the last char is a newline, and replace it if so // See if the last char is a newline, and replace it if so
PRUnichar newline ('\n'); PRUnichar newline ('\n');
if (aOutString.Last() == newline) if (aOutString.Last() == newline)
{ {
aOutString.SetCharAt(' ',aOutString.Length()); aOutString.Append(PRUnichar(' '));
aOutString.AppendWithConversion("<<\n"); aOutString.Append(NS_LITERAL_STRING("<<\n"));
} }
else else
{ {
aOutString.AppendWithConversion(" <<\n"); aOutString.Append(NS_LITERAL_STRING(" <<\n"));
} }
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsAOLCiter::StripCites(const nsString& aInString, nsString& aOutString) nsAOLCiter::StripCites(const nsAReadableString& aInString, nsAWritableString& aOutString)
{ {
// Remove the beginning cites, if any: // Remove the beginning cites, if any:
if (aInString.EqualsWithConversion(">>", PR_FALSE, 2)) nsAutoString tInputString(aInString);//MJUDGE SCC NEED HELP
nsAutoString tOutputString;
if (tInputString.EqualsWithConversion(">>", PR_FALSE, 2))
{ {
PRInt32 i = 3; PRInt32 i = 3;
while (nsCRT::IsAsciiSpace(aInString[i])) while (nsCRT::IsAsciiSpace(tInputString[i]))
++i; ++i;
aOutString.Append(aInString.GetUnicode(), i); tOutputString.Append(tInputString.GetUnicode(), i);
} }
else else
aOutString = aInString; tOutputString = tInputString;
// Remove the end cites, if any: // Remove the end cites, if any:
aOutString.Trim("<", PR_FALSE, PR_TRUE, PR_FALSE); tOutputString.Trim("<", PR_FALSE, PR_TRUE, PR_FALSE);
aOutString.Assign(tOutputString);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsAOLCiter::Rewrap(const nsString& aInString, nsAOLCiter::Rewrap(const nsAReadableString& aInString,
PRUint32 aWrapCol, PRUint32 aFirstLineOffset, PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
PRBool aRespectNewlines, PRBool aRespectNewlines,
nsString& aOutString) nsAWritableString& aOutString)
{ {
nsString citeString; nsString citeString;
return nsWrapUtils::Rewrap(aInString, aWrapCol, aFirstLineOffset, return nsWrapUtils::Rewrap(aInString, aWrapCol, aFirstLineOffset,

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

@ -23,9 +23,9 @@
#ifndef nsAOLCiter_h__ #ifndef nsAOLCiter_h__
#define nsAOLCiter_h__ #define nsAOLCiter_h__
#include "nsString.h"
#include "nsICiter.h" #include "nsICiter.h"
#include "nsString.h"
/** Mail citations using the AOL style >> This is a citation << /** Mail citations using the AOL style >> This is a citation <<
*/ */
@ -38,14 +38,14 @@ public:
//NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor //NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_IMETHOD GetCiteString(const nsString& aInString, nsString& aOutString); NS_IMETHOD GetCiteString(const nsAReadableString & aInString, nsAWritableString & aOutString);
NS_IMETHOD StripCites(const nsString& aInString, nsString& aOutString); NS_IMETHOD StripCites(const nsAReadableString & aInString, nsAWritableString & aOutString);
NS_IMETHOD Rewrap(const nsString& aInString, NS_IMETHOD Rewrap(const nsAReadableString & aInString,
PRUint32 aWrapCol, PRUint32 aFirstLineOffset, PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
PRBool aRespectNewlines, PRBool aRespectNewlines,
nsString& aOutString); nsAWritableString & aOutString);
}; };
#endif //nsAOLCiter_h__ #endif //nsAOLCiter_h__

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

@ -274,7 +274,7 @@ nsPasteQuotationCommand::IsCommandEnabled(const nsAReadableString & aCommandName
nsCOMPtr<nsIEditor> editor; nsCOMPtr<nsIEditor> editor;
editorShell->GetEditor(getter_AddRefs(editor)); editorShell->GetEditor(getter_AddRefs(editor));
if (editor) if (editor)
editor->CanPaste(nsIClipboard::kGlobalClipboard, *outCmdEnabled); editor->CanPaste(nsIClipboard::kGlobalClipboard, outCmdEnabled);
} }
return NS_OK; return NS_OK;
@ -322,7 +322,7 @@ nsStyleUpdatingCommand::GetCurrentState(nsIEditorShell *aEditorShell, const char
if (!htmlEditor) return NS_ERROR_NOT_INITIALIZED; if (!htmlEditor) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIAtom> styleAtom = getter_AddRefs(NS_NewAtom(aTagName)); nsCOMPtr<nsIAtom> styleAtom = getter_AddRefs(NS_NewAtom(aTagName));
rv = htmlEditor->GetInlineProperty(styleAtom, nsnull, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp); rv = htmlEditor->GetInlineProperty(styleAtom, NS_LITERAL_STRING(""), NS_LITERAL_STRING(""), &firstOfSelectionHasProp, &anyOfSelectionHasProp, &allOfSelectionHasProp);
outStyleSet = allOfSelectionHasProp; // change this to alter the behaviour outStyleSet = allOfSelectionHasProp; // change this to alter the behaviour
return rv; return rv;
@ -442,8 +442,7 @@ nsListItemCommand::ToggleState(nsIEditorShell *aEditorShell, const char* aTagNam
{ {
if (!bMixed) if (!bMixed)
{ {
nsAutoString listType(tagStr); rv = htmlEditor->RemoveList(nsLiteralString(tagStr));
rv = htmlEditor->RemoveList(listType);
} }
nsCRT::free(tagStr); nsCRT::free(tagStr);
} }
@ -554,7 +553,7 @@ nsOutdentCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISu
if (htmlEditor) if (htmlEditor)
{ {
PRBool canIndent, canOutdent; PRBool canIndent, canOutdent;
htmlEditor->GetIndentState(canIndent, canOutdent); htmlEditor->GetIndentState(&canIndent, &canOutdent);
*outCmdEnabled = canOutdent; *outCmdEnabled = canOutdent;
} }
@ -690,7 +689,7 @@ nsParagraphStateCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsString&
aEditorShell->GetEditor(getter_AddRefs(editor)); aEditorShell->GetEditor(getter_AddRefs(editor));
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(editor); nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(editor);
if (!htmlEditor) return NS_ERROR_FAILURE; if (!htmlEditor) return NS_ERROR_FAILURE;
return htmlEditor->GetParagraphState(outMixed, outStateString); return htmlEditor->GetParagraphState(&outMixed, outStateString);
} }
@ -727,7 +726,7 @@ nsFontFaceStateCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsString&
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(editor); nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(editor);
if (!htmlEditor) return NS_ERROR_FAILURE; if (!htmlEditor) return NS_ERROR_FAILURE;
return htmlEditor->GetFontFaceState(outMixed, outStateString); return htmlEditor->GetFontFaceState(&outMixed, outStateString);
} }
@ -743,9 +742,6 @@ nsFontFaceStateCommand::SetState(nsIEditorShell *aEditorShell, nsString& newStat
nsresult rv; nsresult rv;
NS_ConvertASCIItoUCS2 emptyString("");
NS_ConvertASCIItoUCS2 fontString("font");
NS_ConvertASCIItoUCS2 faceString("face");
nsCOMPtr<nsIAtom> ttAtom = getter_AddRefs(NS_NewAtom("tt")); nsCOMPtr<nsIAtom> ttAtom = getter_AddRefs(NS_NewAtom("tt"));
nsCOMPtr<nsIAtom> fontAtom = getter_AddRefs(NS_NewAtom("font")); nsCOMPtr<nsIAtom> fontAtom = getter_AddRefs(NS_NewAtom("font"));
@ -753,19 +749,19 @@ nsFontFaceStateCommand::SetState(nsIEditorShell *aEditorShell, nsString& newStat
if (newState.EqualsWithConversion("tt")) if (newState.EqualsWithConversion("tt"))
{ {
// The old "teletype" attribute // The old "teletype" attribute
rv = htmlEditor->SetInlineProperty(ttAtom, &emptyString, &emptyString); rv = htmlEditor->SetInlineProperty(ttAtom, NS_LITERAL_STRING(""), NS_LITERAL_STRING(""));
// Clear existing font face // Clear existing font face
rv = htmlEditor->RemoveInlineProperty(fontAtom, &faceString); rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("face"));
} }
else else
{ {
// Remove any existing TT nodes // Remove any existing TT nodes
rv = htmlEditor->RemoveInlineProperty(ttAtom, &emptyString); rv = htmlEditor->RemoveInlineProperty(ttAtom, NS_LITERAL_STRING(""));
if (newState == emptyString || newState.EqualsWithConversion("normal")) { if (!newState.Length() || newState.EqualsWithConversion("normal")) {
rv = htmlEditor->RemoveInlineProperty(fontAtom, &faceString); rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("face"));
} else { } else {
rv = htmlEditor->SetInlineProperty(fontAtom, &faceString, &newState); rv = htmlEditor->SetInlineProperty(fontAtom, NS_LITERAL_STRING("face"), newState);
} }
} }
@ -791,7 +787,7 @@ nsFontColorStateCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsString&
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(editor); nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(editor);
if (!htmlEditor) return NS_ERROR_FAILURE; if (!htmlEditor) return NS_ERROR_FAILURE;
return htmlEditor->GetFontColorState(outMixed, outStateString); return htmlEditor->GetFontColorState(&outMixed, outStateString);
} }
@ -807,16 +803,13 @@ nsFontColorStateCommand::SetState(nsIEditorShell *aEditorShell, nsString& newSta
nsresult rv; nsresult rv;
NS_ConvertASCIItoUCS2 emptyString("");
NS_ConvertASCIItoUCS2 fontString("font");
NS_ConvertASCIItoUCS2 colorString("color");
nsCOMPtr<nsIAtom> fontAtom = getter_AddRefs(NS_NewAtom("font")); nsCOMPtr<nsIAtom> fontAtom = getter_AddRefs(NS_NewAtom("font"));
if (newState == emptyString || newState.EqualsWithConversion("normal")) { if (!newState.Length() || newState.EqualsWithConversion("normal")) {
rv = htmlEditor->RemoveInlineProperty(fontAtom, &colorString); rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("color"));
} else { } else {
rv = htmlEditor->SetInlineProperty(fontAtom, &colorString, &newState); rv = htmlEditor->SetInlineProperty(fontAtom, NS_LITERAL_STRING("color"), newState);
} }
return rv; return rv;
@ -842,7 +835,7 @@ nsBackgroundColorStateCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsS
if (!htmlEditor) return NS_ERROR_FAILURE; if (!htmlEditor) return NS_ERROR_FAILURE;
return htmlEditor->GetBackgroundColorState(outMixed, outStateString); return htmlEditor->GetBackgroundColorState(&outMixed, outStateString);
} }
@ -879,7 +872,7 @@ nsAlignCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsString& outState
if (!htmlEditor) return NS_ERROR_FAILURE; if (!htmlEditor) return NS_ERROR_FAILURE;
nsIHTMLEditor::EAlignment firstAlign; nsIHTMLEditor::EAlignment firstAlign;
nsresult rv = htmlEditor->GetAlignment(outMixed, firstAlign); nsresult rv = htmlEditor->GetAlignment(&outMixed, &firstAlign);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
switch (firstAlign) switch (firstAlign)
{ {

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

@ -580,17 +580,19 @@ nsEditor::Undo(PRUint32 aCount)
} }
NS_IMETHODIMP nsEditor::CanUndo(PRBool &aIsEnabled, PRBool &aCanUndo) NS_IMETHODIMP nsEditor::CanUndo(PRBool *aIsEnabled, PRBool *aCanUndo)
{ {
aIsEnabled = ((PRBool)((nsITransactionManager *)0!=mTxnMgr.get())); if (!aIsEnabled || !aCanUndo)
if (aIsEnabled) return NS_ERROR_NULL_POINTER;
*aIsEnabled = ((PRBool)((nsITransactionManager *)0!=mTxnMgr.get()));
if (*aIsEnabled)
{ {
PRInt32 numTxns=0; PRInt32 numTxns=0;
mTxnMgr->GetNumberOfUndoItems(&numTxns); mTxnMgr->GetNumberOfUndoItems(&numTxns);
aCanUndo = ((PRBool)(0!=numTxns)); *aCanUndo = ((PRBool)(0!=numTxns));
} }
else { else {
aCanUndo = PR_FALSE; *aCanUndo = PR_FALSE;
} }
return NS_OK; return NS_OK;
} }
@ -624,17 +626,20 @@ nsEditor::Redo(PRUint32 aCount)
} }
NS_IMETHODIMP nsEditor::CanRedo(PRBool &aIsEnabled, PRBool &aCanRedo) NS_IMETHODIMP nsEditor::CanRedo(PRBool *aIsEnabled, PRBool *aCanRedo)
{ {
aIsEnabled = ((PRBool)((nsITransactionManager *)0!=mTxnMgr.get())); if (!aIsEnabled || !aCanRedo)
if (aIsEnabled) return NS_ERROR_NULL_POINTER;
*aIsEnabled = ((PRBool)((nsITransactionManager *)0!=mTxnMgr.get()));
if (*aIsEnabled)
{ {
PRInt32 numTxns=0; PRInt32 numTxns=0;
mTxnMgr->GetNumberOfRedoItems(&numTxns); mTxnMgr->GetNumberOfRedoItems(&numTxns);
aCanRedo = ((PRBool)(0!=numTxns)); *aCanRedo = ((PRBool)(0!=numTxns));
} }
else { else {
aCanRedo = PR_FALSE; *aCanRedo = PR_FALSE;
} }
return NS_OK; return NS_OK;
} }
@ -891,24 +896,19 @@ nsEditor::GetDocumentModified(PRBool *outDocModified)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::GetDocumentCharacterSet(PRUnichar** characterSet) nsEditor::GetDocumentCharacterSet(nsAWritableString &characterSet)
{ {
nsresult rv; nsresult rv;
nsCOMPtr<nsIDocument> doc; nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIPresShell> presShell; nsCOMPtr<nsIPresShell> presShell;
nsAutoString character_set;
if (characterSet==nsnull) return NS_ERROR_NULL_POINTER;
rv = GetPresShell(getter_AddRefs(presShell)); rv = GetPresShell(getter_AddRefs(presShell));
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
presShell->GetDocument(getter_AddRefs(doc)); presShell->GetDocument(getter_AddRefs(doc));
if (doc ) { if (doc )
rv = doc->GetDocumentCharacterSet(character_set); return doc->GetDocumentCharacterSet(characterSet);
if (NS_SUCCEEDED(rv)) *characterSet=character_set.ToNewUnicode(); rv = NS_ERROR_NULL_POINTER;
return rv;
}
} }
return rv; return rv;
@ -916,22 +916,20 @@ nsEditor::GetDocumentCharacterSet(PRUnichar** characterSet)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::SetDocumentCharacterSet(const PRUnichar* characterSet) nsEditor::SetDocumentCharacterSet(const nsAReadableString& characterSet)
{ {
nsresult rv; nsresult rv;
nsCOMPtr<nsIDocument> doc; nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIPresShell> presShell; nsCOMPtr<nsIPresShell> presShell;
nsAutoString character_set(characterSet);
if (characterSet==nsnull) return NS_ERROR_NULL_POINTER;
rv = GetPresShell(getter_AddRefs(presShell)); rv = GetPresShell(getter_AddRefs(presShell));
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
presShell->GetDocument(getter_AddRefs(doc)); presShell->GetDocument(getter_AddRefs(doc));
if (doc) { if (doc) {
return doc->SetDocumentCharacterSet(character_set); return doc->SetDocumentCharacterSet(characterSet);
} }
rv = NS_ERROR_NULL_POINTER;
} }
return rv; return rv;
@ -957,7 +955,7 @@ nsEditor::GetWrapWidth(PRInt32 *aWrapColumn)
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting, nsEditor::SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting,
PRBool aSaveCopy, const nsString& aFormat) PRBool aSaveCopy, const nsAReadableString& aFormat)
{ {
if (!aFileSpec) if (!aFileSpec)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
@ -997,8 +995,9 @@ nsEditor::SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting,
GetWrapWidth(&wrapColumn); GetWrapWidth(&wrapColumn);
if (wrapColumn > 0) if (wrapColumn > 0)
flags |= nsIDocumentEncoder::OutputWrap; flags |= nsIDocumentEncoder::OutputWrap;
const nsPromiseFlatString &formatFlat = PromiseFlatString(aFormat);
rv = diskDoc->SaveFile(aFileSpec, aReplaceExisting, aSaveCopy, rv = diskDoc->SaveFile(aFileSpec, aReplaceExisting, aSaveCopy,
aFormat.GetUnicode(), NS_LITERAL_STRING("").get(), formatFlat.get(), NS_LITERAL_STRING("").get(),
flags, wrapColumn); flags, wrapColumn);
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
DoAfterDocumentSave(); DoAfterDocumentSave();
@ -1015,7 +1014,7 @@ nsEditor::Cut()
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::CanCut(PRBool &aCanCut) nsEditor::CanCut(PRBool *aCanCut)
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
@ -1027,7 +1026,7 @@ nsEditor::Copy()
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::CanCopy(PRBool &aCanCopy) nsEditor::CanCopy(PRBool *aCanCut)
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
@ -1039,13 +1038,13 @@ nsEditor::Paste(PRInt32 aSelectionType)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste) nsEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste)
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::CanDrag(nsIDOMEvent *aEvent, PRBool &aCanDrag) nsEditor::CanDrag(nsIDOMEvent *aEvent, PRBool *aCanDrag)
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
@ -1064,7 +1063,7 @@ nsEditor::InsertFromDrop(nsIDOMEvent *aEvent)
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::SetAttribute(nsIDOMElement *aElement, const nsString& aAttribute, const nsString& aValue) nsEditor::SetAttribute(nsIDOMElement *aElement, const nsAReadableString & aAttribute, const nsAReadableString & aValue)
{ {
ChangeAttributeTxn *txn; ChangeAttributeTxn *txn;
nsresult result = CreateTxnForSetAttribute(aElement, aAttribute, aValue, &txn); nsresult result = CreateTxnForSetAttribute(aElement, aAttribute, aValue, &txn);
@ -1079,11 +1078,13 @@ nsEditor::SetAttribute(nsIDOMElement *aElement, const nsString& aAttribute, cons
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::GetAttributeValue(nsIDOMElement *aElement, nsEditor::GetAttributeValue(nsIDOMElement *aElement,
const nsString& aAttribute, const nsAReadableString & aAttribute,
nsString& aResultValue, nsAWritableString & aResultValue,
PRBool& aResultIsSet) PRBool *aResultIsSet)
{ {
aResultIsSet=PR_FALSE; if (!aResultIsSet)
return NS_ERROR_NULL_POINTER;
*aResultIsSet=PR_FALSE;
nsresult result=NS_OK; nsresult result=NS_OK;
if (nsnull!=aElement) if (nsnull!=aElement)
{ {
@ -1091,7 +1092,7 @@ nsEditor::GetAttributeValue(nsIDOMElement *aElement,
result = aElement->GetAttributeNode(aAttribute, getter_AddRefs(attNode)); result = aElement->GetAttributeNode(aAttribute, getter_AddRefs(attNode));
if ((NS_SUCCEEDED(result)) && attNode) if ((NS_SUCCEEDED(result)) && attNode)
{ {
attNode->GetSpecified(&aResultIsSet); attNode->GetSpecified(aResultIsSet);
attNode->GetValue(aResultValue); attNode->GetValue(aResultValue);
} }
} }
@ -1099,7 +1100,7 @@ nsEditor::GetAttributeValue(nsIDOMElement *aElement,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::RemoveAttribute(nsIDOMElement *aElement, const nsString& aAttribute) nsEditor::RemoveAttribute(nsIDOMElement *aElement, const nsAReadableString& aAttribute)
{ {
ChangeAttributeTxn *txn; ChangeAttributeTxn *txn;
nsresult result = CreateTxnForRemoveAttribute(aElement, aAttribute, &txn); nsresult result = CreateTxnForRemoveAttribute(aElement, aAttribute, &txn);
@ -1129,7 +1130,7 @@ nsEditor::MarkNodeDirty(nsIDOMNode* aNode)
#pragma mark - #pragma mark -
#endif #endif
NS_IMETHODIMP nsEditor::CreateNode(const nsString& aTag, NS_IMETHODIMP nsEditor::CreateNode(const nsAReadableString& aTag,
nsIDOMNode * aParent, nsIDOMNode * aParent,
PRInt32 aPosition, PRInt32 aPosition,
nsIDOMNode ** aNewNode) nsIDOMNode ** aNewNode)
@ -1380,9 +1381,9 @@ NS_IMETHODIMP nsEditor::DeleteNode(nsIDOMNode * aElement)
nsresult nsresult
nsEditor::ReplaceContainer(nsIDOMNode *inNode, nsEditor::ReplaceContainer(nsIDOMNode *inNode,
nsCOMPtr<nsIDOMNode> *outNode, nsCOMPtr<nsIDOMNode> *outNode,
const nsString &aNodeType, const nsAReadableString &aNodeType,
const nsString *aAttribute, const nsAReadableString *aAttribute,
const nsString *aValue, const nsAReadableString *aValue,
PRBool aCloneAttributes) PRBool aCloneAttributes)
{ {
if (!inNode || !outNode) if (!inNode || !outNode)
@ -1502,9 +1503,9 @@ nsEditor::RemoveContainer(nsIDOMNode *inNode)
nsresult nsresult
nsEditor::InsertContainerAbove( nsIDOMNode *inNode, nsEditor::InsertContainerAbove( nsIDOMNode *inNode,
nsCOMPtr<nsIDOMNode> *outNode, nsCOMPtr<nsIDOMNode> *outNode,
const nsString &aNodeType, const nsAReadableString &aNodeType,
const nsString *aAttribute, const nsAReadableString *aAttribute,
const nsString *aValue) const nsAReadableString *aValue)
{ {
if (!inNode || !outNode) if (!inNode || !outNode)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
@ -1771,7 +1772,7 @@ NS_IMETHODIMP nsEditor::OutputToString(nsAWritableString& aOutputString,
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::OutputToStream(nsIOutputStream* aOutputStream, nsEditor::OutputToStream(nsIOutputStream* aOutputStream,
const nsAReadableString& aFormatType, const nsAReadableString& aFormatType,
const nsAReadableString* aCharsetOverride, const nsAReadableString& aCharsetOverride,
PRUint32 aFlags) PRUint32 aFlags)
{ {
// these should be implemented by derived classes. // these should be implemented by derived classes.
@ -1788,7 +1789,7 @@ nsEditor::DumpContentTree()
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::DebugDumpContent() const nsEditor::DebugDumpContent()
{ {
nsCOMPtr<nsIContent>content; nsCOMPtr<nsIContent>content;
nsCOMPtr<nsIDOMNodeList>nodeList; nsCOMPtr<nsIDOMNodeList>nodeList;
@ -1935,7 +1936,7 @@ nsEditor::EndComposition(void)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply) nsEditor::SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply)
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
@ -2276,7 +2277,7 @@ NS_IMETHODIMP nsEditor::ScrollIntoView(PRBool aScrollToBegin)
} }
/** static helper method */ /** static helper method */
nsresult nsEditor::GetTextNodeTag(nsString& aOutString) nsresult nsEditor::GetTextNodeTag(nsAWritableString& aOutString)
{ {
aOutString.SetLength(0); aOutString.SetLength(0);
static nsString *gTextNodeTag=nsnull; static nsString *gTextNodeTag=nsnull;
@ -2291,7 +2292,7 @@ nsresult nsEditor::GetTextNodeTag(nsString& aOutString)
} }
NS_IMETHODIMP nsEditor::InsertTextImpl(const nsString& aStringToInsert, NS_IMETHODIMP nsEditor::InsertTextImpl(const nsAReadableString& aStringToInsert,
nsCOMPtr<nsIDOMNode> *aInOutNode, nsCOMPtr<nsIDOMNode> *aInOutNode,
PRInt32 *aInOutOffset, PRInt32 *aInOutOffset,
nsIDOMDocument *aDoc) nsIDOMDocument *aDoc)
@ -2352,7 +2353,7 @@ NS_IMETHODIMP nsEditor::InsertTextImpl(const nsString& aStringToInsert,
} }
NS_IMETHODIMP nsEditor::InsertTextIntoTextNodeImpl(const nsString& aStringToInsert, NS_IMETHODIMP nsEditor::InsertTextIntoTextNodeImpl(const nsAReadableString& aStringToInsert,
nsIDOMCharacterData *aTextNode, nsIDOMCharacterData *aTextNode,
PRInt32 aOffset) PRInt32 aOffset)
{ {
@ -2570,7 +2571,7 @@ nsEditor::NotifyDocumentListeners(TDocumentListenerNotification aNotificationTyp
} }
NS_IMETHODIMP nsEditor::CreateTxnForInsertText(const nsString & aStringToInsert, NS_IMETHODIMP nsEditor::CreateTxnForInsertText(const nsAReadableString & aStringToInsert,
nsIDOMCharacterData *aTextNode, nsIDOMCharacterData *aTextNode,
PRInt32 aOffset, PRInt32 aOffset,
InsertTextTxn ** aTxn) InsertTextTxn ** aTxn)
@ -3077,6 +3078,7 @@ nsEditor::GetLengthOfDOMNode(nsIDOMNode *aNode, PRUint32 &aCount)
return result; return result;
} }
nsresult nsresult
nsEditor::GetPriorNode(nsIDOMNode *aParentNode, nsEditor::GetPriorNode(nsIDOMNode *aParentNode,
PRInt32 aOffset, PRInt32 aOffset,
@ -3379,24 +3381,22 @@ nsEditor::NodeIsType(nsIDOMNode *aNode, nsIAtom *aTag)
} }
PRBool PRBool
nsEditor::NodeIsType(nsIDOMNode *aNode, const nsString &aTagStr) nsEditor::NodeIsType(nsIDOMNode *aNode, const nsAReadableString &aTagStr)
{ {
nsCOMPtr<nsIDOMElement>element; nsCOMPtr<nsIDOMElement>element;
element = do_QueryInterface(aNode); element = do_QueryInterface(aNode);
if (element) if (element)
{ {
nsAutoString tag; nsAutoString tag, tagStr(aTagStr);
element->GetTagName(tag); element->GetTagName(tag);
if (tag.EqualsIgnoreCase(aTagStr)) if (tag.EqualsIgnoreCase(tagStr))
{
return PR_TRUE; return PR_TRUE;
}
} }
return PR_FALSE; return PR_FALSE;
} }
PRBool PRBool
nsEditor::CanContainTag(nsIDOMNode* aParent, const nsString &aChildTag) nsEditor::CanContainTag(nsIDOMNode* aParent, const nsAReadableString &aChildTag)
{ {
nsAutoString parentStringTag; nsAutoString parentStringTag;
@ -3408,7 +3408,7 @@ nsEditor::CanContainTag(nsIDOMNode* aParent, const nsString &aChildTag)
} }
PRBool PRBool
nsEditor::TagCanContain(const nsString &aParentTag, nsIDOMNode* aChild) nsEditor::TagCanContain(const nsAReadableString &aParentTag, nsIDOMNode* aChild)
{ {
nsAutoString childStringTag; nsAutoString childStringTag;
@ -3426,7 +3426,7 @@ nsEditor::TagCanContain(const nsString &aParentTag, nsIDOMNode* aChild)
} }
PRBool PRBool
nsEditor::TagCanContainTag(const nsString &aParentTag, const nsString &aChildTag) nsEditor::TagCanContainTag(const nsAReadableString &aParentTag, const nsAReadableString &aChildTag)
{ {
// if we don't have a dtd then assume we can insert whatever want // if we don't have a dtd then assume we can insert whatever want
if (!mDTD) return PR_TRUE; if (!mDTD) return PR_TRUE;
@ -3680,7 +3680,7 @@ void nsEditor::HACKForceRedraw()
nsresult nsresult
nsEditor::GetFirstNodeOfType(nsIDOMNode *aStartNode, nsEditor::GetFirstNodeOfType(nsIDOMNode *aStartNode,
const nsString &aTag, const nsAReadableString &aTag,
nsIDOMNode **aResult) nsIDOMNode **aResult)
{ {
nsresult result=NS_OK; nsresult result=NS_OK;
@ -3697,11 +3697,11 @@ nsEditor::GetFirstNodeOfType(nsIDOMNode *aStartNode,
while (childNode) while (childNode)
{ {
result = childNode->QueryInterface(NS_GET_IID(nsIDOMNode),getter_AddRefs(element)); result = childNode->QueryInterface(NS_GET_IID(nsIDOMNode),getter_AddRefs(element));
nsAutoString tag;
if (NS_SUCCEEDED(result) && (element)) if (NS_SUCCEEDED(result) && (element))
{ {
nsAutoString tag, tagStr(aTag);
element->GetTagName(tag); element->GetTagName(tag);
if (PR_TRUE==aTag.EqualsIgnoreCase(tag)) if (tagStr.EqualsIgnoreCase(tag))
{ {
return (childNode->QueryInterface(NS_GET_IID(nsIDOMNode),(void **) aResult)); // does the addref return (childNode->QueryInterface(NS_GET_IID(nsIDOMNode),(void **) aResult)); // does the addref
} }
@ -3797,7 +3797,7 @@ nsEditor::GetTag(nsIDOMNode *aNode)
// GetTagString: digs out string for the tag of this node // GetTagString: digs out string for the tag of this node
// //
nsresult nsresult
nsEditor::GetTagString(nsIDOMNode *aNode, nsString& outString) nsEditor::GetTagString(nsIDOMNode *aNode, nsAWritableString& outString)
{ {
nsCOMPtr<nsIAtom> atom; nsCOMPtr<nsIAtom> atom;
@ -3840,7 +3840,6 @@ nsEditor::NodesSameType(nsIDOMNode *aNode1, nsIDOMNode *aNode2)
} }
///////////////////////////////////////////////////////////////////////////
// IsTextOrElementNode: true if node of dom type element or text // IsTextOrElementNode: true if node of dom type element or text
// //
PRBool PRBool
@ -4378,7 +4377,7 @@ nsEditor::DeleteSelectionImpl(nsIEditor::EDirection aAction)
// XXX: error handling in this routine needs to be cleaned up! // XXX: error handling in this routine needs to be cleaned up!
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::DeleteSelectionAndCreateNode(const nsString& aTag, nsEditor::DeleteSelectionAndCreateNode(const nsAReadableString& aTag,
nsIDOMNode ** aNewNode) nsIDOMNode ** aNewNode)
{ {
nsCOMPtr<nsIDOMNode> parentSelectedNode; nsCOMPtr<nsIDOMNode> parentSelectedNode;
@ -4557,8 +4556,8 @@ nsEditor::DoAfterDocumentSave()
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::CreateTxnForSetAttribute(nsIDOMElement *aElement, nsEditor::CreateTxnForSetAttribute(nsIDOMElement *aElement,
const nsString& aAttribute, const nsAReadableString& aAttribute,
const nsString& aValue, const nsAReadableString& aValue,
ChangeAttributeTxn ** aTxn) ChangeAttributeTxn ** aTxn)
{ {
nsresult result = NS_ERROR_NULL_POINTER; nsresult result = NS_ERROR_NULL_POINTER;
@ -4575,7 +4574,7 @@ nsEditor::CreateTxnForSetAttribute(nsIDOMElement *aElement,
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::CreateTxnForRemoveAttribute(nsIDOMElement *aElement, nsEditor::CreateTxnForRemoveAttribute(nsIDOMElement *aElement,
const nsString& aAttribute, const nsAReadableString& aAttribute,
ChangeAttributeTxn ** aTxn) ChangeAttributeTxn ** aTxn)
{ {
nsresult result = NS_ERROR_NULL_POINTER; nsresult result = NS_ERROR_NULL_POINTER;
@ -4592,7 +4591,7 @@ nsEditor::CreateTxnForRemoveAttribute(nsIDOMElement *aElement,
} }
NS_IMETHODIMP nsEditor::CreateTxnForCreateElement(const nsString& aTag, NS_IMETHODIMP nsEditor::CreateTxnForCreateElement(const nsAReadableString& aTag,
nsIDOMNode *aParent, nsIDOMNode *aParent,
PRInt32 aPosition, PRInt32 aPosition,
CreateElementTxn ** aTxn) CreateElementTxn ** aTxn)
@ -4680,7 +4679,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteElement(nsIDOMNode * aElement,
*/ */
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::CreateTxnForIMEText(const nsString & aStringToInsert, nsEditor::CreateTxnForIMEText(const nsAReadableString& aStringToInsert,
IMETextTxn ** aTxn) IMETextTxn ** aTxn)
{ {
NS_ASSERTION(aTxn, "illegal value- null ptr- aTxn"); NS_ASSERTION(aTxn, "illegal value- null ptr- aTxn");
@ -5085,7 +5084,7 @@ nsresult nsEditor::ClearSelection()
} }
nsresult nsresult
nsEditor::CreateHTMLContent(const nsString& aTag, nsIContent** aContent) nsEditor::CreateHTMLContent(const nsAReadableString& aTag, nsIContent** aContent)
{ {
nsresult rv; nsresult rv;

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

@ -122,123 +122,16 @@ public:
//NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor //NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
/* ------------ nsIEditor methods -------------- */ /* ------------ utility methods -------------- */
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, nsIContent *aRoot, nsISelectionController *aSelCon, PRUint32 aFlags);
NS_IMETHOD PostCreate();
NS_IMETHOD PreDestroy();
NS_IMETHOD GetFlags(PRUint32 *aFlags);
NS_IMETHOD SetFlags(PRUint32 aFlags);
NS_IMETHOD GetDocument(nsIDOMDocument **aDoc);
NS_IMETHOD GetRootElement(nsIDOMElement **aElement);
NS_IMETHOD GetPresShell(nsIPresShell **aPS); NS_IMETHOD GetPresShell(nsIPresShell **aPS);
NS_IMETHOD GetSelectionController(nsISelectionController **aSel); void NotifyEditorObservers(void);
NS_IMETHOD GetSelection(nsISelection **aSelection); /* ------------ nsIEditor methods -------------- */
NS_IMETHOD DeleteSelection(EDirection aAction); NS_DECL_NSIEDITOR
NS_IMETHOD EnableUndo(PRBool aEnable);
NS_IMETHOD GetTransactionManager(nsITransactionManager* *aTxnManager);
NS_IMETHOD Do(nsITransaction *aTxn);
NS_IMETHOD Undo(PRUint32 aCount);
NS_IMETHOD CanUndo(PRBool &aIsEnabled, PRBool &aCanUndo);
NS_IMETHOD Redo(PRUint32 aCount);
NS_IMETHOD CanRedo(PRBool &aIsEnabled, PRBool &aCanRedo);
NS_IMETHOD BeginTransaction();
NS_IMETHOD EndTransaction();
NS_IMETHOD BeginPlaceHolderTransaction(nsIAtom *aName);
NS_IMETHOD EndPlaceHolderTransaction();
NS_IMETHOD ShouldTxnSetSelection(PRBool *aResult);
NS_IMETHOD GetDocumentIsEmpty(PRBool *aDocumentIsEmpty);
// file handling
NS_IMETHOD GetDocumentModified(PRBool *outDocModified);
NS_IMETHOD GetDocumentCharacterSet(PRUnichar** characterSet);
NS_IMETHOD SetDocumentCharacterSet(const PRUnichar* characterSet);
NS_IMETHOD SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting, PRBool aSaveCopy, const nsString& aFormat);
NS_IMETHOD Cut();
NS_IMETHOD CanCut(PRBool &aCanCut);
NS_IMETHOD Copy();
NS_IMETHOD CanCopy(PRBool &aCanCopy);
NS_IMETHOD Paste(PRInt32 aSelectionType);
NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste);
NS_IMETHOD CanDrag(nsIDOMEvent *aEvent, PRBool &aCanDrag);
NS_IMETHOD DoDrag(nsIDOMEvent *aEvent);
NS_IMETHOD InsertFromDrop(nsIDOMEvent *aEvent);
NS_IMETHOD SelectAll();
NS_IMETHOD BeginningOfDocument();
NS_IMETHOD EndOfDocument();
/* Node and element manipulation */
NS_IMETHOD SetAttribute(nsIDOMElement * aElement,
const nsString& aAttribute,
const nsString& aValue);
NS_IMETHOD GetAttributeValue(nsIDOMElement * aElement,
const nsString& aAttribute,
nsString& aResultValue,
PRBool& aResultIsSet);
NS_IMETHOD RemoveAttribute(nsIDOMElement *aElement, const nsString& aAttribute);
NS_IMETHOD CreateNode(const nsString& aTag,
nsIDOMNode * aParent,
PRInt32 aPosition,
nsIDOMNode ** aNewNode);
NS_IMETHOD InsertNode(nsIDOMNode * aNode,
nsIDOMNode * aParent,
PRInt32 aPosition);
NS_IMETHOD SplitNode(nsIDOMNode * aExistingRightNode,
PRInt32 aOffset,
nsIDOMNode ** aNewLeftNode);
NS_IMETHOD JoinNodes(nsIDOMNode * aLeftNode,
nsIDOMNode * aRightNode,
nsIDOMNode * aParent);
NS_IMETHOD DeleteNode(nsIDOMNode * aChild);
NS_IMETHOD MarkNodeDirty(nsIDOMNode* aNode);
/* output */
NS_IMETHOD OutputToString(nsAWritableString& aOutputString,
const nsAReadableString& aFormatType,
PRUint32 aFlags);
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
const nsAReadableString& aFormatType,
const nsAReadableString* aCharsetOverride,
PRUint32 aFlags);
/* Listeners */
NS_IMETHOD AddEditorObserver(nsIEditorObserver *aObserver);
NS_IMETHOD RemoveEditorObserver(nsIEditorObserver *aObserver);
void NotifyEditorObservers(void);
NS_IMETHOD AddEditActionListener(nsIEditActionListener *aListener);
NS_IMETHOD RemoveEditActionListener(nsIEditActionListener *aListener);
NS_IMETHOD AddDocumentStateListener(nsIDocumentStateListener *aListener);
NS_IMETHOD RemoveDocumentStateListener(nsIDocumentStateListener *aListener);
NS_IMETHOD DumpContentTree();
NS_IMETHOD DebugDumpContent() const;
NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
/* ------------ nsIEditorIMESupport methods -------------- */ /* ------------ nsIEditorIMESupport methods -------------- */
NS_IMETHOD BeginComposition(nsTextEventReply* aReply); NS_IMETHOD BeginComposition(nsTextEventReply* aReply);
NS_IMETHOD QueryComposition(nsTextEventReply* aReply); NS_IMETHOD QueryComposition(nsTextEventReply* aReply);
NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply); NS_IMETHOD SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply);
NS_IMETHOD EndComposition(void); NS_IMETHOD EndComposition(void);
NS_IMETHOD ForceCompositionEnd(void); NS_IMETHOD ForceCompositionEnd(void);
NS_IMETHOD GetReconversionString(nsReconversionEventReply *aReply); NS_IMETHOD GetReconversionString(nsReconversionEventReply *aReply);
@ -246,31 +139,31 @@ public:
public: public:
NS_IMETHOD InsertTextImpl(const nsString& aStringToInsert, NS_IMETHOD InsertTextImpl(const nsAReadableString& aStringToInsert,
nsCOMPtr<nsIDOMNode> *aInOutNode, nsCOMPtr<nsIDOMNode> *aInOutNode,
PRInt32 *aInOutOffset, PRInt32 *aInOutOffset,
nsIDOMDocument *aDoc); nsIDOMDocument *aDoc);
NS_IMETHOD InsertTextIntoTextNodeImpl(const nsString& aStringToInsert, NS_IMETHOD InsertTextIntoTextNodeImpl(const nsAReadableString& aStringToInsert,
nsIDOMCharacterData *aTextNode, nsIDOMCharacterData *aTextNode,
PRInt32 aOffset); PRInt32 aOffset);
NS_IMETHOD DeleteSelectionImpl(EDirection aAction); NS_IMETHOD DeleteSelectionImpl(EDirection aAction);
NS_IMETHOD DeleteSelectionAndCreateNode(const nsString& aTag, NS_IMETHOD DeleteSelectionAndCreateNode(const nsAReadableString& aTag,
nsIDOMNode ** aNewNode); nsIDOMNode ** aNewNode);
/* helper routines for node/parent manipulations */ /* helper routines for node/parent manipulations */
nsresult ReplaceContainer(nsIDOMNode *inNode, nsresult ReplaceContainer(nsIDOMNode *inNode,
nsCOMPtr<nsIDOMNode> *outNode, nsCOMPtr<nsIDOMNode> *outNode,
const nsString &aNodeType, const nsAReadableString &aNodeType,
const nsString *aAttribute = nsnull, const nsAReadableString *aAttribute = nsnull,
const nsString *aValue = nsnull, const nsAReadableString *aValue = nsnull,
PRBool aCloneAttributes = PR_FALSE); PRBool aCloneAttributes = PR_FALSE);
nsresult RemoveContainer(nsIDOMNode *inNode); nsresult RemoveContainer(nsIDOMNode *inNode);
nsresult InsertContainerAbove(nsIDOMNode *inNode, nsresult InsertContainerAbove(nsIDOMNode *inNode,
nsCOMPtr<nsIDOMNode> *outNode, nsCOMPtr<nsIDOMNode> *outNode,
const nsString &aNodeType, const nsAReadableString &aNodeType,
const nsString *aAttribute = nsnull, const nsAReadableString *aAttribute = nsnull,
const nsString *aValue = nsnull); const nsAReadableString *aValue = nsnull);
nsresult MoveNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aOffset); nsresult MoveNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aOffset);
/* Method to replace certain CreateElementNS() calls. /* Method to replace certain CreateElementNS() calls.
@ -278,15 +171,10 @@ public:
nsString& aTag - tag you want nsString& aTag - tag you want
nsIContent** aContent - returned Content that was created with above namespace. nsIContent** aContent - returned Content that was created with above namespace.
*/ */
nsresult CreateHTMLContent(const nsString& aTag, nsIContent** aContent); nsresult CreateHTMLContent(const nsAReadableString& aTag, nsIContent** aContent);
protected: protected:
//NOTE: Most callers are dealing with Nodes,
// but these objects must supports nsIDOMElement
NS_IMETHOD CloneAttributes(nsIDOMNode *aDestNode, nsIDOMNode *aSourceNode);
/* /*
NS_IMETHOD SetProperties(nsVoidArray *aPropList); NS_IMETHOD SetProperties(nsVoidArray *aPropList);
NS_IMETHOD GetProperties(nsVoidArray *aPropList); NS_IMETHOD GetProperties(nsVoidArray *aPropList);
@ -295,19 +183,19 @@ protected:
/** create a transaction for setting aAttribute to aValue on aElement /** create a transaction for setting aAttribute to aValue on aElement
*/ */
NS_IMETHOD CreateTxnForSetAttribute(nsIDOMElement *aElement, NS_IMETHOD CreateTxnForSetAttribute(nsIDOMElement *aElement,
const nsString& aAttribute, const nsAReadableString & aAttribute,
const nsString& aValue, const nsAReadableString & aValue,
ChangeAttributeTxn ** aTxn); ChangeAttributeTxn ** aTxn);
/** create a transaction for removing aAttribute on aElement /** create a transaction for removing aAttribute on aElement
*/ */
NS_IMETHOD CreateTxnForRemoveAttribute(nsIDOMElement *aElement, NS_IMETHOD CreateTxnForRemoveAttribute(nsIDOMElement *aElement,
const nsString& aAttribute, const nsAReadableString & aAttribute,
ChangeAttributeTxn ** aTxn); ChangeAttributeTxn ** aTxn);
/** create a transaction for creating a new child node of aParent of type aTag. /** create a transaction for creating a new child node of aParent of type aTag.
*/ */
NS_IMETHOD CreateTxnForCreateElement(const nsString& aTag, NS_IMETHOD CreateTxnForCreateElement(const nsAReadableString & aTag,
nsIDOMNode *aParent, nsIDOMNode *aParent,
PRInt32 aPosition, PRInt32 aPosition,
CreateElementTxn ** aTxn); CreateElementTxn ** aTxn);
@ -336,12 +224,12 @@ protected:
/** create a transaction for inserting aStringToInsert into aTextNode /** create a transaction for inserting aStringToInsert into aTextNode
* if aTextNode is null, the string is inserted at the current selection. * if aTextNode is null, the string is inserted at the current selection.
*/ */
NS_IMETHOD CreateTxnForInsertText(const nsString & aStringToInsert, NS_IMETHOD CreateTxnForInsertText(const nsAReadableString & aStringToInsert,
nsIDOMCharacterData *aTextNode, nsIDOMCharacterData *aTextNode,
PRInt32 aOffset, PRInt32 aOffset,
InsertTextTxn ** aTxn); InsertTextTxn ** aTxn);
NS_IMETHOD CreateTxnForIMEText(const nsString & aStringToInsert, NS_IMETHOD CreateTxnForIMEText(const nsAReadableString & aStringToInsert,
IMETextTxn ** aTxn); IMETextTxn ** aTxn);
/** create a transaction for adding a style sheet /** create a transaction for adding a style sheet
@ -436,7 +324,7 @@ public:
/** return the string that represents text nodes in the content tree */ /** return the string that represents text nodes in the content tree */
static nsresult GetTextNodeTag(nsString& aOutString); static nsresult GetTextNodeTag(nsAWritableString& aOutString);
/** /**
* SplitNode() creates a new node identical to an existing node, and split the contents between the two nodes * SplitNode() creates a new node identical to an existing node, and split the contents between the two nodes
@ -550,17 +438,17 @@ public:
* @param aResult is the node we found, or nsnull if there is none * @param aResult is the node we found, or nsnull if there is none
*/ */
static nsresult GetFirstNodeOfType(nsIDOMNode *aStartNode, static nsresult GetFirstNodeOfType(nsIDOMNode *aStartNode,
const nsString &aTag, const nsAReadableString &aTag,
nsIDOMNode **aResult); nsIDOMNode **aResult);
/** returns PR_TRUE if aNode is of the type implied by aTag */ /** returns PR_TRUE if aNode is of the type implied by aTag */
static PRBool NodeIsType(nsIDOMNode *aNode, nsIAtom *aTag); static PRBool NodeIsType(nsIDOMNode *aNode, nsIAtom *aTag);
static PRBool NodeIsType(nsIDOMNode *aNode, const nsString &aTag); static PRBool NodeIsType(nsIDOMNode *aNode, const nsAReadableString &aTag);
/** returns PR_TRUE if aParent can contain a child of type aTag */ /** returns PR_TRUE if aParent can contain a child of type aTag */
PRBool CanContainTag(nsIDOMNode* aParent, const nsString &aTag); PRBool CanContainTag(nsIDOMNode* aParent, const nsAReadableString &aTag);
PRBool TagCanContain(const nsString &aParentTag, nsIDOMNode* aChild); PRBool TagCanContain(const nsAReadableString &aParentTag, nsIDOMNode* aChild);
virtual PRBool TagCanContainTag(const nsString &aParentTag, const nsString &aChildTag); virtual PRBool TagCanContainTag(const nsAReadableString &aParentTag, const nsAReadableString &aChildTag);
/** returns PR_TRUE if aNode is a descendant of our root node */ /** returns PR_TRUE if aNode is a descendant of our root node */
PRBool IsDescendantOfBody(nsIDOMNode *inNode); PRBool IsDescendantOfBody(nsIDOMNode *inNode);
@ -586,7 +474,7 @@ public:
/** from html rules code - migration in progress */ /** from html rules code - migration in progress */
static nsresult GetTagString(nsIDOMNode *aNode, nsString& outString); static nsresult GetTagString(nsIDOMNode *aNode, nsAWritableString& outString);
static nsCOMPtr<nsIAtom> GetTag(nsIDOMNode *aNode); static nsCOMPtr<nsIAtom> GetTag(nsIDOMNode *aNode);
static PRBool NodesSameType(nsIDOMNode *aNode1, nsIDOMNode *aNode2); static PRBool NodesSameType(nsIDOMNode *aNode1, nsIDOMNode *aNode2);
static PRBool IsTextOrElementNode(nsIDOMNode *aNode); static PRBool IsTextOrElementNode(nsIDOMNode *aNode);
@ -622,7 +510,7 @@ public:
nsCOMPtr<nsIDOMNode> *outRightNode = 0); nsCOMPtr<nsIDOMNode> *outRightNode = 0);
nsresult JoinNodeDeep(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsCOMPtr<nsIDOMNode> *aOutJoinNode, PRInt32 *outOffset); nsresult JoinNodeDeep(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsCOMPtr<nsIDOMNode> *aOutJoinNode, PRInt32 *outOffset);
nsresult GetString(const nsString& name, nsString& value); nsresult GetString(const nsAReadableString& name, nsAWritableString& value);
nsresult BeginUpdateViewBatch(void); nsresult BeginUpdateViewBatch(void);
nsresult EndUpdateViewBatch(void); nsresult EndUpdateViewBatch(void);

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

@ -53,7 +53,7 @@ nsUndoCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISuppo
if (aEditor) if (aEditor)
{ {
PRBool isEnabled; PRBool isEnabled;
return aEditor->CanUndo(isEnabled, *outCmdEnabled); return aEditor->CanUndo(&isEnabled, outCmdEnabled);
} }
return NS_OK; return NS_OK;
} }
@ -78,7 +78,7 @@ nsRedoCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISuppo
if (aEditor) if (aEditor)
{ {
PRBool isEnabled; PRBool isEnabled;
return aEditor->CanRedo(isEnabled, *outCmdEnabled); return aEditor->CanRedo(&isEnabled, outCmdEnabled);
} }
return NS_OK; return NS_OK;
} }
@ -101,7 +101,7 @@ nsCutCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISuppor
nsCOMPtr<nsIEditor> aEditor = do_QueryInterface(aCommandRefCon); nsCOMPtr<nsIEditor> aEditor = do_QueryInterface(aCommandRefCon);
*outCmdEnabled = PR_FALSE; *outCmdEnabled = PR_FALSE;
if (aEditor) if (aEditor)
return aEditor->CanCut(*outCmdEnabled); return aEditor->CanCut(outCmdEnabled);
return NS_OK; return NS_OK;
} }
@ -155,7 +155,7 @@ nsCopyCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISuppo
nsCOMPtr<nsIEditor> aEditor = do_QueryInterface(aCommandRefCon); nsCOMPtr<nsIEditor> aEditor = do_QueryInterface(aCommandRefCon);
*outCmdEnabled = PR_FALSE; *outCmdEnabled = PR_FALSE;
if (aEditor) if (aEditor)
return aEditor->CanCopy(*outCmdEnabled); return aEditor->CanCopy(outCmdEnabled);
return NS_OK; return NS_OK;
} }
@ -209,7 +209,7 @@ nsPasteCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupp
nsCOMPtr<nsIEditor> aEditor = do_QueryInterface(aCommandRefCon); nsCOMPtr<nsIEditor> aEditor = do_QueryInterface(aCommandRefCon);
*outCmdEnabled = PR_FALSE; *outCmdEnabled = PR_FALSE;
if (aEditor) if (aEditor)
return aEditor->CanPaste(nsIClipboard::kGlobalClipboard, *outCmdEnabled); return aEditor->CanPaste(nsIClipboard::kGlobalClipboard, outCmdEnabled);
return NS_OK; return NS_OK;
} }
@ -250,7 +250,7 @@ nsDeleteCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISup
nsAutoString cmdString(aCommandName); nsAutoString cmdString(aCommandName);
if (cmdString.EqualsWithConversion("cmd_delete")) if (cmdString.EqualsWithConversion("cmd_delete"))
rv = aEditor->CanCut(*outCmdEnabled); rv = aEditor->CanCut(outCmdEnabled);
else if (cmdString.EqualsWithConversion("cmd_deleteCharBackward")) else if (cmdString.EqualsWithConversion("cmd_deleteCharBackward"))
*outCmdEnabled = PR_TRUE; *outCmdEnabled = PR_TRUE;
else if (cmdString.EqualsWithConversion("cmd_deleteCharForward")) else if (cmdString.EqualsWithConversion("cmd_deleteCharForward"))

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

@ -615,7 +615,7 @@ nsTextEditorDragListener::DragGesture(nsIDOMEvent* aDragEvent)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
// ...figure out if a drag should be started... // ...figure out if a drag should be started...
nsresult rv = mEditor->CanDrag(aDragEvent, canDrag); nsresult rv = mEditor->CanDrag(aDragEvent, &canDrag);
if ( NS_SUCCEEDED(rv) && canDrag ) if ( NS_SUCCEEDED(rv) && canDrag )
rv = mEditor->DoDrag(aDragEvent); rv = mEditor->DoDrag(aDragEvent);

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

@ -1061,9 +1061,7 @@ nsEditorShell::SetAttribute(nsIDOMElement *element, const PRUnichar *attr, const
nsresult result = NS_NOINTERFACE; nsresult result = NS_NOINTERFACE;
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor); nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
if (editor) { if (editor) {
nsAutoString attributeStr(attr); result = editor->SetAttribute(element, nsLiteralString(attr), nsLiteralString(value));
nsAutoString valueStr(value);
result = editor->SetAttribute(element, attributeStr, valueStr);
} }
return result; return result;
@ -1078,8 +1076,7 @@ nsEditorShell::RemoveAttribute(nsIDOMElement *element, const PRUnichar *attr)
nsresult result = NS_NOINTERFACE; nsresult result = NS_NOINTERFACE;
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor); nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
if (editor) { if (editor) {
nsAutoString attributeStr(attr); result = editor->RemoveAttribute(element, nsLiteralString(attr));
result = editor->RemoveAttribute(element, attributeStr);
} }
return result; return result;
@ -1094,16 +1091,13 @@ nsEditorShell::SetTextProperty(const PRUnichar *prop, const PRUnichar *attr, con
nsCOMPtr<nsIAtom> styleAtom = getter_AddRefs(NS_NewAtom(prop)); /// XXX Hack alert! Look in nsIEditProperty.h for this nsCOMPtr<nsIAtom> styleAtom = getter_AddRefs(NS_NewAtom(prop)); /// XXX Hack alert! Look in nsIEditProperty.h for this
if (! styleAtom) return NS_ERROR_OUT_OF_MEMORY; if (! styleAtom) return NS_ERROR_OUT_OF_MEMORY;
nsAutoString attributeStr(attr);
nsAutoString valueStr(value);
switch (mEditorType) switch (mEditorType)
{ {
case ePlainTextEditorType: case ePlainTextEditorType:
// should we allow this? // should we allow this?
case eHTMLTextEditorType: case eHTMLTextEditorType:
err = mEditor->SetInlineProperty(styleAtom, &attributeStr, &valueStr); err = mEditor->SetInlineProperty(styleAtom, nsLiteralString(attr), nsLiteralString(value));
break; break;
default: default:
err = NS_ERROR_NOT_IMPLEMENTED; err = NS_ERROR_NOT_IMPLEMENTED;
@ -1127,7 +1121,7 @@ nsEditorShell::RemoveOneProperty(const nsString& aProp, const nsString &aAttr)
case ePlainTextEditorType: case ePlainTextEditorType:
// should we allow this? // should we allow this?
case eHTMLTextEditorType: case eHTMLTextEditorType:
err = mEditor->RemoveInlineProperty(styleAtom, &aAttr); err = mEditor->RemoveInlineProperty(styleAtom, aAttr);
break; break;
default: default:
err = NS_ERROR_NOT_IMPLEMENTED; err = NS_ERROR_NOT_IMPLEMENTED;
@ -1172,15 +1166,12 @@ nsEditorShell::GetTextProperty(const PRUnichar *prop, const PRUnichar *attr, con
styleAtom = NS_NewAtom(prop); /// XXX Hack alert! Look in nsIEditProperty.h for this styleAtom = NS_NewAtom(prop); /// XXX Hack alert! Look in nsIEditProperty.h for this
nsAutoString aAttr(attr);
nsAutoString aValue(value);
switch (mEditorType) switch (mEditorType)
{ {
case ePlainTextEditorType: case ePlainTextEditorType:
// should we allow this? // should we allow this?
case eHTMLTextEditorType: case eHTMLTextEditorType:
err = mEditor->GetInlineProperty(styleAtom, &aAttr, &aValue, *firstHas, *anyHas, *allHas); err = mEditor->GetInlineProperty(styleAtom, nsLiteralString(attr), nsLiteralString(value), firstHas, anyHas, allHas);
break; break;
default: default:
err = NS_ERROR_NOT_IMPLEMENTED; err = NS_ERROR_NOT_IMPLEMENTED;
@ -1238,7 +1229,7 @@ nsEditorShell::GetParagraphState(PRBool *aMixed, PRUnichar **_retval)
{ {
PRBool bMixed; PRBool bMixed;
nsAutoString state; nsAutoString state;
err = htmlEditor->GetParagraphState(bMixed, state); err = htmlEditor->GetParagraphState(&bMixed, state);
if (!bMixed) if (!bMixed)
*_retval = state.ToNewUnicode(); *_retval = state.ToNewUnicode();
} }
@ -1257,7 +1248,7 @@ nsEditorShell::GetListState(PRBool *aMixed, PRUnichar **_retval)
if (htmlEditor) if (htmlEditor)
{ {
PRBool bOL, bUL, bDL; PRBool bOL, bUL, bDL;
err = htmlEditor->GetListState(*aMixed, bOL, bUL, bDL); err = htmlEditor->GetListState(aMixed, &bOL, &bUL, &bDL);
if (NS_SUCCEEDED(err)) if (NS_SUCCEEDED(err))
{ {
if (!*aMixed) if (!*aMixed)
@ -1285,7 +1276,7 @@ nsEditorShell::GetListItemState(PRBool *aMixed, PRUnichar **_retval)
if (htmlEditor) if (htmlEditor)
{ {
PRBool bLI,bDT,bDD; PRBool bLI,bDT,bDD;
err = htmlEditor->GetListItemState(*aMixed, bLI, bDT, bDD); err = htmlEditor->GetListItemState(aMixed, &bLI, &bDT, &bDD);
if (NS_SUCCEEDED(err)) if (NS_SUCCEEDED(err))
{ {
if (!*aMixed) if (!*aMixed)
@ -1313,7 +1304,7 @@ nsEditorShell::GetAlignment(PRBool *aMixed, PRUnichar **_retval)
if (htmlEditor) if (htmlEditor)
{ {
nsIHTMLEditor::EAlignment firstAlign; nsIHTMLEditor::EAlignment firstAlign;
err = htmlEditor->GetAlignment(*aMixed, firstAlign); err = htmlEditor->GetAlignment(aMixed, &firstAlign);
if (NS_SUCCEEDED(err)) if (NS_SUCCEEDED(err))
{ {
nsAutoString tagStr; nsAutoString tagStr;
@ -1777,7 +1768,7 @@ nsEditorShell::SaveDocument(PRBool aSaveAs, PRBool aSaveCopy, const PRUnichar* a
return NS_OK; return NS_OK;
} }
// This sets title in HTML node // This sets title in HTML node
mEditor->SetDocumentTitle(titleUnicode); mEditor->SetDocumentTitle(nsLiteralString(titleUnicode));
title = titleUnicode; title = titleUnicode;
nsCRT::free(titleUnicode); nsCRT::free(titleUnicode);
titleChanged = PR_TRUE; titleChanged = PR_TRUE;
@ -2240,7 +2231,7 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title)
if (mEditorType != eHTMLTextEditorType) if (mEditorType != eHTMLTextEditorType)
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
res = mEditor->SetDocumentTitle(title); res = mEditor->SetDocumentTitle(nsLiteralString(title));
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
// PR_FALSE means don't save menu to prefs // PR_FALSE means don't save menu to prefs
@ -2283,7 +2274,7 @@ nsEditorShell::NodeIsBlock(nsIDOMNode *node, PRBool *_retval)
case ePlainTextEditorType: case ePlainTextEditorType:
case eHTMLTextEditorType: case eHTMLTextEditorType:
{ {
rv = mEditor->NodeIsBlock(node, *_retval); rv = mEditor->NodeIsBlock(node, _retval);
} }
break; break;
@ -2610,7 +2601,7 @@ nsEditorShell::InsertText(const PRUnichar *textToInsert)
{ {
nsCOMPtr<nsIPlaintextEditor> textEditor (do_QueryInterface(mEditor)); nsCOMPtr<nsIPlaintextEditor> textEditor (do_QueryInterface(mEditor));
if (textEditor) if (textEditor)
err = textEditor->InsertText(textToInsert); err = textEditor->InsertText(nsLiteralString(textToInsert));
} }
break; break;
@ -2953,11 +2944,19 @@ nsEditorShell::Alert(const nsString& aTitle, const nsString& aMsg)
NS_IMETHODIMP NS_IMETHODIMP
nsEditorShell::GetDocumentCharacterSet(PRUnichar** characterSet) nsEditorShell::GetDocumentCharacterSet(PRUnichar** characterSet)
{ {
if (!characterSet)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor); nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
nsAutoString copiedData;
*characterSet = nsnull;
if (editor) if (editor)
return editor->GetDocumentCharacterSet(characterSet); {
if (NS_SUCCEEDED(editor->GetDocumentCharacterSet(copiedData)))
{
*characterSet = ToNewUnicode(copiedData);
return NS_OK;
}
}
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -2968,7 +2967,7 @@ nsEditorShell::SetDocumentCharacterSet(const PRUnichar* characterSet)
nsresult res = NS_OK; nsresult res = NS_OK;
if (editor) if (editor)
res = editor->SetDocumentCharacterSet(characterSet); res = editor->SetDocumentCharacterSet(nsAutoString(characterSet));
if(NS_SUCCEEDED(res)) { if(NS_SUCCEEDED(res)) {
nsCOMPtr<nsIScriptGlobalObject> globalObj( do_QueryReferent(mContentWindow)); nsCOMPtr<nsIScriptGlobalObject> globalObj( do_QueryReferent(mContentWindow));

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

@ -160,29 +160,29 @@ static nsCOMPtr<nsIDOMNode> GetTableParent(nsIDOMNode* aNode)
} }
NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString) NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsAReadableString & aInString)
{ {
nsAutoString charset; nsAutoString charset;
return InsertHTMLWithCharset(aInputString, charset); return InsertHTMLWithCharset(aInString, charset);
} }
nsresult nsHTMLEditor::InsertHTMLWithContext(const nsString& aInputString, const nsString& aContextStr, const nsString& aInfoStr) nsresult nsHTMLEditor::InsertHTMLWithContext(const nsAReadableString & aInputString, const nsAReadableString & aContextStr, const nsAReadableString & aInfoStr)
{ {
nsAutoString charset; nsAutoString charset;
return InsertHTMLWithCharsetAndContext(aInputString, charset, aContextStr, aInfoStr); return InsertHTMLWithCharsetAndContext(aInputString, charset, aContextStr, aInfoStr);
} }
NS_IMETHODIMP nsHTMLEditor::InsertHTMLWithCharset(const nsString& aInputString, const nsString& aCharset) NS_IMETHODIMP nsHTMLEditor::InsertHTMLWithCharset(const nsAReadableString & aInputString, const nsAReadableString & aCharset)
{ {
return InsertHTMLWithCharsetAndContext(aInputString, aCharset, nsAutoString(), nsAutoString()); return InsertHTMLWithCharsetAndContext(aInputString, aCharset, nsAutoString(), nsAutoString());
} }
nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsString& aInputString, nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsAReadableString & aInputString,
const nsString& aCharset, const nsAReadableString & aCharset,
const nsString& aContextStr, const nsAReadableString & aContextStr,
const nsString& aInfoStr) const nsAReadableString & aInfoStr)
{ {
if (!mRules) return NS_ERROR_NOT_INITIALIZED; if (!mRules) return NS_ERROR_NOT_INITIALIZED;
@ -604,8 +604,8 @@ NS_IMETHODIMP nsHTMLEditor::PrepareTransferable(nsITransferable **transferable)
} }
NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable, NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable,
const nsString& aContextStr, const nsAReadableString & aContextStr,
const nsString& aInfoStr) const nsAReadableString & aInfoStr)
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
char* bestFlavor = nsnull; char* bestFlavor = nsnull;
@ -645,7 +645,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
// pasting does not inherit local inline styles // pasting does not inherit local inline styles
RemoveAllInlineProperties(); RemoveAllInlineProperties();
rv = InsertText(stuffToPaste.GetUnicode()); rv = InsertText(stuffToPaste);
if (text) if (text)
nsMemory::Free(text); nsMemory::Free(text);
} }
@ -906,12 +906,15 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
return rv; return rv;
} }
NS_IMETHODIMP nsHTMLEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag) NS_IMETHODIMP nsHTMLEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag)
{ {
if (!aCanDrag)
return NS_ERROR_NULL_POINTER;
/* we really should be checking the XY coordinates of the mouseevent and ensure that /* we really should be checking the XY coordinates of the mouseevent and ensure that
* that particular point is actually within the selection (not just that there is a selection) * that particular point is actually within the selection (not just that there is a selection)
*/ */
aCanDrag = PR_FALSE; *aCanDrag = PR_FALSE;
// KLUDGE to work around bug 50703 // KLUDGE to work around bug 50703
// After double click and object property editing, // After double click and object property editing,
@ -949,7 +952,7 @@ NS_IMETHODIMP nsHTMLEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag)
res = selection->ContainsNode(eventTargetDomNode, PR_FALSE, &amTargettedCorrectly); res = selection->ContainsNode(eventTargetDomNode, PR_FALSE, &amTargettedCorrectly);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
aCanDrag = amTargettedCorrectly; *aCanDrag = amTargettedCorrectly;
} }
} }
@ -1123,9 +1126,11 @@ NS_IMETHODIMP nsHTMLEditor::Paste(PRInt32 aSelectionType)
} }
NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste) NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste)
{ {
aCanPaste = PR_FALSE; if (!aCanPaste)
return NS_ERROR_NULL_POINTER;
*aCanPaste = PR_FALSE;
// can't paste if readonly // can't paste if readonly
if (!IsModifiable()) if (!IsModifiable())
@ -1180,7 +1185,7 @@ NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste)
rv = clipboard->HasDataMatchingFlavors(flavorsList, aSelectionType, &haveFlavors); rv = clipboard->HasDataMatchingFlavors(flavorsList, aSelectionType, &haveFlavors);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
aCanPaste = haveFlavors; *aCanPaste = haveFlavors;
return NS_OK; return NS_OK;
} }
@ -1197,7 +1202,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsQuotation(PRInt32 aSelectionType)
return PasteAsCitedQuotation(citation, aSelectionType); return PasteAsCitedQuotation(citation, aSelectionType);
} }
NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsString& aCitation, NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsAReadableString & aCitation,
PRInt32 aSelectionType) PRInt32 aSelectionType)
{ {
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
@ -1310,7 +1315,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlaintextQuotation(PRInt32 aSelectionType)
return rv; return rv;
} }
NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsString& aQuotedText, NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsAReadableString & aQuotedText,
nsIDOMNode **aNodeInserted) nsIDOMNode **aNodeInserted)
{ {
if (mFlags & eEditorPlaintextMask) if (mFlags & eEditorPlaintextMask)
@ -1327,7 +1332,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsString& aQuotedText,
// in that here, quoted material is enclosed in a <pre> tag // in that here, quoted material is enclosed in a <pre> tag
// in order to preserve the original line wrapping. // in order to preserve the original line wrapping.
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText, nsHTMLEditor::InsertAsPlaintextQuotation(const nsAReadableString & aQuotedText,
nsIDOMNode **aNodeInserted) nsIDOMNode **aNodeInserted)
{ {
nsresult rv; nsresult rv;
@ -1399,10 +1404,10 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText, nsHTMLEditor::InsertAsCitedQuotation(const nsAReadableString & aQuotedText,
const nsString& aCitation, const nsAReadableString & aCitation,
PRBool aInsertHTML, PRBool aInsertHTML,
const nsString& aCharset, const nsAReadableString & aCharset,
nsIDOMNode **aNodeInserted) nsIDOMNode **aNodeInserted)
{ {
nsCOMPtr<nsIDOMNode> newNode; nsCOMPtr<nsIDOMNode> newNode;
@ -1450,7 +1455,7 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
res = InsertHTMLWithCharset(aQuotedText, aCharset); res = InsertHTMLWithCharset(aQuotedText, aCharset);
else else
res = InsertText(aQuotedText.GetUnicode()); // XXX ignore charset res = InsertText(aQuotedText); // XXX ignore charset
if (aNodeInserted) if (aNodeInserted)
{ {
@ -1475,9 +1480,9 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
} }
nsresult nsHTMLEditor::CreateDOMFragmentFromPaste(nsIDOMNSRange *aNSRange, nsresult nsHTMLEditor::CreateDOMFragmentFromPaste(nsIDOMNSRange *aNSRange,
const nsString& aInputString, const nsAReadableString & aInputString,
const nsString& aContextStr, const nsAReadableString & aContextStr,
const nsString& aInfoStr, const nsAReadableString & aInfoStr,
nsCOMPtr<nsIDOMNode> *outFragNode, nsCOMPtr<nsIDOMNode> *outFragNode,
PRInt32 *outRangeStartHint, PRInt32 *outRangeStartHint,
PRInt32 *outRangeEndHint) PRInt32 *outRangeEndHint)

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

@ -59,6 +59,8 @@
#include "InsertTextTxn.h" #include "InsertTextTxn.h"
#include "DeleteTextTxn.h" #include "DeleteTextTxn.h"
#include "nsReadableUtils.h"
//const static char* kMOZEditorBogusNodeAttr="MOZ_EDITOR_BOGUS_NODE"; //const static char* kMOZEditorBogusNodeAttr="MOZ_EDITOR_BOGUS_NODE";
//const static char* kMOZEditorBogusNodeValue="TRUE"; //const static char* kMOZEditorBogusNodeValue="TRUE";
@ -83,7 +85,7 @@ enum
static PRBool IsBlockNode(nsIDOMNode* node) static PRBool IsBlockNode(nsIDOMNode* node)
{ {
PRBool isBlock (PR_FALSE); PRBool isBlock (PR_FALSE);
nsHTMLEditor::NodeIsBlockStatic(node, isBlock); nsHTMLEditor::NodeIsBlockStatic(node, &isBlock);
return isBlock; return isBlock;
} }
@ -500,12 +502,14 @@ nsHTMLEditRules::DidDoAction(nsISelection *aSelection,
********************************************************/ ********************************************************/
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditRules::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL) nsHTMLEditRules::GetListState(PRBool *aMixed, PRBool *aOL, PRBool *aUL, PRBool *aDL)
{ {
aMixed = PR_FALSE; if (!aMixed || !aOL || !aUL || !aDL)
aOL = PR_FALSE; return NS_ERROR_NULL_POINTER;
aUL = PR_FALSE; *aMixed = PR_FALSE;
aDL = PR_FALSE; *aOL = PR_FALSE;
*aUL = PR_FALSE;
*aDL = PR_FALSE;
PRBool bNonList = PR_FALSE; PRBool bNonList = PR_FALSE;
nsCOMPtr<nsISupportsArray> arrayOfNodes; nsCOMPtr<nsISupportsArray> arrayOfNodes;
@ -522,9 +526,9 @@ nsHTMLEditRules::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &
nsCOMPtr<nsIDOMNode> curNode( do_QueryInterface(isupports) ); nsCOMPtr<nsIDOMNode> curNode( do_QueryInterface(isupports) );
if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::ul)) if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::ul))
aUL = PR_TRUE; *aUL = PR_TRUE;
else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::ol)) else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::ol))
aOL = PR_TRUE; *aOL = PR_TRUE;
else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::li)) else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::li))
{ {
nsCOMPtr<nsIDOMNode> parent; nsCOMPtr<nsIDOMNode> parent;
@ -532,32 +536,34 @@ nsHTMLEditRules::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &
res = nsEditor::GetNodeLocation(curNode, address_of(parent), &offset); res = nsEditor::GetNodeLocation(curNode, address_of(parent), &offset);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
if (nsHTMLEditUtils::IsUnorderedList(parent)) if (nsHTMLEditUtils::IsUnorderedList(parent))
aUL = PR_TRUE; *aUL = PR_TRUE;
else if (nsHTMLEditUtils::IsOrderedList(parent)) else if (nsHTMLEditUtils::IsOrderedList(parent))
aOL = PR_TRUE; *aOL = PR_TRUE;
} }
else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dl) || else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dl) ||
mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dt) || mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dt) ||
mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dd) ) mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dd) )
{ {
aDL = PR_TRUE; *aDL = PR_TRUE;
} }
else bNonList = PR_TRUE; else bNonList = PR_TRUE;
} }
// hokey arithmetic with booleans // hokey arithmetic with booleans
if ( (aUL + aOL + aDL + bNonList) > 1) aMixed = PR_TRUE; if ( (*aUL + *aOL + *aDL + bNonList) > 1) *aMixed = PR_TRUE;
return res; return res;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditRules::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD) nsHTMLEditRules::GetListItemState(PRBool *aMixed, PRBool *aLI, PRBool *aDT, PRBool *aDD)
{ {
aMixed = PR_FALSE; if (!aMixed || !aLI || !aDT || !aDD)
aLI = PR_FALSE; return NS_ERROR_NULL_POINTER;
aDT = PR_FALSE; *aMixed = PR_FALSE;
aDD = PR_FALSE; *aLI = PR_FALSE;
*aDT = PR_FALSE;
*aDD = PR_FALSE;
PRBool bNonList = PR_FALSE; PRBool bNonList = PR_FALSE;
nsCOMPtr<nsISupportsArray> arrayOfNodes; nsCOMPtr<nsISupportsArray> arrayOfNodes;
@ -577,15 +583,15 @@ nsHTMLEditRules::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBo
mHTMLEditor->NodeIsType(curNode,nsIEditProperty::ol) || mHTMLEditor->NodeIsType(curNode,nsIEditProperty::ol) ||
mHTMLEditor->NodeIsType(curNode,nsIEditProperty::li) ) mHTMLEditor->NodeIsType(curNode,nsIEditProperty::li) )
{ {
aLI = PR_TRUE; *aLI = PR_TRUE;
} }
else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dt)) else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dt))
{ {
aDT = PR_TRUE; *aDT = PR_TRUE;
} }
else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dd)) else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dd))
{ {
aDD = PR_TRUE; *aDD = PR_TRUE;
} }
else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dl)) else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dl))
{ {
@ -593,20 +599,20 @@ nsHTMLEditRules::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBo
PRBool bDT, bDD; PRBool bDT, bDD;
res = GetDefinitionListItemTypes(curNode, bDT, bDD); res = GetDefinitionListItemTypes(curNode, bDT, bDD);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
aDT |= bDT; *aDT |= bDT;
aDD |= bDD; *aDD |= bDD;
} }
else bNonList = PR_TRUE; else bNonList = PR_TRUE;
} }
// hokey arithmetic with booleans // hokey arithmetic with booleans
if ( (aDT + aDD + bNonList) > 1) aMixed = PR_TRUE; if ( (*aDT + *aDD + bNonList) > 1) *aMixed = PR_TRUE;
return res; return res;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign) nsHTMLEditRules::GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
{ {
// for now, just return first alignment. we'll lie about // for now, just return first alignment. we'll lie about
// if it's mixed. This is for efficiency // if it's mixed. This is for efficiency
@ -617,8 +623,10 @@ nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
// this routine assumes that alignment is done ONLY via divs // this routine assumes that alignment is done ONLY via divs
// default alignment is left // default alignment is left
aMixed = PR_FALSE; if (!aMixed || !aAlign)
aAlign = nsIHTMLEditor::eLeft; return NS_ERROR_NULL_POINTER;
*aMixed = PR_FALSE;
*aAlign = nsIHTMLEditor::eLeft;
// get selection // get selection
nsCOMPtr<nsISelection>selection; nsCOMPtr<nsISelection>selection;
@ -673,13 +681,13 @@ nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
if (NS_SUCCEEDED(res) && typeAttrVal.Length()) if (NS_SUCCEEDED(res) && typeAttrVal.Length())
{ {
if (typeAttrVal.EqualsWithConversion("center")) if (typeAttrVal.EqualsWithConversion("center"))
aAlign = nsIHTMLEditor::eCenter; *aAlign = nsIHTMLEditor::eCenter;
else if (typeAttrVal.EqualsWithConversion("right")) else if (typeAttrVal.EqualsWithConversion("right"))
aAlign = nsIHTMLEditor::eRight; *aAlign = nsIHTMLEditor::eRight;
else if (typeAttrVal.EqualsWithConversion("justify")) else if (typeAttrVal.EqualsWithConversion("justify"))
aAlign = nsIHTMLEditor::eJustify; *aAlign = nsIHTMLEditor::eJustify;
else else
aAlign = nsIHTMLEditor::eLeft; *aAlign = nsIHTMLEditor::eLeft;
return res; return res;
} }
} }
@ -692,10 +700,12 @@ nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditRules::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent) nsHTMLEditRules::GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent)
{ {
aCanIndent = PR_TRUE; if (!aCanIndent || !aCanOutdent)
aCanOutdent = PR_FALSE; return NS_ERROR_FAILURE;
*aCanIndent = PR_TRUE;
*aCanOutdent = PR_FALSE;
nsCOMPtr<nsISupportsArray> arrayOfNodes; nsCOMPtr<nsISupportsArray> arrayOfNodes;
nsresult res = GetListActionNodes(address_of(arrayOfNodes), PR_FALSE, PR_TRUE); nsresult res = GetListActionNodes(address_of(arrayOfNodes), PR_FALSE, PR_TRUE);
@ -716,7 +726,7 @@ nsHTMLEditRules::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
nsHTMLEditUtils::IsListItem(curNode) || nsHTMLEditUtils::IsListItem(curNode) ||
nsHTMLEditUtils::IsBlockquote(curNode)) nsHTMLEditUtils::IsBlockquote(curNode))
{ {
aCanOutdent = PR_TRUE; *aCanOutdent = PR_TRUE;
break; break;
} }
} }
@ -726,17 +736,19 @@ nsHTMLEditRules::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditRules::GetParagraphState(PRBool &aMixed, nsString &outFormat) nsHTMLEditRules::GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat)
{ {
// This routine is *heavily* tied to our ui choices in the paragraph // This routine is *heavily* tied to our ui choices in the paragraph
// style popup. I cant see a way around that. // style popup. I cant see a way around that.
aMixed = PR_TRUE; if (!aMixed)
outFormat.AssignWithConversion(""); return NS_ERROR_NULL_POINTER;
*aMixed = PR_TRUE;
outFormat.Truncate(0);
PRBool bMixed = PR_FALSE; PRBool bMixed = PR_FALSE;
nsAutoString formatStr; nsAutoString formatStr;
// using "x" as an uninitialized value, since "" is meaningful // using "x" as an uninitialized value, since "" is meaningful
formatStr.AssignWithConversion("x"); formatStr.Assign(NS_LITERAL_STRING("x"));
nsCOMPtr<nsISupportsArray> arrayOfNodes; nsCOMPtr<nsISupportsArray> arrayOfNodes;
nsresult res = GetParagraphFormatNodes(address_of(arrayOfNodes), PR_TRUE); nsresult res = GetParagraphFormatNodes(address_of(arrayOfNodes), PR_TRUE);
@ -794,12 +806,12 @@ nsHTMLEditRules::GetParagraphState(PRBool &aMixed, nsString &outFormat)
} }
else else
{ {
format.AssignWithConversion(""); format.Truncate(0);
} }
} }
else else
{ {
format.AssignWithConversion(""); format.Truncate(0);
} }
} }
else if (nsHTMLEditUtils::IsHeader(curNode)) else if (nsHTMLEditUtils::IsHeader(curNode))
@ -828,7 +840,7 @@ nsHTMLEditRules::GetParagraphState(PRBool &aMixed, nsString &outFormat)
} }
} }
aMixed = bMixed; *aMixed = bMixed;
outFormat = formatStr; outFormat = formatStr;
return res; return res;
} }
@ -904,8 +916,8 @@ nsHTMLEditRules::WillInsertText(PRInt32 aAction,
nsISelection *aSelection, nsISelection *aSelection,
PRBool *aCancel, PRBool *aCancel,
PRBool *aHandled, PRBool *aHandled,
const nsString *inString, const nsAReadableString *inString,
nsString *outString, nsAWritableString *outString,
PRInt32 aMaxLength) PRInt32 aMaxLength)
{ {
if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
@ -986,7 +998,8 @@ nsHTMLEditRules::WillInsertText(PRInt32 aAction,
// dont spaz my selection in subtransactions // dont spaz my selection in subtransactions
nsAutoTxnsConserveSelection dontSpazMySelection(mHTMLEditor); nsAutoTxnsConserveSelection dontSpazMySelection(mHTMLEditor);
nsSubsumeStr subStr; nsSubsumeStr subStr;
const PRUnichar *unicodeBuf = inString->GetUnicode(); const nsPromiseFlatString &tString = PromiseFlatString(*inString);////MJUDGE SCC NEED HELP
const PRUnichar *unicodeBuf = tString.get();
nsCOMPtr<nsIDOMNode> unused; nsCOMPtr<nsIDOMNode> unused;
PRInt32 pos = 0; PRInt32 pos = 0;
@ -995,13 +1008,21 @@ nsHTMLEditRules::WillInsertText(PRInt32 aAction,
// it is to search for both tabs and newlines. // it is to search for both tabs and newlines.
if (isPRE) if (isPRE)
{ {
char newlineChar = '\n'; nsAutoString newlineChar(NS_LITERAL_STRING("\n"));
while (unicodeBuf && (pos != -1) && (pos < (PRInt32)inString->Length())) while (unicodeBuf && (pos != -1) && (pos < (PRInt32)(*inString).Length()))
{ {
PRInt32 oldPos = pos; PRInt32 oldPos = pos;
PRInt32 subStrLen; PRInt32 subStrLen;
pos = inString->FindChar(newlineChar, PR_FALSE, oldPos); pos = -1;
nsReadingIterator<PRUnichar> beginFindIter, endFindIter, beginIter;
inString->BeginReading(beginIter);
beginFindIter = beginIter;
inString->EndReading(endFindIter);
beginFindIter.advance(oldPos);
if (FindInReadable(newlineChar,beginFindIter,endFindIter))
{
pos = Distance(beginIter,beginFindIter);
}
if (pos != -1) if (pos != -1)
{ {
subStrLen = pos - oldPos; subStrLen = pos - oldPos;
@ -1011,8 +1032,8 @@ nsHTMLEditRules::WillInsertText(PRInt32 aAction,
} }
else else
{ {
subStrLen = inString->Length() - oldPos; subStrLen = (*inString).Length() - oldPos;
pos = inString->Length(); pos = (*inString).Length();
} }
subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen); subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen);
@ -1032,13 +1053,22 @@ nsHTMLEditRules::WillInsertText(PRInt32 aAction,
} }
else else
{ {
char specialChars[] = {'\t','\n',0}; nsAutoString specialChars;
specialChars = NS_LITERAL_STRING("\t\n");
nsAutoString tabString; tabString.AssignWithConversion(" "); nsAutoString tabString; tabString.AssignWithConversion(" ");
while (unicodeBuf && (pos != -1) && (pos < (PRInt32)inString->Length())) while (unicodeBuf && (pos != -1) && (pos < (PRInt32)(*inString).Length()))
{ {
PRInt32 oldPos = pos; PRInt32 oldPos = pos;
PRInt32 subStrLen; PRInt32 subStrLen;
pos = inString->FindCharInSet(specialChars, oldPos); nsReadingIterator<PRUnichar> beginFindIter,endFindIter;
(*inString).BeginReading(beginFindIter);
beginFindIter.advance(oldPos);
(*inString).EndReading(endFindIter);
nsReadingIterator<PRUnichar> distanceIter;
(*inString).BeginReading(distanceIter);
pos = -1;
if (FindInReadable((const nsAString &)specialChars,beginFindIter,endFindIter))
pos = Distance(distanceIter,beginFindIter);
if (pos != -1) if (pos != -1)
{ {
@ -1049,8 +1079,8 @@ nsHTMLEditRules::WillInsertText(PRInt32 aAction,
} }
else else
{ {
subStrLen = inString->Length() - oldPos; subStrLen = (*inString).Length() - oldPos;
pos = inString->Length(); pos = (*inString).Length();
} }
subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen); subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen);
@ -1900,11 +1930,11 @@ nsHTMLEditRules::DeleteNonTableElements(nsIDOMNode *aNode)
nsresult nsresult
nsHTMLEditRules::WillMakeList(nsISelection *aSelection, nsHTMLEditRules::WillMakeList(nsISelection *aSelection,
const nsString *aListType, const nsAReadableString *aListType,
PRBool aEntireList, PRBool aEntireList,
PRBool *aCancel, PRBool *aCancel,
PRBool *aHandled, PRBool *aHandled,
const nsString *aItemType) const nsAReadableString *aItemType)
{ {
if (!aSelection || !aListType || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } if (!aSelection || !aListType || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
@ -1918,9 +1948,10 @@ nsHTMLEditRules::WillMakeList(nsISelection *aSelection,
// deduce what tag to use for list items // deduce what tag to use for list items
nsAutoString itemType; nsAutoString itemType;
nsString tString(*aListType);//MJUDGE SCC NEED HELP
if (aItemType) if (aItemType)
itemType = *aItemType; itemType = *aItemType;
else if (aListType->EqualsWithConversion("dl")) else if (tString.EqualsWithConversion("dl"))
itemType.AssignWithConversion("dd"); itemType.AssignWithConversion("dd");
else else
itemType.AssignWithConversion("li"); itemType.AssignWithConversion("li");
@ -2316,7 +2347,7 @@ nsHTMLEditRules::WillRemoveList(nsISelection *aSelection,
nsresult nsresult
nsHTMLEditRules::WillMakeDefListItem(nsISelection *aSelection, nsHTMLEditRules::WillMakeDefListItem(nsISelection *aSelection,
const nsString *aItemType, const nsAReadableString *aItemType,
PRBool aEntireList, PRBool aEntireList,
PRBool *aCancel, PRBool *aCancel,
PRBool *aHandled) PRBool *aHandled)
@ -2329,7 +2360,7 @@ nsHTMLEditRules::WillMakeDefListItem(nsISelection *aSelection,
nsresult nsresult
nsHTMLEditRules::WillMakeBasicBlock(nsISelection *aSelection, nsHTMLEditRules::WillMakeBasicBlock(nsISelection *aSelection,
const nsString *aBlockType, const nsAReadableString *aBlockType,
PRBool *aCancel, PRBool *aCancel,
PRBool *aHandled) PRBool *aHandled)
{ {
@ -2384,7 +2415,8 @@ nsHTMLEditRules::WillMakeBasicBlock(nsISelection *aSelection,
// Ok, now go through all the nodes and make the right kind of blocks, // Ok, now go through all the nodes and make the right kind of blocks,
// or whatever is approriate. Wohoo! // or whatever is approriate. Wohoo!
// Note: blockquote is handled a little differently // Note: blockquote is handled a little differently
if (aBlockType->EqualsWithConversion("blockquote")) nsString tString(*aBlockType);
if (tString.EqualsWithConversion("blockquote"))
res = MakeBlockquote(arrayOfNodes); res = MakeBlockquote(arrayOfNodes);
else else
res = ApplyBlockStyle(arrayOfNodes, aBlockType); res = ApplyBlockStyle(arrayOfNodes, aBlockType);
@ -2664,8 +2696,8 @@ nsHTMLEditRules::WillOutdent(nsISelection *aSelection, PRBool *aCancel, PRBool *
nsresult nsresult
nsHTMLEditRules::ConvertListType(nsIDOMNode *aList, nsHTMLEditRules::ConvertListType(nsIDOMNode *aList,
nsCOMPtr<nsIDOMNode> *outList, nsCOMPtr<nsIDOMNode> *outList,
const nsString& aListType, const nsAReadableString& aListType,
const nsString& aItemType) const nsAReadableString& aItemType)
{ {
if (!aList || !outList) return NS_ERROR_NULL_POINTER; if (!aList || !outList) return NS_ERROR_NULL_POINTER;
*outList = aList; // we migvht not need to change the list *outList = aList; // we migvht not need to change the list
@ -2879,7 +2911,7 @@ nsHTMLEditRules::IsEmptyBlock(nsIDOMNode *aNode,
nsresult nsresult
nsHTMLEditRules::WillAlign(nsISelection *aSelection, nsHTMLEditRules::WillAlign(nsISelection *aSelection,
const nsString *alignType, const nsAReadableString *alignType,
PRBool *aCancel, PRBool *aCancel,
PRBool *aHandled) PRBool *aHandled)
{ {
@ -3046,7 +3078,7 @@ nsHTMLEditRules::WillAlign(nsISelection *aSelection,
// AlignInnerBlocks: align inside table cells or list items // AlignInnerBlocks: align inside table cells or list items
// //
nsresult nsresult
nsHTMLEditRules::AlignInnerBlocks(nsIDOMNode *aNode, const nsString *alignType) nsHTMLEditRules::AlignInnerBlocks(nsIDOMNode *aNode, const nsAReadableString *alignType)
{ {
if (!aNode || !alignType) return NS_ERROR_NULL_POINTER; if (!aNode || !alignType) return NS_ERROR_NULL_POINTER;
nsresult res; nsresult res;
@ -3084,7 +3116,7 @@ nsHTMLEditRules::AlignInnerBlocks(nsIDOMNode *aNode, const nsString *alignType)
// AlignBlockContents: align contents of a block element // AlignBlockContents: align contents of a block element
// //
nsresult nsresult
nsHTMLEditRules::AlignBlockContents(nsIDOMNode *aNode, const nsString *alignType) nsHTMLEditRules::AlignBlockContents(nsIDOMNode *aNode, const nsAReadableString *alignType)
{ {
if (!aNode || !alignType) return NS_ERROR_NULL_POINTER; if (!aNode || !alignType) return NS_ERROR_NULL_POINTER;
nsresult res; nsresult res;
@ -4149,7 +4181,7 @@ nsHTMLEditRules::MakeTransitionList(nsISupportsArray *inArrayOfNodes,
// //
nsresult nsresult
nsHTMLEditRules::InsertTab(nsISelection *aSelection, nsHTMLEditRules::InsertTab(nsISelection *aSelection,
nsString *outString) nsAWritableString *outString)
{ {
nsCOMPtr<nsIDOMNode> parentNode; nsCOMPtr<nsIDOMNode> parentNode;
PRInt32 offset; PRInt32 offset;
@ -4165,14 +4197,14 @@ nsHTMLEditRules::InsertTab(nsISelection *aSelection,
if (isPRE) if (isPRE)
{ {
outString->AssignWithConversion('\t'); outString->Assign(PRUnichar('\t'));
} }
else else
{ {
// number of spaces should be a pref? // number of spaces should be a pref?
// note that we dont play around with nbsps here anymore. // note that we dont play around with nbsps here anymore.
// let the AfterEdit whitespace cleanup code handle it. // let the AfterEdit whitespace cleanup code handle it.
outString->AssignWithConversion(" "); outString->Assign(NS_LITERAL_STRING(" "));
} }
return NS_OK; return NS_OK;
@ -4566,7 +4598,7 @@ nsHTMLEditRules::MakeBlockquote(nsISupportsArray *arrayOfNodes)
// one or more blocks of type blockTag. // one or more blocks of type blockTag.
// //
nsresult nsresult
nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString *aBlockTag) nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsAReadableString *aBlockTag)
{ {
// intent of this routine is to be used for converting to/from // intent of this routine is to be used for converting to/from
// headers, paragraphs, pre, and address. Those blocks // headers, paragraphs, pre, and address. Those blocks
@ -4582,7 +4614,8 @@ nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString
// we special case an empty tag name to mean "remove block parents". // we special case an empty tag name to mean "remove block parents".
// This is used for the "normal" paragraph style in mail-compose // This is used for the "normal" paragraph style in mail-compose
if (aBlockTag->IsEmpty() || aBlockTag->EqualsWithConversion("normal")) bNoParent = PR_TRUE; nsString tString(*aBlockTag);////MJUDGE SCC NEED HELP
if (tString.IsEmpty() || tString.EqualsWithConversion("normal")) bNoParent = PR_TRUE;
arrayOfNodes->Count(&listCount); arrayOfNodes->Count(&listCount);
@ -4674,7 +4707,8 @@ nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString
else if (IsInlineNode(curNode) && !bNoParent) else if (IsInlineNode(curNode) && !bNoParent)
{ {
// if curNode is a non editable, drop it if we are going to <pre> // if curNode is a non editable, drop it if we are going to <pre>
if ((aBlockTag->EqualsWithConversion("pre")) && (!mHTMLEditor->IsEditable(curNode))) nsString tString(*aBlockTag); ////MJUDGE SCC NEED HELP
if ((tString.EqualsWithConversion("pre")) && (!mHTMLEditor->IsEditable(curNode)))
continue; // do nothing to this block continue; // do nothing to this block
// if no curBlock, make one // if no curBlock, make one
@ -4707,7 +4741,7 @@ nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString
// where we can insert the tag. Adjust inOutParent and // where we can insert the tag. Adjust inOutParent and
// inOutOffset to pint to new location for tag. // inOutOffset to pint to new location for tag.
nsresult nsresult
nsHTMLEditRules::SplitAsNeeded(const nsString *aTag, nsHTMLEditRules::SplitAsNeeded(const nsAReadableString *aTag,
nsCOMPtr<nsIDOMNode> *inOutParent, nsCOMPtr<nsIDOMNode> *inOutParent,
PRInt32 *inOutOffset) PRInt32 *inOutOffset)
{ {
@ -5443,47 +5477,48 @@ nsHTMLEditRules::DoTextNodeWhitespace(nsIDOMCharacterData *aTextNode, PRInt32 aS
nsresult nsresult
nsHTMLEditRules::ConvertWhitespace(const nsString & inString, nsString & outString) nsHTMLEditRules::ConvertWhitespace(const nsAReadableString & inString, nsAWritableString & outString)
{ {
PRUint32 j,len = inString.Length(); PRUint32 j,len = inString.Length();
nsString tString(inString);////MJUDGE SCC NEED HELP
switch (len) switch (len)
{ {
case 0: case 0:
outString.SetLength(0); outString.SetLength(0);
return NS_OK; return NS_OK;
case 1: case 1:
if (inString.EqualsWithConversion("\n")) // a bit of a hack: don't convert single newlines that if (tString.EqualsWithConversion("\n")) // a bit of a hack: don't convert single newlines that
outString.AssignWithConversion("\n"); // dont have whitespace adjacent. This is to preserve outString.Assign(NS_LITERAL_STRING("\n")); // dont have whitespace adjacent. This is to preserve
else // html source formatting to some degree. else // html source formatting to some degree.
outString.AssignWithConversion(" "); outString.Assign(NS_LITERAL_STRING(" "));
return NS_OK; return NS_OK;
case 2: case 2:
outString.Assign((PRUnichar)nbsp); outString.Assign(PRUnichar(nbsp));
outString.AppendWithConversion(" "); outString.Append(NS_LITERAL_STRING(" "));
return NS_OK; return NS_OK;
case 3: case 3:
outString.AssignWithConversion(" "); outString.Assign(NS_LITERAL_STRING(" "));
outString += (PRUnichar)nbsp; outString += PRUnichar(nbsp);
outString.AppendWithConversion(" "); outString.Append(NS_LITERAL_STRING(" "));
return NS_OK; return NS_OK;
} }
if (len%2) // length is odd if (len%2) // length is odd
{ {
for (j=0;j<len;j++) for (j=0;j<len;j++)
{ {
if (!(j & 0x01)) outString.AppendWithConversion(" "); // even char if (!(j & 0x01)) outString.Append(NS_LITERAL_STRING(" ")); // even char
else outString += (PRUnichar)nbsp; // odd char else outString += PRUnichar(nbsp); // odd char
} }
} }
else else
{ {
outString.AssignWithConversion(" "); outString.Assign(NS_LITERAL_STRING(" "));
outString += (PRUnichar)nbsp; outString += PRUnichar(nbsp);
outString += (PRUnichar)nbsp; outString += PRUnichar(nbsp);
for (j=0;j<len-3;j++) for (j=0;j<len-3;j++)
{ {
if (!(j%2)) outString.AppendWithConversion(" "); // even char if (!(j%2)) outString.Append(NS_LITERAL_STRING(" ")); // even char
else outString += (PRUnichar)nbsp; // odd char else outString += PRUnichar(nbsp); // odd char
} }
} }
return NS_OK; return NS_OK;
@ -5687,13 +5722,13 @@ nsHTMLEditRules::InsertMozBRIfNeeded(nsIDOMNode *aNode)
#endif #endif
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditRules::WillCreateNode(const nsString& aTag, nsIDOMNode *aParent, PRInt32 aPosition) nsHTMLEditRules::WillCreateNode(const nsAReadableString& aTag, nsIDOMNode *aParent, PRInt32 aPosition)
{ {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditRules::DidCreateNode(const nsString& aTag, nsHTMLEditRules::DidCreateNode(const nsAReadableString& aTag,
nsIDOMNode *aNode, nsIDOMNode *aNode,
nsIDOMNode *aParent, nsIDOMNode *aParent,
PRInt32 aPosition, PRInt32 aPosition,
@ -5798,7 +5833,7 @@ nsHTMLEditRules::DidJoinNodes(nsIDOMNode *aLeftNode,
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditRules::WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString) nsHTMLEditRules::WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString)
{ {
return NS_OK; return NS_OK;
} }
@ -5807,7 +5842,7 @@ nsHTMLEditRules::WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset,
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditRules::DidInsertText(nsIDOMCharacterData *aTextNode, nsHTMLEditRules::DidInsertText(nsIDOMCharacterData *aTextNode,
PRInt32 aOffset, PRInt32 aOffset,
const nsString &aString, const nsAReadableString &aString,
nsresult aResult) nsresult aResult)
{ {
if (!mListenerEnabled) return NS_OK; if (!mListenerEnabled) return NS_OK;

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

@ -54,16 +54,17 @@ public:
NS_IMETHOD DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult); NS_IMETHOD DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult);
// nsIHTMLEditRules methods // nsIHTMLEditRules methods
NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL);
NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD); NS_IMETHOD GetListState(PRBool *aMixed, PRBool *aOL, PRBool *aUL, PRBool *aDL);
NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent); NS_IMETHOD GetListItemState(PRBool *aMixed, PRBool *aLI, PRBool *aDT, PRBool *aDD);
NS_IMETHOD GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign); NS_IMETHOD GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent);
NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat); NS_IMETHOD GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign);
NS_IMETHOD GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat);
// nsIEditActionListener methods // nsIEditActionListener methods
NS_IMETHOD WillCreateNode(const nsString& aTag, nsIDOMNode *aParent, PRInt32 aPosition); NS_IMETHOD WillCreateNode(const nsAReadableString& aTag, nsIDOMNode *aParent, PRInt32 aPosition);
NS_IMETHOD DidCreateNode(const nsString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult); NS_IMETHOD DidCreateNode(const nsAReadableString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult);
NS_IMETHOD WillInsertNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition); NS_IMETHOD WillInsertNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition);
NS_IMETHOD DidInsertNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult); NS_IMETHOD DidInsertNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult);
NS_IMETHOD WillDeleteNode(nsIDOMNode *aChild); NS_IMETHOD WillDeleteNode(nsIDOMNode *aChild);
@ -72,8 +73,8 @@ public:
NS_IMETHOD DidSplitNode(nsIDOMNode *aExistingRightNode, PRInt32 aOffset, nsIDOMNode *aNewLeftNode, nsresult aResult); NS_IMETHOD DidSplitNode(nsIDOMNode *aExistingRightNode, PRInt32 aOffset, nsIDOMNode *aNewLeftNode, nsresult aResult);
NS_IMETHOD WillJoinNodes(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsIDOMNode *aParent); NS_IMETHOD WillJoinNodes(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsIDOMNode *aParent);
NS_IMETHOD DidJoinNodes(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsIDOMNode *aParent, nsresult aResult); NS_IMETHOD DidJoinNodes(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsIDOMNode *aParent, nsresult aResult);
NS_IMETHOD WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString); NS_IMETHOD WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString);
NS_IMETHOD DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString, nsresult aResult); NS_IMETHOD DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString, nsresult aResult);
NS_IMETHOD WillDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength); NS_IMETHOD WillDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength);
NS_IMETHOD DidDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength, nsresult aResult); NS_IMETHOD DidDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength, nsresult aResult);
NS_IMETHOD WillDeleteSelection(nsISelection *aSelection); NS_IMETHOD WillDeleteSelection(nsISelection *aSelection);
@ -95,31 +96,31 @@ protected:
nsISelection *aSelection, nsISelection *aSelection,
PRBool *aCancel, PRBool *aCancel,
PRBool *aHandled, PRBool *aHandled,
const nsString *inString, const nsAReadableString *inString,
nsString *outString, nsAWritableString *outString,
PRInt32 aMaxLength); PRInt32 aMaxLength);
nsresult WillInsertBreak(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); nsresult WillInsertBreak(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled);
nsresult DidInsertBreak(nsISelection *aSelection, nsresult aResult); nsresult DidInsertBreak(nsISelection *aSelection, nsresult aResult);
nsresult WillDeleteSelection(nsISelection *aSelection, nsIEditor::EDirection aAction, nsresult WillDeleteSelection(nsISelection *aSelection, nsIEditor::EDirection aAction,
PRBool *aCancel, PRBool *aHandled); PRBool *aCancel, PRBool *aHandled);
nsresult DeleteNonTableElements(nsIDOMNode *aNode); nsresult DeleteNonTableElements(nsIDOMNode *aNode);
nsresult WillMakeList(nsISelection *aSelection, const nsString *aListType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled, const nsString *aItemType=nsnull); nsresult WillMakeList(nsISelection *aSelection, const nsAReadableString *aListType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled, const nsAReadableString *aItemType=nsnull);
nsresult WillRemoveList(nsISelection *aSelection, PRBool aOrderd, PRBool *aCancel, PRBool *aHandled); nsresult WillRemoveList(nsISelection *aSelection, PRBool aOrderd, PRBool *aCancel, PRBool *aHandled);
nsresult WillIndent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); nsresult WillIndent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled);
nsresult WillOutdent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); nsresult WillOutdent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled);
nsresult WillAlign(nsISelection *aSelection, const nsString *alignType, PRBool *aCancel, PRBool *aHandled); nsresult WillAlign(nsISelection *aSelection, const nsAReadableString *alignType, PRBool *aCancel, PRBool *aHandled);
nsresult WillMakeDefListItem(nsISelection *aSelection, const nsString *aBlockType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled); nsresult WillMakeDefListItem(nsISelection *aSelection, const nsAReadableString *aBlockType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled);
nsresult WillMakeBasicBlock(nsISelection *aSelection, const nsString *aBlockType, PRBool *aCancel, PRBool *aHandled); nsresult WillMakeBasicBlock(nsISelection *aSelection, const nsAReadableString *aBlockType, PRBool *aCancel, PRBool *aHandled);
nsresult DidMakeBasicBlock(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult); nsresult DidMakeBasicBlock(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult);
nsresult AlignInnerBlocks(nsIDOMNode *aNode, const nsString *alignType); nsresult AlignInnerBlocks(nsIDOMNode *aNode, const nsAReadableString *alignType);
nsresult AlignBlockContents(nsIDOMNode *aNode, const nsString *alignType); nsresult AlignBlockContents(nsIDOMNode *aNode, const nsAReadableString *alignType);
nsresult GetInnerContent(nsIDOMNode *aNode, nsISupportsArray *outArrayOfNodes, PRBool aList = PR_TRUE, PRBool aTble = PR_TRUE); nsresult GetInnerContent(nsIDOMNode *aNode, nsISupportsArray *outArrayOfNodes, PRBool aList = PR_TRUE, PRBool aTble = PR_TRUE);
nsresult InsertTab(nsISelection *aSelection, nsString *outString); nsresult InsertTab(nsISelection *aSelection, nsAWritableString *outString);
nsresult ReturnInHeader(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset); nsresult ReturnInHeader(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset);
nsresult ReturnInParagraph(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset, PRBool *aCancel, PRBool *aHandled); nsresult ReturnInParagraph(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset, PRBool *aCancel, PRBool *aHandled);
nsresult ReturnInListItem(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset); nsresult ReturnInListItem(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset);
nsresult AfterEditInner(PRInt32 action, nsIEditor::EDirection aDirection); nsresult AfterEditInner(PRInt32 action, nsIEditor::EDirection aDirection);
nsresult ConvertListType(nsIDOMNode *aList, nsCOMPtr<nsIDOMNode> *outList, const nsString& aListType, const nsString& aItemType); nsresult ConvertListType(nsIDOMNode *aList, nsCOMPtr<nsIDOMNode> *outList, const nsAReadableString& aListType, const nsAReadableString& aItemType);
nsresult CreateStyleForInsertText(nsISelection *aSelection, nsIDOMDocument *aDoc); nsresult CreateStyleForInsertText(nsISelection *aSelection, nsIDOMDocument *aDoc);
nsresult IsEmptyBlock(nsIDOMNode *aNode, nsresult IsEmptyBlock(nsIDOMNode *aNode,
PRBool *outIsEmptyBlock, PRBool *outIsEmptyBlock,
@ -150,9 +151,9 @@ protected:
nsCOMPtr<nsIDOMNode> GetHighestInlineParent(nsIDOMNode* aNode); nsCOMPtr<nsIDOMNode> GetHighestInlineParent(nsIDOMNode* aNode);
nsresult MakeTransitionList(nsISupportsArray *inArrayOfNodes, nsresult MakeTransitionList(nsISupportsArray *inArrayOfNodes,
nsVoidArray *inTransitionArray); nsVoidArray *inTransitionArray);
nsresult ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString *aBlockTag); nsresult ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsAReadableString *aBlockTag);
nsresult MakeBlockquote(nsISupportsArray *arrayOfNodes); nsresult MakeBlockquote(nsISupportsArray *arrayOfNodes);
nsresult SplitAsNeeded(const nsString *aTag, nsCOMPtr<nsIDOMNode> *inOutParent, PRInt32 *inOutOffset); nsresult SplitAsNeeded(const nsAReadableString *aTag, nsCOMPtr<nsIDOMNode> *inOutParent, PRInt32 *inOutOffset);
nsresult AddTerminatingBR(nsIDOMNode *aBlock); nsresult AddTerminatingBR(nsIDOMNode *aBlock);
nsresult JoinNodesSmart( nsIDOMNode *aNodeLeft, nsresult JoinNodesSmart( nsIDOMNode *aNodeLeft,
nsIDOMNode *aNodeRight, nsIDOMNode *aNodeRight,
@ -172,7 +173,7 @@ protected:
nsresult SelectionEndpointInNode(nsIDOMNode *aNode, PRBool *aResult); nsresult SelectionEndpointInNode(nsIDOMNode *aNode, PRBool *aResult);
nsresult DoTextNodeWhitespace(nsIDOMCharacterData *aTextNode, PRInt32 aStart, PRInt32 aEnd); nsresult DoTextNodeWhitespace(nsIDOMCharacterData *aTextNode, PRInt32 aStart, PRInt32 aEnd);
nsresult UpdateDocChangeRange(nsIDOMRange *aRange); nsresult UpdateDocChangeRange(nsIDOMRange *aRange);
nsresult ConvertWhitespace(const nsString & inString, nsString & outString); nsresult ConvertWhitespace(const nsAReadableString & inString, nsAWritableString & outString);
nsresult ConfirmSelectionInBody(); nsresult ConfirmSelectionInBody();
nsresult InsertMozBRIfNeeded(nsIDOMNode *aNode); nsresult InsertMozBRIfNeeded(nsIDOMNode *aNode);

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

@ -425,9 +425,9 @@ NS_IMETHODIMP nsHTMLEditor::InitRules()
* Can be used to determine if a new paragraph should be started. * Can be used to determine if a new paragraph should be started.
*/ */
nsresult nsresult
nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock) nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool *aIsBlock)
{ {
if (!aNode) { return NS_ERROR_NULL_POINTER; } if (!aNode || !aIsBlock) { return NS_ERROR_NULL_POINTER; }
//#define USE_PARSER_FOR_BLOCKNESS 1 //#define USE_PARSER_FOR_BLOCKNESS 1
#ifdef USE_PARSER_FOR_BLOCKNESS #ifdef USE_PARSER_FOR_BLOCKNESS
@ -443,11 +443,11 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
if (!element) if (!element)
{ {
// We don't have an element -- probably a text node // We don't have an element -- probably a text node
aIsBlock = PR_FALSE; *aIsBlock = PR_FALSE;
return NS_OK; return NS_OK;
} }
aIsBlock = PR_FALSE; *aIsBlock = PR_FALSE;
// Get the node name and atom: // Get the node name and atom:
nsAutoString tagName; nsAutoString tagName;
@ -475,7 +475,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
tagAtom==nsIEditProperty::td || tagAtom==nsIEditProperty::td ||
tagAtom==nsIEditProperty::pre) tagAtom==nsIEditProperty::pre)
{ {
aIsBlock = PR_TRUE; *aIsBlock = PR_TRUE;
return NS_OK; return NS_OK;
} }
@ -487,7 +487,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
PRInt32 id; PRInt32 id;
rv = sParserService->HTMLStringTagToId(tagName, &id); rv = sParserService->HTMLStringTagToId(tagName, &id);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = sParserService->IsBlock(id, aIsBlock); rv = sParserService->IsBlock(id, *aIsBlock);
#ifdef DEBUG #ifdef DEBUG
// Check this against what we would have said with the old code: // Check this against what we would have said with the old code:
@ -517,12 +517,12 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
tagAtom==nsIEditProperty::dd || tagAtom==nsIEditProperty::dd ||
tagAtom==nsIEditProperty::legend ) tagAtom==nsIEditProperty::legend )
{ {
if (!aIsBlock) if (!(*aIsBlock))
{ {
nsAutoString assertmsg (NS_LITERAL_STRING("Parser and editor disagree on blockness: ")); nsAutoString assertmsg (NS_LITERAL_STRING("Parser and editor disagree on blockness: "));
assertmsg.Append(tagName); assertmsg.Append(tagName);
char* assertstr = assertmsg.ToNewCString(); char* assertstr = assertmsg.ToNewCString();
NS_ASSERTION(aIsBlock, assertstr); NS_ASSERTION(*aIsBlock, assertstr);
Recycle(assertstr); Recycle(assertstr);
} }
} }
@ -531,7 +531,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
return rv; return rv;
#else /* USE_PARSER_FOR_BLOCKNESS */ #else /* USE_PARSER_FOR_BLOCKNESS */
nsresult result = NS_ERROR_FAILURE; nsresult result = NS_ERROR_FAILURE;
aIsBlock = PR_FALSE; *aIsBlock = PR_FALSE;
nsCOMPtr<nsIDOMElement>element; nsCOMPtr<nsIDOMElement>element;
element = do_QueryInterface(aNode); element = do_QueryInterface(aNode);
if (element) if (element)
@ -578,7 +578,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
tagAtom==nsIEditProperty::dd || tagAtom==nsIEditProperty::dd ||
tagAtom==nsIEditProperty::legend ) tagAtom==nsIEditProperty::legend )
{ {
aIsBlock = PR_TRUE; *aIsBlock = PR_TRUE;
} }
NS_RELEASE(tagAtom); NS_RELEASE(tagAtom);
result = NS_OK; result = NS_OK;
@ -588,7 +588,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
nsCOMPtr<nsIDOMCharacterData>nodeAsText = do_QueryInterface(aNode); nsCOMPtr<nsIDOMCharacterData>nodeAsText = do_QueryInterface(aNode);
if (nodeAsText) if (nodeAsText)
{ {
aIsBlock = PR_FALSE; *aIsBlock = PR_FALSE;
result = NS_OK; result = NS_OK;
} }
} }
@ -597,22 +597,21 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
#endif /* USE_PARSER_FOR_BLOCKNESS */ #endif /* USE_PARSER_FOR_BLOCKNESS */
} }
// Non-static version for the nsIEditor interface and JavaScript NS_IMETHODIMP
NS_IMETHODIMP nsHTMLEditor::NodeIsBlock(nsIDOMNode *aNode, PRBool *aIsBlock)
nsHTMLEditor::NodeIsBlock(nsIDOMNode *aNode, PRBool &aIsBlock)
{ {
return NodeIsBlockStatic(aNode, aIsBlock); return NodeIsBlockStatic(aNode, aIsBlock);
} }
// Non-static version for the nsIEditor interface and JavaScript
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::SetDocumentTitle(const PRUnichar *aTitle) nsHTMLEditor::SetDocumentTitle(const nsAReadableString &aTitle)
{ {
SetDocTitleTxn *txn; SetDocTitleTxn *txn;
nsresult result = TransactionFactory::GetNewTransaction(SetDocTitleTxn::GetCID(), (EditTxn **)&txn); nsresult result = TransactionFactory::GetNewTransaction(SetDocTitleTxn::GetCID(), (EditTxn **)&txn);
if (NS_SUCCEEDED(result)) if (NS_SUCCEEDED(result))
{ {
nsAutoString title(aTitle); result = txn->Init(this, &aTitle);
result = txn->Init(this, &title);
if (NS_SUCCEEDED(result)) if (NS_SUCCEEDED(result))
{ {
@ -646,7 +645,7 @@ nsHTMLEditor::GetBlockNodeParent(nsIDOMNode *aNode)
while (p) while (p)
{ {
PRBool isBlock; PRBool isBlock;
if (NS_FAILED(NodeIsBlockStatic(p, isBlock)) || isBlock) if (NS_FAILED(NodeIsBlockStatic(p, &isBlock)) || isBlock)
break; break;
if ( NS_FAILED(p->GetParentNode(getter_AddRefs(tmp))) || !tmp) // no parent, ran off top of tree if ( NS_FAILED(p->GetParentNode(getter_AddRefs(tmp))) || !tmp) // no parent, ran off top of tree
return p; return p;
@ -697,7 +696,7 @@ nsHTMLEditor::GetBlockSection(nsIDOMNode *aChild,
while ((NS_SUCCEEDED(result)) && sibling) while ((NS_SUCCEEDED(result)) && sibling)
{ {
PRBool isBlock; PRBool isBlock;
NodeIsBlockStatic(sibling, isBlock); NodeIsBlockStatic(sibling, &isBlock);
if (isBlock) if (isBlock)
{ {
nsCOMPtr<nsIDOMCharacterData>nodeAsText = do_QueryInterface(sibling); nsCOMPtr<nsIDOMCharacterData>nodeAsText = do_QueryInterface(sibling);
@ -715,7 +714,7 @@ nsHTMLEditor::GetBlockSection(nsIDOMNode *aChild,
while ((NS_SUCCEEDED(result)) && sibling) while ((NS_SUCCEEDED(result)) && sibling)
{ {
PRBool isBlock; PRBool isBlock;
NodeIsBlockStatic(sibling, isBlock); NodeIsBlockStatic(sibling, &isBlock);
if (isBlock) if (isBlock)
{ {
nsCOMPtr<nsIDOMCharacterData>nodeAsText = do_QueryInterface(sibling); nsCOMPtr<nsIDOMCharacterData>nodeAsText = do_QueryInterface(sibling);
@ -768,7 +767,7 @@ nsHTMLEditor::GetBlockSectionsForRange(nsIDOMRange *aRange,
else else
{ {
PRBool isNotInlineOrText; PRBool isNotInlineOrText;
result = NodeIsBlockStatic(currentNode, isNotInlineOrText); result = NodeIsBlockStatic(currentNode, &isNotInlineOrText);
if (isNotInlineOrText) if (isNotInlineOrText)
{ {
PRUint16 nodeType; PRUint16 nodeType;
@ -861,7 +860,7 @@ nsHTMLEditor::NextNodeInBlock(nsIDOMNode *aNode, IterDirection aDir)
// much gnashing of teeth as we twit back and forth between content and domnode types // much gnashing of teeth as we twit back and forth between content and domnode types
content = do_QueryInterface(aNode); content = do_QueryInterface(aNode);
PRBool isBlock; PRBool isBlock;
if (NS_SUCCEEDED(NodeIsBlockStatic(aNode, isBlock)) && isBlock) if (NS_SUCCEEDED(NodeIsBlockStatic(aNode, &isBlock)) && isBlock)
{ {
blockParent = do_QueryInterface(aNode); blockParent = do_QueryInterface(aNode);
} }
@ -936,7 +935,7 @@ nsHTMLEditor::IsNextCharWhitespace(nsIDOMNode *aParentNode,
while (node) while (node)
{ {
PRBool isBlock (PR_FALSE); PRBool isBlock (PR_FALSE);
NodeIsBlock(node, isBlock); NodeIsBlock(node, &isBlock);
if (isBlock) // skip over bold, italic, link, ect nodes if (isBlock) // skip over bold, italic, link, ect nodes
{ {
if (IsTextNode(node) && IsEditable(node)) if (IsTextNode(node) && IsEditable(node))
@ -1007,7 +1006,7 @@ nsHTMLEditor::IsPrevCharWhitespace(nsIDOMNode *aParentNode,
while (node) while (node)
{ {
PRBool isBlock (PR_FALSE); PRBool isBlock (PR_FALSE);
NodeIsBlock(node, isBlock); NodeIsBlock(node, &isBlock);
if (isBlock) // skip over bold, italic, link, ect nodes if (isBlock) // skip over bold, italic, link, ect nodes
{ {
if (IsTextNode(node) && IsEditable(node)) if (IsTextNode(node) && IsEditable(node))
@ -1093,7 +1092,7 @@ NS_IMETHODIMP nsHTMLEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
if (!node) return NS_ERROR_FAILURE; if (!node) return NS_ERROR_FAILURE;
PRBool isBlock (PR_FALSE); PRBool isBlock (PR_FALSE);
NodeIsBlock(node, isBlock); NodeIsBlock(node, &isBlock);
if (isBlock) blockParent = node; if (isBlock) blockParent = node;
else blockParent = GetBlockNodeParent(node); else blockParent = GetBlockNodeParent(node);
@ -1121,18 +1120,18 @@ NS_IMETHODIMP nsHTMLEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
nsString empty; nsString empty;
if (isShift && !(mFlags&eEditorPlaintextBit)) if (isShift && !(mFlags&eEditorPlaintextBit))
{ {
return TypedText(empty.GetUnicode(), eTypedBR); // only inserts a br node return TypedText(empty, eTypedBR); // only inserts a br node
} }
else else
{ {
return TypedText(empty.GetUnicode(), eTypedBreak); // uses rules to figure out what to insert return TypedText(empty, eTypedBreak); // uses rules to figure out what to insert
} }
} }
else if (keyCode == nsIDOMKeyEvent::DOM_VK_ESCAPE) else if (keyCode == nsIDOMKeyEvent::DOM_VK_ESCAPE)
{ {
// pass escape keypresses through as empty strings: needed forime support // pass escape keypresses through as empty strings: needed forime support
nsString empty; nsString empty;
return TypedText(empty.GetUnicode(), eTypedText); return TypedText(empty, eTypedText);
} }
// if we got here we either fell out of the tab case or have a normal character. // if we got here we either fell out of the tab case or have a normal character.
@ -1140,7 +1139,7 @@ NS_IMETHODIMP nsHTMLEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
if (character && !altKey && !ctrlKey && !isShift && !metaKey) if (character && !altKey && !ctrlKey && !isShift && !metaKey)
{ {
nsAutoString key(character); nsAutoString key(character);
return TypedText(key.GetUnicode(), eTypedText); return TypedText(key, eTypedText);
} }
} }
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -1152,7 +1151,7 @@ NS_IMETHODIMP nsHTMLEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
to TypedText() to determine what action to take, but without passing to TypedText() to determine what action to take, but without passing
an event. an event.
*/ */
NS_IMETHODIMP nsHTMLEditor::TypedText(const PRUnichar* aString, NS_IMETHODIMP nsHTMLEditor::TypedText(const nsAReadableString& aString,
PRInt32 aAction) PRInt32 aAction)
{ {
nsAutoPlaceHolderBatch batch(this, gTypingTxnName); nsAutoPlaceHolderBatch batch(this, gTypingTxnName);
@ -1491,7 +1490,7 @@ nsHTMLEditor::CollapseSelectionToDeepestNonTableFirstChild(nsISelection *aSelect
// but we can't use that because it is selection-based and // but we can't use that because it is selection-based and
// the rules code won't let us edit under the <head> node // the rules code won't let us edit under the <head> node
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsString &aSourceToInsert) nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsAReadableString& aSourceToInsert)
{ {
nsCOMPtr<nsISelection> selection; nsCOMPtr<nsISelection> selection;
nsresult res = GetSelection(getter_AddRefs(selection)); nsresult res = GetSelection(getter_AddRefs(selection));
@ -1596,7 +1595,7 @@ nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsString &aSourceToInsert)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::RebuildDocumentFromSource(const nsString& aSourceString) nsHTMLEditor::RebuildDocumentFromSource(const nsAReadableString& aSourceString)
{ {
ForceCompositionEnd(); ForceCompositionEnd();
@ -1611,22 +1610,29 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsString& aSourceString)
// Find where the <body> tag starts. // Find where the <body> tag starts.
// If user mangled that, then abort // If user mangled that, then abort
PRInt32 bodyStart = aSourceString.Find(NS_ConvertASCIItoUCS2("<body"), PR_TRUE); nsReadingIterator<PRUnichar> beginbody;
if (bodyStart == -1) return NS_ERROR_FAILURE; nsReadingIterator<PRUnichar> endbody;
aSourceString.BeginReading(beginbody);
aSourceString.EndReading(endbody);
if (!FindInReadable(NS_LITERAL_STRING("<body"),beginbody,endbody))
return NS_ERROR_FAILURE;
PRInt32 headStart = aSourceString.Find(NS_ConvertASCIItoUCS2("<head"), PR_TRUE); nsReadingIterator<PRUnichar> beginhead;
if (headStart == -1) return NS_ERROR_FAILURE; nsReadingIterator<PRUnichar> endhead;
aSourceString.BeginReading(beginhead);
aSourceString.EndReading(endhead);
if (!FindInReadable(NS_LITERAL_STRING("<head"),beginhead,endhead))
return NS_ERROR_FAILURE;
nsReadingIterator<PRUnichar> beginclosehead;
nsReadingIterator<PRUnichar> endclosehead;
aSourceString.BeginReading(beginclosehead);
aSourceString.EndReading(endclosehead);
// Find the index after "<head>" // Find the index after "<head>"
PRInt32 headEnd = aSourceString.Find(NS_ConvertASCIItoUCS2("</head"), PR_TRUE); if (!FindInReadable(NS_LITERAL_STRING("</head"),beginclosehead,endclosehead))
beginclosehead = beginbody;
// We'll be forgiving and assume head ends before body // We'll be forgiving and assume head ends before body
if (headEnd == -1) headEnd = bodyStart;
nsAutoString headString;
aSourceString.Mid(headString, headStart, (headEnd - headStart));
nsAutoString bodyString;
aSourceString.Mid(bodyString, bodyStart, (aSourceString.Length() - bodyStart - 1));
// Time to change the document // Time to change the document
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
@ -1635,25 +1641,32 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsString& aSourceString)
res = SelectAll(); res = SelectAll();
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
res = InsertHTML(bodyString); nsReadingIterator<PRUnichar> endtotal;
aSourceString.EndReading(endtotal);
res = InsertHTML(Substring(beginbody,endtotal));
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
selection->Collapse(bodyElement, 0); selection->Collapse(bodyElement, 0);
res = ReplaceHeadContentsWithHTML(headString); res = ReplaceHeadContentsWithHTML(Substring(beginhead,beginclosehead));
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
// Now we must copy attributes user might have edited on the <body> tag // Now we must copy attributes user might have edited on the <body> tag
// because InsertHTML (actually, CreateContextualFragment()) // because InsertHTML (actually, CreateContextualFragment())
// will never return a body node in the DOM fragment // will never return a body node in the DOM fragment
nsAutoString bodyTag; nsReadingIterator<PRUnichar> beginclosebody = endbody;//<bodyX
nsReadingIterator<PRUnichar> endclosebody;
aSourceString.BeginReading(beginclosebody);
aSourceString.EndReading(endclosebody);
if (!FindInReadable(NS_LITERAL_STRING(">"),beginclosebody,endclosebody))
return NS_ERROR_FAILURE;
nsAutoString bodyTag(Substring(beginbody,endclosebody));//<bodyXXXX >
// Truncate at the end of the body tag // Truncate at the end of the body tag
PRInt32 bodyTagEnd = bodyString.FindChar((PRUnichar)'>', PR_FALSE, 5);
if (bodyTagEnd == -1) return NS_ERROR_FAILURE;
bodyString.Truncate(bodyTagEnd+1);
// Kludge of the year: fool the parser by replacing "body" with "div" so we get a node // Kludge of the year: fool the parser by replacing "body" with "div" so we get a node
bodyString.ToLowerCase(); bodyTag.ToLowerCase();
bodyString.ReplaceSubstring(NS_ConvertASCIItoUCS2("body"), NS_ConvertASCIItoUCS2("div")); bodyTag.ReplaceSubstring(NS_ConvertASCIItoUCS2("body"), NS_ConvertASCIItoUCS2("div"));
nsCOMPtr<nsIDOMRange> range; nsCOMPtr<nsIDOMRange> range;
res = selection->GetRangeAt(0, getter_AddRefs(range)); res = selection->GetRangeAt(0, getter_AddRefs(range));
@ -1663,7 +1676,7 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsString& aSourceString)
if (!nsrange) return NS_ERROR_NO_INTERFACE; if (!nsrange) return NS_ERROR_NO_INTERFACE;
nsCOMPtr<nsIDOMDocumentFragment> docfrag; nsCOMPtr<nsIDOMDocumentFragment> docfrag;
res = nsrange->CreateContextualFragment(bodyString, getter_AddRefs(docfrag)); res = nsrange->CreateContextualFragment(bodyTag, getter_AddRefs(docfrag));
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
nsCOMPtr<nsIDOMNode> fragmentAsNode (do_QueryInterface(docfrag)); nsCOMPtr<nsIDOMNode> fragmentAsNode (do_QueryInterface(docfrag));
@ -1876,7 +1889,7 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::SetParagraphFormat(const nsString& aParagraphFormat) nsHTMLEditor::SetParagraphFormat(const nsAReadableString& aParagraphFormat)
{ {
nsAutoString tag; tag.Assign(aParagraphFormat); nsAutoString tag; tag.Assign(aParagraphFormat);
tag.ToLowerCase(); tag.ToLowerCase();
@ -1923,7 +1936,7 @@ nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists)
else else
{ {
PRBool isBlock (PR_FALSE); PRBool isBlock (PR_FALSE);
NodeIsBlock(node, isBlock); NodeIsBlock(node, &isBlock);
if (isBlock) blockParent = node; if (isBlock) blockParent = node;
else blockParent = GetBlockNodeParent(node); else blockParent = GetBlockNodeParent(node);
blockParentElem = do_QueryInterface(blockParent); blockParentElem = do_QueryInterface(blockParent);
@ -2004,10 +2017,10 @@ nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists)
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetParagraphState(PRBool &aMixed, nsString &outFormat) nsHTMLEditor::GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat)
{ {
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
if (!aMixed) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules); nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules);
if (!htmlRules) return NS_ERROR_FAILURE; if (!htmlRules) return NS_ERROR_FAILURE;
@ -2015,11 +2028,12 @@ nsHTMLEditor::GetParagraphState(PRBool &aMixed, nsString &outFormat)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetBackgroundColorState(PRBool &aMixed, nsString &aOutColor) nsHTMLEditor::GetBackgroundColorState(PRBool *aMixed, nsAWritableString &aOutColor)
{ {
//TODO: We don't handle "mixed" correctly! //TODO: We don't handle "mixed" correctly!
aMixed = PR_FALSE; if (!aMixed) return NS_ERROR_NULL_POINTER;
aOutColor.AssignWithConversion(""); *aMixed = PR_FALSE;
aOutColor.Assign(NS_LITERAL_STRING(""));
nsCOMPtr<nsIDOMElement> element; nsCOMPtr<nsIDOMElement> element;
PRInt32 selectedCount; PRInt32 selectedCount;
@ -2059,10 +2073,10 @@ nsHTMLEditor::GetBackgroundColorState(PRBool &aMixed, nsString &aOutColor)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL) nsHTMLEditor::GetListState(PRBool *aMixed, PRBool *aOL, PRBool *aUL, PRBool *aDL)
{ {
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
if (!aMixed || !aOL || !aUL || !aDL) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules); nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules);
if (!htmlRules) return NS_ERROR_FAILURE; if (!htmlRules) return NS_ERROR_FAILURE;
@ -2070,9 +2084,10 @@ nsHTMLEditor::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD) nsHTMLEditor::GetListItemState(PRBool *aMixed, PRBool *aLI, PRBool *aDT, PRBool *aDD)
{ {
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
if (!aMixed || !aLI || !aDT || !aDD) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules); nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules);
if (!htmlRules) return NS_ERROR_FAILURE; if (!htmlRules) return NS_ERROR_FAILURE;
@ -2081,10 +2096,10 @@ nsHTMLEditor::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign) nsHTMLEditor::GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
{ {
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
if (!aMixed || !aAlign) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules); nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules);
if (!htmlRules) return NS_ERROR_FAILURE; if (!htmlRules) return NS_ERROR_FAILURE;
@ -2093,9 +2108,10 @@ nsHTMLEditor::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent) nsHTMLEditor::GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent)
{ {
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
if (!aCanIndent || !aCanOutdent) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules); nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules);
if (!htmlRules) return NS_ERROR_FAILURE; if (!htmlRules) return NS_ERROR_FAILURE;
@ -2104,7 +2120,7 @@ nsHTMLEditor::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::MakeOrChangeList(const nsString& aListType, PRBool entireList) nsHTMLEditor::MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList)
{ {
nsresult res; nsresult res;
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@ -2182,7 +2198,7 @@ nsHTMLEditor::MakeOrChangeList(const nsString& aListType, PRBool entireList)
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::RemoveList(const nsString& aListType) nsHTMLEditor::RemoveList(const nsAReadableString& aListType)
{ {
nsresult res; nsresult res;
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@ -2199,7 +2215,8 @@ nsHTMLEditor::RemoveList(const nsString& aListType)
if (!selection) return NS_ERROR_NULL_POINTER; if (!selection) return NS_ERROR_NULL_POINTER;
nsTextRulesInfo ruleInfo(nsTextEditRules::kRemoveList); nsTextRulesInfo ruleInfo(nsTextEditRules::kRemoveList);
if (aListType.EqualsWithConversion("ol")) ruleInfo.bOrdered = PR_TRUE; nsString tString(aListType);//MJUDGE SCC NEED HELP
if (tString.EqualsWithConversion("ol")) ruleInfo.bOrdered = PR_TRUE;
else ruleInfo.bOrdered = PR_FALSE; else ruleInfo.bOrdered = PR_FALSE;
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled); res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
if (cancel || (NS_FAILED(res))) return res; if (cancel || (NS_FAILED(res))) return res;
@ -2211,7 +2228,7 @@ nsHTMLEditor::RemoveList(const nsString& aListType)
} }
nsresult nsresult
nsHTMLEditor::MakeDefinitionItem(const nsString& aItemType) nsHTMLEditor::MakeDefinitionItem(const nsAReadableString& aItemType)
{ {
nsresult res; nsresult res;
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@ -2241,7 +2258,7 @@ nsHTMLEditor::MakeDefinitionItem(const nsString& aItemType)
} }
nsresult nsresult
nsHTMLEditor::InsertBasicBlock(const nsString& aBlockType) nsHTMLEditor::InsertBasicBlock(const nsAReadableString& aBlockType)
{ {
nsresult res; nsresult res;
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@ -2313,7 +2330,7 @@ nsHTMLEditor::InsertBasicBlock(const nsString& aBlockType)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::Indent(const nsString& aIndent) nsHTMLEditor::Indent(const nsAReadableString& aIndent)
{ {
nsresult res; nsresult res;
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@ -2321,7 +2338,8 @@ nsHTMLEditor::Indent(const nsString& aIndent)
PRBool cancel, handled; PRBool cancel, handled;
PRInt32 theAction = nsTextEditRules::kIndent; PRInt32 theAction = nsTextEditRules::kIndent;
PRInt32 opID = kOpIndent; PRInt32 opID = kOpIndent;
if (aIndent.EqualsWithConversion("outdent")) nsString tString(aIndent);//MJUDGE SCC NEED HELP
if (tString.EqualsWithConversion("outdent"))
{ {
theAction = nsTextEditRules::kOutdent; theAction = nsTextEditRules::kOutdent;
opID = kOpOutdent; opID = kOpOutdent;
@ -2384,7 +2402,7 @@ nsHTMLEditor::Indent(const nsString& aIndent)
// put a space in it so layout will draw the list item // put a space in it so layout will draw the list item
res = selection->Collapse(newBQ,0); res = selection->Collapse(newBQ,0);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
res = InsertText(NS_LITERAL_STRING(" ").get()); res = InsertText(NS_LITERAL_STRING(" "));
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
// reposition selection to before the space character // reposition selection to before the space character
res = GetStartNodeAndOffset(selection, address_of(node), &offset); res = GetStartNodeAndOffset(selection, address_of(node), &offset);
@ -2401,7 +2419,7 @@ nsHTMLEditor::Indent(const nsString& aIndent)
//TODO: IMPLEMENT ALIGNMENT! //TODO: IMPLEMENT ALIGNMENT!
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::Align(const nsString& aAlignType) nsHTMLEditor::Align(const nsAReadableString& aAlignType)
{ {
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, kOpAlign, nsIEditor::eNext); nsAutoRules beginRulesSniffing(this, kOpAlign, nsIEditor::eNext);
@ -2547,7 +2565,7 @@ NODE_FOUND:
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aReturn) nsHTMLEditor::GetSelectedElement(const nsAReadableString& aTagName, nsIDOMElement** aReturn)
{ {
if (!aReturn ) if (!aReturn )
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
@ -2895,8 +2913,8 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
if (href.GetUnicode() && href.Length() > 0) if (href.GetUnicode() && href.Length() > 0)
{ {
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsString attribute; attribute.AssignWithConversion("href"); nsString attribute(NS_LITERAL_STRING("href"));
SetInlineProperty(nsIEditProperty::a, &attribute, &href); SetInlineProperty(nsIEditProperty::a, attribute, href);
//TODO: Enumerate through other properties of the anchor tag //TODO: Enumerate through other properties of the anchor tag
// and set those as well. // and set those as well.
// Optimization: Modify SetTextProperty to set all attributes at once? // Optimization: Modify SetTextProperty to set all attributes at once?
@ -2907,7 +2925,7 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::SetBackgroundColor(const nsString& aColor) nsHTMLEditor::SetBackgroundColor(const nsAReadableString& aColor)
{ {
NS_PRECONDITION(mDocWeak, "Missing Editor DOM Document"); NS_PRECONDITION(mDocWeak, "Missing Editor DOM Document");
@ -2958,7 +2976,7 @@ nsHTMLEditor::SetBackgroundColor(const nsString& aColor)
return res; return res;
} }
NS_IMETHODIMP nsHTMLEditor::SetBodyAttribute(const nsString& aAttribute, const nsString& aValue) NS_IMETHODIMP nsHTMLEditor::SetBodyAttribute(const nsAReadableString& aAttribute, const nsAReadableString& aValue)
{ {
nsresult res; nsresult res;
// TODO: Check selection for Cell, Row, Column or table and do color on appropriate level // TODO: Check selection for Cell, Row, Column or table and do color on appropriate level
@ -3056,20 +3074,20 @@ nsHTMLEditor::RemoveOverrideStyleSheet(nsICSSStyleSheet* aSheet)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::ApplyOverrideStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet) nsHTMLEditor::ApplyOverrideStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet)
{ {
return ApplyDocumentOrOverrideStyleSheet(aURL, PR_TRUE, aStyleSheet); return ApplyDocumentOrOverrideStyleSheet(aURL, PR_TRUE, aStyleSheet);
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet) nsHTMLEditor::ApplyStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet)
{ {
return ApplyDocumentOrOverrideStyleSheet(aURL, PR_FALSE, aStyleSheet); return ApplyDocumentOrOverrideStyleSheet(aURL, PR_FALSE, aStyleSheet);
} }
//Note: Loading a document style sheet is undoable, loading an override sheet is not //Note: Loading a document style sheet is undoable, loading an override sheet is not
nsresult nsresult
nsHTMLEditor::ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet) nsHTMLEditor::ApplyDocumentOrOverrideStyleSheet(const nsAReadableString& aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet)
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
nsCOMPtr<nsIURI> uaURL; nsCOMPtr<nsIURI> uaURL;
@ -3273,7 +3291,7 @@ static nsresult SetSelectionAroundHeadChildren(nsCOMPtr<nsISelection> aSelection
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetHeadContentsAsHTML(nsString& aOutputString) nsHTMLEditor::GetHeadContentsAsHTML(nsAWritableString& aOutputString)
{ {
nsCOMPtr<nsISelection> selection; nsCOMPtr<nsISelection> selection;
nsresult res = GetSelection(getter_AddRefs(selection)); nsresult res = GetSelection(getter_AddRefs(selection));
@ -3292,15 +3310,27 @@ nsHTMLEditor::GetHeadContentsAsHTML(nsString& aOutputString)
{ {
// Selection always includes <body></body>, // Selection always includes <body></body>,
// so terminate there // so terminate there
PRInt32 offset = aOutputString.Find(NS_ConvertASCIItoUCS2("<body"), PR_TRUE); nsReadingIterator<PRUnichar> findIter,endFindIter;
if (offset > 0) aOutputString.BeginReading(findIter);
aOutputString.EndReading(endFindIter);
//counting on our parser to always lower case!!!
if (FindInReadable(NS_LITERAL_STRING("<body"),findIter,endFindIter))
{ {
nsReadingIterator<PRUnichar> beginIter;
aOutputString.BeginReading(beginIter);
PRInt32 offset = Distance(beginIter, findIter);//get the distance
nsWritingIterator<PRUnichar> writeIter;
aOutputString.BeginWriting(writeIter);
// Ensure the string ends in a newline // Ensure the string ends in a newline
PRUnichar newline ('\n'); PRUnichar newline ('\n');
if (aOutputString.CharAt(offset-1) != newline) findIter.advance(-1);
aOutputString.SetCharAt(newline, offset++); if (offset ==0 || (offset >0 && (*findIter) != newline)) //check for 0
{
aOutputString.Truncate(offset); writeIter.advance(offset);
*writeIter = newline;
aOutputString.Truncate(offset+1);
}
} }
} }
return res; return res;
@ -3332,7 +3362,7 @@ nsHTMLEditor::DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed)
#endif #endif
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply) nsHTMLEditor::SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply)
{ {
NS_ASSERTION(aTextRangeList, "null ptr"); NS_ASSERTION(aTextRangeList, "null ptr");
if(nsnull == aTextRangeList) if(nsnull == aTextRangeList)
@ -3355,7 +3385,7 @@ nsHTMLEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivat
mIMETextRangeList = aTextRangeList; mIMETextRangeList = aTextRangeList;
nsAutoPlaceHolderBatch batch(this, gIMETxnName); nsAutoPlaceHolderBatch batch(this, gIMETxnName);
result = InsertText(aCompositionString.GetUnicode()); result = InsertText(aCompositionString);
mIMEBufferLength = aCompositionString.Length(); mIMEBufferLength = aCompositionString.Length();
@ -3492,28 +3522,29 @@ nsHTMLEditor::EndOperation()
} }
PRBool PRBool
nsHTMLEditor::TagCanContainTag(const nsString &aParentTag, const nsString &aChildTag) nsHTMLEditor::TagCanContainTag(const nsAReadableString& aParentTag, const nsAReadableString& aChildTag)
{ {
// COtherDTD gives some unwanted results. We override them here. // COtherDTD gives some unwanted results. We override them here.
nsAutoString olStr, ulStr, liStr; nsAutoString olStr, ulStr, liStr;
olStr = NS_LITERAL_STRING("ol"); olStr = NS_LITERAL_STRING("ol");
ulStr = NS_LITERAL_STRING("ul"); ulStr = NS_LITERAL_STRING("ul");
liStr = NS_LITERAL_STRING("li"); liStr = NS_LITERAL_STRING("li");
nsString tParent(aParentTag);//MJUDGE SCC NEED HELP
if ( aParentTag.EqualsIgnoreCase(olStr) || nsString tChild(aChildTag);//MJUDGE SCC NEED HELP
aParentTag.EqualsIgnoreCase(ulStr) ) if ( tParent.EqualsIgnoreCase(olStr) ||
tParent.EqualsIgnoreCase(ulStr) )
{ {
// if parent is a list and tag is also a list, say "yes". // if parent is a list and tag is also a list, say "yes".
// This is because the editor does sublists illegally for now. // This is because the editor does sublists illegally for now.
if (aChildTag.EqualsIgnoreCase(olStr) || if (tChild.EqualsIgnoreCase(olStr) ||
aChildTag.EqualsIgnoreCase(ulStr) ) tChild.EqualsIgnoreCase(ulStr) )
return PR_TRUE; return PR_TRUE;
} }
if ( aParentTag.EqualsIgnoreCase(liStr) ) if ( tParent.EqualsIgnoreCase(liStr) )
{ {
// list items cant contain list items // list items cant contain list items
if (aChildTag.EqualsIgnoreCase(liStr) ) if (tChild.EqualsIgnoreCase(liStr) )
return PR_FALSE; return PR_FALSE;
} }
@ -3607,8 +3638,8 @@ NS_IMETHODIMP nsHTMLEditor::GetLayoutObject(nsIDOMNode *aNode, nsISupports **aLa
// so singleton attributes like <Table border> will not be matched! // so singleton attributes like <Table border> will not be matched!
void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode *aNode, void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode *aNode,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString *aAttribute,
const nsString *aValue, const nsAReadableString *aValue,
PRBool &aIsSet, PRBool &aIsSet,
nsIDOMNode **aStyleNode, nsIDOMNode **aStyleNode,
nsString *outValue) const nsString *outValue) const
@ -3639,11 +3670,15 @@ void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode *aNode,
if (!aValue) { if (!aValue) {
found = PR_TRUE; found = PR_TRUE;
} }
else if (aValue->EqualsIgnoreCase(value)) { else
found = PR_TRUE; {
} nsString tString(*aValue);
else { // we found the prop with the attribute, but the value doesn't match if (tString.EqualsIgnoreCase(value)) {
break; found = PR_TRUE;
}
else { // we found the prop with the attribute, but the value doesn't match
break;
}
} }
} }
} }
@ -3670,7 +3705,7 @@ void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode *aNode,
void nsHTMLEditor::IsTextStyleSet(nsIStyleContext *aSC, void nsHTMLEditor::IsTextStyleSet(nsIStyleContext *aSC,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString *aAttribute,
PRBool &aIsSet) const PRBool &aIsSet) const
{ {
aIsSet = PR_FALSE; aIsSet = PR_FALSE;
@ -3969,7 +4004,7 @@ nsHTMLEditor::CollapseAdjacentTextNodes(nsIDOMRange *aInRange)
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetNextElementByTagName(nsIDOMElement *aCurrentElement, nsHTMLEditor::GetNextElementByTagName(nsIDOMElement *aCurrentElement,
const nsString *aTagName, const nsAReadableString *aTagName,
nsIDOMElement **aReturn) nsIDOMElement **aReturn)
{ {
nsresult res = NS_OK; nsresult res = NS_OK;

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

@ -99,72 +99,75 @@ public:
/* ------------ nsIHTMLEditor methods -------------- */ /* ------------ nsIHTMLEditor methods -------------- */
NS_IMETHOD SetInlineProperty(nsIAtom *aProperty, NS_IMETHOD SetInlineProperty(nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString & aAttribute,
const nsString *aValue); const nsAReadableString & aValue);
NS_IMETHOD GetInlineProperty(nsIAtom *aProperty, NS_IMETHOD GetInlineProperty(nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString & aAttribute,
const nsString *aValue, const nsAReadableString & aValue,
PRBool &aFirst, PRBool &aAny, PRBool &aAll); PRBool *aFirst,
PRBool *aAny,
PRBool *aAll);
NS_IMETHOD GetInlinePropertyWithAttrValue(nsIAtom *aProperty, NS_IMETHOD GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString &aAttribute,
const nsString *aValue, const nsAReadableString &aValue,
PRBool &aFirst, PRBool &aAny, PRBool &aAll, PRBool *aFirst,
nsString *outValue); PRBool *aAny,
PRBool *aAll,
nsAWritableString &outValue);
NS_IMETHOD RemoveAllInlineProperties(); NS_IMETHOD RemoveAllInlineProperties();
NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute); NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsAReadableString & aAttribute);
NS_IMETHOD IncreaseFontSize(); NS_IMETHOD IncreaseFontSize();
NS_IMETHOD DecreaseFontSize(); NS_IMETHOD DecreaseFontSize();
NS_IMETHOD InsertHTML(const nsString &aInputString); NS_IMETHOD InsertHTML(const nsAReadableString &aInputString);
NS_IMETHOD InsertHTMLWithCharset(const nsString& aInputString, NS_IMETHOD InsertHTMLWithCharset(const nsAReadableString& aInputString,
const nsString& aCharset); const nsAReadableString& aCharset);
NS_IMETHOD RebuildDocumentFromSource(const nsString& aSourceString); NS_IMETHOD RebuildDocumentFromSource(const nsAReadableString& aSourceString);
NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection); NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection);
NS_IMETHOD SelectElement(nsIDOMElement* aElement); NS_IMETHOD SelectElement(nsIDOMElement* aElement);
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement); NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement);
NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat); NS_IMETHOD SetParagraphFormat(const nsAReadableString& aParagraphFormat);
NS_IMETHOD GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists); NS_IMETHOD GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists);
NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat); NS_IMETHOD GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat);
NS_IMETHOD GetFontFaceState(PRBool &aMixed, nsString &outFace); NS_IMETHOD GetFontFaceState(PRBool *aMixed, nsAWritableString &outFace);
NS_IMETHOD GetFontColorState(PRBool &aMixed, nsString &outColor); NS_IMETHOD GetFontColorState(PRBool *aMixed, nsAWritableString &outColor);
NS_IMETHOD GetBackgroundColorState(PRBool &aMixed, nsString &outColor); NS_IMETHOD GetBackgroundColorState(PRBool *aMixed, nsAWritableString &outColor);
NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL); NS_IMETHOD GetListState(PRBool *aMixed, PRBool *aOL, PRBool *aUL, PRBool *aDL);
NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD); NS_IMETHOD GetListItemState(PRBool *aMixed, PRBool *aLI, PRBool *aDT, PRBool *aDD);
NS_IMETHOD GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign); NS_IMETHOD GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign);
NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent); NS_IMETHOD GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent);
NS_IMETHOD MakeOrChangeList(const nsString& aListType, PRBool entireList); NS_IMETHOD MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList);
NS_IMETHOD RemoveList(const nsString& aListType); NS_IMETHOD RemoveList(const nsAReadableString& aListType);
NS_IMETHOD Indent(const nsString& aIndent); NS_IMETHOD Indent(const nsAReadableString& aIndent);
NS_IMETHOD Align(const nsString& aAlign); NS_IMETHOD Align(const nsAReadableString& aAlign);
NS_IMETHOD GetElementOrParentByTagName(const nsAReadableString& aTagName, nsIDOMNode *aNode, nsIDOMElement** aReturn); NS_IMETHOD GetElementOrParentByTagName(const nsAReadableString& aTagName, nsIDOMNode *aNode, nsIDOMElement** aReturn);
NS_IMETHOD GetSelectedElement(const nsString& aTagName, nsIDOMElement** aReturn); NS_IMETHOD GetSelectedElement(const nsAReadableString& aTagName, nsIDOMElement** aReturn);
NS_IMETHOD CreateElementWithDefaults(const nsAReadableString& aTagName, nsIDOMElement** aReturn); NS_IMETHOD CreateElementWithDefaults(const nsAReadableString& aTagName, nsIDOMElement** aReturn);
NS_IMETHOD GetNextElementByTagName(nsIDOMElement *aCurrentElement, const nsString *aTagName, nsIDOMElement **aReturn); NS_IMETHOD GetNextElementByTagName(nsIDOMElement *aCurrentElement, const nsAReadableString *aTagName, nsIDOMElement **aReturn);
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement); NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
/* ------------ nsIEditorIMESupport overrides -------------- */ /* ------------ nsIEditorIMESupport overrides -------------- */
NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply); NS_IMETHOD SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply);
NS_IMETHOD GetReconversionString(nsReconversionEventReply* aReply); NS_IMETHOD GetReconversionString(nsReconversionEventReply* aReply);
/* ------------ nsIEditorStyleSheets methods -------------- */ /* ------------ nsIEditorStyleSheets methods -------------- */
NS_IMETHOD ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet); NS_IMETHOD ApplyStyleSheet(const nsAReadableString & aURL, nsICSSStyleSheet **aStyleSheet);
NS_IMETHOD ApplyOverrideStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet); NS_IMETHOD ApplyOverrideStyleSheet(const nsAReadableString & aURL, nsICSSStyleSheet **aStyleSheet);
/* Above 2 methods call this with appropriate aOverride value /* Above 2 methods call this with appropriate aOverride value
* Not exposed to IDL interface * Not exposed to IDL interface
*/ */
nsresult ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet); nsresult ApplyDocumentOrOverrideStyleSheet(const nsAReadableString & aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet);
NS_IMETHOD AddStyleSheet(nsICSSStyleSheet* aSheet); NS_IMETHOD AddStyleSheet(nsICSSStyleSheet* aSheet);
NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet); NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet);
NS_IMETHOD RemoveOverrideStyleSheet(nsICSSStyleSheet* aSheet); NS_IMETHOD RemoveOverrideStyleSheet(nsICSSStyleSheet* aSheet);
@ -172,13 +175,13 @@ public:
/* ------------ nsIEditorMailSupport methods -------------- */ /* ------------ nsIEditorMailSupport methods -------------- */
NS_IMETHOD PasteAsQuotation(PRInt32 aSelectionType); NS_IMETHOD PasteAsQuotation(PRInt32 aSelectionType);
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, nsIDOMNode **aNodeInserted); NS_IMETHOD InsertAsQuotation(const nsAReadableString & aQuotedText, nsIDOMNode **aNodeInserted);
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation, NS_IMETHOD PasteAsCitedQuotation(const nsAReadableString & aCitation,
PRInt32 aSelectionType); PRInt32 aSelectionType);
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, NS_IMETHOD InsertAsCitedQuotation(const nsAReadableString & aQuotedText,
const nsString& aCitation, const nsAReadableString & aCitation,
PRBool aInsertHTML, PRBool aInsertHTML,
const nsString& aCharset, const nsAReadableString & aCharset,
nsIDOMNode **aNodeInserted); nsIDOMNode **aNodeInserted);
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList); NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList);
@ -240,10 +243,11 @@ public:
/* miscellaneous */ /* miscellaneous */
// This sets background on the appropriate container element (table, cell,) // This sets background on the appropriate container element (table, cell,)
// or calls into nsTextEditor to set the page background // or calls into nsTextEditor to set the page background
NS_IMETHOD SetBackgroundColor(const nsString& aColor); NS_IMETHOD SetBackgroundColor(const nsAReadableString& aColor);
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue); NS_IMETHOD SetBodyAttribute(const nsAReadableString& aAttr, const nsAReadableString& aValue);
// aTitle may be null or empty string to remove child contents of <title> // aTitle may be null or empty string to remove child contents of <title>
NS_IMETHOD SetDocumentTitle(const PRUnichar *aTitle);
NS_IMETHOD SetDocumentTitle(const nsAReadableString &aTitle);
/* ------------ Block methods moved from nsEditor -------------- */ /* ------------ Block methods moved from nsEditor -------------- */
static nsCOMPtr<nsIDOMNode> GetBlockNodeParent(nsIDOMNode *aNode); static nsCOMPtr<nsIDOMNode> GetBlockNodeParent(nsIDOMNode *aNode);
@ -301,10 +305,10 @@ public:
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, nsIContent *aRoot, nsISelectionController *aSelCon, PRUint32 aFlags); NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, nsIContent *aRoot, nsISelectionController *aSelCon, PRUint32 aFlags);
/** Internal, static version */ /** Internal, static version */
static nsresult NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock); static nsresult NodeIsBlockStatic(nsIDOMNode *aNode, PRBool *aIsBlock);
/** This version is for exposure to JavaScript */ /** This version is for exposure to JavaScript */
NS_IMETHOD NodeIsBlock(nsIDOMNode *aNode, PRBool &aIsBlock); NS_IMETHOD NodeIsBlock(nsIDOMNode *aNode, PRBool *aIsBlock);
/** we override this here to install event listeners */ /** we override this here to install event listeners */
NS_IMETHOD PostCreate(); NS_IMETHOD PostCreate();
@ -313,14 +317,14 @@ public:
NS_IMETHOD SetFlags(PRUint32 aFlags); NS_IMETHOD SetFlags(PRUint32 aFlags);
NS_IMETHOD Paste(PRInt32 aSelectionType); NS_IMETHOD Paste(PRInt32 aSelectionType);
NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste); NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste);
NS_IMETHOD CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag); NS_IMETHOD CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag);
NS_IMETHOD DoDrag(nsIDOMEvent *aDragEvent); NS_IMETHOD DoDrag(nsIDOMEvent *aDragEvent);
NS_IMETHOD InsertFromDrop(nsIDOMEvent* aDropEvent); NS_IMETHOD InsertFromDrop(nsIDOMEvent* aDropEvent);
NS_IMETHOD GetHeadContentsAsHTML(nsString& aOutputString); NS_IMETHOD GetHeadContentsAsHTML(nsAWritableString& aOutputString);
NS_IMETHOD ReplaceHeadContentsWithHTML(const nsString &aSourceToInsert); NS_IMETHOD ReplaceHeadContentsWithHTML(const nsAReadableString &aSourceToInsert);
NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed); NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
@ -333,7 +337,7 @@ public:
NS_IMETHOD EndOperation(); NS_IMETHOD EndOperation();
/** returns PR_TRUE if aParentTag can contain a child of type aChildTag */ /** returns PR_TRUE if aParentTag can contain a child of type aChildTag */
virtual PRBool TagCanContainTag(const nsString &aParentTag, const nsString &aChildTag); virtual PRBool TagCanContainTag(const nsAReadableString& aParentTag, const nsAReadableString& aChildTag);
/** make the given selection span the entire document */ /** make the given selection span the entire document */
NS_IMETHOD SelectEntireDocument(nsISelection *aSelection); NS_IMETHOD SelectEntireDocument(nsISelection *aSelection);
@ -345,7 +349,7 @@ public:
NS_IMETHOD StyleSheetLoaded(nsICSSStyleSheet*aSheet, PRBool aNotify); NS_IMETHOD StyleSheetLoaded(nsICSSStyleSheet*aSheet, PRBool aNotify);
/* ------------ Utility Routines, not part of public API -------------- */ /* ------------ Utility Routines, not part of public API -------------- */
NS_IMETHOD TypedText(const PRUnichar* aString, PRInt32 aAction); NS_IMETHOD TypedText(const nsAReadableString& aString, PRInt32 aAction);
nsresult InsertNodeAtPoint(nsIDOMNode *aNode, nsresult InsertNodeAtPoint(nsIDOMNode *aNode,
nsIDOMNode *aParent, nsIDOMNode *aParent,
PRInt32 aOffset, PRInt32 aOffset,
@ -512,8 +516,8 @@ protected:
*/ */
virtual void IsTextPropertySetByContent(nsIDOMNode *aNode, virtual void IsTextPropertySetByContent(nsIDOMNode *aNode,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString *aAttribute,
const nsString *aValue, const nsAReadableString *aValue,
PRBool &aIsSet, PRBool &aIsSet,
nsIDOMNode **aStyleNode, nsIDOMNode **aStyleNode,
nsString *outValue = nsnull) const; nsString *outValue = nsnull) const;
@ -523,7 +527,7 @@ protected:
*/ */
virtual void IsTextStyleSet(nsIStyleContext *aSC, virtual void IsTextStyleSet(nsIStyleContext *aSC,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttributes, const nsAReadableString *aAttributes,
PRBool &aIsSet) const; PRBool &aIsSet) const;
@ -534,26 +538,26 @@ protected:
// Methods for handling plaintext quotations // Methods for handling plaintext quotations
NS_IMETHOD PasteAsPlaintextQuotation(PRInt32 aSelectionType); NS_IMETHOD PasteAsPlaintextQuotation(PRInt32 aSelectionType);
NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText, NS_IMETHOD InsertAsPlaintextQuotation(const nsAReadableString & aQuotedText,
nsIDOMNode **aNodeInserted); nsIDOMNode **aNodeInserted);
// factored methods for handling insertion of data from transferables (drag&drop or clipboard) // factored methods for handling insertion of data from transferables (drag&drop or clipboard)
NS_IMETHOD PrepareTransferable(nsITransferable **transferable); NS_IMETHOD PrepareTransferable(nsITransferable **transferable);
NS_IMETHOD InsertFromTransferable(nsITransferable *transferable, NS_IMETHOD InsertFromTransferable(nsITransferable *transferable,
const nsString& aContextStr, const nsAReadableString & aContextStr,
const nsString& aInfoStr); const nsAReadableString & aInfoStr);
nsresult InsertHTMLWithContext(const nsString& aInputString, nsresult InsertHTMLWithContext(const nsAReadableString & aInputString,
const nsString& aContextStr, const nsAReadableString & aContextStr,
const nsString& aInfoStr); const nsAReadableString & aInfoStr);
nsresult InsertHTMLWithCharsetAndContext(const nsString& aInputString, nsresult InsertHTMLWithCharsetAndContext(const nsAReadableString & aInputString,
const nsString& aCharset, const nsAReadableString & aCharset,
const nsString& aContextStr, const nsAReadableString & aContextStr,
const nsString& aInfoStr); const nsAReadableString & aInfoStr);
nsresult StripFormattingNodes(nsIDOMNode *aNode); nsresult StripFormattingNodes(nsIDOMNode *aNode);
nsresult CreateDOMFragmentFromPaste(nsIDOMNSRange *aNSRange, nsresult CreateDOMFragmentFromPaste(nsIDOMNSRange *aNSRange,
const nsString& aInputString, const nsAReadableString & aInputString,
const nsString& aContextStr, const nsAReadableString & aContextStr,
const nsString& aInfoStr, const nsAReadableString & aInfoStr,
nsCOMPtr<nsIDOMNode> *outFragNode, nsCOMPtr<nsIDOMNode> *outFragNode,
PRInt32 *outRangeStartHint, PRInt32 *outRangeStartHint,
PRInt32 *outRangeEndHint); PRInt32 *outRangeEndHint);
@ -569,8 +573,8 @@ protected:
PRBool IsModifiable(); PRBool IsModifiable();
/* helpers for block transformations */ /* helpers for block transformations */
nsresult MakeDefinitionItem(const nsString& aItemType); nsresult MakeDefinitionItem(const nsAReadableString & aItemType);
nsresult InsertBasicBlock(const nsString& aBlockType); nsresult InsertBasicBlock(const nsAReadableString & aBlockType);
/* increase/decrease the font size of selection */ /* increase/decrease the font size of selection */
nsresult RelativeFontChange( PRInt32 aSizeChange); nsresult RelativeFontChange( PRInt32 aSizeChange);
@ -588,35 +592,35 @@ protected:
PRInt32 aStartOffset, PRInt32 aStartOffset,
PRInt32 aEndOffset, PRInt32 aEndOffset,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString *aAttribute,
const nsString *aValue); const nsAReadableString *aValue);
nsresult SetInlinePropertyOnNode( nsIDOMNode *aNode, nsresult SetInlinePropertyOnNode( nsIDOMNode *aNode,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString *aAttribute,
const nsString *aValue); const nsAReadableString *aValue);
nsresult PromoteInlineRange(nsIDOMRange *inRange); nsresult PromoteInlineRange(nsIDOMRange *inRange);
nsresult SplitStyleAboveRange(nsIDOMRange *aRange, nsresult SplitStyleAboveRange(nsIDOMRange *aRange,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute); const nsAReadableString *aAttribute);
nsresult SplitStyleAbovePoint(nsCOMPtr<nsIDOMNode> *aNode, nsresult SplitStyleAbovePoint(nsCOMPtr<nsIDOMNode> *aNode,
PRInt32 *aOffset, PRInt32 *aOffset,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString *aAttribute,
nsCOMPtr<nsIDOMNode> *outLeftNode = nsnull, nsCOMPtr<nsIDOMNode> *outLeftNode = nsnull,
nsCOMPtr<nsIDOMNode> *outRightNode = nsnull); nsCOMPtr<nsIDOMNode> *outRightNode = nsnull);
nsresult RemoveStyleInside(nsIDOMNode *aNode, nsresult RemoveStyleInside(nsIDOMNode *aNode,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString *aAttribute,
PRBool aChildrenOnly = PR_FALSE); PRBool aChildrenOnly = PR_FALSE);
nsresult RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsString *aAttribute); nsresult RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAReadableString *aAttribute);
PRBool NodeIsProperty(nsIDOMNode *aNode); PRBool NodeIsProperty(nsIDOMNode *aNode);
PRBool HasAttr(nsIDOMNode *aNode, const nsString *aAttribute); PRBool HasAttr(nsIDOMNode *aNode, const nsAReadableString *aAttribute);
PRBool HasAttrVal(nsIDOMNode *aNode, const nsString *aAttribute, const nsString *aValue); PRBool HasAttrVal(nsIDOMNode *aNode, const nsAReadableString *aAttribute, const nsAReadableString *aValue);
PRBool IsAtFrontOfNode(nsIDOMNode *aNode, PRInt32 aOffset); PRBool IsAtFrontOfNode(nsIDOMNode *aNode, PRInt32 aOffset);
PRBool IsAtEndOfNode(nsIDOMNode *aNode, PRInt32 aOffset); PRBool IsAtEndOfNode(nsIDOMNode *aNode, PRInt32 aOffset);
PRBool IsOnlyAttribute(nsIDOMNode *aElement, const nsString *aAttribute); PRBool IsOnlyAttribute(nsIDOMNode *aElement, const nsAReadableString *aAttribute);
PRBool HasMatchingAttributes(nsIDOMNode *aNode1, PRBool HasMatchingAttributes(nsIDOMNode *aNode1,
nsIDOMNode *aNode2); nsIDOMNode *aNode2);
@ -642,6 +646,14 @@ protected:
PRBool mIgnoreSpuriousDragEvent; PRBool mIgnoreSpuriousDragEvent;
NS_IMETHOD IgnoreSpuriousDragEvent(PRBool aIgnoreSpuriousDragEvent) {mIgnoreSpuriousDragEvent = aIgnoreSpuriousDragEvent; return NS_OK;} NS_IMETHOD IgnoreSpuriousDragEvent(PRBool aIgnoreSpuriousDragEvent) {mIgnoreSpuriousDragEvent = aIgnoreSpuriousDragEvent; return NS_OK;}
nsresult GetInlinePropertyBase(nsIAtom *aProperty,
const nsAReadableString *aAttribute,
const nsAReadableString *aValue,
PRBool *aFirst,
PRBool *aAny,
PRBool *aAll,
nsAWritableString *outValue);
// Data members // Data members
protected: protected:

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

@ -54,7 +54,7 @@ nsHTMLEditorLog::~nsHTMLEditorLog()
NS_IMPL_ISUPPORTS_INHERITED(nsHTMLEditorLog, nsHTMLEditor, nsIEditorLogging); NS_IMPL_ISUPPORTS_INHERITED(nsHTMLEditorLog, nsHTMLEditor, nsIEditorLogging);
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::SetInlineProperty(nsIAtom *aProperty, const nsString *aAttribute, const nsString *aValue) nsHTMLEditorLog::SetInlineProperty(nsIAtom *aProperty, const nsAReadableString &aAttribute, const nsAReadableString &aValue)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -68,11 +68,11 @@ nsHTMLEditorLog::SetInlineProperty(nsIAtom *aProperty, const nsString *aAttribut
Write("window.editorShell.SetTextProperty(\""); Write("window.editorShell.SetTextProperty(\"");
PrintUnicode(propStr); PrintUnicode(propStr);
Write("\", \""); Write("\", \"");
if (aAttribute) if (aAttribute.Length())
PrintUnicode(*aAttribute); PrintUnicode(aAttribute);
Write("\", \""); Write("\", \"");
if (aValue) if (aValue.Length())
PrintUnicode(*aValue); PrintUnicode(aValue);
Write("\");\n"); Write("\");\n");
Flush(); Flush();
@ -100,7 +100,7 @@ nsHTMLEditorLog::SetParagraphFormat(const nsString& aParagraphFormat)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute) nsHTMLEditorLog::RemoveInlineProperty(nsIAtom *aProperty, const nsAReadableString &aAttribute)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -114,8 +114,8 @@ nsHTMLEditorLog::RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttri
Write("window.editorShell.RemoveTextProperty(\""); Write("window.editorShell.RemoveTextProperty(\"");
PrintUnicode(propStr); PrintUnicode(propStr);
Write("\", \""); Write("\", \"");
if (aAttribute) if (aAttribute.Length())
PrintUnicode(*aAttribute); PrintUnicode(aAttribute);
Write("\");\n"); Write("\");\n");
Flush(); Flush();
@ -143,7 +143,7 @@ nsHTMLEditorLog::DeleteSelection(nsIEditor::EDirection aAction)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::InsertText(const PRUnichar* aStringToInsert) nsHTMLEditorLog::InsertText(const nsAReadableString& aStringToInsert)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -351,7 +351,7 @@ nsHTMLEditorLog::PasteAsPlaintextQuotation(PRInt32 aSelectionType)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::PasteAsCitedQuotation(const nsString& aCitation, nsHTMLEditorLog::PasteAsCitedQuotation(const nsAReadableString& aCitation,
PRInt32 aSelectionType) PRInt32 aSelectionType)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -369,7 +369,7 @@ nsHTMLEditorLog::PasteAsCitedQuotation(const nsString& aCitation,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::InsertAsQuotation(const nsString& aQuotedText, nsHTMLEditorLog::InsertAsQuotation(const nsAReadableString& aQuotedText,
nsIDOMNode **aNodeInserted) nsIDOMNode **aNodeInserted)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -387,7 +387,7 @@ nsHTMLEditorLog::InsertAsQuotation(const nsString& aQuotedText,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsString& aQuotedText, nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsAReadableString& aQuotedText,
nsIDOMNode **aNodeInserted) nsIDOMNode **aNodeInserted)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -405,10 +405,10 @@ nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsString& aQuotedText,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::InsertAsCitedQuotation(const nsString& aQuotedText, nsHTMLEditorLog::InsertAsCitedQuotation(const nsAReadableString& aQuotedText,
const nsString& aCitation, const nsAReadableString& aCitation,
PRBool aInsertHTML, PRBool aInsertHTML,
const nsString& aCharset, const nsAReadableString& aCharset,
nsIDOMNode **aNodeInserted) nsIDOMNode **aNodeInserted)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -429,7 +429,7 @@ nsHTMLEditorLog::InsertAsCitedQuotation(const nsString& aQuotedText,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::SetBackgroundColor(const nsString& aColor) nsHTMLEditorLog::SetBackgroundColor(const nsAReadableString& aColor)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -445,7 +445,7 @@ nsHTMLEditorLog::SetBackgroundColor(const nsString& aColor)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::SetBodyAttribute(const nsString& aAttr, const nsString& aValue) nsHTMLEditorLog::SetBodyAttribute(const nsAReadableString& aAttr, const nsAReadableString& aValue)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -644,7 +644,7 @@ nsHTMLEditorLog::SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMEle
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::MakeOrChangeList(const nsString& aListType, PRBool entireList) nsHTMLEditorLog::MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -662,7 +662,7 @@ nsHTMLEditorLog::MakeOrChangeList(const nsString& aListType, PRBool entireList)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::Indent(const nsString& aIndent) nsHTMLEditorLog::Indent(const nsAReadableString& aIndent)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -680,7 +680,7 @@ nsHTMLEditorLog::Indent(const nsString& aIndent)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::Align(const nsString& aAlign) nsHTMLEditorLog::Align(const nsAReadableString& aAlign)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -748,7 +748,7 @@ nsHTMLEditorLog::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet) nsHTMLEditorLog::ApplyStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -769,7 +769,7 @@ nsHTMLEditorLog::ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyle
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::SetDocumentTitle(const PRUnichar* aTitle) nsHTMLEditorLog::SetDocumentTitle(const nsAReadableString& aTitle)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -912,23 +912,25 @@ nsHTMLEditorLog::Flush()
} }
nsresult nsresult
nsHTMLEditorLog::PrintUnicode(const nsString &aString) nsHTMLEditorLog::PrintUnicode(const nsAReadableString &aString)
{ {
const PRUnichar *uc = aString.GetUnicode(); //const PRUnichar *uc = aString.GetUnicode();
PRInt32 i, len = aString.Length();
char buf[10]; char buf[10];
nsReadingIterator <PRUnichar> beginIter,endIter;
for (i = 0; i < len; i++) aString.BeginReading(beginIter);
aString.EndReading(endIter);
while(beginIter != endIter)
{ {
if (nsCRT::IsAsciiAlpha(uc[i]) || nsCRT::IsAsciiDigit(uc[i]) || uc[i] == ' ') if (nsCRT::IsAsciiAlpha(*beginIter) || nsCRT::IsAsciiDigit(*beginIter) || *beginIter == ' ')
sprintf(buf, "%c", uc[i]); sprintf(buf, "%c", *beginIter);
else else
sprintf(buf, "\\u%.4x", uc[i]); sprintf(buf, "\\u%.4x", *beginIter);
nsresult result = Write(buf); nsresult result = Write(buf);
if (NS_FAILED(result)) if (NS_FAILED(result))
return result; return result;
++beginIter;
} }
return NS_OK; return NS_OK;

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

@ -54,12 +54,12 @@ public:
/* nsIHTMLEditor method implementations. */ /* nsIHTMLEditor method implementations. */
NS_IMETHOD SetInlineProperty(nsIAtom *aProperty, NS_IMETHOD SetInlineProperty(nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString & aAttribute,
const nsString *aValue); const nsAReadableString & aValue);
NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat); NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat);
NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute); NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsAReadableString& aAttribute);
NS_IMETHOD DeleteSelection(nsIEditor::EDirection aAction); NS_IMETHOD DeleteSelection(nsIEditor::EDirection aAction);
NS_IMETHOD InsertText(const PRUnichar* aStringToInsert); NS_IMETHOD InsertText(const nsAReadableString& aStringToInsert);
NS_IMETHOD InsertLineBreak(); NS_IMETHOD InsertLineBreak();
NS_IMETHOD Undo(PRUint32 aCount); NS_IMETHOD Undo(PRUint32 aCount);
NS_IMETHOD Redo(PRUint32 aCount); NS_IMETHOD Redo(PRUint32 aCount);
@ -74,20 +74,22 @@ public:
NS_IMETHOD Paste(PRInt32 aSelectionType); NS_IMETHOD Paste(PRInt32 aSelectionType);
NS_IMETHOD PasteAsQuotation(PRInt32 aSelectionType); NS_IMETHOD PasteAsQuotation(PRInt32 aSelectionType);
NS_IMETHOD PasteAsPlaintextQuotation(PRInt32 aSelectionType); NS_IMETHOD PasteAsPlaintextQuotation(PRInt32 aSelectionType);
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation, NS_IMETHOD PasteAsCitedQuotation(const nsAReadableString& aCitation,
PRInt32 aSelectionType); PRInt32 aSelectionType);
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, nsIDOMNode** aNodeInserted); NS_IMETHOD InsertAsQuotation(const nsAReadableString& aQuotedText, nsIDOMNode** aNodeInserted);
NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText, nsIDOMNode** aNodeInserted); NS_IMETHOD InsertAsPlaintextQuotation(const nsAReadableString& aQuotedText, nsIDOMNode** aNodeInserted);
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation, PRBool aInsertHTML, const nsString& aCharset, nsIDOMNode** aNodeInserted); NS_IMETHOD InsertAsCitedQuotation(const nsAReadableString& aQuotedText, const nsAReadableString& aCitation,
PRBool aInsertHTML, const nsAReadableString& aCharset,
nsIDOMNode** aNodeInserted);
NS_IMETHOD ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet); NS_IMETHOD ApplyStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet);
NS_IMETHOD SetDocumentTitle(const PRUnichar* aTitle); NS_IMETHOD SetDocumentTitle(const nsAReadableString& aTitle);
NS_IMETHOD SetBackgroundColor(const nsString& aColor); NS_IMETHOD SetBackgroundColor(const nsAReadableString& aColor);
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue); NS_IMETHOD SetBodyAttribute(const nsAReadableString& aAttr, const nsAReadableString& aValue);
NS_IMETHOD MakeOrChangeList(const nsString& aListType, PRBool entireList); NS_IMETHOD MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList);
NS_IMETHOD Indent(const nsString& aIndent); NS_IMETHOD Indent(const nsAReadableString& aIndent);
NS_IMETHOD Align(const nsString& aAlign); NS_IMETHOD Align(const nsAReadableString& aAlign);
NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection); NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection);
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement); NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
@ -112,7 +114,7 @@ public:
nsresult Write(const char *aBuffer); nsresult Write(const char *aBuffer);
nsresult WriteInt(const char *aFormat, PRInt32 aInt); nsresult WriteInt(const char *aFormat, PRInt32 aInt);
nsresult Flush(); nsresult Flush();
nsresult PrintUnicode(const nsString &aString); nsresult PrintUnicode(const nsAReadableString &aString);
nsresult PrintSelection(); nsresult PrintSelection();
nsresult PrintNode(nsIDOMNode *aNode, PRInt32 aDepth=0); nsresult PrintNode(nsIDOMNode *aNode, PRInt32 aDepth=0);
nsresult PrintElementNode(nsIDOMNode *aNode, PRInt32 aDepth); nsresult PrintElementNode(nsIDOMNode *aNode, PRInt32 aDepth);

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

@ -101,8 +101,8 @@ static const PRBool gNoisy = PR_FALSE;
NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty, NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString & aAttribute,
const nsString *aValue) const nsAReadableString & aValue)
{ {
if (!aProperty) { return NS_ERROR_NULL_POINTER; } if (!aProperty) { return NS_ERROR_NULL_POINTER; }
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@ -120,7 +120,9 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
if (isCollapsed) if (isCollapsed)
{ {
// manipulating text attributes on a collapsed selection only sets state for the next text insertion // manipulating text attributes on a collapsed selection only sets state for the next text insertion
return mTypeInState->SetProp(aProperty, *aAttribute, *aValue); nsString tAttr(aAttribute);//MJUDGE SCC NEED HELP
nsString tVal(aValue);//MJUDGE SCC NEED HELP
return mTypeInState->SetProp(aProperty, tAttr, tVal);
} }
nsAutoEditBatch batchIt(this); nsAutoEditBatch batchIt(this);
@ -167,7 +169,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
range->GetStartOffset(&startOffset); range->GetStartOffset(&startOffset);
range->GetEndOffset(&endOffset); range->GetEndOffset(&endOffset);
nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(startNode); nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(startNode);
res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, endOffset, aProperty, aAttribute, aValue); res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, endOffset, aProperty, &aAttribute, &aValue);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
} }
else else
@ -232,7 +234,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
PRUint32 textLen; PRUint32 textLen;
range->GetStartOffset(&startOffset); range->GetStartOffset(&startOffset);
nodeAsText->GetLength(&textLen); nodeAsText->GetLength(&textLen);
res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, textLen, aProperty, aAttribute, aValue); res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, textLen, aProperty, &aAttribute, &aValue);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
} }
@ -244,7 +246,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
{ {
isupports = dont_AddRef(arrayOfNodes->ElementAt(0)); isupports = dont_AddRef(arrayOfNodes->ElementAt(0));
node = do_QueryInterface(isupports); node = do_QueryInterface(isupports);
res = SetInlinePropertyOnNode(node, aProperty, aAttribute, aValue); res = SetInlinePropertyOnNode(node, aProperty, &aAttribute, &aValue);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
arrayOfNodes->RemoveElementAt(0); arrayOfNodes->RemoveElementAt(0);
} }
@ -257,7 +259,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(endNode); nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(endNode);
PRInt32 endOffset; PRInt32 endOffset;
range->GetEndOffset(&endOffset); range->GetEndOffset(&endOffset);
res = SetInlinePropertyOnTextNode(nodeAsText, 0, endOffset, aProperty, aAttribute, aValue); res = SetInlinePropertyOnTextNode(nodeAsText, 0, endOffset, aProperty, &aAttribute, &aValue);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
} }
} }
@ -279,8 +281,8 @@ nsHTMLEditor::SetInlinePropertyOnTextNode( nsIDOMCharacterData *aTextNode,
PRInt32 aStartOffset, PRInt32 aStartOffset,
PRInt32 aEndOffset, PRInt32 aEndOffset,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString *aAttribute,
const nsString *aValue) const nsAReadableString *aValue)
{ {
if (!aTextNode) return NS_ERROR_NULL_POINTER; if (!aTextNode) return NS_ERROR_NULL_POINTER;
@ -323,8 +325,8 @@ nsHTMLEditor::SetInlinePropertyOnTextNode( nsIDOMCharacterData *aTextNode,
nsresult nsresult
nsHTMLEditor::SetInlinePropertyOnNode( nsIDOMNode *aNode, nsHTMLEditor::SetInlinePropertyOnNode( nsIDOMNode *aNode,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString *aAttribute,
const nsString *aValue) const nsAReadableString *aValue)
{ {
if (!aNode || !aProperty) return NS_ERROR_NULL_POINTER; if (!aNode || !aProperty) return NS_ERROR_NULL_POINTER;
@ -430,7 +432,7 @@ nsHTMLEditor::SetInlinePropertyOnNode( nsIDOMNode *aNode,
nsresult nsHTMLEditor::SplitStyleAboveRange(nsIDOMRange *inRange, nsresult nsHTMLEditor::SplitStyleAboveRange(nsIDOMRange *inRange,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute) const nsAReadableString *aAttribute)
{ {
if (!inRange) return NS_ERROR_NULL_POINTER; if (!inRange) return NS_ERROR_NULL_POINTER;
nsresult res; nsresult res;
@ -474,7 +476,7 @@ nsresult nsHTMLEditor::SplitStyleAboveRange(nsIDOMRange *inRange,
nsresult nsHTMLEditor::SplitStyleAbovePoint(nsCOMPtr<nsIDOMNode> *aNode, nsresult nsHTMLEditor::SplitStyleAbovePoint(nsCOMPtr<nsIDOMNode> *aNode,
PRInt32 *aOffset, PRInt32 *aOffset,
nsIAtom *aProperty, // null here means we split all properties nsIAtom *aProperty, // null here means we split all properties
const nsString *aAttribute, const nsAReadableString *aAttribute,
nsCOMPtr<nsIDOMNode> *outLeftNode, nsCOMPtr<nsIDOMNode> *outLeftNode,
nsCOMPtr<nsIDOMNode> *outRightNode) nsCOMPtr<nsIDOMNode> *outRightNode)
{ {
@ -508,7 +510,7 @@ PRBool nsHTMLEditor::NodeIsProperty(nsIDOMNode *aNode)
if (!IsContainer(aNode)) return PR_FALSE; if (!IsContainer(aNode)) return PR_FALSE;
if (!IsEditable(aNode)) return PR_FALSE; if (!IsEditable(aNode)) return PR_FALSE;
PRBool isBlock (PR_FALSE); PRBool isBlock (PR_FALSE);
NodeIsBlock(aNode, isBlock); NodeIsBlock(aNode, &isBlock);
if (isBlock) return PR_FALSE; if (isBlock) return PR_FALSE;
if (NodeIsType(aNode, nsIEditProperty::a)) return PR_FALSE; if (NodeIsType(aNode, nsIEditProperty::a)) return PR_FALSE;
return PR_TRUE; return PR_TRUE;
@ -516,7 +518,7 @@ PRBool nsHTMLEditor::NodeIsProperty(nsIDOMNode *aNode)
nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode, nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode,
nsIAtom *aProperty, // null here means remove all properties nsIAtom *aProperty, // null here means remove all properties
const nsString *aAttribute, const nsAReadableString *aAttribute,
PRBool aChildrenOnly) PRBool aChildrenOnly)
{ {
if (!aNode) return NS_ERROR_NULL_POINTER; if (!aNode) return NS_ERROR_NULL_POINTER;
@ -571,7 +573,7 @@ nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode,
} }
PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode, PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
const nsString *aAttribute) const nsAReadableString *aAttribute)
{ {
if (!aNode || !aAttribute) return PR_FALSE; // ooops if (!aNode || !aAttribute) return PR_FALSE; // ooops
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode); nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
@ -581,6 +583,7 @@ PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
nsCOMPtr<nsIAtom> attrName, prefix; nsCOMPtr<nsIAtom> attrName, prefix;
content->GetAttributeCount(attrCount); content->GetAttributeCount(attrCount);
nsString tString(*aAttribute);//MJUDGE SCC NEED HELP
for (i=0; i<attrCount; i++) for (i=0; i<attrCount; i++)
{ {
content->GetAttributeNameAt(i, nameSpaceID, *getter_AddRefs(attrName), content->GetAttributeNameAt(i, nameSpaceID, *getter_AddRefs(attrName),
@ -589,7 +592,7 @@ PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
if (!attrName) continue; // ooops if (!attrName) continue; // ooops
attrName->ToString(attrString); attrName->ToString(attrString);
// if it's the attribute we know about, keep looking // if it's the attribute we know about, keep looking
if (attrString.EqualsIgnoreCase(*aAttribute)) continue; if (attrString.EqualsIgnoreCase(tString)) continue;
// if it's a special _moz... attribute, keep looking // if it's a special _moz... attribute, keep looking
attrString.Left(tmp,4); attrString.Left(tmp,4);
if (tmp.EqualsWithConversion("_moz")) continue; if (tmp.EqualsWithConversion("_moz")) continue;
@ -656,7 +659,7 @@ nsHTMLEditor::HasMatchingAttributes(nsIDOMNode *aNode1,
} }
PRBool nsHTMLEditor::HasAttr(nsIDOMNode *aNode, PRBool nsHTMLEditor::HasAttr(nsIDOMNode *aNode,
const nsString *aAttribute) const nsAReadableString *aAttribute)
{ {
if (!aNode) return PR_FALSE; if (!aNode) return PR_FALSE;
if (!aAttribute || aAttribute->IsEmpty()) return PR_TRUE; // everybody has the 'null' attribute if (!aAttribute || aAttribute->IsEmpty()) return PR_TRUE; // everybody has the 'null' attribute
@ -674,8 +677,8 @@ PRBool nsHTMLEditor::HasAttr(nsIDOMNode *aNode,
PRBool nsHTMLEditor::HasAttrVal(nsIDOMNode *aNode, PRBool nsHTMLEditor::HasAttrVal(nsIDOMNode *aNode,
const nsString *aAttribute, const nsAReadableString *aAttribute,
const nsString *aValue) const nsAReadableString *aValue)
{ {
if (!aNode) return PR_FALSE; if (!aNode) return PR_FALSE;
if (!aAttribute || aAttribute->IsEmpty()) return PR_TRUE; // everybody has the 'null' attribute if (!aAttribute || aAttribute->IsEmpty()) return PR_TRUE; // everybody has the 'null' attribute
@ -700,7 +703,8 @@ PRBool nsHTMLEditor::HasAttrVal(nsIDOMNode *aNode,
attNode->GetValue(attrVal); attNode->GetValue(attrVal);
// do values match? // do values match?
if (attrVal.EqualsIgnoreCase(*aValue)) return PR_TRUE; nsString tString(*aValue);//MJUDGE SCC NEED HELP
if (attrVal.EqualsIgnoreCase(tString)) return PR_TRUE;
return PR_FALSE; return PR_FALSE;
} }
@ -792,23 +796,15 @@ PRBool nsHTMLEditor::IsAtEndOfNode(nsIDOMNode *aNode, PRInt32 aOffset)
} }
} }
NS_IMETHODIMP nsHTMLEditor::GetInlineProperty(nsIAtom *aProperty,
const nsString *aAttribute,
const nsString *aValue,
PRBool &aFirst,
PRBool &aAny,
PRBool &aAll)
{
return GetInlinePropertyWithAttrValue( aProperty, aAttribute, aValue, aFirst, aAny, aAll, nsnull);
}
NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty, nsresult
const nsString *aAttribute, nsHTMLEditor::GetInlinePropertyBase(nsIAtom *aProperty,
const nsString *aValue, const nsAReadableString *aAttribute,
PRBool &aFirst, const nsAReadableString *aValue,
PRBool &aAny, PRBool *aFirst,
PRBool &aAll, PRBool *aAny,
nsString *outValue) PRBool *aAll,
nsAWritableString *outValue)
{ {
if (!aProperty) if (!aProperty)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
@ -823,9 +819,9 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
} }
*/ */
nsresult result; nsresult result;
aAny=PR_FALSE; *aAny=PR_FALSE;
aAll=PR_TRUE; *aAll=PR_TRUE;
aFirst=PR_FALSE; *aFirst=PR_FALSE;
PRBool first=PR_TRUE; PRBool first=PR_TRUE;
nsCOMPtr<nsISelection>selection; nsCOMPtr<nsISelection>selection;
result = GetSelection(getter_AddRefs(selection)); result = GetSelection(getter_AddRefs(selection));
@ -863,12 +859,21 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
// cache now current, use it! But override it with typeInState results if any... // cache now current, use it! But override it with typeInState results if any...
PRBool isSet, theSetting; PRBool isSet, theSetting;
if (aAttribute) if (aAttribute)
mTypeInState->GetTypingState(isSet, theSetting, aProperty, *aAttribute, outValue); {
nsString tString(*aAttribute); //MJUDGE SCC NEED HELP
nsString tOutString;//MJUDGE SCC NEED HELP
nsString *tPassString=nsnull;
if (outValue)
tPassString = &tOutString;
mTypeInState->GetTypingState(isSet, theSetting, aProperty, tString, &tOutString);
if (outValue)
outValue->Assign(tOutString);
}
else else
mTypeInState->GetTypingState(isSet, theSetting, aProperty); mTypeInState->GetTypingState(isSet, theSetting, aProperty);
if (isSet) if (isSet)
{ {
aFirst = aAny = aAll = theSetting; *aFirst = *aAny = *aAll = theSetting;
return NS_OK; return NS_OK;
} }
/* /*
@ -877,11 +882,11 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
mTypeInState->GetTypingState(isSet, theSetting, aProperty); mTypeInState->GetTypingState(isSet, theSetting, aProperty);
if (isSet) if (isSet)
{ {
aFirst = aAny = aAll = theSetting; *aFirst = *aAny = *aAll = theSetting;
} }
else else
{ {
aFirst = aAny = aAll = mCachedBoldStyle; *aFirst = *aAny = *aAll = mCachedBoldStyle;
} }
return NS_OK; return NS_OK;
} }
@ -890,11 +895,11 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
mTypeInState->GetTypingState(isSet, theSetting, aProperty); mTypeInState->GetTypingState(isSet, theSetting, aProperty);
if (isSet) if (isSet)
{ {
aFirst = aAny = aAll = theSetting; *aFirst = *aAny = *aAll = theSetting;
} }
else else
{ {
aFirst = aAny = aAll = mCachedItalicStyle; *aFirst = *aAny = *aAll = mCachedItalicStyle;
} }
return NS_OK; return NS_OK;
} }
@ -903,11 +908,11 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
mTypeInState->GetTypingState(isSet, theSetting, aProperty); mTypeInState->GetTypingState(isSet, theSetting, aProperty);
if (isSet) if (isSet)
{ {
aFirst = aAny = aAll = theSetting; *aFirst = *aAny = *aAll = theSetting;
} }
else else
{ {
aFirst = aAny = aAll = mCachedUnderlineStyle; *aFirst = *aAny = *aAll = mCachedUnderlineStyle;
} }
return NS_OK; return NS_OK;
} */ } */
@ -975,7 +980,7 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
if (first) if (first)
{ {
IsTextPropertySetByContent(node, aProperty, aAttribute, aValue, isSet, getter_AddRefs(resultNode), &firstValue); IsTextPropertySetByContent(node, aProperty, aAttribute, aValue, isSet, getter_AddRefs(resultNode), &firstValue);
aFirst = isSet; *aFirst = isSet;
first = PR_FALSE; first = PR_FALSE;
if (outValue) *outValue = firstValue; if (outValue) *outValue = firstValue;
} }
@ -983,14 +988,14 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
{ {
IsTextPropertySetByContent(node, aProperty, aAttribute, aValue, isSet, getter_AddRefs(resultNode), &theValue); IsTextPropertySetByContent(node, aProperty, aAttribute, aValue, isSet, getter_AddRefs(resultNode), &theValue);
if (firstValue != theValue) if (firstValue != theValue)
aAll = PR_FALSE; *aAll = PR_FALSE;
} }
if (isSet) { if (isSet) {
aAny = PR_TRUE; *aAny = PR_TRUE;
} }
else { else {
aAll = PR_FALSE; *aAll = PR_FALSE;
} }
} }
} }
@ -1000,26 +1005,65 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
iter->CurrentNode(getter_AddRefs(content)); iter->CurrentNode(getter_AddRefs(content));
} }
} }
if (!aAny) if (!*aAny)
{ // make sure that if none of the selection is set, we don't report all is set { // make sure that if none of the selection is set, we don't report all is set
aAll = PR_FALSE; *aAll = PR_FALSE;
} }
//if (gNoisy) { printf(" returning first=%d any=%d all=%d\n", aFirst, aAny, aAll); } //if (gNoisy) { printf(" returning first=%d any=%d all=%d\n", *aFirst, *aAny, *aAll); }
return result; return result;
} }
NS_IMETHODIMP nsHTMLEditor::GetInlineProperty(nsIAtom *aProperty,
const nsAReadableString &aAttribute,
const nsAReadableString &aValue,
PRBool *aFirst,
PRBool *aAny,
PRBool *aAll)
{
if (!aProperty || !aFirst || !aAny || !aAll)
return NS_ERROR_NULL_POINTER;
const nsAReadableString *att = nsnull;
if (aAttribute.Length())
att = &aAttribute;
const nsAReadableString *val = nsnull;
if (aValue.Length())
val = &aValue;
return GetInlinePropertyBase( aProperty, att, val, aFirst, aAny, aAll, nsnull);
}
NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
const nsAReadableString &aAttribute,
const nsAReadableString &aValue,
PRBool *aFirst,
PRBool *aAny,
PRBool *aAll,
nsAWritableString &outValue)
{
if (!aProperty || !aFirst || !aAny || !aAll)
return NS_ERROR_NULL_POINTER;
const nsAReadableString *att = nsnull;
if (aAttribute.Length())
att = &aAttribute;
const nsAReadableString *val = nsnull;
if (aValue.Length())
val = &aValue;
return GetInlinePropertyBase( aProperty, att, val, aFirst, aAny, aAll, &outValue);
}
NS_IMETHODIMP nsHTMLEditor::RemoveAllInlineProperties() NS_IMETHODIMP nsHTMLEditor::RemoveAllInlineProperties()
{ {
return RemoveInlinePropertyImpl(nsnull, nsnull); return RemoveInlinePropertyImpl(nsnull, nsnull);
} }
NS_IMETHODIMP nsHTMLEditor::RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute) NS_IMETHODIMP nsHTMLEditor::RemoveInlineProperty(nsIAtom *aProperty, const nsAReadableString &aAttribute)
{ {
return RemoveInlinePropertyImpl(aProperty, aAttribute); return RemoveInlinePropertyImpl(aProperty, &aAttribute);
} }
nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsString *aAttribute) nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAReadableString *aAttribute)
{ {
if (!mRules) return NS_ERROR_NOT_INITIALIZED; if (!mRules) return NS_ERROR_NOT_INITIALIZED;
ForceCompositionEnd(); ForceCompositionEnd();
@ -1041,7 +1085,7 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsStri
if (aProperty == nsIEditProperty::href) if (aProperty == nsIEditProperty::href)
aProperty = nsIEditProperty::a; aProperty = nsIEditProperty::a;
if (aProperty) return mTypeInState->ClearProp(aProperty, *aAttribute); if (aProperty) return mTypeInState->ClearProp(aProperty, nsAutoString(*aAttribute));
else return mTypeInState->ClearAllProps(); else return mTypeInState->ClearAllProps();
} }
nsAutoEditBatch batchIt(this); nsAutoEditBatch batchIt(this);
@ -1428,66 +1472,73 @@ nsHTMLEditor::RelativeFontChangeOnNode( PRInt32 aSizeChange,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetFontFaceState(PRBool &aMixed, nsString &outFace) nsHTMLEditor::GetFontFaceState(PRBool *aMixed, nsAWritableString &outFace)
{ {
aMixed = PR_TRUE; if (!aMixed)
outFace.AssignWithConversion(""); return NS_ERROR_FAILURE;
*aMixed = PR_TRUE;
//outFace.AssignWithConversion("");
outFace.SetLength(0);
nsresult res; nsresult res;
nsAutoString faceStr; faceStr.AssignWithConversion("face"); nsAutoString faceStr;
faceStr.AssignWithConversion("face");
PRBool first, any, all; PRBool first, any, all;
res = GetInlinePropertyWithAttrValue(nsIEditProperty::font, &faceStr, nsnull, first, any, all, &outFace);
res = GetInlinePropertyBase(nsIEditProperty::font, &faceStr, nsnull, &first, &any, &all, &outFace);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
if (any && !all) return res; // mixed if (any && !all) return res; // mixed
if (all) if (all)
{ {
aMixed = PR_FALSE; *aMixed = PR_FALSE;
return res; return res;
} }
res = GetInlineProperty(nsIEditProperty::tt, nsnull, nsnull, first, any, all); res = GetInlinePropertyBase(nsIEditProperty::tt, nsnull, nsnull, &first, &any, &all,nsnull);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
if (any && !all) return res; // mixed if (any && !all) return res; // mixed
if (all) if (all)
{ {
aMixed = PR_FALSE; *aMixed = PR_FALSE;
nsIEditProperty::tt->ToString(outFace); nsIEditProperty::tt->ToString(outFace);
} }
if (!any) if (!any)
{ {
// there was no font face attrs of any kind. We are in normal font. // there was no font face attrs of any kind. We are in normal font.
outFace.AssignWithConversion(""); outFace.SetLength(0);
aMixed = PR_FALSE; *aMixed = PR_FALSE;
} }
return res; return res;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetFontColorState(PRBool &aMixed, nsString &aOutColor) nsHTMLEditor::GetFontColorState(PRBool *aMixed, nsAWritableString &aOutColor)
{ {
aMixed = PR_TRUE; if (!aMixed)
aOutColor.AssignWithConversion(""); return NS_ERROR_NULL_POINTER;
*aMixed = PR_TRUE;
aOutColor.SetLength(0);
nsresult res; nsresult res;
nsAutoString colorStr; colorStr.AssignWithConversion("color"); nsAutoString colorStr; colorStr.AssignWithConversion("color");
PRBool first, any, all; PRBool first, any, all;
res = GetInlinePropertyWithAttrValue(nsIEditProperty::font, &colorStr, nsnull, first, any, all, &aOutColor); res = GetInlinePropertyBase(nsIEditProperty::font, &colorStr, nsnull, &first, &any, &all, &aOutColor);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
if (any && !all) return res; // mixed if (any && !all) return res; // mixed
if (all) if (all)
{ {
aMixed = PR_FALSE; *aMixed = PR_FALSE;
return res; return res;
} }
if (!any) if (!any)
{ {
// there was no font color attrs of any kind.. // there was no font color attrs of any kind..
aOutColor.AssignWithConversion(""); aOutColor.SetLength(0);
aMixed = PR_FALSE; *aMixed = PR_FALSE;
} }
return res; return res;
} }

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

@ -35,11 +35,11 @@ class nsIHTMLEditRules : public nsISupports
public: public:
static const nsIID& GetIID() { static nsIID iid = NS_IHTMLEDITRULES_IID; return iid; } static const nsIID& GetIID() { static nsIID iid = NS_IHTMLEDITRULES_IID; return iid; }
NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL)=0; NS_IMETHOD GetListState(PRBool *aMixed, PRBool *aOL, PRBool *aUL, PRBool *aDL)=0;
NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD)=0; NS_IMETHOD GetListItemState(PRBool *aMixed, PRBool *aLI, PRBool *aDT, PRBool *aDD)=0;
NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)=0; NS_IMETHOD GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent)=0;
NS_IMETHOD GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)=0; NS_IMETHOD GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign)=0;
NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat)=0; NS_IMETHOD GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat)=0;
}; };

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

@ -21,9 +21,9 @@
* Pierre Phaneuf <pp@ludusdesign.com> * Pierre Phaneuf <pp@ludusdesign.com>
*/ */
#include "nsInternetCiter.h"
#include "nsString.h" #include "nsString.h"
#include "nsInternetCiter.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
@ -76,7 +76,7 @@ nsInternetCiter::QueryInterface(REFNSIID aIID, void** aInstancePtr)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString) nsInternetCiter::GetCiteString(const nsAReadableString& aInString, nsAWritableString& aOutString)
{ {
PRInt32 i = 0; PRInt32 i = 0;
PRInt32 length = aInString.Length(); PRInt32 length = aInString.Length();
@ -85,9 +85,10 @@ nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
// Strip trailing new lines which will otherwise turn up // Strip trailing new lines which will otherwise turn up
// as ugly quoted empty lines. // as ugly quoted empty lines.
nsString tString(aInString); //CRAPCRAP
while(length > 0 && while(length > 0 &&
(aInString[length-1] == cr || (tString[length-1] == cr ||
aInString[length-1] == nl)) tString[length-1] == nl))
{ {
--length; --length;
} }
@ -100,11 +101,11 @@ nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
aOutString.Append(gt); aOutString.Append(gt);
// No space between >: this is ">>> " style quoting, for // No space between >: this is ">>> " style quoting, for
// compatability with RFC 2646 and format=flowed. // compatability with RFC 2646 and format=flowed.
if (aInString[i] != gt) if (tString[i] != gt)
aOutString.Append(space); aOutString.Append(space);
} }
uch = aInString[i++]; uch = tString[i++];
aOutString += uch; aOutString += uch;
} }
@ -116,8 +117,8 @@ nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
} }
nsresult nsresult
nsInternetCiter::StripCitesAndLinebreaks(const nsString& aInString, nsInternetCiter::StripCitesAndLinebreaks(const nsAReadableString& aInString,
nsString& aOutString, nsAWritableString& aOutString,
PRBool aLinebreaksToo, PRBool aLinebreaksToo,
PRInt32* aCiteLevel) PRInt32* aCiteLevel)
{ {
@ -126,36 +127,37 @@ nsInternetCiter::StripCitesAndLinebreaks(const nsString& aInString,
aOutString.SetLength(0); aOutString.SetLength(0);
PRInt32 length = aInString.Length(); nsString tString(aInString);//CRAPCRAP
PRInt32 length = tString.Length();
PRInt32 i = 0; PRInt32 i = 0;
while (i < length) // loop over lines while (i < length) // loop over lines
{ {
// Clear out cites first, at the beginning of the line: // Clear out cites first, at the beginning of the line:
PRInt32 thisLineCiteLevel = 0; PRInt32 thisLineCiteLevel = 0;
while (aInString[i] == gt || nsCRT::IsAsciiSpace(aInString[i])) while (tString[i] == gt || nsCRT::IsAsciiSpace(tString[i]))
{ {
if (aInString[i] == gt) ++thisLineCiteLevel; if (tString[i] == gt) ++thisLineCiteLevel;
++i; ++i;
} }
// Now copy characters until line end: // Now copy characters until line end:
PRInt32 nextNewline = aInString.FindCharInSet("\r\n", i); PRInt32 nextNewline = tString.FindCharInSet("\r\n", i);
if (nextNewline > i) if (nextNewline > i)
{ {
while (i < nextNewline) while (i < nextNewline)
aOutString.Append(aInString[i++]); aOutString.Append(tString[i++]);
if (aLinebreaksToo) if (aLinebreaksToo)
aOutString.AppendWithConversion(' '); aOutString.Append(PRUnichar(' '));
else else
aOutString.AppendWithConversion('\n'); // DOM linebreaks, not NS_LINEBREAK aOutString.Append(PRUnichar('\n')); // DOM linebreaks, not NS_LINEBREAK
// Skip over any more consecutive linebreak-like characters: // Skip over any more consecutive linebreak-like characters:
while (i < length && (aInString[i] == '\r' || aInString[i] == '\n')) while (i < length && (tString[i] == '\r' || tString[i] == '\n'))
++i; ++i;
} }
else // no more newlines else // no more newlines
{ {
while (i < length) while (i < length)
aOutString.Append(aInString[i++]); aOutString.Append(tString[i++]);
} }
// Done with this line -- update cite level // Done with this line -- update cite level
@ -166,24 +168,24 @@ nsInternetCiter::StripCitesAndLinebreaks(const nsString& aInString,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsInternetCiter::StripCites(const nsString& aInString, nsString& aOutString) nsInternetCiter::StripCites(const nsAReadableString& aInString, nsAWritableString& aOutString)
{ {
return StripCitesAndLinebreaks(aInString, aOutString, PR_FALSE, 0); return StripCitesAndLinebreaks(aInString, aOutString, PR_FALSE, 0);
} }
static void AddCite(nsString& aOutString, PRInt32 citeLevel) static void AddCite(nsAWritableString& aOutString, PRInt32 citeLevel)
{ {
for (PRInt32 i = 0; i < citeLevel; ++i) for (PRInt32 i = 0; i < citeLevel; ++i)
aOutString.Append(gt); aOutString.Append(PRUnichar(gt));
if (citeLevel > 0) if (citeLevel > 0)
aOutString.Append(space); aOutString.Append(PRUnichar(space));
} }
NS_IMETHODIMP NS_IMETHODIMP
nsInternetCiter::Rewrap(const nsString& aInString, nsInternetCiter::Rewrap(const nsAReadableString& aInString,
PRUint32 aWrapCol, PRUint32 aFirstLineOffset, PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
PRBool aRespectNewlines, PRBool aRespectNewlines,
nsString& aOutString) nsAWritableString& aOutString)
{ {
nsCOMPtr<nsILineBreaker> lineBreaker; nsCOMPtr<nsILineBreaker> lineBreaker;
nsILineBreakerFactory *lf; nsILineBreakerFactory *lf;
@ -205,21 +207,21 @@ nsInternetCiter::Rewrap(const nsString& aInString,
PRUint32 posInString = 0; PRUint32 posInString = 0;
PRUint32 outStringCol = 0; PRUint32 outStringCol = 0;
PRUint32 citeLevel = 0; PRUint32 citeLevel = 0;
const PRUnichar* unicodeStr = aInString.GetUnicode(); const nsPromiseFlatString &tString = PromiseFlatString(aInString);//MJUDGE SCC NEED HELP
while (posInString < length) while (posInString < length)
{ {
#ifdef DEBUG_wrapping #ifdef DEBUG_wrapping
nsAutoString debug (nsPromiseSubstring<PRUnichar>(aInString, posInString, length-posInString)); nsAutoString debug (nsPromiseSubstring<PRUnichar>(tString, posInString, length-posInString));
printf("Outer loop: '%s'\n", debug.ToNewCString()); printf("Outer loop: '%s'\n", debug.ToNewCString());
#endif #endif
// Get the new cite level here since we're at the beginning of a line // Get the new cite level here since we're at the beginning of a line
PRUint32 newCiteLevel = 0; PRUint32 newCiteLevel = 0;
while (posInString < length && aInString[posInString] == gt) while (posInString < length && tString[posInString] == gt)
{ {
++newCiteLevel; ++newCiteLevel;
++posInString; ++posInString;
while (posInString < length && aInString[posInString] == space) while (posInString < length && tString[posInString] == space)
++posInString; ++posInString;
} }
if (posInString >= length) if (posInString >= length)
@ -227,9 +229,12 @@ nsInternetCiter::Rewrap(const nsString& aInString,
// Special case: if this is a blank line, maintain a blank line // Special case: if this is a blank line, maintain a blank line
// (retain the original paragraph breaks) // (retain the original paragraph breaks)
if (aInString[posInString] == nl) if (tString[posInString] == nl)
{ {
if (aOutString.Length() > 0 && aOutString[aOutString.Length()-1] != nl) nsReadingIterator <PRUnichar> outPeekIter;
aOutString.EndReading(outPeekIter);
outPeekIter.advance(-1);
if (aOutString.Length() > 0 && (*outPeekIter) != nl)
aOutString.Append(nl); aOutString.Append(nl);
AddCite(aOutString, newCiteLevel); AddCite(aOutString, newCiteLevel);
aOutString.Append(nl); aOutString.Append(nl);
@ -267,12 +272,12 @@ nsInternetCiter::Rewrap(const nsString& aInString,
printf("Appending space; citeLevel=%d, outStringCol=%d\n", citeLevel, printf("Appending space; citeLevel=%d, outStringCol=%d\n", citeLevel,
outStringCol); outStringCol);
#endif #endif
aOutString.Append(space); aOutString.Append(PRUnichar(space));
++outStringCol; ++outStringCol;
} }
// find the next newline -- don't want to go farther than that // find the next newline -- don't want to go farther than that
PRInt32 nextNewline = aInString.FindChar(nl, PR_FALSE, posInString); PRInt32 nextNewline = tString.FindChar(nl, posInString);
if (nextNewline < 0) nextNewline = length; if (nextNewline < 0) nextNewline = length;
// For now, don't wrap unquoted lines at all. // For now, don't wrap unquoted lines at all.
@ -285,11 +290,11 @@ nsInternetCiter::Rewrap(const nsString& aInString,
if (citeLevel == 0) if (citeLevel == 0)
{ {
#ifdef DEBUG_wrapping #ifdef DEBUG_wrapping
nsAutoString debug (nsPromiseSubstring<PRUnichar>(aInString, posInString, nsAutoString debug (nsPromiseSubstring<PRUnichar>(tString, posInString,
nextNewline-posInString)); nextNewline-posInString));
printf("Unquoted: appending '%s'\n", debug.ToNewCString()); printf("Unquoted: appending '%s'\n", debug.ToNewCString());
#endif #endif
aOutString.Append(nsPromiseSubstring(aInString, posInString, aOutString.Append(nsPromiseSubstring(tString, posInString,
nextNewline-posInString)); nextNewline-posInString));
outStringCol += nextNewline - posInString; outStringCol += nextNewline - posInString;
if (nextNewline != (PRInt32)length) if (nextNewline != (PRInt32)length)
@ -309,7 +314,7 @@ nsInternetCiter::Rewrap(const nsString& aInString,
while ((PRInt32)posInString < nextNewline) while ((PRInt32)posInString < nextNewline)
{ {
#ifdef DEBUG_wrapping #ifdef DEBUG_wrapping
nsAutoString debug (nsPromiseSubstring<PRUnichar>(aInString, posInString, nextNewline-posInString)); nsAutoString debug (nsPromiseSubstring<PRUnichar>(tString, posInString, nextNewline-posInString));
printf("Inner loop: '%s'\n", debug.ToNewCString()); printf("Inner loop: '%s'\n", debug.ToNewCString());
#endif #endif
@ -318,13 +323,13 @@ nsInternetCiter::Rewrap(const nsString& aInString,
{ {
// If this short line is the final one in the in string, // If this short line is the final one in the in string,
// then we need to include the final newline, if any: // then we need to include the final newline, if any:
if (nextNewline+1 == (PRInt32)length && aInString[nextNewline-1] == nl) if (nextNewline+1 == (PRInt32)length && tString[nextNewline-1] == nl)
++nextNewline; ++nextNewline;
#ifdef DEBUG_wrapping #ifdef DEBUG_wrapping
nsAutoString debug (nsPromiseSubstring<PRUnichar>(aInString, posInString, nextNewline - posInString)); nsAutoString debug (nsPromiseSubstring<PRUnichar>(tString, posInString, nextNewline - posInString));
printf("Short line: '%s'\n", debug.ToNewCString()); printf("Short line: '%s'\n", debug.ToNewCString());
#endif #endif
aOutString += nsPromiseSubstring(aInString, aOutString += nsPromiseSubstring(tString,
posInString, nextNewline - posInString); posInString, nextNewline - posInString);
outStringCol += nextNewline - posInString; outStringCol += nextNewline - posInString;
posInString = nextNewline + 1; posInString = nextNewline + 1;
@ -339,13 +344,13 @@ nsInternetCiter::Rewrap(const nsString& aInString,
rv = NS_ERROR_BASE; rv = NS_ERROR_BASE;
if (lineBreaker) if (lineBreaker)
{ {
rv = lineBreaker->Prev(unicodeStr + posInString, length - posInString, rv = lineBreaker->Prev(tString.get() + posInString, length - posInString,
eol - posInString, &breakPt, &needMore); eol - posInString, &breakPt, &needMore);
if (NS_FAILED(rv) || needMore) if (NS_FAILED(rv) || needMore)
{ {
// if we couldn't find a breakpoint looking backwards, // if we couldn't find a breakpoint looking backwards,
// try looking forwards: // try looking forwards:
rv = lineBreaker->Next(unicodeStr + posInString, rv = lineBreaker->Next(tString.get() + posInString,
length - posInString, length - posInString,
eol - posInString, &breakPt, &needMore); eol - posInString, &breakPt, &needMore);
if (needMore) rv = NS_ERROR_BASE; if (needMore) rv = NS_ERROR_BASE;
@ -365,7 +370,7 @@ nsInternetCiter::Rewrap(const nsString& aInString,
printf("breakPt = %d\n", breakPt); printf("breakPt = %d\n", breakPt);
#endif #endif
aOutString += nsPromiseSubstring(aInString, posInString, breakPt); aOutString += nsPromiseSubstring(tString, posInString, breakPt);
posInString += breakPt; posInString += breakPt;
outStringCol += breakPt; outStringCol += breakPt;

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

@ -38,17 +38,17 @@ public:
//NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor //NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_IMETHOD GetCiteString(const nsString& aInString, nsString& aOutString); NS_IMETHOD GetCiteString(const nsAReadableString & aInString, nsAWritableString & aOutString);
NS_IMETHOD StripCites(const nsString& aInString, nsString& aOutString); NS_IMETHOD StripCites(const nsAReadableString & aInString, nsAWritableString & aOutString);
NS_IMETHOD Rewrap(const nsString& aInString, NS_IMETHOD Rewrap(const nsAReadableString & aInString,
PRUint32 aWrapCol, PRUint32 aFirstLineOffset, PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
PRBool aRespectNewlines, PRBool aRespectNewlines,
nsString& aOutString); nsAWritableString & aOutString);
protected: protected:
nsresult StripCitesAndLinebreaks(const nsString& aInString, nsString& aOutString, nsresult StripCitesAndLinebreaks(const nsAReadableString& aInString, nsAWritableString& aOutString,
PRBool aLinebreaksToo, PRInt32* aCiteLevel); PRBool aLinebreaksToo, PRInt32* aCiteLevel);
}; };

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

@ -160,7 +160,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertTextFromTransferable(nsITransferable *tra
textDataObj->ToString ( &text ); textDataObj->ToString ( &text );
stuffToPaste.Assign ( text, len / 2 ); stuffToPaste.Assign ( text, len / 2 );
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
rv = InsertText(stuffToPaste.GetUnicode()); rv = InsertText(stuffToPaste);
if (text) if (text)
nsMemory::Free(text); nsMemory::Free(text);
} }
@ -355,12 +355,14 @@ NS_IMETHODIMP nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
return rv; return rv;
} }
NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag) NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag)
{ {
if (!aCanDrag)
return NS_ERROR_NULL_POINTER;
/* we really should be checking the XY coordinates of the mouseevent and ensure that /* we really should be checking the XY coordinates of the mouseevent and ensure that
* that particular point is actually within the selection (not just that there is a selection) * that particular point is actually within the selection (not just that there is a selection)
*/ */
aCanDrag = PR_FALSE; *aCanDrag = PR_FALSE;
// KLUDGE to work around bug 50703 // KLUDGE to work around bug 50703
// After double click and object property editing, // After double click and object property editing,
@ -395,7 +397,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDr
res = selection->ContainsNode(eventTargetDomNode, PR_FALSE, &amTargettedCorrectly); res = selection->ContainsNode(eventTargetDomNode, PR_FALSE, &amTargettedCorrectly);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
aCanDrag = amTargettedCorrectly; *aCanDrag = amTargettedCorrectly;
} }
} }
@ -532,9 +534,11 @@ NS_IMETHODIMP nsPlaintextEditor::Paste(PRInt32 aSelectionType)
} }
NS_IMETHODIMP nsPlaintextEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste) NS_IMETHODIMP nsPlaintextEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste)
{ {
aCanPaste = PR_FALSE; if (!aCanPaste)
return NS_ERROR_NULL_POINTER;
*aCanPaste = PR_FALSE;
// can't paste if readonly // can't paste if readonly
if (!IsModifiable()) if (!IsModifiable())
@ -572,6 +576,6 @@ NS_IMETHODIMP nsPlaintextEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPa
rv = clipboard->HasDataMatchingFlavors(flavorsList, aSelectionType, &haveFlavors); rv = clipboard->HasDataMatchingFlavors(flavorsList, aSelectionType, &haveFlavors);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
aCanPaste = haveFlavors; *aCanPaste = haveFlavors;
return NS_OK; return NS_OK;
} }

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

@ -245,7 +245,7 @@ nsPlaintextEditor::EndEditorInit()
} }
NS_IMETHODIMP NS_IMETHODIMP
nsPlaintextEditor::SetDocumentCharacterSet(const PRUnichar* characterSet) nsPlaintextEditor::SetDocumentCharacterSet(const nsAReadableString & characterSet)
{ {
nsresult result; nsresult result;
@ -312,7 +312,7 @@ nsPlaintextEditor::SetDocumentCharacterSet(const PRUnichar* characterSet)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
// Set attributes to the created element // Set attributes to the created element
if (resultNode && nsCRT::strlen(characterSet) > 0) { if (resultNode && characterSet.Length() > 0) {
metaElement = do_QueryInterface(resultNode); metaElement = do_QueryInterface(resultNode);
if (metaElement) { if (metaElement) {
// not undoable, undo should undo CreateNode // not undoable, undo should undo CreateNode
@ -505,19 +505,19 @@ NS_IMETHODIMP nsPlaintextEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
|| keyCode == nsIDOMKeyEvent::DOM_VK_ENTER) || keyCode == nsIDOMKeyEvent::DOM_VK_ENTER)
{ {
nsString empty; nsString empty;
return TypedText(empty.GetUnicode(), eTypedBreak); return TypedText(empty, eTypedBreak);
} }
else if (keyCode == nsIDOMKeyEvent::DOM_VK_ESCAPE) else if (keyCode == nsIDOMKeyEvent::DOM_VK_ESCAPE)
{ {
// pass escape keypresses through as empty strings: needed for ime support // pass escape keypresses through as empty strings: needed for ime support
nsString empty; nsString empty;
return TypedText(empty.GetUnicode(), eTypedText); return TypedText(empty, eTypedText);
} }
if (character && !altKey && !ctrlKey && !isShift && !metaKey) if (character && !altKey && !ctrlKey && !isShift && !metaKey)
{ {
nsAutoString key(character); nsAutoString key(character);
return TypedText(key.GetUnicode(), eTypedText); return TypedText(key, eTypedText);
} }
} }
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -529,7 +529,7 @@ NS_IMETHODIMP nsPlaintextEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
to TypedText() to determine what action to take, but without passing to TypedText() to determine what action to take, but without passing
an event. an event.
*/ */
NS_IMETHODIMP nsPlaintextEditor::TypedText(const PRUnichar* aString, NS_IMETHODIMP nsPlaintextEditor::TypedText(const nsAReadableString& aString,
PRInt32 aAction) PRInt32 aAction)
{ {
nsAutoPlaceHolderBatch batch(this, gTypingTxnName); nsAutoPlaceHolderBatch batch(this, gTypingTxnName);
@ -944,7 +944,7 @@ NS_IMETHODIMP nsPlaintextEditor::DeleteSelection(nsIEditor::EDirection aAction)
return result; return result;
} }
NS_IMETHODIMP nsPlaintextEditor::InsertText(const PRUnichar* aStringToInsert) NS_IMETHODIMP nsPlaintextEditor::InsertText(const nsAReadableString &aStringToInsert)
{ {
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@ -967,9 +967,9 @@ NS_IMETHODIMP nsPlaintextEditor::InsertText(const PRUnichar* aStringToInsert)
nsAutoString resultString; nsAutoString resultString;
// XXX can we trust instring to outlive ruleInfo, // XXX can we trust instring to outlive ruleInfo,
// XXX and ruleInfo not to refer to instring in its dtor? // XXX and ruleInfo not to refer to instring in its dtor?
nsAutoString instring(aStringToInsert); //nsAutoString instring(aStringToInsert);
nsTextRulesInfo ruleInfo(theAction); nsTextRulesInfo ruleInfo(theAction);
ruleInfo.inString = &instring; ruleInfo.inString = &aStringToInsert;
ruleInfo.outString = &resultString; ruleInfo.outString = &resultString;
ruleInfo.maxLength = mMaxTextLength; ruleInfo.maxLength = mMaxTextLength;
@ -1361,9 +1361,11 @@ NS_IMETHODIMP nsPlaintextEditor::Cut()
return res; return res;
} }
NS_IMETHODIMP nsPlaintextEditor::CanCut(PRBool &aCanCut) NS_IMETHODIMP nsPlaintextEditor::CanCut(PRBool *aCanCut)
{ {
aCanCut = PR_FALSE; if (!aCanCut)
return NS_ERROR_NULL_POINTER;
*aCanCut = PR_FALSE;
nsCOMPtr<nsISelection> selection; nsCOMPtr<nsISelection> selection;
nsresult res = GetSelection(getter_AddRefs(selection)); nsresult res = GetSelection(getter_AddRefs(selection));
@ -1373,7 +1375,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanCut(PRBool &aCanCut)
res = selection->GetIsCollapsed(&isCollapsed); res = selection->GetIsCollapsed(&isCollapsed);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
aCanCut = !isCollapsed && IsModifiable(); *aCanCut = !isCollapsed && IsModifiable();
return NS_OK; return NS_OK;
} }
@ -1385,9 +1387,11 @@ NS_IMETHODIMP nsPlaintextEditor::Copy()
return ps->DoCopy(); return ps->DoCopy();
} }
NS_IMETHODIMP nsPlaintextEditor::CanCopy(PRBool &aCanCopy) NS_IMETHODIMP nsPlaintextEditor::CanCopy(PRBool *aCanCopy)
{ {
aCanCopy = PR_FALSE; if (!aCanCopy)
return NS_ERROR_NULL_POINTER;
*aCanCopy = PR_FALSE;
nsCOMPtr<nsISelection> selection; nsCOMPtr<nsISelection> selection;
nsresult res = GetSelection(getter_AddRefs(selection)); nsresult res = GetSelection(getter_AddRefs(selection));
@ -1397,7 +1401,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanCopy(PRBool &aCanCopy)
res = selection->GetIsCollapsed(&isCollapsed); res = selection->GetIsCollapsed(&isCollapsed);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
aCanCopy = !isCollapsed; *aCanCopy = !isCollapsed;
return NS_OK; return NS_OK;
} }
@ -1406,7 +1410,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanCopy(PRBool &aCanCopy)
NS_IMETHODIMP NS_IMETHODIMP
nsPlaintextEditor::GetAndInitDocEncoder(const nsAReadableString& aFormatType, nsPlaintextEditor::GetAndInitDocEncoder(const nsAReadableString& aFormatType,
PRUint32 aFlags, PRUint32 aFlags,
const nsAReadableString* aCharset, const nsAReadableString& aCharset,
nsIDocumentEncoder** encoder) nsIDocumentEncoder** encoder)
{ {
nsCOMPtr<nsIPresShell> presShell; nsCOMPtr<nsIPresShell> presShell;
@ -1426,9 +1430,9 @@ nsPlaintextEditor::GetAndInitDocEncoder(const nsAReadableString& aFormatType,
rv = docEncoder->Init(doc, aFormatType, aFlags); rv = docEncoder->Init(doc, aFormatType, aFlags);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
if (aCharset && aCharset->Length() != 0 if (aCharset.Length() != 0
&& !(aCharset->Equals(NS_LITERAL_STRING("null")))) && !(aCharset.Equals(NS_LITERAL_STRING("null"))))
docEncoder->SetCharset(*aCharset); docEncoder->SetCharset(aCharset);
PRInt32 wc; PRInt32 wc;
(void) GetWrapWidth(&wc); (void) GetWrapWidth(&wc);
@ -1512,7 +1516,7 @@ nsPlaintextEditor::OutputToString(nsAWritableString& aOutputString,
} }
nsCOMPtr<nsIDocumentEncoder> encoder; nsCOMPtr<nsIDocumentEncoder> encoder;
rv = GetAndInitDocEncoder(aFormatType, aFlags, 0, getter_AddRefs(encoder)); rv = GetAndInitDocEncoder(aFormatType, aFlags, NS_LITERAL_STRING(""), getter_AddRefs(encoder));
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
rv = encoder->EncodeToString(aOutputString); rv = encoder->EncodeToString(aOutputString);
@ -1522,7 +1526,7 @@ nsPlaintextEditor::OutputToString(nsAWritableString& aOutputString,
NS_IMETHODIMP NS_IMETHODIMP
nsPlaintextEditor::OutputToStream(nsIOutputStream* aOutputStream, nsPlaintextEditor::OutputToStream(nsIOutputStream* aOutputStream,
const nsAReadableString& aFormatType, const nsAReadableString& aFormatType,
const nsAReadableString* aCharset, const nsAReadableString& aCharset,
PRUint32 aFlags) PRUint32 aFlags)
{ {
nsresult rv; nsresult rv;
@ -1647,7 +1651,7 @@ static nsICiter* MakeACiter()
} }
NS_IMETHODIMP NS_IMETHODIMP
nsPlaintextEditor::InsertAsQuotation(const nsString& aQuotedText, nsPlaintextEditor::InsertAsQuotation(const nsAReadableString& aQuotedText,
nsIDOMNode **aNodeInserted) nsIDOMNode **aNodeInserted)
{ {
// We have the text. Cite it appropriately: // We have the text. Cite it appropriately:
@ -1681,7 +1685,7 @@ nsPlaintextEditor::InsertAsQuotation(const nsString& aQuotedText,
if (cancel) return NS_OK; // rules canceled the operation if (cancel) return NS_OK; // rules canceled the operation
if (!handled) if (!handled)
{ {
rv = InsertText(quotedStuff.GetUnicode()); rv = InsertText(quotedStuff);
// XXX Should set *aNodeInserted to the first node inserted // XXX Should set *aNodeInserted to the first node inserted
if (aNodeInserted && NS_SUCCEEDED(rv)) if (aNodeInserted && NS_SUCCEEDED(rv))
@ -1694,17 +1698,17 @@ nsPlaintextEditor::InsertAsQuotation(const nsString& aQuotedText,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsPlaintextEditor::PasteAsCitedQuotation(const nsString& aCitation, nsPlaintextEditor::PasteAsCitedQuotation(const nsAReadableString& aCitation,
PRInt32 aSelectionType) PRInt32 aSelectionType)
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsPlaintextEditor::InsertAsCitedQuotation(const nsString& aQuotedText, nsPlaintextEditor::InsertAsCitedQuotation(const nsAReadableString& aQuotedText,
const nsString& aCitation, const nsAReadableString& aCitation,
PRBool aInsertHTML, PRBool aInsertHTML,
const nsString& aCharset, const nsAReadableString& aCharset,
nsIDOMNode **aNodeInserted) nsIDOMNode **aNodeInserted)
{ {
return InsertAsQuotation(aQuotedText, aNodeInserted); return InsertAsQuotation(aQuotedText, aNodeInserted);
@ -1752,7 +1756,7 @@ nsPlaintextEditor::Rewrap(PRBool aRespectNewlines)
rv = SelectAll(); rv = SelectAll();
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
return InsertText(wrapped.GetUnicode()); return InsertText(wrapped);
} }
else // rewrap only the selection else // rewrap only the selection
{ {
@ -1770,7 +1774,7 @@ nsPlaintextEditor::Rewrap(PRBool aRespectNewlines)
wrapped); wrapped);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
return InsertText(wrapped.GetUnicode()); return InsertText(wrapped);
} }
return NS_OK; return NS_OK;
} }
@ -1813,7 +1817,7 @@ nsPlaintextEditor::StripCites()
rv = SelectAll(); rv = SelectAll();
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
return InsertText(stripped.GetUnicode()); return InsertText(stripped);
} }
else // rewrap only the selection else // rewrap only the selection
{ {
@ -1829,7 +1833,7 @@ nsPlaintextEditor::StripCites()
rv = citer->StripCites(current, stripped); rv = citer->StripCites(current, stripped);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
return InsertText(stripped.GetUnicode()); return InsertText(stripped);
} }
return NS_OK; return NS_OK;
} }
@ -1849,7 +1853,7 @@ nsPlaintextEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
#endif #endif
NS_IMETHODIMP NS_IMETHODIMP
nsPlaintextEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply) nsPlaintextEditor::SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply)
{ {
NS_ASSERTION(aTextRangeList, "null ptr"); NS_ASSERTION(aTextRangeList, "null ptr");
if(nsnull == aTextRangeList) if(nsnull == aTextRangeList)
@ -1872,7 +1876,7 @@ nsPlaintextEditor::SetCompositionString(const nsString& aCompositionString, nsIP
mIMETextRangeList = aTextRangeList; mIMETextRangeList = aTextRangeList;
nsAutoPlaceHolderBatch batch(this, gIMETxnName); nsAutoPlaceHolderBatch batch(this, gIMETxnName);
result = InsertText(aCompositionString.GetUnicode()); result = InsertText(aCompositionString);
mIMEBufferLength = aCompositionString.Length(); mIMEBufferLength = aCompositionString.Length();

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

@ -70,14 +70,14 @@ public:
/* ------------ nsIEditorMailSupport overrides -------------- */ /* ------------ nsIEditorMailSupport overrides -------------- */
NS_IMETHOD PasteAsQuotation(PRInt32 aSelectionType); NS_IMETHOD PasteAsQuotation(PRInt32 aSelectionType);
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, NS_IMETHOD InsertAsQuotation(const nsAReadableString& aQuotedText,
nsIDOMNode** aNodeInserted); nsIDOMNode** aNodeInserted);
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation, NS_IMETHOD PasteAsCitedQuotation(const nsAReadableString& aCitation,
PRInt32 aSelectionType); PRInt32 aSelectionType);
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, NS_IMETHOD InsertAsCitedQuotation(const nsAReadableString& aQuotedText,
const nsString& aCitation, const nsAReadableString& aCitation,
PRBool aInsertHTML, PRBool aInsertHTML,
const nsString& aCharset, const nsAReadableString& aCharset,
nsIDOMNode** aNodeInserted); nsIDOMNode** aNodeInserted);
NS_IMETHOD Rewrap(PRBool aRespectNewlines); NS_IMETHOD Rewrap(PRBool aRespectNewlines);
NS_IMETHOD StripCites(); NS_IMETHOD StripCites();
@ -85,7 +85,7 @@ public:
/* ------------ nsIEditorIMESupport overrides -------------- */ /* ------------ nsIEditorIMESupport overrides -------------- */
NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply); NS_IMETHOD SetCompositionString(const nsAReadableString & aCompositionString, nsIPrivateTextRangeList * aTextRange, nsTextEventReply * aReply);
NS_IMETHOD GetReconversionString(nsReconversionEventReply* aReply); NS_IMETHOD GetReconversionString(nsReconversionEventReply* aReply);
/* ------------ Overrides of nsEditor interface methods -------------- */ /* ------------ Overrides of nsEditor interface methods -------------- */
@ -97,7 +97,7 @@ public:
NS_IMETHOD DeleteSelection(EDirection aAction); NS_IMETHOD DeleteSelection(EDirection aAction);
NS_IMETHOD SetDocumentCharacterSet(const PRUnichar* characterSet); NS_IMETHOD SetDocumentCharacterSet(const nsAReadableString & characterSet);
/** we override this here to install event listeners */ /** we override this here to install event listeners */
NS_IMETHOD PostCreate(); NS_IMETHOD PostCreate();
@ -109,13 +109,13 @@ public:
NS_IMETHOD Redo(PRUint32 aCount); NS_IMETHOD Redo(PRUint32 aCount);
NS_IMETHOD Cut(); NS_IMETHOD Cut();
NS_IMETHOD CanCut(PRBool &aCanCut); NS_IMETHOD CanCut(PRBool *aCanCut);
NS_IMETHOD Copy(); NS_IMETHOD Copy();
NS_IMETHOD CanCopy(PRBool &aCanCopy); NS_IMETHOD CanCopy(PRBool *aCanCopy);
NS_IMETHOD Paste(PRInt32 aSelectionType); NS_IMETHOD Paste(PRInt32 aSelectionType);
NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste); NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste);
NS_IMETHOD CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag); NS_IMETHOD CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag);
NS_IMETHOD DoDrag(nsIDOMEvent *aDragEvent); NS_IMETHOD DoDrag(nsIDOMEvent *aDragEvent);
NS_IMETHOD InsertFromDrop(nsIDOMEvent* aDropEvent); NS_IMETHOD InsertFromDrop(nsIDOMEvent* aDropEvent);
@ -125,7 +125,7 @@ public:
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream, NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
const nsAReadableString& aFormatType, const nsAReadableString& aFormatType,
const nsAReadableString* aCharsetOverride, const nsAReadableString& aCharsetOverride,
PRUint32 aFlags); PRUint32 aFlags);
@ -141,7 +141,7 @@ public:
NS_IMETHOD SelectEntireDocument(nsISelection *aSelection); NS_IMETHOD SelectEntireDocument(nsISelection *aSelection);
/* ------------ Utility Routines, not part of public API -------------- */ /* ------------ Utility Routines, not part of public API -------------- */
NS_IMETHOD TypedText(const PRUnichar* aString, PRInt32 aAction); NS_IMETHOD TypedText(const nsAReadableString& aString, PRInt32 aAction);
/** returns the absolute position of the end points of aSelection /** returns the absolute position of the end points of aSelection
* in the document as a text stream. * in the document as a text stream.
@ -183,7 +183,7 @@ protected:
// Helpers for output routines // Helpers for output routines
NS_IMETHOD GetAndInitDocEncoder(const nsAReadableString& aFormatType, NS_IMETHOD GetAndInitDocEncoder(const nsAReadableString& aFormatType,
PRUint32 aFlags, PRUint32 aFlags,
const nsAReadableString* aCharset, const nsAReadableString& aCharset,
nsIDocumentEncoder** encoder); nsIDocumentEncoder** encoder);
// key event helpers // key event helpers

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

@ -1885,7 +1885,7 @@ nsHTMLEditor::CopyCellBackgroundColor(nsIDOMElement *destCell, nsIDOMElement *so
nsAutoString bgcolor; bgcolor.AssignWithConversion("bgcolor"); nsAutoString bgcolor; bgcolor.AssignWithConversion("bgcolor");
nsAutoString color; nsAutoString color;
PRBool isSet; PRBool isSet;
nsresult res = GetAttributeValue(sourceCell, bgcolor, color, isSet); nsresult res = GetAttributeValue(sourceCell, bgcolor, color, &isSet);
if (NS_SUCCEEDED(res) && isSet) if (NS_SUCCEEDED(res) && isSet)
res = SetAttribute(destCell, bgcolor, color); res = SetAttribute(destCell, bgcolor, color);

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

@ -437,13 +437,14 @@ nsTextEditRules::DidInsertBreak(nsISelection *aSelection, nsresult aResult)
return res; return res;
} }
nsresult nsresult
nsTextEditRules::WillInsertText(PRInt32 aAction, nsTextEditRules::WillInsertText(PRInt32 aAction,
nsISelection *aSelection, nsISelection *aSelection,
PRBool *aCancel, PRBool *aCancel,
PRBool *aHandled, PRBool *aHandled,
const nsString *inString, const nsAReadableString *inString,
nsString *outString, nsAWritableString *outString,
PRInt32 aMaxLength) PRInt32 aMaxLength)
{ {
if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
@ -528,17 +529,40 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
if (nsIPlaintextEditor::eEditorSingleLineMask & mFlags) if (nsIPlaintextEditor::eEditorSingleLineMask & mFlags)
{ {
if (singleLineNewlineBehavior == eReplaceWithSpaces) if (singleLineNewlineBehavior == eReplaceWithSpaces)
outString->ReplaceChar(CRLF, ' '); {
nsString tString;
tString.Assign(*outString);
//nsAWritableString destString;
//NormalizeCRLF(outString,destString);
tString.ReplaceChar(CRLF, ' ');
outString->Assign(tString);
}
else if (singleLineNewlineBehavior == eStripNewlines) else if (singleLineNewlineBehavior == eStripNewlines)
outString->StripChars(CRLF); {
nsString tString;
tString.Assign(*outString);
tString.StripChars(CRLF);
outString->Assign(tString);
}
else if (singleLineNewlineBehavior == ePasteFirstLine) else if (singleLineNewlineBehavior == ePasteFirstLine)
{ {
PRInt32 firstCRLF = outString->FindCharInSet(CRLF); nsString tString;
tString.Assign(*outString);
PRInt32 firstCRLF = tString.FindCharInSet(CRLF);
if (firstCRLF > 0) if (firstCRLF > 0)
outString->Truncate(firstCRLF); {
tString.Truncate(firstCRLF);
outString->Assign(tString);
}
} }
else // even if we're pasting newlines, don't paste leading/trailing ones else // even if we're pasting newlines, don't paste leading/trailing ones
outString->Trim(CRLF, PR_TRUE, PR_TRUE); {
nsString tString;
tString.Assign(*outString);
tString.Trim(CRLF, PR_TRUE, PR_TRUE);
outString->Assign(tString);
}
} }
// get the (collapsed) selection location // get the (collapsed) selection location
@ -576,7 +600,8 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
// dont spaz my selection in subtransactions // dont spaz my selection in subtransactions
nsAutoTxnsConserveSelection dontSpazMySelection(mEditor); nsAutoTxnsConserveSelection dontSpazMySelection(mEditor);
nsSubsumeStr subStr; nsSubsumeStr subStr;
const PRUnichar *unicodeBuf = outString->GetUnicode(); nsString tString(*outString);
const PRUnichar *unicodeBuf = tString.GetUnicode();
nsCOMPtr<nsIDOMNode> unused; nsCOMPtr<nsIDOMNode> unused;
PRInt32 pos = 0; PRInt32 pos = 0;
@ -586,11 +611,11 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
if (isPRE) if (isPRE)
{ {
char newlineChar = '\n'; char newlineChar = '\n';
while (unicodeBuf && (pos != -1) && ((PRUint32)pos < outString->Length())) while (unicodeBuf && (pos != -1) && ((PRUint32)pos < tString.Length()))
{ {
PRInt32 oldPos = pos; PRInt32 oldPos = pos;
PRInt32 subStrLen; PRInt32 subStrLen;
pos = outString->FindChar(newlineChar, PR_FALSE, oldPos); pos = tString.FindChar(newlineChar, PR_FALSE, oldPos);
if (pos != -1) if (pos != -1)
{ {
@ -601,8 +626,8 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
} }
else else
{ {
subStrLen = outString->Length() - oldPos; subStrLen = tString.Length() - oldPos;
pos = outString->Length(); pos = tString.Length();
} }
subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen); subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen);
@ -631,11 +656,11 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
{ {
char specialChars[] = {'\t','\n',0}; char specialChars[] = {'\t','\n',0};
nsAutoString tabString; tabString.AssignWithConversion(" "); nsAutoString tabString; tabString.AssignWithConversion(" ");
while (unicodeBuf && (pos != -1) && ((PRUint32)pos < outString->Length())) while (unicodeBuf && (pos != -1) && ((PRUint32)pos < tString.Length()))
{ {
PRInt32 oldPos = pos; PRInt32 oldPos = pos;
PRInt32 subStrLen; PRInt32 subStrLen;
pos = outString->FindCharInSet(specialChars, oldPos); pos = tString.FindCharInSet(specialChars, oldPos);
if (pos != -1) if (pos != -1)
{ {
@ -646,8 +671,8 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
} }
else else
{ {
subStrLen = outString->Length() - oldPos; subStrLen = tString.Length() - oldPos;
pos = outString->Length(); pos = tString.Length();
} }
subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen); subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen);
@ -671,7 +696,10 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
} }
} }
if (curNode) aSelection->Collapse(curNode, curOffset); outString->Assign(tString);
if (curNode)
aSelection->Collapse(curNode, curOffset);
} }
return res; return res;
} }
@ -1018,8 +1046,8 @@ nsTextEditRules::DidRedo(nsISelection *aSelection, nsresult aResult)
nsresult nsresult
nsTextEditRules::WillOutputText(nsISelection *aSelection, nsTextEditRules::WillOutputText(nsISelection *aSelection,
const nsString *aOutputFormat, const nsAReadableString *aOutputFormat,
nsString *aOutString, nsAWritableString *aOutString,
PRBool *aCancel, PRBool *aCancel,
PRBool *aHandled) PRBool *aHandled)
{ {
@ -1031,7 +1059,9 @@ nsTextEditRules::WillOutputText(nsISelection *aSelection,
*aCancel = PR_FALSE; *aCancel = PR_FALSE;
*aHandled = PR_FALSE; *aHandled = PR_FALSE;
if (PR_TRUE == aOutputFormat->EqualsWithConversion("text/plain")) nsAutoString outputFormat(*aOutputFormat);
outputFormat.ToLowerCase();
if (outputFormat.Equals(NS_LITERAL_STRING("text/plain")))
{ // only use these rules for plain text output { // only use these rules for plain text output
if (mFlags & nsIPlaintextEditor::eEditorPasswordMask) if (mFlags & nsIPlaintextEditor::eEditorPasswordMask)
{ {
@ -1214,8 +1244,8 @@ nsTextEditRules::CreateBogusNodeIfNeeded(nsISelection *aSelection)
nsresult nsresult
nsTextEditRules::TruncateInsertionIfNeeded(nsISelection *aSelection, nsTextEditRules::TruncateInsertionIfNeeded(nsISelection *aSelection,
const nsString *aInString, const nsAReadableString *aInString,
nsString *aOutString, nsAWritableString *aOutString,
PRInt32 aMaxLength) PRInt32 aMaxLength)
{ {
if (!aSelection || !aInString || !aOutString) {return NS_ERROR_NULL_POINTER;} if (!aSelection || !aInString || !aOutString) {return NS_ERROR_NULL_POINTER;}
@ -1263,7 +1293,7 @@ nsTextEditRules::TruncateInsertionIfNeeded(nsISelection *aSelection,
nsresult nsresult
nsTextEditRules::EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsString *aOutString) nsTextEditRules::EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsAWritableString *aOutString)
{ {
if (!aOutString) {return NS_ERROR_NULL_POINTER;} if (!aOutString) {return NS_ERROR_NULL_POINTER;}
@ -1275,7 +1305,9 @@ nsTextEditRules::EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsString *a
PRInt32 i; PRInt32 i;
aOutString->SetLength(0); aOutString->SetLength(0);
for (i=0; i<length; i++) for (i=0; i<length; i++)
aOutString->AppendWithConversion('*'); {
aOutString->Append(PRUnichar('*'));
}
return NS_OK; return NS_OK;
} }

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

@ -92,8 +92,8 @@ protected:
nsISelection *aSelection, nsISelection *aSelection,
PRBool *aCancel, PRBool *aCancel,
PRBool *aHandled, PRBool *aHandled,
const nsString *inString, const nsAReadableString *inString,
nsString *outString, nsAWritableString *outString,
PRInt32 aMaxLength); PRInt32 aMaxLength);
nsresult DidInsertText(nsISelection *aSelection, nsresult aResult); nsresult DidInsertText(nsISelection *aSelection, nsresult aResult);
nsresult GetTopEnclosingPre(nsIDOMNode *aNode, nsIDOMNode** aOutPreNode); nsresult GetTopEnclosingPre(nsIDOMNode *aNode, nsIDOMNode** aOutPreNode);
@ -132,8 +132,8 @@ protected:
* and use aOutText as the result. * and use aOutText as the result.
*/ */
nsresult WillOutputText(nsISelection *aSelection, nsresult WillOutputText(nsISelection *aSelection,
const nsString *aInFormat, const nsAReadableString *aInFormat,
nsString *aOutText, nsAWritableString *aOutText,
PRBool *aOutCancel, PRBool *aOutCancel,
PRBool *aHandled); PRBool *aHandled);
@ -151,13 +151,13 @@ protected:
/** returns a truncated insertion string if insertion would place us /** returns a truncated insertion string if insertion would place us
over aMaxLength */ over aMaxLength */
nsresult TruncateInsertionIfNeeded(nsISelection *aSelection, nsresult TruncateInsertionIfNeeded(nsISelection *aSelection,
const nsString *aInString, const nsAReadableString *aInString,
nsString *aOutString, nsAWritableString *aOutString,
PRInt32 aMaxLength); PRInt32 aMaxLength);
/** Echo's the insertion text into the password buffer, and converts /** Echo's the insertion text into the password buffer, and converts
insertion text to '*'s */ insertion text to '*'s */
nsresult EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsString *aOutString); nsresult EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsAWritableString *aOutString);
nsresult CreateMozBR(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outBRNode); nsresult CreateMozBR(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outBRNode);
@ -200,9 +200,9 @@ class nsTextRulesInfo : public nsRulesInfo
virtual ~nsTextRulesInfo() {}; virtual ~nsTextRulesInfo() {};
// kInsertText // kInsertText
const nsString *inString; const nsAReadableString *inString;
nsString *outString; nsAWritableString *outString;
const nsString *outputFormat; const nsAReadableString *outputFormat;
PRInt32 maxLength; PRInt32 maxLength;
// kDeleteSelection // kDeleteSelection
@ -213,10 +213,10 @@ class nsTextRulesInfo : public nsRulesInfo
PRBool entireList; PRBool entireList;
// kAlign // kAlign
const nsString *alignType; const nsAReadableString *alignType;
// kMakeBasicBlock // kMakeBasicBlock
const nsString *blockType; const nsAReadableString *blockType;
// kInsertElement // kInsertElement
const nsIDOMElement* insertElement; const nsIDOMElement* insertElement;

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

@ -35,11 +35,11 @@ static NS_DEFINE_CID(kLWBrkCID, NS_LWBRK_CID);
* Rewrap the given section of string, putting the result in aOutString. * Rewrap the given section of string, putting the result in aOutString.
*/ */
nsresult nsresult
nsWrapUtils::Rewrap(const nsString& aInString, nsWrapUtils::Rewrap(const nsAReadableString& aInString,
PRUint32 aWrapCol, PRUint32 aFirstLineOffset, PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
PRBool aRespectNewlines, PRBool aRespectNewlines,
nsString aLineStartStr, const nsAReadableString &aLineStartStr,
nsString& aOutString) nsAWritableString& aOutString)
{ {
PRInt32 i; PRInt32 i;
@ -61,7 +61,8 @@ nsWrapUtils::Rewrap(const nsString& aInString,
// Now we either have a line breaker, or we don't. // Now we either have a line breaker, or we don't.
PRInt32 length = aInString.Length(); PRInt32 length = aInString.Length();
const PRUnichar* unicodeStr = aInString.GetUnicode(); nsString tString(aInString);
const PRUnichar* unicodeStr = tString.GetUnicode();
for (i = 0; i < length; ) // loop over lines for (i = 0; i < length; ) // loop over lines
{ {
nsAutoString remaining(unicodeStr + i, length - i); nsAutoString remaining(unicodeStr + i, length - i);
@ -75,7 +76,7 @@ nsWrapUtils::Rewrap(const nsString& aInString,
if (eol > length) if (eol > length)
{ {
aOutString.Append(unicodeStr + i, length - i); aOutString.Append(unicodeStr + i, length - i);
aOutString.AppendWithConversion('\n'); // DOM line breaks, not NS_LINEBREAK aOutString.Append(PRUnichar('\n')); // DOM line breaks, not NS_LINEBREAK
break; break;
} }
if (i > 0) aFirstLineOffset = 0; if (i > 0) aFirstLineOffset = 0;
@ -108,7 +109,7 @@ nsWrapUtils::Rewrap(const nsString& aInString,
else breakPt += i; else breakPt += i;
nsAutoString appending(unicodeStr + i, breakPt - i); nsAutoString appending(unicodeStr + i, breakPt - i);
aOutString.Append(unicodeStr + i, breakPt - i); aOutString.Append(unicodeStr + i, breakPt - i);
aOutString.AppendWithConversion('\n'); // DOM line breaks, not NS_LINEBREAK aOutString.Append(PRUnichar('\n')); // DOM line breaks, not NS_LINEBREAK
i = breakPt; i = breakPt;
} // continue looping over lines } // continue looping over lines

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

@ -30,11 +30,11 @@
class nsWrapUtils class nsWrapUtils
{ {
public: public:
static nsresult Rewrap(const nsString& aInString, static nsresult Rewrap(const nsAReadableString& aInString,
PRUint32 aWrapCol, PRUint32 aFirstLineOffset, PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
PRBool aRespectNewlines, PRBool aRespectNewlines,
nsString aLineStartStr, const nsAReadableString &aLineStartStr,
nsString& aOutString); nsAWritableString& aOutString);
}; };
#endif //nsWrapUtils_h__ #endif //nsWrapUtils_h__

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

@ -274,7 +274,7 @@ nsPasteQuotationCommand::IsCommandEnabled(const nsAReadableString & aCommandName
nsCOMPtr<nsIEditor> editor; nsCOMPtr<nsIEditor> editor;
editorShell->GetEditor(getter_AddRefs(editor)); editorShell->GetEditor(getter_AddRefs(editor));
if (editor) if (editor)
editor->CanPaste(nsIClipboard::kGlobalClipboard, *outCmdEnabled); editor->CanPaste(nsIClipboard::kGlobalClipboard, outCmdEnabled);
} }
return NS_OK; return NS_OK;
@ -322,7 +322,7 @@ nsStyleUpdatingCommand::GetCurrentState(nsIEditorShell *aEditorShell, const char
if (!htmlEditor) return NS_ERROR_NOT_INITIALIZED; if (!htmlEditor) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIAtom> styleAtom = getter_AddRefs(NS_NewAtom(aTagName)); nsCOMPtr<nsIAtom> styleAtom = getter_AddRefs(NS_NewAtom(aTagName));
rv = htmlEditor->GetInlineProperty(styleAtom, nsnull, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp); rv = htmlEditor->GetInlineProperty(styleAtom, NS_LITERAL_STRING(""), NS_LITERAL_STRING(""), &firstOfSelectionHasProp, &anyOfSelectionHasProp, &allOfSelectionHasProp);
outStyleSet = allOfSelectionHasProp; // change this to alter the behaviour outStyleSet = allOfSelectionHasProp; // change this to alter the behaviour
return rv; return rv;
@ -442,8 +442,7 @@ nsListItemCommand::ToggleState(nsIEditorShell *aEditorShell, const char* aTagNam
{ {
if (!bMixed) if (!bMixed)
{ {
nsAutoString listType(tagStr); rv = htmlEditor->RemoveList(nsLiteralString(tagStr));
rv = htmlEditor->RemoveList(listType);
} }
nsCRT::free(tagStr); nsCRT::free(tagStr);
} }
@ -554,7 +553,7 @@ nsOutdentCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISu
if (htmlEditor) if (htmlEditor)
{ {
PRBool canIndent, canOutdent; PRBool canIndent, canOutdent;
htmlEditor->GetIndentState(canIndent, canOutdent); htmlEditor->GetIndentState(&canIndent, &canOutdent);
*outCmdEnabled = canOutdent; *outCmdEnabled = canOutdent;
} }
@ -690,7 +689,7 @@ nsParagraphStateCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsString&
aEditorShell->GetEditor(getter_AddRefs(editor)); aEditorShell->GetEditor(getter_AddRefs(editor));
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(editor); nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(editor);
if (!htmlEditor) return NS_ERROR_FAILURE; if (!htmlEditor) return NS_ERROR_FAILURE;
return htmlEditor->GetParagraphState(outMixed, outStateString); return htmlEditor->GetParagraphState(&outMixed, outStateString);
} }
@ -727,7 +726,7 @@ nsFontFaceStateCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsString&
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(editor); nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(editor);
if (!htmlEditor) return NS_ERROR_FAILURE; if (!htmlEditor) return NS_ERROR_FAILURE;
return htmlEditor->GetFontFaceState(outMixed, outStateString); return htmlEditor->GetFontFaceState(&outMixed, outStateString);
} }
@ -743,9 +742,6 @@ nsFontFaceStateCommand::SetState(nsIEditorShell *aEditorShell, nsString& newStat
nsresult rv; nsresult rv;
NS_ConvertASCIItoUCS2 emptyString("");
NS_ConvertASCIItoUCS2 fontString("font");
NS_ConvertASCIItoUCS2 faceString("face");
nsCOMPtr<nsIAtom> ttAtom = getter_AddRefs(NS_NewAtom("tt")); nsCOMPtr<nsIAtom> ttAtom = getter_AddRefs(NS_NewAtom("tt"));
nsCOMPtr<nsIAtom> fontAtom = getter_AddRefs(NS_NewAtom("font")); nsCOMPtr<nsIAtom> fontAtom = getter_AddRefs(NS_NewAtom("font"));
@ -753,19 +749,19 @@ nsFontFaceStateCommand::SetState(nsIEditorShell *aEditorShell, nsString& newStat
if (newState.EqualsWithConversion("tt")) if (newState.EqualsWithConversion("tt"))
{ {
// The old "teletype" attribute // The old "teletype" attribute
rv = htmlEditor->SetInlineProperty(ttAtom, &emptyString, &emptyString); rv = htmlEditor->SetInlineProperty(ttAtom, NS_LITERAL_STRING(""), NS_LITERAL_STRING(""));
// Clear existing font face // Clear existing font face
rv = htmlEditor->RemoveInlineProperty(fontAtom, &faceString); rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("face"));
} }
else else
{ {
// Remove any existing TT nodes // Remove any existing TT nodes
rv = htmlEditor->RemoveInlineProperty(ttAtom, &emptyString); rv = htmlEditor->RemoveInlineProperty(ttAtom, NS_LITERAL_STRING(""));
if (newState == emptyString || newState.EqualsWithConversion("normal")) { if (!newState.Length() || newState.EqualsWithConversion("normal")) {
rv = htmlEditor->RemoveInlineProperty(fontAtom, &faceString); rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("face"));
} else { } else {
rv = htmlEditor->SetInlineProperty(fontAtom, &faceString, &newState); rv = htmlEditor->SetInlineProperty(fontAtom, NS_LITERAL_STRING("face"), newState);
} }
} }
@ -791,7 +787,7 @@ nsFontColorStateCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsString&
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(editor); nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(editor);
if (!htmlEditor) return NS_ERROR_FAILURE; if (!htmlEditor) return NS_ERROR_FAILURE;
return htmlEditor->GetFontColorState(outMixed, outStateString); return htmlEditor->GetFontColorState(&outMixed, outStateString);
} }
@ -807,16 +803,13 @@ nsFontColorStateCommand::SetState(nsIEditorShell *aEditorShell, nsString& newSta
nsresult rv; nsresult rv;
NS_ConvertASCIItoUCS2 emptyString("");
NS_ConvertASCIItoUCS2 fontString("font");
NS_ConvertASCIItoUCS2 colorString("color");
nsCOMPtr<nsIAtom> fontAtom = getter_AddRefs(NS_NewAtom("font")); nsCOMPtr<nsIAtom> fontAtom = getter_AddRefs(NS_NewAtom("font"));
if (newState == emptyString || newState.EqualsWithConversion("normal")) { if (!newState.Length() || newState.EqualsWithConversion("normal")) {
rv = htmlEditor->RemoveInlineProperty(fontAtom, &colorString); rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("color"));
} else { } else {
rv = htmlEditor->SetInlineProperty(fontAtom, &colorString, &newState); rv = htmlEditor->SetInlineProperty(fontAtom, NS_LITERAL_STRING("color"), newState);
} }
return rv; return rv;
@ -842,7 +835,7 @@ nsBackgroundColorStateCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsS
if (!htmlEditor) return NS_ERROR_FAILURE; if (!htmlEditor) return NS_ERROR_FAILURE;
return htmlEditor->GetBackgroundColorState(outMixed, outStateString); return htmlEditor->GetBackgroundColorState(&outMixed, outStateString);
} }
@ -879,7 +872,7 @@ nsAlignCommand::GetCurrentState(nsIEditorShell *aEditorShell, nsString& outState
if (!htmlEditor) return NS_ERROR_FAILURE; if (!htmlEditor) return NS_ERROR_FAILURE;
nsIHTMLEditor::EAlignment firstAlign; nsIHTMLEditor::EAlignment firstAlign;
nsresult rv = htmlEditor->GetAlignment(outMixed, firstAlign); nsresult rv = htmlEditor->GetAlignment(&outMixed, &firstAlign);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
switch (firstAlign) switch (firstAlign)
{ {

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

@ -1061,9 +1061,7 @@ nsEditorShell::SetAttribute(nsIDOMElement *element, const PRUnichar *attr, const
nsresult result = NS_NOINTERFACE; nsresult result = NS_NOINTERFACE;
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor); nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
if (editor) { if (editor) {
nsAutoString attributeStr(attr); result = editor->SetAttribute(element, nsLiteralString(attr), nsLiteralString(value));
nsAutoString valueStr(value);
result = editor->SetAttribute(element, attributeStr, valueStr);
} }
return result; return result;
@ -1078,8 +1076,7 @@ nsEditorShell::RemoveAttribute(nsIDOMElement *element, const PRUnichar *attr)
nsresult result = NS_NOINTERFACE; nsresult result = NS_NOINTERFACE;
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor); nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
if (editor) { if (editor) {
nsAutoString attributeStr(attr); result = editor->RemoveAttribute(element, nsLiteralString(attr));
result = editor->RemoveAttribute(element, attributeStr);
} }
return result; return result;
@ -1094,16 +1091,13 @@ nsEditorShell::SetTextProperty(const PRUnichar *prop, const PRUnichar *attr, con
nsCOMPtr<nsIAtom> styleAtom = getter_AddRefs(NS_NewAtom(prop)); /// XXX Hack alert! Look in nsIEditProperty.h for this nsCOMPtr<nsIAtom> styleAtom = getter_AddRefs(NS_NewAtom(prop)); /// XXX Hack alert! Look in nsIEditProperty.h for this
if (! styleAtom) return NS_ERROR_OUT_OF_MEMORY; if (! styleAtom) return NS_ERROR_OUT_OF_MEMORY;
nsAutoString attributeStr(attr);
nsAutoString valueStr(value);
switch (mEditorType) switch (mEditorType)
{ {
case ePlainTextEditorType: case ePlainTextEditorType:
// should we allow this? // should we allow this?
case eHTMLTextEditorType: case eHTMLTextEditorType:
err = mEditor->SetInlineProperty(styleAtom, &attributeStr, &valueStr); err = mEditor->SetInlineProperty(styleAtom, nsLiteralString(attr), nsLiteralString(value));
break; break;
default: default:
err = NS_ERROR_NOT_IMPLEMENTED; err = NS_ERROR_NOT_IMPLEMENTED;
@ -1127,7 +1121,7 @@ nsEditorShell::RemoveOneProperty(const nsString& aProp, const nsString &aAttr)
case ePlainTextEditorType: case ePlainTextEditorType:
// should we allow this? // should we allow this?
case eHTMLTextEditorType: case eHTMLTextEditorType:
err = mEditor->RemoveInlineProperty(styleAtom, &aAttr); err = mEditor->RemoveInlineProperty(styleAtom, aAttr);
break; break;
default: default:
err = NS_ERROR_NOT_IMPLEMENTED; err = NS_ERROR_NOT_IMPLEMENTED;
@ -1172,15 +1166,12 @@ nsEditorShell::GetTextProperty(const PRUnichar *prop, const PRUnichar *attr, con
styleAtom = NS_NewAtom(prop); /// XXX Hack alert! Look in nsIEditProperty.h for this styleAtom = NS_NewAtom(prop); /// XXX Hack alert! Look in nsIEditProperty.h for this
nsAutoString aAttr(attr);
nsAutoString aValue(value);
switch (mEditorType) switch (mEditorType)
{ {
case ePlainTextEditorType: case ePlainTextEditorType:
// should we allow this? // should we allow this?
case eHTMLTextEditorType: case eHTMLTextEditorType:
err = mEditor->GetInlineProperty(styleAtom, &aAttr, &aValue, *firstHas, *anyHas, *allHas); err = mEditor->GetInlineProperty(styleAtom, nsLiteralString(attr), nsLiteralString(value), firstHas, anyHas, allHas);
break; break;
default: default:
err = NS_ERROR_NOT_IMPLEMENTED; err = NS_ERROR_NOT_IMPLEMENTED;
@ -1238,7 +1229,7 @@ nsEditorShell::GetParagraphState(PRBool *aMixed, PRUnichar **_retval)
{ {
PRBool bMixed; PRBool bMixed;
nsAutoString state; nsAutoString state;
err = htmlEditor->GetParagraphState(bMixed, state); err = htmlEditor->GetParagraphState(&bMixed, state);
if (!bMixed) if (!bMixed)
*_retval = state.ToNewUnicode(); *_retval = state.ToNewUnicode();
} }
@ -1257,7 +1248,7 @@ nsEditorShell::GetListState(PRBool *aMixed, PRUnichar **_retval)
if (htmlEditor) if (htmlEditor)
{ {
PRBool bOL, bUL, bDL; PRBool bOL, bUL, bDL;
err = htmlEditor->GetListState(*aMixed, bOL, bUL, bDL); err = htmlEditor->GetListState(aMixed, &bOL, &bUL, &bDL);
if (NS_SUCCEEDED(err)) if (NS_SUCCEEDED(err))
{ {
if (!*aMixed) if (!*aMixed)
@ -1285,7 +1276,7 @@ nsEditorShell::GetListItemState(PRBool *aMixed, PRUnichar **_retval)
if (htmlEditor) if (htmlEditor)
{ {
PRBool bLI,bDT,bDD; PRBool bLI,bDT,bDD;
err = htmlEditor->GetListItemState(*aMixed, bLI, bDT, bDD); err = htmlEditor->GetListItemState(aMixed, &bLI, &bDT, &bDD);
if (NS_SUCCEEDED(err)) if (NS_SUCCEEDED(err))
{ {
if (!*aMixed) if (!*aMixed)
@ -1313,7 +1304,7 @@ nsEditorShell::GetAlignment(PRBool *aMixed, PRUnichar **_retval)
if (htmlEditor) if (htmlEditor)
{ {
nsIHTMLEditor::EAlignment firstAlign; nsIHTMLEditor::EAlignment firstAlign;
err = htmlEditor->GetAlignment(*aMixed, firstAlign); err = htmlEditor->GetAlignment(aMixed, &firstAlign);
if (NS_SUCCEEDED(err)) if (NS_SUCCEEDED(err))
{ {
nsAutoString tagStr; nsAutoString tagStr;
@ -1777,7 +1768,7 @@ nsEditorShell::SaveDocument(PRBool aSaveAs, PRBool aSaveCopy, const PRUnichar* a
return NS_OK; return NS_OK;
} }
// This sets title in HTML node // This sets title in HTML node
mEditor->SetDocumentTitle(titleUnicode); mEditor->SetDocumentTitle(nsLiteralString(titleUnicode));
title = titleUnicode; title = titleUnicode;
nsCRT::free(titleUnicode); nsCRT::free(titleUnicode);
titleChanged = PR_TRUE; titleChanged = PR_TRUE;
@ -2240,7 +2231,7 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title)
if (mEditorType != eHTMLTextEditorType) if (mEditorType != eHTMLTextEditorType)
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
res = mEditor->SetDocumentTitle(title); res = mEditor->SetDocumentTitle(nsLiteralString(title));
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
// PR_FALSE means don't save menu to prefs // PR_FALSE means don't save menu to prefs
@ -2283,7 +2274,7 @@ nsEditorShell::NodeIsBlock(nsIDOMNode *node, PRBool *_retval)
case ePlainTextEditorType: case ePlainTextEditorType:
case eHTMLTextEditorType: case eHTMLTextEditorType:
{ {
rv = mEditor->NodeIsBlock(node, *_retval); rv = mEditor->NodeIsBlock(node, _retval);
} }
break; break;
@ -2610,7 +2601,7 @@ nsEditorShell::InsertText(const PRUnichar *textToInsert)
{ {
nsCOMPtr<nsIPlaintextEditor> textEditor (do_QueryInterface(mEditor)); nsCOMPtr<nsIPlaintextEditor> textEditor (do_QueryInterface(mEditor));
if (textEditor) if (textEditor)
err = textEditor->InsertText(textToInsert); err = textEditor->InsertText(nsLiteralString(textToInsert));
} }
break; break;
@ -2953,11 +2944,19 @@ nsEditorShell::Alert(const nsString& aTitle, const nsString& aMsg)
NS_IMETHODIMP NS_IMETHODIMP
nsEditorShell::GetDocumentCharacterSet(PRUnichar** characterSet) nsEditorShell::GetDocumentCharacterSet(PRUnichar** characterSet)
{ {
if (!characterSet)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor); nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
nsAutoString copiedData;
*characterSet = nsnull;
if (editor) if (editor)
return editor->GetDocumentCharacterSet(characterSet); {
if (NS_SUCCEEDED(editor->GetDocumentCharacterSet(copiedData)))
{
*characterSet = ToNewUnicode(copiedData);
return NS_OK;
}
}
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -2968,7 +2967,7 @@ nsEditorShell::SetDocumentCharacterSet(const PRUnichar* characterSet)
nsresult res = NS_OK; nsresult res = NS_OK;
if (editor) if (editor)
res = editor->SetDocumentCharacterSet(characterSet); res = editor->SetDocumentCharacterSet(nsAutoString(characterSet));
if(NS_SUCCEEDED(res)) { if(NS_SUCCEEDED(res)) {
nsCOMPtr<nsIScriptGlobalObject> globalObj( do_QueryReferent(mContentWindow)); nsCOMPtr<nsIScriptGlobalObject> globalObj( do_QueryReferent(mContentWindow));

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

@ -29,12 +29,18 @@ include $(DEPTH)/config/autoconf.mk
MODULE = editor MODULE = editor
XPIDLSRCS = \ XPIDLSRCS = \
nsIPlaintextEditor.idl \ nsICiter.idl \
nsIDocumentStateListener.idl \
nsIEditActionListener.idl \
nsIEditorController.idl \
nsIEditor.idl \
nsIEditorIMESupport.idl \
nsIEditorObserver.idl \
nsIEditorService.idl \
nsIEditorShell.idl \ nsIEditorShell.idl \
nsIEditorSpellCheck.idl \ nsIEditorSpellCheck.idl \
nsIDocumentStateListener.idl \ nsIHTMLEditor.idl \
nsIEditorService.idl \ nsIPlaintextEditor.idl \
nsIEditorController.idl \
nsPIEditorTransaction.idl \ nsPIEditorTransaction.idl \
$(NULL) $(NULL)

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

@ -26,13 +26,19 @@ DEPTH=..\..
MODULE=editor MODULE=editor
XPIDL_MODULE=editor XPIDL_MODULE=editor
XPIDLSRCS = .\nsIEditorShell.idl \ XPIDLSRCS = .\nsICiter.idl \
.\nsIPlaintextEditor.idl \ .\nsIDocumentStateListener.idl \
.\nsIEditorSpellCheck.idl \ .\nsIEditActionListener.idl \
.\nsIDocumentStateListener.idl \ .\nsIEditorController.idl \
.\nsIEditorService.idl \ .\nsIEditor.idl \
.\nsIEditorController.idl \ .\nsIEditorIMESupport.idl \
.\nsPIEditorTransaction.idl \ .\nsIEditorObserver.idl \
.\nsIEditorService.idl \
.\nsIEditorShell.idl \
.\nsIEditorSpellCheck.idl \
.\nsIHTMLEditor.idl \
.\nsIPlaintextEditor.idl \
.\nsPIEditorTransaction.idl \
$(NULL) $(NULL)
include <$(DEPTH)\config\rules.mak> include <$(DEPTH)\config\rules.mak>

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

@ -25,7 +25,9 @@
#include "nsISupports.idl" #include "nsISupports.idl"
#include "domstubs.idl" #include "domstubs.idl"
%{C++
#include "nsString.h"
%}
/** Handle plaintext citations, as in mail quoting. /** Handle plaintext citations, as in mail quoting.
* Used by the editor but not dependant on it. * Used by the editor but not dependant on it.
*/ */

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

@ -326,14 +326,6 @@ interface nsIEditor : nsISupports
/* ------------ Node manipulation methods -------------- */ /* ------------ Node manipulation methods -------------- */
/**
* Tests if a node is a BLOCK element according the the HTML 4.0 DTD
* This does NOT consider CSS effect on display type
*
* @param aNode the node to test
*/
void NodeIsBlock(in nsIDOMNode node, out boolean isBlock);
/** /**
* SetAttribute() sets the attribute of aElement. * SetAttribute() sets the attribute of aElement.
* No checking is done to see if aAttribute is a legal attribute of the node, * No checking is done to see if aAttribute is a legal attribute of the node,

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

@ -146,6 +146,14 @@ interface nsIHTMLEditor : nsISupports
/* ------------ HTML content methods -------------- */ /* ------------ HTML content methods -------------- */
/**
* Tests if a node is a BLOCK element according the the HTML 4.0 DTD
* This does NOT consider CSS effect on display type
*
* @param aNode the node to test
*/
void NodeIsBlock(in nsIDOMNode node, out boolean isBlock);
/** /**
* Insert some HTML source at the current location * Insert some HTML source at the current location
* *

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

@ -89,7 +89,7 @@ interface nsIPlaintextEditor : nsISupports
* *
* @param aString the string to be inserted * @param aString the string to be inserted
*/ */
void insertText(in wstring aStringToInsert); void insertText(in DOMString aStringToInsert);
/** /**
* Insert a line break into the content model. * Insert a line break into the content model.

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

@ -35,8 +35,8 @@ ChangeAttributeTxn::~ChangeAttributeTxn()
NS_IMETHODIMP ChangeAttributeTxn::Init(nsIEditor *aEditor, NS_IMETHODIMP ChangeAttributeTxn::Init(nsIEditor *aEditor,
nsIDOMElement *aElement, nsIDOMElement *aElement,
const nsString& aAttribute, const nsAReadableString& aAttribute,
const nsString& aValue, const nsAReadableString& aValue,
PRBool aRemoveAttribute) PRBool aRemoveAttribute)
{ {
NS_ASSERTION(aEditor && aElement, "bad arg"); NS_ASSERTION(aEditor && aElement, "bad arg");
@ -58,7 +58,7 @@ NS_IMETHODIMP ChangeAttributeTxn::DoTransaction(void)
if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; } if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; }
// need to get the current value of the attribute and save it, and set mAttributeWasSet // need to get the current value of the attribute and save it, and set mAttributeWasSet
nsresult result = mEditor->GetAttributeValue(mElement, mAttribute, mUndoValue, mAttributeWasSet); nsresult result = mEditor->GetAttributeValue(mElement, mAttribute, mUndoValue, &mAttributeWasSet);
// XXX: hack until attribute-was-set code is implemented // XXX: hack until attribute-was-set code is implemented
if (PR_FALSE==mUndoValue.IsEmpty()) if (PR_FALSE==mUndoValue.IsEmpty())
mAttributeWasSet=PR_TRUE; mAttributeWasSet=PR_TRUE;

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

@ -54,8 +54,8 @@ public:
*/ */
NS_IMETHOD Init(nsIEditor *aEditor, NS_IMETHOD Init(nsIEditor *aEditor,
nsIDOMElement *aNode, nsIDOMElement *aNode,
const nsString& aAttribute, const nsAReadableString& aAttribute,
const nsString& aValue, const nsAReadableString& aValue,
PRBool aRemoveAttribute); PRBool aRemoveAttribute);
private: private:

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

@ -43,7 +43,7 @@ CreateElementTxn::CreateElementTxn()
} }
NS_IMETHODIMP CreateElementTxn::Init(nsEditor *aEditor, NS_IMETHODIMP CreateElementTxn::Init(nsEditor *aEditor,
const nsString &aTag, const nsAReadableString &aTag,
nsIDOMNode *aParent, nsIDOMNode *aParent,
PRUint32 aOffsetInParent) PRUint32 aOffsetInParent)
{ {

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

@ -52,7 +52,7 @@ public:
* if eAppend, the new element is appended as the last child * if eAppend, the new element is appended as the last child
*/ */
NS_IMETHOD Init(nsEditor *aEditor, NS_IMETHOD Init(nsEditor *aEditor,
const nsString& aTag, const nsAReadableString& aTag,
nsIDOMNode *aParent, nsIDOMNode *aParent,
PRUint32 aOffsetInParent); PRUint32 aOffsetInParent);

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

@ -65,7 +65,7 @@ NS_IMETHODIMP IMETextTxn::Init(nsIDOMCharacterData *aElement,
PRUint32 aOffset, PRUint32 aOffset,
PRUint32 aReplaceLength, PRUint32 aReplaceLength,
nsIPrivateTextRangeList *aTextRangeList, nsIPrivateTextRangeList *aTextRangeList,
const nsString &aStringToInsert, const nsAReadableString &aStringToInsert,
nsWeakPtr aSelConWeak) nsWeakPtr aSelConWeak)
{ {
NS_ASSERTION(aElement, "illegal value- null ptr- aElement"); NS_ASSERTION(aElement, "illegal value- null ptr- aElement");

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

@ -65,7 +65,7 @@ public:
PRUint32 aOffset, PRUint32 aOffset,
PRUint32 aReplaceLength, PRUint32 aReplaceLength,
nsIPrivateTextRangeList* aTextRangeList, nsIPrivateTextRangeList* aTextRangeList,
const nsString& aString, const nsAReadableString& aString,
nsWeakPtr aSelCon); nsWeakPtr aSelCon);
private: private:

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

@ -60,7 +60,7 @@ InsertTextTxn::~InsertTextTxn()
NS_IMETHODIMP InsertTextTxn::Init(nsIDOMCharacterData *aElement, NS_IMETHODIMP InsertTextTxn::Init(nsIDOMCharacterData *aElement,
PRUint32 aOffset, PRUint32 aOffset,
const nsString &aStringToInsert, const nsAReadableString &aStringToInsert,
nsIEditor *aEditor) nsIEditor *aEditor)
{ {
#if 0 //def DEBUG_cmanske #if 0 //def DEBUG_cmanske

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

@ -59,7 +59,7 @@ public:
*/ */
NS_IMETHOD Init(nsIDOMCharacterData *aElement, NS_IMETHOD Init(nsIDOMCharacterData *aElement,
PRUint32 aOffset, PRUint32 aOffset,
const nsString& aString, const nsAReadableString& aString,
nsIEditor *aEditor); nsIEditor *aEditor);
private: private:

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

@ -38,7 +38,7 @@ SetDocTitleTxn::SetDocTitleTxn()
} }
NS_IMETHODIMP SetDocTitleTxn::Init(nsIHTMLEditor *aEditor, NS_IMETHODIMP SetDocTitleTxn::Init(nsIHTMLEditor *aEditor,
const nsString *aValue) const nsAReadableString *aValue)
{ {
NS_ASSERTION(aEditor && aValue, "null args"); NS_ASSERTION(aEditor && aValue, "null args");
@ -72,7 +72,7 @@ NS_IMETHODIMP SetDocTitleTxn::RedoTransaction(void)
return SetDocTitle(mValue); return SetDocTitle(mValue);
} }
nsresult SetDocTitleTxn::SetDocTitle(nsString& aTitle) nsresult SetDocTitleTxn::SetDocTitle(const nsAReadableString& aTitle)
{ {
NS_ASSERTION(mEditor, "bad state"); NS_ASSERTION(mEditor, "bad state");
if (!mEditor) return NS_ERROR_NOT_INITIALIZED; if (!mEditor) return NS_ERROR_NOT_INITIALIZED;
@ -89,7 +89,7 @@ nsresult SetDocTitleTxn::SetDocTitle(nsString& aTitle)
return HTMLDoc->SetTitle(aTitle); return HTMLDoc->SetTitle(aTitle);
} }
nsresult SetDocTitleTxn::SetDomTitle(nsString& aTitle) nsresult SetDocTitleTxn::SetDomTitle(const nsAReadableString& aTitle)
{ {
nsCOMPtr<nsIDOMDocument> domDoc; nsCOMPtr<nsIDOMDocument> domDoc;
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor); nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);

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

@ -53,11 +53,11 @@ public:
* @param aValue the new value for document title * @param aValue the new value for document title
*/ */
NS_IMETHOD Init(nsIHTMLEditor *aEditor, NS_IMETHOD Init(nsIHTMLEditor *aEditor,
const nsString *aValue); const nsAReadableString *aValue);
private: private:
SetDocTitleTxn(); SetDocTitleTxn();
nsresult SetDocTitle(nsString& aTitle); nsresult SetDocTitle(const nsAReadableString& aTitle);
nsresult SetDomTitle(nsString& aTitle); nsresult SetDomTitle(const nsAReadableString& aTitle);
public: public:
NS_IMETHOD DoTransaction(void); NS_IMETHOD DoTransaction(void);

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

@ -580,17 +580,19 @@ nsEditor::Undo(PRUint32 aCount)
} }
NS_IMETHODIMP nsEditor::CanUndo(PRBool &aIsEnabled, PRBool &aCanUndo) NS_IMETHODIMP nsEditor::CanUndo(PRBool *aIsEnabled, PRBool *aCanUndo)
{ {
aIsEnabled = ((PRBool)((nsITransactionManager *)0!=mTxnMgr.get())); if (!aIsEnabled || !aCanUndo)
if (aIsEnabled) return NS_ERROR_NULL_POINTER;
*aIsEnabled = ((PRBool)((nsITransactionManager *)0!=mTxnMgr.get()));
if (*aIsEnabled)
{ {
PRInt32 numTxns=0; PRInt32 numTxns=0;
mTxnMgr->GetNumberOfUndoItems(&numTxns); mTxnMgr->GetNumberOfUndoItems(&numTxns);
aCanUndo = ((PRBool)(0!=numTxns)); *aCanUndo = ((PRBool)(0!=numTxns));
} }
else { else {
aCanUndo = PR_FALSE; *aCanUndo = PR_FALSE;
} }
return NS_OK; return NS_OK;
} }
@ -624,17 +626,20 @@ nsEditor::Redo(PRUint32 aCount)
} }
NS_IMETHODIMP nsEditor::CanRedo(PRBool &aIsEnabled, PRBool &aCanRedo) NS_IMETHODIMP nsEditor::CanRedo(PRBool *aIsEnabled, PRBool *aCanRedo)
{ {
aIsEnabled = ((PRBool)((nsITransactionManager *)0!=mTxnMgr.get())); if (!aIsEnabled || !aCanRedo)
if (aIsEnabled) return NS_ERROR_NULL_POINTER;
*aIsEnabled = ((PRBool)((nsITransactionManager *)0!=mTxnMgr.get()));
if (*aIsEnabled)
{ {
PRInt32 numTxns=0; PRInt32 numTxns=0;
mTxnMgr->GetNumberOfRedoItems(&numTxns); mTxnMgr->GetNumberOfRedoItems(&numTxns);
aCanRedo = ((PRBool)(0!=numTxns)); *aCanRedo = ((PRBool)(0!=numTxns));
} }
else { else {
aCanRedo = PR_FALSE; *aCanRedo = PR_FALSE;
} }
return NS_OK; return NS_OK;
} }
@ -891,24 +896,19 @@ nsEditor::GetDocumentModified(PRBool *outDocModified)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::GetDocumentCharacterSet(PRUnichar** characterSet) nsEditor::GetDocumentCharacterSet(nsAWritableString &characterSet)
{ {
nsresult rv; nsresult rv;
nsCOMPtr<nsIDocument> doc; nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIPresShell> presShell; nsCOMPtr<nsIPresShell> presShell;
nsAutoString character_set;
if (characterSet==nsnull) return NS_ERROR_NULL_POINTER;
rv = GetPresShell(getter_AddRefs(presShell)); rv = GetPresShell(getter_AddRefs(presShell));
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
presShell->GetDocument(getter_AddRefs(doc)); presShell->GetDocument(getter_AddRefs(doc));
if (doc ) { if (doc )
rv = doc->GetDocumentCharacterSet(character_set); return doc->GetDocumentCharacterSet(characterSet);
if (NS_SUCCEEDED(rv)) *characterSet=character_set.ToNewUnicode(); rv = NS_ERROR_NULL_POINTER;
return rv;
}
} }
return rv; return rv;
@ -916,22 +916,20 @@ nsEditor::GetDocumentCharacterSet(PRUnichar** characterSet)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::SetDocumentCharacterSet(const PRUnichar* characterSet) nsEditor::SetDocumentCharacterSet(const nsAReadableString& characterSet)
{ {
nsresult rv; nsresult rv;
nsCOMPtr<nsIDocument> doc; nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIPresShell> presShell; nsCOMPtr<nsIPresShell> presShell;
nsAutoString character_set(characterSet);
if (characterSet==nsnull) return NS_ERROR_NULL_POINTER;
rv = GetPresShell(getter_AddRefs(presShell)); rv = GetPresShell(getter_AddRefs(presShell));
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
presShell->GetDocument(getter_AddRefs(doc)); presShell->GetDocument(getter_AddRefs(doc));
if (doc) { if (doc) {
return doc->SetDocumentCharacterSet(character_set); return doc->SetDocumentCharacterSet(characterSet);
} }
rv = NS_ERROR_NULL_POINTER;
} }
return rv; return rv;
@ -957,7 +955,7 @@ nsEditor::GetWrapWidth(PRInt32 *aWrapColumn)
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting, nsEditor::SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting,
PRBool aSaveCopy, const nsString& aFormat) PRBool aSaveCopy, const nsAReadableString& aFormat)
{ {
if (!aFileSpec) if (!aFileSpec)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
@ -997,8 +995,9 @@ nsEditor::SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting,
GetWrapWidth(&wrapColumn); GetWrapWidth(&wrapColumn);
if (wrapColumn > 0) if (wrapColumn > 0)
flags |= nsIDocumentEncoder::OutputWrap; flags |= nsIDocumentEncoder::OutputWrap;
const nsPromiseFlatString &formatFlat = PromiseFlatString(aFormat);
rv = diskDoc->SaveFile(aFileSpec, aReplaceExisting, aSaveCopy, rv = diskDoc->SaveFile(aFileSpec, aReplaceExisting, aSaveCopy,
aFormat.GetUnicode(), NS_LITERAL_STRING("").get(), formatFlat.get(), NS_LITERAL_STRING("").get(),
flags, wrapColumn); flags, wrapColumn);
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
DoAfterDocumentSave(); DoAfterDocumentSave();
@ -1015,7 +1014,7 @@ nsEditor::Cut()
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::CanCut(PRBool &aCanCut) nsEditor::CanCut(PRBool *aCanCut)
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
@ -1027,7 +1026,7 @@ nsEditor::Copy()
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::CanCopy(PRBool &aCanCopy) nsEditor::CanCopy(PRBool *aCanCut)
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
@ -1039,13 +1038,13 @@ nsEditor::Paste(PRInt32 aSelectionType)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste) nsEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste)
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::CanDrag(nsIDOMEvent *aEvent, PRBool &aCanDrag) nsEditor::CanDrag(nsIDOMEvent *aEvent, PRBool *aCanDrag)
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
@ -1064,7 +1063,7 @@ nsEditor::InsertFromDrop(nsIDOMEvent *aEvent)
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::SetAttribute(nsIDOMElement *aElement, const nsString& aAttribute, const nsString& aValue) nsEditor::SetAttribute(nsIDOMElement *aElement, const nsAReadableString & aAttribute, const nsAReadableString & aValue)
{ {
ChangeAttributeTxn *txn; ChangeAttributeTxn *txn;
nsresult result = CreateTxnForSetAttribute(aElement, aAttribute, aValue, &txn); nsresult result = CreateTxnForSetAttribute(aElement, aAttribute, aValue, &txn);
@ -1079,11 +1078,13 @@ nsEditor::SetAttribute(nsIDOMElement *aElement, const nsString& aAttribute, cons
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::GetAttributeValue(nsIDOMElement *aElement, nsEditor::GetAttributeValue(nsIDOMElement *aElement,
const nsString& aAttribute, const nsAReadableString & aAttribute,
nsString& aResultValue, nsAWritableString & aResultValue,
PRBool& aResultIsSet) PRBool *aResultIsSet)
{ {
aResultIsSet=PR_FALSE; if (!aResultIsSet)
return NS_ERROR_NULL_POINTER;
*aResultIsSet=PR_FALSE;
nsresult result=NS_OK; nsresult result=NS_OK;
if (nsnull!=aElement) if (nsnull!=aElement)
{ {
@ -1091,7 +1092,7 @@ nsEditor::GetAttributeValue(nsIDOMElement *aElement,
result = aElement->GetAttributeNode(aAttribute, getter_AddRefs(attNode)); result = aElement->GetAttributeNode(aAttribute, getter_AddRefs(attNode));
if ((NS_SUCCEEDED(result)) && attNode) if ((NS_SUCCEEDED(result)) && attNode)
{ {
attNode->GetSpecified(&aResultIsSet); attNode->GetSpecified(aResultIsSet);
attNode->GetValue(aResultValue); attNode->GetValue(aResultValue);
} }
} }
@ -1099,7 +1100,7 @@ nsEditor::GetAttributeValue(nsIDOMElement *aElement,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::RemoveAttribute(nsIDOMElement *aElement, const nsString& aAttribute) nsEditor::RemoveAttribute(nsIDOMElement *aElement, const nsAReadableString& aAttribute)
{ {
ChangeAttributeTxn *txn; ChangeAttributeTxn *txn;
nsresult result = CreateTxnForRemoveAttribute(aElement, aAttribute, &txn); nsresult result = CreateTxnForRemoveAttribute(aElement, aAttribute, &txn);
@ -1129,7 +1130,7 @@ nsEditor::MarkNodeDirty(nsIDOMNode* aNode)
#pragma mark - #pragma mark -
#endif #endif
NS_IMETHODIMP nsEditor::CreateNode(const nsString& aTag, NS_IMETHODIMP nsEditor::CreateNode(const nsAReadableString& aTag,
nsIDOMNode * aParent, nsIDOMNode * aParent,
PRInt32 aPosition, PRInt32 aPosition,
nsIDOMNode ** aNewNode) nsIDOMNode ** aNewNode)
@ -1380,9 +1381,9 @@ NS_IMETHODIMP nsEditor::DeleteNode(nsIDOMNode * aElement)
nsresult nsresult
nsEditor::ReplaceContainer(nsIDOMNode *inNode, nsEditor::ReplaceContainer(nsIDOMNode *inNode,
nsCOMPtr<nsIDOMNode> *outNode, nsCOMPtr<nsIDOMNode> *outNode,
const nsString &aNodeType, const nsAReadableString &aNodeType,
const nsString *aAttribute, const nsAReadableString *aAttribute,
const nsString *aValue, const nsAReadableString *aValue,
PRBool aCloneAttributes) PRBool aCloneAttributes)
{ {
if (!inNode || !outNode) if (!inNode || !outNode)
@ -1502,9 +1503,9 @@ nsEditor::RemoveContainer(nsIDOMNode *inNode)
nsresult nsresult
nsEditor::InsertContainerAbove( nsIDOMNode *inNode, nsEditor::InsertContainerAbove( nsIDOMNode *inNode,
nsCOMPtr<nsIDOMNode> *outNode, nsCOMPtr<nsIDOMNode> *outNode,
const nsString &aNodeType, const nsAReadableString &aNodeType,
const nsString *aAttribute, const nsAReadableString *aAttribute,
const nsString *aValue) const nsAReadableString *aValue)
{ {
if (!inNode || !outNode) if (!inNode || !outNode)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
@ -1771,7 +1772,7 @@ NS_IMETHODIMP nsEditor::OutputToString(nsAWritableString& aOutputString,
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::OutputToStream(nsIOutputStream* aOutputStream, nsEditor::OutputToStream(nsIOutputStream* aOutputStream,
const nsAReadableString& aFormatType, const nsAReadableString& aFormatType,
const nsAReadableString* aCharsetOverride, const nsAReadableString& aCharsetOverride,
PRUint32 aFlags) PRUint32 aFlags)
{ {
// these should be implemented by derived classes. // these should be implemented by derived classes.
@ -1788,7 +1789,7 @@ nsEditor::DumpContentTree()
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::DebugDumpContent() const nsEditor::DebugDumpContent()
{ {
nsCOMPtr<nsIContent>content; nsCOMPtr<nsIContent>content;
nsCOMPtr<nsIDOMNodeList>nodeList; nsCOMPtr<nsIDOMNodeList>nodeList;
@ -1935,7 +1936,7 @@ nsEditor::EndComposition(void)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply) nsEditor::SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply)
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
@ -2276,7 +2277,7 @@ NS_IMETHODIMP nsEditor::ScrollIntoView(PRBool aScrollToBegin)
} }
/** static helper method */ /** static helper method */
nsresult nsEditor::GetTextNodeTag(nsString& aOutString) nsresult nsEditor::GetTextNodeTag(nsAWritableString& aOutString)
{ {
aOutString.SetLength(0); aOutString.SetLength(0);
static nsString *gTextNodeTag=nsnull; static nsString *gTextNodeTag=nsnull;
@ -2291,7 +2292,7 @@ nsresult nsEditor::GetTextNodeTag(nsString& aOutString)
} }
NS_IMETHODIMP nsEditor::InsertTextImpl(const nsString& aStringToInsert, NS_IMETHODIMP nsEditor::InsertTextImpl(const nsAReadableString& aStringToInsert,
nsCOMPtr<nsIDOMNode> *aInOutNode, nsCOMPtr<nsIDOMNode> *aInOutNode,
PRInt32 *aInOutOffset, PRInt32 *aInOutOffset,
nsIDOMDocument *aDoc) nsIDOMDocument *aDoc)
@ -2352,7 +2353,7 @@ NS_IMETHODIMP nsEditor::InsertTextImpl(const nsString& aStringToInsert,
} }
NS_IMETHODIMP nsEditor::InsertTextIntoTextNodeImpl(const nsString& aStringToInsert, NS_IMETHODIMP nsEditor::InsertTextIntoTextNodeImpl(const nsAReadableString& aStringToInsert,
nsIDOMCharacterData *aTextNode, nsIDOMCharacterData *aTextNode,
PRInt32 aOffset) PRInt32 aOffset)
{ {
@ -2570,7 +2571,7 @@ nsEditor::NotifyDocumentListeners(TDocumentListenerNotification aNotificationTyp
} }
NS_IMETHODIMP nsEditor::CreateTxnForInsertText(const nsString & aStringToInsert, NS_IMETHODIMP nsEditor::CreateTxnForInsertText(const nsAReadableString & aStringToInsert,
nsIDOMCharacterData *aTextNode, nsIDOMCharacterData *aTextNode,
PRInt32 aOffset, PRInt32 aOffset,
InsertTextTxn ** aTxn) InsertTextTxn ** aTxn)
@ -3077,6 +3078,7 @@ nsEditor::GetLengthOfDOMNode(nsIDOMNode *aNode, PRUint32 &aCount)
return result; return result;
} }
nsresult nsresult
nsEditor::GetPriorNode(nsIDOMNode *aParentNode, nsEditor::GetPriorNode(nsIDOMNode *aParentNode,
PRInt32 aOffset, PRInt32 aOffset,
@ -3379,24 +3381,22 @@ nsEditor::NodeIsType(nsIDOMNode *aNode, nsIAtom *aTag)
} }
PRBool PRBool
nsEditor::NodeIsType(nsIDOMNode *aNode, const nsString &aTagStr) nsEditor::NodeIsType(nsIDOMNode *aNode, const nsAReadableString &aTagStr)
{ {
nsCOMPtr<nsIDOMElement>element; nsCOMPtr<nsIDOMElement>element;
element = do_QueryInterface(aNode); element = do_QueryInterface(aNode);
if (element) if (element)
{ {
nsAutoString tag; nsAutoString tag, tagStr(aTagStr);
element->GetTagName(tag); element->GetTagName(tag);
if (tag.EqualsIgnoreCase(aTagStr)) if (tag.EqualsIgnoreCase(tagStr))
{
return PR_TRUE; return PR_TRUE;
}
} }
return PR_FALSE; return PR_FALSE;
} }
PRBool PRBool
nsEditor::CanContainTag(nsIDOMNode* aParent, const nsString &aChildTag) nsEditor::CanContainTag(nsIDOMNode* aParent, const nsAReadableString &aChildTag)
{ {
nsAutoString parentStringTag; nsAutoString parentStringTag;
@ -3408,7 +3408,7 @@ nsEditor::CanContainTag(nsIDOMNode* aParent, const nsString &aChildTag)
} }
PRBool PRBool
nsEditor::TagCanContain(const nsString &aParentTag, nsIDOMNode* aChild) nsEditor::TagCanContain(const nsAReadableString &aParentTag, nsIDOMNode* aChild)
{ {
nsAutoString childStringTag; nsAutoString childStringTag;
@ -3426,7 +3426,7 @@ nsEditor::TagCanContain(const nsString &aParentTag, nsIDOMNode* aChild)
} }
PRBool PRBool
nsEditor::TagCanContainTag(const nsString &aParentTag, const nsString &aChildTag) nsEditor::TagCanContainTag(const nsAReadableString &aParentTag, const nsAReadableString &aChildTag)
{ {
// if we don't have a dtd then assume we can insert whatever want // if we don't have a dtd then assume we can insert whatever want
if (!mDTD) return PR_TRUE; if (!mDTD) return PR_TRUE;
@ -3680,7 +3680,7 @@ void nsEditor::HACKForceRedraw()
nsresult nsresult
nsEditor::GetFirstNodeOfType(nsIDOMNode *aStartNode, nsEditor::GetFirstNodeOfType(nsIDOMNode *aStartNode,
const nsString &aTag, const nsAReadableString &aTag,
nsIDOMNode **aResult) nsIDOMNode **aResult)
{ {
nsresult result=NS_OK; nsresult result=NS_OK;
@ -3697,11 +3697,11 @@ nsEditor::GetFirstNodeOfType(nsIDOMNode *aStartNode,
while (childNode) while (childNode)
{ {
result = childNode->QueryInterface(NS_GET_IID(nsIDOMNode),getter_AddRefs(element)); result = childNode->QueryInterface(NS_GET_IID(nsIDOMNode),getter_AddRefs(element));
nsAutoString tag;
if (NS_SUCCEEDED(result) && (element)) if (NS_SUCCEEDED(result) && (element))
{ {
nsAutoString tag, tagStr(aTag);
element->GetTagName(tag); element->GetTagName(tag);
if (PR_TRUE==aTag.EqualsIgnoreCase(tag)) if (tagStr.EqualsIgnoreCase(tag))
{ {
return (childNode->QueryInterface(NS_GET_IID(nsIDOMNode),(void **) aResult)); // does the addref return (childNode->QueryInterface(NS_GET_IID(nsIDOMNode),(void **) aResult)); // does the addref
} }
@ -3797,7 +3797,7 @@ nsEditor::GetTag(nsIDOMNode *aNode)
// GetTagString: digs out string for the tag of this node // GetTagString: digs out string for the tag of this node
// //
nsresult nsresult
nsEditor::GetTagString(nsIDOMNode *aNode, nsString& outString) nsEditor::GetTagString(nsIDOMNode *aNode, nsAWritableString& outString)
{ {
nsCOMPtr<nsIAtom> atom; nsCOMPtr<nsIAtom> atom;
@ -3840,7 +3840,6 @@ nsEditor::NodesSameType(nsIDOMNode *aNode1, nsIDOMNode *aNode2)
} }
///////////////////////////////////////////////////////////////////////////
// IsTextOrElementNode: true if node of dom type element or text // IsTextOrElementNode: true if node of dom type element or text
// //
PRBool PRBool
@ -4378,7 +4377,7 @@ nsEditor::DeleteSelectionImpl(nsIEditor::EDirection aAction)
// XXX: error handling in this routine needs to be cleaned up! // XXX: error handling in this routine needs to be cleaned up!
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::DeleteSelectionAndCreateNode(const nsString& aTag, nsEditor::DeleteSelectionAndCreateNode(const nsAReadableString& aTag,
nsIDOMNode ** aNewNode) nsIDOMNode ** aNewNode)
{ {
nsCOMPtr<nsIDOMNode> parentSelectedNode; nsCOMPtr<nsIDOMNode> parentSelectedNode;
@ -4557,8 +4556,8 @@ nsEditor::DoAfterDocumentSave()
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::CreateTxnForSetAttribute(nsIDOMElement *aElement, nsEditor::CreateTxnForSetAttribute(nsIDOMElement *aElement,
const nsString& aAttribute, const nsAReadableString& aAttribute,
const nsString& aValue, const nsAReadableString& aValue,
ChangeAttributeTxn ** aTxn) ChangeAttributeTxn ** aTxn)
{ {
nsresult result = NS_ERROR_NULL_POINTER; nsresult result = NS_ERROR_NULL_POINTER;
@ -4575,7 +4574,7 @@ nsEditor::CreateTxnForSetAttribute(nsIDOMElement *aElement,
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::CreateTxnForRemoveAttribute(nsIDOMElement *aElement, nsEditor::CreateTxnForRemoveAttribute(nsIDOMElement *aElement,
const nsString& aAttribute, const nsAReadableString& aAttribute,
ChangeAttributeTxn ** aTxn) ChangeAttributeTxn ** aTxn)
{ {
nsresult result = NS_ERROR_NULL_POINTER; nsresult result = NS_ERROR_NULL_POINTER;
@ -4592,7 +4591,7 @@ nsEditor::CreateTxnForRemoveAttribute(nsIDOMElement *aElement,
} }
NS_IMETHODIMP nsEditor::CreateTxnForCreateElement(const nsString& aTag, NS_IMETHODIMP nsEditor::CreateTxnForCreateElement(const nsAReadableString& aTag,
nsIDOMNode *aParent, nsIDOMNode *aParent,
PRInt32 aPosition, PRInt32 aPosition,
CreateElementTxn ** aTxn) CreateElementTxn ** aTxn)
@ -4680,7 +4679,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteElement(nsIDOMNode * aElement,
*/ */
NS_IMETHODIMP NS_IMETHODIMP
nsEditor::CreateTxnForIMEText(const nsString & aStringToInsert, nsEditor::CreateTxnForIMEText(const nsAReadableString& aStringToInsert,
IMETextTxn ** aTxn) IMETextTxn ** aTxn)
{ {
NS_ASSERTION(aTxn, "illegal value- null ptr- aTxn"); NS_ASSERTION(aTxn, "illegal value- null ptr- aTxn");
@ -5085,7 +5084,7 @@ nsresult nsEditor::ClearSelection()
} }
nsresult nsresult
nsEditor::CreateHTMLContent(const nsString& aTag, nsIContent** aContent) nsEditor::CreateHTMLContent(const nsAReadableString& aTag, nsIContent** aContent)
{ {
nsresult rv; nsresult rv;

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

@ -122,123 +122,16 @@ public:
//NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor //NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
/* ------------ nsIEditor methods -------------- */ /* ------------ utility methods -------------- */
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, nsIContent *aRoot, nsISelectionController *aSelCon, PRUint32 aFlags);
NS_IMETHOD PostCreate();
NS_IMETHOD PreDestroy();
NS_IMETHOD GetFlags(PRUint32 *aFlags);
NS_IMETHOD SetFlags(PRUint32 aFlags);
NS_IMETHOD GetDocument(nsIDOMDocument **aDoc);
NS_IMETHOD GetRootElement(nsIDOMElement **aElement);
NS_IMETHOD GetPresShell(nsIPresShell **aPS); NS_IMETHOD GetPresShell(nsIPresShell **aPS);
NS_IMETHOD GetSelectionController(nsISelectionController **aSel); void NotifyEditorObservers(void);
NS_IMETHOD GetSelection(nsISelection **aSelection); /* ------------ nsIEditor methods -------------- */
NS_IMETHOD DeleteSelection(EDirection aAction); NS_DECL_NSIEDITOR
NS_IMETHOD EnableUndo(PRBool aEnable);
NS_IMETHOD GetTransactionManager(nsITransactionManager* *aTxnManager);
NS_IMETHOD Do(nsITransaction *aTxn);
NS_IMETHOD Undo(PRUint32 aCount);
NS_IMETHOD CanUndo(PRBool &aIsEnabled, PRBool &aCanUndo);
NS_IMETHOD Redo(PRUint32 aCount);
NS_IMETHOD CanRedo(PRBool &aIsEnabled, PRBool &aCanRedo);
NS_IMETHOD BeginTransaction();
NS_IMETHOD EndTransaction();
NS_IMETHOD BeginPlaceHolderTransaction(nsIAtom *aName);
NS_IMETHOD EndPlaceHolderTransaction();
NS_IMETHOD ShouldTxnSetSelection(PRBool *aResult);
NS_IMETHOD GetDocumentIsEmpty(PRBool *aDocumentIsEmpty);
// file handling
NS_IMETHOD GetDocumentModified(PRBool *outDocModified);
NS_IMETHOD GetDocumentCharacterSet(PRUnichar** characterSet);
NS_IMETHOD SetDocumentCharacterSet(const PRUnichar* characterSet);
NS_IMETHOD SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting, PRBool aSaveCopy, const nsString& aFormat);
NS_IMETHOD Cut();
NS_IMETHOD CanCut(PRBool &aCanCut);
NS_IMETHOD Copy();
NS_IMETHOD CanCopy(PRBool &aCanCopy);
NS_IMETHOD Paste(PRInt32 aSelectionType);
NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste);
NS_IMETHOD CanDrag(nsIDOMEvent *aEvent, PRBool &aCanDrag);
NS_IMETHOD DoDrag(nsIDOMEvent *aEvent);
NS_IMETHOD InsertFromDrop(nsIDOMEvent *aEvent);
NS_IMETHOD SelectAll();
NS_IMETHOD BeginningOfDocument();
NS_IMETHOD EndOfDocument();
/* Node and element manipulation */
NS_IMETHOD SetAttribute(nsIDOMElement * aElement,
const nsString& aAttribute,
const nsString& aValue);
NS_IMETHOD GetAttributeValue(nsIDOMElement * aElement,
const nsString& aAttribute,
nsString& aResultValue,
PRBool& aResultIsSet);
NS_IMETHOD RemoveAttribute(nsIDOMElement *aElement, const nsString& aAttribute);
NS_IMETHOD CreateNode(const nsString& aTag,
nsIDOMNode * aParent,
PRInt32 aPosition,
nsIDOMNode ** aNewNode);
NS_IMETHOD InsertNode(nsIDOMNode * aNode,
nsIDOMNode * aParent,
PRInt32 aPosition);
NS_IMETHOD SplitNode(nsIDOMNode * aExistingRightNode,
PRInt32 aOffset,
nsIDOMNode ** aNewLeftNode);
NS_IMETHOD JoinNodes(nsIDOMNode * aLeftNode,
nsIDOMNode * aRightNode,
nsIDOMNode * aParent);
NS_IMETHOD DeleteNode(nsIDOMNode * aChild);
NS_IMETHOD MarkNodeDirty(nsIDOMNode* aNode);
/* output */
NS_IMETHOD OutputToString(nsAWritableString& aOutputString,
const nsAReadableString& aFormatType,
PRUint32 aFlags);
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
const nsAReadableString& aFormatType,
const nsAReadableString* aCharsetOverride,
PRUint32 aFlags);
/* Listeners */
NS_IMETHOD AddEditorObserver(nsIEditorObserver *aObserver);
NS_IMETHOD RemoveEditorObserver(nsIEditorObserver *aObserver);
void NotifyEditorObservers(void);
NS_IMETHOD AddEditActionListener(nsIEditActionListener *aListener);
NS_IMETHOD RemoveEditActionListener(nsIEditActionListener *aListener);
NS_IMETHOD AddDocumentStateListener(nsIDocumentStateListener *aListener);
NS_IMETHOD RemoveDocumentStateListener(nsIDocumentStateListener *aListener);
NS_IMETHOD DumpContentTree();
NS_IMETHOD DebugDumpContent() const;
NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
/* ------------ nsIEditorIMESupport methods -------------- */ /* ------------ nsIEditorIMESupport methods -------------- */
NS_IMETHOD BeginComposition(nsTextEventReply* aReply); NS_IMETHOD BeginComposition(nsTextEventReply* aReply);
NS_IMETHOD QueryComposition(nsTextEventReply* aReply); NS_IMETHOD QueryComposition(nsTextEventReply* aReply);
NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply); NS_IMETHOD SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply);
NS_IMETHOD EndComposition(void); NS_IMETHOD EndComposition(void);
NS_IMETHOD ForceCompositionEnd(void); NS_IMETHOD ForceCompositionEnd(void);
NS_IMETHOD GetReconversionString(nsReconversionEventReply *aReply); NS_IMETHOD GetReconversionString(nsReconversionEventReply *aReply);
@ -246,31 +139,31 @@ public:
public: public:
NS_IMETHOD InsertTextImpl(const nsString& aStringToInsert, NS_IMETHOD InsertTextImpl(const nsAReadableString& aStringToInsert,
nsCOMPtr<nsIDOMNode> *aInOutNode, nsCOMPtr<nsIDOMNode> *aInOutNode,
PRInt32 *aInOutOffset, PRInt32 *aInOutOffset,
nsIDOMDocument *aDoc); nsIDOMDocument *aDoc);
NS_IMETHOD InsertTextIntoTextNodeImpl(const nsString& aStringToInsert, NS_IMETHOD InsertTextIntoTextNodeImpl(const nsAReadableString& aStringToInsert,
nsIDOMCharacterData *aTextNode, nsIDOMCharacterData *aTextNode,
PRInt32 aOffset); PRInt32 aOffset);
NS_IMETHOD DeleteSelectionImpl(EDirection aAction); NS_IMETHOD DeleteSelectionImpl(EDirection aAction);
NS_IMETHOD DeleteSelectionAndCreateNode(const nsString& aTag, NS_IMETHOD DeleteSelectionAndCreateNode(const nsAReadableString& aTag,
nsIDOMNode ** aNewNode); nsIDOMNode ** aNewNode);
/* helper routines for node/parent manipulations */ /* helper routines for node/parent manipulations */
nsresult ReplaceContainer(nsIDOMNode *inNode, nsresult ReplaceContainer(nsIDOMNode *inNode,
nsCOMPtr<nsIDOMNode> *outNode, nsCOMPtr<nsIDOMNode> *outNode,
const nsString &aNodeType, const nsAReadableString &aNodeType,
const nsString *aAttribute = nsnull, const nsAReadableString *aAttribute = nsnull,
const nsString *aValue = nsnull, const nsAReadableString *aValue = nsnull,
PRBool aCloneAttributes = PR_FALSE); PRBool aCloneAttributes = PR_FALSE);
nsresult RemoveContainer(nsIDOMNode *inNode); nsresult RemoveContainer(nsIDOMNode *inNode);
nsresult InsertContainerAbove(nsIDOMNode *inNode, nsresult InsertContainerAbove(nsIDOMNode *inNode,
nsCOMPtr<nsIDOMNode> *outNode, nsCOMPtr<nsIDOMNode> *outNode,
const nsString &aNodeType, const nsAReadableString &aNodeType,
const nsString *aAttribute = nsnull, const nsAReadableString *aAttribute = nsnull,
const nsString *aValue = nsnull); const nsAReadableString *aValue = nsnull);
nsresult MoveNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aOffset); nsresult MoveNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aOffset);
/* Method to replace certain CreateElementNS() calls. /* Method to replace certain CreateElementNS() calls.
@ -278,15 +171,10 @@ public:
nsString& aTag - tag you want nsString& aTag - tag you want
nsIContent** aContent - returned Content that was created with above namespace. nsIContent** aContent - returned Content that was created with above namespace.
*/ */
nsresult CreateHTMLContent(const nsString& aTag, nsIContent** aContent); nsresult CreateHTMLContent(const nsAReadableString& aTag, nsIContent** aContent);
protected: protected:
//NOTE: Most callers are dealing with Nodes,
// but these objects must supports nsIDOMElement
NS_IMETHOD CloneAttributes(nsIDOMNode *aDestNode, nsIDOMNode *aSourceNode);
/* /*
NS_IMETHOD SetProperties(nsVoidArray *aPropList); NS_IMETHOD SetProperties(nsVoidArray *aPropList);
NS_IMETHOD GetProperties(nsVoidArray *aPropList); NS_IMETHOD GetProperties(nsVoidArray *aPropList);
@ -295,19 +183,19 @@ protected:
/** create a transaction for setting aAttribute to aValue on aElement /** create a transaction for setting aAttribute to aValue on aElement
*/ */
NS_IMETHOD CreateTxnForSetAttribute(nsIDOMElement *aElement, NS_IMETHOD CreateTxnForSetAttribute(nsIDOMElement *aElement,
const nsString& aAttribute, const nsAReadableString & aAttribute,
const nsString& aValue, const nsAReadableString & aValue,
ChangeAttributeTxn ** aTxn); ChangeAttributeTxn ** aTxn);
/** create a transaction for removing aAttribute on aElement /** create a transaction for removing aAttribute on aElement
*/ */
NS_IMETHOD CreateTxnForRemoveAttribute(nsIDOMElement *aElement, NS_IMETHOD CreateTxnForRemoveAttribute(nsIDOMElement *aElement,
const nsString& aAttribute, const nsAReadableString & aAttribute,
ChangeAttributeTxn ** aTxn); ChangeAttributeTxn ** aTxn);
/** create a transaction for creating a new child node of aParent of type aTag. /** create a transaction for creating a new child node of aParent of type aTag.
*/ */
NS_IMETHOD CreateTxnForCreateElement(const nsString& aTag, NS_IMETHOD CreateTxnForCreateElement(const nsAReadableString & aTag,
nsIDOMNode *aParent, nsIDOMNode *aParent,
PRInt32 aPosition, PRInt32 aPosition,
CreateElementTxn ** aTxn); CreateElementTxn ** aTxn);
@ -336,12 +224,12 @@ protected:
/** create a transaction for inserting aStringToInsert into aTextNode /** create a transaction for inserting aStringToInsert into aTextNode
* if aTextNode is null, the string is inserted at the current selection. * if aTextNode is null, the string is inserted at the current selection.
*/ */
NS_IMETHOD CreateTxnForInsertText(const nsString & aStringToInsert, NS_IMETHOD CreateTxnForInsertText(const nsAReadableString & aStringToInsert,
nsIDOMCharacterData *aTextNode, nsIDOMCharacterData *aTextNode,
PRInt32 aOffset, PRInt32 aOffset,
InsertTextTxn ** aTxn); InsertTextTxn ** aTxn);
NS_IMETHOD CreateTxnForIMEText(const nsString & aStringToInsert, NS_IMETHOD CreateTxnForIMEText(const nsAReadableString & aStringToInsert,
IMETextTxn ** aTxn); IMETextTxn ** aTxn);
/** create a transaction for adding a style sheet /** create a transaction for adding a style sheet
@ -436,7 +324,7 @@ public:
/** return the string that represents text nodes in the content tree */ /** return the string that represents text nodes in the content tree */
static nsresult GetTextNodeTag(nsString& aOutString); static nsresult GetTextNodeTag(nsAWritableString& aOutString);
/** /**
* SplitNode() creates a new node identical to an existing node, and split the contents between the two nodes * SplitNode() creates a new node identical to an existing node, and split the contents between the two nodes
@ -550,17 +438,17 @@ public:
* @param aResult is the node we found, or nsnull if there is none * @param aResult is the node we found, or nsnull if there is none
*/ */
static nsresult GetFirstNodeOfType(nsIDOMNode *aStartNode, static nsresult GetFirstNodeOfType(nsIDOMNode *aStartNode,
const nsString &aTag, const nsAReadableString &aTag,
nsIDOMNode **aResult); nsIDOMNode **aResult);
/** returns PR_TRUE if aNode is of the type implied by aTag */ /** returns PR_TRUE if aNode is of the type implied by aTag */
static PRBool NodeIsType(nsIDOMNode *aNode, nsIAtom *aTag); static PRBool NodeIsType(nsIDOMNode *aNode, nsIAtom *aTag);
static PRBool NodeIsType(nsIDOMNode *aNode, const nsString &aTag); static PRBool NodeIsType(nsIDOMNode *aNode, const nsAReadableString &aTag);
/** returns PR_TRUE if aParent can contain a child of type aTag */ /** returns PR_TRUE if aParent can contain a child of type aTag */
PRBool CanContainTag(nsIDOMNode* aParent, const nsString &aTag); PRBool CanContainTag(nsIDOMNode* aParent, const nsAReadableString &aTag);
PRBool TagCanContain(const nsString &aParentTag, nsIDOMNode* aChild); PRBool TagCanContain(const nsAReadableString &aParentTag, nsIDOMNode* aChild);
virtual PRBool TagCanContainTag(const nsString &aParentTag, const nsString &aChildTag); virtual PRBool TagCanContainTag(const nsAReadableString &aParentTag, const nsAReadableString &aChildTag);
/** returns PR_TRUE if aNode is a descendant of our root node */ /** returns PR_TRUE if aNode is a descendant of our root node */
PRBool IsDescendantOfBody(nsIDOMNode *inNode); PRBool IsDescendantOfBody(nsIDOMNode *inNode);
@ -586,7 +474,7 @@ public:
/** from html rules code - migration in progress */ /** from html rules code - migration in progress */
static nsresult GetTagString(nsIDOMNode *aNode, nsString& outString); static nsresult GetTagString(nsIDOMNode *aNode, nsAWritableString& outString);
static nsCOMPtr<nsIAtom> GetTag(nsIDOMNode *aNode); static nsCOMPtr<nsIAtom> GetTag(nsIDOMNode *aNode);
static PRBool NodesSameType(nsIDOMNode *aNode1, nsIDOMNode *aNode2); static PRBool NodesSameType(nsIDOMNode *aNode1, nsIDOMNode *aNode2);
static PRBool IsTextOrElementNode(nsIDOMNode *aNode); static PRBool IsTextOrElementNode(nsIDOMNode *aNode);
@ -622,7 +510,7 @@ public:
nsCOMPtr<nsIDOMNode> *outRightNode = 0); nsCOMPtr<nsIDOMNode> *outRightNode = 0);
nsresult JoinNodeDeep(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsCOMPtr<nsIDOMNode> *aOutJoinNode, PRInt32 *outOffset); nsresult JoinNodeDeep(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsCOMPtr<nsIDOMNode> *aOutJoinNode, PRInt32 *outOffset);
nsresult GetString(const nsString& name, nsString& value); nsresult GetString(const nsAReadableString& name, nsAWritableString& value);
nsresult BeginUpdateViewBatch(void); nsresult BeginUpdateViewBatch(void);
nsresult EndUpdateViewBatch(void); nsresult EndUpdateViewBatch(void);

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

@ -53,7 +53,7 @@ nsUndoCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISuppo
if (aEditor) if (aEditor)
{ {
PRBool isEnabled; PRBool isEnabled;
return aEditor->CanUndo(isEnabled, *outCmdEnabled); return aEditor->CanUndo(&isEnabled, outCmdEnabled);
} }
return NS_OK; return NS_OK;
} }
@ -78,7 +78,7 @@ nsRedoCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISuppo
if (aEditor) if (aEditor)
{ {
PRBool isEnabled; PRBool isEnabled;
return aEditor->CanRedo(isEnabled, *outCmdEnabled); return aEditor->CanRedo(&isEnabled, outCmdEnabled);
} }
return NS_OK; return NS_OK;
} }
@ -101,7 +101,7 @@ nsCutCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISuppor
nsCOMPtr<nsIEditor> aEditor = do_QueryInterface(aCommandRefCon); nsCOMPtr<nsIEditor> aEditor = do_QueryInterface(aCommandRefCon);
*outCmdEnabled = PR_FALSE; *outCmdEnabled = PR_FALSE;
if (aEditor) if (aEditor)
return aEditor->CanCut(*outCmdEnabled); return aEditor->CanCut(outCmdEnabled);
return NS_OK; return NS_OK;
} }
@ -155,7 +155,7 @@ nsCopyCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISuppo
nsCOMPtr<nsIEditor> aEditor = do_QueryInterface(aCommandRefCon); nsCOMPtr<nsIEditor> aEditor = do_QueryInterface(aCommandRefCon);
*outCmdEnabled = PR_FALSE; *outCmdEnabled = PR_FALSE;
if (aEditor) if (aEditor)
return aEditor->CanCopy(*outCmdEnabled); return aEditor->CanCopy(outCmdEnabled);
return NS_OK; return NS_OK;
} }
@ -209,7 +209,7 @@ nsPasteCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupp
nsCOMPtr<nsIEditor> aEditor = do_QueryInterface(aCommandRefCon); nsCOMPtr<nsIEditor> aEditor = do_QueryInterface(aCommandRefCon);
*outCmdEnabled = PR_FALSE; *outCmdEnabled = PR_FALSE;
if (aEditor) if (aEditor)
return aEditor->CanPaste(nsIClipboard::kGlobalClipboard, *outCmdEnabled); return aEditor->CanPaste(nsIClipboard::kGlobalClipboard, outCmdEnabled);
return NS_OK; return NS_OK;
} }
@ -250,7 +250,7 @@ nsDeleteCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISup
nsAutoString cmdString(aCommandName); nsAutoString cmdString(aCommandName);
if (cmdString.EqualsWithConversion("cmd_delete")) if (cmdString.EqualsWithConversion("cmd_delete"))
rv = aEditor->CanCut(*outCmdEnabled); rv = aEditor->CanCut(outCmdEnabled);
else if (cmdString.EqualsWithConversion("cmd_deleteCharBackward")) else if (cmdString.EqualsWithConversion("cmd_deleteCharBackward"))
*outCmdEnabled = PR_TRUE; *outCmdEnabled = PR_TRUE;
else if (cmdString.EqualsWithConversion("cmd_deleteCharForward")) else if (cmdString.EqualsWithConversion("cmd_deleteCharForward"))

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

@ -71,13 +71,13 @@ nsresult TextEditorTest::RunUnitTest(PRInt32 *outNumTests, PRInt32 *outNumTestsF
// shouldn't we just bail on error here? // shouldn't we just bail on error here?
// insert some simple text // insert some simple text
result = mTextEditor->InsertText(NS_LITERAL_STRING("1234567890abcdefghij1234567890").get()); result = mTextEditor->InsertText(NS_LITERAL_STRING("1234567890abcdefghij1234567890"));
TEST_RESULT(result); TEST_RESULT(result);
(*outNumTests)++; (*outNumTests)++;
(*outNumTestsFailed) += (NS_FAILED(result) != NS_OK); (*outNumTestsFailed) += (NS_FAILED(result) != NS_OK);
// insert some more text // insert some more text
result = mTextEditor->InsertText(NS_LITERAL_STRING("Moreover, I am cognizant of the interrelatedness of all communities and states. I cannot sit idly by in Atlanta and not be concerned about what happens in Birmingham. Injustice anywhere is a threat to justice everywhere").get()); result = mTextEditor->InsertText(NS_LITERAL_STRING("Moreover, I am cognizant of the interrelatedness of all communities and states. I cannot sit idly by in Atlanta and not be concerned about what happens in Birmingham. Injustice anywhere is a threat to justice everywhere"));
TEST_RESULT(result); TEST_RESULT(result);
(*outNumTests)++; (*outNumTests)++;
(*outNumTestsFailed) += (NS_FAILED(result) != NS_OK); (*outNumTestsFailed) += (NS_FAILED(result) != NS_OK);
@ -174,14 +174,14 @@ nsresult TextEditorTest::TestTextProperties()
PRBool all = PR_FALSE; PRBool all = PR_FALSE;
PRBool first=PR_FALSE; PRBool first=PR_FALSE;
result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all); result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all);
TEST_RESULT(result); TEST_RESULT(result);
NS_ASSERTION(PR_FALSE==first, "first should be false"); NS_ASSERTION(PR_FALSE==first, "first should be false");
NS_ASSERTION(PR_FALSE==any, "any should be false"); NS_ASSERTION(PR_FALSE==any, "any should be false");
NS_ASSERTION(PR_FALSE==all, "all should be false"); NS_ASSERTION(PR_FALSE==all, "all should be false");
result = htmlEditor->SetInlineProperty(nsIEditProperty::b, nsnull, nsnull); result = htmlEditor->SetInlineProperty(nsIEditProperty::b, nsString(), nsString());
TEST_RESULT(result); TEST_RESULT(result);
result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all); result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all);
TEST_RESULT(result); TEST_RESULT(result);
NS_ASSERTION(PR_TRUE==first, "first should be true"); NS_ASSERTION(PR_TRUE==first, "first should be true");
NS_ASSERTION(PR_TRUE==any, "any should be true"); NS_ASSERTION(PR_TRUE==any, "any should be true");
@ -190,9 +190,9 @@ nsresult TextEditorTest::TestTextProperties()
// remove the bold we just set // remove the bold we just set
printf("set the whole first text node to not bold\n"); printf("set the whole first text node to not bold\n");
result = htmlEditor->RemoveInlineProperty(nsIEditProperty::b, nsnull); result = htmlEditor->RemoveInlineProperty(nsIEditProperty::b, nsString());
TEST_RESULT(result); TEST_RESULT(result);
result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all); result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all);
TEST_RESULT(result); TEST_RESULT(result);
NS_ASSERTION(PR_FALSE==first, "first should be false"); NS_ASSERTION(PR_FALSE==first, "first should be false");
NS_ASSERTION(PR_FALSE==any, "any should be false"); NS_ASSERTION(PR_FALSE==any, "any should be false");
@ -203,23 +203,23 @@ nsresult TextEditorTest::TestTextProperties()
printf("set the first text node (1, length-1) to bold and italic, and (2, length-1) to underline.\n"); printf("set the first text node (1, length-1) to bold and italic, and (2, length-1) to underline.\n");
selection->Collapse(textNode, 1); selection->Collapse(textNode, 1);
selection->Extend(textNode, length-1); selection->Extend(textNode, length-1);
result = htmlEditor->SetInlineProperty(nsIEditProperty::b, nsnull, nsnull); result = htmlEditor->SetInlineProperty(nsIEditProperty::b, nsString(), nsString());
TEST_RESULT(result); TEST_RESULT(result);
result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all); result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all);
TEST_RESULT(result); TEST_RESULT(result);
NS_ASSERTION(PR_TRUE==first, "first should be true"); NS_ASSERTION(PR_TRUE==first, "first should be true");
NS_ASSERTION(PR_TRUE==any, "any should be true"); NS_ASSERTION(PR_TRUE==any, "any should be true");
NS_ASSERTION(PR_TRUE==all, "all should be true"); NS_ASSERTION(PR_TRUE==all, "all should be true");
mEditor->DebugDumpContent(); mEditor->DebugDumpContent();
// make all that same text italic // make all that same text italic
result = htmlEditor->SetInlineProperty(nsIEditProperty::i, nsnull, nsnull); result = htmlEditor->SetInlineProperty(nsIEditProperty::i, nsString(), nsString());
TEST_RESULT(result); TEST_RESULT(result);
result = htmlEditor->GetInlineProperty(nsIEditProperty::i, nsnull, nsnull, first, any, all); result = htmlEditor->GetInlineProperty(nsIEditProperty::i, nsString(), nsString(), &first, &any, &all);
TEST_RESULT(result); TEST_RESULT(result);
NS_ASSERTION(PR_TRUE==first, "first should be true"); NS_ASSERTION(PR_TRUE==first, "first should be true");
NS_ASSERTION(PR_TRUE==any, "any should be true"); NS_ASSERTION(PR_TRUE==any, "any should be true");
NS_ASSERTION(PR_TRUE==all, "all should be true"); NS_ASSERTION(PR_TRUE==all, "all should be true");
result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all); result = htmlEditor->GetInlineProperty(nsIEditProperty::b, nsString(), nsString(), &first, &any, &all);
TEST_RESULT(result); TEST_RESULT(result);
NS_ASSERTION(PR_TRUE==first, "first should be true"); NS_ASSERTION(PR_TRUE==first, "first should be true");
NS_ASSERTION(PR_TRUE==any, "any should be true"); NS_ASSERTION(PR_TRUE==any, "any should be true");
@ -240,9 +240,9 @@ nsresult TextEditorTest::TestTextProperties()
NS_ASSERTION(length==915, "wrong text node"); NS_ASSERTION(length==915, "wrong text node");
selection->Collapse(textNode, 1); selection->Collapse(textNode, 1);
selection->Extend(textNode, length-2); selection->Extend(textNode, length-2);
result = htmlEditor->SetInlineProperty(nsIEditProperty::u, nsnull, nsnull); result = htmlEditor->SetInlineProperty(nsIEditProperty::u, nsString(), nsString());
TEST_RESULT(result); TEST_RESULT(result);
result = htmlEditor->GetInlineProperty(nsIEditProperty::u, nsnull, nsnull, first, any, all); result = htmlEditor->GetInlineProperty(nsIEditProperty::u, nsString(), nsString(), &first, &any, &all);
TEST_RESULT(result); TEST_RESULT(result);
NS_ASSERTION(PR_TRUE==first, "first should be true"); NS_ASSERTION(PR_TRUE==first, "first should be true");
NS_ASSERTION(PR_TRUE==any, "any should be true"); NS_ASSERTION(PR_TRUE==any, "any should be true");

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

@ -160,29 +160,29 @@ static nsCOMPtr<nsIDOMNode> GetTableParent(nsIDOMNode* aNode)
} }
NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString) NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsAReadableString & aInString)
{ {
nsAutoString charset; nsAutoString charset;
return InsertHTMLWithCharset(aInputString, charset); return InsertHTMLWithCharset(aInString, charset);
} }
nsresult nsHTMLEditor::InsertHTMLWithContext(const nsString& aInputString, const nsString& aContextStr, const nsString& aInfoStr) nsresult nsHTMLEditor::InsertHTMLWithContext(const nsAReadableString & aInputString, const nsAReadableString & aContextStr, const nsAReadableString & aInfoStr)
{ {
nsAutoString charset; nsAutoString charset;
return InsertHTMLWithCharsetAndContext(aInputString, charset, aContextStr, aInfoStr); return InsertHTMLWithCharsetAndContext(aInputString, charset, aContextStr, aInfoStr);
} }
NS_IMETHODIMP nsHTMLEditor::InsertHTMLWithCharset(const nsString& aInputString, const nsString& aCharset) NS_IMETHODIMP nsHTMLEditor::InsertHTMLWithCharset(const nsAReadableString & aInputString, const nsAReadableString & aCharset)
{ {
return InsertHTMLWithCharsetAndContext(aInputString, aCharset, nsAutoString(), nsAutoString()); return InsertHTMLWithCharsetAndContext(aInputString, aCharset, nsAutoString(), nsAutoString());
} }
nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsString& aInputString, nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsAReadableString & aInputString,
const nsString& aCharset, const nsAReadableString & aCharset,
const nsString& aContextStr, const nsAReadableString & aContextStr,
const nsString& aInfoStr) const nsAReadableString & aInfoStr)
{ {
if (!mRules) return NS_ERROR_NOT_INITIALIZED; if (!mRules) return NS_ERROR_NOT_INITIALIZED;
@ -604,8 +604,8 @@ NS_IMETHODIMP nsHTMLEditor::PrepareTransferable(nsITransferable **transferable)
} }
NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable, NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable,
const nsString& aContextStr, const nsAReadableString & aContextStr,
const nsString& aInfoStr) const nsAReadableString & aInfoStr)
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
char* bestFlavor = nsnull; char* bestFlavor = nsnull;
@ -645,7 +645,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
// pasting does not inherit local inline styles // pasting does not inherit local inline styles
RemoveAllInlineProperties(); RemoveAllInlineProperties();
rv = InsertText(stuffToPaste.GetUnicode()); rv = InsertText(stuffToPaste);
if (text) if (text)
nsMemory::Free(text); nsMemory::Free(text);
} }
@ -906,12 +906,15 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
return rv; return rv;
} }
NS_IMETHODIMP nsHTMLEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag) NS_IMETHODIMP nsHTMLEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag)
{ {
if (!aCanDrag)
return NS_ERROR_NULL_POINTER;
/* we really should be checking the XY coordinates of the mouseevent and ensure that /* we really should be checking the XY coordinates of the mouseevent and ensure that
* that particular point is actually within the selection (not just that there is a selection) * that particular point is actually within the selection (not just that there is a selection)
*/ */
aCanDrag = PR_FALSE; *aCanDrag = PR_FALSE;
// KLUDGE to work around bug 50703 // KLUDGE to work around bug 50703
// After double click and object property editing, // After double click and object property editing,
@ -949,7 +952,7 @@ NS_IMETHODIMP nsHTMLEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag)
res = selection->ContainsNode(eventTargetDomNode, PR_FALSE, &amTargettedCorrectly); res = selection->ContainsNode(eventTargetDomNode, PR_FALSE, &amTargettedCorrectly);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
aCanDrag = amTargettedCorrectly; *aCanDrag = amTargettedCorrectly;
} }
} }
@ -1123,9 +1126,11 @@ NS_IMETHODIMP nsHTMLEditor::Paste(PRInt32 aSelectionType)
} }
NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste) NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste)
{ {
aCanPaste = PR_FALSE; if (!aCanPaste)
return NS_ERROR_NULL_POINTER;
*aCanPaste = PR_FALSE;
// can't paste if readonly // can't paste if readonly
if (!IsModifiable()) if (!IsModifiable())
@ -1180,7 +1185,7 @@ NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste)
rv = clipboard->HasDataMatchingFlavors(flavorsList, aSelectionType, &haveFlavors); rv = clipboard->HasDataMatchingFlavors(flavorsList, aSelectionType, &haveFlavors);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
aCanPaste = haveFlavors; *aCanPaste = haveFlavors;
return NS_OK; return NS_OK;
} }
@ -1197,7 +1202,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsQuotation(PRInt32 aSelectionType)
return PasteAsCitedQuotation(citation, aSelectionType); return PasteAsCitedQuotation(citation, aSelectionType);
} }
NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsString& aCitation, NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsAReadableString & aCitation,
PRInt32 aSelectionType) PRInt32 aSelectionType)
{ {
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
@ -1310,7 +1315,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlaintextQuotation(PRInt32 aSelectionType)
return rv; return rv;
} }
NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsString& aQuotedText, NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsAReadableString & aQuotedText,
nsIDOMNode **aNodeInserted) nsIDOMNode **aNodeInserted)
{ {
if (mFlags & eEditorPlaintextMask) if (mFlags & eEditorPlaintextMask)
@ -1327,7 +1332,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsString& aQuotedText,
// in that here, quoted material is enclosed in a <pre> tag // in that here, quoted material is enclosed in a <pre> tag
// in order to preserve the original line wrapping. // in order to preserve the original line wrapping.
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText, nsHTMLEditor::InsertAsPlaintextQuotation(const nsAReadableString & aQuotedText,
nsIDOMNode **aNodeInserted) nsIDOMNode **aNodeInserted)
{ {
nsresult rv; nsresult rv;
@ -1399,10 +1404,10 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText, nsHTMLEditor::InsertAsCitedQuotation(const nsAReadableString & aQuotedText,
const nsString& aCitation, const nsAReadableString & aCitation,
PRBool aInsertHTML, PRBool aInsertHTML,
const nsString& aCharset, const nsAReadableString & aCharset,
nsIDOMNode **aNodeInserted) nsIDOMNode **aNodeInserted)
{ {
nsCOMPtr<nsIDOMNode> newNode; nsCOMPtr<nsIDOMNode> newNode;
@ -1450,7 +1455,7 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
res = InsertHTMLWithCharset(aQuotedText, aCharset); res = InsertHTMLWithCharset(aQuotedText, aCharset);
else else
res = InsertText(aQuotedText.GetUnicode()); // XXX ignore charset res = InsertText(aQuotedText); // XXX ignore charset
if (aNodeInserted) if (aNodeInserted)
{ {
@ -1475,9 +1480,9 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText,
} }
nsresult nsHTMLEditor::CreateDOMFragmentFromPaste(nsIDOMNSRange *aNSRange, nsresult nsHTMLEditor::CreateDOMFragmentFromPaste(nsIDOMNSRange *aNSRange,
const nsString& aInputString, const nsAReadableString & aInputString,
const nsString& aContextStr, const nsAReadableString & aContextStr,
const nsString& aInfoStr, const nsAReadableString & aInfoStr,
nsCOMPtr<nsIDOMNode> *outFragNode, nsCOMPtr<nsIDOMNode> *outFragNode,
PRInt32 *outRangeStartHint, PRInt32 *outRangeStartHint,
PRInt32 *outRangeEndHint) PRInt32 *outRangeEndHint)

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

@ -59,6 +59,8 @@
#include "InsertTextTxn.h" #include "InsertTextTxn.h"
#include "DeleteTextTxn.h" #include "DeleteTextTxn.h"
#include "nsReadableUtils.h"
//const static char* kMOZEditorBogusNodeAttr="MOZ_EDITOR_BOGUS_NODE"; //const static char* kMOZEditorBogusNodeAttr="MOZ_EDITOR_BOGUS_NODE";
//const static char* kMOZEditorBogusNodeValue="TRUE"; //const static char* kMOZEditorBogusNodeValue="TRUE";
@ -83,7 +85,7 @@ enum
static PRBool IsBlockNode(nsIDOMNode* node) static PRBool IsBlockNode(nsIDOMNode* node)
{ {
PRBool isBlock (PR_FALSE); PRBool isBlock (PR_FALSE);
nsHTMLEditor::NodeIsBlockStatic(node, isBlock); nsHTMLEditor::NodeIsBlockStatic(node, &isBlock);
return isBlock; return isBlock;
} }
@ -500,12 +502,14 @@ nsHTMLEditRules::DidDoAction(nsISelection *aSelection,
********************************************************/ ********************************************************/
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditRules::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL) nsHTMLEditRules::GetListState(PRBool *aMixed, PRBool *aOL, PRBool *aUL, PRBool *aDL)
{ {
aMixed = PR_FALSE; if (!aMixed || !aOL || !aUL || !aDL)
aOL = PR_FALSE; return NS_ERROR_NULL_POINTER;
aUL = PR_FALSE; *aMixed = PR_FALSE;
aDL = PR_FALSE; *aOL = PR_FALSE;
*aUL = PR_FALSE;
*aDL = PR_FALSE;
PRBool bNonList = PR_FALSE; PRBool bNonList = PR_FALSE;
nsCOMPtr<nsISupportsArray> arrayOfNodes; nsCOMPtr<nsISupportsArray> arrayOfNodes;
@ -522,9 +526,9 @@ nsHTMLEditRules::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &
nsCOMPtr<nsIDOMNode> curNode( do_QueryInterface(isupports) ); nsCOMPtr<nsIDOMNode> curNode( do_QueryInterface(isupports) );
if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::ul)) if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::ul))
aUL = PR_TRUE; *aUL = PR_TRUE;
else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::ol)) else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::ol))
aOL = PR_TRUE; *aOL = PR_TRUE;
else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::li)) else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::li))
{ {
nsCOMPtr<nsIDOMNode> parent; nsCOMPtr<nsIDOMNode> parent;
@ -532,32 +536,34 @@ nsHTMLEditRules::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &
res = nsEditor::GetNodeLocation(curNode, address_of(parent), &offset); res = nsEditor::GetNodeLocation(curNode, address_of(parent), &offset);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
if (nsHTMLEditUtils::IsUnorderedList(parent)) if (nsHTMLEditUtils::IsUnorderedList(parent))
aUL = PR_TRUE; *aUL = PR_TRUE;
else if (nsHTMLEditUtils::IsOrderedList(parent)) else if (nsHTMLEditUtils::IsOrderedList(parent))
aOL = PR_TRUE; *aOL = PR_TRUE;
} }
else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dl) || else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dl) ||
mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dt) || mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dt) ||
mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dd) ) mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dd) )
{ {
aDL = PR_TRUE; *aDL = PR_TRUE;
} }
else bNonList = PR_TRUE; else bNonList = PR_TRUE;
} }
// hokey arithmetic with booleans // hokey arithmetic with booleans
if ( (aUL + aOL + aDL + bNonList) > 1) aMixed = PR_TRUE; if ( (*aUL + *aOL + *aDL + bNonList) > 1) *aMixed = PR_TRUE;
return res; return res;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditRules::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD) nsHTMLEditRules::GetListItemState(PRBool *aMixed, PRBool *aLI, PRBool *aDT, PRBool *aDD)
{ {
aMixed = PR_FALSE; if (!aMixed || !aLI || !aDT || !aDD)
aLI = PR_FALSE; return NS_ERROR_NULL_POINTER;
aDT = PR_FALSE; *aMixed = PR_FALSE;
aDD = PR_FALSE; *aLI = PR_FALSE;
*aDT = PR_FALSE;
*aDD = PR_FALSE;
PRBool bNonList = PR_FALSE; PRBool bNonList = PR_FALSE;
nsCOMPtr<nsISupportsArray> arrayOfNodes; nsCOMPtr<nsISupportsArray> arrayOfNodes;
@ -577,15 +583,15 @@ nsHTMLEditRules::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBo
mHTMLEditor->NodeIsType(curNode,nsIEditProperty::ol) || mHTMLEditor->NodeIsType(curNode,nsIEditProperty::ol) ||
mHTMLEditor->NodeIsType(curNode,nsIEditProperty::li) ) mHTMLEditor->NodeIsType(curNode,nsIEditProperty::li) )
{ {
aLI = PR_TRUE; *aLI = PR_TRUE;
} }
else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dt)) else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dt))
{ {
aDT = PR_TRUE; *aDT = PR_TRUE;
} }
else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dd)) else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dd))
{ {
aDD = PR_TRUE; *aDD = PR_TRUE;
} }
else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dl)) else if (mHTMLEditor->NodeIsType(curNode,nsIEditProperty::dl))
{ {
@ -593,20 +599,20 @@ nsHTMLEditRules::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBo
PRBool bDT, bDD; PRBool bDT, bDD;
res = GetDefinitionListItemTypes(curNode, bDT, bDD); res = GetDefinitionListItemTypes(curNode, bDT, bDD);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
aDT |= bDT; *aDT |= bDT;
aDD |= bDD; *aDD |= bDD;
} }
else bNonList = PR_TRUE; else bNonList = PR_TRUE;
} }
// hokey arithmetic with booleans // hokey arithmetic with booleans
if ( (aDT + aDD + bNonList) > 1) aMixed = PR_TRUE; if ( (*aDT + *aDD + bNonList) > 1) *aMixed = PR_TRUE;
return res; return res;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign) nsHTMLEditRules::GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
{ {
// for now, just return first alignment. we'll lie about // for now, just return first alignment. we'll lie about
// if it's mixed. This is for efficiency // if it's mixed. This is for efficiency
@ -617,8 +623,10 @@ nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
// this routine assumes that alignment is done ONLY via divs // this routine assumes that alignment is done ONLY via divs
// default alignment is left // default alignment is left
aMixed = PR_FALSE; if (!aMixed || !aAlign)
aAlign = nsIHTMLEditor::eLeft; return NS_ERROR_NULL_POINTER;
*aMixed = PR_FALSE;
*aAlign = nsIHTMLEditor::eLeft;
// get selection // get selection
nsCOMPtr<nsISelection>selection; nsCOMPtr<nsISelection>selection;
@ -673,13 +681,13 @@ nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
if (NS_SUCCEEDED(res) && typeAttrVal.Length()) if (NS_SUCCEEDED(res) && typeAttrVal.Length())
{ {
if (typeAttrVal.EqualsWithConversion("center")) if (typeAttrVal.EqualsWithConversion("center"))
aAlign = nsIHTMLEditor::eCenter; *aAlign = nsIHTMLEditor::eCenter;
else if (typeAttrVal.EqualsWithConversion("right")) else if (typeAttrVal.EqualsWithConversion("right"))
aAlign = nsIHTMLEditor::eRight; *aAlign = nsIHTMLEditor::eRight;
else if (typeAttrVal.EqualsWithConversion("justify")) else if (typeAttrVal.EqualsWithConversion("justify"))
aAlign = nsIHTMLEditor::eJustify; *aAlign = nsIHTMLEditor::eJustify;
else else
aAlign = nsIHTMLEditor::eLeft; *aAlign = nsIHTMLEditor::eLeft;
return res; return res;
} }
} }
@ -692,10 +700,12 @@ nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditRules::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent) nsHTMLEditRules::GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent)
{ {
aCanIndent = PR_TRUE; if (!aCanIndent || !aCanOutdent)
aCanOutdent = PR_FALSE; return NS_ERROR_FAILURE;
*aCanIndent = PR_TRUE;
*aCanOutdent = PR_FALSE;
nsCOMPtr<nsISupportsArray> arrayOfNodes; nsCOMPtr<nsISupportsArray> arrayOfNodes;
nsresult res = GetListActionNodes(address_of(arrayOfNodes), PR_FALSE, PR_TRUE); nsresult res = GetListActionNodes(address_of(arrayOfNodes), PR_FALSE, PR_TRUE);
@ -716,7 +726,7 @@ nsHTMLEditRules::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
nsHTMLEditUtils::IsListItem(curNode) || nsHTMLEditUtils::IsListItem(curNode) ||
nsHTMLEditUtils::IsBlockquote(curNode)) nsHTMLEditUtils::IsBlockquote(curNode))
{ {
aCanOutdent = PR_TRUE; *aCanOutdent = PR_TRUE;
break; break;
} }
} }
@ -726,17 +736,19 @@ nsHTMLEditRules::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditRules::GetParagraphState(PRBool &aMixed, nsString &outFormat) nsHTMLEditRules::GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat)
{ {
// This routine is *heavily* tied to our ui choices in the paragraph // This routine is *heavily* tied to our ui choices in the paragraph
// style popup. I cant see a way around that. // style popup. I cant see a way around that.
aMixed = PR_TRUE; if (!aMixed)
outFormat.AssignWithConversion(""); return NS_ERROR_NULL_POINTER;
*aMixed = PR_TRUE;
outFormat.Truncate(0);
PRBool bMixed = PR_FALSE; PRBool bMixed = PR_FALSE;
nsAutoString formatStr; nsAutoString formatStr;
// using "x" as an uninitialized value, since "" is meaningful // using "x" as an uninitialized value, since "" is meaningful
formatStr.AssignWithConversion("x"); formatStr.Assign(NS_LITERAL_STRING("x"));
nsCOMPtr<nsISupportsArray> arrayOfNodes; nsCOMPtr<nsISupportsArray> arrayOfNodes;
nsresult res = GetParagraphFormatNodes(address_of(arrayOfNodes), PR_TRUE); nsresult res = GetParagraphFormatNodes(address_of(arrayOfNodes), PR_TRUE);
@ -794,12 +806,12 @@ nsHTMLEditRules::GetParagraphState(PRBool &aMixed, nsString &outFormat)
} }
else else
{ {
format.AssignWithConversion(""); format.Truncate(0);
} }
} }
else else
{ {
format.AssignWithConversion(""); format.Truncate(0);
} }
} }
else if (nsHTMLEditUtils::IsHeader(curNode)) else if (nsHTMLEditUtils::IsHeader(curNode))
@ -828,7 +840,7 @@ nsHTMLEditRules::GetParagraphState(PRBool &aMixed, nsString &outFormat)
} }
} }
aMixed = bMixed; *aMixed = bMixed;
outFormat = formatStr; outFormat = formatStr;
return res; return res;
} }
@ -904,8 +916,8 @@ nsHTMLEditRules::WillInsertText(PRInt32 aAction,
nsISelection *aSelection, nsISelection *aSelection,
PRBool *aCancel, PRBool *aCancel,
PRBool *aHandled, PRBool *aHandled,
const nsString *inString, const nsAReadableString *inString,
nsString *outString, nsAWritableString *outString,
PRInt32 aMaxLength) PRInt32 aMaxLength)
{ {
if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
@ -986,7 +998,8 @@ nsHTMLEditRules::WillInsertText(PRInt32 aAction,
// dont spaz my selection in subtransactions // dont spaz my selection in subtransactions
nsAutoTxnsConserveSelection dontSpazMySelection(mHTMLEditor); nsAutoTxnsConserveSelection dontSpazMySelection(mHTMLEditor);
nsSubsumeStr subStr; nsSubsumeStr subStr;
const PRUnichar *unicodeBuf = inString->GetUnicode(); const nsPromiseFlatString &tString = PromiseFlatString(*inString);////MJUDGE SCC NEED HELP
const PRUnichar *unicodeBuf = tString.get();
nsCOMPtr<nsIDOMNode> unused; nsCOMPtr<nsIDOMNode> unused;
PRInt32 pos = 0; PRInt32 pos = 0;
@ -995,13 +1008,21 @@ nsHTMLEditRules::WillInsertText(PRInt32 aAction,
// it is to search for both tabs and newlines. // it is to search for both tabs and newlines.
if (isPRE) if (isPRE)
{ {
char newlineChar = '\n'; nsAutoString newlineChar(NS_LITERAL_STRING("\n"));
while (unicodeBuf && (pos != -1) && (pos < (PRInt32)inString->Length())) while (unicodeBuf && (pos != -1) && (pos < (PRInt32)(*inString).Length()))
{ {
PRInt32 oldPos = pos; PRInt32 oldPos = pos;
PRInt32 subStrLen; PRInt32 subStrLen;
pos = inString->FindChar(newlineChar, PR_FALSE, oldPos); pos = -1;
nsReadingIterator<PRUnichar> beginFindIter, endFindIter, beginIter;
inString->BeginReading(beginIter);
beginFindIter = beginIter;
inString->EndReading(endFindIter);
beginFindIter.advance(oldPos);
if (FindInReadable(newlineChar,beginFindIter,endFindIter))
{
pos = Distance(beginIter,beginFindIter);
}
if (pos != -1) if (pos != -1)
{ {
subStrLen = pos - oldPos; subStrLen = pos - oldPos;
@ -1011,8 +1032,8 @@ nsHTMLEditRules::WillInsertText(PRInt32 aAction,
} }
else else
{ {
subStrLen = inString->Length() - oldPos; subStrLen = (*inString).Length() - oldPos;
pos = inString->Length(); pos = (*inString).Length();
} }
subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen); subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen);
@ -1032,13 +1053,22 @@ nsHTMLEditRules::WillInsertText(PRInt32 aAction,
} }
else else
{ {
char specialChars[] = {'\t','\n',0}; nsAutoString specialChars;
specialChars = NS_LITERAL_STRING("\t\n");
nsAutoString tabString; tabString.AssignWithConversion(" "); nsAutoString tabString; tabString.AssignWithConversion(" ");
while (unicodeBuf && (pos != -1) && (pos < (PRInt32)inString->Length())) while (unicodeBuf && (pos != -1) && (pos < (PRInt32)(*inString).Length()))
{ {
PRInt32 oldPos = pos; PRInt32 oldPos = pos;
PRInt32 subStrLen; PRInt32 subStrLen;
pos = inString->FindCharInSet(specialChars, oldPos); nsReadingIterator<PRUnichar> beginFindIter,endFindIter;
(*inString).BeginReading(beginFindIter);
beginFindIter.advance(oldPos);
(*inString).EndReading(endFindIter);
nsReadingIterator<PRUnichar> distanceIter;
(*inString).BeginReading(distanceIter);
pos = -1;
if (FindInReadable((const nsAString &)specialChars,beginFindIter,endFindIter))
pos = Distance(distanceIter,beginFindIter);
if (pos != -1) if (pos != -1)
{ {
@ -1049,8 +1079,8 @@ nsHTMLEditRules::WillInsertText(PRInt32 aAction,
} }
else else
{ {
subStrLen = inString->Length() - oldPos; subStrLen = (*inString).Length() - oldPos;
pos = inString->Length(); pos = (*inString).Length();
} }
subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen); subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen);
@ -1900,11 +1930,11 @@ nsHTMLEditRules::DeleteNonTableElements(nsIDOMNode *aNode)
nsresult nsresult
nsHTMLEditRules::WillMakeList(nsISelection *aSelection, nsHTMLEditRules::WillMakeList(nsISelection *aSelection,
const nsString *aListType, const nsAReadableString *aListType,
PRBool aEntireList, PRBool aEntireList,
PRBool *aCancel, PRBool *aCancel,
PRBool *aHandled, PRBool *aHandled,
const nsString *aItemType) const nsAReadableString *aItemType)
{ {
if (!aSelection || !aListType || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } if (!aSelection || !aListType || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
@ -1918,9 +1948,10 @@ nsHTMLEditRules::WillMakeList(nsISelection *aSelection,
// deduce what tag to use for list items // deduce what tag to use for list items
nsAutoString itemType; nsAutoString itemType;
nsString tString(*aListType);//MJUDGE SCC NEED HELP
if (aItemType) if (aItemType)
itemType = *aItemType; itemType = *aItemType;
else if (aListType->EqualsWithConversion("dl")) else if (tString.EqualsWithConversion("dl"))
itemType.AssignWithConversion("dd"); itemType.AssignWithConversion("dd");
else else
itemType.AssignWithConversion("li"); itemType.AssignWithConversion("li");
@ -2316,7 +2347,7 @@ nsHTMLEditRules::WillRemoveList(nsISelection *aSelection,
nsresult nsresult
nsHTMLEditRules::WillMakeDefListItem(nsISelection *aSelection, nsHTMLEditRules::WillMakeDefListItem(nsISelection *aSelection,
const nsString *aItemType, const nsAReadableString *aItemType,
PRBool aEntireList, PRBool aEntireList,
PRBool *aCancel, PRBool *aCancel,
PRBool *aHandled) PRBool *aHandled)
@ -2329,7 +2360,7 @@ nsHTMLEditRules::WillMakeDefListItem(nsISelection *aSelection,
nsresult nsresult
nsHTMLEditRules::WillMakeBasicBlock(nsISelection *aSelection, nsHTMLEditRules::WillMakeBasicBlock(nsISelection *aSelection,
const nsString *aBlockType, const nsAReadableString *aBlockType,
PRBool *aCancel, PRBool *aCancel,
PRBool *aHandled) PRBool *aHandled)
{ {
@ -2384,7 +2415,8 @@ nsHTMLEditRules::WillMakeBasicBlock(nsISelection *aSelection,
// Ok, now go through all the nodes and make the right kind of blocks, // Ok, now go through all the nodes and make the right kind of blocks,
// or whatever is approriate. Wohoo! // or whatever is approriate. Wohoo!
// Note: blockquote is handled a little differently // Note: blockquote is handled a little differently
if (aBlockType->EqualsWithConversion("blockquote")) nsString tString(*aBlockType);
if (tString.EqualsWithConversion("blockquote"))
res = MakeBlockquote(arrayOfNodes); res = MakeBlockquote(arrayOfNodes);
else else
res = ApplyBlockStyle(arrayOfNodes, aBlockType); res = ApplyBlockStyle(arrayOfNodes, aBlockType);
@ -2664,8 +2696,8 @@ nsHTMLEditRules::WillOutdent(nsISelection *aSelection, PRBool *aCancel, PRBool *
nsresult nsresult
nsHTMLEditRules::ConvertListType(nsIDOMNode *aList, nsHTMLEditRules::ConvertListType(nsIDOMNode *aList,
nsCOMPtr<nsIDOMNode> *outList, nsCOMPtr<nsIDOMNode> *outList,
const nsString& aListType, const nsAReadableString& aListType,
const nsString& aItemType) const nsAReadableString& aItemType)
{ {
if (!aList || !outList) return NS_ERROR_NULL_POINTER; if (!aList || !outList) return NS_ERROR_NULL_POINTER;
*outList = aList; // we migvht not need to change the list *outList = aList; // we migvht not need to change the list
@ -2879,7 +2911,7 @@ nsHTMLEditRules::IsEmptyBlock(nsIDOMNode *aNode,
nsresult nsresult
nsHTMLEditRules::WillAlign(nsISelection *aSelection, nsHTMLEditRules::WillAlign(nsISelection *aSelection,
const nsString *alignType, const nsAReadableString *alignType,
PRBool *aCancel, PRBool *aCancel,
PRBool *aHandled) PRBool *aHandled)
{ {
@ -3046,7 +3078,7 @@ nsHTMLEditRules::WillAlign(nsISelection *aSelection,
// AlignInnerBlocks: align inside table cells or list items // AlignInnerBlocks: align inside table cells or list items
// //
nsresult nsresult
nsHTMLEditRules::AlignInnerBlocks(nsIDOMNode *aNode, const nsString *alignType) nsHTMLEditRules::AlignInnerBlocks(nsIDOMNode *aNode, const nsAReadableString *alignType)
{ {
if (!aNode || !alignType) return NS_ERROR_NULL_POINTER; if (!aNode || !alignType) return NS_ERROR_NULL_POINTER;
nsresult res; nsresult res;
@ -3084,7 +3116,7 @@ nsHTMLEditRules::AlignInnerBlocks(nsIDOMNode *aNode, const nsString *alignType)
// AlignBlockContents: align contents of a block element // AlignBlockContents: align contents of a block element
// //
nsresult nsresult
nsHTMLEditRules::AlignBlockContents(nsIDOMNode *aNode, const nsString *alignType) nsHTMLEditRules::AlignBlockContents(nsIDOMNode *aNode, const nsAReadableString *alignType)
{ {
if (!aNode || !alignType) return NS_ERROR_NULL_POINTER; if (!aNode || !alignType) return NS_ERROR_NULL_POINTER;
nsresult res; nsresult res;
@ -4149,7 +4181,7 @@ nsHTMLEditRules::MakeTransitionList(nsISupportsArray *inArrayOfNodes,
// //
nsresult nsresult
nsHTMLEditRules::InsertTab(nsISelection *aSelection, nsHTMLEditRules::InsertTab(nsISelection *aSelection,
nsString *outString) nsAWritableString *outString)
{ {
nsCOMPtr<nsIDOMNode> parentNode; nsCOMPtr<nsIDOMNode> parentNode;
PRInt32 offset; PRInt32 offset;
@ -4165,14 +4197,14 @@ nsHTMLEditRules::InsertTab(nsISelection *aSelection,
if (isPRE) if (isPRE)
{ {
outString->AssignWithConversion('\t'); outString->Assign(PRUnichar('\t'));
} }
else else
{ {
// number of spaces should be a pref? // number of spaces should be a pref?
// note that we dont play around with nbsps here anymore. // note that we dont play around with nbsps here anymore.
// let the AfterEdit whitespace cleanup code handle it. // let the AfterEdit whitespace cleanup code handle it.
outString->AssignWithConversion(" "); outString->Assign(NS_LITERAL_STRING(" "));
} }
return NS_OK; return NS_OK;
@ -4566,7 +4598,7 @@ nsHTMLEditRules::MakeBlockquote(nsISupportsArray *arrayOfNodes)
// one or more blocks of type blockTag. // one or more blocks of type blockTag.
// //
nsresult nsresult
nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString *aBlockTag) nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsAReadableString *aBlockTag)
{ {
// intent of this routine is to be used for converting to/from // intent of this routine is to be used for converting to/from
// headers, paragraphs, pre, and address. Those blocks // headers, paragraphs, pre, and address. Those blocks
@ -4582,7 +4614,8 @@ nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString
// we special case an empty tag name to mean "remove block parents". // we special case an empty tag name to mean "remove block parents".
// This is used for the "normal" paragraph style in mail-compose // This is used for the "normal" paragraph style in mail-compose
if (aBlockTag->IsEmpty() || aBlockTag->EqualsWithConversion("normal")) bNoParent = PR_TRUE; nsString tString(*aBlockTag);////MJUDGE SCC NEED HELP
if (tString.IsEmpty() || tString.EqualsWithConversion("normal")) bNoParent = PR_TRUE;
arrayOfNodes->Count(&listCount); arrayOfNodes->Count(&listCount);
@ -4674,7 +4707,8 @@ nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString
else if (IsInlineNode(curNode) && !bNoParent) else if (IsInlineNode(curNode) && !bNoParent)
{ {
// if curNode is a non editable, drop it if we are going to <pre> // if curNode is a non editable, drop it if we are going to <pre>
if ((aBlockTag->EqualsWithConversion("pre")) && (!mHTMLEditor->IsEditable(curNode))) nsString tString(*aBlockTag); ////MJUDGE SCC NEED HELP
if ((tString.EqualsWithConversion("pre")) && (!mHTMLEditor->IsEditable(curNode)))
continue; // do nothing to this block continue; // do nothing to this block
// if no curBlock, make one // if no curBlock, make one
@ -4707,7 +4741,7 @@ nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString
// where we can insert the tag. Adjust inOutParent and // where we can insert the tag. Adjust inOutParent and
// inOutOffset to pint to new location for tag. // inOutOffset to pint to new location for tag.
nsresult nsresult
nsHTMLEditRules::SplitAsNeeded(const nsString *aTag, nsHTMLEditRules::SplitAsNeeded(const nsAReadableString *aTag,
nsCOMPtr<nsIDOMNode> *inOutParent, nsCOMPtr<nsIDOMNode> *inOutParent,
PRInt32 *inOutOffset) PRInt32 *inOutOffset)
{ {
@ -5443,47 +5477,48 @@ nsHTMLEditRules::DoTextNodeWhitespace(nsIDOMCharacterData *aTextNode, PRInt32 aS
nsresult nsresult
nsHTMLEditRules::ConvertWhitespace(const nsString & inString, nsString & outString) nsHTMLEditRules::ConvertWhitespace(const nsAReadableString & inString, nsAWritableString & outString)
{ {
PRUint32 j,len = inString.Length(); PRUint32 j,len = inString.Length();
nsString tString(inString);////MJUDGE SCC NEED HELP
switch (len) switch (len)
{ {
case 0: case 0:
outString.SetLength(0); outString.SetLength(0);
return NS_OK; return NS_OK;
case 1: case 1:
if (inString.EqualsWithConversion("\n")) // a bit of a hack: don't convert single newlines that if (tString.EqualsWithConversion("\n")) // a bit of a hack: don't convert single newlines that
outString.AssignWithConversion("\n"); // dont have whitespace adjacent. This is to preserve outString.Assign(NS_LITERAL_STRING("\n")); // dont have whitespace adjacent. This is to preserve
else // html source formatting to some degree. else // html source formatting to some degree.
outString.AssignWithConversion(" "); outString.Assign(NS_LITERAL_STRING(" "));
return NS_OK; return NS_OK;
case 2: case 2:
outString.Assign((PRUnichar)nbsp); outString.Assign(PRUnichar(nbsp));
outString.AppendWithConversion(" "); outString.Append(NS_LITERAL_STRING(" "));
return NS_OK; return NS_OK;
case 3: case 3:
outString.AssignWithConversion(" "); outString.Assign(NS_LITERAL_STRING(" "));
outString += (PRUnichar)nbsp; outString += PRUnichar(nbsp);
outString.AppendWithConversion(" "); outString.Append(NS_LITERAL_STRING(" "));
return NS_OK; return NS_OK;
} }
if (len%2) // length is odd if (len%2) // length is odd
{ {
for (j=0;j<len;j++) for (j=0;j<len;j++)
{ {
if (!(j & 0x01)) outString.AppendWithConversion(" "); // even char if (!(j & 0x01)) outString.Append(NS_LITERAL_STRING(" ")); // even char
else outString += (PRUnichar)nbsp; // odd char else outString += PRUnichar(nbsp); // odd char
} }
} }
else else
{ {
outString.AssignWithConversion(" "); outString.Assign(NS_LITERAL_STRING(" "));
outString += (PRUnichar)nbsp; outString += PRUnichar(nbsp);
outString += (PRUnichar)nbsp; outString += PRUnichar(nbsp);
for (j=0;j<len-3;j++) for (j=0;j<len-3;j++)
{ {
if (!(j%2)) outString.AppendWithConversion(" "); // even char if (!(j%2)) outString.Append(NS_LITERAL_STRING(" ")); // even char
else outString += (PRUnichar)nbsp; // odd char else outString += PRUnichar(nbsp); // odd char
} }
} }
return NS_OK; return NS_OK;
@ -5687,13 +5722,13 @@ nsHTMLEditRules::InsertMozBRIfNeeded(nsIDOMNode *aNode)
#endif #endif
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditRules::WillCreateNode(const nsString& aTag, nsIDOMNode *aParent, PRInt32 aPosition) nsHTMLEditRules::WillCreateNode(const nsAReadableString& aTag, nsIDOMNode *aParent, PRInt32 aPosition)
{ {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditRules::DidCreateNode(const nsString& aTag, nsHTMLEditRules::DidCreateNode(const nsAReadableString& aTag,
nsIDOMNode *aNode, nsIDOMNode *aNode,
nsIDOMNode *aParent, nsIDOMNode *aParent,
PRInt32 aPosition, PRInt32 aPosition,
@ -5798,7 +5833,7 @@ nsHTMLEditRules::DidJoinNodes(nsIDOMNode *aLeftNode,
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditRules::WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString) nsHTMLEditRules::WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString)
{ {
return NS_OK; return NS_OK;
} }
@ -5807,7 +5842,7 @@ nsHTMLEditRules::WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset,
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditRules::DidInsertText(nsIDOMCharacterData *aTextNode, nsHTMLEditRules::DidInsertText(nsIDOMCharacterData *aTextNode,
PRInt32 aOffset, PRInt32 aOffset,
const nsString &aString, const nsAReadableString &aString,
nsresult aResult) nsresult aResult)
{ {
if (!mListenerEnabled) return NS_OK; if (!mListenerEnabled) return NS_OK;

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

@ -54,16 +54,17 @@ public:
NS_IMETHOD DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult); NS_IMETHOD DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult);
// nsIHTMLEditRules methods // nsIHTMLEditRules methods
NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL);
NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD); NS_IMETHOD GetListState(PRBool *aMixed, PRBool *aOL, PRBool *aUL, PRBool *aDL);
NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent); NS_IMETHOD GetListItemState(PRBool *aMixed, PRBool *aLI, PRBool *aDT, PRBool *aDD);
NS_IMETHOD GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign); NS_IMETHOD GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent);
NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat); NS_IMETHOD GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign);
NS_IMETHOD GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat);
// nsIEditActionListener methods // nsIEditActionListener methods
NS_IMETHOD WillCreateNode(const nsString& aTag, nsIDOMNode *aParent, PRInt32 aPosition); NS_IMETHOD WillCreateNode(const nsAReadableString& aTag, nsIDOMNode *aParent, PRInt32 aPosition);
NS_IMETHOD DidCreateNode(const nsString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult); NS_IMETHOD DidCreateNode(const nsAReadableString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult);
NS_IMETHOD WillInsertNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition); NS_IMETHOD WillInsertNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition);
NS_IMETHOD DidInsertNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult); NS_IMETHOD DidInsertNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult);
NS_IMETHOD WillDeleteNode(nsIDOMNode *aChild); NS_IMETHOD WillDeleteNode(nsIDOMNode *aChild);
@ -72,8 +73,8 @@ public:
NS_IMETHOD DidSplitNode(nsIDOMNode *aExistingRightNode, PRInt32 aOffset, nsIDOMNode *aNewLeftNode, nsresult aResult); NS_IMETHOD DidSplitNode(nsIDOMNode *aExistingRightNode, PRInt32 aOffset, nsIDOMNode *aNewLeftNode, nsresult aResult);
NS_IMETHOD WillJoinNodes(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsIDOMNode *aParent); NS_IMETHOD WillJoinNodes(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsIDOMNode *aParent);
NS_IMETHOD DidJoinNodes(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsIDOMNode *aParent, nsresult aResult); NS_IMETHOD DidJoinNodes(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsIDOMNode *aParent, nsresult aResult);
NS_IMETHOD WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString); NS_IMETHOD WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString);
NS_IMETHOD DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString, nsresult aResult); NS_IMETHOD DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString, nsresult aResult);
NS_IMETHOD WillDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength); NS_IMETHOD WillDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength);
NS_IMETHOD DidDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength, nsresult aResult); NS_IMETHOD DidDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength, nsresult aResult);
NS_IMETHOD WillDeleteSelection(nsISelection *aSelection); NS_IMETHOD WillDeleteSelection(nsISelection *aSelection);
@ -95,31 +96,31 @@ protected:
nsISelection *aSelection, nsISelection *aSelection,
PRBool *aCancel, PRBool *aCancel,
PRBool *aHandled, PRBool *aHandled,
const nsString *inString, const nsAReadableString *inString,
nsString *outString, nsAWritableString *outString,
PRInt32 aMaxLength); PRInt32 aMaxLength);
nsresult WillInsertBreak(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); nsresult WillInsertBreak(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled);
nsresult DidInsertBreak(nsISelection *aSelection, nsresult aResult); nsresult DidInsertBreak(nsISelection *aSelection, nsresult aResult);
nsresult WillDeleteSelection(nsISelection *aSelection, nsIEditor::EDirection aAction, nsresult WillDeleteSelection(nsISelection *aSelection, nsIEditor::EDirection aAction,
PRBool *aCancel, PRBool *aHandled); PRBool *aCancel, PRBool *aHandled);
nsresult DeleteNonTableElements(nsIDOMNode *aNode); nsresult DeleteNonTableElements(nsIDOMNode *aNode);
nsresult WillMakeList(nsISelection *aSelection, const nsString *aListType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled, const nsString *aItemType=nsnull); nsresult WillMakeList(nsISelection *aSelection, const nsAReadableString *aListType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled, const nsAReadableString *aItemType=nsnull);
nsresult WillRemoveList(nsISelection *aSelection, PRBool aOrderd, PRBool *aCancel, PRBool *aHandled); nsresult WillRemoveList(nsISelection *aSelection, PRBool aOrderd, PRBool *aCancel, PRBool *aHandled);
nsresult WillIndent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); nsresult WillIndent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled);
nsresult WillOutdent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); nsresult WillOutdent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled);
nsresult WillAlign(nsISelection *aSelection, const nsString *alignType, PRBool *aCancel, PRBool *aHandled); nsresult WillAlign(nsISelection *aSelection, const nsAReadableString *alignType, PRBool *aCancel, PRBool *aHandled);
nsresult WillMakeDefListItem(nsISelection *aSelection, const nsString *aBlockType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled); nsresult WillMakeDefListItem(nsISelection *aSelection, const nsAReadableString *aBlockType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled);
nsresult WillMakeBasicBlock(nsISelection *aSelection, const nsString *aBlockType, PRBool *aCancel, PRBool *aHandled); nsresult WillMakeBasicBlock(nsISelection *aSelection, const nsAReadableString *aBlockType, PRBool *aCancel, PRBool *aHandled);
nsresult DidMakeBasicBlock(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult); nsresult DidMakeBasicBlock(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult);
nsresult AlignInnerBlocks(nsIDOMNode *aNode, const nsString *alignType); nsresult AlignInnerBlocks(nsIDOMNode *aNode, const nsAReadableString *alignType);
nsresult AlignBlockContents(nsIDOMNode *aNode, const nsString *alignType); nsresult AlignBlockContents(nsIDOMNode *aNode, const nsAReadableString *alignType);
nsresult GetInnerContent(nsIDOMNode *aNode, nsISupportsArray *outArrayOfNodes, PRBool aList = PR_TRUE, PRBool aTble = PR_TRUE); nsresult GetInnerContent(nsIDOMNode *aNode, nsISupportsArray *outArrayOfNodes, PRBool aList = PR_TRUE, PRBool aTble = PR_TRUE);
nsresult InsertTab(nsISelection *aSelection, nsString *outString); nsresult InsertTab(nsISelection *aSelection, nsAWritableString *outString);
nsresult ReturnInHeader(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset); nsresult ReturnInHeader(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset);
nsresult ReturnInParagraph(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset, PRBool *aCancel, PRBool *aHandled); nsresult ReturnInParagraph(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset, PRBool *aCancel, PRBool *aHandled);
nsresult ReturnInListItem(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset); nsresult ReturnInListItem(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset);
nsresult AfterEditInner(PRInt32 action, nsIEditor::EDirection aDirection); nsresult AfterEditInner(PRInt32 action, nsIEditor::EDirection aDirection);
nsresult ConvertListType(nsIDOMNode *aList, nsCOMPtr<nsIDOMNode> *outList, const nsString& aListType, const nsString& aItemType); nsresult ConvertListType(nsIDOMNode *aList, nsCOMPtr<nsIDOMNode> *outList, const nsAReadableString& aListType, const nsAReadableString& aItemType);
nsresult CreateStyleForInsertText(nsISelection *aSelection, nsIDOMDocument *aDoc); nsresult CreateStyleForInsertText(nsISelection *aSelection, nsIDOMDocument *aDoc);
nsresult IsEmptyBlock(nsIDOMNode *aNode, nsresult IsEmptyBlock(nsIDOMNode *aNode,
PRBool *outIsEmptyBlock, PRBool *outIsEmptyBlock,
@ -150,9 +151,9 @@ protected:
nsCOMPtr<nsIDOMNode> GetHighestInlineParent(nsIDOMNode* aNode); nsCOMPtr<nsIDOMNode> GetHighestInlineParent(nsIDOMNode* aNode);
nsresult MakeTransitionList(nsISupportsArray *inArrayOfNodes, nsresult MakeTransitionList(nsISupportsArray *inArrayOfNodes,
nsVoidArray *inTransitionArray); nsVoidArray *inTransitionArray);
nsresult ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsString *aBlockTag); nsresult ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsAReadableString *aBlockTag);
nsresult MakeBlockquote(nsISupportsArray *arrayOfNodes); nsresult MakeBlockquote(nsISupportsArray *arrayOfNodes);
nsresult SplitAsNeeded(const nsString *aTag, nsCOMPtr<nsIDOMNode> *inOutParent, PRInt32 *inOutOffset); nsresult SplitAsNeeded(const nsAReadableString *aTag, nsCOMPtr<nsIDOMNode> *inOutParent, PRInt32 *inOutOffset);
nsresult AddTerminatingBR(nsIDOMNode *aBlock); nsresult AddTerminatingBR(nsIDOMNode *aBlock);
nsresult JoinNodesSmart( nsIDOMNode *aNodeLeft, nsresult JoinNodesSmart( nsIDOMNode *aNodeLeft,
nsIDOMNode *aNodeRight, nsIDOMNode *aNodeRight,
@ -172,7 +173,7 @@ protected:
nsresult SelectionEndpointInNode(nsIDOMNode *aNode, PRBool *aResult); nsresult SelectionEndpointInNode(nsIDOMNode *aNode, PRBool *aResult);
nsresult DoTextNodeWhitespace(nsIDOMCharacterData *aTextNode, PRInt32 aStart, PRInt32 aEnd); nsresult DoTextNodeWhitespace(nsIDOMCharacterData *aTextNode, PRInt32 aStart, PRInt32 aEnd);
nsresult UpdateDocChangeRange(nsIDOMRange *aRange); nsresult UpdateDocChangeRange(nsIDOMRange *aRange);
nsresult ConvertWhitespace(const nsString & inString, nsString & outString); nsresult ConvertWhitespace(const nsAReadableString & inString, nsAWritableString & outString);
nsresult ConfirmSelectionInBody(); nsresult ConfirmSelectionInBody();
nsresult InsertMozBRIfNeeded(nsIDOMNode *aNode); nsresult InsertMozBRIfNeeded(nsIDOMNode *aNode);

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

@ -425,9 +425,9 @@ NS_IMETHODIMP nsHTMLEditor::InitRules()
* Can be used to determine if a new paragraph should be started. * Can be used to determine if a new paragraph should be started.
*/ */
nsresult nsresult
nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock) nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool *aIsBlock)
{ {
if (!aNode) { return NS_ERROR_NULL_POINTER; } if (!aNode || !aIsBlock) { return NS_ERROR_NULL_POINTER; }
//#define USE_PARSER_FOR_BLOCKNESS 1 //#define USE_PARSER_FOR_BLOCKNESS 1
#ifdef USE_PARSER_FOR_BLOCKNESS #ifdef USE_PARSER_FOR_BLOCKNESS
@ -443,11 +443,11 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
if (!element) if (!element)
{ {
// We don't have an element -- probably a text node // We don't have an element -- probably a text node
aIsBlock = PR_FALSE; *aIsBlock = PR_FALSE;
return NS_OK; return NS_OK;
} }
aIsBlock = PR_FALSE; *aIsBlock = PR_FALSE;
// Get the node name and atom: // Get the node name and atom:
nsAutoString tagName; nsAutoString tagName;
@ -475,7 +475,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
tagAtom==nsIEditProperty::td || tagAtom==nsIEditProperty::td ||
tagAtom==nsIEditProperty::pre) tagAtom==nsIEditProperty::pre)
{ {
aIsBlock = PR_TRUE; *aIsBlock = PR_TRUE;
return NS_OK; return NS_OK;
} }
@ -487,7 +487,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
PRInt32 id; PRInt32 id;
rv = sParserService->HTMLStringTagToId(tagName, &id); rv = sParserService->HTMLStringTagToId(tagName, &id);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = sParserService->IsBlock(id, aIsBlock); rv = sParserService->IsBlock(id, *aIsBlock);
#ifdef DEBUG #ifdef DEBUG
// Check this against what we would have said with the old code: // Check this against what we would have said with the old code:
@ -517,12 +517,12 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
tagAtom==nsIEditProperty::dd || tagAtom==nsIEditProperty::dd ||
tagAtom==nsIEditProperty::legend ) tagAtom==nsIEditProperty::legend )
{ {
if (!aIsBlock) if (!(*aIsBlock))
{ {
nsAutoString assertmsg (NS_LITERAL_STRING("Parser and editor disagree on blockness: ")); nsAutoString assertmsg (NS_LITERAL_STRING("Parser and editor disagree on blockness: "));
assertmsg.Append(tagName); assertmsg.Append(tagName);
char* assertstr = assertmsg.ToNewCString(); char* assertstr = assertmsg.ToNewCString();
NS_ASSERTION(aIsBlock, assertstr); NS_ASSERTION(*aIsBlock, assertstr);
Recycle(assertstr); Recycle(assertstr);
} }
} }
@ -531,7 +531,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
return rv; return rv;
#else /* USE_PARSER_FOR_BLOCKNESS */ #else /* USE_PARSER_FOR_BLOCKNESS */
nsresult result = NS_ERROR_FAILURE; nsresult result = NS_ERROR_FAILURE;
aIsBlock = PR_FALSE; *aIsBlock = PR_FALSE;
nsCOMPtr<nsIDOMElement>element; nsCOMPtr<nsIDOMElement>element;
element = do_QueryInterface(aNode); element = do_QueryInterface(aNode);
if (element) if (element)
@ -578,7 +578,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
tagAtom==nsIEditProperty::dd || tagAtom==nsIEditProperty::dd ||
tagAtom==nsIEditProperty::legend ) tagAtom==nsIEditProperty::legend )
{ {
aIsBlock = PR_TRUE; *aIsBlock = PR_TRUE;
} }
NS_RELEASE(tagAtom); NS_RELEASE(tagAtom);
result = NS_OK; result = NS_OK;
@ -588,7 +588,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
nsCOMPtr<nsIDOMCharacterData>nodeAsText = do_QueryInterface(aNode); nsCOMPtr<nsIDOMCharacterData>nodeAsText = do_QueryInterface(aNode);
if (nodeAsText) if (nodeAsText)
{ {
aIsBlock = PR_FALSE; *aIsBlock = PR_FALSE;
result = NS_OK; result = NS_OK;
} }
} }
@ -597,22 +597,21 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock)
#endif /* USE_PARSER_FOR_BLOCKNESS */ #endif /* USE_PARSER_FOR_BLOCKNESS */
} }
// Non-static version for the nsIEditor interface and JavaScript NS_IMETHODIMP
NS_IMETHODIMP nsHTMLEditor::NodeIsBlock(nsIDOMNode *aNode, PRBool *aIsBlock)
nsHTMLEditor::NodeIsBlock(nsIDOMNode *aNode, PRBool &aIsBlock)
{ {
return NodeIsBlockStatic(aNode, aIsBlock); return NodeIsBlockStatic(aNode, aIsBlock);
} }
// Non-static version for the nsIEditor interface and JavaScript
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::SetDocumentTitle(const PRUnichar *aTitle) nsHTMLEditor::SetDocumentTitle(const nsAReadableString &aTitle)
{ {
SetDocTitleTxn *txn; SetDocTitleTxn *txn;
nsresult result = TransactionFactory::GetNewTransaction(SetDocTitleTxn::GetCID(), (EditTxn **)&txn); nsresult result = TransactionFactory::GetNewTransaction(SetDocTitleTxn::GetCID(), (EditTxn **)&txn);
if (NS_SUCCEEDED(result)) if (NS_SUCCEEDED(result))
{ {
nsAutoString title(aTitle); result = txn->Init(this, &aTitle);
result = txn->Init(this, &title);
if (NS_SUCCEEDED(result)) if (NS_SUCCEEDED(result))
{ {
@ -646,7 +645,7 @@ nsHTMLEditor::GetBlockNodeParent(nsIDOMNode *aNode)
while (p) while (p)
{ {
PRBool isBlock; PRBool isBlock;
if (NS_FAILED(NodeIsBlockStatic(p, isBlock)) || isBlock) if (NS_FAILED(NodeIsBlockStatic(p, &isBlock)) || isBlock)
break; break;
if ( NS_FAILED(p->GetParentNode(getter_AddRefs(tmp))) || !tmp) // no parent, ran off top of tree if ( NS_FAILED(p->GetParentNode(getter_AddRefs(tmp))) || !tmp) // no parent, ran off top of tree
return p; return p;
@ -697,7 +696,7 @@ nsHTMLEditor::GetBlockSection(nsIDOMNode *aChild,
while ((NS_SUCCEEDED(result)) && sibling) while ((NS_SUCCEEDED(result)) && sibling)
{ {
PRBool isBlock; PRBool isBlock;
NodeIsBlockStatic(sibling, isBlock); NodeIsBlockStatic(sibling, &isBlock);
if (isBlock) if (isBlock)
{ {
nsCOMPtr<nsIDOMCharacterData>nodeAsText = do_QueryInterface(sibling); nsCOMPtr<nsIDOMCharacterData>nodeAsText = do_QueryInterface(sibling);
@ -715,7 +714,7 @@ nsHTMLEditor::GetBlockSection(nsIDOMNode *aChild,
while ((NS_SUCCEEDED(result)) && sibling) while ((NS_SUCCEEDED(result)) && sibling)
{ {
PRBool isBlock; PRBool isBlock;
NodeIsBlockStatic(sibling, isBlock); NodeIsBlockStatic(sibling, &isBlock);
if (isBlock) if (isBlock)
{ {
nsCOMPtr<nsIDOMCharacterData>nodeAsText = do_QueryInterface(sibling); nsCOMPtr<nsIDOMCharacterData>nodeAsText = do_QueryInterface(sibling);
@ -768,7 +767,7 @@ nsHTMLEditor::GetBlockSectionsForRange(nsIDOMRange *aRange,
else else
{ {
PRBool isNotInlineOrText; PRBool isNotInlineOrText;
result = NodeIsBlockStatic(currentNode, isNotInlineOrText); result = NodeIsBlockStatic(currentNode, &isNotInlineOrText);
if (isNotInlineOrText) if (isNotInlineOrText)
{ {
PRUint16 nodeType; PRUint16 nodeType;
@ -861,7 +860,7 @@ nsHTMLEditor::NextNodeInBlock(nsIDOMNode *aNode, IterDirection aDir)
// much gnashing of teeth as we twit back and forth between content and domnode types // much gnashing of teeth as we twit back and forth between content and domnode types
content = do_QueryInterface(aNode); content = do_QueryInterface(aNode);
PRBool isBlock; PRBool isBlock;
if (NS_SUCCEEDED(NodeIsBlockStatic(aNode, isBlock)) && isBlock) if (NS_SUCCEEDED(NodeIsBlockStatic(aNode, &isBlock)) && isBlock)
{ {
blockParent = do_QueryInterface(aNode); blockParent = do_QueryInterface(aNode);
} }
@ -936,7 +935,7 @@ nsHTMLEditor::IsNextCharWhitespace(nsIDOMNode *aParentNode,
while (node) while (node)
{ {
PRBool isBlock (PR_FALSE); PRBool isBlock (PR_FALSE);
NodeIsBlock(node, isBlock); NodeIsBlock(node, &isBlock);
if (isBlock) // skip over bold, italic, link, ect nodes if (isBlock) // skip over bold, italic, link, ect nodes
{ {
if (IsTextNode(node) && IsEditable(node)) if (IsTextNode(node) && IsEditable(node))
@ -1007,7 +1006,7 @@ nsHTMLEditor::IsPrevCharWhitespace(nsIDOMNode *aParentNode,
while (node) while (node)
{ {
PRBool isBlock (PR_FALSE); PRBool isBlock (PR_FALSE);
NodeIsBlock(node, isBlock); NodeIsBlock(node, &isBlock);
if (isBlock) // skip over bold, italic, link, ect nodes if (isBlock) // skip over bold, italic, link, ect nodes
{ {
if (IsTextNode(node) && IsEditable(node)) if (IsTextNode(node) && IsEditable(node))
@ -1093,7 +1092,7 @@ NS_IMETHODIMP nsHTMLEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
if (!node) return NS_ERROR_FAILURE; if (!node) return NS_ERROR_FAILURE;
PRBool isBlock (PR_FALSE); PRBool isBlock (PR_FALSE);
NodeIsBlock(node, isBlock); NodeIsBlock(node, &isBlock);
if (isBlock) blockParent = node; if (isBlock) blockParent = node;
else blockParent = GetBlockNodeParent(node); else blockParent = GetBlockNodeParent(node);
@ -1121,18 +1120,18 @@ NS_IMETHODIMP nsHTMLEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
nsString empty; nsString empty;
if (isShift && !(mFlags&eEditorPlaintextBit)) if (isShift && !(mFlags&eEditorPlaintextBit))
{ {
return TypedText(empty.GetUnicode(), eTypedBR); // only inserts a br node return TypedText(empty, eTypedBR); // only inserts a br node
} }
else else
{ {
return TypedText(empty.GetUnicode(), eTypedBreak); // uses rules to figure out what to insert return TypedText(empty, eTypedBreak); // uses rules to figure out what to insert
} }
} }
else if (keyCode == nsIDOMKeyEvent::DOM_VK_ESCAPE) else if (keyCode == nsIDOMKeyEvent::DOM_VK_ESCAPE)
{ {
// pass escape keypresses through as empty strings: needed forime support // pass escape keypresses through as empty strings: needed forime support
nsString empty; nsString empty;
return TypedText(empty.GetUnicode(), eTypedText); return TypedText(empty, eTypedText);
} }
// if we got here we either fell out of the tab case or have a normal character. // if we got here we either fell out of the tab case or have a normal character.
@ -1140,7 +1139,7 @@ NS_IMETHODIMP nsHTMLEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
if (character && !altKey && !ctrlKey && !isShift && !metaKey) if (character && !altKey && !ctrlKey && !isShift && !metaKey)
{ {
nsAutoString key(character); nsAutoString key(character);
return TypedText(key.GetUnicode(), eTypedText); return TypedText(key, eTypedText);
} }
} }
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -1152,7 +1151,7 @@ NS_IMETHODIMP nsHTMLEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
to TypedText() to determine what action to take, but without passing to TypedText() to determine what action to take, but without passing
an event. an event.
*/ */
NS_IMETHODIMP nsHTMLEditor::TypedText(const PRUnichar* aString, NS_IMETHODIMP nsHTMLEditor::TypedText(const nsAReadableString& aString,
PRInt32 aAction) PRInt32 aAction)
{ {
nsAutoPlaceHolderBatch batch(this, gTypingTxnName); nsAutoPlaceHolderBatch batch(this, gTypingTxnName);
@ -1491,7 +1490,7 @@ nsHTMLEditor::CollapseSelectionToDeepestNonTableFirstChild(nsISelection *aSelect
// but we can't use that because it is selection-based and // but we can't use that because it is selection-based and
// the rules code won't let us edit under the <head> node // the rules code won't let us edit under the <head> node
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsString &aSourceToInsert) nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsAReadableString& aSourceToInsert)
{ {
nsCOMPtr<nsISelection> selection; nsCOMPtr<nsISelection> selection;
nsresult res = GetSelection(getter_AddRefs(selection)); nsresult res = GetSelection(getter_AddRefs(selection));
@ -1596,7 +1595,7 @@ nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsString &aSourceToInsert)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::RebuildDocumentFromSource(const nsString& aSourceString) nsHTMLEditor::RebuildDocumentFromSource(const nsAReadableString& aSourceString)
{ {
ForceCompositionEnd(); ForceCompositionEnd();
@ -1611,22 +1610,29 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsString& aSourceString)
// Find where the <body> tag starts. // Find where the <body> tag starts.
// If user mangled that, then abort // If user mangled that, then abort
PRInt32 bodyStart = aSourceString.Find(NS_ConvertASCIItoUCS2("<body"), PR_TRUE); nsReadingIterator<PRUnichar> beginbody;
if (bodyStart == -1) return NS_ERROR_FAILURE; nsReadingIterator<PRUnichar> endbody;
aSourceString.BeginReading(beginbody);
aSourceString.EndReading(endbody);
if (!FindInReadable(NS_LITERAL_STRING("<body"),beginbody,endbody))
return NS_ERROR_FAILURE;
PRInt32 headStart = aSourceString.Find(NS_ConvertASCIItoUCS2("<head"), PR_TRUE); nsReadingIterator<PRUnichar> beginhead;
if (headStart == -1) return NS_ERROR_FAILURE; nsReadingIterator<PRUnichar> endhead;
aSourceString.BeginReading(beginhead);
aSourceString.EndReading(endhead);
if (!FindInReadable(NS_LITERAL_STRING("<head"),beginhead,endhead))
return NS_ERROR_FAILURE;
nsReadingIterator<PRUnichar> beginclosehead;
nsReadingIterator<PRUnichar> endclosehead;
aSourceString.BeginReading(beginclosehead);
aSourceString.EndReading(endclosehead);
// Find the index after "<head>" // Find the index after "<head>"
PRInt32 headEnd = aSourceString.Find(NS_ConvertASCIItoUCS2("</head"), PR_TRUE); if (!FindInReadable(NS_LITERAL_STRING("</head"),beginclosehead,endclosehead))
beginclosehead = beginbody;
// We'll be forgiving and assume head ends before body // We'll be forgiving and assume head ends before body
if (headEnd == -1) headEnd = bodyStart;
nsAutoString headString;
aSourceString.Mid(headString, headStart, (headEnd - headStart));
nsAutoString bodyString;
aSourceString.Mid(bodyString, bodyStart, (aSourceString.Length() - bodyStart - 1));
// Time to change the document // Time to change the document
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
@ -1635,25 +1641,32 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsString& aSourceString)
res = SelectAll(); res = SelectAll();
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
res = InsertHTML(bodyString); nsReadingIterator<PRUnichar> endtotal;
aSourceString.EndReading(endtotal);
res = InsertHTML(Substring(beginbody,endtotal));
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
selection->Collapse(bodyElement, 0); selection->Collapse(bodyElement, 0);
res = ReplaceHeadContentsWithHTML(headString); res = ReplaceHeadContentsWithHTML(Substring(beginhead,beginclosehead));
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
// Now we must copy attributes user might have edited on the <body> tag // Now we must copy attributes user might have edited on the <body> tag
// because InsertHTML (actually, CreateContextualFragment()) // because InsertHTML (actually, CreateContextualFragment())
// will never return a body node in the DOM fragment // will never return a body node in the DOM fragment
nsAutoString bodyTag; nsReadingIterator<PRUnichar> beginclosebody = endbody;//<bodyX
nsReadingIterator<PRUnichar> endclosebody;
aSourceString.BeginReading(beginclosebody);
aSourceString.EndReading(endclosebody);
if (!FindInReadable(NS_LITERAL_STRING(">"),beginclosebody,endclosebody))
return NS_ERROR_FAILURE;
nsAutoString bodyTag(Substring(beginbody,endclosebody));//<bodyXXXX >
// Truncate at the end of the body tag // Truncate at the end of the body tag
PRInt32 bodyTagEnd = bodyString.FindChar((PRUnichar)'>', PR_FALSE, 5);
if (bodyTagEnd == -1) return NS_ERROR_FAILURE;
bodyString.Truncate(bodyTagEnd+1);
// Kludge of the year: fool the parser by replacing "body" with "div" so we get a node // Kludge of the year: fool the parser by replacing "body" with "div" so we get a node
bodyString.ToLowerCase(); bodyTag.ToLowerCase();
bodyString.ReplaceSubstring(NS_ConvertASCIItoUCS2("body"), NS_ConvertASCIItoUCS2("div")); bodyTag.ReplaceSubstring(NS_ConvertASCIItoUCS2("body"), NS_ConvertASCIItoUCS2("div"));
nsCOMPtr<nsIDOMRange> range; nsCOMPtr<nsIDOMRange> range;
res = selection->GetRangeAt(0, getter_AddRefs(range)); res = selection->GetRangeAt(0, getter_AddRefs(range));
@ -1663,7 +1676,7 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsString& aSourceString)
if (!nsrange) return NS_ERROR_NO_INTERFACE; if (!nsrange) return NS_ERROR_NO_INTERFACE;
nsCOMPtr<nsIDOMDocumentFragment> docfrag; nsCOMPtr<nsIDOMDocumentFragment> docfrag;
res = nsrange->CreateContextualFragment(bodyString, getter_AddRefs(docfrag)); res = nsrange->CreateContextualFragment(bodyTag, getter_AddRefs(docfrag));
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
nsCOMPtr<nsIDOMNode> fragmentAsNode (do_QueryInterface(docfrag)); nsCOMPtr<nsIDOMNode> fragmentAsNode (do_QueryInterface(docfrag));
@ -1876,7 +1889,7 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::SetParagraphFormat(const nsString& aParagraphFormat) nsHTMLEditor::SetParagraphFormat(const nsAReadableString& aParagraphFormat)
{ {
nsAutoString tag; tag.Assign(aParagraphFormat); nsAutoString tag; tag.Assign(aParagraphFormat);
tag.ToLowerCase(); tag.ToLowerCase();
@ -1923,7 +1936,7 @@ nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists)
else else
{ {
PRBool isBlock (PR_FALSE); PRBool isBlock (PR_FALSE);
NodeIsBlock(node, isBlock); NodeIsBlock(node, &isBlock);
if (isBlock) blockParent = node; if (isBlock) blockParent = node;
else blockParent = GetBlockNodeParent(node); else blockParent = GetBlockNodeParent(node);
blockParentElem = do_QueryInterface(blockParent); blockParentElem = do_QueryInterface(blockParent);
@ -2004,10 +2017,10 @@ nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists)
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetParagraphState(PRBool &aMixed, nsString &outFormat) nsHTMLEditor::GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat)
{ {
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
if (!aMixed) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules); nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules);
if (!htmlRules) return NS_ERROR_FAILURE; if (!htmlRules) return NS_ERROR_FAILURE;
@ -2015,11 +2028,12 @@ nsHTMLEditor::GetParagraphState(PRBool &aMixed, nsString &outFormat)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetBackgroundColorState(PRBool &aMixed, nsString &aOutColor) nsHTMLEditor::GetBackgroundColorState(PRBool *aMixed, nsAWritableString &aOutColor)
{ {
//TODO: We don't handle "mixed" correctly! //TODO: We don't handle "mixed" correctly!
aMixed = PR_FALSE; if (!aMixed) return NS_ERROR_NULL_POINTER;
aOutColor.AssignWithConversion(""); *aMixed = PR_FALSE;
aOutColor.Assign(NS_LITERAL_STRING(""));
nsCOMPtr<nsIDOMElement> element; nsCOMPtr<nsIDOMElement> element;
PRInt32 selectedCount; PRInt32 selectedCount;
@ -2059,10 +2073,10 @@ nsHTMLEditor::GetBackgroundColorState(PRBool &aMixed, nsString &aOutColor)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL) nsHTMLEditor::GetListState(PRBool *aMixed, PRBool *aOL, PRBool *aUL, PRBool *aDL)
{ {
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
if (!aMixed || !aOL || !aUL || !aDL) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules); nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules);
if (!htmlRules) return NS_ERROR_FAILURE; if (!htmlRules) return NS_ERROR_FAILURE;
@ -2070,9 +2084,10 @@ nsHTMLEditor::GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD) nsHTMLEditor::GetListItemState(PRBool *aMixed, PRBool *aLI, PRBool *aDT, PRBool *aDD)
{ {
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
if (!aMixed || !aLI || !aDT || !aDD) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules); nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules);
if (!htmlRules) return NS_ERROR_FAILURE; if (!htmlRules) return NS_ERROR_FAILURE;
@ -2081,10 +2096,10 @@ nsHTMLEditor::GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign) nsHTMLEditor::GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
{ {
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
if (!aMixed || !aAlign) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules); nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules);
if (!htmlRules) return NS_ERROR_FAILURE; if (!htmlRules) return NS_ERROR_FAILURE;
@ -2093,9 +2108,10 @@ nsHTMLEditor::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent) nsHTMLEditor::GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent)
{ {
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
if (!aCanIndent || !aCanOutdent) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules); nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules);
if (!htmlRules) return NS_ERROR_FAILURE; if (!htmlRules) return NS_ERROR_FAILURE;
@ -2104,7 +2120,7 @@ nsHTMLEditor::GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::MakeOrChangeList(const nsString& aListType, PRBool entireList) nsHTMLEditor::MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList)
{ {
nsresult res; nsresult res;
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@ -2182,7 +2198,7 @@ nsHTMLEditor::MakeOrChangeList(const nsString& aListType, PRBool entireList)
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::RemoveList(const nsString& aListType) nsHTMLEditor::RemoveList(const nsAReadableString& aListType)
{ {
nsresult res; nsresult res;
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@ -2199,7 +2215,8 @@ nsHTMLEditor::RemoveList(const nsString& aListType)
if (!selection) return NS_ERROR_NULL_POINTER; if (!selection) return NS_ERROR_NULL_POINTER;
nsTextRulesInfo ruleInfo(nsTextEditRules::kRemoveList); nsTextRulesInfo ruleInfo(nsTextEditRules::kRemoveList);
if (aListType.EqualsWithConversion("ol")) ruleInfo.bOrdered = PR_TRUE; nsString tString(aListType);//MJUDGE SCC NEED HELP
if (tString.EqualsWithConversion("ol")) ruleInfo.bOrdered = PR_TRUE;
else ruleInfo.bOrdered = PR_FALSE; else ruleInfo.bOrdered = PR_FALSE;
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled); res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
if (cancel || (NS_FAILED(res))) return res; if (cancel || (NS_FAILED(res))) return res;
@ -2211,7 +2228,7 @@ nsHTMLEditor::RemoveList(const nsString& aListType)
} }
nsresult nsresult
nsHTMLEditor::MakeDefinitionItem(const nsString& aItemType) nsHTMLEditor::MakeDefinitionItem(const nsAReadableString& aItemType)
{ {
nsresult res; nsresult res;
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@ -2241,7 +2258,7 @@ nsHTMLEditor::MakeDefinitionItem(const nsString& aItemType)
} }
nsresult nsresult
nsHTMLEditor::InsertBasicBlock(const nsString& aBlockType) nsHTMLEditor::InsertBasicBlock(const nsAReadableString& aBlockType)
{ {
nsresult res; nsresult res;
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@ -2313,7 +2330,7 @@ nsHTMLEditor::InsertBasicBlock(const nsString& aBlockType)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::Indent(const nsString& aIndent) nsHTMLEditor::Indent(const nsAReadableString& aIndent)
{ {
nsresult res; nsresult res;
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@ -2321,7 +2338,8 @@ nsHTMLEditor::Indent(const nsString& aIndent)
PRBool cancel, handled; PRBool cancel, handled;
PRInt32 theAction = nsTextEditRules::kIndent; PRInt32 theAction = nsTextEditRules::kIndent;
PRInt32 opID = kOpIndent; PRInt32 opID = kOpIndent;
if (aIndent.EqualsWithConversion("outdent")) nsString tString(aIndent);//MJUDGE SCC NEED HELP
if (tString.EqualsWithConversion("outdent"))
{ {
theAction = nsTextEditRules::kOutdent; theAction = nsTextEditRules::kOutdent;
opID = kOpOutdent; opID = kOpOutdent;
@ -2384,7 +2402,7 @@ nsHTMLEditor::Indent(const nsString& aIndent)
// put a space in it so layout will draw the list item // put a space in it so layout will draw the list item
res = selection->Collapse(newBQ,0); res = selection->Collapse(newBQ,0);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
res = InsertText(NS_LITERAL_STRING(" ").get()); res = InsertText(NS_LITERAL_STRING(" "));
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
// reposition selection to before the space character // reposition selection to before the space character
res = GetStartNodeAndOffset(selection, address_of(node), &offset); res = GetStartNodeAndOffset(selection, address_of(node), &offset);
@ -2401,7 +2419,7 @@ nsHTMLEditor::Indent(const nsString& aIndent)
//TODO: IMPLEMENT ALIGNMENT! //TODO: IMPLEMENT ALIGNMENT!
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::Align(const nsString& aAlignType) nsHTMLEditor::Align(const nsAReadableString& aAlignType)
{ {
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, kOpAlign, nsIEditor::eNext); nsAutoRules beginRulesSniffing(this, kOpAlign, nsIEditor::eNext);
@ -2547,7 +2565,7 @@ NODE_FOUND:
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aReturn) nsHTMLEditor::GetSelectedElement(const nsAReadableString& aTagName, nsIDOMElement** aReturn)
{ {
if (!aReturn ) if (!aReturn )
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
@ -2895,8 +2913,8 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
if (href.GetUnicode() && href.Length() > 0) if (href.GetUnicode() && href.Length() > 0)
{ {
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsString attribute; attribute.AssignWithConversion("href"); nsString attribute(NS_LITERAL_STRING("href"));
SetInlineProperty(nsIEditProperty::a, &attribute, &href); SetInlineProperty(nsIEditProperty::a, attribute, href);
//TODO: Enumerate through other properties of the anchor tag //TODO: Enumerate through other properties of the anchor tag
// and set those as well. // and set those as well.
// Optimization: Modify SetTextProperty to set all attributes at once? // Optimization: Modify SetTextProperty to set all attributes at once?
@ -2907,7 +2925,7 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::SetBackgroundColor(const nsString& aColor) nsHTMLEditor::SetBackgroundColor(const nsAReadableString& aColor)
{ {
NS_PRECONDITION(mDocWeak, "Missing Editor DOM Document"); NS_PRECONDITION(mDocWeak, "Missing Editor DOM Document");
@ -2958,7 +2976,7 @@ nsHTMLEditor::SetBackgroundColor(const nsString& aColor)
return res; return res;
} }
NS_IMETHODIMP nsHTMLEditor::SetBodyAttribute(const nsString& aAttribute, const nsString& aValue) NS_IMETHODIMP nsHTMLEditor::SetBodyAttribute(const nsAReadableString& aAttribute, const nsAReadableString& aValue)
{ {
nsresult res; nsresult res;
// TODO: Check selection for Cell, Row, Column or table and do color on appropriate level // TODO: Check selection for Cell, Row, Column or table and do color on appropriate level
@ -3056,20 +3074,20 @@ nsHTMLEditor::RemoveOverrideStyleSheet(nsICSSStyleSheet* aSheet)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::ApplyOverrideStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet) nsHTMLEditor::ApplyOverrideStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet)
{ {
return ApplyDocumentOrOverrideStyleSheet(aURL, PR_TRUE, aStyleSheet); return ApplyDocumentOrOverrideStyleSheet(aURL, PR_TRUE, aStyleSheet);
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet) nsHTMLEditor::ApplyStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet)
{ {
return ApplyDocumentOrOverrideStyleSheet(aURL, PR_FALSE, aStyleSheet); return ApplyDocumentOrOverrideStyleSheet(aURL, PR_FALSE, aStyleSheet);
} }
//Note: Loading a document style sheet is undoable, loading an override sheet is not //Note: Loading a document style sheet is undoable, loading an override sheet is not
nsresult nsresult
nsHTMLEditor::ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet) nsHTMLEditor::ApplyDocumentOrOverrideStyleSheet(const nsAReadableString& aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet)
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
nsCOMPtr<nsIURI> uaURL; nsCOMPtr<nsIURI> uaURL;
@ -3273,7 +3291,7 @@ static nsresult SetSelectionAroundHeadChildren(nsCOMPtr<nsISelection> aSelection
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetHeadContentsAsHTML(nsString& aOutputString) nsHTMLEditor::GetHeadContentsAsHTML(nsAWritableString& aOutputString)
{ {
nsCOMPtr<nsISelection> selection; nsCOMPtr<nsISelection> selection;
nsresult res = GetSelection(getter_AddRefs(selection)); nsresult res = GetSelection(getter_AddRefs(selection));
@ -3292,15 +3310,27 @@ nsHTMLEditor::GetHeadContentsAsHTML(nsString& aOutputString)
{ {
// Selection always includes <body></body>, // Selection always includes <body></body>,
// so terminate there // so terminate there
PRInt32 offset = aOutputString.Find(NS_ConvertASCIItoUCS2("<body"), PR_TRUE); nsReadingIterator<PRUnichar> findIter,endFindIter;
if (offset > 0) aOutputString.BeginReading(findIter);
aOutputString.EndReading(endFindIter);
//counting on our parser to always lower case!!!
if (FindInReadable(NS_LITERAL_STRING("<body"),findIter,endFindIter))
{ {
nsReadingIterator<PRUnichar> beginIter;
aOutputString.BeginReading(beginIter);
PRInt32 offset = Distance(beginIter, findIter);//get the distance
nsWritingIterator<PRUnichar> writeIter;
aOutputString.BeginWriting(writeIter);
// Ensure the string ends in a newline // Ensure the string ends in a newline
PRUnichar newline ('\n'); PRUnichar newline ('\n');
if (aOutputString.CharAt(offset-1) != newline) findIter.advance(-1);
aOutputString.SetCharAt(newline, offset++); if (offset ==0 || (offset >0 && (*findIter) != newline)) //check for 0
{
aOutputString.Truncate(offset); writeIter.advance(offset);
*writeIter = newline;
aOutputString.Truncate(offset+1);
}
} }
} }
return res; return res;
@ -3332,7 +3362,7 @@ nsHTMLEditor::DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed)
#endif #endif
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply) nsHTMLEditor::SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply)
{ {
NS_ASSERTION(aTextRangeList, "null ptr"); NS_ASSERTION(aTextRangeList, "null ptr");
if(nsnull == aTextRangeList) if(nsnull == aTextRangeList)
@ -3355,7 +3385,7 @@ nsHTMLEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivat
mIMETextRangeList = aTextRangeList; mIMETextRangeList = aTextRangeList;
nsAutoPlaceHolderBatch batch(this, gIMETxnName); nsAutoPlaceHolderBatch batch(this, gIMETxnName);
result = InsertText(aCompositionString.GetUnicode()); result = InsertText(aCompositionString);
mIMEBufferLength = aCompositionString.Length(); mIMEBufferLength = aCompositionString.Length();
@ -3492,28 +3522,29 @@ nsHTMLEditor::EndOperation()
} }
PRBool PRBool
nsHTMLEditor::TagCanContainTag(const nsString &aParentTag, const nsString &aChildTag) nsHTMLEditor::TagCanContainTag(const nsAReadableString& aParentTag, const nsAReadableString& aChildTag)
{ {
// COtherDTD gives some unwanted results. We override them here. // COtherDTD gives some unwanted results. We override them here.
nsAutoString olStr, ulStr, liStr; nsAutoString olStr, ulStr, liStr;
olStr = NS_LITERAL_STRING("ol"); olStr = NS_LITERAL_STRING("ol");
ulStr = NS_LITERAL_STRING("ul"); ulStr = NS_LITERAL_STRING("ul");
liStr = NS_LITERAL_STRING("li"); liStr = NS_LITERAL_STRING("li");
nsString tParent(aParentTag);//MJUDGE SCC NEED HELP
if ( aParentTag.EqualsIgnoreCase(olStr) || nsString tChild(aChildTag);//MJUDGE SCC NEED HELP
aParentTag.EqualsIgnoreCase(ulStr) ) if ( tParent.EqualsIgnoreCase(olStr) ||
tParent.EqualsIgnoreCase(ulStr) )
{ {
// if parent is a list and tag is also a list, say "yes". // if parent is a list and tag is also a list, say "yes".
// This is because the editor does sublists illegally for now. // This is because the editor does sublists illegally for now.
if (aChildTag.EqualsIgnoreCase(olStr) || if (tChild.EqualsIgnoreCase(olStr) ||
aChildTag.EqualsIgnoreCase(ulStr) ) tChild.EqualsIgnoreCase(ulStr) )
return PR_TRUE; return PR_TRUE;
} }
if ( aParentTag.EqualsIgnoreCase(liStr) ) if ( tParent.EqualsIgnoreCase(liStr) )
{ {
// list items cant contain list items // list items cant contain list items
if (aChildTag.EqualsIgnoreCase(liStr) ) if (tChild.EqualsIgnoreCase(liStr) )
return PR_FALSE; return PR_FALSE;
} }
@ -3607,8 +3638,8 @@ NS_IMETHODIMP nsHTMLEditor::GetLayoutObject(nsIDOMNode *aNode, nsISupports **aLa
// so singleton attributes like <Table border> will not be matched! // so singleton attributes like <Table border> will not be matched!
void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode *aNode, void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode *aNode,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString *aAttribute,
const nsString *aValue, const nsAReadableString *aValue,
PRBool &aIsSet, PRBool &aIsSet,
nsIDOMNode **aStyleNode, nsIDOMNode **aStyleNode,
nsString *outValue) const nsString *outValue) const
@ -3639,11 +3670,15 @@ void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode *aNode,
if (!aValue) { if (!aValue) {
found = PR_TRUE; found = PR_TRUE;
} }
else if (aValue->EqualsIgnoreCase(value)) { else
found = PR_TRUE; {
} nsString tString(*aValue);
else { // we found the prop with the attribute, but the value doesn't match if (tString.EqualsIgnoreCase(value)) {
break; found = PR_TRUE;
}
else { // we found the prop with the attribute, but the value doesn't match
break;
}
} }
} }
} }
@ -3670,7 +3705,7 @@ void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode *aNode,
void nsHTMLEditor::IsTextStyleSet(nsIStyleContext *aSC, void nsHTMLEditor::IsTextStyleSet(nsIStyleContext *aSC,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString *aAttribute,
PRBool &aIsSet) const PRBool &aIsSet) const
{ {
aIsSet = PR_FALSE; aIsSet = PR_FALSE;
@ -3969,7 +4004,7 @@ nsHTMLEditor::CollapseAdjacentTextNodes(nsIDOMRange *aInRange)
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetNextElementByTagName(nsIDOMElement *aCurrentElement, nsHTMLEditor::GetNextElementByTagName(nsIDOMElement *aCurrentElement,
const nsString *aTagName, const nsAReadableString *aTagName,
nsIDOMElement **aReturn) nsIDOMElement **aReturn)
{ {
nsresult res = NS_OK; nsresult res = NS_OK;

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

@ -99,72 +99,75 @@ public:
/* ------------ nsIHTMLEditor methods -------------- */ /* ------------ nsIHTMLEditor methods -------------- */
NS_IMETHOD SetInlineProperty(nsIAtom *aProperty, NS_IMETHOD SetInlineProperty(nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString & aAttribute,
const nsString *aValue); const nsAReadableString & aValue);
NS_IMETHOD GetInlineProperty(nsIAtom *aProperty, NS_IMETHOD GetInlineProperty(nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString & aAttribute,
const nsString *aValue, const nsAReadableString & aValue,
PRBool &aFirst, PRBool &aAny, PRBool &aAll); PRBool *aFirst,
PRBool *aAny,
PRBool *aAll);
NS_IMETHOD GetInlinePropertyWithAttrValue(nsIAtom *aProperty, NS_IMETHOD GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString &aAttribute,
const nsString *aValue, const nsAReadableString &aValue,
PRBool &aFirst, PRBool &aAny, PRBool &aAll, PRBool *aFirst,
nsString *outValue); PRBool *aAny,
PRBool *aAll,
nsAWritableString &outValue);
NS_IMETHOD RemoveAllInlineProperties(); NS_IMETHOD RemoveAllInlineProperties();
NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute); NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsAReadableString & aAttribute);
NS_IMETHOD IncreaseFontSize(); NS_IMETHOD IncreaseFontSize();
NS_IMETHOD DecreaseFontSize(); NS_IMETHOD DecreaseFontSize();
NS_IMETHOD InsertHTML(const nsString &aInputString); NS_IMETHOD InsertHTML(const nsAReadableString &aInputString);
NS_IMETHOD InsertHTMLWithCharset(const nsString& aInputString, NS_IMETHOD InsertHTMLWithCharset(const nsAReadableString& aInputString,
const nsString& aCharset); const nsAReadableString& aCharset);
NS_IMETHOD RebuildDocumentFromSource(const nsString& aSourceString); NS_IMETHOD RebuildDocumentFromSource(const nsAReadableString& aSourceString);
NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection); NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection);
NS_IMETHOD SelectElement(nsIDOMElement* aElement); NS_IMETHOD SelectElement(nsIDOMElement* aElement);
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement); NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement);
NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat); NS_IMETHOD SetParagraphFormat(const nsAReadableString& aParagraphFormat);
NS_IMETHOD GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists); NS_IMETHOD GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists);
NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat); NS_IMETHOD GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat);
NS_IMETHOD GetFontFaceState(PRBool &aMixed, nsString &outFace); NS_IMETHOD GetFontFaceState(PRBool *aMixed, nsAWritableString &outFace);
NS_IMETHOD GetFontColorState(PRBool &aMixed, nsString &outColor); NS_IMETHOD GetFontColorState(PRBool *aMixed, nsAWritableString &outColor);
NS_IMETHOD GetBackgroundColorState(PRBool &aMixed, nsString &outColor); NS_IMETHOD GetBackgroundColorState(PRBool *aMixed, nsAWritableString &outColor);
NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL); NS_IMETHOD GetListState(PRBool *aMixed, PRBool *aOL, PRBool *aUL, PRBool *aDL);
NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD); NS_IMETHOD GetListItemState(PRBool *aMixed, PRBool *aLI, PRBool *aDT, PRBool *aDD);
NS_IMETHOD GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign); NS_IMETHOD GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign);
NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent); NS_IMETHOD GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent);
NS_IMETHOD MakeOrChangeList(const nsString& aListType, PRBool entireList); NS_IMETHOD MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList);
NS_IMETHOD RemoveList(const nsString& aListType); NS_IMETHOD RemoveList(const nsAReadableString& aListType);
NS_IMETHOD Indent(const nsString& aIndent); NS_IMETHOD Indent(const nsAReadableString& aIndent);
NS_IMETHOD Align(const nsString& aAlign); NS_IMETHOD Align(const nsAReadableString& aAlign);
NS_IMETHOD GetElementOrParentByTagName(const nsAReadableString& aTagName, nsIDOMNode *aNode, nsIDOMElement** aReturn); NS_IMETHOD GetElementOrParentByTagName(const nsAReadableString& aTagName, nsIDOMNode *aNode, nsIDOMElement** aReturn);
NS_IMETHOD GetSelectedElement(const nsString& aTagName, nsIDOMElement** aReturn); NS_IMETHOD GetSelectedElement(const nsAReadableString& aTagName, nsIDOMElement** aReturn);
NS_IMETHOD CreateElementWithDefaults(const nsAReadableString& aTagName, nsIDOMElement** aReturn); NS_IMETHOD CreateElementWithDefaults(const nsAReadableString& aTagName, nsIDOMElement** aReturn);
NS_IMETHOD GetNextElementByTagName(nsIDOMElement *aCurrentElement, const nsString *aTagName, nsIDOMElement **aReturn); NS_IMETHOD GetNextElementByTagName(nsIDOMElement *aCurrentElement, const nsAReadableString *aTagName, nsIDOMElement **aReturn);
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement); NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
/* ------------ nsIEditorIMESupport overrides -------------- */ /* ------------ nsIEditorIMESupport overrides -------------- */
NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply); NS_IMETHOD SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply);
NS_IMETHOD GetReconversionString(nsReconversionEventReply* aReply); NS_IMETHOD GetReconversionString(nsReconversionEventReply* aReply);
/* ------------ nsIEditorStyleSheets methods -------------- */ /* ------------ nsIEditorStyleSheets methods -------------- */
NS_IMETHOD ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet); NS_IMETHOD ApplyStyleSheet(const nsAReadableString & aURL, nsICSSStyleSheet **aStyleSheet);
NS_IMETHOD ApplyOverrideStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet); NS_IMETHOD ApplyOverrideStyleSheet(const nsAReadableString & aURL, nsICSSStyleSheet **aStyleSheet);
/* Above 2 methods call this with appropriate aOverride value /* Above 2 methods call this with appropriate aOverride value
* Not exposed to IDL interface * Not exposed to IDL interface
*/ */
nsresult ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet); nsresult ApplyDocumentOrOverrideStyleSheet(const nsAReadableString & aURL, PRBool aOverride, nsICSSStyleSheet **aStyleSheet);
NS_IMETHOD AddStyleSheet(nsICSSStyleSheet* aSheet); NS_IMETHOD AddStyleSheet(nsICSSStyleSheet* aSheet);
NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet); NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet);
NS_IMETHOD RemoveOverrideStyleSheet(nsICSSStyleSheet* aSheet); NS_IMETHOD RemoveOverrideStyleSheet(nsICSSStyleSheet* aSheet);
@ -172,13 +175,13 @@ public:
/* ------------ nsIEditorMailSupport methods -------------- */ /* ------------ nsIEditorMailSupport methods -------------- */
NS_IMETHOD PasteAsQuotation(PRInt32 aSelectionType); NS_IMETHOD PasteAsQuotation(PRInt32 aSelectionType);
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, nsIDOMNode **aNodeInserted); NS_IMETHOD InsertAsQuotation(const nsAReadableString & aQuotedText, nsIDOMNode **aNodeInserted);
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation, NS_IMETHOD PasteAsCitedQuotation(const nsAReadableString & aCitation,
PRInt32 aSelectionType); PRInt32 aSelectionType);
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, NS_IMETHOD InsertAsCitedQuotation(const nsAReadableString & aQuotedText,
const nsString& aCitation, const nsAReadableString & aCitation,
PRBool aInsertHTML, PRBool aInsertHTML,
const nsString& aCharset, const nsAReadableString & aCharset,
nsIDOMNode **aNodeInserted); nsIDOMNode **aNodeInserted);
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList); NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList);
@ -240,10 +243,11 @@ public:
/* miscellaneous */ /* miscellaneous */
// This sets background on the appropriate container element (table, cell,) // This sets background on the appropriate container element (table, cell,)
// or calls into nsTextEditor to set the page background // or calls into nsTextEditor to set the page background
NS_IMETHOD SetBackgroundColor(const nsString& aColor); NS_IMETHOD SetBackgroundColor(const nsAReadableString& aColor);
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue); NS_IMETHOD SetBodyAttribute(const nsAReadableString& aAttr, const nsAReadableString& aValue);
// aTitle may be null or empty string to remove child contents of <title> // aTitle may be null or empty string to remove child contents of <title>
NS_IMETHOD SetDocumentTitle(const PRUnichar *aTitle);
NS_IMETHOD SetDocumentTitle(const nsAReadableString &aTitle);
/* ------------ Block methods moved from nsEditor -------------- */ /* ------------ Block methods moved from nsEditor -------------- */
static nsCOMPtr<nsIDOMNode> GetBlockNodeParent(nsIDOMNode *aNode); static nsCOMPtr<nsIDOMNode> GetBlockNodeParent(nsIDOMNode *aNode);
@ -301,10 +305,10 @@ public:
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, nsIContent *aRoot, nsISelectionController *aSelCon, PRUint32 aFlags); NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, nsIContent *aRoot, nsISelectionController *aSelCon, PRUint32 aFlags);
/** Internal, static version */ /** Internal, static version */
static nsresult NodeIsBlockStatic(nsIDOMNode *aNode, PRBool &aIsBlock); static nsresult NodeIsBlockStatic(nsIDOMNode *aNode, PRBool *aIsBlock);
/** This version is for exposure to JavaScript */ /** This version is for exposure to JavaScript */
NS_IMETHOD NodeIsBlock(nsIDOMNode *aNode, PRBool &aIsBlock); NS_IMETHOD NodeIsBlock(nsIDOMNode *aNode, PRBool *aIsBlock);
/** we override this here to install event listeners */ /** we override this here to install event listeners */
NS_IMETHOD PostCreate(); NS_IMETHOD PostCreate();
@ -313,14 +317,14 @@ public:
NS_IMETHOD SetFlags(PRUint32 aFlags); NS_IMETHOD SetFlags(PRUint32 aFlags);
NS_IMETHOD Paste(PRInt32 aSelectionType); NS_IMETHOD Paste(PRInt32 aSelectionType);
NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste); NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste);
NS_IMETHOD CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag); NS_IMETHOD CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag);
NS_IMETHOD DoDrag(nsIDOMEvent *aDragEvent); NS_IMETHOD DoDrag(nsIDOMEvent *aDragEvent);
NS_IMETHOD InsertFromDrop(nsIDOMEvent* aDropEvent); NS_IMETHOD InsertFromDrop(nsIDOMEvent* aDropEvent);
NS_IMETHOD GetHeadContentsAsHTML(nsString& aOutputString); NS_IMETHOD GetHeadContentsAsHTML(nsAWritableString& aOutputString);
NS_IMETHOD ReplaceHeadContentsWithHTML(const nsString &aSourceToInsert); NS_IMETHOD ReplaceHeadContentsWithHTML(const nsAReadableString &aSourceToInsert);
NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed); NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
@ -333,7 +337,7 @@ public:
NS_IMETHOD EndOperation(); NS_IMETHOD EndOperation();
/** returns PR_TRUE if aParentTag can contain a child of type aChildTag */ /** returns PR_TRUE if aParentTag can contain a child of type aChildTag */
virtual PRBool TagCanContainTag(const nsString &aParentTag, const nsString &aChildTag); virtual PRBool TagCanContainTag(const nsAReadableString& aParentTag, const nsAReadableString& aChildTag);
/** make the given selection span the entire document */ /** make the given selection span the entire document */
NS_IMETHOD SelectEntireDocument(nsISelection *aSelection); NS_IMETHOD SelectEntireDocument(nsISelection *aSelection);
@ -345,7 +349,7 @@ public:
NS_IMETHOD StyleSheetLoaded(nsICSSStyleSheet*aSheet, PRBool aNotify); NS_IMETHOD StyleSheetLoaded(nsICSSStyleSheet*aSheet, PRBool aNotify);
/* ------------ Utility Routines, not part of public API -------------- */ /* ------------ Utility Routines, not part of public API -------------- */
NS_IMETHOD TypedText(const PRUnichar* aString, PRInt32 aAction); NS_IMETHOD TypedText(const nsAReadableString& aString, PRInt32 aAction);
nsresult InsertNodeAtPoint(nsIDOMNode *aNode, nsresult InsertNodeAtPoint(nsIDOMNode *aNode,
nsIDOMNode *aParent, nsIDOMNode *aParent,
PRInt32 aOffset, PRInt32 aOffset,
@ -512,8 +516,8 @@ protected:
*/ */
virtual void IsTextPropertySetByContent(nsIDOMNode *aNode, virtual void IsTextPropertySetByContent(nsIDOMNode *aNode,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString *aAttribute,
const nsString *aValue, const nsAReadableString *aValue,
PRBool &aIsSet, PRBool &aIsSet,
nsIDOMNode **aStyleNode, nsIDOMNode **aStyleNode,
nsString *outValue = nsnull) const; nsString *outValue = nsnull) const;
@ -523,7 +527,7 @@ protected:
*/ */
virtual void IsTextStyleSet(nsIStyleContext *aSC, virtual void IsTextStyleSet(nsIStyleContext *aSC,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttributes, const nsAReadableString *aAttributes,
PRBool &aIsSet) const; PRBool &aIsSet) const;
@ -534,26 +538,26 @@ protected:
// Methods for handling plaintext quotations // Methods for handling plaintext quotations
NS_IMETHOD PasteAsPlaintextQuotation(PRInt32 aSelectionType); NS_IMETHOD PasteAsPlaintextQuotation(PRInt32 aSelectionType);
NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText, NS_IMETHOD InsertAsPlaintextQuotation(const nsAReadableString & aQuotedText,
nsIDOMNode **aNodeInserted); nsIDOMNode **aNodeInserted);
// factored methods for handling insertion of data from transferables (drag&drop or clipboard) // factored methods for handling insertion of data from transferables (drag&drop or clipboard)
NS_IMETHOD PrepareTransferable(nsITransferable **transferable); NS_IMETHOD PrepareTransferable(nsITransferable **transferable);
NS_IMETHOD InsertFromTransferable(nsITransferable *transferable, NS_IMETHOD InsertFromTransferable(nsITransferable *transferable,
const nsString& aContextStr, const nsAReadableString & aContextStr,
const nsString& aInfoStr); const nsAReadableString & aInfoStr);
nsresult InsertHTMLWithContext(const nsString& aInputString, nsresult InsertHTMLWithContext(const nsAReadableString & aInputString,
const nsString& aContextStr, const nsAReadableString & aContextStr,
const nsString& aInfoStr); const nsAReadableString & aInfoStr);
nsresult InsertHTMLWithCharsetAndContext(const nsString& aInputString, nsresult InsertHTMLWithCharsetAndContext(const nsAReadableString & aInputString,
const nsString& aCharset, const nsAReadableString & aCharset,
const nsString& aContextStr, const nsAReadableString & aContextStr,
const nsString& aInfoStr); const nsAReadableString & aInfoStr);
nsresult StripFormattingNodes(nsIDOMNode *aNode); nsresult StripFormattingNodes(nsIDOMNode *aNode);
nsresult CreateDOMFragmentFromPaste(nsIDOMNSRange *aNSRange, nsresult CreateDOMFragmentFromPaste(nsIDOMNSRange *aNSRange,
const nsString& aInputString, const nsAReadableString & aInputString,
const nsString& aContextStr, const nsAReadableString & aContextStr,
const nsString& aInfoStr, const nsAReadableString & aInfoStr,
nsCOMPtr<nsIDOMNode> *outFragNode, nsCOMPtr<nsIDOMNode> *outFragNode,
PRInt32 *outRangeStartHint, PRInt32 *outRangeStartHint,
PRInt32 *outRangeEndHint); PRInt32 *outRangeEndHint);
@ -569,8 +573,8 @@ protected:
PRBool IsModifiable(); PRBool IsModifiable();
/* helpers for block transformations */ /* helpers for block transformations */
nsresult MakeDefinitionItem(const nsString& aItemType); nsresult MakeDefinitionItem(const nsAReadableString & aItemType);
nsresult InsertBasicBlock(const nsString& aBlockType); nsresult InsertBasicBlock(const nsAReadableString & aBlockType);
/* increase/decrease the font size of selection */ /* increase/decrease the font size of selection */
nsresult RelativeFontChange( PRInt32 aSizeChange); nsresult RelativeFontChange( PRInt32 aSizeChange);
@ -588,35 +592,35 @@ protected:
PRInt32 aStartOffset, PRInt32 aStartOffset,
PRInt32 aEndOffset, PRInt32 aEndOffset,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString *aAttribute,
const nsString *aValue); const nsAReadableString *aValue);
nsresult SetInlinePropertyOnNode( nsIDOMNode *aNode, nsresult SetInlinePropertyOnNode( nsIDOMNode *aNode,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString *aAttribute,
const nsString *aValue); const nsAReadableString *aValue);
nsresult PromoteInlineRange(nsIDOMRange *inRange); nsresult PromoteInlineRange(nsIDOMRange *inRange);
nsresult SplitStyleAboveRange(nsIDOMRange *aRange, nsresult SplitStyleAboveRange(nsIDOMRange *aRange,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute); const nsAReadableString *aAttribute);
nsresult SplitStyleAbovePoint(nsCOMPtr<nsIDOMNode> *aNode, nsresult SplitStyleAbovePoint(nsCOMPtr<nsIDOMNode> *aNode,
PRInt32 *aOffset, PRInt32 *aOffset,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString *aAttribute,
nsCOMPtr<nsIDOMNode> *outLeftNode = nsnull, nsCOMPtr<nsIDOMNode> *outLeftNode = nsnull,
nsCOMPtr<nsIDOMNode> *outRightNode = nsnull); nsCOMPtr<nsIDOMNode> *outRightNode = nsnull);
nsresult RemoveStyleInside(nsIDOMNode *aNode, nsresult RemoveStyleInside(nsIDOMNode *aNode,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString *aAttribute,
PRBool aChildrenOnly = PR_FALSE); PRBool aChildrenOnly = PR_FALSE);
nsresult RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsString *aAttribute); nsresult RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAReadableString *aAttribute);
PRBool NodeIsProperty(nsIDOMNode *aNode); PRBool NodeIsProperty(nsIDOMNode *aNode);
PRBool HasAttr(nsIDOMNode *aNode, const nsString *aAttribute); PRBool HasAttr(nsIDOMNode *aNode, const nsAReadableString *aAttribute);
PRBool HasAttrVal(nsIDOMNode *aNode, const nsString *aAttribute, const nsString *aValue); PRBool HasAttrVal(nsIDOMNode *aNode, const nsAReadableString *aAttribute, const nsAReadableString *aValue);
PRBool IsAtFrontOfNode(nsIDOMNode *aNode, PRInt32 aOffset); PRBool IsAtFrontOfNode(nsIDOMNode *aNode, PRInt32 aOffset);
PRBool IsAtEndOfNode(nsIDOMNode *aNode, PRInt32 aOffset); PRBool IsAtEndOfNode(nsIDOMNode *aNode, PRInt32 aOffset);
PRBool IsOnlyAttribute(nsIDOMNode *aElement, const nsString *aAttribute); PRBool IsOnlyAttribute(nsIDOMNode *aElement, const nsAReadableString *aAttribute);
PRBool HasMatchingAttributes(nsIDOMNode *aNode1, PRBool HasMatchingAttributes(nsIDOMNode *aNode1,
nsIDOMNode *aNode2); nsIDOMNode *aNode2);
@ -642,6 +646,14 @@ protected:
PRBool mIgnoreSpuriousDragEvent; PRBool mIgnoreSpuriousDragEvent;
NS_IMETHOD IgnoreSpuriousDragEvent(PRBool aIgnoreSpuriousDragEvent) {mIgnoreSpuriousDragEvent = aIgnoreSpuriousDragEvent; return NS_OK;} NS_IMETHOD IgnoreSpuriousDragEvent(PRBool aIgnoreSpuriousDragEvent) {mIgnoreSpuriousDragEvent = aIgnoreSpuriousDragEvent; return NS_OK;}
nsresult GetInlinePropertyBase(nsIAtom *aProperty,
const nsAReadableString *aAttribute,
const nsAReadableString *aValue,
PRBool *aFirst,
PRBool *aAny,
PRBool *aAll,
nsAWritableString *outValue);
// Data members // Data members
protected: protected:

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

@ -54,7 +54,7 @@ nsHTMLEditorLog::~nsHTMLEditorLog()
NS_IMPL_ISUPPORTS_INHERITED(nsHTMLEditorLog, nsHTMLEditor, nsIEditorLogging); NS_IMPL_ISUPPORTS_INHERITED(nsHTMLEditorLog, nsHTMLEditor, nsIEditorLogging);
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::SetInlineProperty(nsIAtom *aProperty, const nsString *aAttribute, const nsString *aValue) nsHTMLEditorLog::SetInlineProperty(nsIAtom *aProperty, const nsAReadableString &aAttribute, const nsAReadableString &aValue)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -68,11 +68,11 @@ nsHTMLEditorLog::SetInlineProperty(nsIAtom *aProperty, const nsString *aAttribut
Write("window.editorShell.SetTextProperty(\""); Write("window.editorShell.SetTextProperty(\"");
PrintUnicode(propStr); PrintUnicode(propStr);
Write("\", \""); Write("\", \"");
if (aAttribute) if (aAttribute.Length())
PrintUnicode(*aAttribute); PrintUnicode(aAttribute);
Write("\", \""); Write("\", \"");
if (aValue) if (aValue.Length())
PrintUnicode(*aValue); PrintUnicode(aValue);
Write("\");\n"); Write("\");\n");
Flush(); Flush();
@ -100,7 +100,7 @@ nsHTMLEditorLog::SetParagraphFormat(const nsString& aParagraphFormat)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute) nsHTMLEditorLog::RemoveInlineProperty(nsIAtom *aProperty, const nsAReadableString &aAttribute)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -114,8 +114,8 @@ nsHTMLEditorLog::RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttri
Write("window.editorShell.RemoveTextProperty(\""); Write("window.editorShell.RemoveTextProperty(\"");
PrintUnicode(propStr); PrintUnicode(propStr);
Write("\", \""); Write("\", \"");
if (aAttribute) if (aAttribute.Length())
PrintUnicode(*aAttribute); PrintUnicode(aAttribute);
Write("\");\n"); Write("\");\n");
Flush(); Flush();
@ -143,7 +143,7 @@ nsHTMLEditorLog::DeleteSelection(nsIEditor::EDirection aAction)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::InsertText(const PRUnichar* aStringToInsert) nsHTMLEditorLog::InsertText(const nsAReadableString& aStringToInsert)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -351,7 +351,7 @@ nsHTMLEditorLog::PasteAsPlaintextQuotation(PRInt32 aSelectionType)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::PasteAsCitedQuotation(const nsString& aCitation, nsHTMLEditorLog::PasteAsCitedQuotation(const nsAReadableString& aCitation,
PRInt32 aSelectionType) PRInt32 aSelectionType)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -369,7 +369,7 @@ nsHTMLEditorLog::PasteAsCitedQuotation(const nsString& aCitation,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::InsertAsQuotation(const nsString& aQuotedText, nsHTMLEditorLog::InsertAsQuotation(const nsAReadableString& aQuotedText,
nsIDOMNode **aNodeInserted) nsIDOMNode **aNodeInserted)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -387,7 +387,7 @@ nsHTMLEditorLog::InsertAsQuotation(const nsString& aQuotedText,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsString& aQuotedText, nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsAReadableString& aQuotedText,
nsIDOMNode **aNodeInserted) nsIDOMNode **aNodeInserted)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -405,10 +405,10 @@ nsHTMLEditorLog::InsertAsPlaintextQuotation(const nsString& aQuotedText,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::InsertAsCitedQuotation(const nsString& aQuotedText, nsHTMLEditorLog::InsertAsCitedQuotation(const nsAReadableString& aQuotedText,
const nsString& aCitation, const nsAReadableString& aCitation,
PRBool aInsertHTML, PRBool aInsertHTML,
const nsString& aCharset, const nsAReadableString& aCharset,
nsIDOMNode **aNodeInserted) nsIDOMNode **aNodeInserted)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -429,7 +429,7 @@ nsHTMLEditorLog::InsertAsCitedQuotation(const nsString& aQuotedText,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::SetBackgroundColor(const nsString& aColor) nsHTMLEditorLog::SetBackgroundColor(const nsAReadableString& aColor)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -445,7 +445,7 @@ nsHTMLEditorLog::SetBackgroundColor(const nsString& aColor)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::SetBodyAttribute(const nsString& aAttr, const nsString& aValue) nsHTMLEditorLog::SetBodyAttribute(const nsAReadableString& aAttr, const nsAReadableString& aValue)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -644,7 +644,7 @@ nsHTMLEditorLog::SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMEle
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::MakeOrChangeList(const nsString& aListType, PRBool entireList) nsHTMLEditorLog::MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -662,7 +662,7 @@ nsHTMLEditorLog::MakeOrChangeList(const nsString& aListType, PRBool entireList)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::Indent(const nsString& aIndent) nsHTMLEditorLog::Indent(const nsAReadableString& aIndent)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -680,7 +680,7 @@ nsHTMLEditorLog::Indent(const nsString& aIndent)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::Align(const nsString& aAlign) nsHTMLEditorLog::Align(const nsAReadableString& aAlign)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -748,7 +748,7 @@ nsHTMLEditorLog::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet) nsHTMLEditorLog::ApplyStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -769,7 +769,7 @@ nsHTMLEditorLog::ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyle
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::SetDocumentTitle(const PRUnichar* aTitle) nsHTMLEditorLog::SetDocumentTitle(const nsAReadableString& aTitle)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -912,23 +912,25 @@ nsHTMLEditorLog::Flush()
} }
nsresult nsresult
nsHTMLEditorLog::PrintUnicode(const nsString &aString) nsHTMLEditorLog::PrintUnicode(const nsAReadableString &aString)
{ {
const PRUnichar *uc = aString.GetUnicode(); //const PRUnichar *uc = aString.GetUnicode();
PRInt32 i, len = aString.Length();
char buf[10]; char buf[10];
nsReadingIterator <PRUnichar> beginIter,endIter;
for (i = 0; i < len; i++) aString.BeginReading(beginIter);
aString.EndReading(endIter);
while(beginIter != endIter)
{ {
if (nsCRT::IsAsciiAlpha(uc[i]) || nsCRT::IsAsciiDigit(uc[i]) || uc[i] == ' ') if (nsCRT::IsAsciiAlpha(*beginIter) || nsCRT::IsAsciiDigit(*beginIter) || *beginIter == ' ')
sprintf(buf, "%c", uc[i]); sprintf(buf, "%c", *beginIter);
else else
sprintf(buf, "\\u%.4x", uc[i]); sprintf(buf, "\\u%.4x", *beginIter);
nsresult result = Write(buf); nsresult result = Write(buf);
if (NS_FAILED(result)) if (NS_FAILED(result))
return result; return result;
++beginIter;
} }
return NS_OK; return NS_OK;

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

@ -54,12 +54,12 @@ public:
/* nsIHTMLEditor method implementations. */ /* nsIHTMLEditor method implementations. */
NS_IMETHOD SetInlineProperty(nsIAtom *aProperty, NS_IMETHOD SetInlineProperty(nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString & aAttribute,
const nsString *aValue); const nsAReadableString & aValue);
NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat); NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat);
NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute); NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsAReadableString& aAttribute);
NS_IMETHOD DeleteSelection(nsIEditor::EDirection aAction); NS_IMETHOD DeleteSelection(nsIEditor::EDirection aAction);
NS_IMETHOD InsertText(const PRUnichar* aStringToInsert); NS_IMETHOD InsertText(const nsAReadableString& aStringToInsert);
NS_IMETHOD InsertLineBreak(); NS_IMETHOD InsertLineBreak();
NS_IMETHOD Undo(PRUint32 aCount); NS_IMETHOD Undo(PRUint32 aCount);
NS_IMETHOD Redo(PRUint32 aCount); NS_IMETHOD Redo(PRUint32 aCount);
@ -74,20 +74,22 @@ public:
NS_IMETHOD Paste(PRInt32 aSelectionType); NS_IMETHOD Paste(PRInt32 aSelectionType);
NS_IMETHOD PasteAsQuotation(PRInt32 aSelectionType); NS_IMETHOD PasteAsQuotation(PRInt32 aSelectionType);
NS_IMETHOD PasteAsPlaintextQuotation(PRInt32 aSelectionType); NS_IMETHOD PasteAsPlaintextQuotation(PRInt32 aSelectionType);
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation, NS_IMETHOD PasteAsCitedQuotation(const nsAReadableString& aCitation,
PRInt32 aSelectionType); PRInt32 aSelectionType);
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, nsIDOMNode** aNodeInserted); NS_IMETHOD InsertAsQuotation(const nsAReadableString& aQuotedText, nsIDOMNode** aNodeInserted);
NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText, nsIDOMNode** aNodeInserted); NS_IMETHOD InsertAsPlaintextQuotation(const nsAReadableString& aQuotedText, nsIDOMNode** aNodeInserted);
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation, PRBool aInsertHTML, const nsString& aCharset, nsIDOMNode** aNodeInserted); NS_IMETHOD InsertAsCitedQuotation(const nsAReadableString& aQuotedText, const nsAReadableString& aCitation,
PRBool aInsertHTML, const nsAReadableString& aCharset,
nsIDOMNode** aNodeInserted);
NS_IMETHOD ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet); NS_IMETHOD ApplyStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet);
NS_IMETHOD SetDocumentTitle(const PRUnichar* aTitle); NS_IMETHOD SetDocumentTitle(const nsAReadableString& aTitle);
NS_IMETHOD SetBackgroundColor(const nsString& aColor); NS_IMETHOD SetBackgroundColor(const nsAReadableString& aColor);
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue); NS_IMETHOD SetBodyAttribute(const nsAReadableString& aAttr, const nsAReadableString& aValue);
NS_IMETHOD MakeOrChangeList(const nsString& aListType, PRBool entireList); NS_IMETHOD MakeOrChangeList(const nsAReadableString& aListType, PRBool entireList);
NS_IMETHOD Indent(const nsString& aIndent); NS_IMETHOD Indent(const nsAReadableString& aIndent);
NS_IMETHOD Align(const nsString& aAlign); NS_IMETHOD Align(const nsAReadableString& aAlign);
NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection); NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection);
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement); NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
@ -112,7 +114,7 @@ public:
nsresult Write(const char *aBuffer); nsresult Write(const char *aBuffer);
nsresult WriteInt(const char *aFormat, PRInt32 aInt); nsresult WriteInt(const char *aFormat, PRInt32 aInt);
nsresult Flush(); nsresult Flush();
nsresult PrintUnicode(const nsString &aString); nsresult PrintUnicode(const nsAReadableString &aString);
nsresult PrintSelection(); nsresult PrintSelection();
nsresult PrintNode(nsIDOMNode *aNode, PRInt32 aDepth=0); nsresult PrintNode(nsIDOMNode *aNode, PRInt32 aDepth=0);
nsresult PrintElementNode(nsIDOMNode *aNode, PRInt32 aDepth); nsresult PrintElementNode(nsIDOMNode *aNode, PRInt32 aDepth);

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

@ -101,8 +101,8 @@ static const PRBool gNoisy = PR_FALSE;
NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty, NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString & aAttribute,
const nsString *aValue) const nsAReadableString & aValue)
{ {
if (!aProperty) { return NS_ERROR_NULL_POINTER; } if (!aProperty) { return NS_ERROR_NULL_POINTER; }
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@ -120,7 +120,9 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
if (isCollapsed) if (isCollapsed)
{ {
// manipulating text attributes on a collapsed selection only sets state for the next text insertion // manipulating text attributes on a collapsed selection only sets state for the next text insertion
return mTypeInState->SetProp(aProperty, *aAttribute, *aValue); nsString tAttr(aAttribute);//MJUDGE SCC NEED HELP
nsString tVal(aValue);//MJUDGE SCC NEED HELP
return mTypeInState->SetProp(aProperty, tAttr, tVal);
} }
nsAutoEditBatch batchIt(this); nsAutoEditBatch batchIt(this);
@ -167,7 +169,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
range->GetStartOffset(&startOffset); range->GetStartOffset(&startOffset);
range->GetEndOffset(&endOffset); range->GetEndOffset(&endOffset);
nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(startNode); nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(startNode);
res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, endOffset, aProperty, aAttribute, aValue); res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, endOffset, aProperty, &aAttribute, &aValue);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
} }
else else
@ -232,7 +234,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
PRUint32 textLen; PRUint32 textLen;
range->GetStartOffset(&startOffset); range->GetStartOffset(&startOffset);
nodeAsText->GetLength(&textLen); nodeAsText->GetLength(&textLen);
res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, textLen, aProperty, aAttribute, aValue); res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, textLen, aProperty, &aAttribute, &aValue);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
} }
@ -244,7 +246,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
{ {
isupports = dont_AddRef(arrayOfNodes->ElementAt(0)); isupports = dont_AddRef(arrayOfNodes->ElementAt(0));
node = do_QueryInterface(isupports); node = do_QueryInterface(isupports);
res = SetInlinePropertyOnNode(node, aProperty, aAttribute, aValue); res = SetInlinePropertyOnNode(node, aProperty, &aAttribute, &aValue);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
arrayOfNodes->RemoveElementAt(0); arrayOfNodes->RemoveElementAt(0);
} }
@ -257,7 +259,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(endNode); nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(endNode);
PRInt32 endOffset; PRInt32 endOffset;
range->GetEndOffset(&endOffset); range->GetEndOffset(&endOffset);
res = SetInlinePropertyOnTextNode(nodeAsText, 0, endOffset, aProperty, aAttribute, aValue); res = SetInlinePropertyOnTextNode(nodeAsText, 0, endOffset, aProperty, &aAttribute, &aValue);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
} }
} }
@ -279,8 +281,8 @@ nsHTMLEditor::SetInlinePropertyOnTextNode( nsIDOMCharacterData *aTextNode,
PRInt32 aStartOffset, PRInt32 aStartOffset,
PRInt32 aEndOffset, PRInt32 aEndOffset,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString *aAttribute,
const nsString *aValue) const nsAReadableString *aValue)
{ {
if (!aTextNode) return NS_ERROR_NULL_POINTER; if (!aTextNode) return NS_ERROR_NULL_POINTER;
@ -323,8 +325,8 @@ nsHTMLEditor::SetInlinePropertyOnTextNode( nsIDOMCharacterData *aTextNode,
nsresult nsresult
nsHTMLEditor::SetInlinePropertyOnNode( nsIDOMNode *aNode, nsHTMLEditor::SetInlinePropertyOnNode( nsIDOMNode *aNode,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute, const nsAReadableString *aAttribute,
const nsString *aValue) const nsAReadableString *aValue)
{ {
if (!aNode || !aProperty) return NS_ERROR_NULL_POINTER; if (!aNode || !aProperty) return NS_ERROR_NULL_POINTER;
@ -430,7 +432,7 @@ nsHTMLEditor::SetInlinePropertyOnNode( nsIDOMNode *aNode,
nsresult nsHTMLEditor::SplitStyleAboveRange(nsIDOMRange *inRange, nsresult nsHTMLEditor::SplitStyleAboveRange(nsIDOMRange *inRange,
nsIAtom *aProperty, nsIAtom *aProperty,
const nsString *aAttribute) const nsAReadableString *aAttribute)
{ {
if (!inRange) return NS_ERROR_NULL_POINTER; if (!inRange) return NS_ERROR_NULL_POINTER;
nsresult res; nsresult res;
@ -474,7 +476,7 @@ nsresult nsHTMLEditor::SplitStyleAboveRange(nsIDOMRange *inRange,
nsresult nsHTMLEditor::SplitStyleAbovePoint(nsCOMPtr<nsIDOMNode> *aNode, nsresult nsHTMLEditor::SplitStyleAbovePoint(nsCOMPtr<nsIDOMNode> *aNode,
PRInt32 *aOffset, PRInt32 *aOffset,
nsIAtom *aProperty, // null here means we split all properties nsIAtom *aProperty, // null here means we split all properties
const nsString *aAttribute, const nsAReadableString *aAttribute,
nsCOMPtr<nsIDOMNode> *outLeftNode, nsCOMPtr<nsIDOMNode> *outLeftNode,
nsCOMPtr<nsIDOMNode> *outRightNode) nsCOMPtr<nsIDOMNode> *outRightNode)
{ {
@ -508,7 +510,7 @@ PRBool nsHTMLEditor::NodeIsProperty(nsIDOMNode *aNode)
if (!IsContainer(aNode)) return PR_FALSE; if (!IsContainer(aNode)) return PR_FALSE;
if (!IsEditable(aNode)) return PR_FALSE; if (!IsEditable(aNode)) return PR_FALSE;
PRBool isBlock (PR_FALSE); PRBool isBlock (PR_FALSE);
NodeIsBlock(aNode, isBlock); NodeIsBlock(aNode, &isBlock);
if (isBlock) return PR_FALSE; if (isBlock) return PR_FALSE;
if (NodeIsType(aNode, nsIEditProperty::a)) return PR_FALSE; if (NodeIsType(aNode, nsIEditProperty::a)) return PR_FALSE;
return PR_TRUE; return PR_TRUE;
@ -516,7 +518,7 @@ PRBool nsHTMLEditor::NodeIsProperty(nsIDOMNode *aNode)
nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode, nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode,
nsIAtom *aProperty, // null here means remove all properties nsIAtom *aProperty, // null here means remove all properties
const nsString *aAttribute, const nsAReadableString *aAttribute,
PRBool aChildrenOnly) PRBool aChildrenOnly)
{ {
if (!aNode) return NS_ERROR_NULL_POINTER; if (!aNode) return NS_ERROR_NULL_POINTER;
@ -571,7 +573,7 @@ nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode,
} }
PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode, PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
const nsString *aAttribute) const nsAReadableString *aAttribute)
{ {
if (!aNode || !aAttribute) return PR_FALSE; // ooops if (!aNode || !aAttribute) return PR_FALSE; // ooops
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode); nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
@ -581,6 +583,7 @@ PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
nsCOMPtr<nsIAtom> attrName, prefix; nsCOMPtr<nsIAtom> attrName, prefix;
content->GetAttributeCount(attrCount); content->GetAttributeCount(attrCount);
nsString tString(*aAttribute);//MJUDGE SCC NEED HELP
for (i=0; i<attrCount; i++) for (i=0; i<attrCount; i++)
{ {
content->GetAttributeNameAt(i, nameSpaceID, *getter_AddRefs(attrName), content->GetAttributeNameAt(i, nameSpaceID, *getter_AddRefs(attrName),
@ -589,7 +592,7 @@ PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
if (!attrName) continue; // ooops if (!attrName) continue; // ooops
attrName->ToString(attrString); attrName->ToString(attrString);
// if it's the attribute we know about, keep looking // if it's the attribute we know about, keep looking
if (attrString.EqualsIgnoreCase(*aAttribute)) continue; if (attrString.EqualsIgnoreCase(tString)) continue;
// if it's a special _moz... attribute, keep looking // if it's a special _moz... attribute, keep looking
attrString.Left(tmp,4); attrString.Left(tmp,4);
if (tmp.EqualsWithConversion("_moz")) continue; if (tmp.EqualsWithConversion("_moz")) continue;
@ -656,7 +659,7 @@ nsHTMLEditor::HasMatchingAttributes(nsIDOMNode *aNode1,
} }
PRBool nsHTMLEditor::HasAttr(nsIDOMNode *aNode, PRBool nsHTMLEditor::HasAttr(nsIDOMNode *aNode,
const nsString *aAttribute) const nsAReadableString *aAttribute)
{ {
if (!aNode) return PR_FALSE; if (!aNode) return PR_FALSE;
if (!aAttribute || aAttribute->IsEmpty()) return PR_TRUE; // everybody has the 'null' attribute if (!aAttribute || aAttribute->IsEmpty()) return PR_TRUE; // everybody has the 'null' attribute
@ -674,8 +677,8 @@ PRBool nsHTMLEditor::HasAttr(nsIDOMNode *aNode,
PRBool nsHTMLEditor::HasAttrVal(nsIDOMNode *aNode, PRBool nsHTMLEditor::HasAttrVal(nsIDOMNode *aNode,
const nsString *aAttribute, const nsAReadableString *aAttribute,
const nsString *aValue) const nsAReadableString *aValue)
{ {
if (!aNode) return PR_FALSE; if (!aNode) return PR_FALSE;
if (!aAttribute || aAttribute->IsEmpty()) return PR_TRUE; // everybody has the 'null' attribute if (!aAttribute || aAttribute->IsEmpty()) return PR_TRUE; // everybody has the 'null' attribute
@ -700,7 +703,8 @@ PRBool nsHTMLEditor::HasAttrVal(nsIDOMNode *aNode,
attNode->GetValue(attrVal); attNode->GetValue(attrVal);
// do values match? // do values match?
if (attrVal.EqualsIgnoreCase(*aValue)) return PR_TRUE; nsString tString(*aValue);//MJUDGE SCC NEED HELP
if (attrVal.EqualsIgnoreCase(tString)) return PR_TRUE;
return PR_FALSE; return PR_FALSE;
} }
@ -792,23 +796,15 @@ PRBool nsHTMLEditor::IsAtEndOfNode(nsIDOMNode *aNode, PRInt32 aOffset)
} }
} }
NS_IMETHODIMP nsHTMLEditor::GetInlineProperty(nsIAtom *aProperty,
const nsString *aAttribute,
const nsString *aValue,
PRBool &aFirst,
PRBool &aAny,
PRBool &aAll)
{
return GetInlinePropertyWithAttrValue( aProperty, aAttribute, aValue, aFirst, aAny, aAll, nsnull);
}
NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty, nsresult
const nsString *aAttribute, nsHTMLEditor::GetInlinePropertyBase(nsIAtom *aProperty,
const nsString *aValue, const nsAReadableString *aAttribute,
PRBool &aFirst, const nsAReadableString *aValue,
PRBool &aAny, PRBool *aFirst,
PRBool &aAll, PRBool *aAny,
nsString *outValue) PRBool *aAll,
nsAWritableString *outValue)
{ {
if (!aProperty) if (!aProperty)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
@ -823,9 +819,9 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
} }
*/ */
nsresult result; nsresult result;
aAny=PR_FALSE; *aAny=PR_FALSE;
aAll=PR_TRUE; *aAll=PR_TRUE;
aFirst=PR_FALSE; *aFirst=PR_FALSE;
PRBool first=PR_TRUE; PRBool first=PR_TRUE;
nsCOMPtr<nsISelection>selection; nsCOMPtr<nsISelection>selection;
result = GetSelection(getter_AddRefs(selection)); result = GetSelection(getter_AddRefs(selection));
@ -863,12 +859,21 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
// cache now current, use it! But override it with typeInState results if any... // cache now current, use it! But override it with typeInState results if any...
PRBool isSet, theSetting; PRBool isSet, theSetting;
if (aAttribute) if (aAttribute)
mTypeInState->GetTypingState(isSet, theSetting, aProperty, *aAttribute, outValue); {
nsString tString(*aAttribute); //MJUDGE SCC NEED HELP
nsString tOutString;//MJUDGE SCC NEED HELP
nsString *tPassString=nsnull;
if (outValue)
tPassString = &tOutString;
mTypeInState->GetTypingState(isSet, theSetting, aProperty, tString, &tOutString);
if (outValue)
outValue->Assign(tOutString);
}
else else
mTypeInState->GetTypingState(isSet, theSetting, aProperty); mTypeInState->GetTypingState(isSet, theSetting, aProperty);
if (isSet) if (isSet)
{ {
aFirst = aAny = aAll = theSetting; *aFirst = *aAny = *aAll = theSetting;
return NS_OK; return NS_OK;
} }
/* /*
@ -877,11 +882,11 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
mTypeInState->GetTypingState(isSet, theSetting, aProperty); mTypeInState->GetTypingState(isSet, theSetting, aProperty);
if (isSet) if (isSet)
{ {
aFirst = aAny = aAll = theSetting; *aFirst = *aAny = *aAll = theSetting;
} }
else else
{ {
aFirst = aAny = aAll = mCachedBoldStyle; *aFirst = *aAny = *aAll = mCachedBoldStyle;
} }
return NS_OK; return NS_OK;
} }
@ -890,11 +895,11 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
mTypeInState->GetTypingState(isSet, theSetting, aProperty); mTypeInState->GetTypingState(isSet, theSetting, aProperty);
if (isSet) if (isSet)
{ {
aFirst = aAny = aAll = theSetting; *aFirst = *aAny = *aAll = theSetting;
} }
else else
{ {
aFirst = aAny = aAll = mCachedItalicStyle; *aFirst = *aAny = *aAll = mCachedItalicStyle;
} }
return NS_OK; return NS_OK;
} }
@ -903,11 +908,11 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
mTypeInState->GetTypingState(isSet, theSetting, aProperty); mTypeInState->GetTypingState(isSet, theSetting, aProperty);
if (isSet) if (isSet)
{ {
aFirst = aAny = aAll = theSetting; *aFirst = *aAny = *aAll = theSetting;
} }
else else
{ {
aFirst = aAny = aAll = mCachedUnderlineStyle; *aFirst = *aAny = *aAll = mCachedUnderlineStyle;
} }
return NS_OK; return NS_OK;
} */ } */
@ -975,7 +980,7 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
if (first) if (first)
{ {
IsTextPropertySetByContent(node, aProperty, aAttribute, aValue, isSet, getter_AddRefs(resultNode), &firstValue); IsTextPropertySetByContent(node, aProperty, aAttribute, aValue, isSet, getter_AddRefs(resultNode), &firstValue);
aFirst = isSet; *aFirst = isSet;
first = PR_FALSE; first = PR_FALSE;
if (outValue) *outValue = firstValue; if (outValue) *outValue = firstValue;
} }
@ -983,14 +988,14 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
{ {
IsTextPropertySetByContent(node, aProperty, aAttribute, aValue, isSet, getter_AddRefs(resultNode), &theValue); IsTextPropertySetByContent(node, aProperty, aAttribute, aValue, isSet, getter_AddRefs(resultNode), &theValue);
if (firstValue != theValue) if (firstValue != theValue)
aAll = PR_FALSE; *aAll = PR_FALSE;
} }
if (isSet) { if (isSet) {
aAny = PR_TRUE; *aAny = PR_TRUE;
} }
else { else {
aAll = PR_FALSE; *aAll = PR_FALSE;
} }
} }
} }
@ -1000,26 +1005,65 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
iter->CurrentNode(getter_AddRefs(content)); iter->CurrentNode(getter_AddRefs(content));
} }
} }
if (!aAny) if (!*aAny)
{ // make sure that if none of the selection is set, we don't report all is set { // make sure that if none of the selection is set, we don't report all is set
aAll = PR_FALSE; *aAll = PR_FALSE;
} }
//if (gNoisy) { printf(" returning first=%d any=%d all=%d\n", aFirst, aAny, aAll); } //if (gNoisy) { printf(" returning first=%d any=%d all=%d\n", *aFirst, *aAny, *aAll); }
return result; return result;
} }
NS_IMETHODIMP nsHTMLEditor::GetInlineProperty(nsIAtom *aProperty,
const nsAReadableString &aAttribute,
const nsAReadableString &aValue,
PRBool *aFirst,
PRBool *aAny,
PRBool *aAll)
{
if (!aProperty || !aFirst || !aAny || !aAll)
return NS_ERROR_NULL_POINTER;
const nsAReadableString *att = nsnull;
if (aAttribute.Length())
att = &aAttribute;
const nsAReadableString *val = nsnull;
if (aValue.Length())
val = &aValue;
return GetInlinePropertyBase( aProperty, att, val, aFirst, aAny, aAll, nsnull);
}
NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
const nsAReadableString &aAttribute,
const nsAReadableString &aValue,
PRBool *aFirst,
PRBool *aAny,
PRBool *aAll,
nsAWritableString &outValue)
{
if (!aProperty || !aFirst || !aAny || !aAll)
return NS_ERROR_NULL_POINTER;
const nsAReadableString *att = nsnull;
if (aAttribute.Length())
att = &aAttribute;
const nsAReadableString *val = nsnull;
if (aValue.Length())
val = &aValue;
return GetInlinePropertyBase( aProperty, att, val, aFirst, aAny, aAll, &outValue);
}
NS_IMETHODIMP nsHTMLEditor::RemoveAllInlineProperties() NS_IMETHODIMP nsHTMLEditor::RemoveAllInlineProperties()
{ {
return RemoveInlinePropertyImpl(nsnull, nsnull); return RemoveInlinePropertyImpl(nsnull, nsnull);
} }
NS_IMETHODIMP nsHTMLEditor::RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute) NS_IMETHODIMP nsHTMLEditor::RemoveInlineProperty(nsIAtom *aProperty, const nsAReadableString &aAttribute)
{ {
return RemoveInlinePropertyImpl(aProperty, aAttribute); return RemoveInlinePropertyImpl(aProperty, &aAttribute);
} }
nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsString *aAttribute) nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAReadableString *aAttribute)
{ {
if (!mRules) return NS_ERROR_NOT_INITIALIZED; if (!mRules) return NS_ERROR_NOT_INITIALIZED;
ForceCompositionEnd(); ForceCompositionEnd();
@ -1041,7 +1085,7 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsStri
if (aProperty == nsIEditProperty::href) if (aProperty == nsIEditProperty::href)
aProperty = nsIEditProperty::a; aProperty = nsIEditProperty::a;
if (aProperty) return mTypeInState->ClearProp(aProperty, *aAttribute); if (aProperty) return mTypeInState->ClearProp(aProperty, nsAutoString(*aAttribute));
else return mTypeInState->ClearAllProps(); else return mTypeInState->ClearAllProps();
} }
nsAutoEditBatch batchIt(this); nsAutoEditBatch batchIt(this);
@ -1428,66 +1472,73 @@ nsHTMLEditor::RelativeFontChangeOnNode( PRInt32 aSizeChange,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetFontFaceState(PRBool &aMixed, nsString &outFace) nsHTMLEditor::GetFontFaceState(PRBool *aMixed, nsAWritableString &outFace)
{ {
aMixed = PR_TRUE; if (!aMixed)
outFace.AssignWithConversion(""); return NS_ERROR_FAILURE;
*aMixed = PR_TRUE;
//outFace.AssignWithConversion("");
outFace.SetLength(0);
nsresult res; nsresult res;
nsAutoString faceStr; faceStr.AssignWithConversion("face"); nsAutoString faceStr;
faceStr.AssignWithConversion("face");
PRBool first, any, all; PRBool first, any, all;
res = GetInlinePropertyWithAttrValue(nsIEditProperty::font, &faceStr, nsnull, first, any, all, &outFace);
res = GetInlinePropertyBase(nsIEditProperty::font, &faceStr, nsnull, &first, &any, &all, &outFace);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
if (any && !all) return res; // mixed if (any && !all) return res; // mixed
if (all) if (all)
{ {
aMixed = PR_FALSE; *aMixed = PR_FALSE;
return res; return res;
} }
res = GetInlineProperty(nsIEditProperty::tt, nsnull, nsnull, first, any, all); res = GetInlinePropertyBase(nsIEditProperty::tt, nsnull, nsnull, &first, &any, &all,nsnull);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
if (any && !all) return res; // mixed if (any && !all) return res; // mixed
if (all) if (all)
{ {
aMixed = PR_FALSE; *aMixed = PR_FALSE;
nsIEditProperty::tt->ToString(outFace); nsIEditProperty::tt->ToString(outFace);
} }
if (!any) if (!any)
{ {
// there was no font face attrs of any kind. We are in normal font. // there was no font face attrs of any kind. We are in normal font.
outFace.AssignWithConversion(""); outFace.SetLength(0);
aMixed = PR_FALSE; *aMixed = PR_FALSE;
} }
return res; return res;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::GetFontColorState(PRBool &aMixed, nsString &aOutColor) nsHTMLEditor::GetFontColorState(PRBool *aMixed, nsAWritableString &aOutColor)
{ {
aMixed = PR_TRUE; if (!aMixed)
aOutColor.AssignWithConversion(""); return NS_ERROR_NULL_POINTER;
*aMixed = PR_TRUE;
aOutColor.SetLength(0);
nsresult res; nsresult res;
nsAutoString colorStr; colorStr.AssignWithConversion("color"); nsAutoString colorStr; colorStr.AssignWithConversion("color");
PRBool first, any, all; PRBool first, any, all;
res = GetInlinePropertyWithAttrValue(nsIEditProperty::font, &colorStr, nsnull, first, any, all, &aOutColor); res = GetInlinePropertyBase(nsIEditProperty::font, &colorStr, nsnull, &first, &any, &all, &aOutColor);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
if (any && !all) return res; // mixed if (any && !all) return res; // mixed
if (all) if (all)
{ {
aMixed = PR_FALSE; *aMixed = PR_FALSE;
return res; return res;
} }
if (!any) if (!any)
{ {
// there was no font color attrs of any kind.. // there was no font color attrs of any kind..
aOutColor.AssignWithConversion(""); aOutColor.SetLength(0);
aMixed = PR_FALSE; *aMixed = PR_FALSE;
} }
return res; return res;
} }

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

@ -35,11 +35,11 @@ class nsIHTMLEditRules : public nsISupports
public: public:
static const nsIID& GetIID() { static nsIID iid = NS_IHTMLEDITRULES_IID; return iid; } static const nsIID& GetIID() { static nsIID iid = NS_IHTMLEDITRULES_IID; return iid; }
NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL)=0; NS_IMETHOD GetListState(PRBool *aMixed, PRBool *aOL, PRBool *aUL, PRBool *aDL)=0;
NS_IMETHOD GetListItemState(PRBool &aMixed, PRBool &aLI, PRBool &aDT, PRBool &aDD)=0; NS_IMETHOD GetListItemState(PRBool *aMixed, PRBool *aLI, PRBool *aDT, PRBool *aDD)=0;
NS_IMETHOD GetIndentState(PRBool &aCanIndent, PRBool &aCanOutdent)=0; NS_IMETHOD GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent)=0;
NS_IMETHOD GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign)=0; NS_IMETHOD GetAlignment(PRBool *aMixed, nsIHTMLEditor::EAlignment *aAlign)=0;
NS_IMETHOD GetParagraphState(PRBool &aMixed, nsString &outFormat)=0; NS_IMETHOD GetParagraphState(PRBool *aMixed, nsAWritableString &outFormat)=0;
}; };

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

@ -1885,7 +1885,7 @@ nsHTMLEditor::CopyCellBackgroundColor(nsIDOMElement *destCell, nsIDOMElement *so
nsAutoString bgcolor; bgcolor.AssignWithConversion("bgcolor"); nsAutoString bgcolor; bgcolor.AssignWithConversion("bgcolor");
nsAutoString color; nsAutoString color;
PRBool isSet; PRBool isSet;
nsresult res = GetAttributeValue(sourceCell, bgcolor, color, isSet); nsresult res = GetAttributeValue(sourceCell, bgcolor, color, &isSet);
if (NS_SUCCEEDED(res) && isSet) if (NS_SUCCEEDED(res) && isSet)
res = SetAttribute(destCell, bgcolor, color); res = SetAttribute(destCell, bgcolor, color);

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

@ -62,51 +62,53 @@ nsAOLCiter::QueryInterface(REFNSIID aIID, void** aInstancePtr)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsAOLCiter::GetCiteString(const nsString& aInString, nsString& aOutString) nsAOLCiter::GetCiteString(const nsAReadableString& aInString, nsAWritableString& aOutString)
{ {
aOutString.AssignWithConversion("\n\n>> "); aOutString = NS_LITERAL_STRING("\n\n>> ");
aOutString += aInString; aOutString += aInString;
// See if the last char is a newline, and replace it if so // See if the last char is a newline, and replace it if so
PRUnichar newline ('\n'); PRUnichar newline ('\n');
if (aOutString.Last() == newline) if (aOutString.Last() == newline)
{ {
aOutString.SetCharAt(' ',aOutString.Length()); aOutString.Append(PRUnichar(' '));
aOutString.AppendWithConversion("<<\n"); aOutString.Append(NS_LITERAL_STRING("<<\n"));
} }
else else
{ {
aOutString.AppendWithConversion(" <<\n"); aOutString.Append(NS_LITERAL_STRING(" <<\n"));
} }
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsAOLCiter::StripCites(const nsString& aInString, nsString& aOutString) nsAOLCiter::StripCites(const nsAReadableString& aInString, nsAWritableString& aOutString)
{ {
// Remove the beginning cites, if any: // Remove the beginning cites, if any:
if (aInString.EqualsWithConversion(">>", PR_FALSE, 2)) nsAutoString tInputString(aInString);//MJUDGE SCC NEED HELP
nsAutoString tOutputString;
if (tInputString.EqualsWithConversion(">>", PR_FALSE, 2))
{ {
PRInt32 i = 3; PRInt32 i = 3;
while (nsCRT::IsAsciiSpace(aInString[i])) while (nsCRT::IsAsciiSpace(tInputString[i]))
++i; ++i;
aOutString.Append(aInString.GetUnicode(), i); tOutputString.Append(tInputString.GetUnicode(), i);
} }
else else
aOutString = aInString; tOutputString = tInputString;
// Remove the end cites, if any: // Remove the end cites, if any:
aOutString.Trim("<", PR_FALSE, PR_TRUE, PR_FALSE); tOutputString.Trim("<", PR_FALSE, PR_TRUE, PR_FALSE);
aOutString.Assign(tOutputString);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsAOLCiter::Rewrap(const nsString& aInString, nsAOLCiter::Rewrap(const nsAReadableString& aInString,
PRUint32 aWrapCol, PRUint32 aFirstLineOffset, PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
PRBool aRespectNewlines, PRBool aRespectNewlines,
nsString& aOutString) nsAWritableString& aOutString)
{ {
nsString citeString; nsString citeString;
return nsWrapUtils::Rewrap(aInString, aWrapCol, aFirstLineOffset, return nsWrapUtils::Rewrap(aInString, aWrapCol, aFirstLineOffset,

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

@ -23,9 +23,9 @@
#ifndef nsAOLCiter_h__ #ifndef nsAOLCiter_h__
#define nsAOLCiter_h__ #define nsAOLCiter_h__
#include "nsString.h"
#include "nsICiter.h" #include "nsICiter.h"
#include "nsString.h"
/** Mail citations using the AOL style >> This is a citation << /** Mail citations using the AOL style >> This is a citation <<
*/ */
@ -38,14 +38,14 @@ public:
//NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor //NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_IMETHOD GetCiteString(const nsString& aInString, nsString& aOutString); NS_IMETHOD GetCiteString(const nsAReadableString & aInString, nsAWritableString & aOutString);
NS_IMETHOD StripCites(const nsString& aInString, nsString& aOutString); NS_IMETHOD StripCites(const nsAReadableString & aInString, nsAWritableString & aOutString);
NS_IMETHOD Rewrap(const nsString& aInString, NS_IMETHOD Rewrap(const nsAReadableString & aInString,
PRUint32 aWrapCol, PRUint32 aFirstLineOffset, PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
PRBool aRespectNewlines, PRBool aRespectNewlines,
nsString& aOutString); nsAWritableString & aOutString);
}; };
#endif //nsAOLCiter_h__ #endif //nsAOLCiter_h__

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

@ -615,7 +615,7 @@ nsTextEditorDragListener::DragGesture(nsIDOMEvent* aDragEvent)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
// ...figure out if a drag should be started... // ...figure out if a drag should be started...
nsresult rv = mEditor->CanDrag(aDragEvent, canDrag); nsresult rv = mEditor->CanDrag(aDragEvent, &canDrag);
if ( NS_SUCCEEDED(rv) && canDrag ) if ( NS_SUCCEEDED(rv) && canDrag )
rv = mEditor->DoDrag(aDragEvent); rv = mEditor->DoDrag(aDragEvent);

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

@ -21,9 +21,9 @@
* Pierre Phaneuf <pp@ludusdesign.com> * Pierre Phaneuf <pp@ludusdesign.com>
*/ */
#include "nsInternetCiter.h"
#include "nsString.h" #include "nsString.h"
#include "nsInternetCiter.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
@ -76,7 +76,7 @@ nsInternetCiter::QueryInterface(REFNSIID aIID, void** aInstancePtr)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString) nsInternetCiter::GetCiteString(const nsAReadableString& aInString, nsAWritableString& aOutString)
{ {
PRInt32 i = 0; PRInt32 i = 0;
PRInt32 length = aInString.Length(); PRInt32 length = aInString.Length();
@ -85,9 +85,10 @@ nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
// Strip trailing new lines which will otherwise turn up // Strip trailing new lines which will otherwise turn up
// as ugly quoted empty lines. // as ugly quoted empty lines.
nsString tString(aInString); //CRAPCRAP
while(length > 0 && while(length > 0 &&
(aInString[length-1] == cr || (tString[length-1] == cr ||
aInString[length-1] == nl)) tString[length-1] == nl))
{ {
--length; --length;
} }
@ -100,11 +101,11 @@ nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
aOutString.Append(gt); aOutString.Append(gt);
// No space between >: this is ">>> " style quoting, for // No space between >: this is ">>> " style quoting, for
// compatability with RFC 2646 and format=flowed. // compatability with RFC 2646 and format=flowed.
if (aInString[i] != gt) if (tString[i] != gt)
aOutString.Append(space); aOutString.Append(space);
} }
uch = aInString[i++]; uch = tString[i++];
aOutString += uch; aOutString += uch;
} }
@ -116,8 +117,8 @@ nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
} }
nsresult nsresult
nsInternetCiter::StripCitesAndLinebreaks(const nsString& aInString, nsInternetCiter::StripCitesAndLinebreaks(const nsAReadableString& aInString,
nsString& aOutString, nsAWritableString& aOutString,
PRBool aLinebreaksToo, PRBool aLinebreaksToo,
PRInt32* aCiteLevel) PRInt32* aCiteLevel)
{ {
@ -126,36 +127,37 @@ nsInternetCiter::StripCitesAndLinebreaks(const nsString& aInString,
aOutString.SetLength(0); aOutString.SetLength(0);
PRInt32 length = aInString.Length(); nsString tString(aInString);//CRAPCRAP
PRInt32 length = tString.Length();
PRInt32 i = 0; PRInt32 i = 0;
while (i < length) // loop over lines while (i < length) // loop over lines
{ {
// Clear out cites first, at the beginning of the line: // Clear out cites first, at the beginning of the line:
PRInt32 thisLineCiteLevel = 0; PRInt32 thisLineCiteLevel = 0;
while (aInString[i] == gt || nsCRT::IsAsciiSpace(aInString[i])) while (tString[i] == gt || nsCRT::IsAsciiSpace(tString[i]))
{ {
if (aInString[i] == gt) ++thisLineCiteLevel; if (tString[i] == gt) ++thisLineCiteLevel;
++i; ++i;
} }
// Now copy characters until line end: // Now copy characters until line end:
PRInt32 nextNewline = aInString.FindCharInSet("\r\n", i); PRInt32 nextNewline = tString.FindCharInSet("\r\n", i);
if (nextNewline > i) if (nextNewline > i)
{ {
while (i < nextNewline) while (i < nextNewline)
aOutString.Append(aInString[i++]); aOutString.Append(tString[i++]);
if (aLinebreaksToo) if (aLinebreaksToo)
aOutString.AppendWithConversion(' '); aOutString.Append(PRUnichar(' '));
else else
aOutString.AppendWithConversion('\n'); // DOM linebreaks, not NS_LINEBREAK aOutString.Append(PRUnichar('\n')); // DOM linebreaks, not NS_LINEBREAK
// Skip over any more consecutive linebreak-like characters: // Skip over any more consecutive linebreak-like characters:
while (i < length && (aInString[i] == '\r' || aInString[i] == '\n')) while (i < length && (tString[i] == '\r' || tString[i] == '\n'))
++i; ++i;
} }
else // no more newlines else // no more newlines
{ {
while (i < length) while (i < length)
aOutString.Append(aInString[i++]); aOutString.Append(tString[i++]);
} }
// Done with this line -- update cite level // Done with this line -- update cite level
@ -166,24 +168,24 @@ nsInternetCiter::StripCitesAndLinebreaks(const nsString& aInString,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsInternetCiter::StripCites(const nsString& aInString, nsString& aOutString) nsInternetCiter::StripCites(const nsAReadableString& aInString, nsAWritableString& aOutString)
{ {
return StripCitesAndLinebreaks(aInString, aOutString, PR_FALSE, 0); return StripCitesAndLinebreaks(aInString, aOutString, PR_FALSE, 0);
} }
static void AddCite(nsString& aOutString, PRInt32 citeLevel) static void AddCite(nsAWritableString& aOutString, PRInt32 citeLevel)
{ {
for (PRInt32 i = 0; i < citeLevel; ++i) for (PRInt32 i = 0; i < citeLevel; ++i)
aOutString.Append(gt); aOutString.Append(PRUnichar(gt));
if (citeLevel > 0) if (citeLevel > 0)
aOutString.Append(space); aOutString.Append(PRUnichar(space));
} }
NS_IMETHODIMP NS_IMETHODIMP
nsInternetCiter::Rewrap(const nsString& aInString, nsInternetCiter::Rewrap(const nsAReadableString& aInString,
PRUint32 aWrapCol, PRUint32 aFirstLineOffset, PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
PRBool aRespectNewlines, PRBool aRespectNewlines,
nsString& aOutString) nsAWritableString& aOutString)
{ {
nsCOMPtr<nsILineBreaker> lineBreaker; nsCOMPtr<nsILineBreaker> lineBreaker;
nsILineBreakerFactory *lf; nsILineBreakerFactory *lf;
@ -205,21 +207,21 @@ nsInternetCiter::Rewrap(const nsString& aInString,
PRUint32 posInString = 0; PRUint32 posInString = 0;
PRUint32 outStringCol = 0; PRUint32 outStringCol = 0;
PRUint32 citeLevel = 0; PRUint32 citeLevel = 0;
const PRUnichar* unicodeStr = aInString.GetUnicode(); const nsPromiseFlatString &tString = PromiseFlatString(aInString);//MJUDGE SCC NEED HELP
while (posInString < length) while (posInString < length)
{ {
#ifdef DEBUG_wrapping #ifdef DEBUG_wrapping
nsAutoString debug (nsPromiseSubstring<PRUnichar>(aInString, posInString, length-posInString)); nsAutoString debug (nsPromiseSubstring<PRUnichar>(tString, posInString, length-posInString));
printf("Outer loop: '%s'\n", debug.ToNewCString()); printf("Outer loop: '%s'\n", debug.ToNewCString());
#endif #endif
// Get the new cite level here since we're at the beginning of a line // Get the new cite level here since we're at the beginning of a line
PRUint32 newCiteLevel = 0; PRUint32 newCiteLevel = 0;
while (posInString < length && aInString[posInString] == gt) while (posInString < length && tString[posInString] == gt)
{ {
++newCiteLevel; ++newCiteLevel;
++posInString; ++posInString;
while (posInString < length && aInString[posInString] == space) while (posInString < length && tString[posInString] == space)
++posInString; ++posInString;
} }
if (posInString >= length) if (posInString >= length)
@ -227,9 +229,12 @@ nsInternetCiter::Rewrap(const nsString& aInString,
// Special case: if this is a blank line, maintain a blank line // Special case: if this is a blank line, maintain a blank line
// (retain the original paragraph breaks) // (retain the original paragraph breaks)
if (aInString[posInString] == nl) if (tString[posInString] == nl)
{ {
if (aOutString.Length() > 0 && aOutString[aOutString.Length()-1] != nl) nsReadingIterator <PRUnichar> outPeekIter;
aOutString.EndReading(outPeekIter);
outPeekIter.advance(-1);
if (aOutString.Length() > 0 && (*outPeekIter) != nl)
aOutString.Append(nl); aOutString.Append(nl);
AddCite(aOutString, newCiteLevel); AddCite(aOutString, newCiteLevel);
aOutString.Append(nl); aOutString.Append(nl);
@ -267,12 +272,12 @@ nsInternetCiter::Rewrap(const nsString& aInString,
printf("Appending space; citeLevel=%d, outStringCol=%d\n", citeLevel, printf("Appending space; citeLevel=%d, outStringCol=%d\n", citeLevel,
outStringCol); outStringCol);
#endif #endif
aOutString.Append(space); aOutString.Append(PRUnichar(space));
++outStringCol; ++outStringCol;
} }
// find the next newline -- don't want to go farther than that // find the next newline -- don't want to go farther than that
PRInt32 nextNewline = aInString.FindChar(nl, PR_FALSE, posInString); PRInt32 nextNewline = tString.FindChar(nl, posInString);
if (nextNewline < 0) nextNewline = length; if (nextNewline < 0) nextNewline = length;
// For now, don't wrap unquoted lines at all. // For now, don't wrap unquoted lines at all.
@ -285,11 +290,11 @@ nsInternetCiter::Rewrap(const nsString& aInString,
if (citeLevel == 0) if (citeLevel == 0)
{ {
#ifdef DEBUG_wrapping #ifdef DEBUG_wrapping
nsAutoString debug (nsPromiseSubstring<PRUnichar>(aInString, posInString, nsAutoString debug (nsPromiseSubstring<PRUnichar>(tString, posInString,
nextNewline-posInString)); nextNewline-posInString));
printf("Unquoted: appending '%s'\n", debug.ToNewCString()); printf("Unquoted: appending '%s'\n", debug.ToNewCString());
#endif #endif
aOutString.Append(nsPromiseSubstring(aInString, posInString, aOutString.Append(nsPromiseSubstring(tString, posInString,
nextNewline-posInString)); nextNewline-posInString));
outStringCol += nextNewline - posInString; outStringCol += nextNewline - posInString;
if (nextNewline != (PRInt32)length) if (nextNewline != (PRInt32)length)
@ -309,7 +314,7 @@ nsInternetCiter::Rewrap(const nsString& aInString,
while ((PRInt32)posInString < nextNewline) while ((PRInt32)posInString < nextNewline)
{ {
#ifdef DEBUG_wrapping #ifdef DEBUG_wrapping
nsAutoString debug (nsPromiseSubstring<PRUnichar>(aInString, posInString, nextNewline-posInString)); nsAutoString debug (nsPromiseSubstring<PRUnichar>(tString, posInString, nextNewline-posInString));
printf("Inner loop: '%s'\n", debug.ToNewCString()); printf("Inner loop: '%s'\n", debug.ToNewCString());
#endif #endif
@ -318,13 +323,13 @@ nsInternetCiter::Rewrap(const nsString& aInString,
{ {
// If this short line is the final one in the in string, // If this short line is the final one in the in string,
// then we need to include the final newline, if any: // then we need to include the final newline, if any:
if (nextNewline+1 == (PRInt32)length && aInString[nextNewline-1] == nl) if (nextNewline+1 == (PRInt32)length && tString[nextNewline-1] == nl)
++nextNewline; ++nextNewline;
#ifdef DEBUG_wrapping #ifdef DEBUG_wrapping
nsAutoString debug (nsPromiseSubstring<PRUnichar>(aInString, posInString, nextNewline - posInString)); nsAutoString debug (nsPromiseSubstring<PRUnichar>(tString, posInString, nextNewline - posInString));
printf("Short line: '%s'\n", debug.ToNewCString()); printf("Short line: '%s'\n", debug.ToNewCString());
#endif #endif
aOutString += nsPromiseSubstring(aInString, aOutString += nsPromiseSubstring(tString,
posInString, nextNewline - posInString); posInString, nextNewline - posInString);
outStringCol += nextNewline - posInString; outStringCol += nextNewline - posInString;
posInString = nextNewline + 1; posInString = nextNewline + 1;
@ -339,13 +344,13 @@ nsInternetCiter::Rewrap(const nsString& aInString,
rv = NS_ERROR_BASE; rv = NS_ERROR_BASE;
if (lineBreaker) if (lineBreaker)
{ {
rv = lineBreaker->Prev(unicodeStr + posInString, length - posInString, rv = lineBreaker->Prev(tString.get() + posInString, length - posInString,
eol - posInString, &breakPt, &needMore); eol - posInString, &breakPt, &needMore);
if (NS_FAILED(rv) || needMore) if (NS_FAILED(rv) || needMore)
{ {
// if we couldn't find a breakpoint looking backwards, // if we couldn't find a breakpoint looking backwards,
// try looking forwards: // try looking forwards:
rv = lineBreaker->Next(unicodeStr + posInString, rv = lineBreaker->Next(tString.get() + posInString,
length - posInString, length - posInString,
eol - posInString, &breakPt, &needMore); eol - posInString, &breakPt, &needMore);
if (needMore) rv = NS_ERROR_BASE; if (needMore) rv = NS_ERROR_BASE;
@ -365,7 +370,7 @@ nsInternetCiter::Rewrap(const nsString& aInString,
printf("breakPt = %d\n", breakPt); printf("breakPt = %d\n", breakPt);
#endif #endif
aOutString += nsPromiseSubstring(aInString, posInString, breakPt); aOutString += nsPromiseSubstring(tString, posInString, breakPt);
posInString += breakPt; posInString += breakPt;
outStringCol += breakPt; outStringCol += breakPt;

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

@ -38,17 +38,17 @@ public:
//NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor //NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_IMETHOD GetCiteString(const nsString& aInString, nsString& aOutString); NS_IMETHOD GetCiteString(const nsAReadableString & aInString, nsAWritableString & aOutString);
NS_IMETHOD StripCites(const nsString& aInString, nsString& aOutString); NS_IMETHOD StripCites(const nsAReadableString & aInString, nsAWritableString & aOutString);
NS_IMETHOD Rewrap(const nsString& aInString, NS_IMETHOD Rewrap(const nsAReadableString & aInString,
PRUint32 aWrapCol, PRUint32 aFirstLineOffset, PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
PRBool aRespectNewlines, PRBool aRespectNewlines,
nsString& aOutString); nsAWritableString & aOutString);
protected: protected:
nsresult StripCitesAndLinebreaks(const nsString& aInString, nsString& aOutString, nsresult StripCitesAndLinebreaks(const nsAReadableString& aInString, nsAWritableString& aOutString,
PRBool aLinebreaksToo, PRInt32* aCiteLevel); PRBool aLinebreaksToo, PRInt32* aCiteLevel);
}; };

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

@ -160,7 +160,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertTextFromTransferable(nsITransferable *tra
textDataObj->ToString ( &text ); textDataObj->ToString ( &text );
stuffToPaste.Assign ( text, len / 2 ); stuffToPaste.Assign ( text, len / 2 );
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
rv = InsertText(stuffToPaste.GetUnicode()); rv = InsertText(stuffToPaste);
if (text) if (text)
nsMemory::Free(text); nsMemory::Free(text);
} }
@ -355,12 +355,14 @@ NS_IMETHODIMP nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
return rv; return rv;
} }
NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag) NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag)
{ {
if (!aCanDrag)
return NS_ERROR_NULL_POINTER;
/* we really should be checking the XY coordinates of the mouseevent and ensure that /* we really should be checking the XY coordinates of the mouseevent and ensure that
* that particular point is actually within the selection (not just that there is a selection) * that particular point is actually within the selection (not just that there is a selection)
*/ */
aCanDrag = PR_FALSE; *aCanDrag = PR_FALSE;
// KLUDGE to work around bug 50703 // KLUDGE to work around bug 50703
// After double click and object property editing, // After double click and object property editing,
@ -395,7 +397,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDr
res = selection->ContainsNode(eventTargetDomNode, PR_FALSE, &amTargettedCorrectly); res = selection->ContainsNode(eventTargetDomNode, PR_FALSE, &amTargettedCorrectly);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
aCanDrag = amTargettedCorrectly; *aCanDrag = amTargettedCorrectly;
} }
} }
@ -532,9 +534,11 @@ NS_IMETHODIMP nsPlaintextEditor::Paste(PRInt32 aSelectionType)
} }
NS_IMETHODIMP nsPlaintextEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste) NS_IMETHODIMP nsPlaintextEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste)
{ {
aCanPaste = PR_FALSE; if (!aCanPaste)
return NS_ERROR_NULL_POINTER;
*aCanPaste = PR_FALSE;
// can't paste if readonly // can't paste if readonly
if (!IsModifiable()) if (!IsModifiable())
@ -572,6 +576,6 @@ NS_IMETHODIMP nsPlaintextEditor::CanPaste(PRInt32 aSelectionType, PRBool &aCanPa
rv = clipboard->HasDataMatchingFlavors(flavorsList, aSelectionType, &haveFlavors); rv = clipboard->HasDataMatchingFlavors(flavorsList, aSelectionType, &haveFlavors);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
aCanPaste = haveFlavors; *aCanPaste = haveFlavors;
return NS_OK; return NS_OK;
} }

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

@ -245,7 +245,7 @@ nsPlaintextEditor::EndEditorInit()
} }
NS_IMETHODIMP NS_IMETHODIMP
nsPlaintextEditor::SetDocumentCharacterSet(const PRUnichar* characterSet) nsPlaintextEditor::SetDocumentCharacterSet(const nsAReadableString & characterSet)
{ {
nsresult result; nsresult result;
@ -312,7 +312,7 @@ nsPlaintextEditor::SetDocumentCharacterSet(const PRUnichar* characterSet)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
// Set attributes to the created element // Set attributes to the created element
if (resultNode && nsCRT::strlen(characterSet) > 0) { if (resultNode && characterSet.Length() > 0) {
metaElement = do_QueryInterface(resultNode); metaElement = do_QueryInterface(resultNode);
if (metaElement) { if (metaElement) {
// not undoable, undo should undo CreateNode // not undoable, undo should undo CreateNode
@ -505,19 +505,19 @@ NS_IMETHODIMP nsPlaintextEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
|| keyCode == nsIDOMKeyEvent::DOM_VK_ENTER) || keyCode == nsIDOMKeyEvent::DOM_VK_ENTER)
{ {
nsString empty; nsString empty;
return TypedText(empty.GetUnicode(), eTypedBreak); return TypedText(empty, eTypedBreak);
} }
else if (keyCode == nsIDOMKeyEvent::DOM_VK_ESCAPE) else if (keyCode == nsIDOMKeyEvent::DOM_VK_ESCAPE)
{ {
// pass escape keypresses through as empty strings: needed for ime support // pass escape keypresses through as empty strings: needed for ime support
nsString empty; nsString empty;
return TypedText(empty.GetUnicode(), eTypedText); return TypedText(empty, eTypedText);
} }
if (character && !altKey && !ctrlKey && !isShift && !metaKey) if (character && !altKey && !ctrlKey && !isShift && !metaKey)
{ {
nsAutoString key(character); nsAutoString key(character);
return TypedText(key.GetUnicode(), eTypedText); return TypedText(key, eTypedText);
} }
} }
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -529,7 +529,7 @@ NS_IMETHODIMP nsPlaintextEditor::HandleKeyPress(nsIDOMKeyEvent* aKeyEvent)
to TypedText() to determine what action to take, but without passing to TypedText() to determine what action to take, but without passing
an event. an event.
*/ */
NS_IMETHODIMP nsPlaintextEditor::TypedText(const PRUnichar* aString, NS_IMETHODIMP nsPlaintextEditor::TypedText(const nsAReadableString& aString,
PRInt32 aAction) PRInt32 aAction)
{ {
nsAutoPlaceHolderBatch batch(this, gTypingTxnName); nsAutoPlaceHolderBatch batch(this, gTypingTxnName);
@ -944,7 +944,7 @@ NS_IMETHODIMP nsPlaintextEditor::DeleteSelection(nsIEditor::EDirection aAction)
return result; return result;
} }
NS_IMETHODIMP nsPlaintextEditor::InsertText(const PRUnichar* aStringToInsert) NS_IMETHODIMP nsPlaintextEditor::InsertText(const nsAReadableString &aStringToInsert)
{ {
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
@ -967,9 +967,9 @@ NS_IMETHODIMP nsPlaintextEditor::InsertText(const PRUnichar* aStringToInsert)
nsAutoString resultString; nsAutoString resultString;
// XXX can we trust instring to outlive ruleInfo, // XXX can we trust instring to outlive ruleInfo,
// XXX and ruleInfo not to refer to instring in its dtor? // XXX and ruleInfo not to refer to instring in its dtor?
nsAutoString instring(aStringToInsert); //nsAutoString instring(aStringToInsert);
nsTextRulesInfo ruleInfo(theAction); nsTextRulesInfo ruleInfo(theAction);
ruleInfo.inString = &instring; ruleInfo.inString = &aStringToInsert;
ruleInfo.outString = &resultString; ruleInfo.outString = &resultString;
ruleInfo.maxLength = mMaxTextLength; ruleInfo.maxLength = mMaxTextLength;
@ -1361,9 +1361,11 @@ NS_IMETHODIMP nsPlaintextEditor::Cut()
return res; return res;
} }
NS_IMETHODIMP nsPlaintextEditor::CanCut(PRBool &aCanCut) NS_IMETHODIMP nsPlaintextEditor::CanCut(PRBool *aCanCut)
{ {
aCanCut = PR_FALSE; if (!aCanCut)
return NS_ERROR_NULL_POINTER;
*aCanCut = PR_FALSE;
nsCOMPtr<nsISelection> selection; nsCOMPtr<nsISelection> selection;
nsresult res = GetSelection(getter_AddRefs(selection)); nsresult res = GetSelection(getter_AddRefs(selection));
@ -1373,7 +1375,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanCut(PRBool &aCanCut)
res = selection->GetIsCollapsed(&isCollapsed); res = selection->GetIsCollapsed(&isCollapsed);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
aCanCut = !isCollapsed && IsModifiable(); *aCanCut = !isCollapsed && IsModifiable();
return NS_OK; return NS_OK;
} }
@ -1385,9 +1387,11 @@ NS_IMETHODIMP nsPlaintextEditor::Copy()
return ps->DoCopy(); return ps->DoCopy();
} }
NS_IMETHODIMP nsPlaintextEditor::CanCopy(PRBool &aCanCopy) NS_IMETHODIMP nsPlaintextEditor::CanCopy(PRBool *aCanCopy)
{ {
aCanCopy = PR_FALSE; if (!aCanCopy)
return NS_ERROR_NULL_POINTER;
*aCanCopy = PR_FALSE;
nsCOMPtr<nsISelection> selection; nsCOMPtr<nsISelection> selection;
nsresult res = GetSelection(getter_AddRefs(selection)); nsresult res = GetSelection(getter_AddRefs(selection));
@ -1397,7 +1401,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanCopy(PRBool &aCanCopy)
res = selection->GetIsCollapsed(&isCollapsed); res = selection->GetIsCollapsed(&isCollapsed);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
aCanCopy = !isCollapsed; *aCanCopy = !isCollapsed;
return NS_OK; return NS_OK;
} }
@ -1406,7 +1410,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanCopy(PRBool &aCanCopy)
NS_IMETHODIMP NS_IMETHODIMP
nsPlaintextEditor::GetAndInitDocEncoder(const nsAReadableString& aFormatType, nsPlaintextEditor::GetAndInitDocEncoder(const nsAReadableString& aFormatType,
PRUint32 aFlags, PRUint32 aFlags,
const nsAReadableString* aCharset, const nsAReadableString& aCharset,
nsIDocumentEncoder** encoder) nsIDocumentEncoder** encoder)
{ {
nsCOMPtr<nsIPresShell> presShell; nsCOMPtr<nsIPresShell> presShell;
@ -1426,9 +1430,9 @@ nsPlaintextEditor::GetAndInitDocEncoder(const nsAReadableString& aFormatType,
rv = docEncoder->Init(doc, aFormatType, aFlags); rv = docEncoder->Init(doc, aFormatType, aFlags);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
if (aCharset && aCharset->Length() != 0 if (aCharset.Length() != 0
&& !(aCharset->Equals(NS_LITERAL_STRING("null")))) && !(aCharset.Equals(NS_LITERAL_STRING("null"))))
docEncoder->SetCharset(*aCharset); docEncoder->SetCharset(aCharset);
PRInt32 wc; PRInt32 wc;
(void) GetWrapWidth(&wc); (void) GetWrapWidth(&wc);
@ -1512,7 +1516,7 @@ nsPlaintextEditor::OutputToString(nsAWritableString& aOutputString,
} }
nsCOMPtr<nsIDocumentEncoder> encoder; nsCOMPtr<nsIDocumentEncoder> encoder;
rv = GetAndInitDocEncoder(aFormatType, aFlags, 0, getter_AddRefs(encoder)); rv = GetAndInitDocEncoder(aFormatType, aFlags, NS_LITERAL_STRING(""), getter_AddRefs(encoder));
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
rv = encoder->EncodeToString(aOutputString); rv = encoder->EncodeToString(aOutputString);
@ -1522,7 +1526,7 @@ nsPlaintextEditor::OutputToString(nsAWritableString& aOutputString,
NS_IMETHODIMP NS_IMETHODIMP
nsPlaintextEditor::OutputToStream(nsIOutputStream* aOutputStream, nsPlaintextEditor::OutputToStream(nsIOutputStream* aOutputStream,
const nsAReadableString& aFormatType, const nsAReadableString& aFormatType,
const nsAReadableString* aCharset, const nsAReadableString& aCharset,
PRUint32 aFlags) PRUint32 aFlags)
{ {
nsresult rv; nsresult rv;
@ -1647,7 +1651,7 @@ static nsICiter* MakeACiter()
} }
NS_IMETHODIMP NS_IMETHODIMP
nsPlaintextEditor::InsertAsQuotation(const nsString& aQuotedText, nsPlaintextEditor::InsertAsQuotation(const nsAReadableString& aQuotedText,
nsIDOMNode **aNodeInserted) nsIDOMNode **aNodeInserted)
{ {
// We have the text. Cite it appropriately: // We have the text. Cite it appropriately:
@ -1681,7 +1685,7 @@ nsPlaintextEditor::InsertAsQuotation(const nsString& aQuotedText,
if (cancel) return NS_OK; // rules canceled the operation if (cancel) return NS_OK; // rules canceled the operation
if (!handled) if (!handled)
{ {
rv = InsertText(quotedStuff.GetUnicode()); rv = InsertText(quotedStuff);
// XXX Should set *aNodeInserted to the first node inserted // XXX Should set *aNodeInserted to the first node inserted
if (aNodeInserted && NS_SUCCEEDED(rv)) if (aNodeInserted && NS_SUCCEEDED(rv))
@ -1694,17 +1698,17 @@ nsPlaintextEditor::InsertAsQuotation(const nsString& aQuotedText,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsPlaintextEditor::PasteAsCitedQuotation(const nsString& aCitation, nsPlaintextEditor::PasteAsCitedQuotation(const nsAReadableString& aCitation,
PRInt32 aSelectionType) PRInt32 aSelectionType)
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsPlaintextEditor::InsertAsCitedQuotation(const nsString& aQuotedText, nsPlaintextEditor::InsertAsCitedQuotation(const nsAReadableString& aQuotedText,
const nsString& aCitation, const nsAReadableString& aCitation,
PRBool aInsertHTML, PRBool aInsertHTML,
const nsString& aCharset, const nsAReadableString& aCharset,
nsIDOMNode **aNodeInserted) nsIDOMNode **aNodeInserted)
{ {
return InsertAsQuotation(aQuotedText, aNodeInserted); return InsertAsQuotation(aQuotedText, aNodeInserted);
@ -1752,7 +1756,7 @@ nsPlaintextEditor::Rewrap(PRBool aRespectNewlines)
rv = SelectAll(); rv = SelectAll();
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
return InsertText(wrapped.GetUnicode()); return InsertText(wrapped);
} }
else // rewrap only the selection else // rewrap only the selection
{ {
@ -1770,7 +1774,7 @@ nsPlaintextEditor::Rewrap(PRBool aRespectNewlines)
wrapped); wrapped);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
return InsertText(wrapped.GetUnicode()); return InsertText(wrapped);
} }
return NS_OK; return NS_OK;
} }
@ -1813,7 +1817,7 @@ nsPlaintextEditor::StripCites()
rv = SelectAll(); rv = SelectAll();
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
return InsertText(stripped.GetUnicode()); return InsertText(stripped);
} }
else // rewrap only the selection else // rewrap only the selection
{ {
@ -1829,7 +1833,7 @@ nsPlaintextEditor::StripCites()
rv = citer->StripCites(current, stripped); rv = citer->StripCites(current, stripped);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
return InsertText(stripped.GetUnicode()); return InsertText(stripped);
} }
return NS_OK; return NS_OK;
} }
@ -1849,7 +1853,7 @@ nsPlaintextEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
#endif #endif
NS_IMETHODIMP NS_IMETHODIMP
nsPlaintextEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply) nsPlaintextEditor::SetCompositionString(const nsAReadableString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply)
{ {
NS_ASSERTION(aTextRangeList, "null ptr"); NS_ASSERTION(aTextRangeList, "null ptr");
if(nsnull == aTextRangeList) if(nsnull == aTextRangeList)
@ -1872,7 +1876,7 @@ nsPlaintextEditor::SetCompositionString(const nsString& aCompositionString, nsIP
mIMETextRangeList = aTextRangeList; mIMETextRangeList = aTextRangeList;
nsAutoPlaceHolderBatch batch(this, gIMETxnName); nsAutoPlaceHolderBatch batch(this, gIMETxnName);
result = InsertText(aCompositionString.GetUnicode()); result = InsertText(aCompositionString);
mIMEBufferLength = aCompositionString.Length(); mIMEBufferLength = aCompositionString.Length();

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

@ -70,14 +70,14 @@ public:
/* ------------ nsIEditorMailSupport overrides -------------- */ /* ------------ nsIEditorMailSupport overrides -------------- */
NS_IMETHOD PasteAsQuotation(PRInt32 aSelectionType); NS_IMETHOD PasteAsQuotation(PRInt32 aSelectionType);
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, NS_IMETHOD InsertAsQuotation(const nsAReadableString& aQuotedText,
nsIDOMNode** aNodeInserted); nsIDOMNode** aNodeInserted);
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation, NS_IMETHOD PasteAsCitedQuotation(const nsAReadableString& aCitation,
PRInt32 aSelectionType); PRInt32 aSelectionType);
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, NS_IMETHOD InsertAsCitedQuotation(const nsAReadableString& aQuotedText,
const nsString& aCitation, const nsAReadableString& aCitation,
PRBool aInsertHTML, PRBool aInsertHTML,
const nsString& aCharset, const nsAReadableString& aCharset,
nsIDOMNode** aNodeInserted); nsIDOMNode** aNodeInserted);
NS_IMETHOD Rewrap(PRBool aRespectNewlines); NS_IMETHOD Rewrap(PRBool aRespectNewlines);
NS_IMETHOD StripCites(); NS_IMETHOD StripCites();
@ -85,7 +85,7 @@ public:
/* ------------ nsIEditorIMESupport overrides -------------- */ /* ------------ nsIEditorIMESupport overrides -------------- */
NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply); NS_IMETHOD SetCompositionString(const nsAReadableString & aCompositionString, nsIPrivateTextRangeList * aTextRange, nsTextEventReply * aReply);
NS_IMETHOD GetReconversionString(nsReconversionEventReply* aReply); NS_IMETHOD GetReconversionString(nsReconversionEventReply* aReply);
/* ------------ Overrides of nsEditor interface methods -------------- */ /* ------------ Overrides of nsEditor interface methods -------------- */
@ -97,7 +97,7 @@ public:
NS_IMETHOD DeleteSelection(EDirection aAction); NS_IMETHOD DeleteSelection(EDirection aAction);
NS_IMETHOD SetDocumentCharacterSet(const PRUnichar* characterSet); NS_IMETHOD SetDocumentCharacterSet(const nsAReadableString & characterSet);
/** we override this here to install event listeners */ /** we override this here to install event listeners */
NS_IMETHOD PostCreate(); NS_IMETHOD PostCreate();
@ -109,13 +109,13 @@ public:
NS_IMETHOD Redo(PRUint32 aCount); NS_IMETHOD Redo(PRUint32 aCount);
NS_IMETHOD Cut(); NS_IMETHOD Cut();
NS_IMETHOD CanCut(PRBool &aCanCut); NS_IMETHOD CanCut(PRBool *aCanCut);
NS_IMETHOD Copy(); NS_IMETHOD Copy();
NS_IMETHOD CanCopy(PRBool &aCanCopy); NS_IMETHOD CanCopy(PRBool *aCanCopy);
NS_IMETHOD Paste(PRInt32 aSelectionType); NS_IMETHOD Paste(PRInt32 aSelectionType);
NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool &aCanPaste); NS_IMETHOD CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste);
NS_IMETHOD CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag); NS_IMETHOD CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDrag);
NS_IMETHOD DoDrag(nsIDOMEvent *aDragEvent); NS_IMETHOD DoDrag(nsIDOMEvent *aDragEvent);
NS_IMETHOD InsertFromDrop(nsIDOMEvent* aDropEvent); NS_IMETHOD InsertFromDrop(nsIDOMEvent* aDropEvent);
@ -125,7 +125,7 @@ public:
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream, NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
const nsAReadableString& aFormatType, const nsAReadableString& aFormatType,
const nsAReadableString* aCharsetOverride, const nsAReadableString& aCharsetOverride,
PRUint32 aFlags); PRUint32 aFlags);
@ -141,7 +141,7 @@ public:
NS_IMETHOD SelectEntireDocument(nsISelection *aSelection); NS_IMETHOD SelectEntireDocument(nsISelection *aSelection);
/* ------------ Utility Routines, not part of public API -------------- */ /* ------------ Utility Routines, not part of public API -------------- */
NS_IMETHOD TypedText(const PRUnichar* aString, PRInt32 aAction); NS_IMETHOD TypedText(const nsAReadableString& aString, PRInt32 aAction);
/** returns the absolute position of the end points of aSelection /** returns the absolute position of the end points of aSelection
* in the document as a text stream. * in the document as a text stream.
@ -183,7 +183,7 @@ protected:
// Helpers for output routines // Helpers for output routines
NS_IMETHOD GetAndInitDocEncoder(const nsAReadableString& aFormatType, NS_IMETHOD GetAndInitDocEncoder(const nsAReadableString& aFormatType,
PRUint32 aFlags, PRUint32 aFlags,
const nsAReadableString* aCharset, const nsAReadableString& aCharset,
nsIDocumentEncoder** encoder); nsIDocumentEncoder** encoder);
// key event helpers // key event helpers

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

@ -437,13 +437,14 @@ nsTextEditRules::DidInsertBreak(nsISelection *aSelection, nsresult aResult)
return res; return res;
} }
nsresult nsresult
nsTextEditRules::WillInsertText(PRInt32 aAction, nsTextEditRules::WillInsertText(PRInt32 aAction,
nsISelection *aSelection, nsISelection *aSelection,
PRBool *aCancel, PRBool *aCancel,
PRBool *aHandled, PRBool *aHandled,
const nsString *inString, const nsAReadableString *inString,
nsString *outString, nsAWritableString *outString,
PRInt32 aMaxLength) PRInt32 aMaxLength)
{ {
if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
@ -528,17 +529,40 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
if (nsIPlaintextEditor::eEditorSingleLineMask & mFlags) if (nsIPlaintextEditor::eEditorSingleLineMask & mFlags)
{ {
if (singleLineNewlineBehavior == eReplaceWithSpaces) if (singleLineNewlineBehavior == eReplaceWithSpaces)
outString->ReplaceChar(CRLF, ' '); {
nsString tString;
tString.Assign(*outString);
//nsAWritableString destString;
//NormalizeCRLF(outString,destString);
tString.ReplaceChar(CRLF, ' ');
outString->Assign(tString);
}
else if (singleLineNewlineBehavior == eStripNewlines) else if (singleLineNewlineBehavior == eStripNewlines)
outString->StripChars(CRLF); {
nsString tString;
tString.Assign(*outString);
tString.StripChars(CRLF);
outString->Assign(tString);
}
else if (singleLineNewlineBehavior == ePasteFirstLine) else if (singleLineNewlineBehavior == ePasteFirstLine)
{ {
PRInt32 firstCRLF = outString->FindCharInSet(CRLF); nsString tString;
tString.Assign(*outString);
PRInt32 firstCRLF = tString.FindCharInSet(CRLF);
if (firstCRLF > 0) if (firstCRLF > 0)
outString->Truncate(firstCRLF); {
tString.Truncate(firstCRLF);
outString->Assign(tString);
}
} }
else // even if we're pasting newlines, don't paste leading/trailing ones else // even if we're pasting newlines, don't paste leading/trailing ones
outString->Trim(CRLF, PR_TRUE, PR_TRUE); {
nsString tString;
tString.Assign(*outString);
tString.Trim(CRLF, PR_TRUE, PR_TRUE);
outString->Assign(tString);
}
} }
// get the (collapsed) selection location // get the (collapsed) selection location
@ -576,7 +600,8 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
// dont spaz my selection in subtransactions // dont spaz my selection in subtransactions
nsAutoTxnsConserveSelection dontSpazMySelection(mEditor); nsAutoTxnsConserveSelection dontSpazMySelection(mEditor);
nsSubsumeStr subStr; nsSubsumeStr subStr;
const PRUnichar *unicodeBuf = outString->GetUnicode(); nsString tString(*outString);
const PRUnichar *unicodeBuf = tString.GetUnicode();
nsCOMPtr<nsIDOMNode> unused; nsCOMPtr<nsIDOMNode> unused;
PRInt32 pos = 0; PRInt32 pos = 0;
@ -586,11 +611,11 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
if (isPRE) if (isPRE)
{ {
char newlineChar = '\n'; char newlineChar = '\n';
while (unicodeBuf && (pos != -1) && ((PRUint32)pos < outString->Length())) while (unicodeBuf && (pos != -1) && ((PRUint32)pos < tString.Length()))
{ {
PRInt32 oldPos = pos; PRInt32 oldPos = pos;
PRInt32 subStrLen; PRInt32 subStrLen;
pos = outString->FindChar(newlineChar, PR_FALSE, oldPos); pos = tString.FindChar(newlineChar, PR_FALSE, oldPos);
if (pos != -1) if (pos != -1)
{ {
@ -601,8 +626,8 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
} }
else else
{ {
subStrLen = outString->Length() - oldPos; subStrLen = tString.Length() - oldPos;
pos = outString->Length(); pos = tString.Length();
} }
subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen); subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen);
@ -631,11 +656,11 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
{ {
char specialChars[] = {'\t','\n',0}; char specialChars[] = {'\t','\n',0};
nsAutoString tabString; tabString.AssignWithConversion(" "); nsAutoString tabString; tabString.AssignWithConversion(" ");
while (unicodeBuf && (pos != -1) && ((PRUint32)pos < outString->Length())) while (unicodeBuf && (pos != -1) && ((PRUint32)pos < tString.Length()))
{ {
PRInt32 oldPos = pos; PRInt32 oldPos = pos;
PRInt32 subStrLen; PRInt32 subStrLen;
pos = outString->FindCharInSet(specialChars, oldPos); pos = tString.FindCharInSet(specialChars, oldPos);
if (pos != -1) if (pos != -1)
{ {
@ -646,8 +671,8 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
} }
else else
{ {
subStrLen = outString->Length() - oldPos; subStrLen = tString.Length() - oldPos;
pos = outString->Length(); pos = tString.Length();
} }
subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen); subStr.Subsume((PRUnichar*)&unicodeBuf[oldPos], PR_FALSE, subStrLen);
@ -671,7 +696,10 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
} }
} }
if (curNode) aSelection->Collapse(curNode, curOffset); outString->Assign(tString);
if (curNode)
aSelection->Collapse(curNode, curOffset);
} }
return res; return res;
} }
@ -1018,8 +1046,8 @@ nsTextEditRules::DidRedo(nsISelection *aSelection, nsresult aResult)
nsresult nsresult
nsTextEditRules::WillOutputText(nsISelection *aSelection, nsTextEditRules::WillOutputText(nsISelection *aSelection,
const nsString *aOutputFormat, const nsAReadableString *aOutputFormat,
nsString *aOutString, nsAWritableString *aOutString,
PRBool *aCancel, PRBool *aCancel,
PRBool *aHandled) PRBool *aHandled)
{ {
@ -1031,7 +1059,9 @@ nsTextEditRules::WillOutputText(nsISelection *aSelection,
*aCancel = PR_FALSE; *aCancel = PR_FALSE;
*aHandled = PR_FALSE; *aHandled = PR_FALSE;
if (PR_TRUE == aOutputFormat->EqualsWithConversion("text/plain")) nsAutoString outputFormat(*aOutputFormat);
outputFormat.ToLowerCase();
if (outputFormat.Equals(NS_LITERAL_STRING("text/plain")))
{ // only use these rules for plain text output { // only use these rules for plain text output
if (mFlags & nsIPlaintextEditor::eEditorPasswordMask) if (mFlags & nsIPlaintextEditor::eEditorPasswordMask)
{ {
@ -1214,8 +1244,8 @@ nsTextEditRules::CreateBogusNodeIfNeeded(nsISelection *aSelection)
nsresult nsresult
nsTextEditRules::TruncateInsertionIfNeeded(nsISelection *aSelection, nsTextEditRules::TruncateInsertionIfNeeded(nsISelection *aSelection,
const nsString *aInString, const nsAReadableString *aInString,
nsString *aOutString, nsAWritableString *aOutString,
PRInt32 aMaxLength) PRInt32 aMaxLength)
{ {
if (!aSelection || !aInString || !aOutString) {return NS_ERROR_NULL_POINTER;} if (!aSelection || !aInString || !aOutString) {return NS_ERROR_NULL_POINTER;}
@ -1263,7 +1293,7 @@ nsTextEditRules::TruncateInsertionIfNeeded(nsISelection *aSelection,
nsresult nsresult
nsTextEditRules::EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsString *aOutString) nsTextEditRules::EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsAWritableString *aOutString)
{ {
if (!aOutString) {return NS_ERROR_NULL_POINTER;} if (!aOutString) {return NS_ERROR_NULL_POINTER;}
@ -1275,7 +1305,9 @@ nsTextEditRules::EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsString *a
PRInt32 i; PRInt32 i;
aOutString->SetLength(0); aOutString->SetLength(0);
for (i=0; i<length; i++) for (i=0; i<length; i++)
aOutString->AppendWithConversion('*'); {
aOutString->Append(PRUnichar('*'));
}
return NS_OK; return NS_OK;
} }

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

@ -92,8 +92,8 @@ protected:
nsISelection *aSelection, nsISelection *aSelection,
PRBool *aCancel, PRBool *aCancel,
PRBool *aHandled, PRBool *aHandled,
const nsString *inString, const nsAReadableString *inString,
nsString *outString, nsAWritableString *outString,
PRInt32 aMaxLength); PRInt32 aMaxLength);
nsresult DidInsertText(nsISelection *aSelection, nsresult aResult); nsresult DidInsertText(nsISelection *aSelection, nsresult aResult);
nsresult GetTopEnclosingPre(nsIDOMNode *aNode, nsIDOMNode** aOutPreNode); nsresult GetTopEnclosingPre(nsIDOMNode *aNode, nsIDOMNode** aOutPreNode);
@ -132,8 +132,8 @@ protected:
* and use aOutText as the result. * and use aOutText as the result.
*/ */
nsresult WillOutputText(nsISelection *aSelection, nsresult WillOutputText(nsISelection *aSelection,
const nsString *aInFormat, const nsAReadableString *aInFormat,
nsString *aOutText, nsAWritableString *aOutText,
PRBool *aOutCancel, PRBool *aOutCancel,
PRBool *aHandled); PRBool *aHandled);
@ -151,13 +151,13 @@ protected:
/** returns a truncated insertion string if insertion would place us /** returns a truncated insertion string if insertion would place us
over aMaxLength */ over aMaxLength */
nsresult TruncateInsertionIfNeeded(nsISelection *aSelection, nsresult TruncateInsertionIfNeeded(nsISelection *aSelection,
const nsString *aInString, const nsAReadableString *aInString,
nsString *aOutString, nsAWritableString *aOutString,
PRInt32 aMaxLength); PRInt32 aMaxLength);
/** Echo's the insertion text into the password buffer, and converts /** Echo's the insertion text into the password buffer, and converts
insertion text to '*'s */ insertion text to '*'s */
nsresult EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsString *aOutString); nsresult EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsAWritableString *aOutString);
nsresult CreateMozBR(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outBRNode); nsresult CreateMozBR(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outBRNode);
@ -200,9 +200,9 @@ class nsTextRulesInfo : public nsRulesInfo
virtual ~nsTextRulesInfo() {}; virtual ~nsTextRulesInfo() {};
// kInsertText // kInsertText
const nsString *inString; const nsAReadableString *inString;
nsString *outString; nsAWritableString *outString;
const nsString *outputFormat; const nsAReadableString *outputFormat;
PRInt32 maxLength; PRInt32 maxLength;
// kDeleteSelection // kDeleteSelection
@ -213,10 +213,10 @@ class nsTextRulesInfo : public nsRulesInfo
PRBool entireList; PRBool entireList;
// kAlign // kAlign
const nsString *alignType; const nsAReadableString *alignType;
// kMakeBasicBlock // kMakeBasicBlock
const nsString *blockType; const nsAReadableString *blockType;
// kInsertElement // kInsertElement
const nsIDOMElement* insertElement; const nsIDOMElement* insertElement;

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

@ -35,11 +35,11 @@ static NS_DEFINE_CID(kLWBrkCID, NS_LWBRK_CID);
* Rewrap the given section of string, putting the result in aOutString. * Rewrap the given section of string, putting the result in aOutString.
*/ */
nsresult nsresult
nsWrapUtils::Rewrap(const nsString& aInString, nsWrapUtils::Rewrap(const nsAReadableString& aInString,
PRUint32 aWrapCol, PRUint32 aFirstLineOffset, PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
PRBool aRespectNewlines, PRBool aRespectNewlines,
nsString aLineStartStr, const nsAReadableString &aLineStartStr,
nsString& aOutString) nsAWritableString& aOutString)
{ {
PRInt32 i; PRInt32 i;
@ -61,7 +61,8 @@ nsWrapUtils::Rewrap(const nsString& aInString,
// Now we either have a line breaker, or we don't. // Now we either have a line breaker, or we don't.
PRInt32 length = aInString.Length(); PRInt32 length = aInString.Length();
const PRUnichar* unicodeStr = aInString.GetUnicode(); nsString tString(aInString);
const PRUnichar* unicodeStr = tString.GetUnicode();
for (i = 0; i < length; ) // loop over lines for (i = 0; i < length; ) // loop over lines
{ {
nsAutoString remaining(unicodeStr + i, length - i); nsAutoString remaining(unicodeStr + i, length - i);
@ -75,7 +76,7 @@ nsWrapUtils::Rewrap(const nsString& aInString,
if (eol > length) if (eol > length)
{ {
aOutString.Append(unicodeStr + i, length - i); aOutString.Append(unicodeStr + i, length - i);
aOutString.AppendWithConversion('\n'); // DOM line breaks, not NS_LINEBREAK aOutString.Append(PRUnichar('\n')); // DOM line breaks, not NS_LINEBREAK
break; break;
} }
if (i > 0) aFirstLineOffset = 0; if (i > 0) aFirstLineOffset = 0;
@ -108,7 +109,7 @@ nsWrapUtils::Rewrap(const nsString& aInString,
else breakPt += i; else breakPt += i;
nsAutoString appending(unicodeStr + i, breakPt - i); nsAutoString appending(unicodeStr + i, breakPt - i);
aOutString.Append(unicodeStr + i, breakPt - i); aOutString.Append(unicodeStr + i, breakPt - i);
aOutString.AppendWithConversion('\n'); // DOM line breaks, not NS_LINEBREAK aOutString.Append(PRUnichar('\n')); // DOM line breaks, not NS_LINEBREAK
i = breakPt; i = breakPt;
} // continue looping over lines } // continue looping over lines

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

@ -30,11 +30,11 @@
class nsWrapUtils class nsWrapUtils
{ {
public: public:
static nsresult Rewrap(const nsString& aInString, static nsresult Rewrap(const nsAReadableString& aInString,
PRUint32 aWrapCol, PRUint32 aFirstLineOffset, PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
PRBool aRespectNewlines, PRBool aRespectNewlines,
nsString aLineStartStr, const nsAReadableString &aLineStartStr,
nsString& aOutString); nsAWritableString& aOutString);
}; };
#endif //nsWrapUtils_h__ #endif //nsWrapUtils_h__

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

@ -19,7 +19,7 @@
* *
* Contributor(s): * Contributor(s):
*/ */
#include "nsString.h"
#include "nsIEditActionListener.h" #include "nsIEditActionListener.h"
#include "nsTSDNotifier.h" #include "nsTSDNotifier.h"
#include "nsTextServicesDocument.h" #include "nsTextServicesDocument.h"
@ -173,25 +173,25 @@ nsTSDNotifier::DidJoinNodes(nsIDOMNode *aLeftNode,
// ------------------------------- // -------------------------------
NS_IMETHODIMP NS_IMETHODIMP
nsTSDNotifier::WillCreateNode(const nsString& aTag, nsIDOMNode *aParent, PRInt32 aPosition) nsTSDNotifier::WillCreateNode(const nsAReadableString& aTag, nsIDOMNode *aParent, PRInt32 aPosition)
{ {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsTSDNotifier::DidCreateNode(const nsString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult) nsTSDNotifier::DidCreateNode(const nsAReadableString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult)
{ {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsTSDNotifier::WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString) nsTSDNotifier::WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString)
{ {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsTSDNotifier::DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString, nsresult aResult) nsTSDNotifier::DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString, nsresult aResult)
{ {
return NS_OK; return NS_OK;
} }

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

@ -74,10 +74,10 @@ public:
nsIDOMNode *aParent, nsIDOMNode *aParent,
nsresult aResult); nsresult aResult);
// these listen methods are unused: // these listen methods are unused:
NS_IMETHOD WillCreateNode(const nsString& aTag, nsIDOMNode *aParent, PRInt32 aPosition); NS_IMETHOD WillCreateNode(const nsAReadableString& aTag, nsIDOMNode *aParent, PRInt32 aPosition);
NS_IMETHOD DidCreateNode(const nsString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult); NS_IMETHOD DidCreateNode(const nsAReadableString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult);
NS_IMETHOD WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString); NS_IMETHOD WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString);
NS_IMETHOD DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString, nsresult aResult); NS_IMETHOD DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString, nsresult aResult);
NS_IMETHOD WillDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength); NS_IMETHOD WillDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength);
NS_IMETHOD DidDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength, nsresult aResult); NS_IMETHOD DidDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength, nsresult aResult);
NS_IMETHOD WillDeleteSelection(nsISelection *aSelection); NS_IMETHOD WillDeleteSelection(nsISelection *aSelection);

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

@ -2074,7 +2074,7 @@ nsTextServicesDocument::InsertText(const nsString *aText)
nsCOMPtr<nsIPlaintextEditor> textEditor (do_QueryInterface(mEditor, &result)); nsCOMPtr<nsIPlaintextEditor> textEditor (do_QueryInterface(mEditor, &result));
if (textEditor) if (textEditor)
result = textEditor->InsertText(aText->GetUnicode()); result = textEditor->InsertText(*aText);
if (NS_FAILED(result)) if (NS_FAILED(result))
{ {

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

@ -29,16 +29,10 @@ include $(DEPTH)/config/autoconf.mk
MODULE = editor MODULE = editor
EXPORTS = \ EXPORTS = \
nsIEditActionListener.h \
nsIEditor.h \
nsEditorCID.h \ nsEditorCID.h \
nsICiter.h \
nsIEditorIMESupport.h \
nsIEditorLogging.h \ nsIEditorLogging.h \
nsIEditorMailSupport.h \ nsIEditorMailSupport.h \
nsIEditorObserver.h \
nsIEditorStyleSheets.h \ nsIEditorStyleSheets.h \
nsIHTMLEditor.h \
nsITableEditor.h \ nsITableEditor.h \
$(NULL) $(NULL)

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

@ -22,17 +22,11 @@
DEPTH=..\.. DEPTH=..\..
EXPORTS = \ EXPORTS = \
nsIEditActionListener.h \ nsEditorCID.h \
nsIEditor.h \
nsEditorCID.h \
nsICiter.h \
nsIEditorIMESupport.h \
nsIEditorLogging.h \ nsIEditorLogging.h \
nsIEditorMailSupport.h \ nsIEditorMailSupport.h \
nsIEditorObserver.h \
nsIEditorStyleSheets.h \ nsIEditorStyleSheets.h \
nsIHTMLEditor.h \
nsITableEditor.h \ nsITableEditor.h \
$(NULL) $(NULL)

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

@ -51,7 +51,7 @@ public:
* replacing the selected text (if any). * replacing the selected text (if any).
* @param aQuotedText The actual text to be quoted * @param aQuotedText The actual text to be quoted
*/ */
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, NS_IMETHOD InsertAsQuotation(const nsAReadableString& aQuotedText,
nsIDOMNode** aNodeInserted)=0; nsIDOMNode** aNodeInserted)=0;
/** Paste a string as quoted text, /** Paste a string as quoted text,
@ -60,7 +60,7 @@ public:
* @param aCitation The "mid" URL of the source message * @param aCitation The "mid" URL of the source message
* @param aSelectionType Text or html? * @param aSelectionType Text or html?
*/ */
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation, NS_IMETHOD PasteAsCitedQuotation(const nsAReadableString& aCitation,
PRInt32 aSelectionType)=0; PRInt32 aSelectionType)=0;
/** Insert a string as quoted text /** Insert a string as quoted text
@ -72,10 +72,10 @@ public:
* @param aInsertHTML Insert as html? (vs plaintext) * @param aInsertHTML Insert as html? (vs plaintext)
* @param aCharset The charset of the text to be inserted * @param aCharset The charset of the text to be inserted
*/ */
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, NS_IMETHOD InsertAsCitedQuotation(const nsAReadableString& aQuotedText,
const nsString& aCitation, const nsAReadableString& aCitation,
PRBool aInsertHTML, PRBool aInsertHTML,
const nsString& aCharset, const nsAReadableString& aCharset,
nsIDOMNode** aNodeInserted)=0; nsIDOMNode** aNodeInserted)=0;
/** /**

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

@ -46,7 +46,7 @@ public:
* @param aURL The style sheet to be loaded and applied. * @param aURL The style sheet to be loaded and applied.
* @param aStyleSheet Optional: if not null, return the style sheet created from aURL * @param aStyleSheet Optional: if not null, return the style sheet created from aURL
*/ */
NS_IMETHOD ApplyStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet)=0; NS_IMETHOD ApplyStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet)=0;
/** load and apply an Override style sheet, specified by aURL, to /** load and apply an Override style sheet, specified by aURL, to
* the editor's document. * the editor's document.
@ -61,7 +61,7 @@ public:
* @param aURL The style sheet to be loaded and applied. * @param aURL The style sheet to be loaded and applied.
* @param aStyleSheet Optional: if not null, return the style sheet created from aURL * @param aStyleSheet Optional: if not null, return the style sheet created from aURL
*/ */
NS_IMETHOD ApplyOverrideStyleSheet(const nsString& aURL, nsICSSStyleSheet **aStyleSheet)=0; NS_IMETHOD ApplyOverrideStyleSheet(const nsAReadableString& aURL, nsICSSStyleSheet **aStyleSheet)=0;
/** Add the given Style Sheet to the editor's document /** Add the given Style Sheet to the editor's document
* This is always synchronous * This is always synchronous

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

@ -19,7 +19,7 @@
* *
* Contributor(s): * Contributor(s):
*/ */
#include "nsString.h"
#include "nsIEditActionListener.h" #include "nsIEditActionListener.h"
#include "nsTSDNotifier.h" #include "nsTSDNotifier.h"
#include "nsTextServicesDocument.h" #include "nsTextServicesDocument.h"
@ -173,25 +173,25 @@ nsTSDNotifier::DidJoinNodes(nsIDOMNode *aLeftNode,
// ------------------------------- // -------------------------------
NS_IMETHODIMP NS_IMETHODIMP
nsTSDNotifier::WillCreateNode(const nsString& aTag, nsIDOMNode *aParent, PRInt32 aPosition) nsTSDNotifier::WillCreateNode(const nsAReadableString& aTag, nsIDOMNode *aParent, PRInt32 aPosition)
{ {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsTSDNotifier::DidCreateNode(const nsString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult) nsTSDNotifier::DidCreateNode(const nsAReadableString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult)
{ {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsTSDNotifier::WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString) nsTSDNotifier::WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString)
{ {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsTSDNotifier::DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString, nsresult aResult) nsTSDNotifier::DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString, nsresult aResult)
{ {
return NS_OK; return NS_OK;
} }

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

@ -74,10 +74,10 @@ public:
nsIDOMNode *aParent, nsIDOMNode *aParent,
nsresult aResult); nsresult aResult);
// these listen methods are unused: // these listen methods are unused:
NS_IMETHOD WillCreateNode(const nsString& aTag, nsIDOMNode *aParent, PRInt32 aPosition); NS_IMETHOD WillCreateNode(const nsAReadableString& aTag, nsIDOMNode *aParent, PRInt32 aPosition);
NS_IMETHOD DidCreateNode(const nsString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult); NS_IMETHOD DidCreateNode(const nsAReadableString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aPosition, nsresult aResult);
NS_IMETHOD WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString); NS_IMETHOD WillInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString);
NS_IMETHOD DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString, nsresult aResult); NS_IMETHOD DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsAReadableString &aString, nsresult aResult);
NS_IMETHOD WillDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength); NS_IMETHOD WillDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength);
NS_IMETHOD DidDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength, nsresult aResult); NS_IMETHOD DidDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength, nsresult aResult);
NS_IMETHOD WillDeleteSelection(nsISelection *aSelection); NS_IMETHOD WillDeleteSelection(nsISelection *aSelection);

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

@ -2074,7 +2074,7 @@ nsTextServicesDocument::InsertText(const nsString *aText)
nsCOMPtr<nsIPlaintextEditor> textEditor (do_QueryInterface(mEditor, &result)); nsCOMPtr<nsIPlaintextEditor> textEditor (do_QueryInterface(mEditor, &result));
if (textEditor) if (textEditor)
result = textEditor->InsertText(aText->GetUnicode()); result = textEditor->InsertText(*aText);
if (NS_FAILED(result)) if (NS_FAILED(result))
{ {