Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
SkSVGAttributeParser Class Reference

#include <SkSVGAttributeParser.h>

Inheritance diagram for SkSVGAttributeParser:
SkNoncopyable

Public Types

template<typename T >
using ParseResult = SkTLazy< T >
 

Public Member Functions

 SkSVGAttributeParser (const char[])
 
bool parseInteger (SkSVGIntegerType *)
 
bool parseViewBox (SkSVGViewBoxType *)
 
bool parsePreserveAspectRatio (SkSVGPreserveAspectRatio *)
 
bool parse (SkSVGIntegerType *v)
 
template<>
bool parse (SkSVGColorType *color)
 
template<>
bool parse (SkSVGColor *color)
 
template<>
bool parse (SkSVGIRI *iri)
 
template<>
bool parse (SkSVGStringType *result)
 
template<>
bool parse (SkSVGNumberType *number)
 
template<>
bool parse (SkSVGLength *length)
 
template<>
bool parse (SkSVGTransformType *t)
 
template<>
bool parse (SkSVGPaint *paint)
 
template<>
bool parse (SkSVGFuncIRI *firi)
 
template<>
bool parse (SkSVGLineCap *cap)
 
template<>
bool parse (SkSVGLineJoin *join)
 
template<>
bool parse (SkSVGObjectBoundingBoxUnits *objectBoundingBoxUnits)
 
template<>
bool parse (SkSVGPointsType *points)
 
template<>
bool parse (SkSVGFillRule *fillRule)
 
template<>
bool parse (SkSVGVisibility *visibility)
 
template<>
bool parse (SkSVGDashArray *dashArray)
 
template<>
bool parse (SkSVGFontFamily *family)
 
template<>
bool parse (SkSVGFontSize *size)
 
template<>
bool parse (SkSVGFontStyle *style)
 
template<>
bool parse (SkSVGFontWeight *weight)
 
template<>
bool parse (SkSVGTextAnchor *anchor)
 
template<>
bool parse (SkSVGPreserveAspectRatio *par)
 
template<>
bool parse (std::vector< SkSVGLength > *lengths)
 
template<>
bool parse (std::vector< SkSVGNumberType > *numbers)
 
template<>
bool parse (SkSVGColorspace *colorspace)
 
template<>
bool parse (SkSVGDisplay *display)
 
template<>
bool parse (SkSVGFeInputType *type)
 
template<>
bool parse (SkSVGFeColorMatrixType *type)
 
template<>
bool parse (SkSVGFeFuncType *type)
 
template<>
bool parse (SkSVGFeCompositeOperator *op)
 
template<>
bool parse (SkSVGSpreadMethod *spread)
 
template<>
bool parse (SkSVGXmlSpace *xs)
 
- Public Member Functions inherited from SkNoncopyable
 SkNoncopyable ()=default
 
 SkNoncopyable (SkNoncopyable &&)=default
 
SkNoncopyableoperator= (SkNoncopyable &&)=default
 

Static Public Member Functions

template<typename T >
static ParseResult< Tparse (const char *value)
 
template<typename T >
static ParseResult< Tparse (const char *expectedName, const char *name, const char *value)
 
template<typename PropertyT >
static ParseResult< PropertyT > parseProperty (const char *expectedName, const char *name, const char *value)
 
template<>
bool parse (SkSVGFeTurbulenceBaseFrequency *freq)
 
template<>
bool parse (SkSVGFeTurbulenceType *type)
 
template<>
bool parse (SkPath *path)
 

Detailed Description

Definition at line 17 of file SkSVGAttributeParser.h.

Member Typedef Documentation

◆ ParseResult

template<typename T >
using SkSVGAttributeParser::ParseResult = SkTLazy<T>

Definition at line 29 of file SkSVGAttributeParser.h.

Constructor & Destructor Documentation

◆ SkSVGAttributeParser()

SkSVGAttributeParser::SkSVGAttributeParser ( const char  attributeString[])

Definition at line 43 of file SkSVGAttributeParser.cpp.

