Bug 1132464 - Remove EventStateManager::GetChildProcessOffset in favor of TabParent::GetChildProcessOffset. r=smaug

This commit is contained in:
Kartikaya Gupta 2015-02-16 21:35:03 -05:00
Родитель 362a369841
Коммит 4c7c740129
3 изменённых файлов: 8 добавлений и 67 удалений

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

@ -1141,24 +1141,6 @@ EventStateManager::IsRemoteTarget(nsIContent* target) {
return false;
}
/*static*/ LayoutDeviceIntPoint
EventStateManager::GetChildProcessOffset(nsFrameLoader* aFrameLoader,
const WidgetEvent& aEvent)
{
// The "toplevel widget" in child processes is always at position
// 0,0. Map the event coordinates to match that.
nsIFrame* targetFrame = aFrameLoader->GetPrimaryFrameOfOwningContent();
if (!targetFrame) {
return LayoutDeviceIntPoint();
}
nsPresContext* presContext = targetFrame->PresContext();
// Find out how far we're offset from the nearest widget.
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(&aEvent,
targetFrame);
return LayoutDeviceIntPoint::FromAppUnitsToNearest(pt, presContext->AppUnitsPerDevPixel());
}
bool
CrossProcessSafeEvent(const WidgetEvent& aEvent)
{

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

@ -221,8 +221,6 @@ public:
static void SetFullScreenState(dom::Element* aElement, bool aIsFullScreen);
static bool IsRemoteTarget(nsIContent* aTarget);
static LayoutDeviceIntPoint GetChildProcessOffset(nsFrameLoader* aFrameLoader,
const WidgetEvent& aEvent);
// Returns true if the given WidgetWheelEvent will resolve to a scroll action.
static bool WheelEventIsScrollAction(WidgetWheelEvent* aEvent);

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

@ -1178,48 +1178,12 @@ TabParent::SendKeyEvent(const nsAString& aType,
}
}
bool
TabParent::MapEventCoordinatesForChildProcess(WidgetEvent* aEvent)
{
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
if (!frameLoader) {
return false;
}
LayoutDeviceIntPoint offset =
EventStateManager::GetChildProcessOffset(frameLoader, *aEvent);
MapEventCoordinatesForChildProcess(offset, aEvent);
return true;
}
void
TabParent::MapEventCoordinatesForChildProcess(
const LayoutDeviceIntPoint& aOffset, WidgetEvent* aEvent)
{
if (aEvent->mClass != eTouchEventClass) {
aEvent->refPoint = aOffset;
} else {
aEvent->refPoint = LayoutDeviceIntPoint();
// Then offset all the touch points by that distance, to put them
// in the space where top-left is 0,0.
const WidgetTouchEvent::TouchArray& touches =
aEvent->AsTouchEvent()->touches;
for (uint32_t i = 0; i < touches.Length(); ++i) {
Touch* touch = touches[i];
if (touch) {
touch->mRefPoint += aOffset;
}
}
}
}
bool TabParent::SendRealMouseEvent(WidgetMouseEvent& event)
{
if (mIsDestroyed) {
return false;
}
if (!MapEventCoordinatesForChildProcess(&event)) {
return false;
}
event.refPoint += GetChildProcessOffset();
if (event.message == NS_MOUSE_MOVE) {
return SendRealMouseMoveEvent(event);
}
@ -1290,9 +1254,7 @@ bool TabParent::SendMouseWheelEvent(WidgetWheelEvent& event)
ScrollableLayerGuid guid;
uint64_t blockId;
ApzAwareEventRoutingToChild(&guid, &blockId);
if (!MapEventCoordinatesForChildProcess(&event)) {
return false;
}
event.refPoint += GetChildProcessOffset();
return PBrowserParent::SendMouseWheelEvent(event, guid, blockId);
}
@ -1342,10 +1304,7 @@ bool TabParent::SendRealKeyEvent(WidgetKeyboardEvent& event)
if (mIsDestroyed) {
return false;
}
if (!MapEventCoordinatesForChildProcess(&event)) {
return false;
}
event.refPoint += GetChildProcessOffset();
MaybeNativeKeyBinding bindings;
bindings = void_t();
@ -1385,8 +1344,7 @@ bool TabParent::SendRealTouchEvent(WidgetTouchEvent& event)
return false;
}
mChildProcessOffsetAtTouchStart =
EventStateManager::GetChildProcessOffset(frameLoader, event);
mChildProcessOffsetAtTouchStart = GetChildProcessOffset();
MOZ_ASSERT((!sEventCapturer && mEventCaptureDepth == 0) ||
(sEventCapturer == this && mEventCaptureDepth > 0));
@ -1416,7 +1374,10 @@ bool TabParent::SendRealTouchEvent(WidgetTouchEvent& event)
return false;
}
MapEventCoordinatesForChildProcess(mChildProcessOffsetAtTouchStart, &event);
LayoutDeviceIntPoint offset = GetChildProcessOffset();
for (uint32_t i = 0; i < event.touches.Length(); i++) {
event.touches[i]->mRefPoint += offset;
}
return (event.message == NS_TOUCH_MOVE) ?
PBrowserParent::SendRealTouchMoveEvent(event, guid, blockId) :