Backed out 8 changesets (bug 1806400) for causing OS X mochitests plain failures in test_group_mouseevents.html. CLOSED TREE

Backed out changeset 714d9f890934 (bug 1806400)
Backed out changeset dac639d70f03 (bug 1806400)
Backed out changeset f63cc5d45f1c (bug 1806400)
Backed out changeset 0ad571f73504 (bug 1806400)
Backed out changeset 7dfd76acbfe8 (bug 1806400)
Backed out changeset 01f63c388f1e (bug 1806400)
Backed out changeset 43175acb60fc (bug 1806400)
Backed out changeset 7d1d8ba28a7f (bug 1806400)
This commit is contained in:
Stanca Serban 2024-02-21 08:32:09 +02:00
parent c5089cda6b
commit d405168c4d
7 changed files with 18 additions and 143 deletions

View File

@ -3453,13 +3453,6 @@ void EventStateManager::PostHandleKeyboardEvent(
}
}
static bool NeedsActiveContentChange(const WidgetMouseEvent* aMouseEvent) {
// If the mouse event is a synthesized mouse event due to a touch, do
// not set/clear the activation state. Element activation is handled by APZ.
return !aMouseEvent ||
aMouseEvent->mInputSource != MouseEvent_Binding::MOZ_SOURCE_TOUCH;
}
nsresult EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
WidgetEvent* aEvent,
nsIFrame* aTargetFrame,
@ -3703,9 +3696,7 @@ nsresult EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
}
// XXX Why do we always set this is active? Active window may be changed
// by a mousedown event listener.
if (NeedsActiveContentChange(mouseEvent)) {
SetActiveManager(this, activeContent);
}
SetActiveManager(this, activeContent);
} break;
case ePointerCancel:
case ePointerUp: {
@ -3733,7 +3724,10 @@ nsresult EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
PresShell::ReleaseCapturingContent();
WidgetMouseEvent* mouseUpEvent = aEvent->AsMouseEvent();
if (NeedsActiveContentChange(mouseUpEvent)) {
// If the mouseup event is a synthesized mouse event due to a touch, do
// not clear the activation state. Element activation is handled by APZ.
if (!mouseUpEvent || mouseUpEvent->mInputSource !=
dom::MouseEvent_Binding::MOZ_SOURCE_TOUCH) {
ClearGlobalActiveContent(this);
}
if (mouseUpEvent && EventCausesClickEvents(*mouseUpEvent)) {

View File

@ -1,54 +0,0 @@
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<title>Tests that :active state is changed with `touchstart` event listener</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<script src="apz_test_utils.js"></script>
<script src="apz_test_native_event_utils.js"></script>
<style>
#button {
width: 100px;
height: 100px;
}
</style>
<button id="button">Button</button>
<script>
async function test() {
// Set up an active touchstart event listner.
let eventPromise = promiseOneEvent(document.documentElement, "touchstart");
await promiseApzFlushedRepaints();
await synthesizeNativeTouch(button, 10, 10, SpecialPowers.DOMWindowUtils.TOUCH_CONTACT);
await eventPromise;
// In JS there's no way to ensure `APZStateChange::eStartTouch` notification
// has been processed. So we wait for `:active` state change here.
await SimpleTest.promiseWaitForCondition(
() => button.matches(":active"),
"Waiting for :active state change");
ok(button.matches(":active"), "should be active");
eventPromise = promiseOneEvent(button, "touchend");
await synthesizeNativeTouch(button, 10, 10, SpecialPowers.DOMWindowUtils.TOUCH_REMOVE);
await eventPromise;
// Same as above. We need to wait for not `:active` state here.
await SimpleTest.promiseWaitForCondition(
() => !button.matches(":active"),
"Waiting for :active state change");
ok(!button.matches(":active"), "should not be active");
}
if (getPlatform() == "windows") {
// Bug 1875916. On Windows synthesizeNativeTouch(TOUCH_REMOVE) causes
// `InjectTouchInput failure` with ERROR_TIMEOUT.
ok(true, "Test doesn't need to run on Windows");
subtestDone();
} else {
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
}
</script>
</html>

View File

@ -76,13 +76,6 @@ async function test() {
promiseOneEvent(targetElem, "click"),
];
// Create a promise for :active state change since in the case where the
// target element is inside a scrollable container, APZ delays :active state
// change, it sometimes happens after all the relavant events above.
const activePromise = SimpleTest.promiseWaitForCondition(
() => targetElem.matches(":active"),
"Waiting for :active state change");
// Perform a tap gesture
await synthesizeNativeTap(targetElem, 50, 50);
@ -95,7 +88,7 @@ async function test() {
// The value of ui.touch_activation.duration_ms should be set to
// a large value. If we did not delay sending the synthesized
// mouse events, this test will not timeout.
await Promise.all([...mouseEventPromises, activePromise]);
await Promise.all(mouseEventPromises);
clearTimeout(failTimeout);

View File

@ -23,13 +23,6 @@ var subtests = [
{"file": "helper_bug1719855.html?prevent=contextmenu"},
{"file": "helper_bug1719855.html"},
{"file": "helper_bug1724759.html"},
{"file": "helper_bug1806400.html", "prefs": [
// This test uses `SimpleTest.promiseWaitForCondition` which waits for the
// given condition up to 3s, to avoid opening context menu during the time
// span use a longer `ui.click_hold_context_menus.delay` here.
["ui.click_hold_context_menus.delay", 10000],
["ui.touch_activation.duration_ms", 1000]
]},
// Add new subtests here. If this starts timing out because it's taking too
// long, create a test_group_touchevents-6.html file. Refer to 1423011#c57
// for more details.

View File

@ -353,9 +353,7 @@ void APZEventState::ProcessTouchEvent(
}
[[fallthrough]];
case eTouchCancel:
if (mActiveElementManager->HandleTouchEndEvent(mEndTouchIsClick)) {
mEndTouchIsClick = false;
}
mActiveElementManager->HandleTouchEndEvent(mEndTouchIsClick);
[[fallthrough]];
case eTouchMove: {
if (!mReceivedNonTouchStart) {
@ -535,9 +533,7 @@ void APZEventState::ProcessAPZStateChange(ViewID aViewId,
}
case APZStateChange::eEndTouch: {
mEndTouchIsClick = aArg;
if (mActiveElementManager->HandleTouchEnd(mEndTouchIsClick)) {
mEndTouchIsClick = false;
}
mActiveElementManager->HandleTouchEnd();
break;
}
}

View File

@ -137,10 +137,7 @@ void DelayedClearElementActivation::ClearGlobalActiveContent() {
NS_IMPL_ISUPPORTS(DelayedClearElementActivation, nsITimerCallback, nsINamed)
ActiveElementManager::ActiveElementManager()
: mCanBePan(false),
mCanBePanSet(false),
mSingleTapBeforeActivation(false),
mSetActiveTask(nullptr) {}
: mCanBePan(false), mCanBePanSet(false), mSetActiveTask(nullptr) {}
ActiveElementManager::~ActiveElementManager() = default;
@ -197,9 +194,6 @@ void ActiveElementManager::TriggerElementActivation() {
SetActive(mTarget);
if (mDelayedClearElementActivation) {
if (mSingleTapBeforeActivation) {
mDelayedClearElementActivation->MarkSingleTapProcessed();
}
mDelayedClearElementActivation->StartTimer();
}
} else {
@ -216,10 +210,6 @@ void ActiveElementManager::TriggerElementActivation() {
task.forget(), StaticPrefs::ui_touch_activation_delay_ms());
AEM_LOG("Scheduling mSetActiveTask %p\n", mSetActiveTask.get());
}
AEM_LOG(
"Got both touch-end event and end touch notiication, clearing pan "
"state\n");
mCanBePanSet = false;
}
void ActiveElementManager::ClearActivation() {
@ -228,37 +218,18 @@ void ActiveElementManager::ClearActivation() {
ResetActive();
}
bool ActiveElementManager::HandleTouchEndEvent(bool aWasClick) {
void ActiveElementManager::HandleTouchEndEvent(bool aWasClick) {
AEM_LOG("Touch end event, aWasClick: %d\n", aWasClick);
// If the touch was a click, make mTarget :active right away.
// nsEventStateManager will reset the active element when processing
// the mouse-down event generated by the click.
CancelTask();
mTouchEndState += TouchEndState::GotTouchEndEvent;
return MaybeChangeActiveState(aWasClick);
}
bool ActiveElementManager::HandleTouchEnd(bool aWasClick) {
AEM_LOG("Touch end\n");
mTouchEndState += TouchEndState::GotTouchEndNotification;
return MaybeChangeActiveState(aWasClick);
}
bool ActiveElementManager::MaybeChangeActiveState(bool aWasClick) {
if (mTouchEndState !=
TouchEndStates(TouchEndState::GotTouchEndEvent,
TouchEndState::GotTouchEndNotification)) {
return false;
}
if (aWasClick) {
// Scrollbar thumbs use a different mechanism for their active
// highlight (the "active" attribute), so don't set the active state
// on them because nothing will clear it.
if (mCanBePan && !(mTarget && mTarget->IsXULElement(nsGkAtoms::thumb))) {
if (!(mTarget && mTarget->IsXULElement(nsGkAtoms::thumb))) {
SetActive(mTarget);
}
} else {
@ -269,14 +240,15 @@ bool ActiveElementManager::MaybeChangeActiveState(bool aWasClick) {
}
ResetTouchBlockState();
return true;
}
void ActiveElementManager::HandleTouchEnd() {
AEM_LOG("Touch end, clearing pan state\n");
mCanBePanSet = false;
}
void ActiveElementManager::ProcessSingleTap() {
if (!mDelayedClearElementActivation) {
// We have not received touch-start notification yet. We will have to run
// MarkSingleTapProcessed() when we receive the touch-start notification.
mSingleTapBeforeActivation = true;
return;
}
@ -326,8 +298,6 @@ void ActiveElementManager::ResetActive() {
void ActiveElementManager::ResetTouchBlockState() {
mTarget = nullptr;
mCanBePanSet = false;
mTouchEndState.clear();
mSingleTapBeforeActivation = false;
}
void ActiveElementManager::SetActiveTask(

View File

@ -9,7 +9,6 @@
#include "nsCOMPtr.h"
#include "nsISupportsImpl.h"
#include "mozilla/EnumSet.h"
namespace mozilla {
@ -58,12 +57,12 @@ class ActiveElementManager final {
* Handle a touch-end or touch-cancel event.
* @param aWasClick whether the touch was a click
*/
bool HandleTouchEndEvent(bool aWasClick);
void HandleTouchEndEvent(bool aWasClick);
/**
* Handle a touch-end state notification from APZ. This notification may be
* delayed until after touch listeners have responded to the APZ.
*/
bool HandleTouchEnd(bool aWasClick);
void HandleTouchEnd();
/**
* Possibly clear active element sate in response to a single tap.
*/
@ -88,21 +87,6 @@ class ActiveElementManager final {
* SetTargetElement() to be called in either order.
*/
bool mCanBePanSet;
bool mSingleTapBeforeActivation;
enum class TouchEndState : uint8_t {
GotTouchEndNotification,
GotTouchEndEvent,
};
using TouchEndStates = EnumSet<TouchEndState>;
/**
* A flag tracks whether `APZStateChange::eEndTouch` notification has arrived
* and whether `eTouchEnd` event has arrived.
*/
TouchEndStates mTouchEndState;
/**
* A task for calling SetActive() after a timeout.
*/
@ -119,7 +103,6 @@ class ActiveElementManager final {
void ResetTouchBlockState();
void SetActiveTask(const nsCOMPtr<dom::Element>& aTarget);
void CancelTask();
bool MaybeChangeActiveState(bool aWasClick);
};
} // namespace layers