mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-28 21:28:55 +00:00
338759 Remove dead key event/text input code from widget/src/mac following bug 337199. r=josh a/1.8.1=me
This commit is contained in:
parent
50798069cc
commit
2e77381faf
@ -61,7 +61,7 @@ native OSStatus(OSStatus);
|
||||
*
|
||||
* @status UNDER_REVIEW
|
||||
*/
|
||||
[uuid(26f8f0a1-48b3-11d6-a15d-005004832142)]
|
||||
[uuid(87178C19-801F-4A21-A2F7-F453795C3F60)]
|
||||
interface nsIMacTextInputEventSink : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -71,17 +71,6 @@ interface nsIMacTextInputEventSink : nsISupports
|
||||
OSStatus HandleUpdateActiveInputArea(in AString text, in short script, in short language,
|
||||
in long fixLen, in voidPtr hiliteRng);
|
||||
|
||||
/**
|
||||
* Entry point for kEventTextInputUpdateActiveInputArea events into Gecko for Unicode Document
|
||||
* (need more work later to pass in optional in parameter updateRng, clauseRng, pinRng)
|
||||
*/
|
||||
|
||||
OSStatus HandleUpdateActiveInputAreaForNonUnicode ( in ACString text,
|
||||
in short script, in short language,
|
||||
in long fixLen,
|
||||
in voidPtr hiliteRng
|
||||
) ;
|
||||
|
||||
/**
|
||||
* Entry point for kEventTextInputUnicodeForKeyEvent events into Gecko for Unicode Document
|
||||
*
|
||||
|
@ -397,12 +397,6 @@ PRBool nsMacEventHandler::HandleOSEvent ( EventRecord& aOSEvent )
|
||||
|
||||
switch (aOSEvent.what)
|
||||
{
|
||||
case keyUp:
|
||||
case keyDown:
|
||||
case autoKey:
|
||||
retVal = HandleKeyEvent(aOSEvent);
|
||||
break;
|
||||
|
||||
case activateEvt:
|
||||
retVal = HandleActivateEvent(aOSEvent);
|
||||
break;
|
||||
@ -441,11 +435,6 @@ PRBool nsMacEventHandler::HandleOSEvent ( EventRecord& aOSEvent )
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case nullEvent:
|
||||
if (! sInBackground)
|
||||
retVal = HandleMouseMoveEvent(aOSEvent);
|
||||
break;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
@ -1011,85 +1000,6 @@ PRUint32 nsMacEventHandler::ConvertKeyEventToUnicode(EventRecord& aOSEvent)
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// HandleKeyEvent
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
PRBool nsMacEventHandler::HandleKeyEvent(EventRecord& aOSEvent)
|
||||
{
|
||||
nsresult result = NS_ERROR_UNEXPECTED;
|
||||
nsWindow* checkFocusedWidget;
|
||||
|
||||
// get the focused widget
|
||||
nsWindow* focusedWidget = gEventDispatchHandler.GetActive();
|
||||
if (!focusedWidget)
|
||||
focusedWidget = mTopLevelWidget;
|
||||
|
||||
// nsEvent
|
||||
switch (aOSEvent.what)
|
||||
{
|
||||
case keyUp:
|
||||
{
|
||||
nsKeyEvent keyUpEvent(PR_TRUE, NS_KEY_UP, nsnull);
|
||||
InitializeKeyEvent(keyUpEvent, aOSEvent, focusedWidget, NS_KEY_UP);
|
||||
result = focusedWidget->DispatchWindowEvent(keyUpEvent);
|
||||
break;
|
||||
}
|
||||
|
||||
case keyDown:
|
||||
{
|
||||
nsKeyEvent keyDownEvent(PR_TRUE, NS_KEY_DOWN, nsnull);
|
||||
nsKeyEvent keyPressEvent(PR_TRUE, NS_KEY_PRESS, nsnull);
|
||||
InitializeKeyEvent(keyDownEvent, aOSEvent, focusedWidget, NS_KEY_DOWN);
|
||||
result = focusedWidget->DispatchWindowEvent(keyDownEvent);
|
||||
|
||||
// get the focused widget again in case something happened to it on the previous event
|
||||
checkFocusedWidget = gEventDispatchHandler.GetActive();
|
||||
if (!checkFocusedWidget)
|
||||
checkFocusedWidget = mTopLevelWidget;
|
||||
|
||||
// if this isn't the same widget we had before, we should not send a keypress
|
||||
if (checkFocusedWidget != focusedWidget)
|
||||
return result;
|
||||
|
||||
InitializeKeyEvent(keyPressEvent, aOSEvent, focusedWidget, NS_KEY_PRESS);
|
||||
if (result) {
|
||||
// If keydown default was prevented, do same for keypress
|
||||
keyPressEvent.flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
||||
}
|
||||
|
||||
// before we dispatch this key, check if it's the contextmenu key.
|
||||
// If so, send a context menu event instead.
|
||||
if ( IsContextMenuKey(keyPressEvent) ) {
|
||||
nsMouseEvent contextMenuEvent(PR_TRUE, 0, nsnull,
|
||||
nsMouseEvent::eReal);
|
||||
ConvertKeyEventToContextMenuEvent(&keyPressEvent, &contextMenuEvent);
|
||||
result = focusedWidget->DispatchWindowEvent(contextMenuEvent);
|
||||
NS_ASSERTION(NS_SUCCEEDED(result), "cannot DispatchWindowEvent");
|
||||
}
|
||||
else {
|
||||
result = focusedWidget->DispatchWindowEvent(keyPressEvent);
|
||||
NS_ASSERTION(NS_SUCCEEDED(result), "cannot DispatchWindowEvent");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case autoKey:
|
||||
{
|
||||
nsKeyEvent keyPressEvent(PR_TRUE, NS_KEY_PRESS, nsnull);
|
||||
InitializeKeyEvent(keyPressEvent, aOSEvent, focusedWidget, NS_KEY_PRESS);
|
||||
result = focusedWidget->DispatchWindowEvent(keyPressEvent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// ConvertKeyEventToContextMenuEvent
|
||||
//
|
||||
@ -1162,7 +1072,7 @@ PRBool nsMacEventHandler::HandleUKeyEvent(const PRUnichar* text, long charCount,
|
||||
|
||||
// control key is special in that it doesn't give us letters
|
||||
// it generates a charcode of 0x01 for control-a
|
||||
// so we offset to do the right thing for gecko (as in HandleKeyEvent)
|
||||
// so we offset to do the right thing for gecko
|
||||
// this doesn't happen for us in InitializeKeyEvent because we pass
|
||||
// PR_FALSE so no character translation occurs.
|
||||
// I'm guessing we don't want to do the translation there because
|
||||
@ -1896,363 +1806,6 @@ nsresult nsMacEventHandler::HandleOffsetToPosition(long offset,Point* thePoint)
|
||||
// HandleUpdate Event
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
// See ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/APPLE/CORPCHAR.TXT for detail of IS_APPLE_HINT_IN_PRIVATE_ZONE
|
||||
#define IS_APPLE_HINT_IN_PRIVATE_ZONE(u) ((0xF850 <= (u)) && ((u)<=0xF883))
|
||||
nsresult nsMacEventHandler::HandleUpdateInputArea(const char* text,Size text_size, ScriptCode textScript,long fixedLength,TextRangeArray* textRangeList)
|
||||
{
|
||||
#ifdef DEBUG_TSM
|
||||
printf("********************************************************************************\n");
|
||||
printf("nsMacEventHandler::HandleUpdateInputArea size=%d fixlen=%d\n",text_size, fixedLength);
|
||||
#endif
|
||||
TextToUnicodeInfo textToUnicodeInfo;
|
||||
TextEncoding textEncodingFromScript;
|
||||
int i;
|
||||
OSErr err;
|
||||
ByteCount source_read;
|
||||
nsresult res = NS_OK;
|
||||
long committedLen = 0;
|
||||
PRUnichar* ubuf;
|
||||
|
||||
//====================================================================================================
|
||||
// 0. Create Unicode Converter
|
||||
//====================================================================================================
|
||||
|
||||
//
|
||||
// convert our script code to a TextEncoding
|
||||
//
|
||||
err = ::UpgradeScriptInfoToTextEncoding(textScript,kTextLanguageDontCare,kTextRegionDontCare,nsnull,
|
||||
&textEncodingFromScript);
|
||||
NS_ASSERTION(err==noErr,"nsMacEventHandler::UpdateInputArea: UpgradeScriptInfoToTextEncoding failed.");
|
||||
if (err!=noErr) {
|
||||
res = NS_ERROR_FAILURE;
|
||||
return res;
|
||||
}
|
||||
|
||||
err = ::CreateTextToUnicodeInfoByEncoding(textEncodingFromScript,&textToUnicodeInfo);
|
||||
NS_ASSERTION(err==noErr,"nsMacEventHandler::UpdateInputArea: CreateUnicodeToTextInfoByEncoding failed.");
|
||||
if (err!=noErr) {
|
||||
res = NS_ERROR_FAILURE;
|
||||
return res;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// if we aren't in composition mode alredy, signal the backing store w/ the mode change
|
||||
//------------------------------------------------------------------------------------------------
|
||||
if (!mIMEIsComposing) {
|
||||
res = HandleStartComposition();
|
||||
NS_ASSERTION(NS_SUCCEEDED(res),"nsMacEventHandler::UpdateInputArea: HandleStartComposition failed.");
|
||||
if(NS_FAILED(res))
|
||||
goto error;
|
||||
}
|
||||
// mIMECompositionStr should be created in the HandleStartComposition
|
||||
NS_ASSERTION(mIMECompositionStr, "do not have mIMECompositionStr");
|
||||
if(nsnull == mIMECompositionStr)
|
||||
{
|
||||
res = NS_ERROR_OUT_OF_MEMORY;
|
||||
goto error;
|
||||
}
|
||||
// Prepare buffer....
|
||||
mIMECompositionStr->SetCapacity(text_size+1);
|
||||
ubuf = mIMECompositionStr->BeginWriting();
|
||||
size_t len;
|
||||
|
||||
//====================================================================================================
|
||||
// Note- It is possible that the UnpdateInputArea event sent both committed text and uncommitted text
|
||||
// in the same time. The easies way to do that is using Korean input method w/ "Enter by Character" option
|
||||
//====================================================================================================
|
||||
// 1. Handle the committed text
|
||||
//====================================================================================================
|
||||
committedLen = (fixedLength == -1) ? text_size : fixedLength;
|
||||
if(0 != committedLen)
|
||||
{
|
||||
#ifdef DEBUG_TSM
|
||||
printf("Have commit text from 0 to %d\n",committedLen);
|
||||
#endif
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// 1.1 send textEvent to commit the text
|
||||
//------------------------------------------------------------------------------------------------
|
||||
len = 0;
|
||||
err = ::ConvertFromTextToUnicode(textToUnicodeInfo,committedLen,text,kUnicodeLooseMappingsMask,
|
||||
0,NULL,NULL,NULL,
|
||||
(text_size + 1) * sizeof(PRUnichar),
|
||||
&source_read,&len,NS_REINTERPRET_CAST(PRUint16*, ubuf));
|
||||
NS_ASSERTION(err==noErr,"nsMacEventHandler::UpdateInputArea: ConvertFromTextToUnicode failed.\n");
|
||||
if (err!=noErr)
|
||||
{
|
||||
res = NS_ERROR_FAILURE;
|
||||
goto error;
|
||||
}
|
||||
len /= sizeof(PRUnichar);
|
||||
// 1.2 Strip off the Apple Private U+F850-U+F87F ( source hint characters, transcodeing hints
|
||||
// Metric characters
|
||||
// See ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/APPLE/CORPCHAR.TXT for detail
|
||||
PRUint32 s,d;
|
||||
for(s=d=0;s<len;s++)
|
||||
{
|
||||
if(! IS_APPLE_HINT_IN_PRIVATE_ZONE(ubuf[s]))
|
||||
ubuf[d++] = ubuf[s];
|
||||
}
|
||||
len = d;
|
||||
ubuf[len] = '\0'; // null terminate
|
||||
mIMECompositionStr->SetLength(len);
|
||||
// for committed text, set no highlight ? (Do we need to set CaretPosition here ??? )
|
||||
#ifdef DEBUG_TSM
|
||||
printf("1.2====================================\n");
|
||||
#endif
|
||||
res = HandleTextEvent(0,nsnull);
|
||||
NS_ASSERTION(NS_SUCCEEDED(res),"nsMacEventHandler::UpdateInputArea: HandleTextEvent failed.");
|
||||
if(NS_FAILED(res))
|
||||
goto error;
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// 1.3 send compositionEvent to end the comosition
|
||||
//------------------------------------------------------------------------------------------------
|
||||
res = nsMacEventHandler::HandleEndComposition();
|
||||
NS_ASSERTION(NS_SUCCEEDED(res),"nsMacEventHandler::UpdateInputArea: HandleEndComposition failed.");
|
||||
if(NS_FAILED(res))
|
||||
goto error;
|
||||
} // 1. Handle the committed text
|
||||
|
||||
//====================================================================================================
|
||||
// 2. Handle the uncommitted text
|
||||
//====================================================================================================
|
||||
if((-1 != fixedLength) && (text_size != fixedLength ))
|
||||
{
|
||||
#ifdef DEBUG_TSM
|
||||
printf("Have new uncommited text from %d to text_size(%d)\n",committedLen,text_size);
|
||||
#endif
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// 2.1 send compositionEvent to start the comosition
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// if we aren't in composition mode alredy, signal the backing store w/ the mode change
|
||||
//
|
||||
if (!mIMEIsComposing) {
|
||||
res = HandleStartComposition();
|
||||
NS_ASSERTION(NS_SUCCEEDED(res),"nsMacEventHandler::UpdateInputArea: HandleStartComposition failed.");
|
||||
if(NS_FAILED(res))
|
||||
goto error;
|
||||
} // 2.1 send compositionEvent to start the comosition
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// 2.2 send textEvent for the uncommitted text
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// 2.2.1 make sure we have one range array
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
TextRangeArray rawTextRangeArray;
|
||||
TextRangeArray *rangeArray;
|
||||
if(textRangeList && textRangeList->fNumOfRanges ) {
|
||||
rangeArray = textRangeList;
|
||||
} else {
|
||||
rangeArray = &rawTextRangeArray;
|
||||
rawTextRangeArray.fNumOfRanges = 1;
|
||||
rawTextRangeArray.fRange[0].fStart = committedLen;
|
||||
rawTextRangeArray.fRange[0].fEnd = text_size;
|
||||
rawTextRangeArray.fRange[0].fHiliteStyle = NS_TEXTRANGE_RAWINPUT;
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG_TSM
|
||||
printf("nsMacEventHandler::HandleUpdateInputArea textRangeList is %s\n", textRangeList ? "NOT NULL" : "NULL");
|
||||
#endif
|
||||
nsTextRangeArray xpTextRangeArray = new nsTextRange[rangeArray->fNumOfRanges];
|
||||
NS_ASSERTION(xpTextRangeArray!=NULL,"nsMacEventHandler::UpdateInputArea: xpTextRangeArray memory allocation failed.");
|
||||
if (xpTextRangeArray==NULL)
|
||||
{
|
||||
res = NS_ERROR_OUT_OF_MEMORY;
|
||||
goto error;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// 2.2.2 convert range array into our xp range array
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// the TEC offset mapping capabilities won't work here because you need to have unique, ordered offsets
|
||||
// so instead we iterate over the range list and map each range individually. it's probably faster than
|
||||
// trying to do collapse all the ranges into a single offset list
|
||||
//
|
||||
for(i=0;i<rangeArray->fNumOfRanges;i++) {
|
||||
ByteOffset sourceOffset[2], destinationOffset[2];
|
||||
ItemCount destinationLength;
|
||||
// 2.2.2.1 check each range item in NS_ASSERTION
|
||||
NS_ASSERTION(
|
||||
(NS_TEXTRANGE_CARETPOSITION==rangeArray->fRange[i].fHiliteStyle)||
|
||||
(NS_TEXTRANGE_RAWINPUT==rangeArray->fRange[i].fHiliteStyle)||
|
||||
(NS_TEXTRANGE_SELECTEDRAWTEXT==rangeArray->fRange[i].fHiliteStyle)||
|
||||
(NS_TEXTRANGE_CONVERTEDTEXT==rangeArray->fRange[i].fHiliteStyle)||
|
||||
(NS_TEXTRANGE_SELECTEDCONVERTEDTEXT==rangeArray->fRange[i].fHiliteStyle),
|
||||
"illegal range type");
|
||||
NS_ASSERTION( rangeArray->fRange[i].fStart <= text_size,"illegal range");
|
||||
NS_ASSERTION( rangeArray->fRange[i].fEnd <= text_size,"illegal range");
|
||||
|
||||
#ifdef DEBUG_TSM
|
||||
printf("nsMacEventHandler::HandleUpdateInputArea textRangeList[%d] = (%d,%d) text_size = %d\n",i,
|
||||
rangeArray->fRange[i].fStart, rangeArray->fRange[i].fEnd, text_size);
|
||||
#endif
|
||||
// 2.2.2.2 fill sourceOffset array
|
||||
typedef enum {
|
||||
kEqualToDest0,
|
||||
kEqualToDest1,
|
||||
kEqualToLength
|
||||
} rangePairType;
|
||||
rangePairType tpStart,tpEnd;
|
||||
|
||||
if(rangeArray->fRange[i].fStart < text_size) {
|
||||
sourceOffset[0] = rangeArray->fRange[i].fStart-committedLen;
|
||||
tpStart = kEqualToDest0;
|
||||
destinationLength = 1;
|
||||
if(rangeArray->fRange[i].fStart == rangeArray->fRange[i].fEnd) {
|
||||
tpEnd = kEqualToDest0;
|
||||
} else if(rangeArray->fRange[i].fEnd < text_size) {
|
||||
sourceOffset[1] = rangeArray->fRange[i].fEnd-committedLen;
|
||||
tpEnd = kEqualToDest1;
|
||||
destinationLength++;
|
||||
} else {
|
||||
// fEnd >= text_size
|
||||
tpEnd = kEqualToLength;
|
||||
}
|
||||
} else {
|
||||
// fStart >= text_size
|
||||
tpStart = kEqualToLength;
|
||||
tpEnd = kEqualToLength;
|
||||
destinationLength = 0;
|
||||
} // if(rangeArray->fRange[i].fStart < text_size)
|
||||
|
||||
// 2.2.2.3 call unicode converter to convert the sourceOffset into destinationOffset
|
||||
len = 0;
|
||||
// Note : The TEC will return -50 if sourceOffset[0,1] >= text_size-committedLen
|
||||
err = ::ConvertFromTextToUnicode(textToUnicodeInfo,text_size-committedLen,text+committedLen,kUnicodeLooseMappingsMask,
|
||||
destinationLength,sourceOffset,&destinationLength,destinationOffset,
|
||||
(text_size + 1) * sizeof(PRUnichar),
|
||||
&source_read,&len, NS_REINTERPRET_CAST(PRUint16*, ubuf));
|
||||
NS_ASSERTION(err==noErr,"nsMacEventHandler::UpdateInputArea: ConvertFromTextToUnicode failed.\n");
|
||||
if (err!=noErr)
|
||||
{
|
||||
res = NS_ERROR_FAILURE;
|
||||
goto error;
|
||||
}
|
||||
// 2.2.2.4 Convert len, destinationOffset[0,1] into the unicode of PRUnichar.
|
||||
len /= sizeof(PRUnichar);
|
||||
if(destinationLength > 0 ){
|
||||
destinationOffset[0] /= sizeof(PRUnichar);
|
||||
if(destinationLength > 1 ) {
|
||||
destinationOffset[1] /= sizeof(PRUnichar);
|
||||
}
|
||||
}
|
||||
// 2.2.2.5 Strip off the Apple Private U+F850-U+F87F ( source hint characters, transcodeing hints
|
||||
// Metric characters
|
||||
// See ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/APPLE/CORPCHAR.TXT for detail
|
||||
// If we don't do this, Trad Chinese input method won't handle ',' correctly
|
||||
PRUint32 s,d;
|
||||
for(s=d=0;s<len;s++)
|
||||
{
|
||||
if(! IS_APPLE_HINT_IN_PRIVATE_ZONE(ubuf[s]))
|
||||
{
|
||||
ubuf[d++] = ubuf[s];
|
||||
}
|
||||
else
|
||||
{
|
||||
if(destinationLength > 0 ){
|
||||
if(destinationOffset[0] >= s) {
|
||||
destinationOffset[0]--;
|
||||
}
|
||||
if(destinationLength > 1 ) {
|
||||
if(destinationOffset[1] >= s) {
|
||||
destinationOffset[1]--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
len = d;
|
||||
|
||||
// 2.2.2.6 put destinationOffset into xpTextRangeArray[i].mStartOffset
|
||||
xpTextRangeArray[i].mRangeType = rangeArray->fRange[i].fHiliteStyle;
|
||||
switch(tpStart) {
|
||||
case kEqualToDest0:
|
||||
xpTextRangeArray[i].mStartOffset = destinationOffset[0];
|
||||
break;
|
||||
case kEqualToLength:
|
||||
xpTextRangeArray[i].mStartOffset = len;
|
||||
break;
|
||||
case kEqualToDest1:
|
||||
default:
|
||||
NS_ASSERTION(PR_FALSE, "tpStart is wrong");
|
||||
break;
|
||||
}
|
||||
switch(tpEnd) {
|
||||
case kEqualToDest0:
|
||||
xpTextRangeArray[i].mEndOffset = destinationOffset[0];
|
||||
break;
|
||||
case kEqualToDest1:
|
||||
xpTextRangeArray[i].mEndOffset = destinationOffset[1];
|
||||
break;
|
||||
case kEqualToLength:
|
||||
xpTextRangeArray[i].mEndOffset = len;
|
||||
break;
|
||||
default:
|
||||
NS_ASSERTION(PR_FALSE, "tpEnd is wrong");
|
||||
break;
|
||||
}
|
||||
// 2.2.2.7 Check the converted result in NS_ASSERTION
|
||||
NS_ASSERTION(xpTextRangeArray[i].mStartOffset <= len,"illegal range");
|
||||
NS_ASSERTION(xpTextRangeArray[i].mEndOffset <= len,"illegal range");
|
||||
#ifdef DEBUG_TSM
|
||||
printf("nsMacEventHandler::HandleUpdateInputArea textRangeList[%d] => type=%d (%d,%d)\n",i,
|
||||
xpTextRangeArray[i].mRangeType,
|
||||
xpTextRangeArray[i].mStartOffset, xpTextRangeArray[i].mEndOffset);
|
||||
#endif
|
||||
|
||||
NS_ASSERTION((NS_TEXTRANGE_CARETPOSITION!=xpTextRangeArray[i].mRangeType) ||
|
||||
(xpTextRangeArray[i].mStartOffset == xpTextRangeArray[i].mEndOffset),
|
||||
"start != end in CaretPosition");
|
||||
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// 2.2.3 null terminate the uncommitted text
|
||||
//------------------------------------------------------------------------------------------------
|
||||
mIMECompositionStr->SetLength(len);
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// 2.2.4 send the text event
|
||||
//------------------------------------------------------------------------------------------------
|
||||
#ifdef DEBUG_TSM
|
||||
printf("2.2.4====================================\n");
|
||||
#endif
|
||||
|
||||
res = HandleTextEvent(rangeArray->fNumOfRanges,xpTextRangeArray);
|
||||
NS_ASSERTION(NS_SUCCEEDED(res), "nsMacEventHandler::UpdateInputArea: HandleTextEvent failed.");
|
||||
if(NS_FAILED(res))
|
||||
goto error;
|
||||
if(xpTextRangeArray)
|
||||
delete [] xpTextRangeArray;
|
||||
} // 2. Handle the uncommitted text
|
||||
else if((0==text_size) && (0==fixedLength))
|
||||
{
|
||||
// 3. Handle empty text event
|
||||
// This is needed when we input some uncommitted text, and then delete all of them
|
||||
// When the last delete come, we will got a text_size = 0 and fixedLength = 0
|
||||
// In that case, we need to send a text event to clean un the input hole....
|
||||
mIMECompositionStr->SetLength(0);
|
||||
#ifdef DEBUG_TSM
|
||||
printf("3.====================================\n");
|
||||
#endif
|
||||
// 3.1 send the empty text event.
|
||||
res = HandleTextEvent(0,nsnull);
|
||||
NS_ASSERTION(NS_SUCCEEDED(res),"nsMacEventHandler::UpdateInputArea: HandleTextEvent failed.");
|
||||
if(NS_FAILED(res))
|
||||
goto error;
|
||||
// 3.2 send an endComposition event, we need this to make sure the delete after this work properly.
|
||||
res = nsMacEventHandler::HandleEndComposition();
|
||||
NS_ASSERTION(NS_SUCCEEDED(res),"nsMacEventHandler::UpdateInputArea: HandleEndComposition failed.");
|
||||
if(NS_FAILED(res))
|
||||
goto error;
|
||||
}
|
||||
return res;
|
||||
error:
|
||||
::DisposeTextToUnicodeInfo(&textToUnicodeInfo);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsMacEventHandler::UnicodeHandleUpdateInputArea(const PRUnichar* text, long charCount,
|
||||
long fixedLength, TextRangeArray* textRangeList)
|
||||
{
|
||||
|
@ -126,7 +126,6 @@ public:
|
||||
//
|
||||
virtual long HandlePositionToOffset(Point aPoint,short* regionClass);
|
||||
virtual nsresult HandleOffsetToPosition(long offset,Point* position);
|
||||
virtual nsresult HandleUpdateInputArea(const char* text,Size text_size, ScriptCode textScript,long fixedLength,TextRangeArray* textRangeArray);
|
||||
virtual nsresult UnicodeHandleUpdateInputArea(const PRUnichar* text, long charCount, long fixedLength,TextRangeArray* textRangeArray);
|
||||
virtual nsresult HandleUnicodeGetSelectedText(nsAString& outString);
|
||||
virtual nsresult ResetInputState();
|
||||
@ -150,7 +149,6 @@ protected:
|
||||
virtual PRBool IsSpecialRaptorKey(UInt32 macKeyCode);
|
||||
virtual PRUint32 ConvertKeyEventToUnicode(EventRecord& aOSEvent);
|
||||
#endif
|
||||
virtual PRBool HandleKeyEvent(EventRecord& aOSEvent);
|
||||
virtual PRBool HandleActivateEvent(EventRecord& aOSEvent);
|
||||
virtual PRBool HandleMouseDownEvent(EventRecord& aOSEvent);
|
||||
virtual PRBool HandleMouseUpEvent(EventRecord& aOSEvent);
|
||||
|
@ -72,21 +72,15 @@ nsMacMessagePump::nsMacMessagePump(nsToolkit *aToolkit)
|
||||
{
|
||||
NS_ASSERTION(mToolkit, "No toolkit");
|
||||
|
||||
// This list encompasses all Carbon events that can be converted into
|
||||
// EventRecords. Not all will necessarily be called; not all will necessarily
|
||||
// be handled. Some items here may be redundant in that handlers are already
|
||||
// installed elsewhere. This may need a good audit.
|
||||
// This list encompasses Carbon events that can be converted into
|
||||
// EventRecords, and that still require dispatch through
|
||||
// nsMacMessagePump::DispatchEvent because they haven't yet been converted
|
||||
// completetly to Carbon events.
|
||||
const EventTypeSpec kWNETransitionEventList[] = {
|
||||
{ kEventClassMouse, kEventMouseDown },
|
||||
{ kEventClassMouse, kEventMouseUp },
|
||||
{ kEventClassMouse, kEventMouseMoved },
|
||||
{ kEventClassMouse, kEventMouseDragged },
|
||||
#if 0
|
||||
// These are now handled by nsMacWindow::KeyEventHandler
|
||||
{ kEventClassKeyboard, kEventRawKeyDown },
|
||||
{ kEventClassKeyboard, kEventRawKeyUp },
|
||||
{ kEventClassKeyboard, kEventRawKeyRepeat },
|
||||
#endif
|
||||
{ kEventClassWindow, kEventWindowUpdate },
|
||||
{ kEventClassWindow, kEventWindowActivated },
|
||||
{ kEventClassWindow, kEventWindowDeactivated },
|
||||
@ -161,12 +155,8 @@ PRBool nsMacMessagePump::DispatchEvent(EventRecord *anEvent)
|
||||
|
||||
switch(anEvent->what) {
|
||||
// diskEvt is gone in Carbon, and so is unhandled here.
|
||||
|
||||
case keyUp:
|
||||
case keyDown:
|
||||
case autoKey:
|
||||
handled = DoKey(*anEvent);
|
||||
break;
|
||||
// keyUp, keyDown, and autoKey now have Carbon event handlers in
|
||||
// nsMacWindow.
|
||||
|
||||
case mouseDown:
|
||||
handled = DoMouseDown(*anEvent);
|
||||
@ -467,20 +457,6 @@ PRBool nsMacMessagePump::DoMouseMove(EventRecord &anEvent)
|
||||
return handled;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// DoKey
|
||||
//
|
||||
// This is called for keydown, keyup, and key repeating events. So we need
|
||||
// to be careful not to do things twice.
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsMacMessagePump::DoKey(EventRecord &anEvent)
|
||||
{
|
||||
PRBool handled = PR_FALSE;
|
||||
handled = DispatchOSEventToRaptor(anEvent, ::FrontWindow());
|
||||
return handled;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// DoActivate
|
||||
|
@ -68,7 +68,6 @@ class nsMacMessagePump
|
||||
PRBool DoMouseUp(EventRecord &anEvent);
|
||||
PRBool DoMouseMove(EventRecord &anEvent);
|
||||
PRBool DoUpdate(EventRecord &anEvent);
|
||||
PRBool DoKey(EventRecord &anEvent);
|
||||
PRBool DoActivate(EventRecord &anEvent);
|
||||
|
||||
PRBool DispatchOSEventToRaptor(EventRecord &anEvent, WindowPtr aWindow);
|
||||
|
@ -248,116 +248,6 @@ pascal OSErr nsMacTSMMessagePump::OffsetToPositionHandler(const AppleEvent *theA
|
||||
|
||||
return noErr;
|
||||
}
|
||||
pascal OSErr nsMacTSMMessagePump::UpdateHandler(const AppleEvent *theAppleEvent, AppleEvent *reply, long handlerRefcon)
|
||||
{
|
||||
OSErr err;
|
||||
DescType returnedType;
|
||||
nsMacEventHandler* eventHandler;
|
||||
Size actualSize;
|
||||
AEDesc text, hiliteRangeArray;
|
||||
ScriptCode textScript;
|
||||
long fixLength;
|
||||
nsresult res;
|
||||
TextRangeArray* hiliteRangePtr;
|
||||
|
||||
|
||||
//
|
||||
// refcon stores the nsMacEventHandler
|
||||
//
|
||||
err = AEGetParamPtr(theAppleEvent, keyAETSMDocumentRefcon, typeLongInteger, &returnedType,
|
||||
&eventHandler, sizeof(eventHandler), &actualSize);
|
||||
NS_ASSERTION(err==noErr, "nsMacTSMMessagePump::UpdateHandler: AEGetParamPtr[TSMRefcon] failed.");
|
||||
if (err!=noErr)
|
||||
return err;
|
||||
|
||||
//
|
||||
// IME update text
|
||||
//
|
||||
err = AEGetParamDesc(theAppleEvent, keyAETheData, typeChar, &text);
|
||||
NS_ASSERTION(err==noErr, "nsMacTSMMessagePump::UpdateHandler: AEGetParamDesc[Text] failed.");
|
||||
if (err!=noErr)
|
||||
return err;
|
||||
|
||||
//
|
||||
// get the script of text for Unicode conversion
|
||||
//
|
||||
textScript=smUninterp;
|
||||
AEDesc slr;
|
||||
err = AEGetParamDesc(theAppleEvent, keyAETSMScriptTag, typeIntlWritingCode, &slr);
|
||||
NS_ASSERTION(err==noErr, "nsMacTSMMessagePump::UpdateHandler: AEGetParamDesc[keyAETSMScriptTag] failed.");
|
||||
if (err!=noErr)
|
||||
return err;
|
||||
|
||||
|
||||
ScriptLanguageRecord scriptLangRec;
|
||||
err = AEGetDescData(&slr, (void *) &scriptLangRec, sizeof(ScriptLanguageRecord));
|
||||
if (err!=noErr)
|
||||
return err;
|
||||
textScript = scriptLangRec.fScript;
|
||||
NS_ASSERTION( (textScript < smUninterp), "Illegal script code");
|
||||
|
||||
NS_ASSERTION(textScript == (ScriptCode)::GetScriptManagerVariable(smKeyScript) , "wrong script code");
|
||||
//
|
||||
// length of converted text
|
||||
//
|
||||
err = AEGetParamPtr(theAppleEvent, keyAEFixLength, typeLongInteger, &returnedType,
|
||||
&fixLength, sizeof(fixLength), &actualSize);
|
||||
NS_ASSERTION(err==noErr, "nsMacTSMMessagePump::UpdateHandler: AEGetParamPtr[fixlen] failed.");
|
||||
if (err!=noErr)
|
||||
return err;
|
||||
|
||||
//
|
||||
// extract the hilite ranges (optional param)
|
||||
//
|
||||
err = AEGetParamDesc(theAppleEvent, keyAEHiliteRange, typeTextRangeArray, &hiliteRangeArray);
|
||||
NS_ASSERTION(err==noErr||err==errAEDescNotFound, "nsMacTSMMessagePump::UpdateHandler: AEGetParamPtr[fixlen] failed.");
|
||||
if (err==errAEDescNotFound) {
|
||||
hiliteRangePtr=NULL;
|
||||
} else if (err==noErr) {
|
||||
Size hiliteRangeSize = ::AEGetDescDataSize(&hiliteRangeArray);
|
||||
hiliteRangePtr = (TextRangeArray *) NewPtr(hiliteRangeSize);
|
||||
if (!hiliteRangePtr)
|
||||
return MemError();
|
||||
err = AEGetDescData(&hiliteRangeArray, (void *) hiliteRangePtr, hiliteRangeSize);
|
||||
if (err!=noErr) {
|
||||
DisposePtr((Ptr) hiliteRangePtr);
|
||||
return err;
|
||||
}
|
||||
} else {
|
||||
return err;
|
||||
}
|
||||
|
||||
nsCAutoString mbcsText;
|
||||
Size text_size = ::AEGetDescDataSize(&text);
|
||||
mbcsText.SetCapacity(text_size+1);
|
||||
char* mbcsTextPtr = mbcsText.BeginWriting();
|
||||
err = AEGetDescData(&text, (void *) mbcsTextPtr, text_size);
|
||||
if (err!=noErr) {
|
||||
DisposePtr((Ptr) hiliteRangePtr);
|
||||
return err;
|
||||
}
|
||||
mbcsTextPtr[text_size]=0;
|
||||
|
||||
//
|
||||
// must pass HandleUpdateInputArea a null-terminated multibyte string, the text size must include the terminator
|
||||
//
|
||||
res = eventHandler->HandleUpdateInputArea(mbcsTextPtr, text_size, textScript, fixLength, hiliteRangePtr);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(res), "nsMacMessagePump::UpdateHandler: HandleUpdated failed.");
|
||||
if (NS_FAILED(res))
|
||||
err = paramErr;
|
||||
|
||||
//
|
||||
// clean up
|
||||
//
|
||||
if (hiliteRangePtr)
|
||||
DisposePtr((Ptr) hiliteRangePtr);
|
||||
|
||||
(void)AEDisposeDesc(&text);
|
||||
(void)AEDisposeDesc(&hiliteRangeArray);
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
||||
static OSErr GetAppleEventTSMData(const AppleEvent *inAE, nsMacEventHandler **outEventHandler, AEDesc *outText)
|
||||
{
|
||||
|
@ -62,7 +62,6 @@ public:
|
||||
private:
|
||||
static pascal OSErr PositionToOffsetHandler(const AppleEvent *theAppleEvent, AppleEvent *reply, long handlerRefcon);
|
||||
static pascal OSErr OffsetToPositionHandler(const AppleEvent *theAppleEvent, AppleEvent *reply, long handlerRefcon);
|
||||
static pascal OSErr UpdateHandler(const AppleEvent *theAppleEvent, AppleEvent *reply, long handlerRefcon);
|
||||
static pascal OSErr UnicodeUpdateHandler(const AppleEvent *theAppleEvent, AppleEvent *reply, long handlerRefcon);
|
||||
static pascal OSErr UnicodeNotFromInputMethodHandler(const AppleEvent *theAppleEvent, AppleEvent *reply, long handlerRefcon);
|
||||
static pascal OSErr UnicodeGetSelectedTextHandler(const AppleEvent *theAppleEvent, AppleEvent *reply, long handlerRefcon);
|
||||
|
@ -1755,24 +1755,6 @@ nsMacWindow::HandleUpdateActiveInputArea(const nsAString & text,
|
||||
return res;
|
||||
}
|
||||
|
||||
/* OSStatus HandleUpdateActiveInputAreaForNonUnicode (in string text, in long textLength, in short script, in short language, in long fixLen, in voidPtr hiliteRng); */
|
||||
NS_IMETHODIMP
|
||||
nsMacWindow::HandleUpdateActiveInputAreaForNonUnicode(const nsACString & text,
|
||||
PRInt16 script, PRInt16 language,
|
||||
PRInt32 fixLen, void * hiliteRng,
|
||||
OSStatus *_retval)
|
||||
{
|
||||
*_retval = eventNotHandledErr;
|
||||
NS_ENSURE_TRUE(mMacEventHandler.get(), NS_ERROR_FAILURE);
|
||||
const nsPromiseFlatCString& buffer = PromiseFlatCString(text);
|
||||
// ignore language information for now.
|
||||
nsresult res = mMacEventHandler->HandleUpdateInputArea(buffer.get(), buffer.Length(), script, fixLen, (TextRangeArray*) hiliteRng);
|
||||
// we will lost the real OSStatus for now untill we change the nsMacEventHandler
|
||||
if (NS_SUCCEEDED(res))
|
||||
*_retval = noErr;
|
||||
return res;
|
||||
}
|
||||
|
||||
/* OSStatus HandleUnicodeForKeyEvent (in wstring text, in long textLength, in short script, in short language, in voidPtr keyboardEvent); */
|
||||
NS_IMETHODIMP
|
||||
nsMacWindow::HandleUnicodeForKeyEvent(const nsAString & text,
|
||||
|
Loading…
x
Reference in New Issue
Block a user