style: Disregard the size attribute for input elements other than text

or password fields.

HTML5 § 4.10.5.3.2 doesn't explicitly say to do this, but all other
browser engines seem to do it.

Improves the Google home page.
This commit is contained in:
Patrick Walton 2015-04-24 17:32:05 -07:00
parent 211ee668fa
commit 79336d21b5
5 changed files with 35 additions and 18 deletions

View file

@ -167,18 +167,13 @@ impl PresentationalHintSynthesis for Stylist {
shareable);
}
name if *name == atom!("input") => {
// FIXME(pcwalton): More use of atoms, please!
match element.get_attr(&ns!(""), &atom!("type")) {
Some("text") | Some("password") => {
match element.get_integer_attribute(IntegerAttribute::Size) {
Some(value) if value != 0 => {
// Per HTML 4.01 § 17.4, this value is in characters if `type` is `text` or
// `password` and in pixels otherwise.
//
// FIXME(pcwalton): More use of atoms, please!
let value = match element.get_attr(&ns!(""), &atom!("type")) {
Some("text") | Some("password") => {
specified::Length::ServoCharacterWidth(specified::CharacterWidth(value))
}
_ => specified::Length::Absolute(Au::from_px(value as isize)),
};
let value = specified::Length::ServoCharacterWidth(
specified::CharacterWidth(value));
matching_rules_list.vec_push(from_declaration(
PropertyDeclaration::Width(SpecifiedValue(
specified::LengthOrPercentageOrAuto::Length(value)))));
@ -187,6 +182,9 @@ impl PresentationalHintSynthesis for Stylist {
Some(_) | None => {}
}
}
_ => {}
};
}
name if *name == atom!("textarea") => {
match element.get_integer_attribute(IntegerAttribute::Cols) {
Some(value) if value != 0 => {

View file

@ -4,7 +4,7 @@ textarea { background: white; min-height: 1.0em; padding: 0em; pa
button,
input[type="button"],
input[type="submit"],
input[type="reset"] { background: lightgrey; border-top: solid 1px #EEEEEE; border-left: solid 1px #CCCCCC; border-right: solid 1px #999999; border-bottom: solid 1px #999999; text-align: center; vertical-align: middle; color: black; width: 100%; }
input[type="reset"] { background: lightgrey; border-top: solid 1px #EEEEEE; border-left: solid 1px #CCCCCC; border-right: solid 1px #999999; border-bottom: solid 1px #999999; text-align: center; vertical-align: middle; color: black; }
input[type="hidden"] { display: none !important }
input[type="checkbox"],
input[type="radio"] { font-family: monospace !important; border: none !important; background: transparent; }

View file

@ -179,6 +179,7 @@ flaky_cpu == append_style_a.html append_style_b.html
# inline_text_align_a.html inline_text_align_b.html
== inline_whitespace_a.html inline_whitespace_ref.html
== inline_whitespace_b.html inline_whitespace_ref.html
== input_button_size_a.html input_button_size_ref.html
!= input_height_a.html input_height_ref.html
== inset.html inset_ref.html
!= inset_blackborder.html blackborder_ref.html

View file

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<input type=submit size=100 value=sumbit>
</body>
</html>

View file

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<input type=submit value=sumbit>
</body>
</html>