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

Move some presentational hints to the new infrastructure. #5988

Merged
merged 4 commits into from May 12, 2015
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Move input size to the new infrastructure.

  • Loading branch information
Ms2ger committed May 11, 2015
commit 0c8e55bff1983e03979435ef7cb7053c18a031a3
@@ -280,6 +280,33 @@ impl RawLayoutElementHelpers for Element {
vertical: width_value,
}))));
}


let size = if self.is_htmlinputelement() {
// FIXME(pcwalton): More use of atoms, please!
// FIXME(Ms2ger): this is nonsense! Invalid values also end up as
// a text field
match self.get_attr_val_for_layout(&ns!(""), &atom!("type")) {
Some("text") | Some("password") => {
let this: &HTMLInputElement = mem::transmute(self);
match this.get_size_for_layout() {
0 => None,
s => Some(s as i32),
}
}
_ => None
}
} else {
None
};

if let Some(size) = size {
let value = specified::Length::ServoCharacterWidth(
specified::CharacterWidth(size));
hints.push(from_declaration(
PropertyDeclaration::Width(SpecifiedValue(
specified::LengthOrPercentageOrAuto::Length(value)))));
}
}

#[inline]
@@ -304,13 +331,6 @@ impl RawLayoutElementHelpers for Element {
unsafe fn get_integer_attribute_for_layout(&self, integer_attribute: IntegerAttribute)
-> Option<i32> {
match integer_attribute {
IntegerAttribute::Size => {
if !self.is_htmlinputelement() {
panic!("I'm not a form input!")
}
let this: &HTMLInputElement = mem::transmute(self);
Some(this.get_size_for_layout() as i32)
}
IntegerAttribute::Cols => {
if !self.is_htmltextareaelement() {
panic!("I'm not a textarea element!")
@@ -30,8 +30,6 @@ pub enum LengthAttribute {
/// Legacy presentational attributes that take an integer as defined in HTML5 § 2.4.4.2.
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum IntegerAttribute {
/// `<input size>`
Size,
Cols,
Rows,
}
@@ -122,25 +120,6 @@ impl PresentationalHintSynthesis for Stylist {
matching_rules_list,
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 => {
let value = specified::Length::ServoCharacterWidth(
specified::CharacterWidth(value));
matching_rules_list.push(from_declaration(
PropertyDeclaration::Width(SpecifiedValue(
specified::LengthOrPercentageOrAuto::Length(value)))));
*shareable = false
}
Some(_) | None => {}
}
}
_ => {}
};
}
name if *name == atom!("textarea") => {
match element.get_integer_attribute(IntegerAttribute::Cols) {
Some(value) if value != 0 => {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.