Add previously-skipped border and outline properties to nsStyleAnimation. (Bug 521292) r=dholbert, bzbarsky

This commit is contained in:
L. David Baron 2009-10-13 19:38:20 -07:00
Родитель 04d92dc897
Коммит 7e7105f6e9
4 изменённых файлов: 93 добавлений и 20 удалений

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

@ -576,10 +576,8 @@ CSS_PROP_BORDER(
mBorderColor.mBottom,
eCSSType_Value,
kBorderColorKTable,
// FIXME: should be animatable (but currently involves complex split
// between color and an extra bit on the style, all private members)
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
eStyleAnimType_Custom)
CSS_PROP_BORDER(
-moz-border-bottom-colors,
border_bottom_colors,
@ -613,7 +611,7 @@ CSS_PROP_BORDER(
eCSSType_Value,
kBorderWidthKTable,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
eStyleAnimType_Custom)
CSS_PROP_TABLEBORDER(
border-collapse,
border_collapse,
@ -721,10 +719,8 @@ CSS_PROP_BORDER(
mBorderColor.mLeft,
eCSSType_Value,
kBorderColorKTable,
// FIXME: should be animatable (but currently involves complex split
// between color and an extra bit on the style, all private members)
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
eStyleAnimType_Custom)
CSS_PROP_BORDER(
border-left-color-ltr-source,
border_left_color_ltr_source,
@ -822,7 +818,7 @@ CSS_PROP_BORDER(
eCSSType_Value,
kBorderWidthKTable,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
eStyleAnimType_Custom)
CSS_PROP_BORDER(
border-left-width-ltr-source,
border_left_width_ltr_source,
@ -869,10 +865,8 @@ CSS_PROP_BORDER(
mBorderColor.mRight,
eCSSType_Value,
kBorderColorKTable,
// FIXME: should be animatable (but currently involves complex split
// between color and an extra bit on the style, all private members)
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
eStyleAnimType_Custom)
CSS_PROP_BORDER(
border-right-color-ltr-source,
border_right_color_ltr_source,
@ -970,7 +964,7 @@ CSS_PROP_BORDER(
eCSSType_Value,
kBorderWidthKTable,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
eStyleAnimType_Custom)
CSS_PROP_BORDER(
border-right-width-ltr-source,
border_right_width_ltr_source,
@ -1086,10 +1080,8 @@ CSS_PROP_BORDER(
mBorderColor.mTop,
eCSSType_Value,
kBorderColorKTable,
// FIXME: should be animatable (but currently involves complex split
// between color and an extra bit on the style, all private members)
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
eStyleAnimType_Custom)
CSS_PROP_BORDER(
-moz-border-top-colors,
border_top_colors,
@ -1123,7 +1115,7 @@ CSS_PROP_BORDER(
eCSSType_Value,
kBorderWidthKTable,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
eStyleAnimType_Custom)
CSS_PROP_SHORTHAND(
border-width,
border_width,
@ -1855,10 +1847,8 @@ CSS_PROP_OUTLINE(
mOutlineColor,
eCSSType_Value,
kOutlineColorKTable,
// FIXME: should be animatable (but currently involves complex split
// between color and an extra bit on the style, all private members)
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
eStyleAnimType_Custom)
CSS_PROP_OUTLINE(
outline-style,
outline_style,

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

@ -69,6 +69,10 @@
* Types of animatable values.
*/
enum nsStyleAnimType {
// requires a custom implementation in
// nsStyleAnimation::ExtractComputedValue
eStyleAnimType_Custom,
// nsStyleCoord with animatable values
eStyleAnimType_Coord,

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

@ -535,6 +535,21 @@ StyleDataAtOffset(void* aStyleStruct, ptrdiff_t aOffset)
return reinterpret_cast<char*>(aStyleStruct) + aOffset;
}
static void
ExtractBorderColor(nsStyleContext* aStyleContext, const void* aStyleBorder,
PRUint8 aSide, nsStyleCoord& aComputedValue)
{
nscolor color;
PRBool foreground;
static_cast<const nsStyleBorder*>(aStyleBorder)->
GetBorderColor(aSide, color, foreground);
if (foreground) {
// FIXME: should add test for this
color = aStyleContext->GetStyleColor()->mColor;
}
aComputedValue.SetColorValue(color);
}
PRBool
nsStyleAnimation::ExtractComputedValue(nsCSSProperty aProperty,
nsStyleContext* aStyleContext,
@ -546,9 +561,64 @@ nsStyleAnimation::ExtractComputedValue(nsCSSProperty aProperty,
const void* styleStruct =
aStyleContext->GetStyleData(nsCSSProps::kSIDTable[aProperty]);
ptrdiff_t ssOffset = nsCSSProps::kStyleStructOffsetTable[aProperty];
NS_ABORT_IF_FALSE(0 <= ssOffset, "must be dealing with animatable property");
nsStyleAnimType animType = nsCSSProps::kAnimTypeTable[aProperty];
NS_ABORT_IF_FALSE(0 <= ssOffset || animType == eStyleAnimType_Custom,
"must be dealing with animatable property");
switch (animType) {
case eStyleAnimType_Custom:
switch (aProperty) {
// For border-width, ignore the border-image business (which
// only exists until we update our implementation to the current
// spec) and use GetComputedBorder
#define BORDER_WIDTH_CASE(prop_, side_) \
case prop_: \
aComputedValue.SetCoordValue( \
static_cast<const nsStyleBorder*>(styleStruct)-> \
GetComputedBorder().side_); \
break;
BORDER_WIDTH_CASE(eCSSProperty_border_bottom_width, bottom)
BORDER_WIDTH_CASE(eCSSProperty_border_left_width_value, left)
BORDER_WIDTH_CASE(eCSSProperty_border_right_width_value, right)
BORDER_WIDTH_CASE(eCSSProperty_border_top_width, top)
#undef BORDER_WIDTH_CASE
case eCSSProperty_border_bottom_color:
ExtractBorderColor(aStyleContext, styleStruct, NS_SIDE_BOTTOM,
aComputedValue);
break;
case eCSSProperty_border_left_color_value:
ExtractBorderColor(aStyleContext, styleStruct, NS_SIDE_LEFT,
aComputedValue);
break;
case eCSSProperty_border_right_color_value:
ExtractBorderColor(aStyleContext, styleStruct, NS_SIDE_RIGHT,
aComputedValue);
break;
case eCSSProperty_border_top_color:
ExtractBorderColor(aStyleContext, styleStruct, NS_SIDE_TOP,
aComputedValue);
break;
case eCSSProperty_outline_color: {
const nsStyleOutline *styleOutline =
static_cast<const nsStyleOutline*>(styleStruct);
nscolor color;
#ifdef GFX_HAS_INVERT
styleOutline->GetOutlineColor(color);
#else
if (!styleOutline->GetOutlineColor(color))
color = aStyleContext->GetStyleColor()->mColor;
#endif
aComputedValue.SetColorValue(color);
break;
}
default:
NS_ABORT_IF_FALSE(PR_FALSE, "missing property implementation");
return PR_FALSE;
};
return PR_TRUE;
case eStyleAnimType_Coord:
aComputedValue = *static_cast<const nsStyleCoord*>(
StyleDataAtOffset(styleStruct, ssOffset));

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

@ -50,6 +50,14 @@ var supported_properties = {
"-moz-column-rule-color": [ test_color_transition ],
"-moz-column-width": [ test_length_transition ],
"background-color": [ test_color_transition ],
"border-bottom-color": [ test_color_transition ],
"border-bottom-width": [ test_length_transition ],
"border-left-color": [ test_color_transition ],
"border-left-width": [ test_length_transition ],
"border-right-color": [ test_color_transition ],
"border-right-width": [ test_length_transition ],
"border-top-color": [ test_color_transition ],
"border-top-width": [ test_length_transition ],
"bottom": [ test_length_transition, test_percent_transition ],
"color": [ test_color_transition ],
"fill": [ test_color_transition ],
@ -74,6 +82,7 @@ var supported_properties = {
"min-height": [ test_length_transition, test_percent_transition ],
"min-width": [ test_length_transition, test_percent_transition ],
"opacity" : [ test_float_zeroToOne_transition ],
"outline-color": [ test_color_transition ],
"outline-offset": [ test_length_transition ],
"outline-width": [ test_length_transition ],
"padding-bottom": [ test_length_transition, test_percent_transition ],