зеркало из https://github.com/mozilla/gecko-dev.git
Serialize border-image shorthand to shortest form, with the exception that we'll always serialize 'border-image-source'. (Bug 713643, patch 1) r=bzbarsky
This commit is contained in:
Родитель
ab5cec5feb
Коммит
2cf7788598
|
@ -264,17 +264,40 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const
|
|||
}
|
||||
break;
|
||||
}
|
||||
case eCSSProperty_border_image:
|
||||
case eCSSProperty_border_image: {
|
||||
// Even though there are some cases where we could omit
|
||||
// 'border-image-source' (when it's none), it's probably not a
|
||||
// good idea since it's likely to be confusing. It would also
|
||||
// require adding the extra check that we serialize *something*.
|
||||
AppendValueToString(eCSSProperty_border_image_source, aValue);
|
||||
aValue.Append(PRUnichar(' '));
|
||||
AppendValueToString(eCSSProperty_border_image_slice, aValue);
|
||||
aValue.Append(NS_LITERAL_STRING(" / "));
|
||||
AppendValueToString(eCSSProperty_border_image_width, aValue);
|
||||
aValue.Append(NS_LITERAL_STRING(" / "));
|
||||
AppendValueToString(eCSSProperty_border_image_outset, aValue);
|
||||
aValue.Append(PRUnichar(' '));
|
||||
AppendValueToString(eCSSProperty_border_image_repeat, aValue);
|
||||
|
||||
bool sliceDefault = data->HasDefaultBorderImageSlice();
|
||||
bool widthDefault = data->HasDefaultBorderImageWidth();
|
||||
bool outsetDefault = data->HasDefaultBorderImageOutset();
|
||||
|
||||
if (!sliceDefault || !widthDefault || !outsetDefault) {
|
||||
aValue.Append(PRUnichar(' '));
|
||||
AppendValueToString(eCSSProperty_border_image_slice, aValue);
|
||||
if (!widthDefault || !outsetDefault) {
|
||||
aValue.Append(NS_LITERAL_STRING(" /"));
|
||||
if (!widthDefault) {
|
||||
aValue.Append(PRUnichar(' '));
|
||||
AppendValueToString(eCSSProperty_border_image_width, aValue);
|
||||
}
|
||||
if (!outsetDefault) {
|
||||
aValue.Append(NS_LITERAL_STRING(" / "));
|
||||
AppendValueToString(eCSSProperty_border_image_outset, aValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool repeatDefault = data->HasDefaultBorderImageRepeat();
|
||||
if (!repeatDefault) {
|
||||
aValue.Append(PRUnichar(' '));
|
||||
AppendValueToString(eCSSProperty_border_image_repeat, aValue);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case eCSSProperty_border: {
|
||||
const nsCSSProperty* subproptables[3] = {
|
||||
nsCSSProps::SubpropertyEntryFor(eCSSProperty_border_color),
|
||||
|
|
|
@ -225,6 +225,41 @@ nsCSSCompressedDataBlock::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) c
|
|||
return n;
|
||||
}
|
||||
|
||||
bool
|
||||
nsCSSCompressedDataBlock::HasDefaultBorderImageSlice() const
|
||||
{
|
||||
const nsCSSValueList *slice =
|
||||
ValueFor(eCSSProperty_border_image_slice)->GetListValue();
|
||||
return !slice->mNext &&
|
||||
slice->mValue.GetRectValue().AllSidesEqualTo(
|
||||
nsCSSValue(1.0f, eCSSUnit_Percent));
|
||||
}
|
||||
|
||||
bool
|
||||
nsCSSCompressedDataBlock::HasDefaultBorderImageWidth() const
|
||||
{
|
||||
const nsCSSRect &width =
|
||||
ValueFor(eCSSProperty_border_image_width)->GetRectValue();
|
||||
return width.AllSidesEqualTo(nsCSSValue(1.0f, eCSSUnit_Number));
|
||||
}
|
||||
|
||||
bool
|
||||
nsCSSCompressedDataBlock::HasDefaultBorderImageOutset() const
|
||||
{
|
||||
const nsCSSRect &outset =
|
||||
ValueFor(eCSSProperty_border_image_outset)->GetRectValue();
|
||||
return outset.AllSidesEqualTo(nsCSSValue(0.0f, eCSSUnit_Number));
|
||||
}
|
||||
|
||||
bool
|
||||
nsCSSCompressedDataBlock::HasDefaultBorderImageRepeat() const
|
||||
{
|
||||
const nsCSSValuePair &repeat =
|
||||
ValueFor(eCSSProperty_border_image_repeat)->GetPairValue();
|
||||
return repeat.BothValuesEqualTo(
|
||||
nsCSSValue(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH, eCSSUnit_Enumerated));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
nsCSSExpandedDataBlock::nsCSSExpandedDataBlock()
|
||||
|
|
|
@ -83,6 +83,11 @@ public:
|
|||
|
||||
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
||||
|
||||
bool HasDefaultBorderImageSlice() const;
|
||||
bool HasDefaultBorderImageWidth() const;
|
||||
bool HasDefaultBorderImageOutset() const;
|
||||
bool HasDefaultBorderImageRepeat() const;
|
||||
|
||||
private:
|
||||
void* operator new(size_t aBaseSize, PRUint32 aNumProps) {
|
||||
NS_ABORT_IF_FALSE(aBaseSize == sizeof(nsCSSCompressedDataBlock),
|
||||
|
|
|
@ -706,6 +706,13 @@ struct nsCSSRect {
|
|||
|
||||
void SetAllSidesTo(const nsCSSValue& aValue);
|
||||
|
||||
bool AllSidesEqualTo(const nsCSSValue& aValue) const {
|
||||
return mTop == aValue &&
|
||||
mRight == aValue &&
|
||||
mBottom == aValue &&
|
||||
mLeft == aValue;
|
||||
}
|
||||
|
||||
void Reset() {
|
||||
mTop.Reset();
|
||||
mRight.Reset();
|
||||
|
@ -790,6 +797,11 @@ struct nsCSSValuePair {
|
|||
mYValue != aOther.mYValue;
|
||||
}
|
||||
|
||||
bool BothValuesEqualTo(const nsCSSValue& aValue) const {
|
||||
return mXValue == aValue &&
|
||||
mYValue == aValue;
|
||||
}
|
||||
|
||||
void SetBothValuesTo(const nsCSSValue& aValue) {
|
||||
mXValue = aValue;
|
||||
mYValue = aValue;
|
||||
|
@ -866,6 +878,12 @@ struct nsCSSValueTriplet {
|
|||
mZValue != aOther.mZValue;
|
||||
}
|
||||
|
||||
bool AllValuesEqualTo(const nsCSSValue& aValue) const {
|
||||
return mXValue == aValue &&
|
||||
mYValue == aValue &&
|
||||
mZValue == aValue;
|
||||
}
|
||||
|
||||
void SetAllValuesTo(const nsCSSValue& aValue) {
|
||||
mXValue = aValue;
|
||||
mYValue = aValue;
|
||||
|
|
Загрузка…
Ссылка в новой задаче