Bug 1885565 - Part 1: Add mozac_ic_avatar_circle_24 to ui-icons r=android-reviewers...
[gecko.git] / layout / style / ServoCSSParser.cpp
blob89f17f1733dffc22fb5e258464c31b68b96ab8ee
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* CSS parsing utility functions */
9 #include "ServoCSSParser.h"
11 #include "mozilla/AnimatedPropertyID.h"
12 #include "mozilla/ServoBindings.h"
13 #include "mozilla/ServoStyleSet.h"
14 #include "mozilla/dom/Document.h"
16 using namespace mozilla;
17 using namespace mozilla::dom;
19 /* static */
20 bool ServoCSSParser::IsValidCSSColor(const nsACString& aValue) {
21 return Servo_IsValidCSSColor(&aValue);
24 /* static */
25 bool ServoCSSParser::ComputeColor(ServoStyleSet* aStyleSet,
26 nscolor aCurrentColor,
27 const nsACString& aValue,
28 nscolor* aResultColor, bool* aWasCurrentColor,
29 css::Loader* aLoader) {
30 return Servo_ComputeColor(aStyleSet ? aStyleSet->RawData() : nullptr,
31 aCurrentColor, &aValue, aResultColor,
32 aWasCurrentColor, aLoader);
35 /* static */
36 bool ServoCSSParser::ColorTo(const nsACString& aFromColor,
37 const nsACString& aToColorSpace,
38 nsACString* aResultColor,
39 nsTArray<float>* aResultComponents,
40 bool* aResultAdjusted, css::Loader* aLoader) {
41 return Servo_ColorTo(&aFromColor, &aToColorSpace, aResultColor,
42 aResultComponents, aResultAdjusted, aLoader);
45 /* static */
46 already_AddRefed<StyleLockedDeclarationBlock> ServoCSSParser::ParseProperty(
47 nsCSSPropertyID aProperty, const nsACString& aValue,
48 const ParsingEnvironment& aParsingEnvironment,
49 const StyleParsingMode& aParsingMode) {
50 AnimatedPropertyID property(aProperty);
51 return ParseProperty(property, aValue, aParsingEnvironment, aParsingMode);
54 /* static */
55 already_AddRefed<StyleLockedDeclarationBlock> ServoCSSParser::ParseProperty(
56 const AnimatedPropertyID& aProperty, const nsACString& aValue,
57 const ParsingEnvironment& aParsingEnvironment,
58 const StyleParsingMode& aParsingMode) {
59 return Servo_ParseProperty(
60 &aProperty, &aValue, aParsingEnvironment.mUrlExtraData,
61 aParsingMode, aParsingEnvironment.mCompatMode,
62 aParsingEnvironment.mLoader, aParsingEnvironment.mRuleType)
63 .Consume();
66 /* static */
67 bool ServoCSSParser::ParseEasing(const nsACString& aValue,
68 StyleComputedTimingFunction& aResult) {
69 return Servo_ParseEasing(&aValue, &aResult);
72 /* static */
73 bool ServoCSSParser::ParseTransformIntoMatrix(const nsACString& aValue,
74 bool& aContains3DTransform,
75 gfx::Matrix4x4& aResult) {
76 return Servo_ParseTransformIntoMatrix(&aValue, &aContains3DTransform,
77 &aResult.components);
80 /* static */
81 bool ServoCSSParser::ParseFontShorthandForMatching(
82 const nsACString& aValue, URLExtraData* aUrl, StyleFontFamilyList& aList,
83 StyleFontStyle& aStyle, StyleFontStretch& aStretch,
84 StyleFontWeight& aWeight, float* aSize, bool* aSmallCaps) {
85 return Servo_ParseFontShorthandForMatching(
86 &aValue, aUrl, &aList, &aStyle, &aStretch, &aWeight, aSize, aSmallCaps);
89 /* static */
90 already_AddRefed<URLExtraData> ServoCSSParser::GetURLExtraData(
91 Document* aDocument) {
92 MOZ_ASSERT(aDocument);
93 return do_AddRef(aDocument->DefaultStyleAttrURLData());
96 /* static */ ServoCSSParser::ParsingEnvironment
97 ServoCSSParser::GetParsingEnvironment(Document* aDocument) {
98 return {GetURLExtraData(aDocument), aDocument->GetCompatibilityMode(),
99 aDocument->CSSLoader()};