45 : fCurPos(attributeString), fEndPos(fCurPos + strlen(attributeString)) {}

Member Function Documentation

◆ parse() [1/38]

template<typename T >
static ParseResult< T > SkSVGAttributeParser::parse ( const char *  expectedName,
const char *  name,
const char *  value 
)
inlinestatic

Definition at line 41 of file SkSVGAttributeParser.h.

43 {
44 if (!strcmp(name, expectedName)) {
45 return parse<T>(value);
46 }
47
48 return ParseResult<T>();
49 }
uint8_t value
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ parse() [2/38]

template<typename T >
static ParseResult< T > SkSVGAttributeParser::parse ( const char *  value)
inlinestatic

Definition at line 31 of file SkSVGAttributeParser.h.

31 {
32 ParseResult<T> result;
33 T parsedValue;
34 if (SkSVGAttributeParser(value).parse(&parsedValue)) {
35 result.set(std::move(parsedValue));
36 }
37 return result;
38 }
SkSVGAttributeParser(const char[])
bool parse(SkSVGIntegerType *v)
GAsyncResult * result
#define T
Definition: precompiler.cc:65

◆ parse() [3/38]

template<>
bool SkSVGAttributeParser::parse ( SkPath path)
static

Definition at line 23 of file SkSVGPath.cpp.

23 {
24 return SkParsePath::FromSVGString(fCurPos, path);
25}
static bool FromSVGString(const char str[], SkPath *)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57

◆ parse() [4/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGColor color)

Definition at line 446 of file SkSVGAttributeParser.cpp.

446 {
447 this->parseWSToken();
448 if (!this->parseSVGColor(color, SkSVGColor::Vars())) {
449 return false;
450 }
451 this->parseWSToken();
452 return this->parseEOSToken();
453}
std::vector< SkString > Vars
Definition: SkSVGTypes.h:184
DlColor color

◆ parse() [5/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGColorspace colorspace)

Definition at line 1144 of file SkSVGAttributeParser.cpp.

1144 {
1145 static constexpr std::tuple<const char*, SkSVGColorspace> gColorspaceMap[] = {
1146 { "auto" , SkSVGColorspace::kAuto },
1147 { "sRGB" , SkSVGColorspace::kSRGB },
1148 { "linearRGB", SkSVGColorspace::kLinearRGB },
1149 };
1150
1151 return this->parseEnumMap(gColorspaceMap, colorspace) && this->parseEOSToken();
1152}

◆ parse() [6/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGColorType color)

Definition at line 398 of file SkSVGAttributeParser.cpp.

398 {
399 this->parseWSToken();
400 if (!this->parseSVGColorType(color)) {
401 return false;
402 }
403 this->parseWSToken();
404 return this->parseEOSToken();
405}

◆ parse() [7/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGDashArray dashArray)

Definition at line 931 of file SkSVGAttributeParser.cpp.

931 {
932 bool parsedValue = false;
933 if (this->parseExpectedStringToken("none")) {
935 parsedValue = true;
936 } else if (this->parseExpectedStringToken("inherit")) {
938 parsedValue = true;
939 } else {
940 std::vector<SkSVGLength> dashes;
941 for (;;) {
942 SkSVGLength dash;
943 // parseLength() also consumes trailing separators.
944 if (!this->parse(&dash)) {
945 break;
946 }
947
948 dashes.push_back(dash);
949 parsedValue = true;
950 }
951
952 if (parsedValue) {
953 *dashArray = SkSVGDashArray(std::move(dashes));
954 }
955 }
956
957 return parsedValue && this->parseEOSToken();
958}

◆ parse() [8/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGDisplay display)

Definition at line 1156 of file SkSVGAttributeParser.cpp.

1156 {
1157 static const struct {
1158 SkSVGDisplay fType;
1159 const char* fName;
1160 } gDisplayInfo[] = {
1161 { SkSVGDisplay::kInline, "inline" },
1162 { SkSVGDisplay::kNone , "none" },
1163 };
1164
1165 bool parsedValue = false;
1166 for (const auto& parseInfo : gDisplayInfo) {
1167 if (this->parseExpectedStringToken(parseInfo.fName)) {
1168 *display = SkSVGDisplay(parseInfo.fType);
1169 parsedValue = true;
1170 break;
1171 }
1172 }
1173
1174 return parsedValue && this->parseEOSToken();
1175}
const char * fName
SkSVGDisplay
Definition: SkSVGTypes.h:726

