void nsCSSExpandedDataBlock::DoExpand(nsCSSCompressedDataBlock *aBlock, bool aImportant) { /* * Save needless copying and allocation by copying the memory * corresponding to the stored data in the compressed block. */ for (uint32_t i = 0; i < aBlock->mNumProps; i++) { nsCSSProperty iProp = aBlock->PropertyAtIndex(i); NS_ABORT_IF_FALSE(!nsCSSProps::IsShorthand(iProp), "out of range"); NS_ABORT_IF_FALSE(!HasPropertyBit(iProp), "compressed block has property multiple times"); SetPropertyBit(iProp); if (aImportant) SetImportantBit(iProp); const nsCSSValue* val = aBlock->ValueAtIndex(i); nsCSSValue* dest = PropertyAt(iProp); NS_ABORT_IF_FALSE(val->GetUnit() != eCSSUnit_Null, "oops"); NS_ABORT_IF_FALSE(dest->GetUnit() == eCSSUnit_Null, "expanding into non-empty block"); #ifdef NS_BUILD_REFCNT_LOGGING dest->~nsCSSValue(); #endif memcpy(dest, val, sizeof(nsCSSValue)); } // Set the number of properties to zero so that we don't destroy the // remnants of what we just copied. aBlock->SetNumPropsToZero(); delete aBlock; }
void nsCSSExpandedDataBlock::DoExpand(nsCSSCompressedDataBlock *aBlock, bool aImportant) { /* * Save needless copying and allocation by copying the memory * corresponding to the stored data in the compressed block. */ const char* cursor = aBlock->Block(); const char* cursor_end = aBlock->BlockEnd(); while (cursor < cursor_end) { nsCSSProperty iProp = PropertyAtCursor(cursor); NS_ABORT_IF_FALSE(!nsCSSProps::IsShorthand(iProp), "out of range"); NS_ABORT_IF_FALSE(!HasPropertyBit(iProp), "compressed block has property multiple times"); SetPropertyBit(iProp); if (aImportant) SetImportantBit(iProp); const nsCSSValue* val = ValueAtCursor(cursor); nsCSSValue* dest = PropertyAt(iProp); NS_ABORT_IF_FALSE(val->GetUnit() != eCSSUnit_Null, "oops"); NS_ABORT_IF_FALSE(dest->GetUnit() == eCSSUnit_Null, "expanding into non-empty block"); #ifdef NS_BUILD_REFCNT_LOGGING dest->~nsCSSValue(); #endif memcpy(dest, val, sizeof(nsCSSValue)); cursor += CDBValueStorage_advance; } NS_ABORT_IF_FALSE(cursor == cursor_end, "inconsistent data"); // Don't destroy remnants of what we just copied aBlock->SetBlockEnd(aBlock->Block()); delete aBlock; }