Replace convertLocation with other ways of doing the same thing. The name didn't make much sense, the code was messy, and it was inefficient. b=371902 r=smorgan sr=pav
git-svn-id: svn://10.0.0.236/trunk@221024 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -109,8 +109,6 @@ nsIWidget * gRollupWidget = nsnull;
|
||||
|
||||
// create a gecko key event out of a cocoa event
|
||||
- (void) convertKeyEvent:(NSEvent*)aKeyEvent toGeckoEvent:(nsKeyEvent*)outGeckoEvent;
|
||||
- (void) convertLocation:(NSPoint)inPoint modifiers:(unsigned int)inMods
|
||||
toGeckoEvent:(nsInputEvent*)outGeckoEvent;
|
||||
|
||||
- (NSMenu*)contextMenu;
|
||||
- (TopLevelWindowData*)ensureWindowData;
|
||||
@@ -1603,7 +1601,7 @@ nsChildView::GetChildViewQuickDrawPort()
|
||||
|
||||
// Handle an event coming into us and send it to gecko.
|
||||
NS_IMETHODIMP
|
||||
nsChildView::DispatchEvent ( void* anEvent, PRBool *_retval )
|
||||
nsChildView::DispatchEvent(void* anEvent, PRBool *_retval)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1625,22 +1623,22 @@ nsChildView::DragEvent(PRUint32 aMessage, PRInt16 aMouseGlobalX, PRInt16 aMouseG
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// set up gecko event
|
||||
nsMouseEvent geckoEvent(PR_TRUE, aMessage, nsnull, nsMouseEvent::eReal);
|
||||
|
||||
// we're given the point in global coordinates. We need to convert it to
|
||||
// window coordinates for convert:message:toGeckoEvent
|
||||
[(ChildView*)mView convertEvent:nil toGeckoEvent:&geckoEvent];
|
||||
|
||||
NSPoint dragLoc = NSMakePoint(aMouseGlobalX, aMouseGlobalY);
|
||||
FlipCocoaScreenCoordinate(dragLoc);
|
||||
|
||||
// convert to window coords
|
||||
dragLoc = [[mView window] convertScreenToBase:dragLoc];
|
||||
// and fill in the event
|
||||
[(ChildView*)mView convertLocation:dragLoc modifiers:0 toGeckoEvent:&geckoEvent];
|
||||
// Use our own coordinates in the gecko event.
|
||||
// Convert event from gecko global coords to gecko view coords.
|
||||
NSPoint localPoint = NSMakePoint(aMouseGlobalX, aMouseGlobalY);
|
||||
FlipCocoaScreenCoordinate(localPoint);
|
||||
localPoint = [[mView window] convertScreenToBase:localPoint];
|
||||
localPoint = [mView convertPoint:localPoint fromView:nil];
|
||||
geckoEvent.refPoint.x = NS_STATIC_CAST(nscoord, localPoint.x);
|
||||
geckoEvent.refPoint.y = NS_STATIC_CAST(nscoord, localPoint.y);
|
||||
|
||||
DispatchWindowEvent(geckoEvent);
|
||||
|
||||
|
||||
// we handled the event
|
||||
*_retval = PR_TRUE;
|
||||
return NS_OK;
|
||||
@@ -2737,38 +2735,33 @@ static nsEventStatus SendMouseEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w
|
||||
}
|
||||
|
||||
|
||||
// convert from one event system to the other for event dispatching
|
||||
// Set up a gecko event possibly based on a native event.
|
||||
// Note that it is OK for inEvent to be nil - do a check if you need it!
|
||||
- (void) convertEvent:(NSEvent*)inEvent toGeckoEvent:(nsInputEvent*)outGeckoEvent
|
||||
{
|
||||
outGeckoEvent->nativeMsg = inEvent;
|
||||
[self convertLocation:[inEvent locationInWindow] modifiers:[inEvent modifierFlags]
|
||||
toGeckoEvent:outGeckoEvent];
|
||||
}
|
||||
|
||||
|
||||
- (void) convertLocation:(NSPoint)inPoint modifiers:(unsigned int)inMods toGeckoEvent:(nsInputEvent*)outGeckoEvent
|
||||
{
|
||||
outGeckoEvent->widget = [self widget];
|
||||
outGeckoEvent->time = PR_IntervalNow();
|
||||
|
||||
if (outGeckoEvent->eventStructType != NS_KEY_EVENT) {
|
||||
NSPoint mouseLoc = inPoint;
|
||||
|
||||
// convert point to view coordinate system
|
||||
NSPoint localPoint = [self convertPoint:mouseLoc fromView:nil];
|
||||
|
||||
outGeckoEvent->refPoint.x = NS_STATIC_CAST(nscoord, localPoint.x);
|
||||
outGeckoEvent->refPoint.y = NS_STATIC_CAST(nscoord, localPoint.y);
|
||||
outGeckoEvent->nativeMsg = inEvent;
|
||||
|
||||
if (inEvent) {
|
||||
// set up event location
|
||||
if (outGeckoEvent->eventStructType != NS_KEY_EVENT) {
|
||||
// convert point to view coordinate system
|
||||
NSPoint localPoint = [self convertPoint:[inEvent locationInWindow] fromView:nil];
|
||||
outGeckoEvent->refPoint.x = NS_STATIC_CAST(nscoord, localPoint.x);
|
||||
outGeckoEvent->refPoint.y = NS_STATIC_CAST(nscoord, localPoint.y);
|
||||
}
|
||||
|
||||
// set up modifier keys
|
||||
unsigned int modifiers = [inEvent modifierFlags];
|
||||
outGeckoEvent->isShift = ((modifiers & NSShiftKeyMask) != 0);
|
||||
outGeckoEvent->isControl = ((modifiers & NSControlKeyMask) != 0);
|
||||
outGeckoEvent->isAlt = ((modifiers & NSAlternateKeyMask) != 0);
|
||||
outGeckoEvent->isMeta = ((modifiers & NSCommandKeyMask) != 0);
|
||||
}
|
||||
|
||||
// set up modifier keys
|
||||
outGeckoEvent->isShift = ((inMods & NSShiftKeyMask) != 0);
|
||||
outGeckoEvent->isControl = ((inMods & NSControlKeyMask) != 0);
|
||||
outGeckoEvent->isAlt = ((inMods & NSAlternateKeyMask) != 0);
|
||||
outGeckoEvent->isMeta = ((inMods & NSCommandKeyMask) != 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static PRBool ConvertUnicodeToCharCode(PRUnichar inUniChar, unsigned char* outChar)
|
||||
{
|
||||
UnicodeToTextInfo converterInfo;
|
||||
|
||||
Reference in New Issue
Block a user