◆ parse() [9/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGFeColorMatrixType type)

Definition at line 100 of file SkSVGFeColorMatrix.cpp.

100 {
101 static constexpr std::tuple<const char*, SkSVGFeColorMatrixType> gTypeMap[] = {
105 {"luminanceToAlpha", SkSVGFeColorMatrixType::kLuminanceToAlpha},
106 };
107
108 return this->parseEnumMap(gTypeMap, type) && this->parseEOSToken();
109}
GLenum type

◆ parse() [10/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGFeCompositeOperator op)

Definition at line 63 of file SkSVGFeComposite.cpp.

63 {
64 static constexpr std::tuple<const char*, SkSVGFeCompositeOperator> gOpMap[] = {
71 };
72
73 return this->parseEnumMap(gOpMap, op) && this->parseEOSToken();
74}

◆ parse() [11/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGFeFuncType type)

Definition at line 162 of file SkSVGFeComponentTransfer.cpp.

162 {
163 static constexpr std::tuple<const char*, SkSVGFeFuncType> gTypeMap[] = {
164 { "identity", SkSVGFeFuncType::kIdentity },
165 { "table" , SkSVGFeFuncType::kTable },
166 { "discrete", SkSVGFeFuncType::kDiscrete },
167 { "linear" , SkSVGFeFuncType::kLinear },
168 { "gamma" , SkSVGFeFuncType::kGamma },
169 };
170
171 return this->parseEnumMap(gTypeMap, type) && this->parseEOSToken();
172}

◆ parse() [12/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGFeInputType type)

Definition at line 103 of file SkSVGFe.cpp.

103 {
104 static constexpr std::tuple<const char*, SkSVGFeInputType::Type> gTypeMap[] = {
107 {"BackgroundImage", SkSVGFeInputType::Type::kBackgroundImage},
108 {"BackgroundAlpha", SkSVGFeInputType::Type::kBackgroundAlpha},
111 };
112
113 SkSVGStringType resultId;
115 bool parsedValue = false;
116 if (this->parseEnumMap(gTypeMap, &t)) {
118 parsedValue = true;
119 } else if (parse(&resultId)) {
120 *type = SkSVGFeInputType(resultId);
121 parsedValue = true;
122 }
123
124 return parsedValue && this->parseEOSToken();
125}

◆ parse() [13/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGFeTurbulenceBaseFrequency freq)
static

Definition at line 28 of file SkSVGFeTurbulence.cpp.

29 {
30 SkSVGNumberType freqX;
31 if (!this->parse(&freqX)) {
32 return false;
33 }
34
35 SkSVGNumberType freqY;
36 this->parseCommaWspToken();
37 if (this->parse(&freqY)) {
38 *freq = SkSVGFeTurbulenceBaseFrequency(freqX, freqY);
39 } else {
40 *freq = SkSVGFeTurbulenceBaseFrequency(freqX, freqX);
41 }
42
43 return this->parseEOSToken();
44}
SkScalar SkSVGNumberType
Definition: SkSVGTypes.h:27

◆ parse() [14/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGFeTurbulenceType type)
static

Definition at line 47 of file SkSVGFeTurbulence.cpp.

47 {
48 bool parsedValue = false;
49
50 if (this->parseExpectedStringToken("fractalNoise")) {
52 parsedValue = true;
53 } else if (this->parseExpectedStringToken("turbulence")) {
55 parsedValue = true;
56 }
57
58 return parsedValue && this->parseEOSToken();
59}

◆ parse() [15/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGFillRule fillRule)

Definition at line 882 of file SkSVGAttributeParser.cpp.

