Bug 576044 (6/12): remove vestiges of nsCSSType. r=dbaron a2.0=dbaron

This commit is contained in:
Zack Weinberg 2010-08-19 15:33:44 -04:00
Родитель 89773eab2f
Коммит 670ff6c170
19 изменённых файлов: 318 добавлений и 757 удалений

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

@ -2327,8 +2327,7 @@ nsCanvasRenderingContext2D::SetFont(const nsAString& font)
// We know the declaration is not !important, so we can use
// GetNormalBlock().
const nsCSSValue *fsaVal =
declaration->GetNormalBlock()->
ValueStorageFor(eCSSProperty_font_size_adjust);
declaration->GetNormalBlock()->ValueFor(eCSSProperty_font_size_adjust);
if (!fsaVal || (fsaVal->GetUnit() != eCSSUnit_None &&
fsaVal->GetUnit() != eCSSUnit_System_Font)) {
// We got an all-property value or a syntax error. The spec says

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

@ -39,22 +39,22 @@
#include "nsICSSDeclaration.h"
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
static const nsCSSProperty QS_CSS_PROP_##method_ = eCSSProperty_##id_;
#define CSS_PROP_LIST_EXCLUDE_INTERNAL
#define CSS_PROP_SHORTHAND(name_, id_, method_, flags_) \
CSS_PROP(name_, id_, method_, flags_, X, X, X, X, X, X, X)
CSS_PROP(name_, id_, method_, flags_, X, X, X, X, X, X)
#include "nsCSSPropList.h"
// Aliases
CSS_PROP(X, opacity, MozOpacity, 0, X, X, X, X, X, X, X)
CSS_PROP(X, outline, MozOutline, 0, X, X, X, X, X, X, X)
CSS_PROP(X, outline_color, MozOutlineColor, 0, X, X, X, X, X, X, X)
CSS_PROP(X, outline_style, MozOutlineStyle, 0, X, X, X, X, X, X, X)
CSS_PROP(X, outline_width, MozOutlineWidth, 0, X, X, X, X, X, X, X)
CSS_PROP(X, outline_offset, MozOutlineOffset, 0, X, X, X, X, X, X, X)
CSS_PROP(X, opacity, MozOpacity, X, X, X, X, X, X, X)
CSS_PROP(X, outline, MozOutline, X, X, X, X, X, X, X)
CSS_PROP(X, outline_color, MozOutlineColor, X, X, X, X, X, X, X)
CSS_PROP(X, outline_style, MozOutlineStyle, X, X, X, X, X, X, X)
CSS_PROP(X, outline_width, MozOutlineWidth, X, X, X, X, X, X, X)
CSS_PROP(X, outline_offset, MozOutlineOffset, X, X, X, X, X, X, X)
#undef CSS_PROP_SHORTHAND
#undef CSS_PROP_LIST_EXCLUDE_INTERNAL

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

@ -129,17 +129,12 @@ PRBool Declaration::AppendValueToString(nsCSSProperty aProperty,
nsCSSCompressedDataBlock *data = GetValueIsImportant(aProperty)
? mImportantData : mData;
const void *storage = data->StorageFor(aProperty);
if (!storage) {
const nsCSSValue *val = data->ValueFor(aProperty);
if (!val) {
return PR_FALSE;
}
switch (nsCSSProps::kTypeTable[aProperty]) {
case eCSSType_Value:
static_cast<const nsCSSValue*>(storage)->
AppendToString(aProperty, aResult);
break;
}
val->AppendToString(aProperty, aResult);
return PR_TRUE;
}
@ -184,27 +179,20 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const
continue;
}
++totalCount;
const void *storage = mData->StorageFor(*p);
NS_ASSERTION(!storage || !mImportantData || !mImportantData->StorageFor(*p),
const nsCSSValue *val = mData->ValueFor(*p);
NS_ASSERTION(!val || !mImportantData || !mImportantData->ValueFor(*p),
"can't be in both blocks");
if (!storage && mImportantData) {
if (!val && mImportantData) {
++importantCount;
storage = mImportantData->StorageFor(*p);
val = mImportantData->ValueFor(*p);
}
if (!storage) {
if (!val) {
// Case (1) above: some subproperties not specified.
return;
}
nsCSSUnit unit;
switch (nsCSSProps::kTypeTable[*p]) {
case eCSSType_Value: {
const nsCSSValue *val = static_cast<const nsCSSValue*>(storage);
unit = val->GetUnit();
} break;
}
if (unit == eCSSUnit_Inherit) {
if (val->GetUnit() == eCSSUnit_Inherit) {
++inheritCount;
} else if (unit == eCSSUnit_Initial) {
} else if (val->GetUnit() == eCSSUnit_Initial) {
++initialCount;
}
}
@ -236,11 +224,6 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const
case eCSSProperty_border_width: {
const nsCSSProperty* subprops =
nsCSSProps::SubpropertyEntryFor(aProperty);
NS_ASSERTION(nsCSSProps::kTypeTable[subprops[0]] == eCSSType_Value &&
nsCSSProps::kTypeTable[subprops[1]] == eCSSType_Value &&
nsCSSProps::kTypeTable[subprops[2]] == eCSSType_Value &&
nsCSSProps::kTypeTable[subprops[3]] == eCSSType_Value,
"type mismatch");
NS_ASSERTION(nsCSSProps::GetStringValue(subprops[0]).Find("-top") !=
kNotFound, "first subprop must be top");
NS_ASSERTION(nsCSSProps::GetStringValue(subprops[1]).Find("-right") !=
@ -249,10 +232,10 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const
kNotFound, "third subprop must be bottom");
NS_ASSERTION(nsCSSProps::GetStringValue(subprops[3]).Find("-left") !=
kNotFound, "fourth subprop must be left");
const nsCSSValue &topValue = *data->ValueStorageFor(subprops[0]);
const nsCSSValue &rightValue = *data->ValueStorageFor(subprops[1]);
const nsCSSValue &bottomValue = *data->ValueStorageFor(subprops[2]);
const nsCSSValue &leftValue = *data->ValueStorageFor(subprops[3]);
const nsCSSValue &topValue = *data->ValueFor(subprops[0]);
const nsCSSValue &rightValue = *data->ValueFor(subprops[1]);
const nsCSSValue &bottomValue = *data->ValueFor(subprops[2]);
const nsCSSValue &leftValue = *data->ValueFor(subprops[3]);
NS_ASSERTION(topValue.GetUnit() != eCSSUnit_Null, "null top");
topValue.AppendToString(subprops[0], aValue);
@ -279,10 +262,10 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const
const nsCSSProperty* subprops =
nsCSSProps::SubpropertyEntryFor(aProperty);
const nsCSSValue* vals[4] = {
data->ValueStorageFor(subprops[0]),
data->ValueStorageFor(subprops[1]),
data->ValueStorageFor(subprops[2]),
data->ValueStorageFor(subprops[3])
data->ValueFor(subprops[0]),
data->ValueFor(subprops[1]),
data->ValueFor(subprops[2]),
data->ValueFor(subprops[3])
};
// For compatibility, only write a slash and the y-values
@ -325,10 +308,10 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const
subprops < subprops_end; ++subprops) {
// Check only the first four subprops in each table, since the
// others are extras for dimensional box properties.
const nsCSSValue *firstSide = data->ValueStorageFor((*subprops)[0]);
const nsCSSValue *firstSide = data->ValueFor((*subprops)[0]);
for (PRInt32 side = 1; side < 4; ++side) {
const nsCSSValue *otherSide =
data->ValueStorageFor((*subprops)[side]);
data->ValueFor((*subprops)[side]);
if (*firstSide != *otherSide)
match = PR_FALSE;
}
@ -350,16 +333,12 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const
case eCSSProperty_outline: {
const nsCSSProperty* subprops =
nsCSSProps::SubpropertyEntryFor(aProperty);
NS_ASSERTION(nsCSSProps::kTypeTable[subprops[0]] == eCSSType_Value &&
nsCSSProps::kTypeTable[subprops[1]] == eCSSType_Value &&
nsCSSProps::kTypeTable[subprops[2]] == eCSSType_Value,
"type mismatch");
NS_ASSERTION(StringEndsWith(nsCSSProps::GetStringValue(subprops[2]),
NS_LITERAL_CSTRING("-color")) ||
StringEndsWith(nsCSSProps::GetStringValue(subprops[2]),
NS_LITERAL_CSTRING("-color-value")),
"third subprop must be the color property");
const nsCSSValue *colorValue = data->ValueStorageFor(subprops[2]);
const nsCSSValue *colorValue = data->ValueFor(subprops[2]);
PRBool isMozUseTextColor =
colorValue->GetUnit() == eCSSUnit_Enumerated &&
colorValue->GetIntValue() == NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR;
@ -410,25 +389,25 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const
// background-origin that are different and not the default
// values. (We omit them if they're both default.)
const nsCSSValueList *image =
data->ValueStorageFor(eCSSProperty_background_image)->
data->ValueFor(eCSSProperty_background_image)->
GetListValue();
const nsCSSValueList *repeat =
data->ValueStorageFor(eCSSProperty_background_repeat)->
data->ValueFor(eCSSProperty_background_repeat)->
GetListValue();
const nsCSSValueList *attachment =
data->ValueStorageFor(eCSSProperty_background_attachment)->
data->ValueFor(eCSSProperty_background_attachment)->
GetListValue();
const nsCSSValuePairList *position =
data->ValueStorageFor(eCSSProperty_background_position)->
data->ValueFor(eCSSProperty_background_position)->
GetPairListValue();
const nsCSSValueList *clip =
data->ValueStorageFor(eCSSProperty_background_clip)->
data->ValueFor(eCSSProperty_background_clip)->
GetListValue();
const nsCSSValueList *origin =
data->ValueStorageFor(eCSSProperty_background_origin)->
data->ValueFor(eCSSProperty_background_origin)->
GetListValue();
const nsCSSValuePairList *size =
data->ValueStorageFor(eCSSProperty_background_size)->
data->ValueFor(eCSSProperty_background_size)->
GetPairListValue();
for (;;) {
if (size->mXValue.GetUnit() != eCSSUnit_Auto ||
@ -515,27 +494,27 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const
// systemFont might not be present; the others are guaranteed to be
// based on the shorthand check at the beginning of the function
const nsCSSValue *systemFont =
data->ValueStorageFor(eCSSProperty__x_system_font);
data->ValueFor(eCSSProperty__x_system_font);
const nsCSSValue &style =
*data->ValueStorageFor(eCSSProperty_font_style);
*data->ValueFor(eCSSProperty_font_style);
const nsCSSValue &variant =
*data->ValueStorageFor(eCSSProperty_font_variant);
*data->ValueFor(eCSSProperty_font_variant);
const nsCSSValue &weight =
*data->ValueStorageFor(eCSSProperty_font_weight);
*data->ValueFor(eCSSProperty_font_weight);
const nsCSSValue &size =
*data->ValueStorageFor(eCSSProperty_font_size);
*data->ValueFor(eCSSProperty_font_size);
const nsCSSValue &lh =
*data->ValueStorageFor(eCSSProperty_line_height);
*data->ValueFor(eCSSProperty_line_height);
const nsCSSValue &family =
*data->ValueStorageFor(eCSSProperty_font_family);
*data->ValueFor(eCSSProperty_font_family);
const nsCSSValue &stretch =
*data->ValueStorageFor(eCSSProperty_font_stretch);
*data->ValueFor(eCSSProperty_font_stretch);
const nsCSSValue &sizeAdjust =
*data->ValueStorageFor(eCSSProperty_font_size_adjust);
*data->ValueFor(eCSSProperty_font_size_adjust);
const nsCSSValue &featureSettings =
*data->ValueStorageFor(eCSSProperty_font_feature_settings);
*data->ValueFor(eCSSProperty_font_feature_settings);
const nsCSSValue &languageOverride =
*data->ValueStorageFor(eCSSProperty_font_language_override);
*data->ValueFor(eCSSProperty_font_language_override);
if (systemFont &&
systemFont->GetUnit() != eCSSUnit_None &&
@ -601,9 +580,9 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const
break;
case eCSSProperty_overflow: {
const nsCSSValue &xValue =
*data->ValueStorageFor(eCSSProperty_overflow_x);
*data->ValueFor(eCSSProperty_overflow_x);
const nsCSSValue &yValue =
*data->ValueStorageFor(eCSSProperty_overflow_y);
*data->ValueFor(eCSSProperty_overflow_y);
if (xValue == yValue)
xValue.AppendToString(eCSSProperty_overflow_x, aValue);
break;
@ -618,13 +597,13 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const
}
case eCSSProperty_transition: {
const nsCSSValue &transProp =
*data->ValueStorageFor(eCSSProperty_transition_property);
*data->ValueFor(eCSSProperty_transition_property);
const nsCSSValue &transDuration =
*data->ValueStorageFor(eCSSProperty_transition_duration);
*data->ValueFor(eCSSProperty_transition_duration);
const nsCSSValue &transTiming =
*data->ValueStorageFor(eCSSProperty_transition_timing_function);
*data->ValueFor(eCSSProperty_transition_timing_function);
const nsCSSValue &transDelay =
*data->ValueStorageFor(eCSSProperty_transition_delay);
*data->ValueFor(eCSSProperty_transition_delay);
NS_ABORT_IF_FALSE(transDuration.GetUnit() == eCSSUnit_List ||
transDuration.GetUnit() == eCSSUnit_ListDep,
@ -696,11 +675,11 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const
case eCSSProperty_marker: {
const nsCSSValue &endValue =
*data->ValueStorageFor(eCSSProperty_marker_end);
*data->ValueFor(eCSSProperty_marker_end);
const nsCSSValue &midValue =
*data->ValueStorageFor(eCSSProperty_marker_mid);
*data->ValueFor(eCSSProperty_marker_mid);
const nsCSSValue &startValue =
*data->ValueStorageFor(eCSSProperty_marker_start);
*data->ValueFor(eCSSProperty_marker_start);
if (endValue == midValue && midValue == startValue)
AppendValueToString(eCSSProperty_marker_end, aValue);
break;
@ -724,8 +703,7 @@ Declaration::GetValueIsImportant(nsCSSProperty aProperty) const
if (!mImportantData)
return PR_FALSE;
// Calling StorageFor is inefficient, but we can assume '!important'
// is rare.
// Calling ValueFor is inefficient, but we can assume '!important' is rare.
if (nsCSSProps::IsShorthand(aProperty)) {
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aProperty) {
@ -733,14 +711,14 @@ Declaration::GetValueIsImportant(nsCSSProperty aProperty) const
// The system_font subproperty doesn't count.
continue;
}
if (!mImportantData->StorageFor(*p)) {
if (!mImportantData->ValueFor(*p)) {
return PR_FALSE;
}
}
return PR_TRUE;
}
return mImportantData->StorageFor(aProperty) != nsnull;
return mImportantData->ValueFor(aProperty) != nsnull;
}
/* static */ void
@ -782,8 +760,8 @@ Declaration::ToString(nsAString& aString) const
nsCSSCompressedDataBlock *systemFontData =
GetValueIsImportant(eCSSProperty__x_system_font) ? mImportantData : mData;
const nsCSSValue *systemFont =
systemFontData->ValueStorageFor(eCSSProperty__x_system_font);
const nsCSSValue *systemFont =
systemFontData->ValueFor(eCSSProperty__x_system_font);
const PRBool haveSystemFont = systemFont &&
systemFont->GetUnit() != eCSSUnit_None &&
systemFont->GetUnit() != eCSSUnit_Null;
@ -850,10 +828,8 @@ Declaration::ToString(nsAString& aString) const
// (2) its value is the hidden system font value and it matches
// the hidden system font subproperty in importance, and
// we output the system font subproperty.
NS_ASSERTION(nsCSSProps::kTypeTable[property] == eCSSType_Value,
"not a value typed subproperty");
const nsCSSValue *val =
systemFontData->ValueStorageFor(property);
systemFontData->ValueFor(property);
if (property == eCSSProperty__x_system_font ||
(haveSystemFont && val && val->GetUnit() == eCSSUnit_System_Font)) {
doneProperty = PR_TRUE;

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

@ -164,7 +164,7 @@ public:
* May only be called when not expanded, and the caller must call
* EnsureMutable first.
*/
void* SlotForValue(nsCSSProperty aProperty, PRBool aIsImportant) {
nsCSSValue* SlotForValue(nsCSSProperty aProperty, PRBool aIsImportant) {
AssertMutable();
NS_ABORT_IF_FALSE(mData, "called while expanded");
@ -177,11 +177,11 @@ public:
return nsnull;
}
void *slot = block->SlotForValue(aProperty);
nsCSSValue *slot = block->SlotForValue(aProperty);
#ifdef DEBUG
{
nsCSSCompressedDataBlock *other = aIsImportant ? mData : mImportantData;
NS_ABORT_IF_FALSE(!slot || !other || !other->StorageFor(aProperty),
NS_ABORT_IF_FALSE(!slot || !other || !other->ValueFor(aProperty),
"Property both important and not?");
}
#endif
@ -190,7 +190,7 @@ public:
PRBool HasNonImportantValueFor(nsCSSProperty aProperty) const {
NS_ABORT_IF_FALSE(!nsCSSProps::IsShorthand(aProperty), "must be longhand");
return !!mData->StorageFor(aProperty);
return !!mData->ValueFor(aProperty);
}
/**

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

@ -52,18 +52,8 @@ namespace css = mozilla::css;
/*
* nsCSSCompressedDataBlock holds property-value pairs corresponding
* to CSS declaration blocks. The value is stored in one of the three
* CSS data types: nsCSSValue, nsCSSValueList, and nsCSSValuePairList,
* which each correspond to a value of the nsCSSType enumeration.
*
* The storage strategy uses the CDB*Storage structs below to help
* ensure that all the types remain properly aligned. nsCSSValue's
* alignment requirements cannot be weaker than any others, since it
* contains a pointer and an enumeration.
*
* nsCSSValue objects are stored directly in the block; list types
* have only a pointer to the first element in the list stored in the
* block.
* to CSS declaration blocks. Each pair is stored in a CDBValueStorage
* object; these objects form an array at the end of the data block.
*/
struct CDBValueStorage {
@ -179,55 +169,43 @@ nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
"out of range");
if (nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[iProp]) &
aRuleData->mSIDs) {
void *prop = aRuleData->StorageFor(iProp);
switch (nsCSSProps::kTypeTable[iProp]) {
case eCSSType_Value: {
nsCSSValue* target = static_cast<nsCSSValue*>(prop);
if (target->GetUnit() == eCSSUnit_Null) {
const nsCSSValue *val = ValueAtCursor(cursor);
NS_ASSERTION(val->GetUnit() != eCSSUnit_Null, "oops");
if (ShouldStartImageLoads(aRuleData, iProp)) {
TryToStartImageLoad(*val, doc, iProp);
}
*target = *val;
if (iProp == eCSSProperty_font_family) {
// XXX Are there other things like this?
aRuleData->mFontData->mFamilyFromHTML = PR_FALSE;
}
if (nsCSSProps::PropHasFlags(iProp,
CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED) &&
ShouldIgnoreColors(aRuleData))
{
if (iProp == eCSSProperty_background_color) {
// Force non-'transparent' background
// colors to the user's default.
if (target->IsNonTransparentColor()) {
target->SetColorValue(aRuleData->
mPresContext->
DefaultBackgroundColor());
}
} else {
// Ignore 'color', 'border-*-color', etc.
*target = nsCSSValue();
}
nsCSSValue* target = aRuleData->ValueFor(iProp);
if (target->GetUnit() == eCSSUnit_Null) {
const nsCSSValue *val = ValueAtCursor(cursor);
NS_ASSERTION(val->GetUnit() != eCSSUnit_Null, "oops");
if (ShouldStartImageLoads(aRuleData, iProp)) {
TryToStartImageLoad(*val, doc, iProp);
}
*target = *val;
if (iProp == eCSSProperty_font_family) {
// XXX Are there other things like this?
aRuleData->mFontData->mFamilyFromHTML = PR_FALSE;
}
if (nsCSSProps::PropHasFlags(iProp,
CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED) &&
ShouldIgnoreColors(aRuleData))
{
if (iProp == eCSSProperty_background_color) {
// Force non-'transparent' background
// colors to the user's default.
if (target->IsNonTransparentColor()) {
target->SetColorValue(aRuleData->mPresContext->
DefaultBackgroundColor());
}
} else {
// Ignore 'color', 'border-*-color', etc.
*target = nsCSSValue();
}
cursor += CDBValueStorage_advance;
} break;
}
} else {
switch (nsCSSProps::kTypeTable[iProp]) {
case eCSSType_Value: {
cursor += CDBValueStorage_advance;
} break;
}
}
}
cursor += CDBValueStorage_advance;
}
NS_ASSERTION(cursor == cursor_end, "inconsistent data");
}
const void*
nsCSSCompressedDataBlock::StorageFor(nsCSSProperty aProperty) const
const nsCSSValue*
nsCSSCompressedDataBlock::ValueFor(nsCSSProperty aProperty) const
{
NS_PRECONDITION(!nsCSSProps::IsShorthand(aProperty),
"Don't call for shorthands");
@ -247,17 +225,9 @@ nsCSSCompressedDataBlock::StorageFor(nsCSSProperty aProperty) const
NS_ASSERTION(0 <= iProp && iProp < eCSSProperty_COUNT_no_shorthands,
"out of range");
if (iProp == aProperty) {
switch (nsCSSProps::kTypeTable[iProp]) {
case eCSSType_Value: {
return ValueAtCursor(cursor);
}
}
}
switch (nsCSSProps::kTypeTable[iProp]) {
case eCSSType_Value: {
cursor += CDBValueStorage_advance;
} break;
return ValueAtCursor(cursor);
}
cursor += CDBValueStorage_advance;
}
NS_ASSERTION(cursor == cursor_end, "inconsistent data");
@ -282,16 +252,11 @@ nsCSSCompressedDataBlock::Clone() const
"out of range");
PropertyAtCursor(result_cursor) = iProp;
switch (nsCSSProps::kTypeTable[iProp]) {
case eCSSType_Value: {
const nsCSSValue* val = ValueAtCursor(cursor);
NS_ASSERTION(val->GetUnit() != eCSSUnit_Null, "oops");
nsCSSValue *result_val = ValueAtCursor(result_cursor);
new (result_val) nsCSSValue(*val);
cursor += CDBValueStorage_advance;
result_cursor += CDBValueStorage_advance;
} break;
}
const nsCSSValue* val = ValueAtCursor(cursor);
nsCSSValue *result_val = ValueAtCursor(result_cursor);
new (result_val) nsCSSValue(*val);
cursor += CDBValueStorage_advance;
result_cursor += CDBValueStorage_advance;
}
NS_ASSERTION(cursor == cursor_end, "inconsistent data");
@ -311,14 +276,10 @@ nsCSSCompressedDataBlock::~nsCSSCompressedDataBlock()
NS_ASSERTION(0 <= iProp && iProp < eCSSProperty_COUNT_no_shorthands,
"out of range");
switch (nsCSSProps::kTypeTable[iProp]) {
case eCSSType_Value: {
const nsCSSValue* val = ValueAtCursor(cursor);
NS_ASSERTION(val->GetUnit() != eCSSUnit_Null, "oops");
val->~nsCSSValue();
cursor += CDBValueStorage_advance;
} break;
}
const nsCSSValue* val = ValueAtCursor(cursor);
NS_ASSERTION(val->GetUnit() != eCSSUnit_Null, "oops");
val->~nsCSSValue();
cursor += CDBValueStorage_advance;
}
NS_ASSERTION(cursor == cursor_end, "inconsistent data");
}
@ -331,22 +292,14 @@ nsCSSCompressedDataBlock::CreateEmptyBlock()
return result;
}
/* static */ void
nsCSSCompressedDataBlock::MoveValue(void *aSource, void *aDest,
nsCSSProperty aPropID,
PRBool* aChanged)
/* static */ PRBool
nsCSSCompressedDataBlock::MoveValue(nsCSSValue *aSource, nsCSSValue *aDest)
{
switch (nsCSSProps::kTypeTable[aPropID]) {
case eCSSType_Value: {
nsCSSValue *source = static_cast<nsCSSValue*>(aSource);
nsCSSValue *dest = static_cast<nsCSSValue*>(aDest);
if (*source != *dest)
*aChanged = PR_TRUE;
dest->~nsCSSValue();
memcpy(dest, source, sizeof(nsCSSValue));
new (source) nsCSSValue();
} break;
}
PRBool changed = (*aSource != *aDest);
aDest->~nsCSSValue();
memcpy(aDest, aSource, sizeof(nsCSSValue));
new (aSource) nsCSSValue();
return changed;
}
/*****************************************************************************/
@ -363,7 +316,7 @@ nsCSSExpandedDataBlock::~nsCSSExpandedDataBlock()
const size_t
nsCSSExpandedDataBlock::kOffsetTable[] = {
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
offsetof(nsCSSExpandedDataBlock, m##datastruct_.member_),
#include "nsCSSPropList.h"
@ -389,22 +342,17 @@ nsCSSExpandedDataBlock::DoExpand(nsCSSCompressedDataBlock *aBlock,
SetPropertyBit(iProp);
if (aImportant)
SetImportantBit(iProp);
void *prop = PropertyAt(iProp);
switch (nsCSSProps::kTypeTable[iProp]) {
case eCSSType_Value: {
const nsCSSValue* val = ValueAtCursor(cursor);
nsCSSValue* dest = static_cast<nsCSSValue*>(prop);
NS_ASSERTION(val->GetUnit() != eCSSUnit_Null, "oops");
NS_ASSERTION(dest->GetUnit() == eCSSUnit_Null,
"expanding into non-empty block");
const nsCSSValue* val = ValueAtCursor(cursor);
nsCSSValue* dest = PropertyAt(iProp);
NS_ASSERTION(val->GetUnit() != eCSSUnit_Null, "oops");
NS_ASSERTION(dest->GetUnit() == eCSSUnit_Null,
"expanding into non-empty block");
#ifdef NS_BUILD_REFCNT_LOGGING
dest->~nsCSSValue();
dest->~nsCSSValue();
#endif
memcpy(dest, val, sizeof(nsCSSValue));
cursor += CDBValueStorage_advance;
} break;
}
memcpy(dest, val, sizeof(nsCSSValue));
cursor += CDBValueStorage_advance;
}
NS_ASSERTION(cursor == cursor_end, "inconsistent data");
@ -439,24 +387,12 @@ nsCSSExpandedDataBlock::ComputeSize()
nsCSSProperty iProp = nsCSSPropertySet::CSSPropertyAt(iHigh, iLow);
NS_ASSERTION(0 <= iProp && iProp < eCSSProperty_COUNT_no_shorthands,
"out of range");
#ifdef DEBUG
void *prop = PropertyAt(iProp);
#endif
PRUint32 increment = 0;
switch (nsCSSProps::kTypeTable[iProp]) {
case eCSSType_Value: {
#ifdef DEBUG
nsCSSValue* val = static_cast<nsCSSValue*>(prop);
NS_ASSERTION(val->GetUnit() != eCSSUnit_Null,
"null value while computing size");
#endif
increment = CDBValueStorage_advance;
} break;
}
NS_ASSERTION(PropertyAt(iProp)->GetUnit() != eCSSUnit_Null,
"null value while computing size");
if (mPropertiesImportant.HasPropertyAt(iHigh, iLow))
result.important += increment;
result.important += CDBValueStorage_advance;
else
result.normal += increment;
result.normal += CDBValueStorage_advance;
}
}
return result;
@ -505,25 +441,20 @@ nsCSSExpandedDataBlock::Compress(nsCSSCompressedDataBlock **aNormalBlock,
nsCSSProperty iProp = nsCSSPropertySet::CSSPropertyAt(iHigh, iLow);
NS_ASSERTION(0 <= iProp && iProp < eCSSProperty_COUNT_no_shorthands,
"out of range");
void *prop = PropertyAt(iProp);
PRBool important =
mPropertiesImportant.HasPropertyAt(iHigh, iLow);
char *&cursor = important ? cursor_important : cursor_normal;
nsCSSCompressedDataBlock *result =
important ? result_important : result_normal;
switch (nsCSSProps::kTypeTable[iProp]) {
case eCSSType_Value: {
nsCSSValue* val = static_cast<nsCSSValue*>(prop);
NS_ASSERTION(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;
} break;
}
nsCSSValue* val = PropertyAt(iProp);
NS_ASSERTION(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]);
}
@ -582,49 +513,45 @@ nsCSSExpandedDataBlock::ClearLonghandProperty(nsCSSProperty aPropID)
ClearPropertyBit(aPropID);
ClearImportantBit(aPropID);
void *prop = PropertyAt(aPropID);
switch (nsCSSProps::kTypeTable[aPropID]) {
case eCSSType_Value: {
nsCSSValue* val = static_cast<nsCSSValue*>(prop);
val->Reset();
} break;
}
PropertyAt(aPropID)->Reset();
}
void
PRBool
nsCSSExpandedDataBlock::TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
nsCSSProperty aPropID,
PRBool aIsImportant,
PRBool aOverrideImportant,
PRBool aMustCallValueAppended,
css::Declaration* aDeclaration,
PRBool* aChanged)
css::Declaration* aDeclaration)
{
if (nsCSSProps::IsShorthand(aPropID)) {
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aPropID) {
DoTransferFromBlock(aFromBlock, *p, aIsImportant, aOverrideImportant,
aMustCallValueAppended, aDeclaration, aChanged);
if (!nsCSSProps::IsShorthand(aPropID)) {
return DoTransferFromBlock(aFromBlock, aPropID,
aIsImportant, aOverrideImportant,
aMustCallValueAppended, aDeclaration);
}
} else {
DoTransferFromBlock(aFromBlock, aPropID, aIsImportant, aOverrideImportant,
aMustCallValueAppended, aDeclaration, aChanged);
}
PRBool changed = PR_FALSE;
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aPropID) {
changed |= DoTransferFromBlock(aFromBlock, *p,
aIsImportant, aOverrideImportant,
aMustCallValueAppended, aDeclaration);
}
return changed;
}
void
PRBool
nsCSSExpandedDataBlock::DoTransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
nsCSSProperty aPropID,
PRBool aIsImportant,
PRBool aOverrideImportant,
PRBool aMustCallValueAppended,
css::Declaration* aDeclaration,
PRBool* aChanged)
css::Declaration* aDeclaration)
{
PRBool changed = PR_FALSE;
NS_ASSERTION(aFromBlock.HasPropertyBit(aPropID), "oops");
if (aIsImportant) {
if (!HasImportantBit(aPropID))
*aChanged = PR_TRUE;
changed = PR_TRUE;
SetImportantBit(aPropID);
} else {
if (HasImportantBit(aPropID)) {
@ -635,9 +562,9 @@ nsCSSExpandedDataBlock::DoTransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
// overwrite the property.
if (!aOverrideImportant) {
aFromBlock.ClearLonghandProperty(aPropID);
return;
return PR_FALSE;
}
*aChanged = PR_TRUE;
changed = PR_TRUE;
ClearImportantBit(aPropID);
}
}
@ -654,9 +581,9 @@ nsCSSExpandedDataBlock::DoTransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
* the destination, copying memory directly, and then using placement
* new.
*/
void *v_source = aFromBlock.PropertyAt(aPropID);
void *v_dest = PropertyAt(aPropID);
nsCSSCompressedDataBlock::MoveValue(v_source, v_dest, aPropID, aChanged);
changed |= nsCSSCompressedDataBlock::MoveValue(aFromBlock.PropertyAt(aPropID),
PropertyAt(aPropID));
return changed;
}
#ifdef DEBUG
@ -667,14 +594,8 @@ nsCSSExpandedDataBlock::DoAssertInitialState()
mPropertiesImportant.AssertIsEmpty("not initial state");
for (PRUint32 i = 0; i < eCSSProperty_COUNT_no_shorthands; ++i) {
void *prop = PropertyAt(nsCSSProperty(i));
switch (nsCSSProps::kTypeTable[i]) {
case eCSSType_Value: {
nsCSSValue* val = static_cast<nsCSSValue*>(prop);
NS_ASSERTION(val->GetUnit() == eCSSUnit_Null,
"not initial state");
} break;
}
NS_ASSERTION(PropertyAt(nsCSSProperty(i))->GetUnit() == eCSSUnit_Null,
"not initial state");
}
}
#endif

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

@ -82,30 +82,19 @@ public:
/**
* 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. This is either an |nsCSSValue*|, |nsCSSRect*|, or an
* |nsCSSValueList**|, etc.
* property.
*
* Inefficient (by design).
*
* Must not be called for shorthands.
*/
const void* StorageFor(nsCSSProperty aProperty) const;
const nsCSSValue* ValueFor(nsCSSProperty aProperty) const;
/**
* As above, but provides mutable access to a value slot.
*/
void* SlotForValue(nsCSSProperty aProperty) {
return const_cast<void*>(StorageFor(aProperty));
}
/**
* A set of slightly more typesafe helpers for the above. All
* return null if the value is not present.
*/
const nsCSSValue* ValueStorageFor(nsCSSProperty aProperty) const {
NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] == eCSSType_Value,
"type mismatch");
return static_cast<const nsCSSValue*>(StorageFor(aProperty));
nsCSSValue* SlotForValue(nsCSSProperty aProperty) {
return const_cast<nsCSSValue*>(ValueFor(aProperty));
}
/**
@ -120,16 +109,12 @@ public:
/**
* Does a fast move of aSource to aDest. The previous value in
* aDest is cleanly destroyed, and aSource is cleared. *aChanged
* is set true if, before the copy, the value at aSource compares
* unequal to the value at aDest.
*
* This can only be used for non-shorthand properties. The caller
* must make sure that the source and destination locations point
* to the right kind of objects for the property id.
* aDest is cleanly destroyed, and aSource is cleared. Returns
* true if, before the copy, the value at aSource compared unequal
* to the value at aDest; false otherwise.
*/
static void MoveValue(void *aSource, void *aDest, nsCSSProperty aPropID,
PRBool* aChanged);
static PRBool MoveValue(nsCSSValue* aSource, nsCSSValue* aDest);
private:
PRInt32 mStyleBits; // the structs for which we have data, according to
@ -228,18 +213,16 @@ public:
* existing !important property regardless of its own importance
* if |aOverrideImportant| is true.
*
* Sets |*aChanged| to true if something changed, leaves it
* unmodified otherwise. Calls |ValueAppended| on |aDeclaration|
* if the property was not previously set, or in any case if
* |aMustCallValueAppended| is true.
* 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.
*/
void TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
nsCSSProperty aPropID,
PRBool aIsImportant,
PRBool aOverrideImportant,
PRBool aMustCallValueAppended,
mozilla::css::Declaration* aDeclaration,
PRBool* aChanged);
PRBool TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
nsCSSProperty aPropID,
PRBool aIsImportant,
PRBool aOverrideImportant,
PRBool aMustCallValueAppended,
mozilla::css::Declaration* aDeclaration);
void AssertInitialState() {
#ifdef DEBUG
@ -262,13 +245,12 @@ private:
/**
* Worker for TransferFromBlock; cannot be used with shorthands.
*/
void DoTransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
nsCSSProperty aPropID,
PRBool aIsImportant,
PRBool aOverrideImportant,
PRBool aMustCallValueAppended,
mozilla::css::Declaration* aDeclaration,
PRBool* aChanged);
PRBool DoTransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
nsCSSProperty aPropID,
PRBool aIsImportant,
PRBool aOverrideImportant,
PRBool aMustCallValueAppended,
mozilla::css::Declaration* aDeclaration);
#ifdef DEBUG
void DoAssertInitialState();
@ -293,12 +275,12 @@ private:
public:
/*
* Return the storage location within |this| of the value of the
* property (i.e., either an |nsCSSValue*|, |nsCSSRect*|, or
* |nsCSSValueList**| (etc.).
* property |aProperty|.
*/
void* PropertyAt(nsCSSProperty aProperty) {
nsCSSValue* PropertyAt(nsCSSProperty aProperty) {
size_t offset = nsCSSExpandedDataBlock::kOffsetTable[aProperty];
return reinterpret_cast<void*>(reinterpret_cast<char*>(this) + offset);
return reinterpret_cast<nsCSSValue*>(reinterpret_cast<char*>(this) +
offset);
}
void SetPropertyBit(nsCSSProperty aProperty) {

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

@ -1124,15 +1124,15 @@ CSSParserImpl::ParseProperty(const nsCSSProperty aPropID,
// same importance level, then we can just copy our parsed value
// directly into the declaration without going through the whole
// expand/compress thing.
void* valueSlot = aDeclaration->SlotForValue(aPropID, aIsImportant);
nsCSSValue* valueSlot = aDeclaration->SlotForValue(aPropID, aIsImportant);
if (valueSlot) {
nsCSSCompressedDataBlock::MoveValue(mTempData.PropertyAt(aPropID),
valueSlot, aPropID, aChanged);
*aChanged = nsCSSCompressedDataBlock::
MoveValue(mTempData.PropertyAt(aPropID), valueSlot);
mTempData.ClearPropertyBit(aPropID);
} else {
aDeclaration->ExpandTo(&mData);
mData.TransferFromBlock(mTempData, aPropID, aIsImportant, PR_TRUE,
PR_FALSE, aDeclaration, aChanged);
*aChanged = mData.TransferFromBlock(mTempData, aPropID, aIsImportant,
PR_TRUE, PR_FALSE, aDeclaration);
aDeclaration->CompressFrom(&mData);
}
CLEAR_ERROR();
@ -4031,9 +4031,10 @@ CSSParserImpl::ParseDeclaration(css::Declaration* aDeclaration,
return PR_FALSE;
}
mData.TransferFromBlock(mTempData, propID, status == ePriority_Important,
PR_FALSE, aMustCallValueAppended,
aDeclaration, aChanged);
*aChanged |= mData.TransferFromBlock(mTempData, propID,
status == ePriority_Important,
PR_FALSE, aMustCallValueAppended,
aDeclaration);
return PR_TRUE;
}
@ -4997,9 +4998,6 @@ CSSParserImpl::AppendValue(nsCSSProperty aPropID, const nsCSSValue& aValue)
{
NS_ASSERTION(0 <= aPropID && aPropID < eCSSProperty_COUNT_no_shorthands,
"property out of range");
NS_ASSERTION(nsCSSProps::kTypeTable[aPropID] == eCSSType_Value,
nsPrintfCString(64, "type error (property=\'%s\')",
nsCSSProps::GetStringValue(aPropID).get()).get());
nsCSSValue& storage =
*static_cast<nsCSSValue*>(mTempData.PropertyAt(aPropID));
storage = aValue;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -51,8 +51,8 @@
enum nsCSSProperty {
eCSSProperty_UNKNOWN = -1,
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
eCSSProperty_##id_,
#include "nsCSSPropList.h"
#undef CSS_PROP
@ -79,12 +79,6 @@ enum nsCSSProperty {
eCSSPropertyExtra_x_none_value
};
// The types of values that can be in the nsCSS*/nsRuleData* structs.
// See nsCSSPropList.h for uses.
enum nsCSSType {
eCSSType_Value
};
// The "descriptors" that can appear in a @font-face rule.
// They have the syntax of properties but different value rules.
// Keep in sync with kCSSRawFontDescs in nsCSSProps.cpp and

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

@ -60,7 +60,7 @@ extern const char* const kCSSRawProperties[];
// define an array of all CSS properties
const char* const kCSSRawProperties[] = {
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
#name_,
#include "nsCSSPropList.h"
@ -1480,7 +1480,7 @@ nsCSSProps::ValueToKeyword(PRInt32 aValue, const PRInt32 aTable[])
/* static */ const PRInt32* const
nsCSSProps::kKeywordTableTable[eCSSProperty_COUNT_no_shorthands] = {
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
kwtable_,
#include "nsCSSPropList.h"
@ -1520,20 +1520,11 @@ PRBool nsCSSProps::GetColorName(PRInt32 aPropValue, nsCString &aStr)
return rv;
}
// define array of all CSS property types
const nsCSSType nsCSSProps::kTypeTable[eCSSProperty_COUNT_no_shorthands] = {
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
type_,
#include "nsCSSPropList.h"
#undef CSS_PROP
};
const nsStyleStructID nsCSSProps::kSIDTable[eCSSProperty_COUNT_no_shorthands] = {
// Note that this uses the special BackendOnly style struct ID
// (which does need to be valid for storing in the
// nsCSSCompressedDataBlock::mStyleBits bitfield).
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
eStyleStruct_##stylestruct_,
@ -1544,7 +1535,7 @@ const nsStyleStructID nsCSSProps::kSIDTable[eCSSProperty_COUNT_no_shorthands] =
const nsStyleAnimType
nsCSSProps::kAnimTypeTable[eCSSProperty_COUNT_no_shorthands] = {
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
animtype_,
#include "nsCSSPropList.h"
@ -1553,7 +1544,7 @@ nsCSSProps::kAnimTypeTable[eCSSProperty_COUNT_no_shorthands] = {
const ptrdiff_t
nsCSSProps::kStyleStructOffsetTable[eCSSProperty_COUNT_no_shorthands] = {
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
stylestructoffset_,
#include "nsCSSPropList.h"
@ -1561,7 +1552,7 @@ nsCSSProps::kStyleStructOffsetTable[eCSSProperty_COUNT_no_shorthands] = {
};
const PRUint32 nsCSSProps::kFlagsTable[eCSSProperty_COUNT] = {
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
flags_,
#include "nsCSSPropList.h"

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

@ -184,7 +184,6 @@ public:
// Ditto but as a string, return "" when not found.
static const nsAFlatCString& ValueToKeyword(PRInt32 aValue, const PRInt32 aTable[]);
static const nsCSSType kTypeTable[eCSSProperty_COUNT_no_shorthands];
static const nsStyleStructID kSIDTable[eCSSProperty_COUNT_no_shorthands];
static const PRInt32* const kKeywordTableTable[eCSSProperty_COUNT_no_shorthands];
static const nsStyleAnimType kAnimTypeTable[eCSSProperty_COUNT_no_shorthands];

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

@ -337,7 +337,7 @@ nsDOMCSSDeclaration::RemoveProperty(const nsCSSProperty aPropID)
// nsIDOMCSS2Properties
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
NS_IMETHODIMP \
nsDOMCSSDeclaration::Get##method_(nsAString& aValue) \
@ -353,16 +353,16 @@ nsDOMCSSDeclaration::RemoveProperty(const nsCSSProperty aPropID)
#define CSS_PROP_LIST_EXCLUDE_INTERNAL
#define CSS_PROP_SHORTHAND(name_, id_, method_, flags_) \
CSS_PROP(name_, id_, method_, flags_, X, X, X, X, X, X, X)
CSS_PROP(name_, id_, method_, flags_, X, X, X, X, X, X)
#include "nsCSSPropList.h"
// Aliases
CSS_PROP(X, opacity, MozOpacity, X, X, X, X, X, X, X, X)
CSS_PROP(X, outline, MozOutline, X, X, X, X, X, X, X, X)
CSS_PROP(X, outline_color, MozOutlineColor, X, X, X, X, X, X, X, X)
CSS_PROP(X, outline_style, MozOutlineStyle, X, X, X, X, X, X, X, X)
CSS_PROP(X, outline_width, MozOutlineWidth, X, X, X, X, X, X, X, X)
CSS_PROP(X, outline_offset, MozOutlineOffset, X, X, X, X, X, X, X, X)
CSS_PROP(X, opacity, MozOpacity, X, X, X, X, X, X, X)
CSS_PROP(X, outline, MozOutline, X, X, X, X, X, X, X)
CSS_PROP(X, outline_color, MozOutlineColor, X, X, X, X, X, X, X)
CSS_PROP(X, outline_style, MozOutlineStyle, X, X, X, X, X, X, X)
CSS_PROP(X, outline_width, MozOutlineWidth, X, X, X, X, X, X, X)
CSS_PROP(X, outline_offset, MozOutlineOffset, X, X, X, X, X, X, X)
#undef CSS_PROP_SHORTHAND
#undef CSS_PROP_LIST_EXCLUDE_INTERNAL

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

@ -50,9 +50,9 @@ struct PropertyOffsetInfo {
const PropertyOffsetInfo kOffsetTable[eCSSProperty_COUNT_no_shorthands] = {
#define CSS_PROP_BACKENDONLY(name_, id_, method_, flags_, datastruct_, \
member_, type_, kwtable_) \
member_, kwtable_) \
{ size_t(-1), size_t(-1) },
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
{ offsetof(nsRuleData, m##datastruct_##Data), \
offsetof(nsRuleData##datastruct_, member_) },
@ -63,8 +63,8 @@ const PropertyOffsetInfo kOffsetTable[eCSSProperty_COUNT_no_shorthands] = {
} // anon namespace
void*
nsRuleData::StorageFor(nsCSSProperty aProperty)
nsCSSValue*
nsRuleData::ValueFor(nsCSSProperty aProperty)
{
NS_ABORT_IF_FALSE(aProperty < eCSSProperty_COUNT_no_shorthands,
"invalid or shorthand property");
@ -77,5 +77,5 @@ nsRuleData::StorageFor(nsCSSProperty aProperty)
(reinterpret_cast<char*>(this) + offsets.struct_offset);
NS_ABORT_IF_FALSE(cssstruct, "substructure pointer should never be null");
return reinterpret_cast<void*>(cssstruct + offsets.member_offset);
return reinterpret_cast<nsCSSValue*>(cssstruct + offsets.member_offset);
}

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

@ -104,10 +104,11 @@ struct nsRuleData
~nsRuleData() {}
/**
* Non-typesafe worker routine for the above five value retrieval
* functions. Avoid using.
* Return a pointer to the value object within |this| corresponding
* to property |aProperty|, or null if storage for that property has
* not been allocated.
*/
void* StorageFor(nsCSSProperty aProperty);
nsCSSValue* ValueFor(nsCSSProperty aProperty);
};
#endif

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

@ -1365,10 +1365,8 @@ nsRuleNode::PropagateDependentBit(PRUint32 aBit, nsRuleNode* aHighestNode)
struct PropertyCheckData {
size_t offset;
// These duplicate the same data in nsCSSProps::kTypeTable and
// kFlagsTable, except that we have some extra entries for
// CSS_PROP_INCLUDE_NOT_CSS.
nsCSSType type;
// These duplicate the data in nsCSSProps::kFlagsTable, except that
// we have some extra entries for CSS_PROP_INCLUDE_NOT_CSS.
PRUint32 flags;
};
@ -1494,8 +1492,8 @@ CheckTextCallback(const nsRuleDataStruct& aData,
// structs but not nsCSS*
#define CSS_PROP_INCLUDE_NOT_CSS
#define CHECK_DATA_FOR_PROPERTY(name_, id_, method_, flags_, datastruct_, member_, type_, kwtable_, stylestructoffset_, animtype_) \
{ offsetof(nsRuleData##datastruct_, member_), type_, flags_ },
#define CHECK_DATA_FOR_PROPERTY(name_, id_, method_, flags_, datastruct_, member_, kwtable_, stylestructoffset_, animtype_) \
{ offsetof(nsRuleData##datastruct_, member_), flags_ },
static const PropertyCheckData FontCheckProperties[] = {
#define CSS_PROP_FONT CHECK_DATA_FOR_PROPERTY
@ -1735,20 +1733,12 @@ nsRuleNode::CheckSpecifiedProperties(const nsStyleStructID aSID,
for (const PropertyCheckData *prop = structData->props,
*prop_end = prop + structData->nprops;
prop != prop_end;
++prop)
switch (prop->type) {
++prop) {
case eCSSType_Value:
++total;
ExamineCSSValue(ValueAtOffset(aRuleDataStruct, prop->offset),
specified, inherited);
break;
default:
NS_NOTREACHED("unknown type");
break;
}
++total;
ExamineCSSValue(ValueAtOffset(aRuleDataStruct, prop->offset),
specified, inherited);
}
#if 0
printf("CheckSpecifiedProperties: SID=%d total=%d spec=%d inh=%d.\n",
@ -2063,18 +2053,8 @@ UnsetPropertiesWithoutFlags(const nsStyleStructID aSID,
*prop_end = prop + structData->nprops;
prop != prop_end;
++prop) {
if ((prop->flags & aFlags) == aFlags)
// Don't unset the property.
continue;
switch (prop->type) {
case eCSSType_Value:
ValueAtOffset(aRuleDataStruct, prop->offset).Reset();
break;
default:
NS_NOTREACHED("unknown type");
break;
}
if ((prop->flags & aFlags) != aFlags)
ValueAtOffset(aRuleDataStruct, prop->offset).Reset();
}
}

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

@ -1738,93 +1738,67 @@ PRBool
nsStyleAnimation::UncomputeValue(nsCSSProperty aProperty,
nsPresContext* aPresContext,
const Value& aComputedValue,
void* aSpecifiedValue)
nsCSSValue& aSpecifiedValue)
{
NS_ABORT_IF_FALSE(aPresContext, "null pres context");
switch (aComputedValue.GetUnit()) {
case eUnit_Normal:
NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] == eCSSType_Value,
"type mismatch");
static_cast<nsCSSValue*>(aSpecifiedValue)->SetNormalValue();
aSpecifiedValue.SetNormalValue();
break;
case eUnit_Auto:
NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] == eCSSType_Value,
"type mismatch");
static_cast<nsCSSValue*>(aSpecifiedValue)->SetAutoValue();
aSpecifiedValue.SetAutoValue();
break;
case eUnit_None:
NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] == eCSSType_Value,
"type mismatch");
static_cast<nsCSSValue*>(aSpecifiedValue)->SetNoneValue();
aSpecifiedValue.SetNoneValue();
break;
case eUnit_Enumerated:
case eUnit_Visibility:
NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] == eCSSType_Value,
"type mismatch");
static_cast<nsCSSValue*>(aSpecifiedValue)->
aSpecifiedValue.
SetIntValue(aComputedValue.GetIntValue(), eCSSUnit_Enumerated);
break;
case eUnit_Integer:
NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] == eCSSType_Value,
"type mismatch");
static_cast<nsCSSValue*>(aSpecifiedValue)->
aSpecifiedValue.
SetIntValue(aComputedValue.GetIntValue(), eCSSUnit_Integer);
break;
case eUnit_Coord: {
NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] == eCSSType_Value,
"type mismatch");
nscoordToCSSValue(aComputedValue.GetCoordValue(),
*static_cast<nsCSSValue*>(aSpecifiedValue));
case eUnit_Coord:
nscoordToCSSValue(aComputedValue.GetCoordValue(), aSpecifiedValue);
break;
}
case eUnit_Percent:
NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] == eCSSType_Value,
"type mismatch");
static_cast<nsCSSValue*>(aSpecifiedValue)->
SetPercentValue(aComputedValue.GetPercentValue());
aSpecifiedValue.SetPercentValue(aComputedValue.GetPercentValue());
break;
case eUnit_Float:
NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] == eCSSType_Value,
"type mismatch");
static_cast<nsCSSValue*>(aSpecifiedValue)->
aSpecifiedValue.
SetFloatValue(aComputedValue.GetFloatValue(), eCSSUnit_Number);
break;
case eUnit_Color:
// colors can be alone, or part of a paint server
NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] == eCSSType_Value,
"type mismatch");
static_cast<nsCSSValue*>(aSpecifiedValue)->
SetColorValue(aComputedValue.GetColorValue());
aSpecifiedValue.SetColorValue(aComputedValue.GetColorValue());
break;
case eUnit_CSSValuePair: {
NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] == eCSSType_Value,
"type mismatch");
// Rule node processing expects pair values to be collapsed to a
// single value if both halves would be equal, for most but not
// all properties. At present, all animatable properties that
// use pairs do expect collapsing.
const nsCSSValuePair* pair = aComputedValue.GetCSSValuePairValue();
if (pair->mXValue == pair->mYValue) {
*static_cast<nsCSSValue*>(aSpecifiedValue) = pair->mXValue;
aSpecifiedValue = pair->mXValue;
} else {
static_cast<nsCSSValue*>(aSpecifiedValue)->
SetPairValue(pair);
aSpecifiedValue.SetPairValue(pair);
}
} break;
case eUnit_CSSRect: {
nsCSSRect& rect = static_cast<nsCSSValue*>(aSpecifiedValue)->
SetRectValue();
nsCSSRect& rect = aSpecifiedValue.SetRectValue();
rect = *aComputedValue.GetCSSRectValue();
} break;
case eUnit_Dasharray:
case eUnit_Shadow:
case eUnit_Transform:
static_cast<nsCSSValue*>(aSpecifiedValue)->
aSpecifiedValue.
SetDependentListValue(aComputedValue.GetCSSValueListValue());
break;
case eUnit_CSSValuePairList:
static_cast<nsCSSValue*>(aSpecifiedValue)->
aSpecifiedValue.
SetDependentPairListValue(aComputedValue.GetCSSValuePairListValue());
break;
default:
@ -1847,30 +1821,12 @@ nsStyleAnimation::UncomputeValue(nsCSSProperty aProperty,
return PR_TRUE;
}
nsCSSValue val;
void *storage;
switch (nsCSSProps::kTypeTable[aProperty]) {
case eCSSType_Value:
storage = &val;
break;
default:
NS_ABORT_IF_FALSE(PR_FALSE, "unexpected case");
storage = nsnull;
break;
}
if (!nsStyleAnimation::UncomputeValue(aProperty, aPresContext,
aComputedValue, storage)) {
aComputedValue, val)) {
return PR_FALSE;
}
switch (nsCSSProps::kTypeTable[aProperty]) {
case eCSSType_Value:
val.AppendToString(aProperty, aSpecifiedValue);
break;
default:
NS_ABORT_IF_FALSE(PR_FALSE, "unexpected case");
return PR_FALSE;
}
val.AppendToString(aProperty, aSpecifiedValue);
return PR_TRUE;
}

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

