Add gecko glue for grid <track-size>

This commit is contained in:
Ravi Shankar 2017-02-18 11:13:19 +05:30
parent 6d4cf7424c
commit 5d740e4edd
2 changed files with 66 additions and 2 deletions

View file

@ -961,7 +961,7 @@ fn static_assert() {
<%self:impl_trait style_struct_name="Position"
skip_longhands="${skip_position_longhands} z-index box-sizing order align-content
justify-content align-self justify-self align-items
justify-items">
justify-items grid-auto-rows grid-auto-columns">
% for side in SIDES:
<% impl_split_style_coord("%s" % side.ident,
"mOffset",
@ -1083,6 +1083,36 @@ fn static_assert() {
}
% endfor
% for kind in ["rows", "columns"]:
pub fn set_grid_auto_${kind}(&mut self, v: longhands::grid_auto_rows::computed_value::T) {
use values::specified::grid::TrackSize;
match v {
TrackSize::FitContent(lop) => {
// Gecko sets min value to None and max value to the actual value in fit-content
// https://dxr.mozilla.org/mozilla-central/rev/0eef1d5/layout/style/nsRuleNode.cpp#8221
self.gecko.mGridAuto${kind.title()}Min.set_value(CoordDataValue::None);
lop.to_gecko_style_coord(&mut self.gecko.mGridAuto${kind.title()}Max);
},
TrackSize::Breadth(breadth) => {
// Set the value to both fields if there's one breadth value
// https://dxr.mozilla.org/mozilla-central/rev/0eef1d5/layout/style/nsRuleNode.cpp#8230
breadth.to_gecko_style_coord(&mut self.gecko.mGridAuto${kind.title()}Min);
breadth.to_gecko_style_coord(&mut self.gecko.mGridAuto${kind.title()}Max);
},
TrackSize::MinMax(min, max) => {
min.to_gecko_style_coord(&mut self.gecko.mGridAuto${kind.title()}Min);
max.to_gecko_style_coord(&mut self.gecko.mGridAuto${kind.title()}Max);
},
}
}
pub fn copy_grid_auto_${kind}_from(&mut self, other: &Self) {
self.gecko.mGridAuto${kind.title()}Min.copy_from(&other.gecko.mGridAuto${kind.title()}Min);
self.gecko.mGridAuto${kind.title()}Max.copy_from(&other.gecko.mGridAuto${kind.title()}Max);
}
% endfor
</%self:impl_trait>
<% skip_outline_longhands = " ".join("outline-style outline-width".split() +