882 {
883 static const struct {
885 const char* fName;
886 } gFillRuleInfo[] = {
887 { SkSVGFillRule::Type::kNonZero, "nonzero" },
888 { SkSVGFillRule::Type::kEvenOdd, "evenodd" },
889 { SkSVGFillRule::Type::kInherit, "inherit" },
890 };
891
892 bool parsedValue = false;
893 for (size_t i = 0; i < std::size(gFillRuleInfo); ++i) {
894 if (this->parseExpectedStringToken(gFillRuleInfo[i].fName)) {
895 *fillRule = SkSVGFillRule(gFillRuleInfo[i].fType);
896 parsedValue = true;
897 break;
898 }
899 }
900
901 return parsedValue && this->parseEOSToken();
902}
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259

◆ parse() [16/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGFontFamily family)

Definition at line 962 of file SkSVGAttributeParser.cpp.

962 {
963 bool parsedValue = false;
964 if (this->parseExpectedStringToken("inherit")) {
965 *family = SkSVGFontFamily();
966 parsedValue = true;
967 } else {
968 // The spec allows specifying a comma-separated list for explicit fallback order.
969 // For now, we only use the first entry and rely on the font manager to handle fallback.
970 const auto* comma = strchr(fCurPos, ',');
971 auto family_name = comma ? SkString(fCurPos, comma - fCurPos)
972 : SkString(fCurPos);
973 *family = SkSVGFontFamily(family_name.c_str());
974 fCurPos += strlen(fCurPos);
975 parsedValue = true;
976 }
977
978 return parsedValue && this->parseEOSToken();
979}

◆ parse() [17/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGFontSize size)

Definition at line 983 of file SkSVGAttributeParser.cpp.

983 {
984 bool parsedValue = false;
985 if (this->parseExpectedStringToken("inherit")) {
986 *size = SkSVGFontSize();
987 parsedValue = true;
988 } else {
990 if (this->parse(&length)) {
992 parsedValue = true;
993 }
994 }
995
996 return parsedValue && this->parseEOSToken();
997}
size_t length

◆ parse() [18/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGFontStyle style)

Definition at line 1001 of file SkSVGAttributeParser.cpp.

1001 {
1002 static constexpr std::tuple<const char*, SkSVGFontStyle::Type> gStyleMap[] = {
1003 { "normal" , SkSVGFontStyle::Type::kNormal },
1004 { "italic" , SkSVGFontStyle::Type::kItalic },
1005 { "oblique", SkSVGFontStyle::Type::kOblique },
1006 { "inherit", SkSVGFontStyle::Type::kInherit },
1007 };
1008
1009 bool parsedValue = false;
1011
1012 if (this->parseEnumMap(gStyleMap, &type)) {
1013 *style = SkSVGFontStyle(type);
1014 parsedValue = true;
1015 }
1016
1017 return parsedValue && this->parseEOSToken();
1018}

◆ parse() [19/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGFontWeight weight)

Definition at line 1022 of file SkSVGAttributeParser.cpp.

1022 {
1023 static constexpr std::tuple<const char*, SkSVGFontWeight::Type> gWeightMap[] = {
1024 { "normal" , SkSVGFontWeight::Type::kNormal },
1025 { "bold" , SkSVGFontWeight::Type::kBold },
1026 { "bolder" , SkSVGFontWeight::Type::kBolder },
1027 { "lighter", SkSVGFontWeight::Type::kLighter },
1028 { "100" , SkSVGFontWeight::Type::k100 },
1029 { "200" , SkSVGFontWeight::Type::k200 },
1030 { "300" , SkSVGFontWeight::Type::k300 },
1031 { "400" , SkSVGFontWeight::Type::k400 },
1032 { "500" , SkSVGFontWeight::Type::k500 },
1033 { "600" , SkSVGFontWeight::Type::k600 },
1034 { "700" , SkSVGFontWeight::Type::k700 },
1035 { "800" , SkSVGFontWeight::Type::k800 },
1036 { "900" , SkSVGFontWeight::Type::k900 },
1037 { "inherit", SkSVGFontWeight::Type::kInherit },
1038 };
1039
1040 bool parsedValue = false;
1042
1043 if (this->parseEnumMap(gWeightMap, &type)) {
1044 *weight = SkSVGFontWeight(type);
1045 parsedValue = true;
1046 }
1047
1048 return parsedValue && this->parseEOSToken();
1049}

