Bug 1078029 - Dispatch a dummy mouse event so that browser.js can pick up the event's retargeted target. r=wesj

This commit is contained in:
Kartikaya Gupta 2014-11-04 09:53:17 -05:00
parent 3c7e130926
commit b61c73d4d6
3 changed files with 31 additions and 1 deletions

View File

@ -261,7 +261,7 @@ interface nsIDOMWindowUtils : nsISupports {
/** Synthesize a mouse event. The event types supported are:
* mousedown, mouseup, mousemove, mouseover, mouseout, contextmenu,
* MozMouseHitTest
* MozMouseHittest
*
* Events are sent in coordinates offset by aX and aY from the window.
*

View File

@ -4851,6 +4851,7 @@ var BrowserEventHandler = {
BrowserApp.deck.addEventListener("DOMUpdatePageReport", PopupBlockerObserver.onUpdatePageReport, false);
BrowserApp.deck.addEventListener("touchstart", this, true);
BrowserApp.deck.addEventListener("MozMouseHittest", this, true);
BrowserApp.deck.addEventListener("click", InputWidgetHelper, true);
BrowserApp.deck.addEventListener("click", SelectHelper, true);
@ -4883,6 +4884,9 @@ var BrowserEventHandler = {
case 'touchstart':
this._handleTouchStart(aEvent);
break;
case 'MozMouseHittest':
this._handleRetargetedTouchStart(aEvent);
break;
case 'MozMagnifyGesture':
this.observe(this, aEvent.type,
JSON.stringify({x: aEvent.screenX, y: aEvent.screenY,
@ -4915,6 +4919,19 @@ var BrowserEventHandler = {
Messaging.sendRequest({ type: "Panning:Override" });
}
}
},
_handleRetargetedTouchStart: function(aEvent) {
// we should only get this called just after a new touchstart with a single
// touch point.
if (!BrowserApp.isBrowserContentDocumentDisplayed() || aEvent.defaultPrevented) {
return;
}
let target = aEvent.target;
if (!target) {
return;
}
let uri = this._getLinkURI(target);
if (uri) {

View File

@ -1088,6 +1088,19 @@ bool nsWindow::OnMultitouchEvent(AndroidGeckoEvent *ae)
isDownEvent = (event.message == NS_TOUCH_START);
}
if (isDownEvent && event.touches.Length() == 1) {
// Since touch events don't get retargeted by PositionedEventTargeting.cpp
// code on Fennec, we dispatch a dummy mouse event that *does* get
// retargeted. The Fennec browser.js code can use this to activate the
// highlight element in case the this touchstart is the start of a tap.
WidgetMouseEvent hittest(true, NS_MOUSE_MOZHITTEST, this, WidgetMouseEvent::eReal);
hittest.refPoint = LayoutDeviceIntPoint::FromUntyped(event.touches[0]->mRefPoint);
hittest.ignoreRootScrollFrame = true;
hittest.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
nsEventStatus status;
DispatchEvent(&hittest, status);
}
// if the last event we got was a down event, then by now we know for sure whether
// this block has been default-prevented or not. if we haven't already sent the
// notification for this block, do so now.