MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / xmlSAX2StartElement

Method xmlSAX2StartElement

Source/Cache/SVGCache.cpp:300–731  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298}
299
300void SVGCache::Parser::xmlSAX2StartElement(std::string_view name, const std::vector<std::string_view>& selfAttrs) {
301 auto def = getItem();
302 auto attrs = selfAttrs;
303 if (!_attrStack.empty()) {
304 attrs.insert(--attrs.end(),
305 _attrStack.top().begin(), _attrStack.top().end());
306 }
307 switch (Switch::hash(name)) {
308 case "svg"_hash: {
309 ATTR_START
310 case "width"_hash: def->_width = v.toFloat(); break;
311 case "height"_hash: def->_height = v.toFloat(); break;
312 case "viewBox"_hash: {
313 Rect rc;
314 get(v, rc);
315 def->_width = rc.getWidth();
316 def->_height = rc.getHeight();
317 break;
318 }
319 ATTR_STOP
320 break;
321 }
322 case "circle"_hash: {
323 CircleData data;
324 ATTR_START
325 case "cx"_hash: data.cx = v.toFloat(); break;
326 case "cy"_hash: data.cy = v.toFloat(); break;
327 case "r"_hash: data.r = v.toFloat(); break;
328 case "style"_hash: attribStyle(data.fillStroke, v); break;
329 default:
330 attribFillStroke(data.fillStroke, k, v);
331 break;
332 ATTR_STOP
333 def->_commands.push_back([data](SVGDef::Context* ctx) {
334 drawBegin(ctx);
335 nvgCircle(ctx->nvg, data.cx, data.cy, data.r);
336 drawEnd(ctx, data.fillStroke);
337 });
338 break;
339 }
340 case "ellipse"_hash: {
341 EllipseData data;
342 ATTR_START
343 case "cx"_hash: data.cx = v.toFloat(); break;
344 case "cy"_hash: data.cy = v.toFloat(); break;
345 case "rx"_hash: data.rx = v.toFloat(); break;
346 case "ry"_hash: data.ry = v.toFloat(); break;
347 case "style"_hash: attribStyle(data.fillStroke, v); break;
348 default:
349 attribFillStroke(data.fillStroke, k, v);
350 break;
351 ATTR_STOP
352 def->_commands.push_back([data](SVGDef::Context* ctx) {
353 drawBegin(ctx);
354 nvgEllipse(ctx->nvg, data.cx, data.cy, data.rx, data.ry);
355 drawEnd(ctx, data.fillStroke);
356 });
357 break;

Callers

nothing calls this directly

Calls 15

getItemFunction · 0.85
attribStyleFunction · 0.85
attribFillStrokeFunction · 0.85
drawBeginFunction · 0.85
nvgCircleFunction · 0.85
drawEndFunction · 0.85
nvgEllipseFunction · 0.85
nvgMoveToFunction · 0.85
nvgLineToFunction · 0.85
getTransformFunction · 0.85
parse_errorClass · 0.85
moveFunction · 0.85

Tested by

no test coverage detected