Backed out changeset 2fb0417cfd2f (bug 1959275) for causing wpt failures at pointerdown-add-overflow-hidden.html. CLOSED TREE

This commit is contained in:
Cristina Horotan
2025-04-16 21:49:30 +03:00
parent 32eaee26c4
commit 95088967b9
6 changed files with 21 additions and 108 deletions

View File

@@ -6627,8 +6627,6 @@ void EventStateManager::ContentRemoved(Document* aDocument,
entry.GetData()->ContentRemoved(*aContent);
}
}
NotifyContentWillBeRemovedForGesture(*aContent);
}
void EventStateManager::TextControlRootWillBeRemoved(
@@ -7516,24 +7514,24 @@ bool EventStateManager::WheelPrefs::IsOverOnePageScrollAllowedY(
MIN_MULTIPLIER_VALUE_ALLOWING_OVER_ONE_PAGE_SCROLL;
}
void EventStateManager::NotifyContentWillBeRemovedForGesture(
nsIContent& aContent) {
if (!mGestureDownContent) {
void EventStateManager::NotifyDestroyingFrameForGesture(nsIFrame* aFrame) {
MOZ_ASSERT(aFrame);
if (mGestureDownContent != aFrame->GetContent()) {
return;
}
if (!nsContentUtils::ContentIsFlattenedTreeDescendantOf(mGestureDownContent,
&aContent)) {
return;
}
if (nsIFrame* parent = aFrame->GetParent()) {
nsIFrame* f = nsLayoutUtils::GetNonGeneratedAncestor(parent);
MOZ_ASSERT(f);
nsIContent* parent = aContent.GetFlattenedTreeParent();
mGestureDownContent = parent;
mGestureDownFrameOwner = parent;
mGestureDownInTextControl =
parent && parent->IsInNativeAnonymousSubtree() &&
TextControlElement::FromNodeOrNull(
parent->GetClosestNativeAnonymousSubtreeRootParentOrHost());
nsIContent* content = f->GetContent();
mGestureDownContent = content;
mGestureDownFrameOwner = content;
mGestureDownInTextControl =
content && content->IsInNativeAnonymousSubtree() &&
TextControlElement::FromNodeOrNull(
content->GetClosestNativeAnonymousSubtreeRootParentOrHost());
}
}
} // namespace mozilla

View File

@@ -530,9 +530,10 @@ class EventStateManager : public nsSupportsWeakReference, public nsIObserver {
return mGestureDownContent;
}
// Update the tracked gesture content to the parent of its frame when it's
// removed, so that the gesture can be continued.
void NotifyContentWillBeRemovedForGesture(nsIContent& aContent);
// If the current frame is for the current gesture down content (being
// dragged), when it's destroyed, we should continue the gesture on its
// parent.
void NotifyDestroyingFrameForGesture(nsIFrame* aFrame);
bool IsTrackingDragGesture() const { return mGestureDownContent != nullptr; }

View File

@@ -2249,6 +2249,9 @@ void PresShell::NotifyDestroyingFrame(nsIFrame* aFrame) {
}
}
EventStateManager* const esm = mPresContext->EventStateManager();
esm->NotifyDestroyingFrameForGesture(aFrame);
mFramesToDirty.Remove(aFrame);
if (ScrollContainerFrame* scrollContainerFrame = do_QueryFrame(aFrame)) {

View File

@@ -1,47 +0,0 @@
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<head>
<title>Test dragging still occurs when mousedown moves the inner element</title>
</head>
<body>
<div id="container">
<template shadowrootmode="open">
<div id="element" draggable="true" style="width: 40px; height: 40px; background-color:red;">
<slot id="slot"></slot>
</div>
<div id="element2"></div>
</template>
<div id="inner" style="width: 30px; height: 30px; background-color:black;"></div>
</div>
<script>
promise_test(function() {
return new Promise(r => {
const element = container.shadowRoot.getElementById("element");
element.addEventListener("dragstart", function(e) {
assert_equals(e.target, element);
r();
});
element.addEventListener("mousedown", function() {
const element2 = container.shadowRoot.getElementById("element2");
const slot = container.shadowRoot.getElementById("slot");
element2.appendChild(slot);
});
new test_driver.Actions()
.pointerMove(0, 0, {origin: inner})
.pointerDown()
.pointerMove(10, 10, {origin:inner})
.pointerUp()
.send();
});
}, "dragstart should still fire when the mousedown event moves the container of the inner element around");
</script>
</body>
</html>

View File

@@ -1,42 +0,0 @@
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<head>
<title>Test dragging still occurs when pointerdown adds overflow:hidden to the dragged element</title>
<style>
.dragging {
overflow: hidden;
}
</style>
</head>
<body>
<li id="item" draggable="true">
Item 1
</li>
<script>
promise_test(function() {
return new Promise(r => {
item.addEventListener("pointerdown", function() {
item.classList.add("dragging");
});
item.addEventListener("dragstart", function(e) {
assert_equals(e.target, item);
r();
});
new test_driver.Actions()
.pointerMove(0, 0, {origin: item})
.pointerDown()
.pointerMove(10, 10, {origin: item})
.pointerUp()
.send();
});
}, "dragstart should still fire when the dragged element gets overflow:hidden in its pointerdown");
</script>
</body>
</html>