Bug 913990 - When encountering bogus URI during style computation for filter, fall back to initial value. r=dholbert

This commit is contained in:
Max Vujovic 2013-10-17 14:37:57 -04:00
parent 799b253be3
commit b1e4d40e37
4 changed files with 26 additions and 7 deletions

View File

@ -7992,7 +7992,8 @@ nsRuleNode::ComputeSVGData(void* aStartStruct,
COMPUTE_END_INHERITED(SVG, svg)
}
void
// Returns true if the nsStyleFilter was successfully set using the nsCSSValue.
bool
nsRuleNode::SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter,
const nsCSSValue& aValue,
nsStyleContext* aStyleContext,
@ -8001,8 +8002,11 @@ nsRuleNode::SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter,
{
nsCSSUnit unit = aValue.GetUnit();
if (unit == eCSSUnit_URL) {
aStyleFilter->SetURL(aValue.GetURLValue());
return;
nsIURI* url = aValue.GetURLValue();
if (!url)
return false;
aStyleFilter->SetURL(url);
return true;
}
NS_ABORT_IF_FALSE(unit == eCSSUnit_Function, "expected a filter function");
@ -8024,7 +8028,7 @@ nsRuleNode::SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter,
false,
aCanStoreInRuleTree);
aStyleFilter->SetDropShadow(shadowArray);
return;
return true;
}
int32_t mask = SETCOORD_PERCENT | SETCOORD_FACTOR;
@ -8046,6 +8050,7 @@ nsRuleNode::SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter,
aCanStoreInRuleTree);
aStyleFilter->SetFilterParameter(filterParameter, type);
NS_ABORT_IF_FALSE(didSetCoord, "unexpected unit");
return true;
}
const void*
@ -8150,8 +8155,11 @@ nsRuleNode::ComputeSVGResetData(void* aStartStruct,
const nsCSSValueList* cur = filterValue->GetListValue();
while(cur) {
nsStyleFilter styleFilter;
SetStyleFilterToCSSValue(&styleFilter, cur->mValue, aContext,
mPresContext, canStoreInRuleTree);
if (!SetStyleFilterToCSSValue(&styleFilter, cur->mValue, aContext,
mPresContext, canStoreInRuleTree)) {
svgReset->mFilters.Clear();
break;
}
NS_ABORT_IF_FALSE(styleFilter.GetType() != NS_STYLE_FILTER_NONE,
"filter should be set");
svgReset->mFilters.AppendElement(styleFilter);

View File

@ -628,7 +628,7 @@ protected:
nsStyleContext* aContext,
bool aIsBoxShadow,
bool& aCanStoreInRuleTree);
void SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter,
bool SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter,
const nsCSSValue& aValue,
nsStyleContext* aStyleContext,
nsPresContext* aPresContext,

View File

@ -4442,6 +4442,12 @@ if (SpecialPowers.getBoolPref("layout.css.filters.enabled")) {
"grayscale(1) url(#my-filter-1)",
"url(#my-filter-1) brightness(50%) contrast(0.9)",
// The CSS parser will accept these weird URLs. However, we'll fail
// to resolve them when computing style, so we'll fall back to the
// initial value ("none").
"url('feed:javascript:5')",
"blur(3px) url('feed:javascript:5') grayscale(50%)",
"blur(0)",
"blur(0px)",
"blur(0.5px)",

View File

@ -41,6 +41,11 @@
/** Test for computation of values in property database **/
var gBadComputed = {
// The CSS parser will accept these weird URLs. However, we'll fail to
// resolve them when computing style, so we'll fall back to the initial
// value ("none").
"filter": [ "url('feed:javascript:5')", "blur(3px) url('feed:javascript:5') grayscale(50%)" ],
// These values are treated as auto.
"page-break-after": [ "avoid" ],
"page-break-before": [ "avoid" ],