Bug 1152479 - In C++ APZ code, use nsContentUtils rather than nsIDOMWindowUtils to send key and mouse events. r=kats

This commit is contained in:
Botond Ballo 2015-04-15 03:09:46 -04:00
parent 1e8ab6501c
commit 7a120e83fd
6 changed files with 16 additions and 17 deletions

View File

@ -2114,7 +2114,7 @@ bool
TabChild::RecvHandleLongTap(const CSSPoint& aPoint, const Modifiers& aModifiers, const ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId)
{
if (mGlobal && mTabChildGlobal) {
mAPZEventState->ProcessLongTap(GetDOMWindowUtils(), aPoint, aModifiers, aGuid,
mAPZEventState->ProcessLongTap(GetPresShell(), aPoint, aModifiers, aGuid,
aInputBlockId, GetPresShellResolution());
}
return true;
@ -2165,7 +2165,7 @@ TabChild::RecvMouseEvent(const nsString& aType,
const int32_t& aModifiers,
const bool& aIgnoreRootScrollFrame)
{
APZCCallbackHelper::DispatchMouseEvent(GetDOMWindowUtils(), aType, CSSPoint(aX, aY),
APZCCallbackHelper::DispatchMouseEvent(GetPresShell(), aType, CSSPoint(aX, aY),
aButton, aClickCount, aModifiers, aIgnoreRootScrollFrame, nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN);
return true;
}
@ -2328,7 +2328,7 @@ TabChild::FireContextMenuEvent()
MOZ_ASSERT(mTapHoldTimer && mActivePointerId >= 0);
bool defaultPrevented = APZCCallbackHelper::DispatchMouseEvent(
GetDOMWindowUtils(),
GetPresShell(),
NS_LITERAL_STRING("contextmenu"),
mGestureDownPoint / CSSToLayoutDeviceScale(scale),
2 /* Right button */,
@ -2526,11 +2526,9 @@ TabChild::RecvKeyEvent(const nsString& aType,
const int32_t& aModifiers,
const bool& aPreventDefault)
{
nsCOMPtr<nsIDOMWindowUtils> utils(GetDOMWindowUtils());
NS_ENSURE_TRUE(utils, true);
bool ignored = false;
utils->SendKeyEvent(aType, aKeyCode, aCharCode,
aModifiers, aPreventDefault, &ignored);
nsContentUtils::SendKeyEvent(mWidget, aType, aKeyCode, aCharCode,
aModifiers, aPreventDefault, &ignored);
return true;
}

View File

@ -433,7 +433,7 @@ APZCCallbackHelper::DispatchSynthesizedMouseEvent(uint32_t aMsg,
}
bool
APZCCallbackHelper::DispatchMouseEvent(const nsCOMPtr<nsIDOMWindowUtils>& aUtils,
APZCCallbackHelper::DispatchMouseEvent(const nsCOMPtr<nsIPresShell>& aPresShell,
const nsString& aType,
const CSSPoint& aPoint,
int32_t aButton,
@ -442,11 +442,12 @@ APZCCallbackHelper::DispatchMouseEvent(const nsCOMPtr<nsIDOMWindowUtils>& aUtils
bool aIgnoreRootScrollFrame,
unsigned short aInputSourceArg)
{
NS_ENSURE_TRUE(aUtils, true);
NS_ENSURE_TRUE(aPresShell, true);
bool defaultPrevented = false;
aUtils->SendMouseEvent(aType, aPoint.x, aPoint.y, aButton, aClickCount, aModifiers,
aIgnoreRootScrollFrame, 0, aInputSourceArg, false, 4, &defaultPrevented);
nsContentUtils::SendMouseEvent(aPresShell, aType, aPoint.x, aPoint.y,
aButton, aClickCount, aModifiers, aIgnoreRootScrollFrame, 0,
aInputSourceArg, false, &defaultPrevented, false);
return defaultPrevented;
}

View File

@ -122,7 +122,7 @@ public:
/* Dispatch a mouse event with the given parameters.
* Return whether or not any listeners have called preventDefault on the event. */
static bool DispatchMouseEvent(const nsCOMPtr<nsIDOMWindowUtils>& aUtils,
static bool DispatchMouseEvent(const nsCOMPtr<nsIPresShell>& aPresShell,
const nsString& aType,
const CSSPoint& aPoint,
int32_t aButton,

View File

@ -190,7 +190,7 @@ APZEventState::ProcessSingleTap(const CSSPoint& aPoint,
}
void
APZEventState::ProcessLongTap(const nsCOMPtr<nsIDOMWindowUtils>& aUtils,
APZEventState::ProcessLongTap(const nsCOMPtr<nsIPresShell>& aPresShell,
const CSSPoint& aPoint,
Modifiers aModifiers,
const ScrollableLayerGuid& aGuid,
@ -211,7 +211,7 @@ APZEventState::ProcessLongTap(const nsCOMPtr<nsIDOMWindowUtils>& aUtils,
// just converts them back to widget format, but that API has many callers,
// including in JS code, so it's not trivial to change.
bool eventHandled =
APZCCallbackHelper::DispatchMouseEvent(aUtils, NS_LITERAL_STRING("contextmenu"),
APZCCallbackHelper::DispatchMouseEvent(aPresShell, NS_LITERAL_STRING("contextmenu"),
APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid, aPresShellResolution),
2, 1, WidgetModifiersToDOMModifiers(aModifiers), true,
nsIDOMMouseEvent::MOZ_SOURCE_TOUCH);

View File

@ -18,7 +18,7 @@
#include "nsRefPtr.h"
template <class> class nsCOMPtr;
class nsIDOMWindowUtils;
class nsIPresShell;
class nsIWidget;
namespace mozilla {
@ -53,7 +53,7 @@ public:
Modifiers aModifiers,
const ScrollableLayerGuid& aGuid,
float aPresShellResolution);
void ProcessLongTap(const nsCOMPtr<nsIDOMWindowUtils>& aUtils,
void ProcessLongTap(const nsCOMPtr<nsIPresShell>& aUtils,
const CSSPoint& aPoint,
Modifiers aModifiers,
const ScrollableLayerGuid& aGuid,

View File

@ -179,7 +179,7 @@ ChromeProcessController::HandleLongTap(const mozilla::CSSPoint& aPoint, Modifier
return;
}
mAPZEventState->ProcessLongTap(GetDOMWindowUtils(), aPoint, aModifiers, aGuid,
mAPZEventState->ProcessLongTap(GetPresShell(), aPoint, aModifiers, aGuid,
aInputBlockId, GetPresShellResolution());
}