Bug 1355402 - Support prefixed intrinsic size value for {width,height,{inline,block}-size}}. r?manishearth
MozReview-Commit-ID: ERJh18sHMDq
--- a/servo/components/style/properties/helpers.mako.rs
+++ b/servo/components/style/properties/helpers.mako.rs
@@ -1052,17 +1052,17 @@
}
pub mod computed_value {
pub type T = ::values::computed::${length_type};
}
#[derive(PartialEq, Clone, Debug)]
#[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 {
use values::computed::${length_type};
${length_type}::${initial_value}
}
fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
% if logical:
--- a/servo/components/style/properties/longhand/position.mako.rs
+++ b/servo/components/style/properties/longhand/position.mako.rs
@@ -147,37 +147,41 @@
animation_value_type="ComputedValue" if product == "gecko" else "none")}
% for (size, logical) in ALL_SIZES:
<%
spec = "https://drafts.csswg.org/css-box/#propdef-%s"
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":
+ // width, height, block-size, inline-size
+ ${helpers.gecko_length_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_length_type("min-%s" % size, "MozLength", "auto()",
logical,
spec=spec % size,
animation_value_type="ComputedValue")}
${helpers.gecko_length_type("max-%s" % size, "MaxLength", "none()",
logical,
spec=spec % size,
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))",
"parse_non_negative",
spec=spec % ("min-%s" % size),
animation_value_type="ComputedValue",
logical=logical,
allow_quirks=not logical)}
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -1577,25 +1577,28 @@ pub extern "C" fn Servo_DeclarationBlock
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_SetPixelValue(declarations:
RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID,
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()),
BorderLeftWidth => BorderWidth::Width(nocalc.into()),
MarginTop => nocalc.into(),
MarginRight => nocalc.into(),
MarginBottom => nocalc.into(),
MarginLeft => nocalc.into(),
@@ -1623,16 +1626,18 @@ pub extern "C" fn Servo_DeclarationBlock
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_SetLengthValue(declarations:
RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID,
value: f32,
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};
let long = get_longhand_from_id!(property);
let nocalc = match unit {
structs::nsCSSUnit::eCSSUnit_EM => NoCalcLength::FontRelative(FontRelativeLength::Em(value)),
structs::nsCSSUnit::eCSSUnit_XHeight => NoCalcLength::FontRelative(FontRelativeLength::Ex(value)),
structs::nsCSSUnit::eCSSUnit_Pixel => NoCalcLength::Absolute(AbsoluteLength::Px(value)),
@@ -1642,17 +1647,17 @@ pub extern "C" fn Servo_DeclarationBlock
structs::nsCSSUnit::eCSSUnit_PhysicalMillimeter => NoCalcLength::Physical(PhysicalLength(value)),
structs::nsCSSUnit::eCSSUnit_Point => NoCalcLength::Absolute(AbsoluteLength::Pt(value)),
structs::nsCSSUnit::eCSSUnit_Pica => NoCalcLength::Absolute(AbsoluteLength::Pc(value)),
structs::nsCSSUnit::eCSSUnit_Quarter => NoCalcLength::Absolute(AbsoluteLength::Q(value)),
_ => unreachable!("Unknown unit {:?} passed to SetLengthValue", unit)
};
let prop = match_wrap_declared! { long,
- Width => nocalc.into(),
+ Width => Width(MozLength::LengthOrPercentageOrAuto(nocalc.into())),
FontSize => LengthOrPercentage::from(nocalc).into(),
MozScriptMinSize => MozScriptMinSize(nocalc),
};
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
decls.push(prop, Importance::Normal);
})
}
@@ -1677,48 +1682,53 @@ pub extern "C" fn Servo_DeclarationBlock
}
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_SetPercentValue(declarations:
RawServoDeclarationBlockBorrowed,
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(),
MarginLeft => pc.into(),
FontSize => LengthOrPercentage::from(pc).into(),
};
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
decls.push(prop, Importance::Normal);
})
}
#[no_mangle]
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,
MarginLeft => auto,
};
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
decls.push(prop, Importance::Normal);
})