Bug 1628041 - Use fill length rather than index to indicate a repeat(auto) in subgrid from Servo r=mats

Differential Revision: https://phabricator.services.mozilla.com/D70066
This commit is contained in:
Emily McDonough 2020-05-06 19:35:03 +00:00
Родитель 7fce40912d
Коммит 1943cf3dcf
2 изменённых файлов: 11 добавлений и 15 удалений

Просмотреть файл

@ -1410,22 +1410,18 @@ class MOZ_STACK_CLASS nsGridContainerFrame::LineNameMap {
mClampMaxLine = 1 + aRange->Extent();
mRepeatAutoEnd = mRepeatAutoStart;
const auto& styleSubgrid = aTracks.mTemplate.AsSubgrid();
const auto fillStart = styleSubgrid->fill_start;
// Use decltype so we do not rely on the exact type that was exposed from
// rust code.
mHasRepeatAuto =
fillStart != std::numeric_limits<decltype(fillStart)>::max();
const auto fillLen = styleSubgrid->fill_len;
mHasRepeatAuto = fillLen != 0;
if (mHasRepeatAuto) {
const auto& lineNameLists = styleSubgrid->names;
int32_t extraAutoFillLineCount = mClampMaxLine - lineNameLists.Length();
const int32_t extraAutoFillLineCount =
mClampMaxLine - lineNameLists.Length();
// Maximum possible number of repeat name lists. This must be reduced
// to a whole number of repetitions of the fill length.
const uint32_t possibleRepeatLength = std::max<int32_t>(
0, extraAutoFillLineCount + styleSubgrid->fill_len);
MOZ_ASSERT(styleSubgrid->fill_len > 0);
const uint32_t repeatRemainder =
possibleRepeatLength % styleSubgrid->fill_len;
mRepeatAutoStart = fillStart;
const uint32_t possibleRepeatLength =
std::max<int32_t>(0, extraAutoFillLineCount + fillLen);
const uint32_t repeatRemainder = possibleRepeatLength % fillLen;
mRepeatAutoStart = styleSubgrid->fill_start;
mRepeatAutoEnd =
mRepeatAutoStart + possibleRepeatLength - repeatRemainder;
}

Просмотреть файл

@ -714,7 +714,7 @@ impl Parse for LineNameList {
line_names.truncate(MAX_GRID_LINE as usize);
}
let (fill_start, fill_len) = fill_data.unwrap_or((usize::MAX, 0));
let (fill_start, fill_len) = fill_data.unwrap_or((0, 0));
Ok(LineNameList {
names: line_names.into(),
@ -733,7 +733,7 @@ impl ToCss for LineNameList {
let fill_start = self.fill_start;
let fill_len = self.fill_len;
for (i, names) in self.names.iter().enumerate() {
if i == fill_start {
if fill_len > 0 && i == fill_start {
dest.write_str(" repeat(auto-fill,")?;
}
@ -748,7 +748,7 @@ impl ToCss for LineNameList {
}
dest.write_str("]")?;
if i == fill_start + fill_len - 1 {
if fill_len > 0 && i == fill_start + fill_len - 1 {
dest.write_str(")")?;
}
}