Previous work on bug 183720 moves much of Canvas 2d's to a base class. The font functions are skipped mainly I assume due to a reliance on Document to be able to use fonts. This bug is for moving that functionality into the relevant base classes, but not necessarily removing the Document dependency (which is a much larger task that it'd be sensible to split as much work away from as possible).
Created attachment 380631 [details] Patch
Comment on attachment 380631 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=380631&action=review > Source/WebCore/html/canvas/OffscreenCanvasRenderingContext2D.cpp:60 > + auto parsedStyle = MutableStyleProperties::create(); > + CSSParser::parseValue(parsedStyle, CSSPropertyFont, newFont, true, strictToCSSParserMode(!m_usesCSSCompatibilityParseMode)); > + if (parsedStyle->isEmpty()) As far as I know, CSS parser isn't thread safe due to CSSValuePool and other static variables. For example, consumeFontWeightKeywordValue would use CSSValuePool::singleton().createIdentifierValue.
(In reply to Ryosuke Niwa from comment #2) > Comment on attachment 380631 [details] > As far as I know, CSS parser isn't thread safe due to CSSValuePool and other > static variables. > For example, consumeFontWeightKeywordValue would use > CSSValuePool::singleton().createIdentifierValue. This is correct, however I've altered the behaviour of CSSValuePool when used off the main thread in the dependent patch on bug #182686 to not return static variables.
(In reply to Chris Lord from comment #3) > (In reply to Ryosuke Niwa from comment #2) > > Comment on attachment 380631 [details] > > As far as I know, CSS parser isn't thread safe due to CSSValuePool and other > > static variables. > > For example, consumeFontWeightKeywordValue would use > > CSSValuePool::singleton().createIdentifierValue. > > This is correct, however I've altered the behaviour of CSSValuePool when > used off the main thread in the dependent patch on bug #182686 to not return > static variables. Ah, I didn't see that. I added a comment there.
The work from this bug was essentially done in bug 219088