зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1293174 - [Pointer Event] Implement implicit pointer capture for touch. f=bevistseng. r=smaug
--HG-- extra : rebase_source : ef86008679a1c0e7af30bab658e0c7668093adfe
This commit is contained in:
Родитель
19607c3802
Коммит
1aa4b81fa4
|
@ -0,0 +1,64 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Pointer Events properties tests</title>
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<link rel="stylesheet" type="text/css" href="pointerevent_styles.css">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<!--script src="/resources/testharnessreport.js"></script-->
|
||||
<!-- Additional helper script for common checks across event types -->
|
||||
<script type="text/javascript" src="pointerevent_support.js"></script>
|
||||
<script type="text/javascript" src="mochitest_support_internal.js"></script>
|
||||
<script>
|
||||
var detected_pointertypes = {};
|
||||
var test_pointerEvent = async_test("implicit pointer capture for touch");
|
||||
// showPointerTypes is defined in pointerevent_support.js
|
||||
// Requirements: the callback function will reference the test_pointerEvent object and
|
||||
// will fail unless the async_test is created with the var name "test_pointerEvent".
|
||||
add_completion_callback(showPointerTypes);
|
||||
|
||||
function run() {
|
||||
let target0 = window.document.getElementById("target0");
|
||||
let target1 = window.document.getElementById("target1");
|
||||
|
||||
on_event(target0, "pointerdown", function (event) {
|
||||
pointerdown_event = event;
|
||||
detected_pointertypes[event.pointerType] = true;
|
||||
assert_true(true, "target0 receives pointerdown");
|
||||
});
|
||||
|
||||
on_event(target0, "pointermove", function (event) {
|
||||
assert_true(true, "target0 receives pointermove");
|
||||
assert_true(target0.hasPointerCapture(event.pointerId), "target0.hasPointerCapture should be true");
|
||||
});
|
||||
|
||||
on_event(target0, "gotpointercapture", function (event) {
|
||||
assert_true(true, "target0 should receive gotpointercapture");
|
||||
});
|
||||
|
||||
on_event(target0, "lostpointercapture", function (event) {
|
||||
assert_true(true, "target0 should receive lostpointercapture");
|
||||
});
|
||||
|
||||
on_event(target1, "pointermove", function (event) {
|
||||
assert_true(false, "target1 should not receive pointermove");
|
||||
});
|
||||
|
||||
on_event(target0, "pointerup", function (event) {
|
||||
assert_true(true, "target0 receives pointerup");
|
||||
test_pointerEvent.done();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="run()">
|
||||
<h1>Pointer Events tests</h1>
|
||||
<div id="target0" style="width: 200px; height: 200px; background: green" touch-action:none></div>
|
||||
<div id="target1" style="width: 200px; height: 200px; background: green" touch-action:none></div>
|
||||
<div id="complete-notice">
|
||||
<p>The following pointer types were detected: <span id="pointertype-log"></span>.</p>
|
||||
<p>Refresh the page to run the tests again with a different pointer type.</p>
|
||||
</div>
|
||||
<div id="log"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,65 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Pointer Events properties tests</title>
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<link rel="stylesheet" type="text/css" href="pointerevent_styles.css">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<!--script src="/resources/testharnessreport.js"></script-->
|
||||
<!-- Additional helper script for common checks across event types -->
|
||||
<script type="text/javascript" src="pointerevent_support.js"></script>
|
||||
<script type="text/javascript" src="mochitest_support_internal.js"></script>
|
||||
<script>
|
||||
var detected_pointertypes = {};
|
||||
var test_pointerEvent = async_test("implicit pointer capture for touch");
|
||||
// showPointerTypes is defined in pointerevent_support.js
|
||||
// Requirements: the callback function will reference the test_pointerEvent object and
|
||||
// will fail unless the async_test is created with the var name "test_pointerEvent".
|
||||
add_completion_callback(showPointerTypes);
|
||||
|
||||
function run() {
|
||||
let target0 = window.document.getElementById("target0");
|
||||
let target1 = window.document.getElementById("target1");
|
||||
|
||||
on_event(target0, "pointerdown", function (event) {
|
||||
pointerdown_event = event;
|
||||
detected_pointertypes[event.pointerType] = true;
|
||||
assert_true(true, "target0 receives pointerdown");
|
||||
});
|
||||
|
||||
on_event(target0, "pointermove", function (event) {
|
||||
assert_true(true, "target0 receives pointermove");
|
||||
assert_false(target0.hasPointerCapture(event.pointerId), "target0.hasPointerCapture should be false");
|
||||
});
|
||||
|
||||
on_event(target0, "gotpointercapture", function (event) {
|
||||
assert_unreached("target0 should not receive gotpointercapture");
|
||||
});
|
||||
|
||||
on_event(target0, "lostpointercapture", function (event) {
|
||||
assert_unreached("target0 should not receive lostpointercapture");
|
||||
});
|
||||
|
||||
on_event(target1, "pointermove", function (event) {
|
||||
assert_true(true, "target1 receives pointermove");
|
||||
assert_false(target1.hasPointerCapture(), "target1.hasPointerCapture should be false");
|
||||
});
|
||||
|
||||
on_event(target0, "pointerup", function (event) {
|
||||
assert_true(true, "target0 receives pointerup");
|
||||
test_pointerEvent.done();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="run()">
|
||||
<h1>Pointer Events tests</h1>
|
||||
<div id="target0" style="width: 200px; height: 200px; background: green" touch-action:none></div>
|
||||
<div id="target1" style="width: 200px; height: 200px; background: green" touch-action:none></div>
|
||||
<div id="complete-notice">
|
||||
<p>The following pointer types were detected: <span id="pointertype-log"></span>.</p>
|
||||
<p>Refresh the page to run the tests again with a different pointer type.</p>
|
||||
</div>
|
||||
<div id="log"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -149,5 +149,9 @@ support-files =
|
|||
pointerevent_touch-action-svg-test_touch-manual.html
|
||||
pointerevent_touch-action-table-test_touch-manual.html
|
||||
[test_bug1285128.html]
|
||||
[test_bug1293174_implicit_pointer_capture_for_touch_1.html]
|
||||
support-files = bug1293174_implicit_pointer_capture_for_touch_1.html
|
||||
[test_bug1293174_implicit_pointer_capture_for_touch_2.html]
|
||||
support-files = bug1293174_implicit_pointer_capture_for_touch_2.html
|
||||
[test_empty_file.html]
|
||||
disabled = disabled # Bug 1150091 - Issue with support-files
|
||||
|
|
|
@ -15,6 +15,15 @@ function prepareTest() {
|
|||
turnOnPointerEvents(startTest);
|
||||
}
|
||||
|
||||
function setImplicitPointerCapture(capture, callback) {
|
||||
console.log("SET dom.w3c_pointer_events.implicit_capture as " + capture);
|
||||
SpecialPowers.pushPrefEnv({
|
||||
"set": [
|
||||
["dom.w3c_pointer_events.implicit_capture", capture]
|
||||
]
|
||||
}, callback);
|
||||
}
|
||||
|
||||
function turnOnPointerEvents(callback) {
|
||||
console.log("SET dom.w3c_pointer_events.enabled as TRUE");
|
||||
console.log("SET layout.css.touch_action.enabled as TRUE");
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1293174</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="text/javascript" src="mochitest_support_external.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
function startTest() {
|
||||
setImplicitPointerCapture(true, loadSubFrame);
|
||||
}
|
||||
function loadSubFrame() {
|
||||
var iframe = document.getElementById("testFrame");
|
||||
iframe.src = "bug1293174_implicit_pointer_capture_for_touch_1.html";
|
||||
}
|
||||
function executeTest(int_win) {
|
||||
sendTouchEvent(int_win, "target0", "touchstart");
|
||||
sendTouchEvent(int_win, "target0", "touchmove");
|
||||
sendTouchEvent(int_win, "target1", "touchmove");
|
||||
sendTouchEvent(int_win, "target0", "touchmove");
|
||||
sendTouchEvent(int_win, "target0", "touchend");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<iframe id="testFrame" height="800" width="1000"></iframe>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1293174</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="text/javascript" src="mochitest_support_external.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
function startTest() {
|
||||
setImplicitPointerCapture(false, loadSubFrame);
|
||||
}
|
||||
function loadSubFrame() {
|
||||
var iframe = document.getElementById("testFrame");
|
||||
iframe.src = "bug1293174_implicit_pointer_capture_for_touch_2.html";
|
||||
}
|
||||
function executeTest(int_win) {
|
||||
sendTouchEvent(int_win, "target0", "touchstart");
|
||||
sendTouchEvent(int_win, "target0", "touchmove");
|
||||
sendTouchEvent(int_win, "target1", "touchmove");
|
||||
sendTouchEvent(int_win, "target0", "touchmove");
|
||||
sendTouchEvent(int_win, "target0", "touchend");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<iframe id="testFrame" height="800" width="1000"></iframe>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -731,6 +731,7 @@ nsIPresShell::FrameSelection()
|
|||
static bool sSynthMouseMove = true;
|
||||
static uint32_t sNextPresShellId;
|
||||
static bool sPointerEventEnabled = true;
|
||||
static bool sPointerEventImplicitCapture = false;
|
||||
static bool sAccessibleCaretEnabled = false;
|
||||
static bool sAccessibleCaretOnTouch = false;
|
||||
static bool sBeforeAfterKeyboardEventEnabled = false;
|
||||
|
@ -808,7 +809,13 @@ PresShell::PresShell()
|
|||
"dom.w3c_pointer_events.enabled", true);
|
||||
addedPointerEventEnabled = true;
|
||||
}
|
||||
|
||||
static bool addedPointerEventImplicitCapture = false;
|
||||
if (!addedPointerEventImplicitCapture) {
|
||||
Preferences::AddBoolVarCache(&sPointerEventImplicitCapture,
|
||||
"dom.w3c_pointer_events.implicit_capture",
|
||||
true);
|
||||
addedPointerEventImplicitCapture = true;
|
||||
}
|
||||
mPaintingIsFrozen = false;
|
||||
mHasCSSBackgroundColor = true;
|
||||
mIsLastChromeOnlyEscapeKeyConsumed = false;
|
||||
|
@ -7691,6 +7698,19 @@ PresShell::HandleEvent(nsIFrame* aFrame,
|
|||
if (!frameKeeper.IsAlive()) {
|
||||
frame = nullptr;
|
||||
}
|
||||
// Implicit pointer capture for touch
|
||||
if (sPointerEventImplicitCapture &&
|
||||
pointerEvent->mMessage == ePointerDown &&
|
||||
pointerEvent->inputSource == nsIDOMMouseEvent::MOZ_SOURCE_TOUCH) {
|
||||
nsCOMPtr<nsIContent> targetContent;
|
||||
frame->GetContentForEvent(aEvent, getter_AddRefs(targetContent));
|
||||
while (targetContent && !targetContent->IsElement()) {
|
||||
targetContent = targetContent->GetParent();
|
||||
}
|
||||
if (targetContent) {
|
||||
SetPointerCapturingContent(pointerEvent->pointerId, targetContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4813,6 +4813,9 @@ pref("dom.w3c_touch_events.enabled", 2);
|
|||
// W3C draft pointer events
|
||||
pref("dom.w3c_pointer_events.enabled", false);
|
||||
|
||||
// W3C pointer events draft
|
||||
pref("dom.w3c_pointer_events.implicit_capture", false);
|
||||
|
||||
// W3C draft ImageCapture API
|
||||
pref("dom.imagecapture.enabled", false);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче