Bug 655877 - Part 21: Avoid assertions when nsStyleContext::GetVisitedDependentColor is called for an SVG paint property. r=dbaron

This commit is contained in:
Cameron McCormack 2012-08-05 11:01:19 +10:00
Родитель 7404892c56
Коммит 209745005d
1 изменённых файлов: 36 добавлений и 9 удалений

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

@ -18,11 +18,14 @@
#include "nsStyleContext.h"
#include "prlog.h"
#include "nsStyleAnimation.h"
#include "mozilla/Util.h"
#ifdef DEBUG
// #define NOISY_DEBUG
#endif
using namespace mozilla;
//----------------------------------------------------------------------
@ -699,19 +702,38 @@ NS_NewStyleContext(nsStyleContext* aParentContext,
return context;
}
static nscolor ExtractColor(nsCSSProperty aProperty,
nsStyleContext *aStyleContext)
static inline void
ExtractAnimationValue(nsCSSProperty aProperty,
nsStyleContext* aStyleContext,
nsStyleAnimation::Value& aResult)
{
nsStyleAnimation::Value val;
#ifdef DEBUG
bool success =
#endif
nsStyleAnimation::ExtractComputedValue(aProperty, aStyleContext, val);
DebugOnly<bool> success =
nsStyleAnimation::ExtractComputedValue(aProperty, aStyleContext, aResult);
NS_ABORT_IF_FALSE(success,
"aProperty must be extractable by nsStyleAnimation");
}
static nscolor
ExtractColor(nsCSSProperty aProperty,
nsStyleContext *aStyleContext)
{
nsStyleAnimation::Value val;
ExtractAnimationValue(aProperty, aStyleContext, val);
return val.GetColorValue();
}
static nscolor
ExtractColorLenient(nsCSSProperty aProperty,
nsStyleContext *aStyleContext)
{
nsStyleAnimation::Value val;
ExtractAnimationValue(aProperty, aStyleContext, val);
if (val.GetUnit() == nsStyleAnimation::eUnit_Color) {
return val.GetColorValue();
}
return NS_RGBA(0, 0, 0, 0);
}
struct ColorIndexSet {
PRUint8 colorIndex, alphaIndex;
};
@ -734,15 +756,20 @@ nsStyleContext::GetVisitedDependentColor(nsCSSProperty aProperty)
aProperty == eCSSProperty_stroke,
"we need to add to nsStyleContext::CalcStyleDifference");
bool isPaintProperty = aProperty == eCSSProperty_fill ||
aProperty == eCSSProperty_stroke;
nscolor colors[2];
colors[0] = ExtractColor(aProperty, this);
colors[0] = isPaintProperty ? ExtractColorLenient(aProperty, this)
: ExtractColor(aProperty, this);
nsStyleContext *visitedStyle = this->GetStyleIfVisited();
if (!visitedStyle) {
return colors[0];
}
colors[1] = ExtractColor(aProperty, visitedStyle);
colors[1] = isPaintProperty ? ExtractColorLenient(aProperty, visitedStyle)
: ExtractColor(aProperty, visitedStyle);
return nsStyleContext::CombineVisitedColors(colors,
this->RelevantLinkVisited());