зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
cc2978a0dd
Коммит
5967cfb1cf
|
@ -4426,156 +4426,158 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent)
|
||||||
return nsEventStatus_eIgnore;
|
return nsEventStatus_eIgnore;
|
||||||
|
|
||||||
#ifdef XP_MACOSX
|
#ifdef XP_MACOSX
|
||||||
if (mWidget) {
|
if (!mWidget)
|
||||||
// we never care about synthesized mouse enter
|
return nsEventStatus_eIgnore;
|
||||||
if (anEvent.message == NS_MOUSE_ENTER_SYNTH)
|
|
||||||
return nsEventStatus_eIgnore;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
|
// we never care about synthesized mouse enter
|
||||||
if (pluginWidget && NS_SUCCEEDED(pluginWidget->StartDrawPlugin())) {
|
if (anEvent.message == NS_MOUSE_ENTER_SYNTH)
|
||||||
NPEventModel eventModel = GetEventModel();
|
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
|
#ifndef NP_NO_CARBON
|
||||||
EventRecord synthCarbonEvent;
|
EventRecord synthCarbonEvent;
|
||||||
#endif
|
#endif
|
||||||
NPCocoaEvent synthCocoaEvent;
|
NPCocoaEvent synthCocoaEvent;
|
||||||
void* event = anEvent.pluginEvent;
|
void* event = anEvent.pluginEvent;
|
||||||
nsPoint pt =
|
nsPoint pt =
|
||||||
nsLayoutUtils::GetEventCoordinatesRelativeTo(&anEvent, mObjectFrame) -
|
nsLayoutUtils::GetEventCoordinatesRelativeTo(&anEvent, mObjectFrame) -
|
||||||
mObjectFrame->GetUsedBorderAndPadding().TopLeft();
|
mObjectFrame->GetUsedBorderAndPadding().TopLeft();
|
||||||
nsPresContext* presContext = mObjectFrame->PresContext();
|
nsPresContext* presContext = mObjectFrame->PresContext();
|
||||||
nsIntPoint ptPx(presContext->AppUnitsToDevPixels(pt.x),
|
nsIntPoint ptPx(presContext->AppUnitsToDevPixels(pt.x),
|
||||||
presContext->AppUnitsToDevPixels(pt.y));
|
presContext->AppUnitsToDevPixels(pt.y));
|
||||||
#ifndef NP_NO_CARBON
|
#ifndef NP_NO_CARBON
|
||||||
nsIntPoint geckoScreenCoords = mWidget->WidgetToScreenOffset();
|
nsIntPoint geckoScreenCoords = mWidget->WidgetToScreenOffset();
|
||||||
Point carbonPt = { ptPx.y + geckoScreenCoords.y, ptPx.x + geckoScreenCoords.x };
|
Point carbonPt = { ptPx.y + geckoScreenCoords.y, ptPx.x + geckoScreenCoords.x };
|
||||||
if (eventModel == NPEventModelCarbon) {
|
if (eventModel == NPEventModelCarbon) {
|
||||||
if (event && anEvent.eventStructType == NS_MOUSE_EVENT) {
|
if (event && anEvent.eventStructType == NS_MOUSE_EVENT) {
|
||||||
static_cast<EventRecord*>(event)->where = carbonPt;
|
static_cast<EventRecord*>(event)->where = carbonPt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
#ifndef NP_NO_CARBON
|
||||||
if (eventModel == NPEventModelCarbon) {
|
if (eventModel == NPEventModelCarbon) {
|
||||||
InitializeEventRecord(&synthCarbonEvent, &carbonPt);
|
synthCarbonEvent.what = (anEvent.message == NS_FOCUS_CONTENT) ?
|
||||||
} else
|
NPEventType_GetFocusEvent : NPEventType_LoseFocusEvent;
|
||||||
#endif
|
event = &synthCarbonEvent;
|
||||||
{
|
|
||||||
InitializeNPCocoaEvent(&synthCocoaEvent);
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
switch (anEvent.message) {
|
break;
|
||||||
case NS_FOCUS_CONTENT:
|
case NS_MOUSE_MOVE:
|
||||||
case NS_BLUR_CONTENT:
|
{
|
||||||
|
// 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
|
#ifndef NP_NO_CARBON
|
||||||
if (eventModel == NPEventModelCarbon) {
|
if (eventModel == NPEventModelCarbon) {
|
||||||
synthCarbonEvent.what = (anEvent.message == NS_FOCUS_CONTENT) ?
|
synthCarbonEvent.what = osEvt;
|
||||||
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;
|
|
||||||
event = &synthCarbonEvent;
|
event = &synthCarbonEvent;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
synthCocoaEvent.type = NPCocoaEventMouseDown;
|
synthCocoaEvent.type = NPCocoaEventMouseMoved;
|
||||||
synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
|
synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
|
||||||
synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
|
synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
|
||||||
event = &synthCocoaEvent;
|
event = &synthCocoaEvent;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case NS_MOUSE_BUTTON_UP:
|
}
|
||||||
// If we're in a dragging operation that started over another frame,
|
break;
|
||||||
// either ignore the mouse-up event (in the Carbon Event Model) or
|
case NS_MOUSE_BUTTON_DOWN:
|
||||||
// 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 {
|
|
||||||
#ifndef NP_NO_CARBON
|
#ifndef NP_NO_CARBON
|
||||||
if (eventModel == NPEventModelCarbon) {
|
if (eventModel == NPEventModelCarbon) {
|
||||||
synthCarbonEvent.what = mouseUp;
|
synthCarbonEvent.what = mouseDown;
|
||||||
event = &synthCarbonEvent;
|
event = &synthCarbonEvent;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
synthCocoaEvent.type = NPCocoaEventMouseUp;
|
synthCocoaEvent.type = NPCocoaEventMouseDown;
|
||||||
synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
|
synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
|
||||||
synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
|
synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
|
||||||
event = &synthCocoaEvent;
|
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;
|
} else {
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we still don't have an event, bail.
|
|
||||||
if (!event) {
|
|
||||||
pluginWidget->EndDrawPlugin();
|
|
||||||
return nsEventStatus_eIgnore;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef NP_NO_CARBON
|
#ifndef NP_NO_CARBON
|
||||||
// Work around an issue in the Flash plugin, which can cache a pointer
|
if (eventModel == NPEventModelCarbon) {
|
||||||
// to a doomed TSM document (one that belongs to a NSTSMInputContext)
|
synthCarbonEvent.what = mouseUp;
|
||||||
// and try to activate it after it has been deleted. See bug 183313.
|
event = &synthCarbonEvent;
|
||||||
if (eventModel == NPEventModelCarbon && anEvent.message == NS_FOCUS_CONTENT)
|
} else
|
||||||
::DeactivateTSMDocument(::TSMGetActiveDocument());
|
|
||||||
#endif
|
#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;
|
// If we still don't have an event, bail.
|
||||||
void* window = FixUpPluginWindow(ePluginPaintEnable);
|
if (!event) {
|
||||||
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();
|
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
|
#endif
|
||||||
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
|
|
Загрузка…
Ссылка в новой задаче