Bug 1423378 Part 1: Specially treat the explicit line names following a repeat auto-fit or auto-fill declaration to ensure they are always applied to the following line. r=mats

MozReview-Commit-ID: iFM5J6wRL6
This commit is contained in:
Brad Werth 2017-12-05 14:51:06 -08:00
parent 23bdfd7fcc
commit b61d32f5ef
3 changed files with 43 additions and 16 deletions

View File

@ -137,15 +137,11 @@ GridLines::SetLineInfo(const ComputedGridTrackInfo* aTrackInfo,
// problem. We do the work here since this is only run when
// requested by devtools, and slowness here will not affect
// normal browsing.
nsTArray<nsString> possiblyDuplicateLineNames(
const nsTArray<nsString>& possiblyDuplicateLineNames(
aLineInfo->mNames.SafeElementAt(i, nsTArray<nsString>()));
// Add the possiblyDuplicateLineNames one at a time to filter
// out the duplicates.
nsTArray<nsString> lineNames;
for (const auto& name : possiblyDuplicateLineNames) {
AddLineNameIfNotPresent(lineNames, name);
}
AddLineNamesIfNotPresent(lineNames, possiblyDuplicateLineNames);
// Add in names from grid areas where this line is used as a boundary.
for (auto area : aAreas) {
@ -187,6 +183,16 @@ GridLines::SetLineInfo(const ComputedGridTrackInfo* aTrackInfo,
lineNames);
}
// If this line is the one that ends a repeat, then add
// in the mNamesFollowingRepeat names from aLineInfo.
if (numRepeatTracks > 0 &&
i == (aTrackInfo->mRepeatFirstTrack +
aTrackInfo->mNumLeadingImplicitTracks +
numRepeatTracks - numAddedLines)) {
AddLineNamesIfNotPresent(lineNames,
aLineInfo->mNamesFollowingRepeat);
}
RefPtr<GridLine> line = new GridLine(this);
mLines.AppendElement(line);
MOZ_ASSERT(line1Index > 0, "line1Index must be positive.");

View File

@ -1633,12 +1633,6 @@ struct nsGridContainerFrame::Tracks
if (aIndex < lineNameLists.Length()) {
lineNames.AppendElements(lineNameLists[aIndex]);
}
if (aIndex == repeatAutoEnd) {
uint32_t i = aIndex + 1;
if (i < lineNameLists.Length()) {
lineNames.AppendElements(lineNameLists[i]);
}
}
}
if (aIndex <= repeatAutoEnd && aIndex > repeatAutoStart) {
lineNames.AppendElements(aGridTemplate.mRepeatAutoLineNameListAfter);
@ -1646,7 +1640,7 @@ struct nsGridContainerFrame::Tracks
if (aIndex < repeatAutoEnd && aIndex >= repeatAutoStart) {
lineNames.AppendElements(aGridTemplate.mRepeatAutoLineNameListBefore);
}
if (aIndex >= repeatAutoEnd && aIndex > repeatAutoStart) {
if (aIndex > repeatAutoEnd && aIndex > repeatAutoStart) {
uint32_t i = aIndex - repeatEndDelta;
if (i < lineNameLists.Length()) {
lineNames.AppendElements(lineNameLists[i]);
@ -6241,10 +6235,22 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext,
columnLineNames.AppendElement(explicitNames);
}
// Get the explicit names that follow a repeat auto declaration.
nsTArray<nsString> colNamesFollowingRepeat;
if (gridColTemplate.HasRepeatAuto()) {
// The line name list after the repeatAutoIndex holds the line names
// for the first explicit line after the repeat auto declaration.
uint32_t repeatAutoEnd = gridColTemplate.mRepeatAutoIndex + 1;
MOZ_ASSERT(repeatAutoEnd < gridColTemplate.mLineNameLists.Length());
colNamesFollowingRepeat.AppendElements(
gridColTemplate.mLineNameLists[repeatAutoEnd]);
}
ComputedGridLineInfo* columnLineInfo = new ComputedGridLineInfo(
Move(columnLineNames),
gridColTemplate.mRepeatAutoLineNameListBefore,
gridColTemplate.mRepeatAutoLineNameListAfter);
gridColTemplate.mRepeatAutoLineNameListAfter,
Move(colNamesFollowingRepeat));
SetProperty(GridColumnLineInfo(), columnLineInfo);
// Generate row lines next.
@ -6262,10 +6268,22 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext,
rowLineNames.AppendElement(explicitNames);
}
// Get the explicit names that follow a repeat auto declaration.
nsTArray<nsString> rowNamesFollowingRepeat;
if (gridRowTemplate.HasRepeatAuto()) {
// The line name list after the repeatAutoIndex holds the line names
// for the first explicit line after the repeat auto declaration.
uint32_t repeatAutoEnd = gridRowTemplate.mRepeatAutoIndex + 1;
MOZ_ASSERT(repeatAutoEnd < gridRowTemplate.mLineNameLists.Length());
rowNamesFollowingRepeat.AppendElements(
gridRowTemplate.mLineNameLists[repeatAutoEnd]);
}
ComputedGridLineInfo* rowLineInfo = new ComputedGridLineInfo(
Move(rowLineNames),
gridRowTemplate.mRepeatAutoLineNameListBefore,
gridRowTemplate.mRepeatAutoLineNameListAfter);
gridRowTemplate.mRepeatAutoLineNameListAfter,
Move(rowNamesFollowingRepeat));
SetProperty(GridRowLineInfo(), rowLineInfo);
// Generate area info for explicit areas. Implicit areas are handled

View File

@ -70,14 +70,17 @@ struct ComputedGridLineInfo
{
explicit ComputedGridLineInfo(nsTArray<nsTArray<nsString>>&& aNames,
const nsTArray<nsString>& aNamesBefore,
const nsTArray<nsString>& aNamesAfter)
const nsTArray<nsString>& aNamesAfter,
nsTArray<nsString>&& aNamesFollowingRepeat)
: mNames(aNames)
, mNamesBefore(aNamesBefore)
, mNamesAfter(aNamesAfter)
, mNamesFollowingRepeat(aNamesFollowingRepeat)
{}
nsTArray<nsTArray<nsString>> mNames;
nsTArray<nsString> mNamesBefore;
nsTArray<nsString> mNamesAfter;
nsTArray<nsString> mNamesFollowingRepeat;
};
} // namespace mozilla