@@ -76,101 +76,34 @@ void SetInheritedByDefault(SkTLazy<T>& presentation_attribute, const T& value) {
76
76
}
77
77
}
78
78
79
- void SkSVGNode::setColor (const SkSVGColorType& color) {
80
- // TODO: Color should be inherited by default
81
- fPresentationAttributes .fColor .set (color);
82
- }
83
-
84
- void SkSVGNode::setFillOpacity (const SkSVGNumberType& opacity) {
85
- fPresentationAttributes .fFillOpacity .set (SkSVGNumberType (SkTPin<SkScalar>(opacity, 0 , 1 )));
86
- }
87
-
88
- void SkSVGNode::setOpacity (const SkSVGNumberType& opacity) {
89
- fPresentationAttributes .fOpacity .set (SkSVGNumberType (SkTPin<SkScalar>(opacity, 0 , 1 )));
90
- }
91
-
92
- void SkSVGNode::setStrokeDashOffset (const SkSVGLength& dashOffset) {
93
- fPresentationAttributes .fStrokeDashOffset .set (dashOffset);
94
- }
95
-
96
- void SkSVGNode::setStrokeOpacity (const SkSVGNumberType& opacity) {
97
- fPresentationAttributes .fStrokeOpacity .set (SkSVGNumberType (SkTPin<SkScalar>(opacity, 0 , 1 )));
98
- }
99
-
100
- void SkSVGNode::setStrokeMiterLimit (const SkSVGNumberType& ml) {
101
- fPresentationAttributes .fStrokeMiterLimit .set (ml);
102
- }
103
-
104
- void SkSVGNode::setStrokeWidth (const SkSVGLength& strokeWidth) {
105
- fPresentationAttributes .fStrokeWidth .set (strokeWidth);
106
- }
107
-
108
- void SkSVGNode::onSetAttribute (SkSVGAttribute attr, const SkSVGValue& v) {
109
- switch (attr) {
110
- case SkSVGAttribute::kColor :
111
- if (const SkSVGColorValue* color = v.as <SkSVGColorValue>()) {
112
- this ->setColor (*color);
113
- }
114
- break ;
115
- case SkSVGAttribute::kFillOpacity :
116
- if (const SkSVGNumberValue* opacity = v.as <SkSVGNumberValue>()) {
117
- this ->setFillOpacity (*opacity);
118
- }
119
- break ;
120
- case SkSVGAttribute::kOpacity :
121
- if (const SkSVGNumberValue* opacity = v.as <SkSVGNumberValue>()) {
122
- this ->setOpacity (*opacity);
123
- }
124
- break ;
125
- case SkSVGAttribute::kStrokeDashOffset :
126
- if (const SkSVGLengthValue* dashOffset= v.as <SkSVGLengthValue>()) {
127
- this ->setStrokeDashOffset (*dashOffset);
128
- }
129
- break ;
130
- case SkSVGAttribute::kStrokeOpacity :
131
- if (const SkSVGNumberValue* opacity = v.as <SkSVGNumberValue>()) {
132
- this ->setStrokeOpacity (*opacity);
133
- }
134
- break ;
135
- case SkSVGAttribute::kStrokeMiterLimit :
136
- if (const SkSVGNumberValue* miterLimit = v.as <SkSVGNumberValue>()) {
137
- this ->setStrokeMiterLimit (*miterLimit);
138
- }
139
- break ;
140
- case SkSVGAttribute::kStrokeWidth :
141
- if (const SkSVGLengthValue* strokeWidth = v.as <SkSVGLengthValue>()) {
142
- this ->setStrokeWidth (*strokeWidth);
143
- }
144
- break ;
145
- default :
146
- #if defined(SK_VERBOSE_SVG_PARSING)
147
- SkDebugf (" attribute ID <%d> ignored for node <%d>\n " , attr, fTag );
148
- #endif
149
- break ;
150
- }
151
- }
152
-
153
79
bool SkSVGNode::parseAndSetAttribute (const char * n, const char * v) {
154
80
#define PARSE_AND_SET (svgName, attrName ) \
155
81
this ->set ##attrName ( \
156
82
SkSVGAttributeParser::parseProperty<decltype (fPresentationAttributes .f ##attrName)>( \
157
83
svgName, n, v))
158
84
159
- return PARSE_AND_SET ( " clip-path" , ClipPath)
160
- || PARSE_AND_SET (" clip-rule" , ClipRule)
161
- || PARSE_AND_SET (" fill" , Fill)
162
- || PARSE_AND_SET (" fill-rule" , FillRule)
163
- || PARSE_AND_SET (" filter" , Filter)
164
- || PARSE_AND_SET (" font-family" , FontFamily)
165
- || PARSE_AND_SET (" font-size" , FontSize)
166
- || PARSE_AND_SET (" font-style" , FontStyle)
167
- || PARSE_AND_SET (" font-weight" , FontWeight)
168
- || PARSE_AND_SET (" stroke" , Stroke)
169
- || PARSE_AND_SET (" stroke-dasharray" , StrokeDashArray)
170
- || PARSE_AND_SET (" stroke-linecap" , StrokeLineCap)
171
- || PARSE_AND_SET (" stroke-linejoin" , StrokeLineJoin)
172
- || PARSE_AND_SET (" text-anchor" , TextAnchor)
173
- || PARSE_AND_SET (" visibility" , Visibility);
85
+ return PARSE_AND_SET ( " clip-path" , ClipPath)
86
+ || PARSE_AND_SET (" clip-rule" , ClipRule)
87
+ || PARSE_AND_SET (" color" , Color)
88
+ || PARSE_AND_SET (" fill" , Fill)
89
+ || PARSE_AND_SET (" fill-opacity" , FillOpacity)
90
+ || PARSE_AND_SET (" fill-rule" , FillRule)
91
+ || PARSE_AND_SET (" filter" , Filter)
92
+ || PARSE_AND_SET (" font-family" , FontFamily)
93
+ || PARSE_AND_SET (" font-size" , FontSize)
94
+ || PARSE_AND_SET (" font-style" , FontStyle)
95
+ || PARSE_AND_SET (" font-weight" , FontWeight)
96
+ || PARSE_AND_SET (" opacity" , Opacity)
97
+ || PARSE_AND_SET (" stroke" , Stroke)
98
+ || PARSE_AND_SET (" stroke-dasharray" , StrokeDashArray)
99
+ || PARSE_AND_SET (" stroke-dashoffset" , StrokeDashOffset)
100
+ || PARSE_AND_SET (" stroke-linecap" , StrokeLineCap)
101
+ || PARSE_AND_SET (" stroke-linejoin" , StrokeLineJoin)
102
+ || PARSE_AND_SET (" stroke-miterlimit" , StrokeMiterLimit)
103
+ || PARSE_AND_SET (" stroke-opacity" , StrokeOpacity)
104
+ || PARSE_AND_SET (" stroke-width" , StrokeWidth)
105
+ || PARSE_AND_SET (" text-anchor" , TextAnchor)
106
+ || PARSE_AND_SET (" visibility" , Visibility);
174
107
175
108
#undef PARSE_AND_SET
176
109
}
0 commit comments