◆ parse() [20/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGFuncIRI firi)

Definition at line 752 of file SkSVGAttributeParser.cpp.

752 {
753 SkSVGStringType iri;
754 bool parsedValue = false;
755
756 if (this->parseExpectedStringToken("none")) {
757 *firi = SkSVGFuncIRI();
758 parsedValue = true;
759 } else if (this->parseFuncIRI(firi)) {
760 parsedValue = true;
761 }
762
763 return parsedValue && this->parseEOSToken();
764}

◆ parse() [21/38]

bool SkSVGAttributeParser::parse ( SkSVGIntegerType v)
inline

Definition at line 27 of file SkSVGAttributeParser.h.

27{ return parseInteger(v); }
bool parseInteger(SkSVGIntegerType *)

◆ parse() [22/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGIRI iri)

Definition at line 457 of file SkSVGAttributeParser.cpp.

457 {
458 // consume preceding whitespace
459 this->parseWSToken();
460
461 SkSVGIRI::Type iriType;
462 if (this->parseExpectedStringToken("#")) {
463 iriType = SkSVGIRI::Type::kLocal;
464 } else if (this->matchStringToken("data:")) {
465 iriType = SkSVGIRI::Type::kDataURI;
466 } else {
468 }
469
470 const auto* start = fCurPos;
471 if (!this->advanceWhile([](char c) -> bool { return c != ')'; })) {
472 return false;
473 }
474 *iri = SkSVGIRI(iriType, SkString(start, fCurPos - start));
475 return true;
476}

◆ parse() [23/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGLength length)

Definition at line 538 of file SkSVGAttributeParser.cpp.

538 {
539 SkScalar s;
541
542 if (this->parseScalarToken(&s) &&
543 (this->parseLengthUnitToken(&u) || this->parseSepToken() || this->parseEOSToken())) {
544 *length = SkSVGLength(s, u);
545 // consume trailing separators
546 this->parseSepToken();
547 return true;
548 }
549
550 return false;
551}
float SkScalar
Definition: extension.cpp:12
struct MyStruct s

◆ parse() [24/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGLineCap cap)

Definition at line 768 of file SkSVGAttributeParser.cpp.

768 {
769 static const struct {
770 SkSVGLineCap fType;
771 const char* fName;
772 } gCapInfo[] = {
773 { SkSVGLineCap::kButt , "butt" },
774 { SkSVGLineCap::kRound , "round" },
775 { SkSVGLineCap::kSquare , "square" },
776 };
777
778 bool parsedValue = false;
779 for (size_t i = 0; i < std::size(gCapInfo); ++i) {
780 if (this->parseExpectedStringToken(gCapInfo[i].fName)) {
781 *cap = SkSVGLineCap(gCapInfo[i].fType);
782 parsedValue = true;
783 break;
784 }
785 }
786
787 return parsedValue && this->parseEOSToken();
788}
SkSVGLineCap
Definition: SkSVGTypes.h:288

◆ parse() [25/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGLineJoin join)

Definition at line 792 of file SkSVGAttributeParser.cpp.

792 {
793 static const struct {
795 const char* fName;
796 } gJoinInfo[] = {
797 { SkSVGLineJoin::Type::kMiter , "miter" },
798 { SkSVGLineJoin::Type::kRound , "round" },
799 { SkSVGLineJoin::Type::kBevel , "bevel" },
800 { SkSVGLineJoin::Type::kInherit, "inherit" },
801 };
802
803 bool parsedValue = false;
804 for (size_t i = 0; i < std::size(gJoinInfo); ++i) {
805 if (this->parseExpectedStringToken(gJoinInfo[i].fName)) {
806 *join = SkSVGLineJoin(gJoinInfo[i].fType);
807 parsedValue = true;
808 break;
809 }
810 }
811
812 return parsedValue && this->parseEOSToken();
813}
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741

