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

Properly dispatch keypress event #14738

Merged
merged 3 commits into from Jan 4, 2017
Merged

Properly dispatch keypress event #14738

merged 3 commits into from Jan 4, 2017

Conversation

@wafflespeanut
Copy link
Member

wafflespeanut commented Dec 26, 2016

This was an attempt to fix #14659. It turned out that the problem wasn't what I thought it was. So, I didn't fix that. On the brighter side, this fixes two related issues.

  • Previously, we were unable to launch keypress events from input and textarea elements, because we'd been cancelling the key events, so that they don't trigger window navigation - #8400). I've introduced an enum to represent an additional state to an event's cancellation.
  • According to the spec, keypress (if available) should be dispatched immediately after keydown, and it should be followed by input. Canceling keypress should also cancel input. But, we'd been dispatching input before keypress. We now dispatch input once the keypress event is on the respective elements.

  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes do not require tests because it's a refactor?

r? @jdm or anyone interested


This change is Reviewable

@highfive
Copy link

highfive commented Dec 26, 2016

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/document.rs, components/script/dom/htmltextareaelement.rs, components/script/dom/event.rs, components/script/dom/htmlinputelement.rs
  • @KiChjang: components/script/dom/document.rs, components/script/dom/htmltextareaelement.rs, components/script/dom/event.rs, components/script/dom/htmlinputelement.rs
@highfive
Copy link

highfive commented Dec 26, 2016

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
@wafflespeanut wafflespeanut force-pushed the wafflespeanut:keypress branch 3 times, most recently from 95a2d9a to e039bea Dec 26, 2016
@@ -77,14 +77,21 @@ impl From<bool> for EventCancelable {
}
}

#[derive(JSTraceable, HeapSizeOf, Copy, Clone, PartialEq)]
pub enum EventDefault {

This comment has been minimized.

Copy link
@Ms2ger

Ms2ger Dec 26, 2016

Contributor

This is going to need some clear documentation

This comment has been minimized.

Copy link
@wafflespeanut

wafflespeanut Dec 27, 2016

Author Member

Certainly :)

@wafflespeanut wafflespeanut force-pushed the wafflespeanut:keypress branch from e039bea to 44808cc Dec 27, 2016
@wafflespeanut
Copy link
Member Author

wafflespeanut commented Dec 27, 2016

Do we need tests for this?

@wafflespeanut wafflespeanut force-pushed the wafflespeanut:keypress branch from 44808cc to 5f0b3bd Dec 27, 2016
@jdm
Copy link
Member

jdm commented Dec 27, 2016

I don't think we can write automated tests for this yet, because we can't synthesize key input.

@jdm
Copy link
Member

jdm commented Jan 4, 2017

@bors-servo: r+
Nice work. Sorry about the review delay!

@bors-servo
Copy link
Contributor

bors-servo commented Jan 4, 2017

📌 Commit 5f0b3bd has been approved by jdm

@wafflespeanut
Copy link
Member Author

wafflespeanut commented Jan 4, 2017

Oh please... I haven't actually fixed the issue yet. I'll get back into it once again this weekend 😄

@bors-servo
Copy link
Contributor

bors-servo commented Jan 4, 2017

Testing commit 5f0b3bd with merge 6f9ff7b...

bors-servo added a commit that referenced this pull request Jan 4, 2017
Properly dispatch keypress event

<!-- Please describe your changes on the following line: -->

This was an attempt to fix #14659. It turned out that the problem wasn't what I thought it was. So, I didn't fix that. On the brighter side, this fixes two related issues.

- Previously, we were unable to launch `keypress` events from `input` and `textarea` elements, because [we'd been cancelling](https://github.com/servo/servo/blob/1327ebd52f53f5f6637a12fab6cf0cad0aa0be6f/components/script/dom/htmlinputelement.rs#L1120-L1124) the key events, so that they don't trigger window navigation - #8400). I've introduced an enum to represent an additional state to an event's cancellation.
- [According to the spec](https://w3c.github.io/uievents/#keypress-event-order), `keypress` (if available) should be dispatched immediately after `keydown`, and it should be followed by `input`. Canceling `keypress` should also cancel `input`. But, we'd been dispatching `input` before `keypress`. We now dispatch `input` once the `keypress` event is on the respective elements.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [x] These changes do not require tests because it's a refactor?

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

r? @jdm or anyone interested

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14738)
<!-- Reviewable:end -->
@bors-servo bors-servo merged commit 5f0b3bd into servo:master Jan 4, 2017
2 of 3 checks passed
2 of 3 checks passed
continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
@wafflespeanut wafflespeanut deleted the wafflespeanut:keypress branch Jan 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

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