@ -53,6 +53,7 @@
class nsIContent;
class nsPresContext;
class nsStyleContext;
class nsCSSValue;
struct nsCSSValueList;
struct nsCSSValuePair;
struct nsCSSValuePairList;
@ -178,14 +179,10 @@ public:
/**
* Creates a specified value for the given computed value.
*
* The first form fills in one of the nsCSSType types into the void*;
* for some types this means that the void* is pointing to memory
* owned by the nsStyleAnimation::Value. (For all complex types, the
* nsStyleAnimation::Value owns the necessary objects so that the
* caller does not need to do anything to free them. However, this
* means that callers using the void* variant must keep
* |aComputedValue| alive longer than the structure into which they've
* filled the value.)
* The first overload fills in an nsCSSValue object; the second
* produces a string. The nsCSSValue result may depend on objects
* owned by the |aComputedValue| object, so users of that variant
* must keep |aComputedValue| alive longer than |aSpecifiedValue|.
*
* @param aProperty The property whose value we're uncomputing.
* @param aPresContext The presentation context for the document in
@ -197,7 +194,7 @@ public:
static PRBool UncomputeValue(nsCSSProperty aProperty,
nsPresContext* aPresContext,
const Value& aComputedValue,
void* aSpecifiedValue);
nsCSSValue& aSpecifiedValue);
static PRBool UncomputeValue(nsCSSProperty aProperty,
nsPresContext* aPresContext,
const Value& aComputedValue,

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

@ -241,12 +241,12 @@ AnimValuesStyleRule::MapRuleInfoInto(nsRuleData* aRuleData)
if (aRuleData->mSIDs & nsCachedStyleData::GetBitForSID(
nsCSSProps::kSIDTable[cv.mProperty]))
{
void *prop = aRuleData->StorageFor(cv.mProperty);
nsCSSValue *prop = aRuleData->ValueFor(cv.mProperty);
#ifdef DEBUG
PRBool ok =
#endif
nsStyleAnimation::UncomputeValue(cv.mProperty, aRuleData->mPresContext,
cv.mValue, prop);
cv.mValue, *prop);
NS_ABORT_IF_FALSE(ok, "could not store computed value");
}
}

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

@ -48,7 +48,7 @@ struct PropertyInfo {
const PropertyInfo gLonghandProperties[] = {
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
{ #name_, #method_ },
@ -66,7 +66,7 @@ const PropertyInfo gLonghandProperties[] = {
const char* gLonghandPropertiesWithDOMProp[] = {
#define CSS_PROP_LIST_EXCLUDE_INTERNAL
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
#name_,