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 // We know the declaration is not !important, so we can use
// GetNormalBlock(). // GetNormalBlock().
const nsCSSValue *fsaVal = const nsCSSValue *fsaVal =
declaration->GetNormalBlock()-> declaration->GetNormalBlock()->ValueFor(eCSSProperty_font_size_adjust);
ValueStorageFor(eCSSProperty_font_size_adjust);
if (!fsaVal || (fsaVal->GetUnit() != eCSSUnit_None && if (!fsaVal || (fsaVal->GetUnit() != eCSSUnit_None &&
fsaVal->GetUnit() != eCSSUnit_System_Font)) { fsaVal->GetUnit() != eCSSUnit_System_Font)) {
// We got an all-property value or a syntax error. The spec says // We got an all-property value or a syntax error. The spec says

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

@ -39,22 +39,22 @@
#include "nsICSSDeclaration.h" #include "nsICSSDeclaration.h"
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \ #define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \ kwtable_, stylestruct_, stylestructoffset_, animtype_) \
static const nsCSSProperty QS_CSS_PROP_##method_ = eCSSProperty_##id_; static const nsCSSProperty QS_CSS_PROP_##method_ = eCSSProperty_##id_;
#define CSS_PROP_LIST_EXCLUDE_INTERNAL #define CSS_PROP_LIST_EXCLUDE_INTERNAL
#define CSS_PROP_SHORTHAND(name_, id_, method_, flags_) \ #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" #include "nsCSSPropList.h"
// Aliases // Aliases
CSS_PROP(X, opacity, MozOpacity, 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, 0, 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, 0, 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, 0, 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, 0, 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, 0, 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_SHORTHAND
#undef CSS_PROP_LIST_EXCLUDE_INTERNAL #undef CSS_PROP_LIST_EXCLUDE_INTERNAL

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

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

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

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

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

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

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

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

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

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

@ -51,8 +51,8 @@
enum nsCSSProperty { enum nsCSSProperty {
eCSSProperty_UNKNOWN = -1, eCSSProperty_UNKNOWN = -1,
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \ #define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \ kwtable_, stylestruct_, stylestructoffset_, animtype_) \
eCSSProperty_##id_, eCSSProperty_##id_,
#include "nsCSSPropList.h" #include "nsCSSPropList.h"
#undef CSS_PROP #undef CSS_PROP
@ -79,12 +79,6 @@ enum nsCSSProperty {
eCSSPropertyExtra_x_none_value 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. // The "descriptors" that can appear in a @font-face rule.
// They have the syntax of properties but different value rules. // They have the syntax of properties but different value rules.
// Keep in sync with kCSSRawFontDescs in nsCSSProps.cpp and // 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 // define an array of all CSS properties
const char* const kCSSRawProperties[] = { 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_) \ kwtable_, stylestruct_, stylestructoffset_, animtype_) \
#name_, #name_,
#include "nsCSSPropList.h" #include "nsCSSPropList.h"
@ -1480,7 +1480,7 @@ nsCSSProps::ValueToKeyword(PRInt32 aValue, const PRInt32 aTable[])
/* static */ const PRInt32* const /* static */ const PRInt32* const
nsCSSProps::kKeywordTableTable[eCSSProperty_COUNT_no_shorthands] = { 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_, stylestruct_, stylestructoffset_, animtype_) \
kwtable_, kwtable_,
#include "nsCSSPropList.h" #include "nsCSSPropList.h"
@ -1520,20 +1520,11 @@ PRBool nsCSSProps::GetColorName(PRInt32 aPropValue, nsCString &aStr)
return rv; 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] = { const nsStyleStructID nsCSSProps::kSIDTable[eCSSProperty_COUNT_no_shorthands] = {
// Note that this uses the special BackendOnly style struct ID // Note that this uses the special BackendOnly style struct ID
// (which does need to be valid for storing in the // (which does need to be valid for storing in the
// nsCSSCompressedDataBlock::mStyleBits bitfield). // 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_) \ kwtable_, stylestruct_, stylestructoffset_, animtype_) \
eStyleStruct_##stylestruct_, eStyleStruct_##stylestruct_,
@ -1544,7 +1535,7 @@ const nsStyleStructID nsCSSProps::kSIDTable[eCSSProperty_COUNT_no_shorthands] =
const nsStyleAnimType const nsStyleAnimType
nsCSSProps::kAnimTypeTable[eCSSProperty_COUNT_no_shorthands] = { 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_) \ kwtable_, stylestruct_, stylestructoffset_, animtype_) \
animtype_, animtype_,
#include "nsCSSPropList.h" #include "nsCSSPropList.h"
@ -1553,7 +1544,7 @@ nsCSSProps::kAnimTypeTable[eCSSProperty_COUNT_no_shorthands] = {
const ptrdiff_t const ptrdiff_t
nsCSSProps::kStyleStructOffsetTable[eCSSProperty_COUNT_no_shorthands] = { 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_) \ kwtable_, stylestruct_, stylestructoffset_, animtype_) \
stylestructoffset_, stylestructoffset_,
#include "nsCSSPropList.h" #include "nsCSSPropList.h"
@ -1561,7 +1552,7 @@ nsCSSProps::kStyleStructOffsetTable[eCSSProperty_COUNT_no_shorthands] = {
}; };
const PRUint32 nsCSSProps::kFlagsTable[eCSSProperty_COUNT] = { 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_) \ kwtable_, stylestruct_, stylestructoffset_, animtype_) \
flags_, flags_,
#include "nsCSSPropList.h" #include "nsCSSPropList.h"

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

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

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

@ -337,7 +337,7 @@ nsDOMCSSDeclaration::RemoveProperty(const nsCSSProperty aPropID)
// nsIDOMCSS2Properties // nsIDOMCSS2Properties
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \ #define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \ kwtable_, stylestruct_, stylestructoffset_, animtype_) \
NS_IMETHODIMP \ NS_IMETHODIMP \
nsDOMCSSDeclaration::Get##method_(nsAString& aValue) \ nsDOMCSSDeclaration::Get##method_(nsAString& aValue) \
@ -353,16 +353,16 @@ nsDOMCSSDeclaration::RemoveProperty(const nsCSSProperty aPropID)
#define CSS_PROP_LIST_EXCLUDE_INTERNAL #define CSS_PROP_LIST_EXCLUDE_INTERNAL
#define CSS_PROP_SHORTHAND(name_, id_, method_, flags_) \ #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" #include "nsCSSPropList.h"
// Aliases // Aliases
CSS_PROP(X, opacity, MozOpacity, 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, 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, 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, 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, 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, X) CSS_PROP(X, outline_offset, MozOutlineOffset, X, X, X, X, X, X, X)
#undef CSS_PROP_SHORTHAND #undef CSS_PROP_SHORTHAND
#undef CSS_PROP_LIST_EXCLUDE_INTERNAL #undef CSS_PROP_LIST_EXCLUDE_INTERNAL

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

@ -50,9 +50,9 @@ struct PropertyOffsetInfo {
const PropertyOffsetInfo kOffsetTable[eCSSProperty_COUNT_no_shorthands] = { const PropertyOffsetInfo kOffsetTable[eCSSProperty_COUNT_no_shorthands] = {
#define CSS_PROP_BACKENDONLY(name_, id_, method_, flags_, datastruct_, \ #define CSS_PROP_BACKENDONLY(name_, id_, method_, flags_, datastruct_, \
member_, type_, kwtable_) \ member_, kwtable_) \
{ size_t(-1), size_t(-1) }, { 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_) \ kwtable_, stylestruct_, stylestructoffset_, animtype_) \
{ offsetof(nsRuleData, m##datastruct_##Data), \ { offsetof(nsRuleData, m##datastruct_##Data), \
offsetof(nsRuleData##datastruct_, member_) }, offsetof(nsRuleData##datastruct_, member_) },
@ -63,8 +63,8 @@ const PropertyOffsetInfo kOffsetTable[eCSSProperty_COUNT_no_shorthands] = {
} // anon namespace } // anon namespace
void* nsCSSValue*
nsRuleData::StorageFor(nsCSSProperty aProperty) nsRuleData::ValueFor(nsCSSProperty aProperty)
{ {
NS_ABORT_IF_FALSE(aProperty < eCSSProperty_COUNT_no_shorthands, NS_ABORT_IF_FALSE(aProperty < eCSSProperty_COUNT_no_shorthands,
"invalid or shorthand property"); "invalid or shorthand property");
@ -77,5 +77,5 @@ nsRuleData::StorageFor(nsCSSProperty aProperty)
(reinterpret_cast<char*>(this) + offsets.struct_offset); (reinterpret_cast<char*>(this) + offsets.struct_offset);
NS_ABORT_IF_FALSE(cssstruct, "substructure pointer should never be null"); 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() {} ~nsRuleData() {}
/** /**
* Non-typesafe worker routine for the above five value retrieval * Return a pointer to the value object within |this| corresponding
* functions. Avoid using. * to property |aProperty|, or null if storage for that property has
* not been allocated.
*/ */
void* StorageFor(nsCSSProperty aProperty); nsCSSValue* ValueFor(nsCSSProperty aProperty);
}; };
#endif #endif

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

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

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

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

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

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

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

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

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

@ -48,7 +48,7 @@ struct PropertyInfo {
const PropertyInfo gLonghandProperties[] = { 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_) \ kwtable_, stylestruct_, stylestructoffset_, animtype_) \
{ #name_, #method_ }, { #name_, #method_ },
@ -66,7 +66,7 @@ const PropertyInfo gLonghandProperties[] = {
const char* gLonghandPropertiesWithDOMProp[] = { const char* gLonghandPropertiesWithDOMProp[] = {
#define CSS_PROP_LIST_EXCLUDE_INTERNAL #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_) \ kwtable_, stylestruct_, stylestructoffset_, animtype_) \
#name_, #name_,