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::AddLonghandProperty(nsCSSProperty aProperty, const nsCSSValue& aValue) { NS_ABORT_IF_FALSE(!nsCSSProps::IsShorthand(aProperty), "property out of range"); nsCSSValue& storage = *static_cast<nsCSSValue*>(PropertyAt(aProperty)); storage = aValue; SetPropertyBit(aProperty); }
bool InterfaceRec::look_in_properties(const SString & id) { int32_t i, count = CountProperties(); for (i=0; i<count; i++) { if (PropertyAt(i)->m_id == id) { return true; } } return false; }
status_t InterfaceRec::View() { bout << "ID = " << ID() << endl; bout << "Namespace = " << Namespace() << endl; SVector<SString> rents=Parents(); for (int s=0; s<rents.CountItems(); s++) { if (s=0) { bout << "Parents = " << endl; } bout << " - " << rents.ItemAt(s) << endl; } int32_t num=CountProperties(); bout << "# of Properties = " << num << endl; for (int s=0; s< num; s++) { sptr<IDLNameType> nt=PropertyAt(s); bout << " - " << nt->m_id << endl; } num=CountMethods(); bout << "# of Methods = " << num << endl; for (int s=0; s< num; s++) { sptr<IDLMethod> m=MethodAt(s); bout << " - " << m->ID() << endl; } num=CountEvents(); bout << "# of Events = " << num << endl; for (int s=0; s< CountEvents(); s++) { sptr<IDLEvent> e=EventAt(s); bout << " - " << e->ID() << endl; } return B_OK; }
void nsCSSExpandedDataBlock::ComputeNumProps(uint32_t* aNumPropsNormal, uint32_t* aNumPropsImportant) { *aNumPropsNormal = *aNumPropsImportant = 0; for (size_t iHigh = 0; iHigh < nsCSSPropertySet::kChunkCount; ++iHigh) { if (!mPropertiesSet.HasPropertyInChunk(iHigh)) continue; for (size_t iLow = 0; iLow < nsCSSPropertySet::kBitsInChunk; ++iLow) { if (!mPropertiesSet.HasPropertyAt(iHigh, iLow)) continue; #ifdef DEBUG nsCSSProperty iProp = nsCSSPropertySet::CSSPropertyAt(iHigh, iLow); #endif NS_ABORT_IF_FALSE(!nsCSSProps::IsShorthand(iProp), "out of range"); NS_ABORT_IF_FALSE(PropertyAt(iProp)->GetUnit() != eCSSUnit_Null, "null value while computing size"); if (mPropertiesImportant.HasPropertyAt(iHigh, iLow)) (*aNumPropsImportant)++; else (*aNumPropsNormal)++; } } }
nsCSSExpandedDataBlock::ComputeSizeResult nsCSSExpandedDataBlock::ComputeSize() { ComputeSizeResult result = {0, 0}; for (size_t iHigh = 0; iHigh < nsCSSPropertySet::kChunkCount; ++iHigh) { if (!mPropertiesSet.HasPropertyInChunk(iHigh)) continue; for (size_t iLow = 0; iLow < nsCSSPropertySet::kBitsInChunk; ++iLow) { if (!mPropertiesSet.HasPropertyAt(iHigh, iLow)) continue; #ifdef DEBUG nsCSSProperty iProp = nsCSSPropertySet::CSSPropertyAt(iHigh, iLow); #endif NS_ABORT_IF_FALSE(!nsCSSProps::IsShorthand(iProp), "out of range"); NS_ABORT_IF_FALSE(PropertyAt(iProp)->GetUnit() != eCSSUnit_Null, "null value while computing size"); if (mPropertiesImportant.HasPropertyAt(iHigh, iLow)) result.important += CDBValueStorage_advance; else result.normal += CDBValueStorage_advance; } } return result; }
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; }
void nsCSSExpandedDataBlock::Compress(nsCSSCompressedDataBlock **aNormalBlock, nsCSSCompressedDataBlock **aImportantBlock) { nsAutoPtr<nsCSSCompressedDataBlock> result_normal, result_important; uint32_t i_normal = 0, i_important = 0; uint32_t numPropsNormal, numPropsImportant; ComputeNumProps(&numPropsNormal, &numPropsImportant); result_normal = new(numPropsNormal) nsCSSCompressedDataBlock(numPropsNormal); if (numPropsImportant != 0) { result_important = new(numPropsImportant) nsCSSCompressedDataBlock(numPropsImportant); } else { result_important = nullptr; } /* * Save needless copying and allocation by copying the memory * corresponding to the stored data in the expanded block, and then * clearing the data in the expanded block. */ for (size_t iHigh = 0; iHigh < nsCSSPropertySet::kChunkCount; ++iHigh) { if (!mPropertiesSet.HasPropertyInChunk(iHigh)) continue; for (size_t iLow = 0; iLow < nsCSSPropertySet::kBitsInChunk; ++iLow) { if (!mPropertiesSet.HasPropertyAt(iHigh, iLow)) continue; nsCSSProperty iProp = nsCSSPropertySet::CSSPropertyAt(iHigh, iLow); NS_ABORT_IF_FALSE(!nsCSSProps::IsShorthand(iProp), "out of range"); bool important = mPropertiesImportant.HasPropertyAt(iHigh, iLow); nsCSSCompressedDataBlock *result = important ? result_important : result_normal; uint32_t* ip = important ? &i_important : &i_normal; nsCSSValue* val = PropertyAt(iProp); NS_ABORT_IF_FALSE(val->GetUnit() != eCSSUnit_Null, "Null value while compressing"); result->SetPropertyAtIndex(*ip, iProp); result->RawCopyValueToIndex(*ip, val); new (val) nsCSSValue(); (*ip)++; result->mStyleBits |= nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[iProp]); } } NS_ABORT_IF_FALSE(numPropsNormal == i_normal, "bad numProps"); if (result_important) { NS_ABORT_IF_FALSE(numPropsImportant == i_important, "bad numProps"); } ClearSets(); AssertInitialState(); *aNormalBlock = result_normal.forget(); *aImportantBlock = result_important.forget(); }
void nsCSSExpandedDataBlock::Compress(nsCSSCompressedDataBlock **aNormalBlock, nsCSSCompressedDataBlock **aImportantBlock) { nsAutoPtr<nsCSSCompressedDataBlock> result_normal, result_important; char *cursor_normal, *cursor_important; ComputeSizeResult size = ComputeSize(); result_normal = new(size.normal) nsCSSCompressedDataBlock(); cursor_normal = result_normal->Block(); if (size.important != 0) { result_important = new(size.important) nsCSSCompressedDataBlock(); cursor_important = result_important->Block(); } else { result_important = nsnull; cursor_important = nsnull; } /* * Save needless copying and allocation by copying the memory * corresponding to the stored data in the expanded block, and then * clearing the data in the expanded block. */ for (size_t iHigh = 0; iHigh < nsCSSPropertySet::kChunkCount; ++iHigh) { if (!mPropertiesSet.HasPropertyInChunk(iHigh)) continue; for (size_t iLow = 0; iLow < nsCSSPropertySet::kBitsInChunk; ++iLow) { if (!mPropertiesSet.HasPropertyAt(iHigh, iLow)) continue; nsCSSProperty iProp = nsCSSPropertySet::CSSPropertyAt(iHigh, iLow); NS_ABORT_IF_FALSE(!nsCSSProps::IsShorthand(iProp), "out of range"); bool important = mPropertiesImportant.HasPropertyAt(iHigh, iLow); char *&cursor = important ? cursor_important : cursor_normal; nsCSSCompressedDataBlock *result = important ? result_important : result_normal; nsCSSValue* val = PropertyAt(iProp); NS_ABORT_IF_FALSE(val->GetUnit() != eCSSUnit_Null, "Null value while compressing"); CDBValueStorage *storage = reinterpret_cast<CDBValueStorage*>(cursor); storage->property = iProp; memcpy(&storage->value, val, sizeof(nsCSSValue)); new (val) nsCSSValue(); cursor += CDBValueStorage_advance; result->mStyleBits |= nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[iProp]); } } result_normal->SetBlockEnd(cursor_normal); NS_ABORT_IF_FALSE(result_normal->DataSize() == ptrdiff_t(size.normal), "size miscalculation"); if (result_important) { result_important->SetBlockEnd(cursor_important); NS_ABORT_IF_FALSE(result_important->DataSize() == ptrdiff_t(size.important), "size miscalculation"); } ClearSets(); AssertInitialState(); *aNormalBlock = result_normal.forget(); *aImportantBlock = result_important.forget(); }