Bug 202626 - Move font-rendering code from CanvasRenderingContext2D to CanvasRenderingContext2DBase to be used with OffscreenCanvas
Summary: Move font-rendering code from CanvasRenderingContext2D to CanvasRenderingCont...
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Lord
URL:
Keywords:
Depends on: 182686
Blocks: 186759 202793
  Show dependency treegraph
 
Reported: 2019-10-07 01:15 PDT by Chris Lord
Modified: 2021-01-20 06:56 PST (History)
8 users (show)

See Also:


Attachments
Patch (82.44 KB, patch)
2019-10-10 04:18 PDT, Chris Lord
rniwa: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Lord 2019-10-07 01:15:32 PDT
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).
Comment 1 Chris Lord 2019-10-10 04:18:46 PDT
Created attachment 380631 [details]
Patch
Comment 2 Ryosuke Niwa 2019-10-10 12:41:17 PDT
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.
Comment 3 Chris Lord 2019-10-11 01:51:40 PDT
(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.
Comment 4 Ryosuke Niwa 2019-10-11 02:45:19 PDT
(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.
Comment 5 Chris Lord 2021-01-20 06:56:41 PST
The work from this bug was essentially done in bug 219088