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

How to prevent Servo shutdown on Escape when iframe is focused #11194

Closed
paulrouget opened this issue May 16, 2016 · 1 comment
Closed

How to prevent Servo shutdown on Escape when iframe is focused #11194

paulrouget opened this issue May 16, 2016 · 1 comment

Comments

@paulrouget
Copy link
Contributor

@paulrouget paulrouget commented May 16, 2016

For browserhtml, when we get a keypress event and key is the Escape key, we call event.preventDefault() to prevent Servo to shutdown.

When the user presses escape when an iframe is focused, the event doesn't go through the browserhtml document, so the compositor handles the keyevent and shuts down Servo.

I think the proper way to handle this is to let the event go through the containing pipeline if the iframe is a mozbrowser iframe, to allow the container the stop the propagation during the capturing phase, or, in our case, preventDefault() the event during the bubbling phase. Then the event would not go back the compositor right away.

Another option, a lot simpler, is to just not quit the application on Escape when the focused pipeline is not the top level pipeline. Not sure how that could work, maybe just not send back the key event to the compositor if the pipeline is not the top one:

compositor.send(ScriptToCompositorMsg::SendKeyEvent(key, state, modifiers)).unwrap();

Also, it's a bit annoying we have to prevent the escape event to reach the glutin window object. Maybe the best way is just to have an option (in resources/prefs.json) to allow/disallow shut down on escape (that we would disable for browserhtml).

Please advise.

@jdm
Copy link
Member

@jdm jdm commented May 16, 2016

Having a preference that disables shut down on escape sounds like the most sensible choice to me.

@paulrouget paulrouget mentioned this issue May 16, 2016
4 of 5 tasks complete
bors-servo added a commit that referenced this issue May 16, 2016
Make quit-on-escape optional

For browserhtml, we don't want Servo to shut down when the user presses the escape key.

- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #11194

Either:
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because I don't know how to test shutdown and how to dispatch a non-DOM key event

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11200)
<!-- Reviewable:end -->
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.

2 participants
You can’t perform that action at this time.