diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-12-06 14:16:04 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-06 14:16:04 -0600 |
commit | 6a6da9c2a4805d28365961c6ecd1e8dc7559b0b1 (patch) | |
tree | ef4e147b52d7d55f6f8640ea08aae847132b14f3 /components/script/dom/textcontrol.rs | |
parent | 7fd7c21c4c99dd9f8e118948f0c52d4b4073d559 (diff) | |
parent | 05bfb8d07aec90a232d12e503dc611d3dbd4bc0a (diff) | |
download | servo-6a6da9c2a4805d28365961c6ecd1e8dc7559b0b1.tar.gz servo-6a6da9c2a4805d28365961c6ecd1e8dc7559b0b1.zip |
Auto merge of #19471 - jonleighton:input-type, r=jdm
Expand InputType to cover all possible types
This came out of a conversation with nox in IRC:
https://mozilla.logbot.info/servo/20171201#c13946454-c13946594
The code I was working on which motivated this change is here:
https://github.com/servo/servo/pull/19461
Previously, InputType::Text was used to represent several different
values of the type attribute on an input element.
If an input element doesn't have a type attribute, or its type attribute
doesn't contain a recognised value, then the input's type defaults to
"text".
Before this change, there were a number of checks in the code which
directly looked at the type attribute. If those checks matched against
the value "text", then they were potentially buggy, since an input with
type=invalid should also behave like an input with type=text.
Rather than have every conditional which cares about the input type also
have to deal with invalid input types, we can convert the type attribute
to an InputType enum once, and then match against the enum.
A secondary benefit is that the compiler can tell us whether we've
missed branches in a match expression. While working on this I
discovered that the HTMLInputElement::value_mode() method misses a case
for inputs with type=hidden (this resulted in a failing WPT test
passing).
I've also implemented the Default trait for InputType, so we now only
have one place in the code which knows that InputType::Text is the
default, where previously there were several.
<!-- 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/19471)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/textcontrol.rs')
0 files changed, 0 insertions, 0 deletions