Bug 151468 - circle's r, cx, and cy should be parsed via fast path
Summary: circle's r, cx, and cy should be parsed via fast path
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-19 17:19 PST by Ryosuke Niwa
Modified: 2019-08-05 21:13 PDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2015-11-19 17:19:50 PST
When a circle element's r, cx, and cy attributes are specified without unit, we end up parsing via yyparse.
We should be using the fast path instead.

This shows up as 10% of CPU time while loading the internal perf dashboard.
We fail because parseSimpleLengthValue in CSSParser.cpp has a check for isStrictParserMode which returns false for SVG elements:

    if (unit == CSSPrimitiveValue::CSS_NUMBER) {
        if (number && isStrictParserMode(cssParserMode))
            return CSSParser::ParseResult::Error;
        unit = CSSPrimitiveValue::CSS_PX;
    }

I don't know this code or SVG well enough to tell why this early exit is needed.
Comment 1 Dirk Schulze 2016-10-05 18:44:41 PDT
Can't comment on yyparse but to add some background to isStrictParserMode:

It was a requirement of the CSS WG that all CSS specified layout properties (r, cx, cy, ..) in SVG must have units (just like every other length unit taking property). Attribute values are still allowed to be unit less for backwards compatibility reasons.

isStrictParserMode is true if the property was specified by CSS (inline style or style sheet for instance) and false if the property was specified by an attribute.