Skip to content

Properly dispatch keypress event - #14738

Merged
bors-servo merged 3 commits into
masterfrom
unknown repository
Jan 4, 2017
Merged

bors-servo merged 3 commits into
masterfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Dec 26, 2016 •

Copy link
Copy Markdown

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 - Added call to event.PreventDefault on html text inputs and textareas. #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
Copy Markdown

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 highfive added the S-awaiting-review There is new code that needs to be reviewed. label Dec 26, 2016
@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!

}

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to need some clear documentation

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly :)

@ghost

ghost commented Dec 27, 2016

Copy link
Copy Markdown
Author

Do we need tests for this?

@jdm

jdm commented Dec 27, 2016

Copy link
Copy Markdown
Member

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

@jdm

jdm commented Jan 4, 2017

Copy link
Copy Markdown
Member

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

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 5f0b3bd has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Jan 4, 2017
@ghost

ghost commented Jan 4, 2017

Copy link
Copy Markdown
Author

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

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 5f0b3bd with merge 6f9ff7b...

bors-servo pushed 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

Copy link
Copy Markdown
Contributor

@bors-servo
bors-servo merged commit 5f0b3bd into servo:master Jan 4, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 4, 2017
@ghost
ghost deleted the keypress branch January 5, 2017 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Github wiki search doesn't work

4 participants