Bug 811836. Fast path eCSSUnit_Color colors when parsing colors in canvas. r=dholbert

This will avoid doing extra work/flushing layout in the common case.

--HG--
extra : rebase_source : 95df23c3e6a5118ec4964336465a6554705b99dd
This commit is contained in:
Jeff Muizelaar 2012-11-14 12:46:26 -08:00
parent 9b8069b669
commit 517a0e7414

View File

@ -591,6 +591,11 @@ CanvasRenderingContext2D::ParseColor(const nsAString& aString,
return false;
}
if (value.GetUnit() == nsCSSUnit::eCSSUnit_Color) {
// if we already have a color we can just use it directly
*aColor = value.GetColorValue();
} else {
// otherwise resolve it
nsIPresShell* presShell = GetPresShell();
nsRefPtr<nsStyleContext> parentContext;
if (mCanvasElement && mCanvasElement->IsInDoc()) {
@ -602,6 +607,7 @@ CanvasRenderingContext2D::ParseColor(const nsAString& aString,
unused << nsRuleNode::ComputeColor(
value, presShell ? presShell->GetPresContext() : nullptr, parentContext,
*aColor);
}
return true;
}