Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Click event erroneously firing on div which is not visible due to CSS translateZ transform. #12411

Open
samuknet opened this issue Jul 12, 2016 · 6 comments

Comments

@samuknet
Copy link
Contributor

@samuknet samuknet commented Jul 12, 2016

When an element has been transformed such that it is no longer visible, clicking anywhere on the page in Servo fires a click event on the element.

In example below, FF/Chrome the click event (correctly) does not fire. In Servo, clicking anywhere on the page fires the event, even though the is "behind the screen" and not visible.

<style>
        body {
            margin: 0;
            padding: 0;
        }
        div {
            border: 1px solid black;
            width: 100vw;
            height: 100vh;
            background-color:#83D0FC;
            transform: perspective(500px) translateZ(500px);
        }
</style>
<div></div>
<script>
        document.querySelector('div').addEventListener('click', function() {
            console.log('Event firing when div not visible on page');
        });
</script>

Online test case here.

@jdm
Copy link
Member

@jdm jdm commented Jul 12, 2016

@pcwalton I guess hit testing is somehow not taking the transform into account? Could you look into this?

@samuknet
Copy link
Contributor Author

@samuknet samuknet commented Jul 12, 2016

@jdm Out of interest, just to take a look, where could I find the relevant hit testing code? I would just be interested to read it and further my understanding a little.

@jdm
Copy link
Member

@jdm jdm commented Jul 12, 2016

Look for the code that assigns hit_test_response from components/layout/query.rs. I'd give a better answer but I'm getting on an airplane :)

@pcwalton
Copy link
Contributor

@pcwalton pcwalton commented Jul 25, 2016

@jdm It may be that the code that determines whether to check the descendants of a stacking context isn't taking the transform into account, and as such its items never get checked.

@mrobinson mrobinson self-assigned this Aug 11, 2017
@mrobinson
Copy link
Member

@mrobinson mrobinson commented Aug 11, 2017

Hit testing takes into account transforms, but only in the x and y dimension, which is why I think this test is failing.

@dralley
Copy link
Contributor

@dralley dralley commented Apr 1, 2020

This still happens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.