diff options
author | Bobby Holley <bobbyholley@gmail.com> | 2017-03-15 11:59:53 -0700 |
---|---|---|
committer | Bobby Holley <bobbyholley@gmail.com> | 2017-03-16 14:40:55 -0700 |
commit | 8cf331a49891dfe59be22995c65f706ccbc994d4 (patch) | |
tree | bbe9e1f5681dc8f5532740e783c1bdec0a7cd9c1 /components/script/dom/element.rs | |
parent | e34aac03ffc1cff060eef26b7ed96a69dfd5b08f (diff) | |
download | servo-8cf331a49891dfe59be22995c65f706ccbc994d4.tar.gz servo-8cf331a49891dfe59be22995c65f706ccbc994d4.zip |
Rearrange PropertyDeclaration to avoid embedding DeclaredValue.
From https://bugzilla.mozilla.org/show_bug.cgi?id=1347719
This effectively combines the discriminants of the two enums and reduces the
size of PropertyDeclaration by one word.
MozReview-Commit-ID: 9rCRiSVZTQT
Diffstat (limited to 'components/script/dom/element.rs')
-rw-r--r-- | components/script/dom/element.rs | 52 |
1 files changed, 23 insertions, 29 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 33b2ccb9b7f..dcafd4bf9d7 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -103,8 +103,7 @@ use style::context::{QuirksMode, ReflowGoal}; use style::element_state::*; use style::matching::{common_style_affecting_attributes, rare_style_affecting_attributes}; use style::parser::ParserContextExtraData; -use style::properties::{DeclaredValue, Importance}; -use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, parse_style_attribute}; +use style::properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock, parse_style_attribute}; use style::properties::longhands::{self, background_image, border_spacing, font_family, font_size, overflow_x}; use style::restyle_hints::RESTYLE_SELF; use style::rule_tree::CascadeLevel; @@ -409,8 +408,8 @@ impl LayoutElementHelpers for LayoutJS<Element> { if let Some(color) = bgcolor { hints.push(from_declaration( - PropertyDeclaration::BackgroundColor(DeclaredValue::Value( - CSSColor { parsed: Color::RGBA(color), authored: None })))); + PropertyDeclaration::BackgroundColor( + CSSColor { parsed: Color::RGBA(color), authored: None }))); } let background = if let Some(this) = self.downcast::<HTMLBodyElement>() { @@ -421,12 +420,12 @@ impl LayoutElementHelpers for LayoutJS<Element> { if let Some(url) = background { hints.push(from_declaration( - PropertyDeclaration::BackgroundImage(DeclaredValue::Value( + PropertyDeclaration::BackgroundImage( background_image::SpecifiedValue(vec![ background_image::single_value::SpecifiedValue(Some( specified::Image::for_cascade(url.into(), specified::url::UrlExtraData { }) )) - ]))))); + ])))); } let color = if let Some(this) = self.downcast::<HTMLFontElement>() { @@ -443,12 +442,12 @@ impl LayoutElementHelpers for LayoutJS<Element> { if let Some(color) = color { hints.push(from_declaration( - PropertyDeclaration::Color(DeclaredValue::Value( + PropertyDeclaration::Color( longhands::color::SpecifiedValue(CSSColor { parsed: Color::RGBA(color), authored: None, }) - )) + ) )); } @@ -461,19 +460,16 @@ impl LayoutElementHelpers for LayoutJS<Element> { if let Some(font_family) = font_family { hints.push(from_declaration( PropertyDeclaration::FontFamily( - DeclaredValue::Value( font_family::computed_value::T(vec![ font_family::computed_value::FontFamily::from_atom( - font_family)]))))); + font_family)])))); } let font_size = self.downcast::<HTMLFontElement>().and_then(|this| this.get_size()); if let Some(font_size) = font_size { hints.push(from_declaration( - PropertyDeclaration::FontSize( - DeclaredValue::Value( - font_size::SpecifiedValue(font_size.into()))))) + PropertyDeclaration::FontSize(font_size::SpecifiedValue(font_size.into())))) } let cellspacing = if let Some(this) = self.downcast::<HTMLTableElement>() { @@ -485,11 +481,11 @@ impl LayoutElementHelpers for LayoutJS<Element> { if let Some(cellspacing) = cellspacing { let width_value = specified::Length::from_px(cellspacing as f32); hints.push(from_declaration( - PropertyDeclaration::BorderSpacing(DeclaredValue::Value( + PropertyDeclaration::BorderSpacing( Box::new(border_spacing::SpecifiedValue { horizontal: width_value.clone(), vertical: width_value, - }))))); + })))); } @@ -518,8 +514,8 @@ impl LayoutElementHelpers for LayoutJS<Element> { if let Some(size) = size { let value = specified::NoCalcLength::ServoCharacterWidth(specified::CharacterWidth(size)); hints.push(from_declaration( - PropertyDeclaration::Width(DeclaredValue::Value( - specified::LengthOrPercentageOrAuto::Length(value))))); + PropertyDeclaration::Width( + specified::LengthOrPercentageOrAuto::Length(value)))); } let width = if let Some(this) = self.downcast::<HTMLIFrameElement>() { @@ -543,13 +539,13 @@ impl LayoutElementHelpers for LayoutJS<Element> { let width_value = specified::LengthOrPercentageOrAuto::Percentage(specified::Percentage(percentage)); hints.push(from_declaration( - PropertyDeclaration::Width(DeclaredValue::Value(width_value)))); + PropertyDeclaration::Width(width_value))); } LengthOrPercentageOrAuto::Length(length) => { let width_value = specified::LengthOrPercentageOrAuto::Length( specified::NoCalcLength::Absolute(length)); hints.push(from_declaration( - PropertyDeclaration::Width(DeclaredValue::Value(width_value)))); + PropertyDeclaration::Width(width_value))); } } @@ -568,13 +564,13 @@ impl LayoutElementHelpers for LayoutJS<Element> { let height_value = specified::LengthOrPercentageOrAuto::Percentage(specified::Percentage(percentage)); hints.push(from_declaration( - PropertyDeclaration::Height(DeclaredValue::Value(height_value)))); + PropertyDeclaration::Height(height_value))); } LengthOrPercentageOrAuto::Length(length) => { let height_value = specified::LengthOrPercentageOrAuto::Length( specified::NoCalcLength::Absolute(length)); hints.push(from_declaration( - PropertyDeclaration::Height(DeclaredValue::Value(height_value)))); + PropertyDeclaration::Height(height_value))); } } @@ -596,8 +592,7 @@ impl LayoutElementHelpers for LayoutJS<Element> { // https://html.spec.whatwg.org/multipage/#textarea-effective-width let value = specified::NoCalcLength::ServoCharacterWidth(specified::CharacterWidth(cols)); hints.push(from_declaration( - PropertyDeclaration::Width(DeclaredValue::Value( - specified::LengthOrPercentageOrAuto::Length(value))))); + PropertyDeclaration::Width(specified::LengthOrPercentageOrAuto::Length(value)))); } let rows = if let Some(this) = self.downcast::<HTMLTextAreaElement>() { @@ -615,8 +610,7 @@ impl LayoutElementHelpers for LayoutJS<Element> { // https://html.spec.whatwg.org/multipage/#textarea-effective-height let value = specified::NoCalcLength::FontRelative(specified::FontRelativeLength::Em(rows as CSSFloat)); hints.push(from_declaration( - PropertyDeclaration::Height(DeclaredValue::Value( - specified::LengthOrPercentageOrAuto::Length(value))))); + PropertyDeclaration::Height(specified::LengthOrPercentageOrAuto::Length(value)))); } @@ -629,13 +623,13 @@ impl LayoutElementHelpers for LayoutJS<Element> { if let Some(border) = border { let width_value = specified::BorderWidth::from_length(specified::Length::from_px(border as f32)); hints.push(from_declaration( - PropertyDeclaration::BorderTopWidth(DeclaredValue::Value(width_value.clone())))); + PropertyDeclaration::BorderTopWidth(width_value.clone()))); hints.push(from_declaration( - PropertyDeclaration::BorderLeftWidth(DeclaredValue::Value(width_value.clone())))); + PropertyDeclaration::BorderLeftWidth(width_value.clone()))); hints.push(from_declaration( - PropertyDeclaration::BorderBottomWidth(DeclaredValue::Value(width_value.clone())))); + PropertyDeclaration::BorderBottomWidth(width_value.clone()))); hints.push(from_declaration( - PropertyDeclaration::BorderRightWidth(DeclaredValue::Value(width_value)))); + PropertyDeclaration::BorderRightWidth(width_value))); } } |