◆ parse() [26/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGNumberType number)

Definition at line 502 of file SkSVGAttributeParser.cpp.

502 {
503 // consume WS
504 this->parseWSToken();
505
506 SkScalar s;
507 if (this->parseScalarToken(&s)) {
508 *number = SkSVGNumberType(s);
509 // consume trailing separators
510 this->parseSepToken();
511 return true;
512 }
513
514 return false;
515}

◆ parse() [27/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGObjectBoundingBoxUnits objectBoundingBoxUnits)

Definition at line 817 of file SkSVGAttributeParser.cpp.

817 {
818 bool parsedValue = false;
819 if (this->parseExpectedStringToken("userSpaceOnUse")) {
820 *objectBoundingBoxUnits =
822 parsedValue = true;
823 } else if (this->parseExpectedStringToken("objectBoundingBox")) {
824 *objectBoundingBoxUnits =
826 parsedValue = true;
827 }
828 return parsedValue && this->parseEOSToken();
829}

◆ parse() [28/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGPaint paint)

Definition at line 725 of file SkSVGAttributeParser.cpp.

725 {
726 SkSVGColor c;
727 SkSVGFuncIRI iri;
728 bool parsedValue = false;
729
730 this->parseWSToken();
731 if (this->parseSVGColor(&c, SkSVGColor::Vars())) {
732 *paint = SkSVGPaint(std::move(c));
733 parsedValue = true;
734 } else if (this->parseExpectedStringToken("none")) {
736 parsedValue = true;
737 } else if (this->parseFuncIRI(&iri)) {
738 // optional fallback color
739 this->parseWSToken();
740 this->parseSVGColor(&c, SkSVGColor::Vars());
741 *paint = SkSVGPaint(iri.iri(), std::move(c));
742 parsedValue = true;
743 }
744 this->parseWSToken();
745 return parsedValue && this->parseEOSToken();
746}
const SkSVGIRI & iri() const
Definition: SkSVGTypes.h:281
const Paint & paint
Definition: color_source.cc:38

◆ parse() [29/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGPointsType points)

Definition at line 833 of file SkSVGAttributeParser.cpp.

833 {
834 SkSVGPointsType pts;
835
836 // Skip initial wsp.
837 // list-of-points:
838 // wsp* coordinate-pairs? wsp*
839 this->advanceWhile(is_ws);
840
841 bool parsedValue = false;
842 for (;;) {
843 // Adjacent coordinate-pairs separated by comma-wsp.
844 // coordinate-pairs:
845 // coordinate-pair
846 // | coordinate-pair comma-wsp coordinate-pairs
847 if (parsedValue && !this->parseCommaWspToken()) {
848 break;
849 }
850
851 SkScalar x, y;
852 if (!this->parseScalarToken(&x)) {
853 break;
854 }
855
856 // Coordinate values separated by comma-wsp or '-'.
857 // coordinate-pair:
858 // coordinate comma-wsp coordinate
859 // | coordinate negative-coordinate
860 if (!this->parseCommaWspToken() && !this->parseEOSToken() && *fCurPos != '-') {
861 break;
862 }
863
864 if (!this->parseScalarToken(&y)) {
865 break;
866 }
867
868 pts.push_back(SkPoint::Make(x, y));
869 parsedValue = true;
870 }
871
872 if (parsedValue && this->parseEOSToken()) {
873 *points = std::move(pts);
874 return true;
875 }
876
877 return false;
878}
static const int points[]
static bool is_ws(int c)
Definition: SkParse.cpp:24
std::vector< SkPoint > SkSVGPointsType
Definition: SkSVGTypes.h:31
double y
double x
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173

◆ parse() [30/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGPreserveAspectRatio par)

Definition at line 1110 of file SkSVGAttributeParser.cpp.

1110 {
1111 return this->parsePreserveAspectRatio(par);
1112}
bool parsePreserveAspectRatio(SkSVGPreserveAspectRatio *)

