Bug 1420026 - Part 2: Replace one more use of nsCSSParser::ParseColor with ServoCSSParser::ComputeColor. r=TYLin

MozReview-Commit-ID: FIqhPFKS1IR

--HG--
extra : rebase_source : 551e9a9a7effe1bf447b58495560aba0b8a06594
This commit is contained in:
Cameron McCormack 2017-11-24 11:30:02 +08:00
Родитель 8ff908d39a
Коммит 040ca098ab
1 изменённых файлов: 21 добавлений и 0 удалений

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

@ -1167,6 +1167,27 @@ CanvasRenderingContext2D::ParseColor(const nsAString& aString,
? mCanvasElement->OwnerDoc()
: nullptr;
if (document->IsStyledByServo()) {
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
ServoStyleSet* set = presShell ? presShell->StyleSet()->AsServo() : nullptr;
// First, try computing the color without handling currentcolor.
bool wasCurrentColor = false;
if (!ServoCSSParser::ComputeColor(set, NS_RGB(0, 0, 0), aString, aColor,
&wasCurrentColor)) {
return false;
}
if (wasCurrentColor) {
// Otherwise, get the value of the color property, flushing style
// if necessary.
RefPtr<nsStyleContext> canvasStyle =
nsComputedDOMStyle::GetStyleContext(mCanvasElement, nullptr, presShell);
*aColor = canvasStyle->StyleColor()->mColor;
}
return true;
}
// Pass the CSS Loader object to the parser, to allow parser error
// reports to include the outer window ID.
nsCSSParser parser(document ? document->CSSLoader() : nullptr);