Bug 1238403 - Fix inconsistent indenting in layout/style/. r=xidorn

This commit is contained in:
Cameron McCormack 2016-01-11 10:28:35 +11:00
parent ba6aa5e879
commit e24a87cf9c
10 changed files with 1401 additions and 1345 deletions

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -283,7 +284,8 @@ AppendCSSShadowValue(const nsCSSShadowItem *aShadow,
// Like nsStyleCoord::CalcValue, but with length in float pixels instead
// of nscoord.
struct PixelCalcValue {
struct PixelCalcValue
{
float mLength, mPercent;
bool mHasPercent;
};
@ -3858,11 +3860,11 @@ void
StyleAnimationValue::SetAndAdoptCSSValueTripletValue(
nsCSSValueTriplet *aValueTriplet, Unit aUnit)
{
FreeValue();
MOZ_ASSERT(IsCSSValueTripletUnit(aUnit), "bad unit");
MOZ_ASSERT(aValueTriplet != nullptr, "value pairs may not be null");
mUnit = aUnit;
mValue.mCSSValueTriplet = aValueTriplet; // take ownership
FreeValue();
MOZ_ASSERT(IsCSSValueTripletUnit(aUnit), "bad unit");
MOZ_ASSERT(aValueTriplet != nullptr, "value pairs may not be null");
mUnit = aUnit;
mValue.mCSSValueTriplet = aValueTriplet; // take ownership
}
void

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -33,11 +34,11 @@ using namespace mozilla::css;
static bool
MoveValue(nsCSSValue* aSource, nsCSSValue* aDest)
{
bool changed = (*aSource != *aDest);
aDest->~nsCSSValue();
memcpy(aDest, aSource, sizeof(nsCSSValue));
new (aSource) nsCSSValue();
return changed;
bool changed = (*aSource != *aDest);
aDest->~nsCSSValue();
memcpy(aDest, aSource, sizeof(nsCSSValue));
new (aSource) nsCSSValue();
return changed;
}
/**
@ -87,9 +88,9 @@ ConvertBoxOrientToFlexDirection(const nsCSSValue* aBoxOrientVal,
static bool
ShouldIgnoreColors(nsRuleData *aRuleData)
{
return aRuleData->mLevel != SheetType::Agent &&
aRuleData->mLevel != SheetType::User &&
!aRuleData->mPresContext->UseDocumentColors();
return aRuleData->mLevel != SheetType::Agent &&
aRuleData->mLevel != SheetType::User &&
!aRuleData->mPresContext->UseDocumentColors();
}
/**
@ -175,61 +176,61 @@ MapSinglePropertyInto(nsCSSProperty aSrcProp,
nsCSSValue* aTargetValue,
nsRuleData* aRuleData)
{
MOZ_ASSERT(!nsCSSProps::PropHasFlags(aTargetProp, CSS_PROPERTY_LOGICAL),
"Can't map into a logical property");
MOZ_ASSERT(aSrcProp == aTargetProp ||
nsCSSProps::PropHasFlags(aSrcProp, CSS_PROPERTY_LOGICAL),
"Source & target property must be the same, except when we're "
"doing a logical-to-physical property mapping");
MOZ_ASSERT(aSrcValue->GetUnit() != eCSSUnit_Null, "oops");
MOZ_ASSERT(!nsCSSProps::PropHasFlags(aTargetProp, CSS_PROPERTY_LOGICAL),
"Can't map into a logical property");
MOZ_ASSERT(aSrcProp == aTargetProp ||
nsCSSProps::PropHasFlags(aSrcProp, CSS_PROPERTY_LOGICAL),
"Source & target property must be the same, except when we're "
"doing a logical-to-physical property mapping");
MOZ_ASSERT(aSrcValue->GetUnit() != eCSSUnit_Null, "oops");
// Handle logical properties that have custom value-mapping behavior:
Maybe<nsCSSValue> convertedVal; // storage for converted value, if needed
bool hasCustomValMapping =
nsCSSProps::PropHasFlags(aSrcProp,
CSS_PROPERTY_LOGICAL_SINGLE_CUSTOM_VALMAPPING);
if (hasCustomValMapping) {
if (aSrcProp == eCSSProperty_webkit_box_orient) {
aSrcValue = ConvertBoxOrientToFlexDirection(aSrcValue, aRuleData,
convertedVal);
}
// Handle logical properties that have custom value-mapping behavior:
Maybe<nsCSSValue> convertedVal; // storage for converted value, if needed
bool hasCustomValMapping =
nsCSSProps::PropHasFlags(aSrcProp,
CSS_PROPERTY_LOGICAL_SINGLE_CUSTOM_VALMAPPING);
if (hasCustomValMapping) {
if (aSrcProp == eCSSProperty_webkit_box_orient) {
aSrcValue = ConvertBoxOrientToFlexDirection(aSrcValue, aRuleData,
convertedVal);
}
}
// Although aTargetValue is the nsCSSValue we are going to write into,
// we also look at its value before writing into it. This is done
// when aTargetValue is a token stream value, which is the case when we
// have just re-parsed a property that had a variable reference (in
// nsCSSParser::ParsePropertyWithVariableReferences). TryToStartImageLoad
// then records any resulting ImageValue objects in the
// CSSVariableImageTable, to give them the appropriate lifetime.
MOZ_ASSERT(aTargetValue->GetUnit() == eCSSUnit_TokenStream ||
aTargetValue->GetUnit() == eCSSUnit_Null,
"aTargetValue must only be a token stream (when re-parsing "
"properties with variable references) or null");
// Although aTargetValue is the nsCSSValue we are going to write into,
// we also look at its value before writing into it. This is done
// when aTargetValue is a token stream value, which is the case when we
// have just re-parsed a property that had a variable reference (in
// nsCSSParser::ParsePropertyWithVariableReferences). TryToStartImageLoad
// then records any resulting ImageValue objects in the
// CSSVariableImageTable, to give them the appropriate lifetime.
MOZ_ASSERT(aTargetValue->GetUnit() == eCSSUnit_TokenStream ||
aTargetValue->GetUnit() == eCSSUnit_Null,
"aTargetValue must only be a token stream (when re-parsing "
"properties with variable references) or null");
if (ShouldStartImageLoads(aRuleData, aTargetProp)) {
nsIDocument* doc = aRuleData->mPresContext->Document();
TryToStartImageLoad(*aSrcValue, doc, aRuleData->mStyleContext,
aTargetProp,
aTargetValue->GetUnit() == eCSSUnit_TokenStream);
}
*aTargetValue = *aSrcValue;
if (nsCSSProps::PropHasFlags(aTargetProp,
CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED) &&
ShouldIgnoreColors(aRuleData))
{
if (aTargetProp == eCSSProperty_background_color) {
// Force non-'transparent' background
// colors to the user's default.
if (aTargetValue->IsNonTransparentColor()) {
aTargetValue->SetColorValue(aRuleData->mPresContext->
DefaultBackgroundColor());
}
} else {
// Ignore 'color', 'border-*-color', etc.
*aTargetValue = nsCSSValue();
}
if (ShouldStartImageLoads(aRuleData, aTargetProp)) {
nsIDocument* doc = aRuleData->mPresContext->Document();
TryToStartImageLoad(*aSrcValue, doc, aRuleData->mStyleContext,
aTargetProp,
aTargetValue->GetUnit() == eCSSUnit_TokenStream);
}
*aTargetValue = *aSrcValue;
if (nsCSSProps::PropHasFlags(aTargetProp,
CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED) &&
ShouldIgnoreColors(aRuleData))
{
if (aTargetProp == eCSSProperty_background_color) {
// Force non-'transparent' background
// colors to the user's default.
if (aTargetValue->IsNonTransparentColor()) {
aTargetValue->SetColorValue(aRuleData->mPresContext->
DefaultBackgroundColor());
}
} else {
// Ignore 'color', 'border-*-color', etc.
*aTargetValue = nsCSSValue();
}
}
}
/**
@ -312,69 +313,69 @@ EnsurePhysicalProperty(nsCSSProperty aProperty, nsRuleData* aRuleData)
void
nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
{
// If we have no data for these structs, then return immediately.
// This optimization should make us return most of the time, so we
// have to worry much less (although still some) about the speed of
// the rest of the function.
if (!(aRuleData->mSIDs & mStyleBits))
return;
// If we have no data for these structs, then return immediately.
// This optimization should make us return most of the time, so we
// have to worry much less (although still some) about the speed of
// the rest of the function.
if (!(aRuleData->mSIDs & mStyleBits))
return;
// We process these in reverse order so that we end up mapping the
// right property when one can be expressed using both logical and
// physical property names.
for (uint32_t i = mNumProps; i-- > 0; ) {
nsCSSProperty iProp = PropertyAtIndex(i);
if (nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[iProp]) &
aRuleData->mSIDs) {
nsCSSProperty physicalProp = EnsurePhysicalProperty(iProp,
aRuleData);
if (physicalProp != iProp) {
// We can't cache anything on the rule tree if we use any data from
// the style context, since data cached in the rule tree could be
// used with a style context with a different value.
uint8_t wm = WritingMode(aRuleData->mStyleContext).GetBits();
aRuleData->mConditions.SetWritingModeDependency(wm);
}
nsCSSValue* target = aRuleData->ValueFor(physicalProp);
if (target->GetUnit() == eCSSUnit_Null) {
const nsCSSValue *val = ValueAtIndex(i);
// In order for variable resolution to have the right information
// about the stylesheet level of a value, that level needs to be
// stored on the token stream. We can't do that at creation time
// because the CSS parser (which creates the object) has no idea
// about the stylesheet level, so we do it here instead, where
// the rule walking will have just updated aRuleData.
if (val->GetUnit() == eCSSUnit_TokenStream) {
val->GetTokenStreamValue()->mLevel = aRuleData->mLevel;
}
MapSinglePropertyInto(iProp, val, physicalProp, target,
aRuleData);
}
// We process these in reverse order so that we end up mapping the
// right property when one can be expressed using both logical and
// physical property names.
for (uint32_t i = mNumProps; i-- > 0; ) {
nsCSSProperty iProp = PropertyAtIndex(i);
if (nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[iProp]) &
aRuleData->mSIDs) {
nsCSSProperty physicalProp = EnsurePhysicalProperty(iProp,
aRuleData);
if (physicalProp != iProp) {
// We can't cache anything on the rule tree if we use any data from
// the style context, since data cached in the rule tree could be
// used with a style context with a different value.
uint8_t wm = WritingMode(aRuleData->mStyleContext).GetBits();
aRuleData->mConditions.SetWritingModeDependency(wm);
}
nsCSSValue* target = aRuleData->ValueFor(physicalProp);
if (target->GetUnit() == eCSSUnit_Null) {
const nsCSSValue *val = ValueAtIndex(i);
// In order for variable resolution to have the right information
// about the stylesheet level of a value, that level needs to be
// stored on the token stream. We can't do that at creation time
// because the CSS parser (which creates the object) has no idea
// about the stylesheet level, so we do it here instead, where
// the rule walking will have just updated aRuleData.
if (val->GetUnit() == eCSSUnit_TokenStream) {
val->GetTokenStreamValue()->mLevel = aRuleData->mLevel;
}
MapSinglePropertyInto(iProp, val, physicalProp, target,
aRuleData);
}
}
}
}
const nsCSSValue*
nsCSSCompressedDataBlock::ValueFor(nsCSSProperty aProperty) const
{
MOZ_ASSERT(!nsCSSProps::IsShorthand(aProperty),
"Don't call for shorthands");
// If we have no data for this struct, then return immediately.
// This optimization should make us return most of the time, so we
// have to worry much less (although still some) about the speed of
// the rest of the function.
if (!(nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[aProperty]) &
mStyleBits))
return nullptr;
for (uint32_t i = 0; i < mNumProps; i++) {
if (PropertyAtIndex(i) == aProperty) {
return ValueAtIndex(i);
}
}
MOZ_ASSERT(!nsCSSProps::IsShorthand(aProperty),
"Don't call for shorthands");
// If we have no data for this struct, then return immediately.
// This optimization should make us return most of the time, so we
// have to worry much less (although still some) about the speed of
// the rest of the function.
if (!(nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[aProperty]) &
mStyleBits))
return nullptr;
for (uint32_t i = 0; i < mNumProps; i++) {
if (PropertyAtIndex(i) == aProperty) {
return ValueAtIndex(i);
}
}
return nullptr;
}
bool
@ -382,64 +383,64 @@ nsCSSCompressedDataBlock::TryReplaceValue(nsCSSProperty aProperty,
nsCSSExpandedDataBlock& aFromBlock,
bool *aChanged)
{
nsCSSValue* newValue = aFromBlock.PropertyAt(aProperty);
MOZ_ASSERT(newValue && newValue->GetUnit() != eCSSUnit_Null,
"cannot replace with empty value");
nsCSSValue* newValue = aFromBlock.PropertyAt(aProperty);
MOZ_ASSERT(newValue && newValue->GetUnit() != eCSSUnit_Null,
"cannot replace with empty value");
const nsCSSValue* oldValue = ValueFor(aProperty);
if (!oldValue) {
*aChanged = false;
return false;
}
const nsCSSValue* oldValue = ValueFor(aProperty);
if (!oldValue) {
*aChanged = false;
return false;
}
*aChanged = MoveValue(newValue, const_cast<nsCSSValue*>(oldValue));
aFromBlock.ClearPropertyBit(aProperty);
return true;
*aChanged = MoveValue(newValue, const_cast<nsCSSValue*>(oldValue));
aFromBlock.ClearPropertyBit(aProperty);
return true;
}
nsCSSCompressedDataBlock*
nsCSSCompressedDataBlock::Clone() const
{
nsAutoPtr<nsCSSCompressedDataBlock>
result(new(mNumProps) nsCSSCompressedDataBlock(mNumProps));
nsAutoPtr<nsCSSCompressedDataBlock>
result(new(mNumProps) nsCSSCompressedDataBlock(mNumProps));
result->mStyleBits = mStyleBits;
result->mStyleBits = mStyleBits;
for (uint32_t i = 0; i < mNumProps; i++) {
result->SetPropertyAtIndex(i, PropertyAtIndex(i));
result->CopyValueToIndex(i, ValueAtIndex(i));
}
for (uint32_t i = 0; i < mNumProps; i++) {
result->SetPropertyAtIndex(i, PropertyAtIndex(i));
result->CopyValueToIndex(i, ValueAtIndex(i));
}
return result.forget();
return result.forget();
}
nsCSSCompressedDataBlock::~nsCSSCompressedDataBlock()
{
for (uint32_t i = 0; i < mNumProps; i++) {
for (uint32_t i = 0; i < mNumProps; i++) {
#ifdef DEBUG
(void)PropertyAtIndex(i); // this checks the property is in range
(void)PropertyAtIndex(i); // this checks the property is in range
#endif
const nsCSSValue* val = ValueAtIndex(i);
MOZ_ASSERT(val->GetUnit() != eCSSUnit_Null, "oops");
val->~nsCSSValue();
}
const nsCSSValue* val = ValueAtIndex(i);
MOZ_ASSERT(val->GetUnit() != eCSSUnit_Null, "oops");
val->~nsCSSValue();
}
}
/* static */ nsCSSCompressedDataBlock*
nsCSSCompressedDataBlock::CreateEmptyBlock()
{
nsCSSCompressedDataBlock *result = new(0) nsCSSCompressedDataBlock(0);
return result;
nsCSSCompressedDataBlock *result = new(0) nsCSSCompressedDataBlock(0);
return result;
}
size_t
nsCSSCompressedDataBlock::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
size_t n = aMallocSizeOf(this);
for (uint32_t i = 0; i < mNumProps; i++) {
n += ValueAtIndex(i)->SizeOfExcludingThis(aMallocSizeOf);
}
return n;
size_t n = aMallocSizeOf(this);
for (uint32_t i = 0; i < mNumProps; i++) {
n += ValueAtIndex(i)->SizeOfExcludingThis(aMallocSizeOf);
}
return n;
}
bool
@ -481,84 +482,84 @@ nsCSSCompressedDataBlock::HasDefaultBorderImageRepeat() const
nsCSSExpandedDataBlock::nsCSSExpandedDataBlock()
{
AssertInitialState();
AssertInitialState();
}
nsCSSExpandedDataBlock::~nsCSSExpandedDataBlock()
{
AssertInitialState();
AssertInitialState();
}
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);
MOZ_ASSERT(!nsCSSProps::IsShorthand(iProp), "out of range");
MOZ_ASSERT(!HasPropertyBit(iProp),
"compressed block has property multiple times");
SetPropertyBit(iProp);
if (aImportant)
SetImportantBit(iProp);
/*
* 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);
MOZ_ASSERT(!nsCSSProps::IsShorthand(iProp), "out of range");
MOZ_ASSERT(!HasPropertyBit(iProp),
"compressed block has property multiple times");
SetPropertyBit(iProp);
if (aImportant)
SetImportantBit(iProp);
const nsCSSValue* val = aBlock->ValueAtIndex(i);
nsCSSValue* dest = PropertyAt(iProp);
MOZ_ASSERT(val->GetUnit() != eCSSUnit_Null, "oops");
MOZ_ASSERT(dest->GetUnit() == eCSSUnit_Null,
"expanding into non-empty block");
const nsCSSValue* val = aBlock->ValueAtIndex(i);
nsCSSValue* dest = PropertyAt(iProp);
MOZ_ASSERT(val->GetUnit() != eCSSUnit_Null, "oops");
MOZ_ASSERT(dest->GetUnit() == eCSSUnit_Null,
"expanding into non-empty block");
#ifdef NS_BUILD_REFCNT_LOGGING
dest->~nsCSSValue();
dest->~nsCSSValue();
#endif
memcpy(dest, val, sizeof(nsCSSValue));
}
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;
// 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::Expand(nsCSSCompressedDataBlock *aNormalBlock,
nsCSSCompressedDataBlock *aImportantBlock)
{
MOZ_ASSERT(aNormalBlock, "unexpected null block");
AssertInitialState();
MOZ_ASSERT(aNormalBlock, "unexpected null block");
AssertInitialState();
DoExpand(aNormalBlock, false);
if (aImportantBlock) {
DoExpand(aImportantBlock, true);
}
DoExpand(aNormalBlock, false);
if (aImportantBlock) {
DoExpand(aImportantBlock, true);
}
}
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;
*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);
nsCSSProperty iProp = nsCSSPropertySet::CSSPropertyAt(iHigh, iLow);
#endif
MOZ_ASSERT(!nsCSSProps::IsShorthand(iProp), "out of range");
MOZ_ASSERT(PropertyAt(iProp)->GetUnit() != eCSSUnit_Null,
"null value while computing size");
if (mPropertiesImportant.HasPropertyAt(iHigh, iLow))
(*aNumPropsImportant)++;
else
(*aNumPropsNormal)++;
}
MOZ_ASSERT(!nsCSSProps::IsShorthand(iProp), "out of range");
MOZ_ASSERT(PropertyAt(iProp)->GetUnit() != eCSSUnit_Null,
"null value while computing size");
if (mPropertiesImportant.HasPropertyAt(iHigh, iLow))
(*aNumPropsImportant)++;
else
(*aNumPropsNormal)++;
}
}
}
void
@ -566,110 +567,110 @@ nsCSSExpandedDataBlock::Compress(nsCSSCompressedDataBlock **aNormalBlock,
nsCSSCompressedDataBlock **aImportantBlock,
const nsTArray<uint32_t>& aOrder)
{
nsAutoPtr<nsCSSCompressedDataBlock> result_normal, result_important;
uint32_t i_normal = 0, i_important = 0;
nsAutoPtr<nsCSSCompressedDataBlock> result_normal, result_important;
uint32_t i_normal = 0, i_important = 0;
uint32_t numPropsNormal, numPropsImportant;
ComputeNumProps(&numPropsNormal, &numPropsImportant);
uint32_t numPropsNormal, numPropsImportant;
ComputeNumProps(&numPropsNormal, &numPropsImportant);
result_normal =
new(numPropsNormal) nsCSSCompressedDataBlock(numPropsNormal);
result_normal =
new(numPropsNormal) nsCSSCompressedDataBlock(numPropsNormal);
if (numPropsImportant != 0) {
result_important =
new(numPropsImportant) nsCSSCompressedDataBlock(numPropsImportant);
} else {
result_important = nullptr;
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 i = 0; i < aOrder.Length(); i++) {
nsCSSProperty iProp = static_cast<nsCSSProperty>(aOrder[i]);
if (iProp >= eCSSProperty_COUNT) {
// a custom property
continue;
}
MOZ_ASSERT(mPropertiesSet.HasProperty(iProp),
"aOrder identifies a property not in the expanded "
"data block");
MOZ_ASSERT(!nsCSSProps::IsShorthand(iProp), "out of range");
bool important = mPropertiesImportant.HasProperty(iProp);
nsCSSCompressedDataBlock *result =
important ? result_important : result_normal;
uint32_t* ip = important ? &i_important : &i_normal;
nsCSSValue* val = PropertyAt(iProp);
MOZ_ASSERT(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]);
}
/*
* 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 i = 0; i < aOrder.Length(); i++) {
nsCSSProperty iProp = static_cast<nsCSSProperty>(aOrder[i]);
if (iProp >= eCSSProperty_COUNT) {
// a custom property
continue;
}
MOZ_ASSERT(mPropertiesSet.HasProperty(iProp),
"aOrder identifies a property not in the expanded "
"data block");
MOZ_ASSERT(!nsCSSProps::IsShorthand(iProp), "out of range");
bool important = mPropertiesImportant.HasProperty(iProp);
nsCSSCompressedDataBlock *result =
important ? result_important : result_normal;
uint32_t* ip = important ? &i_important : &i_normal;
nsCSSValue* val = PropertyAt(iProp);
MOZ_ASSERT(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]);
}
MOZ_ASSERT(numPropsNormal == i_normal, "bad numProps");
MOZ_ASSERT(numPropsNormal == i_normal, "bad numProps");
if (result_important) {
MOZ_ASSERT(numPropsImportant == i_important, "bad numProps");
}
if (result_important) {
MOZ_ASSERT(numPropsImportant == i_important, "bad numProps");
}
#ifdef DEBUG
{
// assert that we didn't have any other properties on this expanded data
// block that we didn't find in aOrder
uint32_t numPropsInSet = 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)) {
numPropsInSet++;
}
}
{
// assert that we didn't have any other properties on this expanded data
// block that we didn't find in aOrder
uint32_t numPropsInSet = 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)) {
numPropsInSet++;
}
}
MOZ_ASSERT(numPropsNormal + numPropsImportant == numPropsInSet,
"aOrder missing properties from the expanded data block");
}
MOZ_ASSERT(numPropsNormal + numPropsImportant == numPropsInSet,
"aOrder missing properties from the expanded data block");
}
#endif
ClearSets();
AssertInitialState();
*aNormalBlock = result_normal.forget();
*aImportantBlock = result_important.forget();
ClearSets();
AssertInitialState();
*aNormalBlock = result_normal.forget();
*aImportantBlock = result_important.forget();
}
void
nsCSSExpandedDataBlock::AddLonghandProperty(nsCSSProperty aProperty,
const nsCSSValue& aValue)
{
MOZ_ASSERT(!nsCSSProps::IsShorthand(aProperty),
"property out of range");
nsCSSValue& storage = *static_cast<nsCSSValue*>(PropertyAt(aProperty));
storage = aValue;
SetPropertyBit(aProperty);
MOZ_ASSERT(!nsCSSProps::IsShorthand(aProperty),
"property out of range");
nsCSSValue& storage = *static_cast<nsCSSValue*>(PropertyAt(aProperty));
storage = aValue;
SetPropertyBit(aProperty);
}
void
nsCSSExpandedDataBlock::Clear()
{
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);
ClearLonghandProperty(iProp);
}
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);
ClearLonghandProperty(iProp);
}
}
AssertInitialState();
AssertInitialState();
}
void
@ -688,11 +689,11 @@ nsCSSExpandedDataBlock::ClearProperty(nsCSSProperty aPropID)
void
nsCSSExpandedDataBlock::ClearLonghandProperty(nsCSSProperty aPropID)
{
MOZ_ASSERT(!nsCSSProps::IsShorthand(aPropID), "out of range");
MOZ_ASSERT(!nsCSSProps::IsShorthand(aPropID), "out of range");
ClearPropertyBit(aPropID);
ClearImportantBit(aPropID);
PropertyAt(aPropID)->Reset();
ClearPropertyBit(aPropID);
ClearImportantBit(aPropID);
PropertyAt(aPropID)->Reset();
}
bool
@ -705,26 +706,26 @@ nsCSSExpandedDataBlock::TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
css::Declaration* aDeclaration,
nsIDocument* aSheetDocument)
{
if (!nsCSSProps::IsShorthand(aPropID)) {
return DoTransferFromBlock(aFromBlock, aPropID,
if (!nsCSSProps::IsShorthand(aPropID)) {
return DoTransferFromBlock(aFromBlock, aPropID,
aIsImportant, aOverrideImportant,
aMustCallValueAppended, aDeclaration,
aSheetDocument);
}
// We can pass eIgnoreEnabledState (here, and in ClearProperty above) rather
// than a value corresponding to whether we're parsing a UA style sheet or
// certified app because we assert in nsCSSProps::AddRefTable that shorthand
// properties available in these contexts also have all of their
// subproperties available in these contexts.
bool changed = false;
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aPropID, aEnabledState) {
changed |= DoTransferFromBlock(aFromBlock, *p,
aIsImportant, aOverrideImportant,
aMustCallValueAppended, aDeclaration,
aSheetDocument);
}
// We can pass eIgnoreEnabledState (here, and in ClearProperty above) rather
// than a value corresponding to whether we're parsing a UA style sheet or
// certified app because we assert in nsCSSProps::AddRefTable that shorthand
// properties available in these contexts also have all of their
// subproperties available in these contexts.
bool changed = false;
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aPropID, aEnabledState) {
changed |= DoTransferFromBlock(aFromBlock, *p,
aIsImportant, aOverrideImportant,
aMustCallValueAppended, aDeclaration,
aSheetDocument);
}
return changed;
}
return changed;
}
bool
@ -809,13 +810,13 @@ nsCSSExpandedDataBlock::MapRuleInfoInto(nsCSSProperty aPropID,
void
nsCSSExpandedDataBlock::DoAssertInitialState()
{
mPropertiesSet.AssertIsEmpty("not initial state");
mPropertiesImportant.AssertIsEmpty("not initial state");
mPropertiesSet.AssertIsEmpty("not initial state");
mPropertiesImportant.AssertIsEmpty("not initial state");
for (uint32_t i = 0; i < eCSSProperty_COUNT_no_shorthands; ++i) {
nsCSSProperty prop = nsCSSProperty(i);
MOZ_ASSERT(PropertyAt(prop)->GetUnit() == eCSSUnit_Null,
"not initial state");
}
for (uint32_t i = 0; i < eCSSProperty_COUNT_no_shorthands; ++i) {
nsCSSProperty prop = nsCSSProperty(i);
MOZ_ASSERT(PropertyAt(prop)->GetUnit() == eCSSUnit_Null,
"not initial state");
}
}
#endif

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -34,137 +35,138 @@ class Declaration;
* |css::Declaration|). Mutation is accomplished through
* |nsCSSExpandedDataBlock| or in some cases via direct slot access.
*/
class nsCSSCompressedDataBlock {
class nsCSSCompressedDataBlock
{
private:
friend class nsCSSExpandedDataBlock;
friend class nsCSSExpandedDataBlock;
// Only this class (via |CreateEmptyBlock|) or nsCSSExpandedDataBlock
// (in |Compress|) can create compressed data blocks.
explicit nsCSSCompressedDataBlock(uint32_t aNumProps)
: mStyleBits(0), mNumProps(aNumProps)
{}
// Only this class (via |CreateEmptyBlock|) or nsCSSExpandedDataBlock
// (in |Compress|) can create compressed data blocks.
explicit nsCSSCompressedDataBlock(uint32_t aNumProps)
: mStyleBits(0), mNumProps(aNumProps)
{}
public:
~nsCSSCompressedDataBlock();
~nsCSSCompressedDataBlock();
/**
* Do what |nsIStyleRule::MapRuleInfoInto| needs to do for a style
* rule using this block for storage.
*/
void MapRuleInfoInto(nsRuleData *aRuleData) const;
/**
* Do what |nsIStyleRule::MapRuleInfoInto| needs to do for a style
* rule using this block for storage.
*/
void MapRuleInfoInto(nsRuleData *aRuleData) const;
/**
* Return the location at which the *value* for the property is
* stored, or null if the block does not contain a value for the
* property.
*
* Inefficient (by design).
*
* Must not be called for shorthands.
*/
const nsCSSValue* ValueFor(nsCSSProperty aProperty) const;
/**
* Return the location at which the *value* for the property is
* stored, or null if the block does not contain a value for the
* property.
*
* Inefficient (by design).
*
* Must not be called for shorthands.
*/
const nsCSSValue* ValueFor(nsCSSProperty aProperty) const;
/**
* Attempt to replace the value for |aProperty| stored in this block
* with the matching value stored in |aFromBlock|.
* This method will fail (returning false) if |aProperty| is not
* already in this block. It will set |aChanged| to true if it
* actually made a change to the block, but regardless, if it
* returns true, the value in |aFromBlock| was erased.
*/
bool TryReplaceValue(nsCSSProperty aProperty,
nsCSSExpandedDataBlock& aFromBlock,
bool* aChanged);
/**
* Attempt to replace the value for |aProperty| stored in this block
* with the matching value stored in |aFromBlock|.
* This method will fail (returning false) if |aProperty| is not
* already in this block. It will set |aChanged| to true if it
* actually made a change to the block, but regardless, if it
* returns true, the value in |aFromBlock| was erased.
*/
bool TryReplaceValue(nsCSSProperty aProperty,
nsCSSExpandedDataBlock& aFromBlock,
bool* aChanged);
/**
* Clone this block, or return null on out-of-memory.
*/
nsCSSCompressedDataBlock* Clone() const;
/**
* Clone this block, or return null on out-of-memory.
*/
nsCSSCompressedDataBlock* Clone() const;
/**
* Create a new nsCSSCompressedDataBlock holding no declarations.
*/
static nsCSSCompressedDataBlock* CreateEmptyBlock();
/**
* Create a new nsCSSCompressedDataBlock holding no declarations.
*/
static nsCSSCompressedDataBlock* CreateEmptyBlock();
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
bool HasDefaultBorderImageSlice() const;
bool HasDefaultBorderImageWidth() const;
bool HasDefaultBorderImageOutset() const;
bool HasDefaultBorderImageRepeat() const;
bool HasDefaultBorderImageSlice() const;
bool HasDefaultBorderImageWidth() const;
bool HasDefaultBorderImageOutset() const;
bool HasDefaultBorderImageRepeat() const;
bool HasInheritedStyleData() const
{
return mStyleBits & NS_STYLE_INHERITED_STRUCT_MASK;
}
bool HasInheritedStyleData() const
{
return mStyleBits & NS_STYLE_INHERITED_STRUCT_MASK;
}
private:
void* operator new(size_t aBaseSize, uint32_t aNumProps) {
MOZ_ASSERT(aBaseSize == sizeof(nsCSSCompressedDataBlock),
"unexpected size for nsCSSCompressedDataBlock");
return ::operator new(aBaseSize + DataSize(aNumProps));
}
void* operator new(size_t aBaseSize, uint32_t aNumProps) {
MOZ_ASSERT(aBaseSize == sizeof(nsCSSCompressedDataBlock),
"unexpected size for nsCSSCompressedDataBlock");
return ::operator new(aBaseSize + DataSize(aNumProps));
}
public:
// Ideally, |nsCSSProperty| would be |enum nsCSSProperty : int16_t|. But
// not all of the compilers we use are modern enough to support small
// enums. So we manually squeeze nsCSSProperty into 16 bits ourselves.
// The static assertion below ensures it fits.
typedef int16_t CompressedCSSProperty;
static const size_t MaxCompressedCSSProperty = INT16_MAX;
// Ideally, |nsCSSProperty| would be |enum nsCSSProperty : int16_t|. But
// not all of the compilers we use are modern enough to support small
// enums. So we manually squeeze nsCSSProperty into 16 bits ourselves.
// The static assertion below ensures it fits.
typedef int16_t CompressedCSSProperty;
static const size_t MaxCompressedCSSProperty = INT16_MAX;
private:
static size_t DataSize(uint32_t aNumProps) {
return size_t(aNumProps) *
(sizeof(nsCSSValue) + sizeof(CompressedCSSProperty));
}
static size_t DataSize(uint32_t aNumProps) {
return size_t(aNumProps) *
(sizeof(nsCSSValue) + sizeof(CompressedCSSProperty));
}
int32_t mStyleBits; // the structs for which we have data, according to
// |nsCachedStyleData::GetBitForSID|.
uint32_t mNumProps;
// nsCSSValue elements are stored after these fields, and
// nsCSSProperty elements are stored -- each one compressed as a
// CompressedCSSProperty -- after the nsCSSValue elements. Space for them
// is allocated in |operator new| above. The static assertions following
// this class make sure that the value and property elements are aligned
// appropriately.
int32_t mStyleBits; // the structs for which we have data, according to
// |nsCachedStyleData::GetBitForSID|.
uint32_t mNumProps;
// nsCSSValue elements are stored after these fields, and
// nsCSSProperty elements are stored -- each one compressed as a
// CompressedCSSProperty -- after the nsCSSValue elements. Space for them
// is allocated in |operator new| above. The static assertions following
// this class make sure that the value and property elements are aligned
// appropriately.
nsCSSValue* Values() const {
return (nsCSSValue*)(this + 1);
}
nsCSSValue* Values() const {
return (nsCSSValue*)(this + 1);
}
CompressedCSSProperty* CompressedProperties() const {
return (CompressedCSSProperty*)(Values() + mNumProps);
}
CompressedCSSProperty* CompressedProperties() const {
return (CompressedCSSProperty*)(Values() + mNumProps);
}
nsCSSValue* ValueAtIndex(uint32_t i) const {
MOZ_ASSERT(i < mNumProps, "value index out of range");
return Values() + i;
}
nsCSSValue* ValueAtIndex(uint32_t i) const {
MOZ_ASSERT(i < mNumProps, "value index out of range");
return Values() + i;
}
nsCSSProperty PropertyAtIndex(uint32_t i) const {
MOZ_ASSERT(i < mNumProps, "property index out of range");
nsCSSProperty prop = (nsCSSProperty)CompressedProperties()[i];
MOZ_ASSERT(!nsCSSProps::IsShorthand(prop), "out of range");
return prop;
}
nsCSSProperty PropertyAtIndex(uint32_t i) const {
MOZ_ASSERT(i < mNumProps, "property index out of range");
nsCSSProperty prop = (nsCSSProperty)CompressedProperties()[i];
MOZ_ASSERT(!nsCSSProps::IsShorthand(prop), "out of range");
return prop;
}
void CopyValueToIndex(uint32_t i, nsCSSValue* aValue) {
new (ValueAtIndex(i)) nsCSSValue(*aValue);
}
void CopyValueToIndex(uint32_t i, nsCSSValue* aValue) {
new (ValueAtIndex(i)) nsCSSValue(*aValue);
}
void RawCopyValueToIndex(uint32_t i, nsCSSValue* aValue) {
memcpy(ValueAtIndex(i), aValue, sizeof(nsCSSValue));
}
void RawCopyValueToIndex(uint32_t i, nsCSSValue* aValue) {
memcpy(ValueAtIndex(i), aValue, sizeof(nsCSSValue));
}
void SetPropertyAtIndex(uint32_t i, nsCSSProperty aProperty) {
MOZ_ASSERT(i < mNumProps, "set property index out of range");
CompressedProperties()[i] = (CompressedCSSProperty)aProperty;
}
void SetPropertyAtIndex(uint32_t i, nsCSSProperty aProperty) {
MOZ_ASSERT(i < mNumProps, "set property index out of range");
CompressedProperties()[i] = (CompressedCSSProperty)aProperty;
}
void SetNumPropsToZero() {
mNumProps = 0;
}
void SetNumPropsToZero() {
mNumProps = 0;
}
};
// Make sure the values and properties are aligned appropriately. (These
@ -172,198 +174,199 @@ private:
static_assert(sizeof(nsCSSCompressedDataBlock) == 8,
"nsCSSCompressedDataBlock's size has changed");
static_assert(NS_ALIGNMENT_OF(nsCSSValue) == 4 || NS_ALIGNMENT_OF(nsCSSValue) == 8,
"nsCSSValue doesn't align with nsCSSCompressedDataBlock");
"nsCSSValue doesn't align with nsCSSCompressedDataBlock");
static_assert(NS_ALIGNMENT_OF(nsCSSCompressedDataBlock::CompressedCSSProperty) == 2,
"CompressedCSSProperty doesn't align with nsCSSValue");
"CompressedCSSProperty doesn't align with nsCSSValue");
// Make sure that sizeof(CompressedCSSProperty) is big enough.
static_assert(eCSSProperty_COUNT_no_shorthands <=
nsCSSCompressedDataBlock::MaxCompressedCSSProperty,
"nsCSSProperty doesn't fit in StoredSizeOfCSSProperty");
class nsCSSExpandedDataBlock {
friend class nsCSSCompressedDataBlock;
class nsCSSExpandedDataBlock
{
friend class nsCSSCompressedDataBlock;
public:
nsCSSExpandedDataBlock();
~nsCSSExpandedDataBlock();
nsCSSExpandedDataBlock();
~nsCSSExpandedDataBlock();
private:
/* Property storage may not be accessed directly; use AddLonghandProperty
* and friends.
*/
nsCSSValue mValues[eCSSProperty_COUNT_no_shorthands];
/* Property storage may not be accessed directly; use AddLonghandProperty
* and friends.
*/
nsCSSValue mValues[eCSSProperty_COUNT_no_shorthands];
public:
/**
* Transfer all of the state from a pair of compressed data blocks
* to this expanded block. This expanded block must be clear
* beforehand.
*
* This method DELETES both of the compressed data blocks it is
* passed. (This is necessary because ownership of sub-objects
* is transferred to the expanded block.)
*/
void Expand(nsCSSCompressedDataBlock *aNormalBlock,
nsCSSCompressedDataBlock *aImportantBlock);
/**
* Transfer all of the state from a pair of compressed data blocks
* to this expanded block. This expanded block must be clear
* beforehand.
*
* This method DELETES both of the compressed data blocks it is
* passed. (This is necessary because ownership of sub-objects
* is transferred to the expanded block.)
*/
void Expand(nsCSSCompressedDataBlock *aNormalBlock,
nsCSSCompressedDataBlock *aImportantBlock);
/**
* Allocate new compressed blocks and transfer all of the state
* from this expanded block to the new blocks, clearing this
* expanded block. A normal block will always be allocated, but
* an important block will only be allocated if there are
* !important properties in the expanded block; otherwise
* |*aImportantBlock| will be set to null.
*
* aOrder is an array of nsCSSProperty values specifying the order
* to store values in the two data blocks.
*/
void Compress(nsCSSCompressedDataBlock **aNormalBlock,
nsCSSCompressedDataBlock **aImportantBlock,
const nsTArray<uint32_t>& aOrder);
/**
* Allocate new compressed blocks and transfer all of the state
* from this expanded block to the new blocks, clearing this
* expanded block. A normal block will always be allocated, but
* an important block will only be allocated if there are
* !important properties in the expanded block; otherwise
* |*aImportantBlock| will be set to null.
*
* aOrder is an array of nsCSSProperty values specifying the order
* to store values in the two data blocks.
*/
void Compress(nsCSSCompressedDataBlock **aNormalBlock,
nsCSSCompressedDataBlock **aImportantBlock,
const nsTArray<uint32_t>& aOrder);
/**
* Copy a value into this expanded block. This does NOT destroy
* the source value object. |aProperty| cannot be a shorthand.
*/
void AddLonghandProperty(nsCSSProperty aProperty, const nsCSSValue& aValue);
/**
* Copy a value into this expanded block. This does NOT destroy
* the source value object. |aProperty| cannot be a shorthand.
*/
void AddLonghandProperty(nsCSSProperty aProperty, const nsCSSValue& aValue);
/**
* Clear the state of this expanded block.
*/
void Clear();
/**
* Clear the state of this expanded block.
*/
void Clear();
/**
* Clear the data for the given property (including the set and
* important bits). Can be used with shorthand properties.
*/
void ClearProperty(nsCSSProperty aPropID);
/**
* Clear the data for the given property (including the set and
* important bits). Can be used with shorthand properties.
*/
void ClearProperty(nsCSSProperty aPropID);
/**
* Same as ClearProperty, but faster and cannot be used with shorthands.
*/
void ClearLonghandProperty(nsCSSProperty aPropID);
/**
* Same as ClearProperty, but faster and cannot be used with shorthands.
*/
void ClearLonghandProperty(nsCSSProperty aPropID);
/**
* Transfer the state for |aPropID| (which may be a shorthand)
* from |aFromBlock| to this block. The property being transferred
* is !important if |aIsImportant| is true, and should replace an
* existing !important property regardless of its own importance
* if |aOverrideImportant| is true. |aEnabledState| is used to
* determine which longhand components of |aPropID| (if it is a
* shorthand) to transfer.
*
* Returns true if something changed, false otherwise. Calls
* |ValueAppended| on |aDeclaration| if the property was not
* previously set, or in any case if |aMustCallValueAppended| is true.
* Calls |SetDocumentAndPageUseCounter| on |aSheetDocument| if it is
* non-null and |aPropID| has a use counter.
*/
bool TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
nsCSSProperty aPropID,
nsCSSProps::EnabledState aEnabledState,
bool aIsImportant,
bool aOverrideImportant,
bool aMustCallValueAppended,
mozilla::css::Declaration* aDeclaration,
nsIDocument* aSheetDocument);
/**
* Transfer the state for |aPropID| (which may be a shorthand)
* from |aFromBlock| to this block. The property being transferred
* is !important if |aIsImportant| is true, and should replace an
* existing !important property regardless of its own importance
* if |aOverrideImportant| is true. |aEnabledState| is used to
* determine which longhand components of |aPropID| (if it is a
* shorthand) to transfer.
*
* Returns true if something changed, false otherwise. Calls
* |ValueAppended| on |aDeclaration| if the property was not
* previously set, or in any case if |aMustCallValueAppended| is true.
* Calls |SetDocumentAndPageUseCounter| on |aSheetDocument| if it is
* non-null and |aPropID| has a use counter.
*/
bool TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
nsCSSProperty aPropID,
nsCSSProps::EnabledState aEnabledState,
bool aIsImportant,
bool aOverrideImportant,
bool aMustCallValueAppended,
mozilla::css::Declaration* aDeclaration,
nsIDocument* aSheetDocument);
/**
* Copies the values for aPropID into the specified aRuleData object.
*
* This is used for copying parsed-at-computed-value-time properties
* that had variable references. aPropID must be a longhand property.
*/
void MapRuleInfoInto(nsCSSProperty aPropID, nsRuleData* aRuleData) const;
/**
* Copies the values for aPropID into the specified aRuleData object.
*
* This is used for copying parsed-at-computed-value-time properties
* that had variable references. aPropID must be a longhand property.
*/
void MapRuleInfoInto(nsCSSProperty aPropID, nsRuleData* aRuleData) const;
void AssertInitialState() {
void AssertInitialState() {
#ifdef DEBUG
DoAssertInitialState();
DoAssertInitialState();
#endif
}
}
private:
/**
* Compute the number of properties that will be present in the
* result of |Compress|.
*/
void ComputeNumProps(uint32_t* aNumPropsNormal,
uint32_t* aNumPropsImportant);
void DoExpand(nsCSSCompressedDataBlock *aBlock, bool aImportant);
/**
* Compute the number of properties that will be present in the
* result of |Compress|.
*/
void ComputeNumProps(uint32_t* aNumPropsNormal,
uint32_t* aNumPropsImportant);
/**
* Worker for TransferFromBlock; cannot be used with shorthands.
*/
bool DoTransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
nsCSSProperty aPropID,
bool aIsImportant,
bool aOverrideImportant,
bool aMustCallValueAppended,
mozilla::css::Declaration* aDeclaration,
nsIDocument* aSheetDocument);
void DoExpand(nsCSSCompressedDataBlock *aBlock, bool aImportant);
/**
* Worker for TransferFromBlock; cannot be used with shorthands.
*/
bool DoTransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
nsCSSProperty aPropID,
bool aIsImportant,
bool aOverrideImportant,
bool aMustCallValueAppended,
mozilla::css::Declaration* aDeclaration,
nsIDocument* aSheetDocument);
#ifdef DEBUG
void DoAssertInitialState();
void DoAssertInitialState();
#endif
/*
* mPropertiesSet stores a bit for every property that is present,
* to optimize compression of blocks with small numbers of
* properties (the norm) and to allow quickly checking whether a
* property is set in this block.
*/
nsCSSPropertySet mPropertiesSet;
/*
* mPropertiesImportant indicates which properties are '!important'.
*/
nsCSSPropertySet mPropertiesImportant;
/*
* mPropertiesSet stores a bit for every property that is present,
* to optimize compression of blocks with small numbers of
* properties (the norm) and to allow quickly checking whether a
* property is set in this block.
*/
nsCSSPropertySet mPropertiesSet;
/*
* mPropertiesImportant indicates which properties are '!important'.
*/
nsCSSPropertySet mPropertiesImportant;
/*
* Return the storage location within |this| of the value of the
* property |aProperty|.
*/
nsCSSValue* PropertyAt(nsCSSProperty aProperty) {
MOZ_ASSERT(0 <= aProperty &&
aProperty < eCSSProperty_COUNT_no_shorthands,
"property out of range");
return &mValues[aProperty];
}
const nsCSSValue* PropertyAt(nsCSSProperty aProperty) const {
MOZ_ASSERT(0 <= aProperty &&
aProperty < eCSSProperty_COUNT_no_shorthands,
"property out of range");
return &mValues[aProperty];
}
/*
* Return the storage location within |this| of the value of the
* property |aProperty|.
*/
nsCSSValue* PropertyAt(nsCSSProperty aProperty) {
MOZ_ASSERT(0 <= aProperty &&
aProperty < eCSSProperty_COUNT_no_shorthands,
"property out of range");
return &mValues[aProperty];
}
const nsCSSValue* PropertyAt(nsCSSProperty aProperty) const {
MOZ_ASSERT(0 <= aProperty &&
aProperty < eCSSProperty_COUNT_no_shorthands,
"property out of range");
return &mValues[aProperty];
}
void SetPropertyBit(nsCSSProperty aProperty) {
mPropertiesSet.AddProperty(aProperty);
}
void SetPropertyBit(nsCSSProperty aProperty) {
mPropertiesSet.AddProperty(aProperty);
}
void ClearPropertyBit(nsCSSProperty aProperty) {
mPropertiesSet.RemoveProperty(aProperty);
}
void ClearPropertyBit(nsCSSProperty aProperty) {
mPropertiesSet.RemoveProperty(aProperty);
}
bool HasPropertyBit(nsCSSProperty aProperty) {
return mPropertiesSet.HasProperty(aProperty);
}
bool HasPropertyBit(nsCSSProperty aProperty) {
return mPropertiesSet.HasProperty(aProperty);
}
void SetImportantBit(nsCSSProperty aProperty) {
mPropertiesImportant.AddProperty(aProperty);
}
void SetImportantBit(nsCSSProperty aProperty) {
mPropertiesImportant.AddProperty(aProperty);
}
void ClearImportantBit(nsCSSProperty aProperty) {
mPropertiesImportant.RemoveProperty(aProperty);
}
void ClearImportantBit(nsCSSProperty aProperty) {
mPropertiesImportant.RemoveProperty(aProperty);
}
bool HasImportantBit(nsCSSProperty aProperty) {
return mPropertiesImportant.HasProperty(aProperty);
}
bool HasImportantBit(nsCSSProperty aProperty) {
return mPropertiesImportant.HasProperty(aProperty);
}
void ClearSets() {
mPropertiesSet.Empty();
mPropertiesImportant.Empty();
}
void ClearSets() {
mPropertiesSet.Empty();
mPropertiesImportant.Empty();
}
};
#endif /* !defined(nsCSSDataBlock_h__) */

