From 79336d21b530a3fc553fa75554dc668f3f5c7349 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 24 Apr 2015 17:32:05 -0700 Subject: [PATCH] style: Disregard the `size` attribute for input elements other than text or password fields. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- components/style/legacy.rs | 32 +++++++++++++--------------- resources/servo.css | 2 +- tests/ref/basic.list | 1 + tests/ref/input_button_size_a.html | 9 ++++++++ tests/ref/input_button_size_ref.html | 9 ++++++++ 5 files changed, 35 insertions(+), 18 deletions(-) create mode 100644 tests/ref/input_button_size_a.html create mode 100644 tests/ref/input_button_size_ref.html diff --git a/components/style/legacy.rs b/components/style/legacy.rs index 7ddee2f8a0d..2ce112a2f3a 100644 --- a/components/style/legacy.rs +++ b/components/style/legacy.rs @@ -167,25 +167,23 @@ impl PresentationalHintSynthesis for Stylist { shareable); } name if *name == atom!("input") => { - 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)) + // 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 => { + let value = specified::Length::ServoCharacterWidth( + specified::CharacterWidth(value)); + matching_rules_list.vec_push(from_declaration( + PropertyDeclaration::Width(SpecifiedValue( + specified::LengthOrPercentageOrAuto::Length(value))))); + *shareable = false } - _ => specified::Length::Absolute(Au::from_px(value as isize)), - }; - matching_rules_list.vec_push(from_declaration( - PropertyDeclaration::Width(SpecifiedValue( - specified::LengthOrPercentageOrAuto::Length(value))))); - *shareable = false + Some(_) | None => {} + } } - Some(_) | None => {} - } + _ => {} + }; } name if *name == atom!("textarea") => { match element.get_integer_attribute(IntegerAttribute::Cols) { diff --git a/resources/servo.css b/resources/servo.css index e62ca9837bb..6008dafc2db 100644 --- a/resources/servo.css +++ b/resources/servo.css @@ -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; } diff --git a/tests/ref/basic.list b/tests/ref/basic.list index 8d8a6b21add..1e9a887fcb1 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -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 diff --git a/tests/ref/input_button_size_a.html b/tests/ref/input_button_size_a.html new file mode 100644 index 00000000000..4640d1f199b --- /dev/null +++ b/tests/ref/input_button_size_a.html @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/ref/input_button_size_ref.html b/tests/ref/input_button_size_ref.html new file mode 100644 index 00000000000..672f4d7e67f --- /dev/null +++ b/tests/ref/input_button_size_ref.html @@ -0,0 +1,9 @@ + + + + + + + + +