Skip to content

Commit

Permalink
More TabChild merging
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeshkova committed Mar 12, 2014
1 parent 0b6df23 commit 783b481
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 57 deletions.
32 changes: 20 additions & 12 deletions dom/ipc/TabChild.cpp
Expand Up @@ -1692,9 +1692,9 @@ void
TabChild::FireSingleTapEvent(LayoutDevicePoint aPoint)
{
int time = 0;
DispatchSynthesizedMouseEvent(NS_MOUSE_MOVE, time, aPoint);
DispatchSynthesizedMouseEvent(NS_MOUSE_BUTTON_DOWN, time, aPoint);
DispatchSynthesizedMouseEvent(NS_MOUSE_BUTTON_UP, time, aPoint);
DispatchSynthesizedMouseEvent(NS_MOUSE_MOVE, time, aPoint, mWidget);
DispatchSynthesizedMouseEvent(NS_MOUSE_BUTTON_DOWN, time, aPoint, mWidget);
DispatchSynthesizedMouseEvent(NS_MOUSE_BUTTON_UP, time, aPoint, mWidget);
}

bool
Expand Down Expand Up @@ -1784,6 +1784,7 @@ bool
TabChild::RecvRealMouseEvent(const WidgetMouseEvent& event)
{
WidgetMouseEvent localEvent(event);
localEvent.widget = mWidget;
DispatchWidgetEvent(localEvent);
return true;
}
Expand All @@ -1792,13 +1793,15 @@ bool
TabChild::RecvMouseWheelEvent(const WidgetWheelEvent& event)
{
WidgetWheelEvent localEvent(event);
localEvent.widget = mWidget;
DispatchWidgetEvent(localEvent);
return true;
}

