зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1559814 - Use the cbindgen representation for grid line properties. r=mats
We clamp earlier (parse time rather than computed value time), but that's the only behavior change, which I think doesn't really matter. Differential Revision: https://phabricator.services.mozilla.com/D35198 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
914637451c
Коммит
e86340308c
|
@ -39,13 +39,16 @@ using namespace mozilla;
|
|||
|
||||
typedef nsAbsoluteContainingBlock::AbsPosReflowFlags AbsPosReflowFlags;
|
||||
typedef nsGridContainerFrame::TrackSize TrackSize;
|
||||
const uint32_t nsGridContainerFrame::kTranslatedMaxLine =
|
||||
uint32_t(nsStyleGridLine::kMaxLine - nsStyleGridLine::kMinLine);
|
||||
const uint32_t nsGridContainerFrame::kAutoLine = kTranslatedMaxLine + 3457U;
|
||||
typedef nsTHashtable<nsPtrHashKey<nsIFrame>> FrameHashtable;
|
||||
typedef mozilla::CSSAlignUtils::AlignJustifyFlags AlignJustifyFlags;
|
||||
typedef nsLayoutUtils::IntrinsicISizeType IntrinsicISizeType;
|
||||
|
||||
static const int32_t kMaxLine = StyleMAX_GRID_LINE;
|
||||
static const int32_t kMinLine = StyleMIN_GRID_LINE;
|
||||
// The maximum line number, in the zero-based translated grid.
|
||||
static const uint32_t kTranslatedMaxLine = uint32_t(kMaxLine - kMinLine);
|
||||
static const uint32_t kAutoLine = kTranslatedMaxLine + 3457U;
|
||||
|
||||
static const nsFrameState kIsSubgridBits =
|
||||
(NS_STATE_GRID_IS_COL_SUBGRID | NS_STATE_GRID_IS_ROW_SUBGRID);
|
||||
|
||||
|
@ -385,17 +388,13 @@ struct nsGridContainerFrame::LineRange {
|
|||
#ifdef DEBUG
|
||||
if (!IsAutoAuto()) {
|
||||
if (IsAuto()) {
|
||||
MOZ_ASSERT(aEnd >= nsStyleGridLine::kMinLine &&
|
||||
aEnd <= nsStyleGridLine::kMaxLine,
|
||||
"invalid span");
|
||||
MOZ_ASSERT(aEnd >= kMinLine && aEnd <= kMaxLine, "invalid span");
|
||||
} else {
|
||||
MOZ_ASSERT(aStart >= nsStyleGridLine::kMinLine &&
|
||||
aStart <= nsStyleGridLine::kMaxLine,
|
||||
MOZ_ASSERT(aStart >= kMinLine && aStart <= kMaxLine,
|
||||
"invalid start line");
|
||||
MOZ_ASSERT(
|
||||
aEnd == int32_t(kAutoLine) || (aEnd >= nsStyleGridLine::kMinLine &&
|
||||
aEnd <= nsStyleGridLine::kMaxLine),
|
||||
"invalid end line");
|
||||
MOZ_ASSERT(aEnd == int32_t(kAutoLine) ||
|
||||
(aEnd >= kMinLine && aEnd <= kMaxLine),
|
||||
"invalid end line");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -406,8 +405,7 @@ struct nsGridContainerFrame::LineRange {
|
|||
uint32_t Extent() const {
|
||||
MOZ_ASSERT(mEnd != kAutoLine, "Extent is undefined for abs.pos. 'auto'");
|
||||
if (IsAuto()) {
|
||||
MOZ_ASSERT(mEnd >= 1 && mEnd < uint32_t(nsStyleGridLine::kMaxLine),
|
||||
"invalid span");
|
||||
MOZ_ASSERT(mEnd >= 1 && mEnd < uint32_t(kMaxLine), "invalid span");
|
||||
return mEnd;
|
||||
}
|
||||
return mEnd - mStart;
|
||||
|
@ -461,12 +459,11 @@ struct nsGridContainerFrame::LineRange {
|
|||
*/
|
||||
void AdjustAbsPosForRemovedTracks(
|
||||
const nsTArray<uint32_t>& aNumRemovedTracks) {
|
||||
if (mStart != nsGridContainerFrame::kAutoLine) {
|
||||
if (mStart != kAutoLine) {
|
||||
mStart -= aNumRemovedTracks[mStart];
|
||||
}
|
||||
if (mEnd != nsGridContainerFrame::kAutoLine) {
|
||||
MOZ_ASSERT(mStart == nsGridContainerFrame::kAutoLine || mEnd > mStart,
|
||||
"invalid line range");
|
||||
if (mEnd != kAutoLine) {
|
||||
MOZ_ASSERT(mStart == kAutoLine || mEnd > mStart, "invalid line range");
|
||||
mEnd -= aNumRemovedTracks[mEnd];
|
||||
}
|
||||
}
|
||||
|
@ -1358,7 +1355,7 @@ struct nsGridContainerFrame::TrackSizingFunctions {
|
|||
}
|
||||
// Clamp the number of repeat tracks so that the last line <= kMaxLine.
|
||||
// (note that |numTracks| already includes one repeat() track)
|
||||
const uint32_t maxRepeatTracks = nsStyleGridLine::kMaxLine - numTracks;
|
||||
const uint32_t maxRepeatTracks = kMaxLine - numTracks;
|
||||
return std::min(numRepeatTracks, maxRepeatTracks);
|
||||
}
|
||||
|
||||
|
@ -1369,7 +1366,7 @@ struct nsGridContainerFrame::TrackSizingFunctions {
|
|||
uint32_t ComputeExplicitGridEnd(uint32_t aGridTemplateAreasEnd) {
|
||||
uint32_t end = NumExplicitTracks() + 1;
|
||||
end = std::max(end, aGridTemplateAreasEnd);
|
||||
end = std::min(end, uint32_t(nsStyleGridLine::kMaxLine));
|
||||
end = std::min(end, uint32_t(kMaxLine));
|
||||
return end;
|
||||
}
|
||||
|
||||
|
@ -2541,8 +2538,8 @@ struct MOZ_STACK_CLASS nsGridContainerFrame::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,
|
||||
const nsStyleGridLine& aEnd,
|
||||
LineRange ResolveAbsPosLineRange(const StyleGridLine& aStart,
|
||||
const StyleGridLine& aEnd,
|
||||
const LineNameMap& aNameMap,
|
||||
LogicalAxis aAxis, uint32_t aExplicitGridEnd,
|
||||
int32_t aGridStart, int32_t aGridEnd,
|
||||
|
@ -2663,7 +2660,7 @@ struct MOZ_STACK_CLASS nsGridContainerFrame::Grid {
|
|||
* @return a definite line (1-based), clamped to
|
||||
* the mClampMinLine..mClampMaxLine range
|
||||
*/
|
||||
int32_t ResolveLine(const nsStyleGridLine& aLine, int32_t aNth,
|
||||
int32_t ResolveLine(const StyleGridLine& aLine, int32_t aNth,
|
||||
uint32_t aFromIndex, const LineNameMap& aNameMap,
|
||||
LogicalSide aSide, uint32_t aExplicitGridEnd,
|
||||
const nsStylePosition* aStyle);
|
||||
|
@ -2674,8 +2671,8 @@ struct MOZ_STACK_CLASS nsGridContainerFrame::Grid {
|
|||
* @return a pair (start,end) of lines
|
||||
*/
|
||||
typedef std::pair<int32_t, int32_t> LinePair;
|
||||
LinePair ResolveLineRangeHelper(const nsStyleGridLine& aStart,
|
||||
const nsStyleGridLine& aEnd,
|
||||
LinePair ResolveLineRangeHelper(const StyleGridLine& aStart,
|
||||
const StyleGridLine& aEnd,
|
||||
const LineNameMap& aNameMap,
|
||||
LogicalAxis aAxis, uint32_t aExplicitGridEnd,
|
||||
const nsStylePosition* aStyle);
|
||||
|
@ -2694,8 +2691,8 @@ struct MOZ_STACK_CLASS nsGridContainerFrame::Grid {
|
|||
* @param aExplicitGridEnd the last line in the explicit grid
|
||||
* @param aStyle the StylePosition() for the grid container
|
||||
*/
|
||||
LineRange ResolveLineRange(const nsStyleGridLine& aStart,
|
||||
const nsStyleGridLine& aEnd,
|
||||
LineRange ResolveLineRange(const StyleGridLine& aStart,
|
||||
const StyleGridLine& aEnd,
|
||||
const LineNameMap& aNameMap, LogicalAxis aAxis,
|
||||
uint32_t aExplicitGridEnd,
|
||||
const nsStylePosition* aStyle);
|
||||
|
@ -3334,8 +3331,7 @@ void nsGridContainerFrame::AddImplicitNamedAreas(
|
|||
const nsTArray<nsTArray<RefPtr<nsAtom>>>& aLineNameLists) {
|
||||
// http://dev.w3.org/csswg/css-grid/#implicit-named-areas
|
||||
// Note: recording these names for fast lookup later is just an optimization.
|
||||
const uint32_t len =
|
||||
std::min(aLineNameLists.Length(), size_t(nsStyleGridLine::kMaxLine));
|
||||
const uint32_t len = std::min(aLineNameLists.Length(), size_t(kMaxLine));
|
||||
nsTHashtable<nsStringHashKey> currentStarts;
|
||||
ImplicitNamedAreas* areas = GetImplicitNamedAreas();
|
||||
for (uint32_t i = 0; i < len; ++i) {
|
||||
|
@ -3383,12 +3379,12 @@ void nsGridContainerFrame::InitImplicitNamedAreas(
|
|||
}
|
||||
|
||||
int32_t nsGridContainerFrame::Grid::ResolveLine(
|
||||
const nsStyleGridLine& aLine, int32_t aNth, uint32_t aFromIndex,
|
||||
const StyleGridLine& aLine, int32_t aNth, uint32_t aFromIndex,
|
||||
const LineNameMap& aNameMap, LogicalSide aSide, uint32_t aExplicitGridEnd,
|
||||
const nsStylePosition* aStyle) {
|
||||
MOZ_ASSERT(!aLine.IsAuto());
|
||||
int32_t line = 0;
|
||||
if (aLine.mLineName->IsEmpty()) {
|
||||
if (aLine.LineName()->IsEmpty()) {
|
||||
MOZ_ASSERT(aNth != 0, "css-grid 9.2: <integer> must not be zero.");
|
||||
line = int32_t(aFromIndex) + aNth;
|
||||
} else {
|
||||
|
@ -3396,16 +3392,16 @@ int32_t nsGridContainerFrame::Grid::ResolveLine(
|
|||
// <integer> was omitted; treat it as 1.
|
||||
aNth = 1;
|
||||
}
|
||||
bool isNameOnly = !aLine.mHasSpan && aLine.mInteger == 0;
|
||||
bool isNameOnly = !aLine.is_span && aLine.line_num == 0;
|
||||
if (isNameOnly) {
|
||||
AutoTArray<uint32_t, 16> implicitLines;
|
||||
aNameMap.FindNamedAreas(aLine.mLineName, aSide, implicitLines);
|
||||
aNameMap.FindNamedAreas(aLine.ident.AsAtom(), aSide, implicitLines);
|
||||
if (!implicitLines.IsEmpty() ||
|
||||
aNameMap.HasImplicitNamedArea(aLine.mLineName)) {
|
||||
aNameMap.HasImplicitNamedArea(aLine.LineName())) {
|
||||
// aName is a named area - look for explicit lines named
|
||||
// <name>-start/-end depending on which side we're resolving.
|
||||
// http://dev.w3.org/csswg/css-grid/#grid-placement-slot
|
||||
nsAutoString lineName(nsDependentAtomString(aLine.mLineName));
|
||||
nsAutoString lineName(nsDependentAtomString(aLine.LineName()));
|
||||
if (IsStart(aSide)) {
|
||||
lineName.AppendLiteral("-start");
|
||||
} else {
|
||||
|
@ -3417,25 +3413,25 @@ int32_t nsGridContainerFrame::Grid::ResolveLine(
|
|||
}
|
||||
|
||||
if (line == 0) {
|
||||
// If mLineName ends in -start/-end, try the prefix as a named area.
|
||||
// If LineName() ends in -start/-end, try the prefix as a named area.
|
||||
AutoTArray<uint32_t, 16> implicitLines;
|
||||
uint32_t index;
|
||||
bool useStart = IsNameWithStartSuffix(aLine.mLineName, &index);
|
||||
if (useStart || IsNameWithEndSuffix(aLine.mLineName, &index)) {
|
||||
bool useStart = IsNameWithStartSuffix(aLine.LineName(), &index);
|
||||
if (useStart || IsNameWithEndSuffix(aLine.LineName(), &index)) {
|
||||
auto side = MakeLogicalSide(
|
||||
GetAxis(aSide), useStart ? eLogicalEdgeStart : eLogicalEdgeEnd);
|
||||
RefPtr<nsAtom> name = NS_Atomize(nsDependentSubstring(
|
||||
nsDependentAtomString(aLine.mLineName), 0, index));
|
||||
nsDependentAtomString(aLine.LineName()), 0, index));
|
||||
aNameMap.FindNamedAreas(name, side, implicitLines);
|
||||
}
|
||||
line = aNameMap.FindNamedLine(aLine.mLineName, &aNth, aFromIndex,
|
||||
line = aNameMap.FindNamedLine(aLine.LineName(), &aNth, aFromIndex,
|
||||
implicitLines);
|
||||
}
|
||||
|
||||
if (line == 0) {
|
||||
MOZ_ASSERT(aNth != 0, "we found all N named lines but 'line' is zero!");
|
||||
int32_t edgeLine;
|
||||
if (aLine.mHasSpan) {
|
||||
if (aLine.is_span) {
|
||||
// http://dev.w3.org/csswg/css-grid/#grid-placement-span-int
|
||||
// 'span <custom-ident> N'
|
||||
edgeLine = IsStart(aSide) ? 1 : aExplicitGridEnd;
|
||||
|
@ -3454,30 +3450,29 @@ int32_t nsGridContainerFrame::Grid::ResolveLine(
|
|||
|
||||
nsGridContainerFrame::Grid::LinePair
|
||||
nsGridContainerFrame::Grid::ResolveLineRangeHelper(
|
||||
const nsStyleGridLine& aStart, const nsStyleGridLine& aEnd,
|
||||
const StyleGridLine& aStart, const StyleGridLine& aEnd,
|
||||
const LineNameMap& aNameMap, LogicalAxis aAxis, uint32_t aExplicitGridEnd,
|
||||
const nsStylePosition* aStyle) {
|
||||
MOZ_ASSERT(int32_t(nsGridContainerFrame::kAutoLine) >
|
||||
nsStyleGridLine::kMaxLine);
|
||||
MOZ_ASSERT(int32_t(kAutoLine) > kMaxLine);
|
||||
|
||||
if (aStart.mHasSpan) {
|
||||
if (aEnd.mHasSpan || aEnd.IsAuto()) {
|
||||
if (aStart.is_span) {
|
||||
if (aEnd.is_span || aEnd.IsAuto()) {
|
||||
// http://dev.w3.org/csswg/css-grid/#grid-placement-errors
|
||||
if (aStart.mLineName->IsEmpty()) {
|
||||
if (aStart.LineName()->IsEmpty()) {
|
||||
// span <integer> / span *
|
||||
// span <integer> / auto
|
||||
return LinePair(kAutoLine, aStart.mInteger);
|
||||
return LinePair(kAutoLine, aStart.line_num);
|
||||
}
|
||||
// span <custom-ident> / span *
|
||||
// span <custom-ident> / auto
|
||||
return LinePair(kAutoLine, 1); // XXX subgrid explicit size instead of 1?
|
||||
}
|
||||
|
||||
uint32_t from = aEnd.mInteger < 0 ? aExplicitGridEnd + 1 : 0;
|
||||
auto end = ResolveLine(aEnd, aEnd.mInteger, from, aNameMap,
|
||||
uint32_t from = aEnd.line_num < 0 ? aExplicitGridEnd + 1 : 0;
|
||||
auto end = ResolveLine(aEnd, aEnd.line_num, from, aNameMap,
|
||||
MakeLogicalSide(aAxis, eLogicalEdgeEnd),
|
||||
aExplicitGridEnd, aStyle);
|
||||
int32_t span = aStart.mInteger == 0 ? 1 : aStart.mInteger;
|
||||
int32_t span = aStart.line_num == 0 ? 1 : aStart.line_num;
|
||||
if (end <= 1) {
|
||||
// The end is at or before the first explicit line, thus all lines before
|
||||
// it match <custom-ident> since they're implicit.
|
||||
|
@ -3496,19 +3491,19 @@ nsGridContainerFrame::Grid::ResolveLineRangeHelper(
|
|||
// auto / auto
|
||||
return LinePair(start, 1); // XXX subgrid explicit size instead of 1?
|
||||
}
|
||||
if (aEnd.mHasSpan) {
|
||||
if (aEnd.mLineName->IsEmpty()) {
|
||||
if (aEnd.is_span) {
|
||||
if (aEnd.LineName()->IsEmpty()) {
|
||||
// auto / span <integer>
|
||||
MOZ_ASSERT(aEnd.mInteger != 0);
|
||||
return LinePair(start, aEnd.mInteger);
|
||||
MOZ_ASSERT(aEnd.line_num != 0);
|
||||
return LinePair(start, aEnd.line_num);
|
||||
}
|
||||
// http://dev.w3.org/csswg/css-grid/#grid-placement-errors
|
||||
// auto / span <custom-ident>
|
||||
return LinePair(start, 1); // XXX subgrid explicit size instead of 1?
|
||||
}
|
||||
} else {
|
||||
uint32_t from = aStart.mInteger < 0 ? aExplicitGridEnd + 1 : 0;
|
||||
start = ResolveLine(aStart, aStart.mInteger, from, aNameMap,
|
||||
uint32_t from = aStart.line_num < 0 ? aExplicitGridEnd + 1 : 0;
|
||||
start = ResolveLine(aStart, aStart.line_num, from, aNameMap,
|
||||
MakeLogicalSide(aAxis, eLogicalEdgeStart),
|
||||
aExplicitGridEnd, aStyle);
|
||||
if (aEnd.IsAuto()) {
|
||||
|
@ -3520,10 +3515,10 @@ nsGridContainerFrame::Grid::ResolveLineRangeHelper(
|
|||
}
|
||||
|
||||
uint32_t from;
|
||||
int32_t nth = aEnd.mInteger == 0 ? 1 : aEnd.mInteger;
|
||||
if (aEnd.mHasSpan) {
|
||||
int32_t nth = aEnd.line_num == 0 ? 1 : aEnd.line_num;
|
||||
if (aEnd.is_span) {
|
||||
if (MOZ_UNLIKELY(start < 0)) {
|
||||
if (aEnd.mLineName->IsEmpty()) {
|
||||
if (aEnd.LineName()->IsEmpty()) {
|
||||
return LinePair(start, start + nth);
|
||||
}
|
||||
from = 0;
|
||||
|
@ -3536,7 +3531,7 @@ nsGridContainerFrame::Grid::ResolveLineRangeHelper(
|
|||
from = start;
|
||||
}
|
||||
} else {
|
||||
from = aEnd.mInteger < 0 ? aExplicitGridEnd + 1 : 0;
|
||||
from = aEnd.line_num < 0 ? aExplicitGridEnd + 1 : 0;
|
||||
}
|
||||
auto end = ResolveLine(aEnd, nth, from, aNameMap,
|
||||
MakeLogicalSide(aAxis, eLogicalEdgeEnd),
|
||||
|
@ -3549,7 +3544,7 @@ nsGridContainerFrame::Grid::ResolveLineRangeHelper(
|
|||
}
|
||||
|
||||
nsGridContainerFrame::LineRange nsGridContainerFrame::Grid::ResolveLineRange(
|
||||
const nsStyleGridLine& aStart, const nsStyleGridLine& aEnd,
|
||||
const StyleGridLine& aStart, const StyleGridLine& aEnd,
|
||||
const LineNameMap& aNameMap, LogicalAxis aAxis, uint32_t aExplicitGridEnd,
|
||||
const nsStylePosition* aStyle) {
|
||||
LinePair r = ResolveLineRangeHelper(aStart, aEnd, aNameMap, aAxis,
|
||||
|
@ -3590,18 +3585,18 @@ nsGridContainerFrame::GridArea nsGridContainerFrame::Grid::PlaceDefinite(
|
|||
|
||||
nsGridContainerFrame::LineRange
|
||||
nsGridContainerFrame::Grid::ResolveAbsPosLineRange(
|
||||
const nsStyleGridLine& aStart, const nsStyleGridLine& aEnd,
|
||||
const StyleGridLine& aStart, const StyleGridLine& aEnd,
|
||||
const LineNameMap& aNameMap, LogicalAxis aAxis, uint32_t aExplicitGridEnd,
|
||||
int32_t aGridStart, int32_t aGridEnd, const nsStylePosition* aStyle) {
|
||||
if (aStart.IsAuto()) {
|
||||
if (aEnd.IsAuto()) {
|
||||
return LineRange(kAutoLine, kAutoLine);
|
||||
}
|
||||
uint32_t from = aEnd.mInteger < 0 ? aExplicitGridEnd + 1 : 0;
|
||||
int32_t end = ResolveLine(aEnd, aEnd.mInteger, from, aNameMap,
|
||||
uint32_t from = aEnd.line_num < 0 ? aExplicitGridEnd + 1 : 0;
|
||||
int32_t end = ResolveLine(aEnd, aEnd.line_num, from, aNameMap,
|
||||
MakeLogicalSide(aAxis, eLogicalEdgeEnd),
|
||||
aExplicitGridEnd, aStyle);
|
||||
if (aEnd.mHasSpan) {
|
||||
if (aEnd.is_span) {
|
||||
++end;
|
||||
}
|
||||
// A line outside the existing grid is treated as 'auto' for abs.pos (10.1).
|
||||
|
@ -3610,11 +3605,11 @@ nsGridContainerFrame::Grid::ResolveAbsPosLineRange(
|
|||
}
|
||||
|
||||
if (aEnd.IsAuto()) {
|
||||
uint32_t from = aStart.mInteger < 0 ? aExplicitGridEnd + 1 : 0;
|
||||
int32_t start = ResolveLine(aStart, aStart.mInteger, from, aNameMap,
|
||||
uint32_t from = aStart.line_num < 0 ? aExplicitGridEnd + 1 : 0;
|
||||
int32_t start = ResolveLine(aStart, aStart.line_num, from, aNameMap,
|
||||
MakeLogicalSide(aAxis, eLogicalEdgeStart),
|
||||
aExplicitGridEnd, aStyle);
|
||||
if (aStart.mHasSpan) {
|
||||
if (aStart.is_span) {
|
||||
start = std::max(aGridEnd - start, aGridStart);
|
||||
}
|
||||
start = AutoIfOutside(start, aGridStart, aGridEnd);
|
||||
|
@ -3624,7 +3619,7 @@ nsGridContainerFrame::Grid::ResolveAbsPosLineRange(
|
|||
LineRange r =
|
||||
ResolveLineRange(aStart, aEnd, aNameMap, aAxis, aExplicitGridEnd, aStyle);
|
||||
if (r.IsAuto()) {
|
||||
MOZ_ASSERT(aStart.mHasSpan && aEnd.mHasSpan,
|
||||
MOZ_ASSERT(aStart.is_span && aEnd.is_span,
|
||||
"span / span is the only case "
|
||||
"leading to IsAuto here -- we dealt with the other cases above");
|
||||
// The second span was ignored per 9.2.1. For abs.pos., 10.1 says that this
|
||||
|
@ -3881,8 +3876,8 @@ void nsGridContainerFrame::Grid::PlaceGridItems(
|
|||
// to a 0,0 based grid after placing definite lines.
|
||||
const nsStylePosition* const gridStyle = aState.mGridStyle;
|
||||
const auto* areas = gridStyle->mGridTemplateAreas.IsNone() ? nullptr : &*gridStyle->mGridTemplateAreas.AsAreas();
|
||||
int32_t clampMinColLine = nsStyleGridLine::kMinLine;
|
||||
int32_t clampMaxColLine = nsStyleGridLine::kMaxLine;
|
||||
int32_t clampMinColLine = kMinLine;
|
||||
int32_t clampMaxColLine = kMaxLine;
|
||||
uint32_t numRepeatCols;
|
||||
const LineNameMap* parentLineNameMap = nullptr;
|
||||
const LineRange* subgridRange = nullptr;
|
||||
|
@ -3918,9 +3913,8 @@ void nsGridContainerFrame::Grid::PlaceGridItems(
|
|||
clampMinColLine, clampMaxColLine, parentLineNameMap, subgridRange,
|
||||
subgridAxisIsSameDirection);
|
||||
|
||||
int32_t clampMinRowLine = nsStyleGridLine::kMinLine;
|
||||
|
||||
int32_t clampMaxRowLine = nsStyleGridLine::kMaxLine;
|
||||
int32_t clampMinRowLine = kMinLine;
|
||||
int32_t clampMaxRowLine = kMaxLine;
|
||||
uint32_t numRepeatRows;
|
||||
if (!aState.mFrame->IsRowSubgrid()) {
|
||||
numRepeatRows = aState.mRowFunctions.InitRepeatTracks(
|
||||
|
@ -4301,8 +4295,8 @@ void nsGridContainerFrame::Grid::PlaceGridItems(
|
|||
// Resolve the lines for the area. We use the name of the area as the
|
||||
// name of the lines, knowing that the line placement algorithm will
|
||||
// add the -start and -end suffixes as appropriate for layout.
|
||||
nsStyleGridLine lineStartAndEnd;
|
||||
lineStartAndEnd.mLineName = areaInfo.name.AsAtom();
|
||||
StyleGridLine lineStartAndEnd;
|
||||
lineStartAndEnd.ident = areaInfo.name;
|
||||
|
||||
LineRange columnLines =
|
||||
ResolveLineRange(lineStartAndEnd, lineStartAndEnd, colLineNameMap,
|
||||
|
|
|
@ -286,9 +286,6 @@ class nsGridContainerFrame final : public nsContainerFrame {
|
|||
nsGridContainerFrame* ParentGridContainerForSubgrid() const;
|
||||
|
||||
protected:
|
||||
static const uint32_t kAutoLine;
|
||||
// The maximum line number, in the zero-based translated grid.
|
||||
static const uint32_t kTranslatedMaxLine;
|
||||
typedef mozilla::LogicalPoint LogicalPoint;
|
||||
typedef mozilla::LogicalRect LogicalRect;
|
||||
typedef mozilla::LogicalSize LogicalSize;
|
||||
|
|
|
@ -513,6 +513,7 @@ cbindgen-types = [
|
|||
{ gecko = "StyleGenericGradient", servo = "values::generics::image::Gradient" },
|
||||
{ gecko = "StyleLineDirection", servo = "values::computed::image::LineDirection" },
|
||||
{ gecko = "StyleGridTemplateAreas", servo = "values::computed::position::GridTemplateAreas" },
|
||||
{ gecko = "StyleGenericGridLine", servo = "values::generics::grid::GridLine" },
|
||||
]
|
||||
|
||||
mapped-generic-types = [
|
||||
|
|
|
@ -236,7 +236,13 @@ inline nsAtom* StyleAtom::AsAtom() const {
|
|||
return reinterpret_cast<nsAtom*>(_0);
|
||||
}
|
||||
|
||||
inline StyleAtom::~StyleAtom() {
|
||||
inline void StyleAtom::AddRef() {
|
||||
if (!IsStatic()) {
|
||||
AsAtom()->AddRef();
|
||||
}
|
||||
}
|
||||
|
||||
inline void StyleAtom::Release() {
|
||||
if (!IsStatic()) {
|
||||
AsAtom()->Release();
|
||||
}
|
||||
|
@ -256,11 +262,20 @@ inline StyleAtom::StyleAtom(already_AddRefed<nsAtom> aAtom) {
|
|||
}
|
||||
|
||||
inline StyleAtom::StyleAtom(const StyleAtom& aOther) : _0(aOther._0) {
|
||||
if (!IsStatic()) {
|
||||
reinterpret_cast<nsAtom*>(_0)->AddRef();
|
||||
}
|
||||
AddRef();
|
||||
}
|
||||
|
||||
inline StyleAtom& StyleAtom::operator=(const StyleAtom& aOther) {
|
||||
if (MOZ_LIKELY(this != &aOther)) {
|
||||
Release();
|
||||
_0 = aOther._0;
|
||||
AddRef();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline StyleAtom::~StyleAtom() { Release(); }
|
||||
|
||||
inline nsAtom* StyleCustomIdent::AsAtom() const { return _0.AsAtom(); }
|
||||
|
||||
inline nsDependentCSubstring StyleOwnedStr::AsString() const {
|
||||
|
@ -369,6 +384,22 @@ inline bool StyleComputedUrl::HasRef() const {
|
|||
template <>
|
||||
bool StyleGradient::IsOpaque() const;
|
||||
|
||||
template <typename Integer>
|
||||
inline StyleGenericGridLine<Integer>::StyleGenericGridLine()
|
||||
: ident(do_AddRef(static_cast<nsAtom*>(nsGkAtoms::_empty))),
|
||||
line_num(0),
|
||||
is_span(false) {}
|
||||
|
||||
template <>
|
||||
inline nsAtom* StyleGridLine::LineName() const {
|
||||
return ident.AsAtom();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline bool StyleGridLine::IsAuto() const {
|
||||
return LineName()->IsEmpty() && line_num == 0 && !is_span;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
||||
|
|
|
@ -46,9 +46,6 @@
|
|||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
/* static */ const int32_t nsStyleGridLine::kMinLine;
|
||||
/* static */ const int32_t nsStyleGridLine::kMaxLine;
|
||||
|
||||
static const nscoord kMediumBorderWidth = nsPresContext::CSSPixelsToAppUnits(3);
|
||||
|
||||
// We set the size limit of style structs to 504 bytes so that when they
|
||||
|
|
|
@ -945,44 +945,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleList {
|
|||
mMozListReversed; // true in an <ol reversed> scope
|
||||
};
|
||||
|
||||
struct nsStyleGridLine {
|
||||
// http://dev.w3.org/csswg/css-grid/#typedef-grid-line
|
||||
// XXXmats we could optimize memory size here
|
||||
bool mHasSpan;
|
||||
int32_t mInteger; // 0 means not provided
|
||||
RefPtr<nsAtom> mLineName; // Empty string means not provided.
|
||||
|
||||
// These are the limits that we choose to clamp grid line numbers to.
|
||||
// http://dev.w3.org/csswg/css-grid/#overlarge-grids
|
||||
// mInteger is clamped to this range:
|
||||
static const int32_t kMinLine = -10000;
|
||||
static const int32_t kMaxLine = 10000;
|
||||
|
||||
nsStyleGridLine()
|
||||
: mHasSpan(false), mInteger(0), mLineName(nsGkAtoms::_empty) {}
|
||||
|
||||
nsStyleGridLine(const nsStyleGridLine& aOther) { (*this) = aOther; }
|
||||
|
||||
void operator=(const nsStyleGridLine& aOther) {
|
||||
mHasSpan = aOther.mHasSpan;
|
||||
mInteger = aOther.mInteger;
|
||||
mLineName = aOther.mLineName;
|
||||
}
|
||||
|
||||
bool operator!=(const nsStyleGridLine& aOther) const {
|
||||
return mHasSpan != aOther.mHasSpan || mInteger != aOther.mInteger ||
|
||||
mLineName != aOther.mLineName;
|
||||
}
|
||||
|
||||
bool IsAuto() const {
|
||||
bool haveInitialValues = mInteger == 0 && mLineName == nsGkAtoms::_empty;
|
||||
MOZ_ASSERT(!(haveInitialValues && mHasSpan),
|
||||
"should not have 'span' when other components are "
|
||||
"at their initial values");
|
||||
return haveInitialValues;
|
||||
}
|
||||
};
|
||||
|
||||
// Computed value of the grid-template-columns or grid-template-rows property
|
||||
// (but *not* grid-template-areas.)
|
||||
// http://dev.w3.org/csswg/css-grid/#track-sizing
|
||||
|
@ -1051,7 +1013,7 @@ struct nsStyleGridTemplate {
|
|||
bool HasRepeatAuto() const { return mRepeatAutoIndex != -1; }
|
||||
|
||||
bool IsRepeatAutoIndex(uint32_t aIndex) const {
|
||||
MOZ_ASSERT(aIndex < uint32_t(2 * nsStyleGridLine::kMaxLine));
|
||||
MOZ_ASSERT(aIndex < uint32_t(2 * mozilla::StyleMAX_GRID_LINE));
|
||||
return int32_t(aIndex) == mRepeatAutoIndex;
|
||||
}
|
||||
};
|
||||
|
@ -1142,10 +1104,10 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePosition {
|
|||
|
||||
mozilla::StyleGridTemplateAreas mGridTemplateAreas;
|
||||
|
||||
nsStyleGridLine mGridColumnStart;
|
||||
nsStyleGridLine mGridColumnEnd;
|
||||
nsStyleGridLine mGridRowStart;
|
||||
nsStyleGridLine mGridRowEnd;
|
||||
mozilla::StyleGridLine mGridColumnStart;
|
||||
mozilla::StyleGridLine mGridColumnEnd;
|
||||
mozilla::StyleGridLine mGridRowStart;
|
||||
mozilla::StyleGridLine mGridRowEnd;
|
||||
mozilla::NonNegativeLengthPercentageOrNormal mColumnGap;
|
||||
mozilla::NonNegativeLengthPercentageOrNormal mRowGap;
|
||||
|
||||
|
|
|
@ -880,15 +880,8 @@ class Side(object):
|
|||
self.ident = name.lower()
|
||||
self.index = index
|
||||
|
||||
class GridLine(object):
|
||||
def __init__(self, name):
|
||||
self.ident = "grid-" + name.lower()
|
||||
self.name = self.ident.replace('-', '_')
|
||||
self.gecko = "m" + to_camel_case(self.ident)
|
||||
|
||||
SIDES = [Side("Top", 0), Side("Right", 1), Side("Bottom", 2), Side("Left", 3)]
|
||||
CORNERS = ["top_left", "top_right", "bottom_right", "bottom_left"]
|
||||
GRID_LINES = map(GridLine, ["row-start", "row-end", "column-start", "column-end"])
|
||||
%>
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
@ -1077,7 +1070,7 @@ fn static_assert() {
|
|||
% endfor
|
||||
</%self:impl_trait>
|
||||
|
||||
<% skip_position_longhands = " ".join(x.ident for x in SIDES + GRID_LINES) %>
|
||||
<% skip_position_longhands = " ".join(x.ident for x in SIDES) %>
|
||||
<%self:impl_trait style_struct_name="Position"
|
||||
skip_longhands="${skip_position_longhands} order
|
||||
align-content justify-content align-self
|
||||
|
@ -1132,45 +1125,6 @@ fn static_assert() {
|
|||
|
||||
${impl_simple_copy('order', 'mOrder')}
|
||||
|
||||
% for value in GRID_LINES:
|
||||
pub fn set_${value.name}(&mut self, v: longhands::${value.name}::computed_value::T) {
|
||||
use crate::gecko_bindings::structs::{nsStyleGridLine_kMinLine, nsStyleGridLine_kMaxLine};
|
||||
|
||||
let line = &mut self.gecko.${value.gecko};
|
||||
line.mLineName.set_move(unsafe {
|
||||
RefPtr::from_addrefed(v.ident.into_addrefed())
|
||||
});
|
||||
line.mHasSpan = v.is_span;
|
||||
// clamping the integer between a range
|
||||
line.mInteger = cmp::max(
|
||||
nsStyleGridLine_kMinLine,
|
||||
cmp::min(v.line_num, nsStyleGridLine_kMaxLine),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn copy_${value.name}_from(&mut self, other: &Self) {
|
||||
self.gecko.${value.gecko}.mHasSpan = other.gecko.${value.gecko}.mHasSpan;
|
||||
self.gecko.${value.gecko}.mInteger = other.gecko.${value.gecko}.mInteger;
|
||||
unsafe {
|
||||
self.gecko.${value.gecko}.mLineName.set(&other.gecko.${value.gecko}.mLineName);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reset_${value.name}(&mut self, other: &Self) {
|
||||
self.copy_${value.name}_from(other)
|
||||
}
|
||||
|
||||
pub fn clone_${value.name}(&self) -> longhands::${value.name}::computed_value::T {
|
||||
longhands::${value.name}::computed_value::T {
|
||||
is_span: self.gecko.${value.gecko}.mHasSpan,
|
||||
ident: unsafe {
|
||||
Atom::from_raw(self.gecko.${value.gecko}.mLineName.mRawPtr)
|
||||
},
|
||||
line_num: self.gecko.${value.gecko}.mInteger,
|
||||
}
|
||||
}
|
||||
% endfor
|
||||
|
||||
% for kind in ["rows", "columns"]:
|
||||
pub fn set_grid_auto_${kind}(&mut self, v: longhands::grid_auto_${kind}::computed_value::T) {
|
||||
let gecko = &mut *self.gecko;
|
||||
|
@ -1194,11 +1148,11 @@ fn static_assert() {
|
|||
|
||||
pub fn set_grid_template_${kind}(&mut self, v: longhands::grid_template_${kind}::computed_value::T) {
|
||||
<% self_grid = "self.gecko.mGridTemplate%s" % kind.title() %>
|
||||
use crate::gecko_bindings::structs::{nsTArray, nsStyleGridLine_kMaxLine};
|
||||
use crate::gecko_bindings::structs::nsTArray;
|
||||
use std::usize;
|
||||
use crate::values::CustomIdent;
|
||||
use crate::values::generics::grid::TrackListType::Auto;
|
||||
use crate::values::generics::grid::{GridTemplateComponent, RepeatCount};
|
||||
use crate::values::generics::grid::{GridTemplateComponent, RepeatCount, MAX_GRID_LINE};
|
||||
|
||||
#[inline]
|
||||
fn set_line_names(servo_names: &[CustomIdent], gecko_names: &mut nsTArray<structs::RefPtr<structs::nsAtom>>) {
|
||||
|
@ -1213,7 +1167,7 @@ fn static_assert() {
|
|||
}
|
||||
}
|
||||
|
||||
let max_lines = nsStyleGridLine_kMaxLine as usize - 1; // for accounting the final <line-names>
|
||||
let max_lines = MAX_GRID_LINE as usize - 1; // for accounting the final <line-names>
|
||||
|
||||
let result = match v {
|
||||
GridTemplateComponent::None => ptr::null_mut(),
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
use self::transform::DirectionVector;
|
||||
use super::animated::ToAnimatedValue;
|
||||
use super::generics::grid::GridTemplateComponent as GenericGridTemplateComponent;
|
||||
use super::generics::grid::{GridLine as GenericGridLine, TrackBreadth as GenericTrackBreadth};
|
||||
use super::generics::grid::{GenericGridLine, TrackBreadth as GenericTrackBreadth};
|
||||
use super::generics::grid::{TrackList as GenericTrackList, TrackSize as GenericTrackSize};
|
||||
use super::generics::transform::IsParallelTo;
|
||||
use super::generics::{self, GreaterThanOrEqualToOne, NonNegative, ZeroToOne};
|
||||
|
|
|
@ -13,9 +13,17 @@ use crate::values::specified::grid::parse_line_names;
|
|||
use crate::values::{CSSFloat, CustomIdent};
|
||||
use cssparser::Parser;
|
||||
use std::fmt::{self, Write};
|
||||
use std::{mem, usize};
|
||||
use std::{cmp, mem, usize};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
|
||||
|
||||
/// These are the limits that we choose to clamp grid line numbers to.
|
||||
/// http://drafts.csswg.org/css-grid/#overlarge-grids
|
||||
/// line_num is clamped to this range at parse time.
|
||||
pub const MIN_GRID_LINE: i32 = -10000;
|
||||
/// See above.
|
||||
pub const MAX_GRID_LINE: i32 = 10000;
|
||||
|
||||
/// A `<grid-line>` type.
|
||||
///
|
||||
/// <https://drafts.csswg.org/css-grid/#typedef-grid-row-start-grid-line>
|
||||
|
@ -32,14 +40,20 @@ use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
|||
)]
|
||||
#[repr(C)]
|
||||
pub struct GenericGridLine<Integer> {
|
||||
/// Flag to check whether it's a `span` keyword.
|
||||
pub is_span: bool,
|
||||
/// A custom identifier for named lines, or the empty atom otherwise.
|
||||
///
|
||||
/// <https://drafts.csswg.org/css-grid/#grid-placement-slot>
|
||||
pub ident: Atom,
|
||||
/// Denotes the nth grid line from grid item's placement.
|
||||
///
|
||||
/// This is clamped by MIN_GRID_LINE and MAX_GRID_LINE.
|
||||
///
|
||||
/// NOTE(emilio): If we ever allow animating these we need to either do
|
||||
/// something more complicated for the clamping, or do this clamping at
|
||||
/// used-value time.
|
||||
pub line_num: Integer,
|
||||
/// Flag to check whether it's a `span` keyword.
|
||||
pub is_span: bool,
|
||||
}
|
||||
|
||||
pub use self::GenericGridLine as GridLine;
|
||||
|
@ -128,11 +142,12 @@ impl Parse for GridLine<specified::Integer> {
|
|||
grid_line.is_span = true;
|
||||
} else if let Ok(i) = input.try(|i| specified::Integer::parse(context, i)) {
|
||||
// FIXME(emilio): Probably shouldn't reject if it's calc()...
|
||||
if i.value() == 0 || val_before_span || grid_line.line_num.value() != 0 {
|
||||
let value = i.value();
|
||||
if value == 0 || val_before_span || !grid_line.line_num.is_zero() {
|
||||
return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
grid_line.line_num = i;
|
||||
grid_line.line_num = specified::Integer::new(cmp::max(MIN_GRID_LINE, cmp::min(value, MAX_GRID_LINE)));
|
||||
} else if let Ok(name) = input.try(|i| i.expect_ident_cloned()) {
|
||||
if val_before_span || grid_line.ident != atom!("") {
|
||||
return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
|
|
|
@ -156,6 +156,7 @@ include = [
|
|||
"Filter",
|
||||
"Gradient",
|
||||
"GridTemplateAreas",
|
||||
"GridLine",
|
||||
]
|
||||
item_types = ["enums", "structs", "typedefs", "functions", "constants"]
|
||||
renaming_overrides_prefixing = true
|
||||
|
@ -467,16 +468,17 @@ renaming_overrides_prefixing = true
|
|||
StyleAtom(size_t) = delete;
|
||||
StyleAtom() = delete;
|
||||
|
||||
// NOTE(emilio): For now we don't need to expose anything else, but it'd be trivial if we wanted to.
|
||||
inline bool IsStatic() const;
|
||||
inline nsAtom* AsAtom() const;
|
||||
|
||||
private:
|
||||
inline void AddRef();
|
||||
inline void Release();
|
||||
|
||||
public:
|
||||
inline explicit StyleAtom(already_AddRefed<nsAtom> aAtom);
|
||||
|
||||
// Could be implemented if wanted.
|
||||
StyleAtom& operator=(const StyleAtom&) = delete;
|
||||
|
||||
inline StyleAtom(const StyleAtom& aOther);
|
||||
inline StyleAtom& operator=(const StyleAtom&);
|
||||
inline ~StyleAtom();
|
||||
"""
|
||||
|
||||
|
@ -596,3 +598,11 @@ renaming_overrides_prefixing = true
|
|||
StyleGridTemplateAreas() {}
|
||||
public:
|
||||
"""
|
||||
|
||||
"GenericGridLine" = """
|
||||
// Returns the `auto` value.
|
||||
inline StyleGenericGridLine();
|
||||
inline bool IsAuto() const;
|
||||
// The line name, or nsGkAtoms::_empty if not present.
|
||||
inline nsAtom* LineName() const;
|
||||
"""
|
||||
|
|
Загрузка…
Ссылка в новой задаче