View File

@ -542,48 +542,48 @@ void nsCSSValue::SetPairValue(const nsCSSValue& xValue,
void nsCSSValue::SetTripletValue(const nsCSSValueTriplet* aValue)
{
// triplet should not be used for null/inherit/initial values
MOZ_ASSERT(aValue &&
aValue->mXValue.GetUnit() != eCSSUnit_Null &&
aValue->mYValue.GetUnit() != eCSSUnit_Null &&
aValue->mZValue.GetUnit() != eCSSUnit_Null &&
aValue->mXValue.GetUnit() != eCSSUnit_Inherit &&
aValue->mYValue.GetUnit() != eCSSUnit_Inherit &&
aValue->mZValue.GetUnit() != eCSSUnit_Inherit &&
aValue->mXValue.GetUnit() != eCSSUnit_Initial &&
aValue->mYValue.GetUnit() != eCSSUnit_Initial &&
aValue->mZValue.GetUnit() != eCSSUnit_Initial &&
aValue->mXValue.GetUnit() != eCSSUnit_Unset &&
aValue->mYValue.GetUnit() != eCSSUnit_Unset &&
aValue->mZValue.GetUnit() != eCSSUnit_Unset,
"missing or inappropriate triplet value");
Reset();
mUnit = eCSSUnit_Triplet;
mValue.mTriplet = new nsCSSValueTriplet_heap(aValue->mXValue, aValue->mYValue, aValue->mZValue);
mValue.mTriplet->AddRef();
// triplet should not be used for null/inherit/initial values
MOZ_ASSERT(aValue &&
aValue->mXValue.GetUnit() != eCSSUnit_Null &&
aValue->mYValue.GetUnit() != eCSSUnit_Null &&
aValue->mZValue.GetUnit() != eCSSUnit_Null &&
aValue->mXValue.GetUnit() != eCSSUnit_Inherit &&
aValue->mYValue.GetUnit() != eCSSUnit_Inherit &&
aValue->mZValue.GetUnit() != eCSSUnit_Inherit &&
aValue->mXValue.GetUnit() != eCSSUnit_Initial &&
aValue->mYValue.GetUnit() != eCSSUnit_Initial &&
aValue->mZValue.GetUnit() != eCSSUnit_Initial &&
aValue->mXValue.GetUnit() != eCSSUnit_Unset &&
aValue->mYValue.GetUnit() != eCSSUnit_Unset &&
aValue->mZValue.GetUnit() != eCSSUnit_Unset,
"missing or inappropriate triplet value");
Reset();
mUnit = eCSSUnit_Triplet;
mValue.mTriplet = new nsCSSValueTriplet_heap(aValue->mXValue, aValue->mYValue, aValue->mZValue);
mValue.mTriplet->AddRef();
}
void nsCSSValue::SetTripletValue(const nsCSSValue& xValue,
const nsCSSValue& yValue,
const nsCSSValue& zValue)
{
// Only allow Null for the z component
MOZ_ASSERT(xValue.GetUnit() != eCSSUnit_Null &&
yValue.GetUnit() != eCSSUnit_Null &&
xValue.GetUnit() != eCSSUnit_Inherit &&
yValue.GetUnit() != eCSSUnit_Inherit &&
zValue.GetUnit() != eCSSUnit_Inherit &&
xValue.GetUnit() != eCSSUnit_Initial &&
yValue.GetUnit() != eCSSUnit_Initial &&
zValue.GetUnit() != eCSSUnit_Initial &&
xValue.GetUnit() != eCSSUnit_Unset &&
yValue.GetUnit() != eCSSUnit_Unset &&
zValue.GetUnit() != eCSSUnit_Unset,
"inappropriate triplet value");
Reset();
mUnit = eCSSUnit_Triplet;
mValue.mTriplet = new nsCSSValueTriplet_heap(xValue, yValue, zValue);
mValue.mTriplet->AddRef();
// Only allow Null for the z component
MOZ_ASSERT(xValue.GetUnit() != eCSSUnit_Null &&
yValue.GetUnit() != eCSSUnit_Null &&
xValue.GetUnit() != eCSSUnit_Inherit &&
yValue.GetUnit() != eCSSUnit_Inherit &&
zValue.GetUnit() != eCSSUnit_Inherit &&
xValue.GetUnit() != eCSSUnit_Initial &&
yValue.GetUnit() != eCSSUnit_Initial &&
zValue.GetUnit() != eCSSUnit_Initial &&
xValue.GetUnit() != eCSSUnit_Unset &&
yValue.GetUnit() != eCSSUnit_Unset &&
zValue.GetUnit() != eCSSUnit_Unset,
"inappropriate triplet value");
Reset();
mUnit = eCSSUnit_Triplet;
mValue.mTriplet = new nsCSSValueTriplet_heap(xValue, yValue, zValue);
mValue.mTriplet->AddRef();
}
nsCSSRect& nsCSSValue::SetRectValue()
@ -1975,9 +1975,9 @@ nsCSSValueList::Clone() const
void
nsCSSValueList::CloneInto(nsCSSValueList* aList) const
{
NS_ASSERTION(!aList->mNext, "Must be an empty list!");
aList->mValue = mValue;
aList->mNext = mNext ? mNext->Clone() : nullptr;
NS_ASSERTION(!aList->mNext, "Must be an empty list!");
aList->mValue = mValue;
aList->mNext = mNext ? mNext->Clone() : nullptr;
}
static void
@ -2304,15 +2304,15 @@ nsCSSValueTriplet::AppendToString(nsCSSProperty aProperty,
nsAString& aResult,
nsCSSValue::Serialization aSerialization) const
{
mXValue.AppendToString(aProperty, aResult, aSerialization);
if (mYValue.GetUnit() != eCSSUnit_Null) {
aResult.Append(char16_t(' '));
mYValue.AppendToString(aProperty, aResult, aSerialization);
if (mZValue.GetUnit() != eCSSUnit_Null) {
aResult.Append(char16_t(' '));
mZValue.AppendToString(aProperty, aResult, aSerialization);
}
mXValue.AppendToString(aProperty, aResult, aSerialization);
if (mYValue.GetUnit() != eCSSUnit_Null) {
aResult.Append(char16_t(' '));
mYValue.AppendToString(aProperty, aResult, aSerialization);
if (mZValue.GetUnit() != eCSSUnit_Null) {
aResult.Append(char16_t(' '));
mZValue.AppendToString(aProperty, aResult, aSerialization);
}
}
}
size_t

View File

@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set tw=78 expandtab softtabstop=2 ts=2 sw=2: */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -1278,29 +1278,29 @@ nsComputedDOMStyle::DoGetPerspectiveOrigin()
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetPerspective()
{
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
SetValueToCoord(val, StyleDisplay()->mChildPerspective, false);
return val.forget();
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
SetValueToCoord(val, StyleDisplay()->mChildPerspective, false);
return val.forget();
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetBackfaceVisibility()
{
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetIdent(
nsCSSProps::ValueToKeywordEnum(StyleDisplay()->mBackfaceVisibility,
nsCSSProps::kBackfaceVisibilityKTable));
return val.forget();
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetIdent(
nsCSSProps::ValueToKeywordEnum(StyleDisplay()->mBackfaceVisibility,
nsCSSProps::kBackfaceVisibilityKTable));
return val.forget();
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetTransformStyle()
{
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetIdent(
nsCSSProps::ValueToKeywordEnum(StyleDisplay()->mTransformStyle,
nsCSSProps::kTransformStyleKTable));
return val.forget();
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetIdent(
nsCSSProps::ValueToKeywordEnum(StyleDisplay()->mTransformStyle,
nsCSSProps::kTransformStyleKTable));
return val.forget();
}
/* If the property is "none", hand back "none" wrapped in a value.

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,5 @@
/* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -20,64 +21,66 @@ typedef nsresult
const nsMediaFeature* aFeature,
nsCSSValue& aResult);
struct nsMediaFeature {
nsIAtom **mName; // extra indirection to point to nsGkAtoms members
struct nsMediaFeature
{
nsIAtom **mName; // extra indirection to point to nsGkAtoms members
enum RangeType { eMinMaxAllowed, eMinMaxNotAllowed };
RangeType mRangeType;
enum RangeType { eMinMaxAllowed, eMinMaxNotAllowed };
RangeType mRangeType;
enum ValueType {
// All value types allow eCSSUnit_Null to indicate that no value
// was given (in addition to the types listed below).
eLength, // values are such that nsCSSValue::IsLengthUnit() is true
eInteger, // values are eCSSUnit_Integer
eFloat, // values are eCSSUnit_Number
eBoolInteger,// values are eCSSUnit_Integer (0, -0, or 1 only)
eIntRatio, // values are eCSSUnit_Array of two eCSSUnit_Integer
eResolution, // values are in eCSSUnit_Inch (for dpi),
// eCSSUnit_Pixel (for dppx), or
// eCSSUnit_Centimeter (for dpcm)
eEnumerated, // values are eCSSUnit_Enumerated (uses keyword table)
eIdent // values are eCSSUnit_Ident
// Note that a number of pieces of code (both for parsing and
// for matching of valueless expressions) assume that all numeric
// value types cannot be negative. The parsing code also does
// not allow zeros in eIntRatio types.
};
ValueType mValueType;
enum ValueType {
// All value types allow eCSSUnit_Null to indicate that no value
// was given (in addition to the types listed below).
eLength, // values are such that nsCSSValue::IsLengthUnit() is true
eInteger, // values are eCSSUnit_Integer
eFloat, // values are eCSSUnit_Number
eBoolInteger,// values are eCSSUnit_Integer (0, -0, or 1 only)
eIntRatio, // values are eCSSUnit_Array of two eCSSUnit_Integer
eResolution, // values are in eCSSUnit_Inch (for dpi),
// eCSSUnit_Pixel (for dppx), or
// eCSSUnit_Centimeter (for dpcm)
eEnumerated, // values are eCSSUnit_Enumerated (uses keyword table)
eIdent // values are eCSSUnit_Ident
// Note that a number of pieces of code (both for parsing and
// for matching of valueless expressions) assume that all numeric
// value types cannot be negative. The parsing code also does
// not allow zeros in eIntRatio types.
};
ValueType mValueType;
enum RequirementFlags : uint8_t {
// Bitfield of requirements that must be satisfied in order for this
// media feature to be active.
eNoRequirements = 0,
eHasWebkitPrefix = 1 // Feature name must start w/ "-webkit-", even
// before any "min-"/"max-" qualifier.
};
uint8_t mReqFlags;
enum RequirementFlags : uint8_t {
// Bitfield of requirements that must be satisfied in order for this
// media feature to be active.
eNoRequirements = 0,
eHasWebkitPrefix = 1 // Feature name must start w/ "-webkit-", even
// before any "min-"/"max-" qualifier.
};
uint8_t mReqFlags;
union {
// In static arrays, it's the first member that's initialized. We
// need that to be void* so we can initialize both other types.
// This member should never be accessed by name.
const void* mInitializer_;
// If mValueType == eEnumerated: const int32_t*: keyword table in
// the same format as the keyword tables in nsCSSProps.
const nsCSSProps::KTableEntry* mKeywordTable;
// If mGetter == GetSystemMetric (which implies mValueType ==
// eBoolInteger): nsIAtom * const *, for the system metric.
nsIAtom * const * mMetric;
} mData;
union {
// In static arrays, it's the first member that's initialized. We
// need that to be void* so we can initialize both other types.
// This member should never be accessed by name.
const void* mInitializer_;
// If mValueType == eEnumerated: const int32_t*: keyword table in
// the same format as the keyword tables in nsCSSProps.
const nsCSSProps::KTableEntry* mKeywordTable;
// If mGetter == GetSystemMetric (which implies mValueType ==
// eBoolInteger): nsIAtom * const *, for the system metric.
nsIAtom * const * mMetric;
} mData;
// A function that returns the current value for this feature for a
// given presentation. If it returns eCSSUnit_Null, the feature is
// not present.
nsMediaFeatureValueGetter mGetter;
// A function that returns the current value for this feature for a
// given presentation. If it returns eCSSUnit_Null, the feature is
// not present.
nsMediaFeatureValueGetter mGetter;
};
class nsMediaFeatures {
class nsMediaFeatures
{
public:
// Terminated with an entry whose mName is null.
static const nsMediaFeature features[];
// Terminated with an entry whose mName is null.
static const nsMediaFeature features[];
};
#endif /* !defined(nsMediaFeatures_h_) */

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -526,9 +527,9 @@ nsROCSSPrimitiveValue::GetRGBColorValue(ErrorResult& aRv)
void
nsROCSSPrimitiveValue::SetNumber(float aValue)
{
Reset();
mValue.mFloat = aValue;
mType = CSS_NUMBER;
Reset();
mValue.mFloat = aValue;
mType = CSS_NUMBER;
}
void

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -820,44 +821,43 @@ nsChangeHint nsStyleColumn::CalcDifference(const nsStyleColumn& aOther) const
// --------------------
// nsStyleSVG
//
nsStyleSVG::nsStyleSVG()
nsStyleSVG::nsStyleSVG()
{
MOZ_COUNT_CTOR(nsStyleSVG);
mFill.mType = eStyleSVGPaintType_Color;
mFill.mPaint.mColor = NS_RGB(0,0,0);
mFill.mFallbackColor = NS_RGB(0,0,0);
mStroke.mType = eStyleSVGPaintType_None;
mStroke.mPaint.mColor = NS_RGB(0,0,0);
mStroke.mFallbackColor = NS_RGB(0,0,0);
mStrokeDasharray = nullptr;
MOZ_COUNT_CTOR(nsStyleSVG);
mFill.mType = eStyleSVGPaintType_Color;
mFill.mPaint.mColor = NS_RGB(0,0,0);
mFill.mFallbackColor = NS_RGB(0,0,0);
mStroke.mType = eStyleSVGPaintType_None;
mStroke.mPaint.mColor = NS_RGB(0,0,0);
mStroke.mFallbackColor = NS_RGB(0,0,0);
mStrokeDasharray = nullptr;
mStrokeDashoffset.SetCoordValue(0);
mStrokeWidth.SetCoordValue(nsPresContext::CSSPixelsToAppUnits(1));
mStrokeDashoffset.SetCoordValue(0);
mStrokeWidth.SetCoordValue(nsPresContext::CSSPixelsToAppUnits(1));
mFillOpacity = 1.0f;
mStrokeMiterlimit = 4.0f;
mStrokeOpacity = 1.0f;
mFillOpacity = 1.0f;
mStrokeMiterlimit = 4.0f;
mStrokeOpacity = 1.0f;
mStrokeDasharrayLength = 0;
mClipRule = NS_STYLE_FILL_RULE_NONZERO;
mColorInterpolation = NS_STYLE_COLOR_INTERPOLATION_SRGB;
mColorInterpolationFilters = NS_STYLE_COLOR_INTERPOLATION_LINEARRGB;
mFillRule = NS_STYLE_FILL_RULE_NONZERO;
mImageRendering = NS_STYLE_IMAGE_RENDERING_AUTO;
mPaintOrder = NS_STYLE_PAINT_ORDER_NORMAL;
mShapeRendering = NS_STYLE_SHAPE_RENDERING_AUTO;
mStrokeLinecap = NS_STYLE_STROKE_LINECAP_BUTT;
mStrokeLinejoin = NS_STYLE_STROKE_LINEJOIN_MITER;
mTextAnchor = NS_STYLE_TEXT_ANCHOR_START;
mTextRendering = NS_STYLE_TEXT_RENDERING_AUTO;
mFillOpacitySource = eStyleSVGOpacitySource_Normal;
mStrokeOpacitySource = eStyleSVGOpacitySource_Normal;
mStrokeDasharrayFromObject = false;
mStrokeDashoffsetFromObject = false;
mStrokeWidthFromObject = false;
}
nsStyleSVG::~nsStyleSVG()
mStrokeDasharrayLength = 0;
mClipRule = NS_STYLE_FILL_RULE_NONZERO;
mColorInterpolation = NS_STYLE_COLOR_INTERPOLATION_SRGB;
mColorInterpolationFilters = NS_STYLE_COLOR_INTERPOLATION_LINEARRGB;
mFillRule = NS_STYLE_FILL_RULE_NONZERO;
mImageRendering = NS_STYLE_IMAGE_RENDERING_AUTO;
mPaintOrder = NS_STYLE_PAINT_ORDER_NORMAL;
mShapeRendering = NS_STYLE_SHAPE_RENDERING_AUTO;
mStrokeLinecap = NS_STYLE_STROKE_LINECAP_BUTT;
mStrokeLinejoin = NS_STYLE_STROKE_LINEJOIN_MITER;
mTextAnchor = NS_STYLE_TEXT_ANCHOR_START;
mTextRendering = NS_STYLE_TEXT_RENDERING_AUTO;
mFillOpacitySource = eStyleSVGOpacitySource_Normal;
mStrokeOpacitySource = eStyleSVGOpacitySource_Normal;
mStrokeDasharrayFromObject = false;
mStrokeDashoffsetFromObject = false;
mStrokeWidthFromObject = false;
}
nsStyleSVG::~nsStyleSVG()
{
MOZ_COUNT_DTOR(nsStyleSVG);
delete [] mStrokeDasharray;
@ -1240,21 +1240,21 @@ nsStyleFilter::SetDropShadow(nsCSSShadowArray* aDropShadow)
// --------------------
// nsStyleSVGReset
//
nsStyleSVGReset::nsStyleSVGReset()
nsStyleSVGReset::nsStyleSVGReset()
{
MOZ_COUNT_CTOR(nsStyleSVGReset);
mStopColor = NS_RGB(0,0,0);
mFloodColor = NS_RGB(0,0,0);
mLightingColor = NS_RGB(255,255,255);
mMask = nullptr;
mStopOpacity = 1.0f;
mFloodOpacity = 1.0f;
mDominantBaseline = NS_STYLE_DOMINANT_BASELINE_AUTO;
mVectorEffect = NS_STYLE_VECTOR_EFFECT_NONE;
mMaskType = NS_STYLE_MASK_TYPE_LUMINANCE;
MOZ_COUNT_CTOR(nsStyleSVGReset);
mStopColor = NS_RGB(0,0,0);
mFloodColor = NS_RGB(0,0,0);
mLightingColor = NS_RGB(255,255,255);
mMask = nullptr;
mStopOpacity = 1.0f;
mFloodOpacity = 1.0f;
mDominantBaseline = NS_STYLE_DOMINANT_BASELINE_AUTO;
mVectorEffect = NS_STYLE_VECTOR_EFFECT_NONE;
mMaskType = NS_STYLE_MASK_TYPE_LUMINANCE;
}
nsStyleSVGReset::~nsStyleSVGReset()
nsStyleSVGReset::~nsStyleSVGReset()
{
MOZ_COUNT_DTOR(nsStyleSVGReset);
}

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -97,7 +98,8 @@ static_assert(int(mozilla::SheetType::Count) - 1 <=
// The lifetime of these objects is managed by the presshell's arena.
struct nsStyleFont {
struct nsStyleFont
{
nsStyleFont(const nsFont& aFont, nsPresContext *aPresContext);
nsStyleFont(const nsStyleFont& aStyleFont);
explicit nsStyleFont(nsPresContext *aPresContext);
@ -174,7 +176,8 @@ struct nsStyleFont {
nsCOMPtr<nsIAtom> mLanguage; // [inherited]
};
struct nsStyleGradientStop {
struct nsStyleGradientStop
{
nsStyleCoord mLocation; // percent, coord, calc, none
nscolor mColor;
bool mIsInterpolationHint;
@ -184,7 +187,8 @@ struct nsStyleGradientStop {
bool operator!=(const nsStyleGradientStop&) const = delete;
};
class nsStyleGradient final {
class nsStyleGradient final
{
public:
nsStyleGradient();
uint8_t mShape; // NS_STYLE_GRADIENT_SHAPE_*
@ -239,7 +243,8 @@ enum nsStyleImageType {
* region of an image. (Currently, this feature is only supported with an
* image of type (1)).
*/
struct nsStyleImage {
struct nsStyleImage
{
nsStyleImage();
~nsStyleImage();
nsStyleImage(const nsStyleImage& aOther);
@ -360,7 +365,8 @@ private:
#endif
};
struct nsStyleColor {
struct nsStyleColor
{
explicit nsStyleColor(nsPresContext* aPresContext);
nsStyleColor(const nsStyleColor& aOther);
~nsStyleColor(void) {
@ -392,7 +398,8 @@ struct nsStyleColor {
nscolor mColor; // [inherited]
};
struct nsStyleBackground {
struct nsStyleBackground
{
nsStyleBackground();
nsStyleBackground(const nsStyleBackground& aOther);
~nsStyleBackground();
@ -629,7 +636,8 @@ struct nsStyleBackground {
#define NS_SPACING_BORDER 2
struct nsStyleMargin {
struct nsStyleMargin
{
nsStyleMargin(void);
nsStyleMargin(const nsStyleMargin& aMargin);
~nsStyleMargin(void) {
@ -673,7 +681,8 @@ protected:
};
struct nsStylePadding {
struct nsStylePadding
{
nsStylePadding(void);
nsStylePadding(const nsStylePadding& aPadding);
~nsStylePadding(void) {
@ -721,7 +730,8 @@ protected:
nsMargin mCachedPadding;
};
struct nsBorderColors {
struct nsBorderColors
{
nsBorderColors* mNext;
nscolor mColor;
@ -750,7 +760,8 @@ private:
nsBorderColors* Clone(bool aDeep) const;
};
struct nsCSSShadowItem {
struct nsCSSShadowItem
{
nscoord mXOffset;
nscoord mYOffset;
nscoord mRadius;
@ -781,74 +792,75 @@ struct nsCSSShadowItem {
}
};
class nsCSSShadowArray final {
public:
void* operator new(size_t aBaseSize, uint32_t aArrayLen) {
// We can allocate both this nsCSSShadowArray and the
// actual array in one allocation. The amount of memory to
// allocate is equal to the class's size + the number of bytes for all
// but the first array item (because aBaseSize includes one
// item, see the private declarations)
return ::operator new(aBaseSize +
(aArrayLen - 1) * sizeof(nsCSSShadowItem));
}
class nsCSSShadowArray final
{
public:
void* operator new(size_t aBaseSize, uint32_t aArrayLen) {
// We can allocate both this nsCSSShadowArray and the
// actual array in one allocation. The amount of memory to
// allocate is equal to the class's size + the number of bytes for all
// but the first array item (because aBaseSize includes one
// item, see the private declarations)
return ::operator new(aBaseSize +
(aArrayLen - 1) * sizeof(nsCSSShadowItem));
}
explicit nsCSSShadowArray(uint32_t aArrayLen) :
mLength(aArrayLen)
{
MOZ_COUNT_CTOR(nsCSSShadowArray);
for (uint32_t i = 1; i < mLength; ++i) {
// Make sure we call the constructors of each nsCSSShadowItem
// (the first one is called for us because we declared it under private)
new (&mArray[i]) nsCSSShadowItem();
}
explicit nsCSSShadowArray(uint32_t aArrayLen) :
mLength(aArrayLen)
{
MOZ_COUNT_CTOR(nsCSSShadowArray);
for (uint32_t i = 1; i < mLength; ++i) {
// Make sure we call the constructors of each nsCSSShadowItem
// (the first one is called for us because we declared it under private)
new (&mArray[i]) nsCSSShadowItem();
}
}
private:
// Private destructor, to discourage deletion outside of Release():
~nsCSSShadowArray() {
MOZ_COUNT_DTOR(nsCSSShadowArray);
for (uint32_t i = 1; i < mLength; ++i) {
mArray[i].~nsCSSShadowItem();
}
// Private destructor, to discourage deletion outside of Release():
~nsCSSShadowArray() {
MOZ_COUNT_DTOR(nsCSSShadowArray);
for (uint32_t i = 1; i < mLength; ++i) {
mArray[i].~nsCSSShadowItem();
}
}
public:
uint32_t Length() const { return mLength; }
nsCSSShadowItem* ShadowAt(uint32_t i) {
MOZ_ASSERT(i < mLength, "Accessing too high an index in the text shadow array!");
return &mArray[i];
}
const nsCSSShadowItem* ShadowAt(uint32_t i) const {
MOZ_ASSERT(i < mLength, "Accessing too high an index in the text shadow array!");
return &mArray[i];
}
uint32_t Length() const { return mLength; }
nsCSSShadowItem* ShadowAt(uint32_t i) {
MOZ_ASSERT(i < mLength, "Accessing too high an index in the text shadow array!");
return &mArray[i];
}
const nsCSSShadowItem* ShadowAt(uint32_t i) const {
MOZ_ASSERT(i < mLength, "Accessing too high an index in the text shadow array!");
return &mArray[i];
}
bool HasShadowWithInset(bool aInset) {
for (uint32_t i = 0; i < mLength; ++i) {
if (mArray[i].mInset == aInset)
return true;
}
bool HasShadowWithInset(bool aInset) {
for (uint32_t i = 0; i < mLength; ++i) {
if (mArray[i].mInset == aInset)
return true;
}
return false;
}
bool operator==(const nsCSSShadowArray& aOther) const {
if (mLength != aOther.Length())
return false;
}
bool operator==(const nsCSSShadowArray& aOther) const {
if (mLength != aOther.Length())
for (uint32_t i = 0; i < mLength; ++i) {
if (ShadowAt(i) != aOther.ShadowAt(i))
return false;
for (uint32_t i = 0; i < mLength; ++i) {
if (ShadowAt(i) != aOther.ShadowAt(i))
return false;
}
return true;
}
NS_INLINE_DECL_REFCOUNTING(nsCSSShadowArray)
return true;
}
private:
uint32_t mLength;
nsCSSShadowItem mArray[1]; // This MUST be the last item
NS_INLINE_DECL_REFCOUNTING(nsCSSShadowArray)
private:
uint32_t mLength;
nsCSSShadowItem mArray[1]; // This MUST be the last item
};
// Border widths are rounded to the nearest-below integer number of pixels,
@ -871,7 +883,8 @@ static bool IsVisibleBorderStyle(uint8_t aStyle)
aStyle != NS_STYLE_BORDER_STYLE_HIDDEN);
}
struct nsStyleBorder {
struct nsStyleBorder
{
explicit nsStyleBorder(nsPresContext* aContext);
nsStyleBorder(const nsStyleBorder& aBorder);
~nsStyleBorder();
@ -1097,7 +1110,8 @@ private:
};
struct nsStyleOutline {
struct nsStyleOutline
{
explicit nsStyleOutline(nsPresContext* aPresContext);
nsStyleOutline(const nsStyleOutline& aOutline);
~nsStyleOutline(void) {
@ -1195,7 +1209,8 @@ protected:
};
struct nsStyleList {
struct nsStyleList
{
explicit nsStyleList(nsPresContext* aPresContext);
nsStyleList(const nsStyleList& aStyleList);
~nsStyleList(void);
@ -1261,7 +1276,8 @@ public:
nsRect mImageRegion; // [inherited] the rect to use within an image
};
struct nsStyleGridLine {
struct nsStyleGridLine
{
// http://dev.w3.org/csswg/css-grid/#typedef-grid-line
// XXXmats we could optimize memory size here
bool mHasSpan;
@ -1360,7 +1376,8 @@ struct nsStyleGridLine {
// when there is no <auto-repeat> track, i.e. when mRepeatAutoIndex == -1).
// When mIsSubgrid is true, mRepeatAutoLineNameListBefore contains the line
// names and mRepeatAutoLineNameListAfter is empty.
struct nsStyleGridTemplate {
struct nsStyleGridTemplate
{
nsTArray<nsTArray<nsString>> mLineNameLists;
nsTArray<nsStyleCoord> mMinTrackSizingFunctions;
nsTArray<nsStyleCoord> mMaxTrackSizingFunctions;
@ -1399,7 +1416,8 @@ struct nsStyleGridTemplate {
}
};
struct nsStylePosition {
struct nsStylePosition
{
nsStylePosition(void);
nsStylePosition(const nsStylePosition& aOther);
~nsStylePosition(void);
@ -1590,7 +1608,8 @@ private:
{ return aCoord.HasPercent(); }
};
struct nsStyleTextOverflowSide {
struct nsStyleTextOverflowSide
{
nsStyleTextOverflowSide() : mType(NS_STYLE_TEXT_OVERFLOW_CLIP) {}
bool operator==(const nsStyleTextOverflowSide& aOther) const {
@ -1606,7 +1625,8 @@ struct nsStyleTextOverflowSide {
uint8_t mType;
};
struct nsStyleTextOverflow {
struct nsStyleTextOverflow
{
nsStyleTextOverflow() : mLogicalDirections(true) {}
bool operator==(const nsStyleTextOverflow& aOther) const {
return mLeft == aOther.mLeft && mRight == aOther.mRight;
@ -1646,7 +1666,8 @@ struct nsStyleTextOverflow {
bool mLogicalDirections; // true when only one value was specified
};
struct nsStyleTextReset {
struct nsStyleTextReset
{
nsStyleTextReset(void);
nsStyleTextReset(const nsStyleTextReset& aOther);
~nsStyleTextReset(void);
@ -1723,7 +1744,8 @@ protected:
nscolor mTextDecorationColor; // [reset] the colors to use for a decoration lines, not used at currentColor
};
struct nsStyleText {
struct nsStyleText
{
explicit nsStyleText(nsPresContext* aPresContext);
nsStyleText(const nsStyleText& aOther);
~nsStyleText(void);
@ -1835,7 +1857,8 @@ struct nsStyleText {
mozilla::LogicalSide TextEmphasisSide(mozilla::WritingMode aWM) const;
};
struct nsStyleImageOrientation {
struct nsStyleImageOrientation
{
static nsStyleImageOrientation CreateAsAngleAndFlip(double aRadians,
bool aFlip) {
uint8_t orientation(0);
@ -1927,7 +1950,8 @@ protected:
uint8_t mOrientation;
};
struct nsStyleVisibility {
struct nsStyleVisibility
{
explicit nsStyleVisibility(nsPresContext* aPresContext);
nsStyleVisibility(const nsStyleVisibility& aVisibility);
~nsStyleVisibility() {
@ -1975,7 +1999,8 @@ struct nsStyleVisibility {
inline uint8_t GetEffectivePointerEvents(nsIFrame* aFrame) const;
};
struct nsTimingFunction {
struct nsTimingFunction
{
enum class Type {
Ease, // ease
@ -2102,7 +2127,8 @@ private:
namespace mozilla {
struct StyleTransition {
struct StyleTransition
{
StyleTransition() { /* leaves uninitialized; see also SetInitialValues */ }
explicit StyleTransition(const StyleTransition& aCopy);
@ -2156,7 +2182,8 @@ private:
// eCSSPropertyExtra_variable
};
struct StyleAnimation {
struct StyleAnimation
{
StyleAnimation() { /* leaves uninitialized; see also SetInitialValues */ }
explicit StyleAnimation(const StyleAnimation& aCopy);
@ -2203,7 +2230,8 @@ private:
} // namespace mozilla
struct nsStyleDisplay {
struct nsStyleDisplay
{
nsStyleDisplay();
nsStyleDisplay(const nsStyleDisplay& aOther);
~nsStyleDisplay() {
@ -2482,7 +2510,8 @@ struct nsStyleDisplay {
inline uint8_t PhysicalBreakType(mozilla::WritingMode aWM) const;
};
struct nsStyleTable {
struct nsStyleTable
{
nsStyleTable(void);
nsStyleTable(const nsStyleTable& aOther);
~nsStyleTable(void);
@ -2513,7 +2542,8 @@ struct nsStyleTable {
int32_t mSpan; // [reset] the number of columns spanned by a colgroup or col
};
struct nsStyleTableBorder {
struct nsStyleTableBorder
{
nsStyleTableBorder();
nsStyleTableBorder(const nsStyleTableBorder& aOther);
~nsStyleTableBorder(void);
@ -2561,7 +2591,8 @@ enum nsStyleContentType {
eStyleContentType_Uninitialized
};
struct nsStyleContentData {
struct nsStyleContentData
{
nsStyleContentType mType;
union {
char16_t *mString;
@ -2601,7 +2632,8 @@ private:
nsStyleContentData(const nsStyleContentData&); // not to be implemented
};
struct nsStyleCounterData {
struct nsStyleCounterData
{
nsString mCounter;
int32_t mValue;
};
@ -2609,7 +2641,8 @@ struct nsStyleCounterData {
#define DELETE_ARRAY_IF(array) if (array) { delete[] array; array = nullptr; }
struct nsStyleQuotes {
struct nsStyleQuotes
{
nsStyleQuotes();
nsStyleQuotes(const nsStyleQuotes& aQuotes);
~nsStyleQuotes();
@ -2691,7 +2724,8 @@ protected:
nsString* mQuotes;
};
struct nsStyleContent {
struct nsStyleContent
{
nsStyleContent(void);
nsStyleContent(const nsStyleContent& aContent);
~nsStyleContent(void);
@ -2800,7 +2834,8 @@ protected:
uint32_t mResetCount;
};
struct nsStyleUIReset {
struct nsStyleUIReset
{
nsStyleUIReset(void);
nsStyleUIReset(const nsStyleUIReset& aOther);
~nsStyleUIReset(void);
@ -2833,7 +2868,8 @@ struct nsStyleUIReset {
uint8_t mWindowShadow; // [reset]
};
struct nsCursorImage {
struct nsCursorImage
{
bool mHaveHotspot;
float mHotspotX, mHotspotY;
@ -2862,7 +2898,8 @@ private:
nsCOMPtr<imgIRequest> mImage;
};
struct nsStyleUserInterface {
struct nsStyleUserInterface
{
nsStyleUserInterface(void);
nsStyleUserInterface(const nsStyleUserInterface& aOther);
~nsStyleUserInterface(void);
@ -2909,7 +2946,8 @@ struct nsStyleUserInterface {
void CopyCursorArrayFrom(const nsStyleUserInterface& aSource);
};
struct nsStyleXUL {
struct nsStyleXUL
{
nsStyleXUL();
nsStyleXUL(const nsStyleXUL& aSource);
~nsStyleXUL();
@ -2945,7 +2983,8 @@ struct nsStyleXUL {
bool mStretchStack; // [reset] see nsStyleConsts.h
};
struct nsStyleColumn {
struct nsStyleColumn
{
explicit nsStyleColumn(nsPresContext* aPresContext);
nsStyleColumn(const nsStyleColumn& aSource);
~nsStyleColumn();
@ -3038,7 +3077,8 @@ struct nsStyleSVGPaint
}
};
struct nsStyleSVG {
struct nsStyleSVG
{
nsStyleSVG();
nsStyleSVG(const nsStyleSVG& aSource);
~nsStyleSVG();
@ -3125,7 +3165,8 @@ struct nsStyleSVG {
}
};
class nsStyleBasicShape final {
class nsStyleBasicShape final
{
public:
enum Type {
eInset,
@ -3267,7 +3308,8 @@ private:
uint8_t mSizingBox; // see NS_STYLE_CLIP_SHAPE_SIZING_* constants in nsStyleConsts.h
};
struct nsStyleFilter {
struct nsStyleFilter
{
nsStyleFilter();
nsStyleFilter(const nsStyleFilter& aSource);
~nsStyleFilter();
@ -3316,11 +3358,13 @@ private:
};
template<>
struct nsTArray_CopyChooser<nsStyleFilter> {
struct nsTArray_CopyChooser<nsStyleFilter>
{
typedef nsTArray_CopyWithConstructors<nsStyleFilter> Type;
};
struct nsStyleSVGReset {
struct nsStyleSVGReset
{
nsStyleSVGReset();
nsStyleSVGReset(const nsStyleSVGReset& aSource);
~nsStyleSVGReset();
@ -3371,7 +3415,8 @@ struct nsStyleSVGReset {
uint8_t mMaskType; // [reset] see nsStyleConsts.h
};
struct nsStyleVariables {
struct nsStyleVariables
{
nsStyleVariables();
nsStyleVariables(const nsStyleVariables& aSource);
~nsStyleVariables();