diff options
-rw-r--r-- | components/style/properties/helpers.mako.rs | 2 | ||||
-rw-r--r-- | components/style/properties/longhand/position.mako.rs | 111 | ||||
-rw-r--r-- | ports/geckolib/glue.rs | 26 |
3 files changed, 31 insertions, 108 deletions
diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index 1de154f9a09..23398a9729e 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -1088,7 +1088,7 @@ #[derive(Clone, Debug, HasViewportPercentage, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - pub struct SpecifiedValue(${length_type}); + pub struct SpecifiedValue(pub ${length_type}); #[inline] pub fn get_initial_value() -> computed_value::T { diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index 652c8e31fd2..270430333cd 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -152,106 +152,12 @@ ${helpers.predefined_type("flex-basis", if logical: spec = "https://drafts.csswg.org/css-logical-props/#propdef-%s" %> - // width, height, block-size, inline-size - ${helpers.predefined_type("%s" % size, - "LengthOrPercentageOrAuto", - "computed::LengthOrPercentageOrAuto::Auto", - "parse_non_negative", - spec=spec % size, - allow_quirks=not logical, - animation_value_type="ComputedValue", logical = logical)} % if product == "gecko": - % for min_max in ["min", "max"]: - <% - LengthType = "MaxLength" if "max" == min_max else "MozLength" - initial = "none()" if "max" == min_max else "auto()" - %> - - // min-width, min-height, min-block-size, min-inline-size, - // max-width, max-height, max-block-size, max-inline-size - // - // Keyword values are only valid in the inline direction; they must - // be replaced with auto/none in block. - <%helpers:longhand name="${min_max}-${size}" spec="${spec % ('%s-%s' % (min_max, size))}" - animation_value_type="ComputedValue" - logical="${logical}" predefined_type="${LengthType}"> - - use std::fmt; - use style_traits::ToCss; - % if not logical: - use values::specified::AllowQuirks; - % endif - use values::specified::${LengthType}; - - - pub mod computed_value { - pub type T = ::values::computed::${LengthType}; - } - - #[derive(Clone, Debug, HasViewportPercentage, PartialEq)] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - pub struct SpecifiedValue(${LengthType}); - - #[inline] - pub fn get_initial_value() -> computed_value::T { - use values::computed::${LengthType}; - ${LengthType}::${initial} - } - fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> { - % if logical: - let ret = ${LengthType}::parse(context, input); - % else: - let ret = ${LengthType}::parse_quirky(context, input, AllowQuirks::Yes); - % endif - // Keyword values don't make sense in the block direction; don't parse them - % if "block" in size: - if let Ok(${LengthType}::ExtremumLength(..)) = ret { - return Err(()) - } - % endif - ret.map(SpecifiedValue) - } - - impl ToCss for SpecifiedValue { - fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { - self.0.to_css(dest) - } - } - - impl ToComputedValue for SpecifiedValue { - type ComputedValue = computed_value::T; - #[inline] - fn to_computed_value(&self, context: &Context) -> computed_value::T { - % if not logical or "block" in size: - use values::computed::${LengthType}; - % endif - let computed = self.0.to_computed_value(context); - - // filter out keyword values in the block direction - % if logical: - % if "block" in size: - if let ${LengthType}::ExtremumLength(..) = computed { - return get_initial_value() - } - % endif - % else: - if let ${LengthType}::ExtremumLength(..) = computed { - <% is_height = "true" if "height" in size else "false" %> - if ${is_height} != context.style().writing_mode.is_vertical() { - return get_initial_value() - } - } - % endif - computed - } - - #[inline] - fn from_computed_value(computed: &computed_value::T) -> Self { - SpecifiedValue(ToComputedValue::from_computed_value(computed)) - } - } - </%helpers:longhand> - % endfor + // width, height, block-size, inline-size + ${helpers.gecko_size_type("%s" % size, "MozLength", "auto()", + logical, + spec=spec % size, + animation_value_type="ComputedValue")} // min-width, min-height, min-block-size, min-inline-size, // max-width, max-height, max-block-size, max-inline-size ${helpers.gecko_size_type("min-%s" % size, "MozLength", "auto()", @@ -264,6 +170,13 @@ ${helpers.predefined_type("flex-basis", animation_value_type="ComputedValue")} % else: // servo versions (no keyword support) + ${helpers.predefined_type("%s" % size, + "LengthOrPercentageOrAuto", + "computed::LengthOrPercentageOrAuto::Auto", + "parse_non_negative", + spec=spec % size, + allow_quirks=not logical, + animation_value_type="ComputedValue", logical = logical)} ${helpers.predefined_type("min-%s" % size, "LengthOrPercentage", "computed::LengthOrPercentage::Length(Au(0))", diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index a78a43ef395..835d99feeca 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -1770,15 +1770,18 @@ pub extern "C" fn Servo_DeclarationBlock_SetPixelValue(declarations: value: f32) { use style::properties::{PropertyDeclaration, LonghandId}; use style::properties::longhands::border_spacing::SpecifiedValue as BorderSpacing; + use style::properties::longhands::height::SpecifiedValue as Height; + use style::properties::longhands::width::SpecifiedValue as Width; use style::values::specified::BorderWidth; + use style::values::specified::MozLength; use style::values::specified::length::{NoCalcLength, LengthOrPercentage}; let long = get_longhand_from_id!(property); let nocalc = NoCalcLength::from_px(value); let prop = match_wrap_declared! { long, - Height => nocalc.into(), - Width => nocalc.into(), + Height => Height(MozLength::LengthOrPercentageOrAuto(nocalc.into())), + Width => Width(MozLength::LengthOrPercentageOrAuto(nocalc.into())), BorderTopWidth => BorderWidth::Width(nocalc.into()), BorderRightWidth => BorderWidth::Width(nocalc.into()), BorderBottomWidth => BorderWidth::Width(nocalc.into()), @@ -1816,6 +1819,8 @@ pub extern "C" fn Servo_DeclarationBlock_SetLengthValue(declarations: unit: structs::nsCSSUnit) { use style::properties::{PropertyDeclaration, LonghandId}; use style::properties::longhands::_moz_script_min_size::SpecifiedValue as MozScriptMinSize; + use style::properties::longhands::width::SpecifiedValue as Width; + use style::values::specified::MozLength; use style::values::specified::length::{AbsoluteLength, FontRelativeLength, PhysicalLength}; use style::values::specified::length::{LengthOrPercentage, NoCalcLength}; @@ -1835,7 +1840,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetLengthValue(declarations: }; let prop = match_wrap_declared! { long, - Width => nocalc.into(), + Width => Width(MozLength::LengthOrPercentageOrAuto(nocalc.into())), FontSize => LengthOrPercentage::from(nocalc).into(), MozScriptMinSize => MozScriptMinSize(nocalc), }; @@ -1870,14 +1875,17 @@ pub extern "C" fn Servo_DeclarationBlock_SetPercentValue(declarations: property: nsCSSPropertyID, value: f32) { use style::properties::{PropertyDeclaration, LonghandId}; + use style::properties::longhands::height::SpecifiedValue as Height; + use style::properties::longhands::width::SpecifiedValue as Width; + use style::values::specified::MozLength; use style::values::specified::length::{LengthOrPercentage, Percentage}; let long = get_longhand_from_id!(property); let pc = Percentage(value); let prop = match_wrap_declared! { long, - Height => pc.into(), - Width => pc.into(), + Height => Height(MozLength::LengthOrPercentageOrAuto(pc.into())), + Width => Width(MozLength::LengthOrPercentageOrAuto(pc.into())), MarginTop => pc.into(), MarginRight => pc.into(), MarginBottom => pc.into(), @@ -1894,14 +1902,16 @@ pub extern "C" fn Servo_DeclarationBlock_SetAutoValue(declarations: RawServoDeclarationBlockBorrowed, property: nsCSSPropertyID) { use style::properties::{PropertyDeclaration, LonghandId}; - use style::values::specified::LengthOrPercentageOrAuto; + use style::properties::longhands::height::SpecifiedValue as Height; + use style::properties::longhands::width::SpecifiedValue as Width; + use style::values::specified::{LengthOrPercentageOrAuto, MozLength}; let long = get_longhand_from_id!(property); let auto = LengthOrPercentageOrAuto::Auto; let prop = match_wrap_declared! { long, - Height => auto, - Width => auto, + Height => Height(MozLength::LengthOrPercentageOrAuto(auto)), + Width => Width(MozLength::LengthOrPercentageOrAuto(auto)), MarginTop => auto, MarginRight => auto, MarginBottom => auto, |