Bug 751785 - Make Selection.toString() API use DOMString instead of wstring

This commit is contained in:
Jignesh Kakadiya 2012-06-09 15:15:12 -07:00
parent 710953df6a
commit 2f9b3165ba
3 changed files with 10 additions and 19 deletions

View File

@ -18,7 +18,7 @@ interface nsINode;
* @version 1.0
*/
[scriptable, uuid(dd40d5b8-1fe1-487f-b66e-28f4b837024f)]
[scriptable, uuid(12cf5a4d-fffb-4f2f-9cec-c65195661d76)]
interface nsISelection : nsISupports
{
/**
@ -135,8 +135,8 @@ interface nsISelection : nsISupports
/**
* Returns the whole selection into a plain text string.
*/
wstring toString();
DOMString toString();
/**
* Modifies the selection. Note that the parameters are case-insensitive.
*

View File

@ -34,7 +34,7 @@ struct ScrollAxis;
native nsDirection(nsDirection);
native ScrollAxis(nsIPresShell::ScrollAxis);
[scriptable, uuid(719a803f-aa1e-436c-8919-c42908f00599)]
[scriptable, uuid(3a1a6d3b-3698-4561-ba00-ba648cb2b0d4)]
interface nsISelectionPrivate : nsISelection
{
const short ENDOFPRECEDINGLINE=0;
@ -53,7 +53,7 @@ interface nsISelectionPrivate : nsISelection
void endBatchChanges();
nsIEnumerator getEnumerator();
wstring toStringWithFormat(in string formatType, in unsigned long flags, in PRInt32 wrapColumn);
DOMString toStringWithFormat(in string formatType, in unsigned long flags, in PRInt32 wrapColumn);
void addSelectionListener(in nsISelectionListener newListener);
void removeSelectionListener(in nsISelectionListener listenerToRemove);

View File

@ -1087,18 +1087,15 @@ nsFrameSelection::MoveCaret(PRUint32 aKeycode,
//BEGIN nsFrameSelection methods
NS_IMETHODIMP
nsTypedSelection::ToString(PRUnichar **aReturn)
nsTypedSelection::ToString(nsAString& aReturn)
{
if (!aReturn) {
return NS_ERROR_NULL_POINTER;
}
// We need Flush_Style here to make sure frames have been created for
// the selected content. Use mFrameSelection->GetShell() which returns
// null if the Selection has been disconnected (the shell is Destroyed).
nsCOMPtr<nsIPresShell> shell =
mFrameSelection ? mFrameSelection->GetShell() : nsnull;
if (!shell) {
*aReturn = ToNewUnicode(EmptyString());
aReturn.Truncate();
return NS_OK;
}
shell->FlushPendingNotifications(Flush_Style);
@ -1109,13 +1106,10 @@ nsTypedSelection::ToString(PRUnichar **aReturn)
}
NS_IMETHODIMP
nsTypedSelection::ToStringWithFormat(const char * aFormatType, PRUint32 aFlags,
PRInt32 aWrapCol, PRUnichar **aReturn)
nsTypedSelection::ToStringWithFormat(const char * aFormatType, PRUint32 aFlags,
PRInt32 aWrapCol, nsAString& aReturn)
{
nsresult rv = NS_OK;
if (!aReturn)
return NS_ERROR_NULL_POINTER;
nsCAutoString formatType( NS_DOC_ENCODER_CONTRACTID_BASE );
formatType.Append(aFormatType);
nsCOMPtr<nsIDocumentEncoder> encoder =
@ -1145,10 +1139,7 @@ nsTypedSelection::ToStringWithFormat(const char * aFormatType, PRUint32 aFlags,
if (aWrapCol != 0)
encoder->SetWrapColumn(aWrapCol);
nsAutoString tmp;
rv = encoder->EncodeToString(tmp);
*aReturn = ToNewUnicode(tmp);//get the unicode pointer from it. this is temporary
return rv;
return encoder->EncodeToString(aReturn);
}
NS_IMETHODIMP