mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 569719 part 7: Add AppendToString methods to nsCSSRect and friends as well, replacing Declaration::AppendStorageToString. r=dbaron
This commit is contained in:
parent
b87b69a229
commit
b9547bdd5e
@ -122,110 +122,40 @@ Declaration::RemoveProperty(nsCSSProperty aProperty)
|
||||
PRBool Declaration::AppendValueToString(nsCSSProperty aProperty,
|
||||
nsAString& aResult) const
|
||||
{
|
||||
NS_ABORT_IF_FALSE(0 <= aProperty &&
|
||||
aProperty < eCSSProperty_COUNT_no_shorthands,
|
||||
"property ID out of range");
|
||||
|
||||
nsCSSCompressedDataBlock *data = GetValueIsImportant(aProperty)
|
||||
? mImportantData : mData;
|
||||
const void *storage = data->StorageFor(aProperty);
|
||||
return Declaration::AppendStorageToString(aProperty, storage, aResult);
|
||||
}
|
||||
|
||||
/* static */ PRBool
|
||||
Declaration::AppendStorageToString(nsCSSProperty aProperty,
|
||||
const void* aStorage,
|
||||
nsAString& aResult)
|
||||
{
|
||||
if (aStorage) {
|
||||
switch (nsCSSProps::kTypeTable[aProperty]) {
|
||||
case eCSSType_Value: {
|
||||
const nsCSSValue *val = static_cast<const nsCSSValue*>(aStorage);
|
||||
val->AppendToString(aProperty, aResult);
|
||||
} break;
|
||||
case eCSSType_Rect: {
|
||||
const nsCSSRect *rect = static_cast<const nsCSSRect*>(aStorage);
|
||||
const nsCSSUnit topUnit = rect->mTop.GetUnit();
|
||||
if (topUnit == eCSSUnit_Inherit ||
|
||||
topUnit == eCSSUnit_Initial ||
|
||||
topUnit == eCSSUnit_RectIsAuto) {
|
||||
NS_ASSERTION(rect->mRight.GetUnit() == topUnit &&
|
||||
rect->mBottom.GetUnit() == topUnit &&
|
||||
rect->mLeft.GetUnit() == topUnit,
|
||||
"parser should make all sides have the same unit");
|
||||
if (topUnit == eCSSUnit_RectIsAuto)
|
||||
aResult.AppendLiteral("auto");
|
||||
else
|
||||
rect->mTop.AppendToString(aProperty, aResult);
|
||||
} else {
|
||||
aResult.AppendLiteral("rect(");
|
||||
rect->mTop.AppendToString(aProperty, aResult);
|
||||
NS_NAMED_LITERAL_STRING(comma, ", ");
|
||||
aResult.Append(comma);
|
||||
rect->mRight.AppendToString(aProperty, aResult);
|
||||
aResult.Append(comma);
|
||||
rect->mBottom.AppendToString(aProperty, aResult);
|
||||
aResult.Append(comma);
|
||||
rect->mLeft.AppendToString(aProperty, aResult);
|
||||
aResult.Append(PRUnichar(')'));
|
||||
}
|
||||
} break;
|
||||
case eCSSType_ValuePair: {
|
||||
const nsCSSValuePair *pair = static_cast<const nsCSSValuePair*>(aStorage);
|
||||
pair->mXValue.AppendToString(aProperty, aResult);
|
||||
if (pair->mYValue != pair->mXValue ||
|
||||
((aProperty == eCSSProperty_background_position ||
|
||||
aProperty == eCSSProperty__moz_transform_origin) &&
|
||||
pair->mXValue.GetUnit() != eCSSUnit_Inherit &&
|
||||
pair->mXValue.GetUnit() != eCSSUnit_Initial) ||
|
||||
(aProperty == eCSSProperty_background_size &&
|
||||
pair->mXValue.GetUnit() != eCSSUnit_Inherit &&
|
||||
pair->mXValue.GetUnit() != eCSSUnit_Initial &&
|
||||
pair->mXValue.GetUnit() != eCSSUnit_Enumerated)) {
|
||||
// Only output a Y value if it's different from the X value,
|
||||
// or if it's a background-position value other than 'initial'
|
||||
// or 'inherit', or if it's a -moz-transform-origin value other
|
||||
// than 'initial' or 'inherit', or if it's a background-size
|
||||
// value other than 'initial' or 'inherit' or 'contain' or 'cover'.
|
||||
aResult.Append(PRUnichar(' '));
|
||||
pair->mYValue.AppendToString(aProperty, aResult);
|
||||
}
|
||||
} break;
|
||||
case eCSSType_ValueList: {
|
||||
const nsCSSValueList* val =
|
||||
*static_cast<nsCSSValueList*const*>(aStorage);
|
||||
do {
|
||||
val->mValue.AppendToString(aProperty, aResult);
|
||||
val = val->mNext;
|
||||
if (val) {
|
||||
if (nsCSSProps::PropHasFlags(aProperty,
|
||||
CSS_PROPERTY_VALUE_LIST_USES_COMMAS))
|
||||
aResult.Append(PRUnichar(','));
|
||||
aResult.Append(PRUnichar(' '));
|
||||
}
|
||||
} while (val);
|
||||
} break;
|
||||
case eCSSType_ValuePairList: {
|
||||
const nsCSSValuePairList* item =
|
||||
*static_cast<nsCSSValuePairList*const*>(aStorage);
|
||||
do {
|
||||
NS_ASSERTION(item->mXValue.GetUnit() != eCSSUnit_Null,
|
||||
"unexpected null unit");
|
||||
item->mXValue.AppendToString(aProperty, aResult);
|
||||
if (item->mXValue.GetUnit() != eCSSUnit_Inherit &&
|
||||
item->mXValue.GetUnit() != eCSSUnit_Initial &&
|
||||
item->mYValue.GetUnit() != eCSSUnit_Null) {
|
||||
aResult.Append(PRUnichar(' '));
|
||||
item->mYValue.AppendToString(aProperty, aResult);
|
||||
}
|
||||
item = item->mNext;
|
||||
if (item) {
|
||||
if (nsCSSProps::PropHasFlags(aProperty,
|
||||
CSS_PROPERTY_VALUE_LIST_USES_COMMAS))
|
||||
aResult.Append(PRUnichar(','));
|
||||
aResult.Append(PRUnichar(' '));
|
||||
}
|
||||
} while (item);
|
||||
} break;
|
||||
}
|
||||
if (!storage) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
return aStorage != nsnull;
|
||||
|
||||
switch (nsCSSProps::kTypeTable[aProperty]) {
|
||||
case eCSSType_Value:
|
||||
static_cast<const nsCSSValue*>(storage)->
|
||||
AppendToString(aProperty, aResult);
|
||||
break;
|
||||
case eCSSType_Rect:
|
||||
static_cast<const nsCSSRect*>(storage)->
|
||||
AppendToString(aProperty, aResult);
|
||||
break;
|
||||
case eCSSType_ValuePair:
|
||||
static_cast<const nsCSSValuePair*>(storage)->
|
||||
AppendToString(aProperty, aResult);
|
||||
break;
|
||||
case eCSSType_ValueList:
|
||||
(*static_cast<nsCSSValueList*const*>(storage))->
|
||||
AppendToString(aProperty, aResult);
|
||||
break;
|
||||
case eCSSType_ValuePairList:
|
||||
(*static_cast<nsCSSValuePairList*const*>(storage))->
|
||||
AppendToString(aProperty, aResult);
|
||||
break;
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -187,11 +187,6 @@ public:
|
||||
void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
|
||||
#endif
|
||||
|
||||
// return whether there was a value in |aStorage| (i.e., it was non-null)
|
||||
static PRBool AppendStorageToString(nsCSSProperty aProperty,
|
||||
const void* aStorage,
|
||||
nsAString& aResult);
|
||||
|
||||
private:
|
||||
// Not implemented, and not supported.
|
||||
Declaration& operator=(const Declaration& aCopy);
|
||||
|
@ -93,6 +93,22 @@ nsCSSValueList::Clone() const
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
nsCSSValueList::AppendToString(nsCSSProperty aProperty, nsAString& aResult) const
|
||||
{
|
||||
const nsCSSValueList* val = this;
|
||||
for (;;) {
|
||||
val->mValue.AppendToString(aProperty, aResult);
|
||||
val = val->mNext;
|
||||
if (!val)
|
||||
break;
|
||||
|
||||
if (nsCSSProps::PropHasFlags(aProperty, CSS_PROPERTY_VALUE_LIST_USES_COMMAS))
|
||||
aResult.Append(PRUnichar(','));
|
||||
aResult.Append(PRUnichar(' '));
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
nsCSSValueList::operator==(const nsCSSValueList& aOther) const
|
||||
{
|
||||
@ -169,6 +185,35 @@ nsCSSRect::~nsCSSRect()
|
||||
MOZ_COUNT_DTOR(nsCSSRect);
|
||||
}
|
||||
|
||||
void
|
||||
nsCSSRect::AppendToString(nsCSSProperty aProperty, nsAString& aResult) const
|
||||
{
|
||||
const nsCSSUnit topUnit = mTop.GetUnit();
|
||||
if (topUnit == eCSSUnit_Inherit ||
|
||||
topUnit == eCSSUnit_Initial ||
|
||||
topUnit == eCSSUnit_RectIsAuto) {
|
||||
NS_ASSERTION(mRight.GetUnit() == topUnit &&
|
||||
mBottom.GetUnit() == topUnit &&
|
||||
mLeft.GetUnit() == topUnit,
|
||||
"parser should make all sides have the same unit");
|
||||
if (topUnit == eCSSUnit_RectIsAuto)
|
||||
aResult.AppendLiteral("auto");
|
||||
else
|
||||
mTop.AppendToString(aProperty, aResult);
|
||||
} else {
|
||||
aResult.AppendLiteral("rect(");
|
||||
mTop.AppendToString(aProperty, aResult);
|
||||
NS_NAMED_LITERAL_STRING(comma, ", ");
|
||||
aResult.Append(comma);
|
||||
mRight.AppendToString(aProperty, aResult);
|
||||
aResult.Append(comma);
|
||||
mBottom.AppendToString(aProperty, aResult);
|
||||
aResult.Append(comma);
|
||||
mLeft.AppendToString(aProperty, aResult);
|
||||
aResult.Append(PRUnichar(')'));
|
||||
}
|
||||
}
|
||||
|
||||
void nsCSSRect::SetAllSidesTo(const nsCSSValue& aValue)
|
||||
{
|
||||
mTop = aValue;
|
||||
@ -350,7 +395,32 @@ nsCSSPage::~nsCSSPage(void)
|
||||
MOZ_COUNT_DTOR(nsCSSPage);
|
||||
}
|
||||
|
||||
// --- nsCSSContent support -----------------
|
||||
// --- nsCSSValuePair -----------------
|
||||
|
||||
void
|
||||
nsCSSValuePair::AppendToString(nsCSSProperty aProperty, nsAString& aResult) const
|
||||
{
|
||||
mXValue.AppendToString(aProperty, aResult);
|
||||
if (mYValue != mXValue ||
|
||||
((aProperty == eCSSProperty_background_position ||
|
||||
aProperty == eCSSProperty__moz_transform_origin) &&
|
||||
mXValue.GetUnit() != eCSSUnit_Inherit &&
|
||||
mXValue.GetUnit() != eCSSUnit_Initial) ||
|
||||
(aProperty == eCSSProperty_background_size &&
|
||||
mXValue.GetUnit() != eCSSUnit_Inherit &&
|
||||
mXValue.GetUnit() != eCSSUnit_Initial &&
|
||||
mXValue.GetUnit() != eCSSUnit_Enumerated)) {
|
||||
// Only output a Y value if it's different from the X value,
|
||||
// or if it's a background-position value other than 'initial'
|
||||
// or 'inherit', or if it's a -moz-transform-origin value other
|
||||
// than 'initial' or 'inherit', or if it's a background-size
|
||||
// value other than 'initial' or 'inherit' or 'contain' or 'cover'.
|
||||
aResult.Append(PRUnichar(' '));
|
||||
mYValue.AppendToString(aProperty, aResult);
|
||||
}
|
||||
}
|
||||
|
||||
// --- nsCSSValuePairList -----------------
|
||||
|
||||
nsCSSValuePairList::~nsCSSValuePairList()
|
||||
{
|
||||
@ -372,6 +442,31 @@ nsCSSValuePairList::Clone() const
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
nsCSSValuePairList::AppendToString(nsCSSProperty aProperty,
|
||||
nsAString& aResult) const
|
||||
{
|
||||
const nsCSSValuePairList* val = this;
|
||||
for (;;) {
|
||||
NS_ABORT_IF_FALSE(val->mXValue.GetUnit() != eCSSUnit_Null,
|
||||
"unexpected null unit");
|
||||
val->mXValue.AppendToString(aProperty, aResult);
|
||||
if (val->mXValue.GetUnit() != eCSSUnit_Inherit &&
|
||||
val->mXValue.GetUnit() != eCSSUnit_Initial &&
|
||||
val->mYValue.GetUnit() != eCSSUnit_Null) {
|
||||
aResult.Append(PRUnichar(' '));
|
||||
val->mYValue.AppendToString(aProperty, aResult);
|
||||
}
|
||||
val = val->mNext;
|
||||
if (!val)
|
||||
break;
|
||||
|
||||
if (nsCSSProps::PropHasFlags(aProperty, CSS_PROPERTY_VALUE_LIST_USES_COMMAS))
|
||||
aResult.Append(PRUnichar(','));
|
||||
aResult.Append(PRUnichar(' '));
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
nsCSSValuePairList::operator==(const nsCSSValuePairList& aOther) const
|
||||
{
|
||||
|
@ -54,6 +54,7 @@ struct nsCSSValueList {
|
||||
~nsCSSValueList();
|
||||
|
||||
nsCSSValueList* Clone() const; // makes a deep copy
|
||||
void AppendToString(nsCSSProperty aProperty, nsAString& aResult) const;
|
||||
|
||||
bool operator==(nsCSSValueList const& aOther) const; // deep comparison
|
||||
bool operator!=(const nsCSSValueList& aOther) const
|
||||
@ -75,6 +76,8 @@ struct nsCSSRect {
|
||||
nsCSSRect(const nsCSSRect& aCopy);
|
||||
~nsCSSRect();
|
||||
|
||||
void AppendToString(nsCSSProperty aProperty, nsAString& aResult) const;
|
||||
|
||||
PRBool operator==(const nsCSSRect& aOther) const {
|
||||
return mTop == aOther.mTop &&
|
||||
mRight == aOther.mRight &&
|
||||
@ -160,6 +163,8 @@ struct nsCSSValuePair {
|
||||
mYValue.GetUnit() != eCSSUnit_Null;
|
||||
}
|
||||
|
||||
void AppendToString(nsCSSProperty aProperty, nsAString& aResult) const;
|
||||
|
||||
nsCSSValue mXValue;
|
||||
nsCSSValue mYValue;
|
||||
};
|
||||
@ -243,6 +248,7 @@ struct nsCSSValuePairList {
|
||||
~nsCSSValuePairList();
|
||||
|
||||
nsCSSValuePairList* Clone() const; // makes a deep copy
|
||||
void AppendToString(nsCSSProperty aProperty, nsAString& aResult) const;
|
||||
|
||||
bool operator==(const nsCSSValuePairList& aOther) const; // deep comparison
|
||||
bool operator!=(const nsCSSValuePairList& aOther) const
|
||||
|
@ -1872,7 +1872,8 @@ nsStyleAnimation::UncomputeValue(nsCSSProperty aProperty,
|
||||
}
|
||||
nsCSSValuePair vp;
|
||||
nsCSSRect rect;
|
||||
void *ptr = nsnull;
|
||||
nsCSSValueList* vl = nsnull;
|
||||
nsCSSValuePairList* vpl = nsnull;
|
||||
void *storage;
|
||||
switch (nsCSSProps::kTypeTable[aProperty]) {
|
||||
case eCSSType_Value:
|
||||
@ -1885,8 +1886,10 @@ nsStyleAnimation::UncomputeValue(nsCSSProperty aProperty,
|
||||
storage = &vp;
|
||||
break;
|
||||
case eCSSType_ValueList:
|
||||
storage = &vl;
|
||||
break;
|
||||
case eCSSType_ValuePairList:
|
||||
storage = &ptr;
|
||||
storage = &vpl;
|
||||
break;
|
||||
default:
|
||||
NS_ABORT_IF_FALSE(PR_FALSE, "unexpected case");
|
||||
@ -1894,13 +1897,32 @@ nsStyleAnimation::UncomputeValue(nsCSSProperty aProperty,
|
||||
break;
|
||||
}
|
||||
|
||||
nsCSSValue value;
|
||||
if (!nsStyleAnimation::UncomputeValue(aProperty, aPresContext,
|
||||
aComputedValue, storage)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
return css::Declaration::AppendStorageToString(aProperty, storage,
|
||||
aSpecifiedValue);
|
||||
|
||||
switch (nsCSSProps::kTypeTable[aProperty]) {
|
||||
case eCSSType_Value:
|
||||
vp.mXValue.AppendToString(aProperty, aSpecifiedValue);
|
||||
break;
|
||||
case eCSSType_Rect:
|
||||
rect.AppendToString(aProperty, aSpecifiedValue);
|
||||
break;
|
||||
case eCSSType_ValuePair:
|
||||
vp.AppendToString(aProperty, aSpecifiedValue);
|
||||
break;
|
||||
case eCSSType_ValueList:
|
||||
vl->AppendToString(aProperty, aSpecifiedValue);
|
||||
break;
|
||||
case eCSSType_ValuePairList:
|
||||
vpl->AppendToString(aProperty, aSpecifiedValue);
|
||||
break;
|
||||
default:
|
||||
NS_ABORT_IF_FALSE(PR_FALSE, "unexpected case");
|
||||
return PR_FALSE;
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
inline const void*
|
||||
|
Loading…
Reference in New Issue
Block a user