зеркало из https://github.com/mozilla/gecko-dev.git
Bug 663803 - Add hitCluster flag to detect touch in cluster links area r=smaug,kats
This commit is contained in:
Родитель
9e81b5c305
Коммит
d15b47438e
|
@ -466,6 +466,12 @@ MouseEvent::GetMozPressure(float* aPressure)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
MouseEvent::HitCluster() const
|
||||
{
|
||||
return mEvent->AsMouseEventBase()->hitCluster;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
MouseEvent::MozInputSource() const
|
||||
{
|
||||
|
|
|
@ -83,6 +83,7 @@ public:
|
|||
return GetMovementPoint().y;
|
||||
}
|
||||
float MozPressure() const;
|
||||
bool HitCluster() const;
|
||||
uint16_t MozInputSource() const;
|
||||
void InitNSMouseEvent(const nsAString& aType,
|
||||
bool aCanBubble, bool aCancelable,
|
||||
|
|
|
@ -106,6 +106,8 @@ partial interface MouseEvent
|
|||
EventTarget? relatedTargetArg,
|
||||
float pressure,
|
||||
unsigned short inputSourceArg);
|
||||
[ChromeOnly]
|
||||
readonly attribute boolean hitCluster; // True when touch occurs in a cluster of links
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ struct EventRadiusPrefs
|
|||
bool mRegistered;
|
||||
bool mTouchOnly;
|
||||
bool mRepositionEventCoords;
|
||||
bool mTouchClusterDetection;
|
||||
};
|
||||
|
||||
static EventRadiusPrefs sMouseEventRadiusPrefs;
|
||||
|
@ -121,6 +122,9 @@ GetPrefsFor(EventClassID aEventClassID)
|
|||
|
||||
nsPrintfCString repositionPref("ui.%s.radius.reposition", prefBranch);
|
||||
Preferences::AddBoolVarCache(&prefs->mRepositionEventCoords, repositionPref.get(), false);
|
||||
|
||||
nsPrintfCString touchClusterPref("ui.zoomedview.enabled", prefBranch);
|
||||
Preferences::AddBoolVarCache(&prefs->mTouchClusterDetection, touchClusterPref.get(), false);
|
||||
}
|
||||
|
||||
return prefs;
|
||||
|
@ -316,7 +320,8 @@ SubtractFromExposedRegion(nsRegion* aExposedRegion, const nsRegion& aRegion)
|
|||
static nsIFrame*
|
||||
GetClosest(nsIFrame* aRoot, const nsPoint& aPointRelativeToRootFrame,
|
||||
const nsRect& aTargetRect, const EventRadiusPrefs* aPrefs,
|
||||
nsIFrame* aRestrictToDescendants, nsTArray<nsIFrame*>& aCandidates)
|
||||
nsIFrame* aRestrictToDescendants, nsTArray<nsIFrame*>& aCandidates,
|
||||
int32_t* aElementsInCluster)
|
||||
{
|
||||
nsIFrame* bestTarget = nullptr;
|
||||
// Lower is better; distance is in appunits
|
||||
|
@ -358,6 +363,8 @@ GetClosest(nsIFrame* aRoot, const nsPoint& aPointRelativeToRootFrame,
|
|||
continue;
|
||||
}
|
||||
|
||||
(*aElementsInCluster)++;
|
||||
|
||||
// distance is in appunits
|
||||
float distance = ComputeDistanceFromRegion(aPointRelativeToRootFrame, region);
|
||||
nsIContent* content = f->GetContent();
|
||||
|
@ -424,10 +431,18 @@ FindFrameTargetedByInputEvent(WidgetGUIEvent* aEvent,
|
|||
return target;
|
||||
}
|
||||
|
||||
int32_t elementsInCluster = 0;
|
||||
|
||||
nsIFrame* closestClickable =
|
||||
GetClosest(aRootFrame, aPointRelativeToRootFrame, targetRect, prefs,
|
||||
restrictToDescendants, candidates);
|
||||
restrictToDescendants, candidates, &elementsInCluster);
|
||||
if (closestClickable) {
|
||||
if (prefs->mTouchClusterDetection && elementsInCluster > 1) {
|
||||
if (aEvent->mClass == eMouseEventClass) {
|
||||
WidgetMouseEventBase* mouseEventBase = aEvent->AsMouseEventBase();
|
||||
mouseEventBase->hitCluster = true;
|
||||
}
|
||||
}
|
||||
target = closestClickable;
|
||||
}
|
||||
PET_LOG("Final target is %p\n", target);
|
||||
|
|
|
@ -395,6 +395,8 @@ pref("font.size.inflation.minTwips", 120);
|
|||
// When true, zooming will be enabled on all sites, even ones that declare user-scalable=no.
|
||||
pref("browser.ui.zoom.force-user-scalable", false);
|
||||
|
||||
pref("ui.zoomedview.enabled", false);
|
||||
|
||||
pref("ui.touch.radius.enabled", false);
|
||||
pref("ui.touch.radius.leftmm", 3);
|
||||
pref("ui.touch.radius.topmm", 5);
|
||||
|
|
|
@ -4980,7 +4980,7 @@ var BrowserEventHandler = {
|
|||
if (!target) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._inCluster = aEvent.hitCluster;
|
||||
let uri = this._getLinkURI(target);
|
||||
if (uri) {
|
||||
try {
|
||||
|
@ -5095,16 +5095,18 @@ var BrowserEventHandler = {
|
|||
Cu.reportError(e);
|
||||
}
|
||||
|
||||
let data = JSON.parse(aData);
|
||||
let {x, y} = data;
|
||||
if (this._inCluster) {
|
||||
this._clusterClicked(x, y);
|
||||
} else {
|
||||
// The _highlightElement was chosen after fluffing the touch events
|
||||
// that led to this SingleTap, so by fluffing the mouse events, they
|
||||
// should find the same target since we fluff them again below.
|
||||
let data = JSON.parse(aData);
|
||||
let {x, y} = data;
|
||||
|
||||
this._sendMouseEvent("mousemove", x, y);
|
||||
this._sendMouseEvent("mousedown", x, y);
|
||||
this._sendMouseEvent("mouseup", x, y);
|
||||
|
||||
}
|
||||
// scrollToFocusedInput does its own checks to find out if an element should be zoomed into
|
||||
BrowserApp.scrollToFocusedInput(BrowserApp.selectedBrowser);
|
||||
|
||||
|
@ -5127,6 +5129,16 @@ var BrowserEventHandler = {
|
|||
}
|
||||
},
|
||||
|
||||
_clusterClicked: function sh_clusterClicked(aX, aY) {
|
||||
Messaging.sendRequest({
|
||||
type: "Gesture:clusteredLinksClicked",
|
||||
clicPosition: {
|
||||
x: aX,
|
||||
y: aY
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onDoubleTap: function(aData) {
|
||||
let metadata = BrowserApp.selectedTab.metadata;
|
||||
if (!metadata.allowDoubleTapZoom) {
|
||||
|
|
|
@ -83,6 +83,7 @@ protected:
|
|||
, button(0)
|
||||
, buttons(0)
|
||||
, pressure(0)
|
||||
, hitCluster(false)
|
||||
, inputSource(nsIDOMMouseEvent::MOZ_SOURCE_MOUSE)
|
||||
{
|
||||
}
|
||||
|
@ -127,6 +128,8 @@ public:
|
|||
|
||||
// Finger or touch pressure of event. It ranges between 0.0 and 1.0.
|
||||
float pressure;
|
||||
// Touch near a cluster of links (true)
|
||||
bool hitCluster;
|
||||
|
||||
// Possible values at nsIDOMMouseEvent
|
||||
uint16_t inputSource;
|
||||
|
@ -143,6 +146,7 @@ public:
|
|||
button = aEvent.button;
|
||||
buttons = aEvent.buttons;
|
||||
pressure = aEvent.pressure;
|
||||
hitCluster = aEvent.hitCluster;
|
||||
inputSource = aEvent.inputSource;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче