Bug 1760368 - A fixed element hit in the gutter should not be absorbed. r=botond

When a hit test result hits a fixed element that extends over the gutter, do not
absorb the event.

Depends on D147564

Differential Revision: https://phabricator.services.mozilla.com/D148077
This commit is contained in:
Dan Robertson 2022-06-03 18:12:26 +00:00
Родитель 49c7adc0d3
Коммит f25a982b1d
3 изменённых файлов: 49 добавлений и 28 удалений

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

@ -1889,8 +1889,9 @@ APZEventResult APZCTreeManager::InputHandlingState::Finish(
mEvent.mLayersId = mHit.mLayersId;
}
// If the event is over an overscroll gutter, do not dispatch it to Gecko.
if (mHit.mHitOverscrollGutter) {
// Absorb events that are in targetted at a position in the gutter,
// unless they are fixed position elements.
if (mHit.mHitOverscrollGutter && mHit.mFixedPosSides == SideBits::eNone) {
mResult.SetStatusAsConsumeNoDefault();
}

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

@ -1698,8 +1698,8 @@ class AsyncPanZoomController {
// its composition bounds.
bool Contains(const ScreenIntPoint& aPoint) const;
bool IsInOverscrollGutter(const ScreenPoint& aPoint) const;
bool IsInOverscrollGutter(const ParentLayerPoint& aPoint) const;
bool IsInOverscrollGutter(const ScreenPoint& aHitTestPoint) const;
bool IsInOverscrollGutter(const ParentLayerPoint& aHitTestPoint) const;
bool IsOverscrolled() const;

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

@ -126,31 +126,42 @@ async function test() {
// on both the browser chrome window and the content window.
// This makes sure we catch the case where the overscroll transform causes
// the event to incorrectly target the browser chrome.
startListeningForClickEventsInChrome();
let contentReceivedClick = false;
let contentListener = function(e) {
contentReceivedClick = true;
};
document.addEventListener("click", contentListener);
await synthesizeNativeMouseEventWithAPZ({
type: "click",
target: window,
offsetX: 100,
offsetY: 4
});
// Wait 10 frames for the event to maybe arrive, and if it
// hasn't, assume it won't.
for (let i = 0; i < 10; i++) {
await promiseFrame();
//// Util function to perform mouse events in the gutter. Used to ensure these
//// events are not dispatched to the content.
async function clickInGutter(xOffset, yOffset) {
startListeningForClickEventsInChrome();
let contentReceivedClick = false;
let contentListener = function(e) {
info("event clientX = " + e.clientX);
info("event clientY = " + e.clientY);
info("event target id: " + e.target.id);
contentReceivedClick = true;
};
document.addEventListener("click", contentListener);
await synthesizeNativeMouseEventWithAPZ({
type: "click",
target: window,
offsetX: xOffset,
offsetY: yOffset,
});
// Wait 10 frames for the event to maybe arrive, and if it
// hasn't, assume it won't.
for (let i = 0; i < 10; i++) {
await promiseFrame();
}
info("Finished waiting around for click event");
let chromeReceivedClick = await didChromeReceiveClick();
ok(!chromeReceivedClick,
"Gecko received click event in browser chrome when it shouldn't have");
ok(!contentReceivedClick,
"Gecko received click event targeting web content when it shouldn't have");
stopListeningForClickEventsInChrome();
document.removeEventListener("click", contentListener);
}
info("Finished waiting around for click event");
let chromeReceivedClick = await didChromeReceiveClick();
ok(!chromeReceivedClick,
"Gecko received click event in browser chrome when it shouldn't have");
ok(!contentReceivedClick,
"Gecko received click event targeting web content when it shouldn't have");
stopListeningForClickEventsInChrome();
document.removeEventListener("click", contentListener);
// Perform the test
await clickInGutter(100, 4);
// Finally, while still overscrolled, perform a click not in the gutter.
// This event should successfully go through to the web content, and
@ -193,6 +204,10 @@ async function test() {
await clickFixedPromise;
}
// This hit is technically in the gutter created by the overscroll, but we
// should still dispatch to gecko due to the fixed element extending into
// the gutter.
await clickFixed(4, fixedtarget, false);
// Perform various mouse events to ensure the fixed element has not moved
await clickFixed(10, fixedtarget, false);
await clickFixed(14, fixedtargetbutton, false);
@ -222,6 +237,11 @@ async function test() {
offsetY: 25,
});
await clickFixedPromise;
// Click above the fixed element, but in the gutter.
await clickInGutter(302, 1);
// Click left of the the fixed element, but in the gutter.
await clickInGutter(298, 4);
}
waitUntilApzStable()