зеркало из https://github.com/mozilla/gecko-dev.git
fix problem where SetText would truncate text to 255.
This commit is contained in:
Родитель
ecb91bfb05
Коммит
901eaba192
|
@ -22,7 +22,7 @@
|
||||||
#include "nsColor.h"
|
#include "nsColor.h"
|
||||||
#include "nsGUIEvent.h"
|
#include "nsGUIEvent.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#define DBG 0
|
#define DBG 0
|
||||||
|
|
||||||
|
@ -449,23 +449,28 @@ LongRect macRect;
|
||||||
*/
|
*/
|
||||||
PRUint32 nsTextAreaWidget::SetText(const nsString& aText, PRUint32& aSize)
|
PRUint32 nsTextAreaWidget::SetText(const nsString& aText, PRUint32& aSize)
|
||||||
{
|
{
|
||||||
char buffer[256];
|
|
||||||
PRInt32 len;
|
|
||||||
PRInt32 offx,offy;
|
PRInt32 offx,offy;
|
||||||
GrafPtr theport;
|
GrafPtr theport;
|
||||||
|
|
||||||
|
Size textSize = aText.Length();
|
||||||
|
if ( aSize < textSize ) // truncate to given size
|
||||||
|
textSize = aSize;
|
||||||
|
const unsigned int bufferSize = textSize + 1; // add 1 for null
|
||||||
|
|
||||||
CalcOffset(offx,offy);
|
CalcOffset(offx,offy);
|
||||||
::GetPort(&theport);
|
::GetPort(&theport);
|
||||||
::SetPort(mWindowPtr);
|
::SetPort(mWindowPtr);
|
||||||
//::SetOrigin(-offx,-offy);
|
//::SetOrigin(-offx,-offy);
|
||||||
|
|
||||||
this->RemoveText();
|
this->RemoveText();
|
||||||
aText.ToCString(buffer,255);
|
auto_ptr<char> buffer ( new char[bufferSize] );
|
||||||
len = strlen(buffer);
|
if ( buffer.get() ) {
|
||||||
|
aText.ToCString(buffer.get(),bufferSize);
|
||||||
WEInsert(buffer,len,0,0,mTE_Data);
|
WEInsert(buffer.get(),aSize,0,0,mTE_Data);
|
||||||
|
}
|
||||||
aSize = len;
|
else
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
//::SetOrigin(0,0);
|
//::SetOrigin(0,0);
|
||||||
::SetPort(theport);
|
::SetPort(theport);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче