Simple removal of a couple of scope levels in Mac OS X object frame event handling code. No bug. r=roc

This commit is contained in:
Josh Aas 2010-05-26 20:19:13 -04:00
Родитель cc2978a0dd
Коммит 5967cfb1cf
1 изменённых файлов: 124 добавлений и 122 удалений

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

@ -4426,156 +4426,158 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent)
return nsEventStatus_eIgnore;
#ifdef XP_MACOSX
if (mWidget) {
// we never care about synthesized mouse enter
if (anEvent.message == NS_MOUSE_ENTER_SYNTH)
return nsEventStatus_eIgnore;
if (!mWidget)
return nsEventStatus_eIgnore;
nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
if (pluginWidget && NS_SUCCEEDED(pluginWidget->StartDrawPlugin())) {
NPEventModel eventModel = GetEventModel();
// we never care about synthesized mouse enter
if (anEvent.message == NS_MOUSE_ENTER_SYNTH)
return nsEventStatus_eIgnore;
// If we have to synthesize an event we'll use one of these.
nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
if (!pluginWidget || NS_FAILED(pluginWidget->StartDrawPlugin()))
return nsEventStatus_eIgnore;
NPEventModel eventModel = GetEventModel();
// If we have to synthesize an event we'll use one of these.
#ifndef NP_NO_CARBON
EventRecord synthCarbonEvent;
EventRecord synthCarbonEvent;
#endif
NPCocoaEvent synthCocoaEvent;
void* event = anEvent.pluginEvent;
nsPoint pt =
nsLayoutUtils::GetEventCoordinatesRelativeTo(&anEvent, mObjectFrame) -
mObjectFrame->GetUsedBorderAndPadding().TopLeft();
nsPresContext* presContext = mObjectFrame->PresContext();
nsIntPoint ptPx(presContext->AppUnitsToDevPixels(pt.x),
presContext->AppUnitsToDevPixels(pt.y));
NPCocoaEvent synthCocoaEvent;
void* event = anEvent.pluginEvent;
nsPoint pt =
nsLayoutUtils::GetEventCoordinatesRelativeTo(&anEvent, mObjectFrame) -
mObjectFrame->GetUsedBorderAndPadding().TopLeft();
nsPresContext* presContext = mObjectFrame->PresContext();
nsIntPoint ptPx(presContext->AppUnitsToDevPixels(pt.x),
presContext->AppUnitsToDevPixels(pt.y));
#ifndef NP_NO_CARBON
nsIntPoint geckoScreenCoords = mWidget->WidgetToScreenOffset();
Point carbonPt = { ptPx.y + geckoScreenCoords.y, ptPx.x + geckoScreenCoords.x };
if (eventModel == NPEventModelCarbon) {
if (event && anEvent.eventStructType == NS_MOUSE_EVENT) {
static_cast<EventRecord*>(event)->where = carbonPt;
}
}
nsIntPoint geckoScreenCoords = mWidget->WidgetToScreenOffset();
Point carbonPt = { ptPx.y + geckoScreenCoords.y, ptPx.x + geckoScreenCoords.x };
if (eventModel == NPEventModelCarbon) {
if (event && anEvent.eventStructType == NS_MOUSE_EVENT) {
static_cast<EventRecord*>(event)->where = carbonPt;
}
}
#endif
if (!event) {
if (!event) {
#ifndef NP_NO_CARBON
if (eventModel == NPEventModelCarbon) {
InitializeEventRecord(&synthCarbonEvent, &carbonPt);
} else
#endif
{
InitializeNPCocoaEvent(&synthCocoaEvent);
}
switch (anEvent.message) {
case NS_FOCUS_CONTENT:
case NS_BLUR_CONTENT:
#ifndef NP_NO_CARBON
if (eventModel == NPEventModelCarbon) {
InitializeEventRecord(&synthCarbonEvent, &carbonPt);
} else
#endif
{
InitializeNPCocoaEvent(&synthCocoaEvent);
synthCarbonEvent.what = (anEvent.message == NS_FOCUS_CONTENT) ?
NPEventType_GetFocusEvent : NPEventType_LoseFocusEvent;
event = &synthCarbonEvent;
}
switch (anEvent.message) {
case NS_FOCUS_CONTENT:
case NS_BLUR_CONTENT:
#endif
break;
case NS_MOUSE_MOVE:
{
// Ignore mouse-moved events that happen as part of a dragging
// operation that started over another frame. See bug 525078.
nsCOMPtr<nsFrameSelection> frameselection = mObjectFrame->GetFrameSelection();
if (!frameselection->GetMouseDownState() ||
(nsIPresShell::GetCapturingContent() == mObjectFrame->GetContent())) {
#ifndef NP_NO_CARBON
if (eventModel == NPEventModelCarbon) {
synthCarbonEvent.what = (anEvent.message == NS_FOCUS_CONTENT) ?
NPEventType_GetFocusEvent : NPEventType_LoseFocusEvent;
event = &synthCarbonEvent;
}
#endif
break;
case NS_MOUSE_MOVE:
{
// Ignore mouse-moved events that happen as part of a dragging
// operation that started over another frame. See bug 525078.
nsCOMPtr<nsFrameSelection> frameselection = mObjectFrame->GetFrameSelection();
if (!frameselection->GetMouseDownState() ||
(nsIPresShell::GetCapturingContent() == mObjectFrame->GetContent())) {
#ifndef NP_NO_CARBON
if (eventModel == NPEventModelCarbon) {
synthCarbonEvent.what = osEvt;
event = &synthCarbonEvent;
} else
#endif
{
synthCocoaEvent.type = NPCocoaEventMouseMoved;
synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
event = &synthCocoaEvent;
}
}
}
break;
case NS_MOUSE_BUTTON_DOWN:
#ifndef NP_NO_CARBON
if (eventModel == NPEventModelCarbon) {
synthCarbonEvent.what = mouseDown;
synthCarbonEvent.what = osEvt;
event = &synthCarbonEvent;
} else
#endif
{
synthCocoaEvent.type = NPCocoaEventMouseDown;
synthCocoaEvent.type = NPCocoaEventMouseMoved;
synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
event = &synthCocoaEvent;
}
break;
case NS_MOUSE_BUTTON_UP:
// If we're in a dragging operation that started over another frame,
// either ignore the mouse-up event (in the Carbon Event Model) or
// convert it into a mouse-entered event (in the Cocoa Event Model).
// See bug 525078.
if ((static_cast<const nsMouseEvent&>(anEvent).button == nsMouseEvent::eLeftButton) &&
(nsIPresShell::GetCapturingContent() != mObjectFrame->GetContent())) {
if (eventModel == NPEventModelCocoa) {
synthCocoaEvent.type = NPCocoaEventMouseEntered;
synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
event = &synthCocoaEvent;
}
} else {
}
}
break;
case NS_MOUSE_BUTTON_DOWN:
#ifndef NP_NO_CARBON
if (eventModel == NPEventModelCarbon) {
synthCarbonEvent.what = mouseUp;
event = &synthCarbonEvent;
} else
if (eventModel == NPEventModelCarbon) {
synthCarbonEvent.what = mouseDown;
event = &synthCarbonEvent;
} else
#endif
{
synthCocoaEvent.type = NPCocoaEventMouseUp;
synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
event = &synthCocoaEvent;
}
{
synthCocoaEvent.type = NPCocoaEventMouseDown;
synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
event = &synthCocoaEvent;
}
break;
case NS_MOUSE_BUTTON_UP:
// If we're in a dragging operation that started over another frame,
// either ignore the mouse-up event (in the Carbon Event Model) or
// convert it into a mouse-entered event (in the Cocoa Event Model).
// See bug 525078.
if ((static_cast<const nsMouseEvent&>(anEvent).button == nsMouseEvent::eLeftButton) &&
(nsIPresShell::GetCapturingContent() != mObjectFrame->GetContent())) {
if (eventModel == NPEventModelCocoa) {
synthCocoaEvent.type = NPCocoaEventMouseEntered;
synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
event = &synthCocoaEvent;
}
break;
default:
break;
}
// If we still don't have an event, bail.
if (!event) {
pluginWidget->EndDrawPlugin();
return nsEventStatus_eIgnore;
}
}
} else {
#ifndef NP_NO_CARBON
// Work around an issue in the Flash plugin, which can cache a pointer
// to a doomed TSM document (one that belongs to a NSTSMInputContext)
// and try to activate it after it has been deleted. See bug 183313.
if (eventModel == NPEventModelCarbon && anEvent.message == NS_FOCUS_CONTENT)
::DeactivateTSMDocument(::TSMGetActiveDocument());
if (eventModel == NPEventModelCarbon) {
synthCarbonEvent.what = mouseUp;
event = &synthCarbonEvent;
} else
#endif
{
synthCocoaEvent.type = NPCocoaEventMouseUp;
synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
event = &synthCocoaEvent;
}
}
break;
default:
break;
}
PRBool eventHandled = PR_FALSE;
void* window = FixUpPluginWindow(ePluginPaintEnable);
if (window || (eventModel == NPEventModelCocoa)) {
mInstance->HandleEvent(event, &eventHandled);
}
if (eventHandled &&
!(anEvent.eventStructType == NS_MOUSE_EVENT &&
anEvent.message == NS_MOUSE_BUTTON_DOWN &&
static_cast<const nsMouseEvent&>(anEvent).button == nsMouseEvent::eLeftButton &&
!mContentFocused))
rv = nsEventStatus_eConsumeNoDefault;
// If we still don't have an event, bail.
if (!event) {
pluginWidget->EndDrawPlugin();
return nsEventStatus_eIgnore;
}
}
#ifndef NP_NO_CARBON
// Work around an issue in the Flash plugin, which can cache a pointer
// to a doomed TSM document (one that belongs to a NSTSMInputContext)
// and try to activate it after it has been deleted. See bug 183313.
if (eventModel == NPEventModelCarbon && anEvent.message == NS_FOCUS_CONTENT)
::DeactivateTSMDocument(::TSMGetActiveDocument());
#endif
PRBool eventHandled = PR_FALSE;
void* window = FixUpPluginWindow(ePluginPaintEnable);
if (window || (eventModel == NPEventModelCocoa)) {
mInstance->HandleEvent(event, &eventHandled);
}
if (eventHandled &&
!(anEvent.eventStructType == NS_MOUSE_EVENT &&
anEvent.message == NS_MOUSE_BUTTON_DOWN &&
static_cast<const nsMouseEvent&>(anEvent).button == nsMouseEvent::eLeftButton &&
!mContentFocused))
rv = nsEventStatus_eConsumeNoDefault;
pluginWidget->EndDrawPlugin();
#endif
#ifdef XP_WIN