Add and use some convenience functions on nsCSSRect. Bug 208731, r+sr=dbaron

This commit is contained in:
bzbarsky%mit.edu 2004-05-05 00:43:50 +00:00
Родитель c06f7bf9d6
Коммит 9d1ed0ca64
4 изменённых файлов: 44 добавлений и 56 удалений

Просмотреть файл

@ -200,10 +200,7 @@ nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
case eCSSType_Rect: {
const nsCSSRect* val = RectAtCursor(cursor);
NS_ASSERTION(val->mTop.GetUnit() != eCSSUnit_Null ||
val->mRight.GetUnit() != eCSSUnit_Null ||
val->mBottom.GetUnit() != eCSSUnit_Null ||
val->mLeft.GetUnit() != eCSSUnit_Null, "oops");
NS_ASSERTION(val->HasValue(), "oops");
nsCSSRect* target = NS_STATIC_CAST(nsCSSRect*, prop);
if (target->mTop.GetUnit() == eCSSUnit_Null)
target->mTop = val->mTop;
@ -338,10 +335,7 @@ nsCSSCompressedDataBlock::Clone() const
case eCSSType_Rect: {
const nsCSSRect* val = RectAtCursor(cursor);
NS_ASSERTION(val->mTop.GetUnit() != eCSSUnit_Null ||
val->mRight.GetUnit() != eCSSUnit_Null ||
val->mBottom.GetUnit() != eCSSUnit_Null ||
val->mLeft.GetUnit() != eCSSUnit_Null, "oops");
NS_ASSERTION(val->HasValue(), "oops");
nsCSSRect* result_val = RectAtCursor(result_cursor);
new (result_val) nsCSSRect(*val);
cursor += CDBRectStorage_advance;
@ -412,10 +406,7 @@ nsCSSCompressedDataBlock::Destroy()
case eCSSType_Rect: {
const nsCSSRect* val = RectAtCursor(cursor);
NS_ASSERTION(val->mTop.GetUnit() != eCSSUnit_Null ||
val->mRight.GetUnit() != eCSSUnit_Null ||
val->mBottom.GetUnit() != eCSSUnit_Null ||
val->mLeft.GetUnit() != eCSSUnit_Null, "oops");
NS_ASSERTION(val->HasValue(), "oops");
val->~nsCSSRect();
cursor += CDBRectStorage_advance;
} break;
@ -526,10 +517,7 @@ nsCSSExpandedDataBlock::DoExpand(nsCSSCompressedDataBlock *aBlock,
case eCSSType_Rect: {
const nsCSSRect* val = RectAtCursor(cursor);
NS_ASSERTION(val->mTop.GetUnit() != eCSSUnit_Null ||
val->mRight.GetUnit() != eCSSUnit_Null ||
val->mBottom.GetUnit() != eCSSUnit_Null ||
val->mLeft.GetUnit() != eCSSUnit_Null, "oops");
NS_ASSERTION(val->HasValue(), "oops");
memcpy(prop, val, sizeof(nsCSSRect));
cursor += CDBRectStorage_advance;
} break;
@ -591,10 +579,7 @@ nsCSSExpandedDataBlock::ComputeSize()
case eCSSType_Rect: {
nsCSSRect* val = NS_STATIC_CAST(nsCSSRect*, prop);
if (val->mTop.GetUnit() != eCSSUnit_Null ||
val->mRight.GetUnit() != eCSSUnit_Null ||
val->mBottom.GetUnit() != eCSSUnit_Null ||
val->mLeft.GetUnit() != eCSSUnit_Null) {
if (val->HasValue()) {
increment = CDBRectStorage_advance;
}
} break;
@ -686,10 +671,7 @@ nsCSSExpandedDataBlock::Compress(nsCSSCompressedDataBlock **aNormalBlock,
case eCSSType_Rect: {
nsCSSRect* val = NS_STATIC_CAST(nsCSSRect*, prop);
if (val->mTop.GetUnit() != eCSSUnit_Null ||
val->mRight.GetUnit() != eCSSUnit_Null ||
val->mBottom.GetUnit() != eCSSUnit_Null ||
val->mLeft.GetUnit() != eCSSUnit_Null) {
if (val->HasValue()) {
CDBRectStorage *storage =
NS_REINTERPRET_CAST(CDBRectStorage*, cursor);
storage->property = iProp;
@ -774,10 +756,7 @@ nsCSSExpandedDataBlock::ClearProperty(nsCSSProperty aPropID)
case eCSSType_Rect: {
nsCSSRect* val = NS_STATIC_CAST(nsCSSRect*, prop);
val->mTop.Reset();
val->mRight.Reset();
val->mBottom.Reset();
val->mLeft.Reset();
val->Reset();
} break;
case eCSSType_ValueList: {

Просмотреть файл

@ -174,6 +174,21 @@ struct nsCSSRect {
void SetAllSidesTo(const nsCSSValue& aValue);
void Reset() {
mTop.Reset();
mRight.Reset();
mBottom.Reset();
mLeft.Reset();
}
PRBool HasValue() const {
return
mTop.GetUnit() != eCSSUnit_Null ||
mRight.GetUnit() != eCSSUnit_Null ||
mBottom.GetUnit() != eCSSUnit_Null ||
mLeft.GetUnit() != eCSSUnit_Null;
}
nsCSSValue mTop;
nsCSSValue mRight;
nsCSSValue mBottom;

Просмотреть файл

@ -200,10 +200,7 @@ nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
case eCSSType_Rect: {
const nsCSSRect* val = RectAtCursor(cursor);
NS_ASSERTION(val->mTop.GetUnit() != eCSSUnit_Null ||
val->mRight.GetUnit() != eCSSUnit_Null ||
val->mBottom.GetUnit() != eCSSUnit_Null ||
val->mLeft.GetUnit() != eCSSUnit_Null, "oops");
NS_ASSERTION(val->HasValue(), "oops");
nsCSSRect* target = NS_STATIC_CAST(nsCSSRect*, prop);
if (target->mTop.GetUnit() == eCSSUnit_Null)
target->mTop = val->mTop;
@ -338,10 +335,7 @@ nsCSSCompressedDataBlock::Clone() const
case eCSSType_Rect: {
const nsCSSRect* val = RectAtCursor(cursor);
NS_ASSERTION(val->mTop.GetUnit() != eCSSUnit_Null ||
val->mRight.GetUnit() != eCSSUnit_Null ||
val->mBottom.GetUnit() != eCSSUnit_Null ||
val->mLeft.GetUnit() != eCSSUnit_Null, "oops");
NS_ASSERTION(val->HasValue(), "oops");
nsCSSRect* result_val = RectAtCursor(result_cursor);
new (result_val) nsCSSRect(*val);
cursor += CDBRectStorage_advance;
@ -412,10 +406,7 @@ nsCSSCompressedDataBlock::Destroy()
case eCSSType_Rect: {
const nsCSSRect* val = RectAtCursor(cursor);
NS_ASSERTION(val->mTop.GetUnit() != eCSSUnit_Null ||
val->mRight.GetUnit() != eCSSUnit_Null ||
val->mBottom.GetUnit() != eCSSUnit_Null ||
val->mLeft.GetUnit() != eCSSUnit_Null, "oops");
NS_ASSERTION(val->HasValue(), "oops");
val->~nsCSSRect();
cursor += CDBRectStorage_advance;
} break;
@ -526,10 +517,7 @@ nsCSSExpandedDataBlock::DoExpand(nsCSSCompressedDataBlock *aBlock,
case eCSSType_Rect: {
const nsCSSRect* val = RectAtCursor(cursor);
NS_ASSERTION(val->mTop.GetUnit() != eCSSUnit_Null ||
val->mRight.GetUnit() != eCSSUnit_Null ||
val->mBottom.GetUnit() != eCSSUnit_Null ||
val->mLeft.GetUnit() != eCSSUnit_Null, "oops");
NS_ASSERTION(val->HasValue(), "oops");
memcpy(prop, val, sizeof(nsCSSRect));
cursor += CDBRectStorage_advance;
} break;
@ -591,10 +579,7 @@ nsCSSExpandedDataBlock::ComputeSize()
case eCSSType_Rect: {
nsCSSRect* val = NS_STATIC_CAST(nsCSSRect*, prop);
if (val->mTop.GetUnit() != eCSSUnit_Null ||
val->mRight.GetUnit() != eCSSUnit_Null ||
val->mBottom.GetUnit() != eCSSUnit_Null ||
val->mLeft.GetUnit() != eCSSUnit_Null) {
if (val->HasValue()) {
increment = CDBRectStorage_advance;
}
} break;
@ -686,10 +671,7 @@ nsCSSExpandedDataBlock::Compress(nsCSSCompressedDataBlock **aNormalBlock,
case eCSSType_Rect: {
nsCSSRect* val = NS_STATIC_CAST(nsCSSRect*, prop);
if (val->mTop.GetUnit() != eCSSUnit_Null ||
val->mRight.GetUnit() != eCSSUnit_Null ||
val->mBottom.GetUnit() != eCSSUnit_Null ||
val->mLeft.GetUnit() != eCSSUnit_Null) {
if (val->HasValue()) {
CDBRectStorage *storage =
NS_REINTERPRET_CAST(CDBRectStorage*, cursor);
storage->property = iProp;
@ -774,10 +756,7 @@ nsCSSExpandedDataBlock::ClearProperty(nsCSSProperty aPropID)
case eCSSType_Rect: {
nsCSSRect* val = NS_STATIC_CAST(nsCSSRect*, prop);
val->mTop.Reset();
val->mRight.Reset();
val->mBottom.Reset();
val->mLeft.Reset();
val->Reset();
} break;
case eCSSType_ValueList: {

Просмотреть файл

@ -174,6 +174,21 @@ struct nsCSSRect {
void SetAllSidesTo(const nsCSSValue& aValue);
void Reset() {
mTop.Reset();
mRight.Reset();
mBottom.Reset();
mLeft.Reset();
}
PRBool HasValue() const {
return
mTop.GetUnit() != eCSSUnit_Null ||
mRight.GetUnit() != eCSSUnit_Null ||
mBottom.GetUnit() != eCSSUnit_Null ||
mLeft.GetUnit() != eCSSUnit_Null;
}
nsCSSValue mTop;
nsCSSValue mRight;
nsCSSValue mBottom;