Bug 926389 - Add touch event handling during fluffing. r=roc

This commit is contained in:
Alexandre Lissy 2013-10-17 14:42:48 -04:00
Родитель 1b4e1bdd87
Коммит 28bacce9d2
2 изменённых файлов: 37 добавлений и 1 удалений

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

@ -127,6 +127,31 @@ HasMouseListener(nsIContent* aContent)
elm->HasListenersFor(nsGkAtoms::onmouseup);
}
static bool gTouchEventsRegistered = false;
static int32_t gTouchEventsEnabled = 0;
static bool
HasTouchListener(nsIContent* aContent)
{
nsEventListenerManager* elm = aContent->GetListenerManager(false);
if (!elm) {
return false;
}
if (!gTouchEventsRegistered) {
Preferences::AddIntVarCache(&gTouchEventsEnabled,
"dom.w3c_touch_events.enabled", gTouchEventsEnabled);
gTouchEventsRegistered = true;
}
if (!gTouchEventsEnabled) {
return false;
}
return elm->HasListenersFor(nsGkAtoms::ontouchstart) ||
elm->HasListenersFor(nsGkAtoms::ontouchend);
}
static bool
IsElementClickable(nsIFrame* aFrame, nsIAtom* stopAt = nullptr)
{
@ -138,7 +163,7 @@ IsElementClickable(nsIFrame* aFrame, nsIAtom* stopAt = nullptr)
if (content->IsHTML() && stopAt && tag == stopAt) {
break;
}
if (HasMouseListener(content)) {
if (HasTouchListener(content) || HasMouseListener(content)) {
return true;
}
if (content->IsHTML()) {

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

@ -45,6 +45,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=780847
<div id="t8" contenteditable="true" class="target" hidden></div>
<div id="t9" class="target" ontouchend="x=1" hidden></div>
</div>
<pre id="test">
<script type="application/javascript">
@ -203,6 +205,15 @@ function test3() {
});
setShowing("t8", false);
// Check that elements are touchable
setShowing("t9", true);
var rect = document.getElementById("t9").getBoundingClientRect();
testMouseClick("t9", rect.left + 1, rect.top + 1, "t9", "div enabled with mouse input");
testMouseClick("t9", rect.left + 1, rect.top + 1, "t9", "div enabled with touch input", {
inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH
});
setShowing("t9", false);
// Not yet tested:
// -- visited link weight
// -- "Closest" using Euclidean distance