void
TabChild::DispatchSynthesizedMouseEvent(uint32_t aMsg, uint64_t aTime,
const LayoutDevicePoint& aRefPoint)
TabChildBase::DispatchSynthesizedMouseEvent(uint32_t aMsg, uint64_t aTime,
const LayoutDevicePoint& aRefPoint,
nsIWidget* aWidget)
{
MOZ_ASSERT(aMsg == NS_MOUSE_MOVE || aMsg == NS_MOUSE_BUTTON_DOWN ||
aMsg == NS_MOUSE_BUTTON_UP);
Expand All @@ -1812,6 +1815,7 @@ TabChild::DispatchSynthesizedMouseEvent(uint32_t aMsg, uint64_t aTime,
if (aMsg != NS_MOUSE_MOVE) {
event.clickCount = 1;
}
event.widget = aWidget;

DispatchWidgetEvent(event);
}
Expand Down Expand Up @@ -1900,9 +1904,9 @@ TabChild::UpdateTapState(const WidgetTouchEvent& aEvent, nsEventStatus aStatus)

case NS_TOUCH_END:
if (!nsIPresShell::gPreventMouseEvents) {
DispatchSynthesizedMouseEvent(NS_MOUSE_MOVE, time, currentPoint);
DispatchSynthesizedMouseEvent(NS_MOUSE_BUTTON_DOWN, time, currentPoint);
DispatchSynthesizedMouseEvent(NS_MOUSE_BUTTON_UP, time, currentPoint);
DispatchSynthesizedMouseEvent(NS_MOUSE_MOVE, time, currentPoint, mWidget);
DispatchSynthesizedMouseEvent(NS_MOUSE_BUTTON_DOWN, time, currentPoint, mWidget);
DispatchSynthesizedMouseEvent(NS_MOUSE_BUTTON_UP, time, currentPoint, mWidget);
}
// fall through
case NS_TOUCH_CANCEL:
Expand Down Expand Up @@ -1957,6 +1961,7 @@ TabChild::RecvRealTouchEvent(const WidgetTouchEvent& aEvent,
const ScrollableLayerGuid& aGuid)
{
WidgetTouchEvent localEvent(aEvent);
localEvent.widget = mWidget;
nsEventStatus status = DispatchWidgetEvent(localEvent);

if (!IsAsyncPanZoomEnabled()) {
Expand Down Expand Up @@ -2012,6 +2017,7 @@ bool
TabChild::RecvRealKeyEvent(const WidgetKeyboardEvent& event)
{
WidgetKeyboardEvent localEvent(event);
localEvent.widget = mWidget;
DispatchWidgetEvent(localEvent);
return true;
}
Expand All @@ -2035,6 +2041,7 @@ bool
TabChild::RecvCompositionEvent(const WidgetCompositionEvent& event)
{
WidgetCompositionEvent localEvent(event);
localEvent.widget = mWidget;
DispatchWidgetEvent(localEvent);
return true;
}
Expand All @@ -2043,6 +2050,7 @@ bool
TabChild::RecvTextEvent(const WidgetTextEvent& event)
{
WidgetTextEvent localEvent(event);
localEvent.widget = mWidget;
DispatchWidgetEvent(localEvent);
return true;
}
Expand All @@ -2051,19 +2059,19 @@ bool
TabChild::RecvSelectionEvent(const WidgetSelectionEvent& event)
{
WidgetSelectionEvent localEvent(event);
localEvent.widget = mWidget;
DispatchWidgetEvent(localEvent);
return true;
}

nsEventStatus
TabChild::DispatchWidgetEvent(WidgetGUIEvent& event)
TabChildBase::DispatchWidgetEvent(WidgetGUIEvent& event)
{
if (!mWidget)
if (!event.widget)
return nsEventStatus_eConsumeNoDefault;

nsEventStatus status;
event.widget = mWidget;
NS_ENSURE_SUCCESS(mWidget->DispatchEvent(&event, status),
NS_ENSURE_SUCCESS(event.widget->DispatchEvent(&event, status),
nsEventStatus_eConsumeNoDefault);
return status;
}
Expand Down
11 changes: 6 additions & 5 deletions dom/ipc/TabChild.h
Expand Up @@ -174,6 +174,12 @@ class TabChildBase : public nsFrameScriptExecutor,
void DispatchMessageManagerMessage(const nsAString& aMessageName,
const nsAString& aJSONData);

void DispatchSynthesizedMouseEvent(uint32_t aMsg, uint64_t aTime,
const LayoutDevicePoint& aRefPoint,
nsIWidget* aWidget);

nsEventStatus DispatchWidgetEvent(WidgetGUIEvent& event);

protected:
float mOldViewportWidth;
bool mContentDocumentIsDisplayed;
Expand Down Expand Up @@ -430,8 +436,6 @@ class TabChild : public PBrowserChild,
virtual bool RecvSetUpdateHitRegion(const bool& aEnabled) MOZ_OVERRIDE;
virtual bool RecvSetIsDocShellActive(const bool& aIsActive) MOZ_OVERRIDE;

nsEventStatus DispatchWidgetEvent(WidgetGUIEvent& event);

virtual PIndexedDBChild* AllocPIndexedDBChild(const nsCString& aGroup,
const nsCString& aASCIIOrigin,
bool* /* aAllowed */) MOZ_OVERRIDE;
Expand Down Expand Up @@ -482,9 +486,6 @@ class TabChild : public PBrowserChild,
// not be called all the time as it is fairly expensive.
void HandlePossibleViewportChange();

void DispatchSynthesizedMouseEvent(uint32_t aMsg, uint64_t aTime,
const LayoutDevicePoint& aRefPoint);

// These methods are used for tracking synthetic mouse events
// dispatched for compatibility. On each touch event, we
// UpdateTapState(). If we've detected that the current gesture
Expand Down
36 changes: 0 additions & 36 deletions embedding/embedlite/utils/TabChildHelper.cpp
Expand Up @@ -602,21 +602,6 @@ TabChildHelper::InitEvent(WidgetGUIEvent& event, nsIntPoint* aPoint)
event.time = PR_Now() / 1000;
}

nsEventStatus
TabChildHelper::DispatchWidgetEvent(WidgetGUIEvent& event)
{
if (!mView->mWidget || !event.widget) {
return nsEventStatus_eConsumeNoDefault;
}

event.mFlags.mIsBeingDispatched = false;

nsEventStatus status;
NS_ENSURE_SUCCESS(event.widget->DispatchEvent(&event, status),
nsEventStatus_eConsumeNoDefault);
return status;
}

nsEventStatus
TabChildHelper::DispatchSynthesizedMouseEvent(const WidgetTouchEvent& aEvent)
{
Expand Down Expand Up @@ -675,27 +660,6 @@ TabChildHelper::DispatchSynthesizedMouseEvent(const WidgetTouchEvent& aEvent)
return nsEventStatus_eIgnore;
}

void
TabChildHelper::DispatchSynthesizedMouseEvent(uint32_t aMsg, uint64_t aTime,
const nsIntPoint& aRefPoint)
{
// Synthesize a phony mouse event.
MOZ_ASSERT(aMsg == NS_MOUSE_MOVE || aMsg == NS_MOUSE_BUTTON_DOWN ||
aMsg == NS_MOUSE_BUTTON_UP);

WidgetMouseEvent event(true, aMsg, NULL,
WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal);
event.refPoint.x = aRefPoint.x;
event.refPoint.y = aRefPoint.y;
event.time = aTime;
event.button = WidgetMouseEvent::eLeftButton;
if (aMsg != NS_MOUSE_MOVE) {
event.clickCount = 1;
}

DispatchWidgetEvent(event);
}

bool
TabChildHelper::HandlePossibleViewportChange()
{
Expand Down
5 changes: 1 addition & 4 deletions embedding/embedlite/utils/TabChildHelper.h
Expand Up @@ -42,7 +42,7 @@ class TabChildHelper : public nsIDOMEventListener,

virtual nsIWebNavigation* WebNavigation() MOZ_OVERRIDE;

virtual bool DoLoadFrameScript(const nsAString& aURL, bool aRunInGlobalScope);
virtual bool DoLoadFrameScript(const nsAString& aURL, bool aRunInGlobalScope) MOZ_OVERRIDE;
virtual bool DoSendBlockingMessage(JSContext* aCx,
const nsAString& aMessage,
const mozilla::dom::StructuredCloneData& aData,
Expand All @@ -61,12 +61,9 @@ class TabChildHelper : public nsIDOMEventListener,
nsIWidget* GetWidget(nsPoint* aOffset);
nsPresContext* GetPresContext();
void InitEvent(WidgetGUIEvent& event, nsIntPoint* aPoint = nullptr);
nsEventStatus DispatchWidgetEvent(WidgetGUIEvent& event);
// Sends a simulated mouse event from a touch event for compatibility.
bool ConvertMutiTouchInputToEvent(const mozilla::MultiTouchInput& aData,
WidgetTouchEvent& aEvent);
void DispatchSynthesizedMouseEvent(uint32_t aMsg, uint64_t aTime,
const nsIntPoint& aRefPoint);
nsEventStatus DispatchSynthesizedMouseEvent(const WidgetTouchEvent& aEvent);

void CancelTapTracking();
Expand Down

0 comments on commit 783b481

Please sign in to comment.