Bug 984760 part 2: Use GridTemplateAreasValue though nsRefPtr pointers. r=dholbert
This commit is contained in:
@@ -1022,7 +1022,7 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue,
|
|||||||
// which isn't a value that the shorthand can express. Bail.
|
// which isn't a value that the shorthand can express. Bail.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const GridTemplateAreasValue& areas = areasValue.GetGridTemplateAreas();
|
const GridTemplateAreasValue* areas = areasValue.GetGridTemplateAreas();
|
||||||
const nsCSSValueList* rowsItem = rowsValue.GetListValue();
|
const nsCSSValueList* rowsItem = rowsValue.GetListValue();
|
||||||
uint32_t nRowItems = 0;
|
uint32_t nRowItems = 0;
|
||||||
while (rowsItem) {
|
while (rowsItem) {
|
||||||
@@ -1030,7 +1030,7 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue,
|
|||||||
rowsItem = rowsItem->mNext;
|
rowsItem = rowsItem->mNext;
|
||||||
}
|
}
|
||||||
MOZ_ASSERT(nRowItems % 2 == 1, "expected an odd number of items");
|
MOZ_ASSERT(nRowItems % 2 == 1, "expected an odd number of items");
|
||||||
if ((nRowItems - 1) / 2 != areas.NRows()) {
|
if ((nRowItems - 1) / 2 != areas->NRows()) {
|
||||||
// Not serializable, bail.
|
// Not serializable, bail.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1057,7 +1057,7 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue,
|
|||||||
aValue.AppendLiteral(")");
|
aValue.AppendLiteral(")");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
nsStyleUtil::AppendEscapedCSSString(areas.mTemplates[row++], aValue);
|
nsStyleUtil::AppendEscapedCSSString(areas->mTemplates[row++], aValue);
|
||||||
aValue.Append(char16_t(' '));
|
aValue.Append(char16_t(' '));
|
||||||
|
|
||||||
// <track-size>
|
// <track-size>
|
||||||
|
|||||||
@@ -673,7 +673,7 @@ protected:
|
|||||||
// |aAreaIndices| is a lookup table to help us parse faster,
|
// |aAreaIndices| is a lookup table to help us parse faster,
|
||||||
// mapping area names to indices in |aResult.mNamedAreas|.
|
// mapping area names to indices in |aResult.mNamedAreas|.
|
||||||
bool ParseGridTemplateAreasLine(const nsAutoString& aInput,
|
bool ParseGridTemplateAreasLine(const nsAutoString& aInput,
|
||||||
css::GridTemplateAreasValue& aResult,
|
css::GridTemplateAreasValue* aResult,
|
||||||
nsDataHashtable<nsStringHashKey, uint32_t>& aAreaIndices);
|
nsDataHashtable<nsStringHashKey, uint32_t>& aAreaIndices);
|
||||||
bool ParseGridTemplateAreas();
|
bool ParseGridTemplateAreas();
|
||||||
bool ParseGridTemplate();
|
bool ParseGridTemplate();
|
||||||
@@ -7156,15 +7156,15 @@ CSSParserImpl::ParseGridTemplateColumnsRows(nsCSSProperty aPropID)
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
CSSParserImpl::ParseGridTemplateAreasLine(const nsAutoString& aInput,
|
CSSParserImpl::ParseGridTemplateAreasLine(const nsAutoString& aInput,
|
||||||
css::GridTemplateAreasValue& aAreas,
|
css::GridTemplateAreasValue* aAreas,
|
||||||
nsDataHashtable<nsStringHashKey, uint32_t>& aAreaIndices)
|
nsDataHashtable<nsStringHashKey, uint32_t>& aAreaIndices)
|
||||||
{
|
{
|
||||||
aAreas.mTemplates.AppendElement(mToken.mIdent);
|
aAreas->mTemplates.AppendElement(mToken.mIdent);
|
||||||
|
|
||||||
nsCSSGridTemplateAreaScanner scanner(aInput);
|
nsCSSGridTemplateAreaScanner scanner(aInput);
|
||||||
nsCSSGridTemplateAreaToken token;
|
nsCSSGridTemplateAreaToken token;
|
||||||
css::GridNamedArea* currentArea = nullptr;
|
css::GridNamedArea* currentArea = nullptr;
|
||||||
uint32_t row = aAreas.NRows();
|
uint32_t row = aAreas->NRows();
|
||||||
uint32_t column;
|
uint32_t column;
|
||||||
for (column = 1; scanner.Next(token); column++) {
|
for (column = 1; scanner.Next(token); column++) {
|
||||||
if (token.isTrash) {
|
if (token.isTrash) {
|
||||||
@@ -7194,9 +7194,9 @@ CSSParserImpl::ParseGridTemplateAreasLine(const nsAutoString& aInput,
|
|||||||
// Check if this is the continuation of an existing named area:
|
// Check if this is the continuation of an existing named area:
|
||||||
uint32_t index;
|
uint32_t index;
|
||||||
if (aAreaIndices.Get(token.mName, &index)) {
|
if (aAreaIndices.Get(token.mName, &index)) {
|
||||||
MOZ_ASSERT(index < aAreas.mNamedAreas.Length(),
|
MOZ_ASSERT(index < aAreas->mNamedAreas.Length(),
|
||||||
"Invalid aAreaIndices hash table");
|
"Invalid aAreaIndices hash table");
|
||||||
currentArea = &aAreas.mNamedAreas[index];
|
currentArea = &aAreas->mNamedAreas[index];
|
||||||
if (currentArea->mColumnStart != column ||
|
if (currentArea->mColumnStart != column ||
|
||||||
currentArea->mRowEnd != row) {
|
currentArea->mRowEnd != row) {
|
||||||
// Existing named area, but not forming a rectangle
|
// Existing named area, but not forming a rectangle
|
||||||
@@ -7206,8 +7206,8 @@ CSSParserImpl::ParseGridTemplateAreasLine(const nsAutoString& aInput,
|
|||||||
currentArea->mRowEnd++;
|
currentArea->mRowEnd++;
|
||||||
} else {
|
} else {
|
||||||
// New named area
|
// New named area
|
||||||
aAreaIndices.Put(token.mName, aAreas.mNamedAreas.Length());
|
aAreaIndices.Put(token.mName, aAreas->mNamedAreas.Length());
|
||||||
currentArea = aAreas.mNamedAreas.AppendElement();
|
currentArea = aAreas->mNamedAreas.AppendElement();
|
||||||
currentArea->mName = token.mName;
|
currentArea->mName = token.mName;
|
||||||
// For column or row N (starting at 1),
|
// For column or row N (starting at 1),
|
||||||
// the start line is N, the end line is N + 1
|
// the start line is N, the end line is N + 1
|
||||||
@@ -7230,8 +7230,8 @@ CSSParserImpl::ParseGridTemplateAreasLine(const nsAutoString& aInput,
|
|||||||
// On other rows, check that the number of columns is consistent
|
// On other rows, check that the number of columns is consistent
|
||||||
// between rows.
|
// between rows.
|
||||||
if (row == 1) {
|
if (row == 1) {
|
||||||
aAreas.mNColumns = column;
|
aAreas->mNColumns = column;
|
||||||
} else if (aAreas.mNColumns != column) {
|
} else if (aAreas->mNColumns != column) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -7246,7 +7246,8 @@ CSSParserImpl::ParseGridTemplateAreas()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
css::GridTemplateAreasValue& areas = value.SetGridTemplateAreas();
|
nsRefPtr<css::GridTemplateAreasValue> areas =
|
||||||
|
new css::GridTemplateAreasValue();
|
||||||
nsDataHashtable<nsStringHashKey, uint32_t> areaIndices;
|
nsDataHashtable<nsStringHashKey, uint32_t> areaIndices;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (!GetToken(true)) {
|
if (!GetToken(true)) {
|
||||||
@@ -7261,11 +7262,11 @@ CSSParserImpl::ParseGridTemplateAreas()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (areas.NRows() == 0) {
|
if (areas->NRows() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AppendValue(eCSSProperty_grid_template_areas, value);
|
AppendValue(eCSSProperty_grid_template_areas, nsCSSValue(areas));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7366,9 +7367,9 @@ CSSParserImpl::ParseGridTemplateAfterString(const nsCSSValue& aFirstLineNames)
|
|||||||
MOZ_ASSERT(mToken.mType == eCSSToken_String,
|
MOZ_ASSERT(mToken.mType == eCSSToken_String,
|
||||||
"ParseGridTemplateAfterString called with a non-string token");
|
"ParseGridTemplateAfterString called with a non-string token");
|
||||||
|
|
||||||
nsCSSValue areasValue;
|
|
||||||
nsCSSValue rowsValue;
|
nsCSSValue rowsValue;
|
||||||
css::GridTemplateAreasValue& areas = areasValue.SetGridTemplateAreas();
|
nsRefPtr<css::GridTemplateAreasValue> areas =
|
||||||
|
new css::GridTemplateAreasValue();
|
||||||
nsDataHashtable<nsStringHashKey, uint32_t> areaIndices;
|
nsDataHashtable<nsStringHashKey, uint32_t> areaIndices;
|
||||||
nsCSSValueList* rowsItem = rowsValue.SetListValue();
|
nsCSSValueList* rowsItem = rowsValue.SetListValue();
|
||||||
rowsItem->mValue = aFirstLineNames;
|
rowsItem->mValue = aFirstLineNames;
|
||||||
@@ -7410,7 +7411,7 @@ CSSParserImpl::ParseGridTemplateAfterString(const nsCSSValue& aFirstLineNames)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AppendValue(eCSSProperty_grid_template_areas, areasValue);
|
AppendValue(eCSSProperty_grid_template_areas, nsCSSValue(areas));
|
||||||
AppendValue(eCSSProperty_grid_template_rows, rowsValue);
|
AppendValue(eCSSProperty_grid_template_rows, rowsValue);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,6 +104,13 @@ nsCSSValue::nsCSSValue(nsCSSValueTokenStream* aValue)
|
|||||||
mValue.mTokenStream->AddRef();
|
mValue.mTokenStream->AddRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsCSSValue::nsCSSValue(mozilla::css::GridTemplateAreasValue* aValue)
|
||||||
|
: mUnit(eCSSUnit_GridTemplateAreas)
|
||||||
|
{
|
||||||
|
mValue.mGridTemplateAreas = aValue;
|
||||||
|
mValue.mGridTemplateAreas->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
nsCSSValue::nsCSSValue(const nsCSSValue& aCopy)
|
nsCSSValue::nsCSSValue(const nsCSSValue& aCopy)
|
||||||
: mUnit(aCopy.mUnit)
|
: mUnit(aCopy.mUnit)
|
||||||
{
|
{
|
||||||
@@ -460,6 +467,14 @@ void nsCSSValue::SetTokenStreamValue(nsCSSValueTokenStream* aValue)
|
|||||||
mValue.mTokenStream->AddRef();
|
mValue.mTokenStream->AddRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nsCSSValue::SetGridTemplateAreas(mozilla::css::GridTemplateAreasValue* aValue)
|
||||||
|
{
|
||||||
|
Reset();
|
||||||
|
mUnit = eCSSUnit_GridTemplateAreas;
|
||||||
|
mValue.mGridTemplateAreas = aValue;
|
||||||
|
mValue.mGridTemplateAreas->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
void nsCSSValue::SetPairValue(const nsCSSValuePair* aValue)
|
void nsCSSValue::SetPairValue(const nsCSSValuePair* aValue)
|
||||||
{
|
{
|
||||||
// pairs should not be used for null/inherit/initial values
|
// pairs should not be used for null/inherit/initial values
|
||||||
@@ -596,15 +611,6 @@ void nsCSSValue::SetDependentPairListValue(nsCSSValuePairList* aList)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::css::GridTemplateAreasValue& nsCSSValue::SetGridTemplateAreas()
|
|
||||||
{
|
|
||||||
Reset();
|
|
||||||
mUnit = eCSSUnit_GridTemplateAreas;
|
|
||||||
mValue.mGridTemplateAreas = new mozilla::css::GridTemplateAreasValue;
|
|
||||||
mValue.mGridTemplateAreas->AddRef();
|
|
||||||
return *mValue.mGridTemplateAreas;
|
|
||||||
}
|
|
||||||
|
|
||||||
void nsCSSValue::SetAutoValue()
|
void nsCSSValue::SetAutoValue()
|
||||||
{
|
{
|
||||||
Reset();
|
Reset();
|
||||||
@@ -1345,13 +1351,13 @@ nsCSSValue::AppendToString(nsCSSProperty aProperty, nsAString& aResult,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (eCSSUnit_GridTemplateAreas == unit) {
|
} else if (eCSSUnit_GridTemplateAreas == unit) {
|
||||||
const mozilla::css::GridTemplateAreasValue& areas = GetGridTemplateAreas();
|
const mozilla::css::GridTemplateAreasValue* areas = GetGridTemplateAreas();
|
||||||
MOZ_ASSERT(!areas.mTemplates.IsEmpty(),
|
MOZ_ASSERT(!areas->mTemplates.IsEmpty(),
|
||||||
"Unexpected empty array in GridTemplateAreasValue");
|
"Unexpected empty array in GridTemplateAreasValue");
|
||||||
nsStyleUtil::AppendEscapedCSSString(areas.mTemplates[0], aResult);
|
nsStyleUtil::AppendEscapedCSSString(areas->mTemplates[0], aResult);
|
||||||
for (uint32_t i = 1; i < areas.mTemplates.Length(); i++) {
|
for (uint32_t i = 1; i < areas->mTemplates.Length(); i++) {
|
||||||
aResult.Append(char16_t(' '));
|
aResult.Append(char16_t(' '));
|
||||||
nsStyleUtil::AppendEscapedCSSString(areas.mTemplates[i], aResult);
|
nsStyleUtil::AppendEscapedCSSString(areas->mTemplates[i], aResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ struct GridNamedArea {
|
|||||||
uint32_t mRowEnd;
|
uint32_t mRowEnd;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GridTemplateAreasValue {
|
struct GridTemplateAreasValue MOZ_FINAL {
|
||||||
// Parsed value
|
// Parsed value
|
||||||
nsTArray<GridNamedArea> mNamedAreas;
|
nsTArray<GridNamedArea> mNamedAreas;
|
||||||
|
|
||||||
@@ -168,13 +168,6 @@ struct GridTemplateAreasValue {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reset()
|
|
||||||
{
|
|
||||||
mNamedAreas.Clear();
|
|
||||||
mTemplates.Clear();
|
|
||||||
mNColumns = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const GridTemplateAreasValue& aOther) const
|
bool operator==(const GridTemplateAreasValue& aOther) const
|
||||||
{
|
{
|
||||||
return mTemplates == aOther.mTemplates;
|
return mTemplates == aOther.mTemplates;
|
||||||
@@ -188,6 +181,17 @@ struct GridTemplateAreasValue {
|
|||||||
NS_INLINE_DECL_REFCOUNTING(GridTemplateAreasValue)
|
NS_INLINE_DECL_REFCOUNTING(GridTemplateAreasValue)
|
||||||
|
|
||||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private destructor to make sure this isn't used as a stack variable
|
||||||
|
// or member variable.
|
||||||
|
~GridTemplateAreasValue()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GridTemplateAreasValue(const GridTemplateAreasValue& aOther) MOZ_DELETE;
|
||||||
|
GridTemplateAreasValue&
|
||||||
|
operator=(const GridTemplateAreasValue& aOther) MOZ_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -247,6 +251,8 @@ enum nsCSSUnit {
|
|||||||
eCSSUnit_Image = 41, // (nsCSSValue::Image*) value
|
eCSSUnit_Image = 41, // (nsCSSValue::Image*) value
|
||||||
eCSSUnit_Gradient = 42, // (nsCSSValueGradient*) value
|
eCSSUnit_Gradient = 42, // (nsCSSValueGradient*) value
|
||||||
eCSSUnit_TokenStream = 43, // (nsCSSValueTokenStream*) value
|
eCSSUnit_TokenStream = 43, // (nsCSSValueTokenStream*) value
|
||||||
|
eCSSUnit_GridTemplateAreas = 44, // (GridTemplateAreasValue*)
|
||||||
|
// for grid-template-areas
|
||||||
|
|
||||||
eCSSUnit_Pair = 50, // (nsCSSValuePair*) pair of values
|
eCSSUnit_Pair = 50, // (nsCSSValuePair*) pair of values
|
||||||
eCSSUnit_Triplet = 51, // (nsCSSValueTriplet*) triplet of values
|
eCSSUnit_Triplet = 51, // (nsCSSValueTriplet*) triplet of values
|
||||||
@@ -260,8 +266,6 @@ enum nsCSSUnit {
|
|||||||
eCSSUnit_PairListDep = 57, // (nsCSSValuePairList*) same as PairList
|
eCSSUnit_PairListDep = 57, // (nsCSSValuePairList*) same as PairList
|
||||||
// but does not own the list
|
// but does not own the list
|
||||||
|
|
||||||
eCSSUnit_GridTemplateAreas = 60, // (GridTemplateAreasValue*) for grid-template-areas
|
|
||||||
|
|
||||||
eCSSUnit_Integer = 70, // (int) simple value
|
eCSSUnit_Integer = 70, // (int) simple value
|
||||||
eCSSUnit_Enumerated = 71, // (int) value has enumerated meaning
|
eCSSUnit_Enumerated = 71, // (int) value has enumerated meaning
|
||||||
|
|
||||||
@@ -359,6 +363,7 @@ public:
|
|||||||
explicit nsCSSValue(mozilla::css::ImageValue* aValue);
|
explicit nsCSSValue(mozilla::css::ImageValue* aValue);
|
||||||
explicit nsCSSValue(nsCSSValueGradient* aValue);
|
explicit nsCSSValue(nsCSSValueGradient* aValue);
|
||||||
explicit nsCSSValue(nsCSSValueTokenStream* aValue);
|
explicit nsCSSValue(nsCSSValueTokenStream* aValue);
|
||||||
|
explicit nsCSSValue(mozilla::css::GridTemplateAreasValue* aValue);
|
||||||
nsCSSValue(const nsCSSValue& aCopy);
|
nsCSSValue(const nsCSSValue& aCopy);
|
||||||
~nsCSSValue() { Reset(); }
|
~nsCSSValue() { Reset(); }
|
||||||
|
|
||||||
@@ -553,8 +558,6 @@ public:
|
|||||||
inline nsCSSValueTriplet& GetTripletValue();
|
inline nsCSSValueTriplet& GetTripletValue();
|
||||||
inline const nsCSSValueTriplet& GetTripletValue() const;
|
inline const nsCSSValueTriplet& GetTripletValue() const;
|
||||||
|
|
||||||
inline mozilla::css::GridTemplateAreasValue& GetGridTemplateAreas();
|
|
||||||
inline const mozilla::css::GridTemplateAreasValue& GetGridTemplateAreas() const;
|
|
||||||
|
|
||||||
mozilla::css::URLValue* GetURLStructValue() const
|
mozilla::css::URLValue* GetURLStructValue() const
|
||||||
{
|
{
|
||||||
@@ -570,6 +573,13 @@ public:
|
|||||||
return mValue.mImage;
|
return mValue.mImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mozilla::css::GridTemplateAreasValue* GetGridTemplateAreas() const
|
||||||
|
{
|
||||||
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_GridTemplateAreas,
|
||||||
|
"not a grid-template-areas value");
|
||||||
|
return mValue.mGridTemplateAreas;
|
||||||
|
}
|
||||||
|
|
||||||
const char16_t* GetOriginalURLValue() const
|
const char16_t* GetOriginalURLValue() const
|
||||||
{
|
{
|
||||||
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_URL || mUnit == eCSSUnit_Image,
|
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_URL || mUnit == eCSSUnit_Image,
|
||||||
@@ -611,6 +621,7 @@ public:
|
|||||||
void SetImageValue(mozilla::css::ImageValue* aImage);
|
void SetImageValue(mozilla::css::ImageValue* aImage);
|
||||||
void SetGradientValue(nsCSSValueGradient* aGradient);
|
void SetGradientValue(nsCSSValueGradient* aGradient);
|
||||||
void SetTokenStreamValue(nsCSSValueTokenStream* aTokenStream);
|
void SetTokenStreamValue(nsCSSValueTokenStream* aTokenStream);
|
||||||
|
void SetGridTemplateAreas(mozilla::css::GridTemplateAreasValue* aValue);
|
||||||
void SetPairValue(const nsCSSValuePair* aPair);
|
void SetPairValue(const nsCSSValuePair* aPair);
|
||||||
void SetPairValue(const nsCSSValue& xValue, const nsCSSValue& yValue);
|
void SetPairValue(const nsCSSValue& xValue, const nsCSSValue& yValue);
|
||||||
void SetSharedListValue(nsCSSValueSharedList* aList);
|
void SetSharedListValue(nsCSSValueSharedList* aList);
|
||||||
@@ -634,7 +645,6 @@ public:
|
|||||||
nsCSSRect& SetRectValue();
|
nsCSSRect& SetRectValue();
|
||||||
nsCSSValueList* SetListValue();
|
nsCSSValueList* SetListValue();
|
||||||
nsCSSValuePairList* SetPairListValue();
|
nsCSSValuePairList* SetPairListValue();
|
||||||
mozilla::css::GridTemplateAreasValue& SetGridTemplateAreas();
|
|
||||||
|
|
||||||
void StartImageLoad(nsIDocument* aDocument) const; // Only pretend const
|
void StartImageLoad(nsIDocument* aDocument) const; // Only pretend const
|
||||||
|
|
||||||
@@ -1246,22 +1256,6 @@ nsCSSValue::GetPairListValue() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline mozilla::css::GridTemplateAreasValue&
|
|
||||||
nsCSSValue::GetGridTemplateAreas()
|
|
||||||
{
|
|
||||||
NS_ABORT_IF_FALSE (mUnit == eCSSUnit_GridTemplateAreas,
|
|
||||||
"not a grid-template-areas value");
|
|
||||||
return *mValue.mGridTemplateAreas;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const mozilla::css::GridTemplateAreasValue&
|
|
||||||
nsCSSValue::GetGridTemplateAreas() const
|
|
||||||
{
|
|
||||||
NS_ABORT_IF_FALSE (mUnit == eCSSUnit_GridTemplateAreas,
|
|
||||||
"not a grid-template-areas value");
|
|
||||||
return *mValue.mGridTemplateAreas;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct nsCSSValueGradientStop {
|
struct nsCSSValueGradientStop {
|
||||||
public:
|
public:
|
||||||
nsCSSValueGradientStop();
|
nsCSSValueGradientStop();
|
||||||
|
|||||||
@@ -2274,18 +2274,20 @@ nsComputedDOMStyle::DoGetBackgroundSize()
|
|||||||
CSSValue*
|
CSSValue*
|
||||||
nsComputedDOMStyle::DoGetGridTemplateAreas()
|
nsComputedDOMStyle::DoGetGridTemplateAreas()
|
||||||
{
|
{
|
||||||
const nsTArray<nsString>& templates =
|
const css::GridTemplateAreasValue* areas =
|
||||||
StylePosition()->mGridTemplateAreas.mTemplates;
|
StylePosition()->mGridTemplateAreas;
|
||||||
if (templates.IsEmpty()) {
|
if (!areas) {
|
||||||
nsROCSSPrimitiveValue *val = new nsROCSSPrimitiveValue;
|
nsROCSSPrimitiveValue *val = new nsROCSSPrimitiveValue;
|
||||||
val->SetIdent(eCSSKeyword_none);
|
val->SetIdent(eCSSKeyword_none);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MOZ_ASSERT(!areas->mTemplates.IsEmpty(),
|
||||||
|
"Unexpected empty array in GridTemplateAreasValue");
|
||||||
nsDOMCSSValueList *valueList = GetROCSSValueList(false);
|
nsDOMCSSValueList *valueList = GetROCSSValueList(false);
|
||||||
for (uint32_t i = 0; i < templates.Length(); i++) {
|
for (uint32_t i = 0; i < areas->mTemplates.Length(); i++) {
|
||||||
nsAutoString str;
|
nsAutoString str;
|
||||||
nsStyleUtil::AppendEscapedCSSString(templates[i], str);
|
nsStyleUtil::AppendEscapedCSSString(areas->mTemplates[i], str);
|
||||||
nsROCSSPrimitiveValue *val = new nsROCSSPrimitiveValue;
|
nsROCSSPrimitiveValue *val = new nsROCSSPrimitiveValue;
|
||||||
val->SetString(str);
|
val->SetString(str);
|
||||||
valueList->AppendCSSValue(val);
|
valueList->AppendCSSValue(val);
|
||||||
|
|||||||
@@ -7234,8 +7234,8 @@ SetGridTrackList(const nsCSSValue& aValue,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
SetGridTemplateAreas(const nsCSSValue& aValue,
|
SetGridTemplateAreas(const nsCSSValue& aValue,
|
||||||
css::GridTemplateAreasValue& aResult,
|
nsRefPtr<css::GridTemplateAreasValue>* aResult,
|
||||||
const css::GridTemplateAreasValue& aParentValue,
|
css::GridTemplateAreasValue* aParentValue,
|
||||||
bool& aCanStoreInRuleTree)
|
bool& aCanStoreInRuleTree)
|
||||||
{
|
{
|
||||||
switch (aValue.GetUnit()) {
|
switch (aValue.GetUnit()) {
|
||||||
@@ -7244,17 +7244,17 @@ SetGridTemplateAreas(const nsCSSValue& aValue,
|
|||||||
|
|
||||||
case eCSSUnit_Inherit:
|
case eCSSUnit_Inherit:
|
||||||
aCanStoreInRuleTree = false;
|
aCanStoreInRuleTree = false;
|
||||||
aResult = aParentValue;
|
*aResult = aParentValue;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eCSSUnit_Initial:
|
case eCSSUnit_Initial:
|
||||||
case eCSSUnit_Unset:
|
case eCSSUnit_Unset:
|
||||||
case eCSSUnit_None:
|
case eCSSUnit_None:
|
||||||
aResult.Reset();
|
*aResult = nullptr;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
aResult = aValue.GetGridTemplateAreas();
|
*aResult = aValue.GetGridTemplateAreas();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7521,7 +7521,8 @@ nsRuleNode::ComputePositionData(void* aStartStruct,
|
|||||||
|
|
||||||
// grid-tempate-areas
|
// grid-tempate-areas
|
||||||
SetGridTemplateAreas(*aRuleData->ValueForGridTemplateAreas(),
|
SetGridTemplateAreas(*aRuleData->ValueForGridTemplateAreas(),
|
||||||
pos->mGridTemplateAreas, parentPos->mGridTemplateAreas,
|
&pos->mGridTemplateAreas,
|
||||||
|
parentPos->mGridTemplateAreas,
|
||||||
canStoreInRuleTree);
|
canStoreInRuleTree);
|
||||||
|
|
||||||
// grid-auto-position
|
// grid-auto-position
|
||||||
|
|||||||
@@ -1254,12 +1254,11 @@ nsStylePosition::nsStylePosition(void)
|
|||||||
mZIndex.SetAutoValue();
|
mZIndex.SetAutoValue();
|
||||||
mGridAutoPositionColumn.SetToInteger(1);
|
mGridAutoPositionColumn.SetToInteger(1);
|
||||||
mGridAutoPositionRow.SetToInteger(1);
|
mGridAutoPositionRow.SetToInteger(1);
|
||||||
// mGridTemplateRows, mGridTemplateColumns, and mGridTemplateAreas
|
// Other members get their default constructors
|
||||||
// get their default constructors
|
// which initialize them to representations of their respective initial value.
|
||||||
// which initialize them to empty arrays,
|
// mGridTemplateAreas: nullptr for 'none'
|
||||||
// which represent the properties' initial value 'none'.
|
// mGridTemplate{Rows,Columns}: empty arrays for 'none'
|
||||||
|
// mGrid{Column,Row}{Start,End}: false/0/empty values for 'auto'
|
||||||
// mGrid{Column,Row}{Start,End} get their default constructor, 'auto'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsStylePosition::~nsStylePosition(void)
|
nsStylePosition::~nsStylePosition(void)
|
||||||
|
|||||||
@@ -1300,7 +1300,9 @@ struct nsStylePosition {
|
|||||||
// in nsStyleStruct.cpp
|
// in nsStyleStruct.cpp
|
||||||
nsStyleGridTrackList mGridTemplateColumns;
|
nsStyleGridTrackList mGridTemplateColumns;
|
||||||
nsStyleGridTrackList mGridTemplateRows;
|
nsStyleGridTrackList mGridTemplateRows;
|
||||||
mozilla::css::GridTemplateAreasValue mGridTemplateAreas;
|
|
||||||
|
// nullptr for 'none'
|
||||||
|
nsRefPtr<mozilla::css::GridTemplateAreasValue> mGridTemplateAreas;
|
||||||
|
|
||||||
// We represent the "grid-auto-position" property in two parts:
|
// We represent the "grid-auto-position" property in two parts:
|
||||||
nsStyleGridLine mGridAutoPositionColumn;
|
nsStyleGridLine mGridAutoPositionColumn;
|
||||||
|
|||||||
Reference in New Issue
Block a user