◆ parse() [31/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGSpreadMethod spread)

Definition at line 98 of file SkSVGGradient.cpp.

98 {
99 static const struct {
101 const char* fName;
102 } gSpreadInfo[] = {
106 };
107
108 bool parsedValue = false;
109 for (size_t i = 0; i < std::size(gSpreadInfo); ++i) {
110 if (this->parseExpectedStringToken(gSpreadInfo[i].fName)) {
111 *spread = SkSVGSpreadMethod(gSpreadInfo[i].fType);
112 parsedValue = true;
113 break;
114 }
115 }
116
117 return parsedValue && this->parseEOSToken();
118}

◆ parse() [32/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGStringType result)

Definition at line 491 of file SkSVGAttributeParser.cpp.

491 {
492 if (this->parseEOSToken()) {
493 return false;
494 }
495 *result = SkSVGStringType(fCurPos);
496 fCurPos += result->size();
497 return this->parseEOSToken();
498}
SkString SkSVGStringType
Definition: SkSVGTypes.h:28

◆ parse() [33/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGTextAnchor anchor)

Definition at line 1053 of file SkSVGAttributeParser.cpp.

1053 {
1054 static constexpr std::tuple<const char*, SkSVGTextAnchor::Type> gAnchorMap[] = {
1055 { "start" , SkSVGTextAnchor::Type::kStart },
1056 { "middle" , SkSVGTextAnchor::Type::kMiddle },
1057 { "end" , SkSVGTextAnchor::Type::kEnd },
1058 { "inherit", SkSVGTextAnchor::Type::kInherit},
1059 };
1060
1061 bool parsedValue = false;
1063
1064 if (this->parseEnumMap(gAnchorMap, &type)) {
1065 *anchor = SkSVGTextAnchor(type);
1066 parsedValue = true;
1067 }
1068
1069 return parsedValue && this->parseEOSToken();
1070}

◆ parse() [34/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGTransformType t)

Definition at line 692 of file SkSVGAttributeParser.cpp.

692 {
694
695 bool parsed = false;
696 while (true) {
697 SkMatrix m;
698
699 if (!( this->parseMatrixToken(&m)
700 || this->parseTranslateToken(&m)
701 || this->parseScaleToken(&m)
702 || this->parseRotateToken(&m)
703 || this->parseSkewXToken(&m)
704 || this->parseSkewYToken(&m))) {
705 break;
706 }
707
708 matrix.preConcat(m);
709 parsed = true;
710
711 this->parseCommaWspToken();
712 }
713
714 this->parseWSToken();
715 if (!parsed || !this->parseEOSToken()) {
716 return false;
717 }
718
720 return true;
721}
SkMatrix SkSVGTransformType
Definition: SkSVGTypes.h:30
static const SkMatrix & I()
Definition: SkMatrix.cpp:1544
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258

◆ parse() [35/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGVisibility visibility)

Definition at line 906 of file SkSVGAttributeParser.cpp.

906 {
907 static const struct {
909 const char* fName;
910 } gVisibilityInfo[] = {
911 { SkSVGVisibility::Type::kVisible , "visible" },
912 { SkSVGVisibility::Type::kHidden , "hidden" },
913 { SkSVGVisibility::Type::kCollapse, "collapse" },
914 { SkSVGVisibility::Type::kInherit , "inherit" },
915 };
916
917 bool parsedValue = false;
918 for (const auto& parseInfo : gVisibilityInfo) {
919 if (this->parseExpectedStringToken(parseInfo.fName)) {
920 *visibility = SkSVGVisibility(parseInfo.fType);
921 parsedValue = true;
922 break;
923 }
924 }
925
926 return parsedValue && this->parseEOSToken();
927}

◆ parse() [36/38]

template<>
bool SkSVGAttributeParser::parse ( SkSVGXmlSpace xs)

Definition at line 575 of file SkSVGText.cpp.

