Bug 1146051 part 5b - [css-grid] Clamp resolved definite lines for abs.pos. to the untranslated grid bounds. r=dholbert

This commit is contained in:
Mats Palmgren 2015-04-30 18:42:50 +00:00
parent ab12605d8b
commit a916ebef56
2 changed files with 17 additions and 10 deletions

View File

@ -617,7 +617,8 @@ nsGridContainerFrame::ResolveAbsPosLineRange(
uint32_t GridNamedArea::* aAreaStart,
uint32_t GridNamedArea::* aAreaEnd,
uint32_t aExplicitGridEnd,
uint32_t aGridEnd,
int32_t aGridStart,
int32_t aGridEnd,
const nsStylePosition* aStyle)
{
if (aStart.IsAuto()) {
@ -630,7 +631,7 @@ nsGridContainerFrame::ResolveAbsPosLineRange(
if (aEnd.mHasSpan) {
++end;
}
return LineRange(kAutoLine, clamped(end, 1, int32_t(aGridEnd)));
return LineRange(kAutoLine, clamped(end, aGridStart, aGridEnd));
}
if (aEnd.IsAuto()) {
@ -638,9 +639,9 @@ nsGridContainerFrame::ResolveAbsPosLineRange(
ResolveLine(aStart, aStart.mInteger, 0, aLineNameList, aAreaStart,
aAreaEnd, aExplicitGridEnd, eLineRangeSideStart, aStyle);
if (aStart.mHasSpan) {
start = std::max(int32_t(aGridEnd) - start, 1);
start = std::max(aGridEnd - start, aGridStart);
}
return LineRange(clamped(start, 1, int32_t(aGridEnd)), kAutoLine);
return LineRange(clamped(start, aGridStart, aGridEnd), kAutoLine);
}
LineRange r = ResolveLineRange(aStart, aEnd, aLineNameList, aAreaStart,
@ -648,8 +649,8 @@ nsGridContainerFrame::ResolveAbsPosLineRange(
MOZ_ASSERT(!r.IsAuto(), "resolving definite lines shouldn't result in auto");
// Clamp definite lines to be within the implicit grid.
// Note that this implies mStart may be equal to mEnd.
r.mStart = clamped(r.mStart, 1, int32_t(aGridEnd));
r.mEnd = clamped(r.mEnd, 1, int32_t(aGridEnd));
r.mStart = clamped(r.mStart, aGridStart, aGridEnd);
r.mEnd = clamped(r.mEnd, aGridStart, aGridEnd);
MOZ_ASSERT(r.mStart <= r.mEnd);
return r;
}
@ -700,19 +701,23 @@ nsGridContainerFrame::PlaceAbsPos(nsIFrame* aChild,
const nsStylePosition* aStyle)
{
const nsStylePosition* itemStyle = aChild->StylePosition();
int32_t gridColStart = 1 - mExplicitGridOffsetCol;
int32_t gridRowStart = 1 - mExplicitGridOffsetRow;
return GridArea(
ResolveAbsPosLineRange(itemStyle->mGridColumnStart,
itemStyle->mGridColumnEnd,
aStyle->mGridTemplateColumns.mLineNameLists,
&GridNamedArea::mColumnStart,
&GridNamedArea::mColumnEnd,
mExplicitGridColEnd, mGridColEnd, aStyle),
mExplicitGridColEnd, gridColStart, mGridColEnd,
aStyle),
ResolveAbsPosLineRange(itemStyle->mGridRowStart,
itemStyle->mGridRowEnd,
aStyle->mGridTemplateRows.mLineNameLists,
&GridNamedArea::mRowStart,
&GridNamedArea::mRowEnd,
mExplicitGridRowEnd, mGridRowEnd, aStyle));
mExplicitGridRowEnd, gridRowStart, mGridRowEnd,
aStyle));
}
void

View File

@ -242,7 +242,8 @@ protected:
/**
* As above but for an abs.pos. child. Any 'auto' lines will be represented
* by kAutoLine in the LineRange result.
* @param aGridEnd the last line in the (final) implicit grid
* @param aGridStart the first line in the final, but untranslated grid
* @param aGridEnd the last line in the final, but untranslated grid
*/
LineRange
ResolveAbsPosLineRange(const nsStyleGridLine& aStart,
@ -251,7 +252,8 @@ protected:
uint32_t GridNamedArea::* aAreaStart,
uint32_t GridNamedArea::* aAreaEnd,
uint32_t aExplicitGridEnd,
uint32_t aGridEnd,
int32_t aGridStart,
int32_t aGridEnd,
const nsStylePosition* aStyle);
/**