575 {
576 static constexpr std::tuple<const char*, SkSVGXmlSpace> gXmlSpaceMap[] = {
577 {"default" , SkSVGXmlSpace::kDefault },
578 {"preserve", SkSVGXmlSpace::kPreserve},
579 };
580
581 return this->parseEnumMap(gXmlSpaceMap, xs) && this->parseEOSToken();
582}

◆ parse() [37/38]

template<>
bool SkSVGAttributeParser::parse ( std::vector< SkSVGLength > *  lengths)

Definition at line 1134 of file SkSVGAttributeParser.cpp.

1134 {
1135 return this->parseList(lengths);
1136}

◆ parse() [38/38]

template<>
bool SkSVGAttributeParser::parse ( std::vector< SkSVGNumberType > *  numbers)

Definition at line 1139 of file SkSVGAttributeParser.cpp.

1139 {
1140 return this->parseList(numbers);
1141}

◆ parseInteger()

bool SkSVGAttributeParser::parseInteger ( SkSVGIntegerType number)

Definition at line 518 of file SkSVGAttributeParser.cpp.

518 {
519 // consume WS
520 this->parseWSToken();
521
522 // consume optional '+'
523 this->parseExpectedStringToken("+");
524
526 if (this->parseInt32Token(&i)) {
527 *number = SkSVGNumberType(i);
528 // consume trailing separators
529 this->parseSepToken();
530 return true;
531 }
532
533 return false;
534}
int SkSVGIntegerType
Definition: SkSVGTypes.h:26

◆ parsePreserveAspectRatio()

bool SkSVGAttributeParser::parsePreserveAspectRatio ( SkSVGPreserveAspectRatio par)

Definition at line 1073 of file SkSVGAttributeParser.cpp.

1073 {
1074 static constexpr std::tuple<const char*, SkSVGPreserveAspectRatio::Align> gAlignMap[] = {
1085 };
1086
1087 static constexpr std::tuple<const char*, SkSVGPreserveAspectRatio::Scale> gScaleMap[] = {
1090 };
1091
1092 bool parsedValue = false;
1093
1094 // ignoring optional 'defer'
1095 this->parseExpectedStringToken("defer");
1096 this->parseWSToken();
1097
1098 if (this->parseEnumMap(gAlignMap, &par->fAlign)) {
1099 parsedValue = true;
1100
1101 // optional scaling selector
1102 this->parseWSToken();
1103 this->parseEnumMap(gScaleMap, &par->fScale);
1104 }
1105
1106 return parsedValue && this->parseEOSToken();
1107}

◆ parseProperty()

template<typename PropertyT >
static ParseResult< PropertyT > SkSVGAttributeParser::parseProperty ( const char *  expectedName,
const char *  name,
const char *  value 
)
inlinestatic

Definition at line 52 of file SkSVGAttributeParser.h.

54 {
55 if (strcmp(name, expectedName) != 0) {
56 return ParseResult<PropertyT>();
57 }
58
59 if (!strcmp(value, "inherit")) {
61 return ParseResult<PropertyT>(&result);
62 }
63
64 auto pr = parse<typename PropertyT::ValueT>(value);
65 if (pr.isValid()) {
66 PropertyT result(*pr);
67 return ParseResult<PropertyT>(&result);
68 }
69
70 return ParseResult<PropertyT>();
71 }

◆ parseViewBox()

bool SkSVGAttributeParser::parseViewBox ( SkSVGViewBoxType vb)

Definition at line 554 of file SkSVGAttributeParser.cpp.

554 {
555 SkScalar x, y, w, h;
556 this->parseWSToken();
557
558 bool parsedValue = false;
559 if (this->parseScalarToken(&x) && this->parseSepToken() &&
560 this->parseScalarToken(&y) && this->parseSepToken() &&
561 this->parseScalarToken(&w) && this->parseSepToken() &&
562 this->parseScalarToken(&h)) {
563
565 parsedValue = true;
566 // consume trailing whitespace
567 this->parseWSToken();
568 }
569 return parsedValue && this->parseEOSToken();
570}
SkRect SkSVGViewBoxType
Definition: SkSVGTypes.h:29
SkScalar w
SkScalar h
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

The documentation for this class was generated from the following files: