Bug 219088 - Enable font functions on OffscreenCanvas for main-thread
Summary: Enable font functions on OffscreenCanvas for main-thread
Status: RESOLVED FIXED
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: InRadar
Depends on: 219151
Blocks: 183720 186759
  Show dependency treegraph
 
Reported: 2020-11-18 08:07 PST by Chris Lord
Modified: 2020-11-27 11:36 PST (History)
15 users (show)

See Also:


Attachments
Patch (122.65 KB, patch)
2020-11-19 05:06 PST, Chris Lord
no flags Details | Formatted Diff | Diff
Patch (122.64 KB, patch)
2020-11-20 01:38 PST, Chris Lord
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Lord 2020-11-18 08:07:17 PST
There is still a lot of work to do (I think) to make text usable on 2d contexts for OffscreenCanvas in a Worker, but that shouldn't stop us from enabling those functions for use on the main thread. This bug tracks enabling the functions on the main thread only.
Comment 1 Chris Lord 2020-11-19 05:06:40 PST
Created attachment 414566 [details]
Patch
Comment 2 Simon Fraser (smfr) 2020-11-19 09:54:12 PST
Comment on attachment 414566 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=414566&action=review

> Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:2255
> +String CanvasRenderingContext2DBase::font() const

This should be called fontStyle or something. It doesn't return a Font*

> Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:2484
> +#if USE(CG)

Sad to see #if USE(CG) here.

> Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h:384
> +    // Therefore, all font operations must pass through the State.

Not clear from this comment what "the State" refers to.
Comment 3 Darin Adler 2020-11-19 11:17:52 PST
Comment on attachment 414566 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=414566&action=review

>> Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:2255
>> +String CanvasRenderingContext2DBase::font() const
> 
> This should be called fontStyle or something. It doesn't return a Font*

The name font here comes from the HTML specification of CanvasTextDrawingStyles <https://html.spec.whatwg.org/#dom-context-2d-font>. So it needs to be "font" in the IDL file. We can make it different in C++ by renaming it using [ImplementedAs]. Iā€™m not sure we should do that, but if we do we sometimes use names like fontForBindings, or could use your suggested fontStyle or serializedFont or fontString.
Comment 4 Simon Fraser (smfr) 2020-11-19 11:18:50 PST
OK, not worth fixing then.
Comment 5 Chris Lord 2020-11-20 01:35:06 PST
(In reply to Simon Fraser (smfr) from comment #2)
> Comment on attachment 414566 [details]
> Patch
> > Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:2484
> > +#if USE(CG)
> 
> Sad to see #if USE(CG) here.

This is pre-existing. Reading the code, I don't know why that behaviour is specific to USE(CG), probably worth digging into... I'd rather not touch it with this patch though, which was just moving this from CanvasRenderingContext2D to Base.

> > Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h:384
> > +    // Therefore, all font operations must pass through the State.
> 
> Not clear from this comment what "the State" refers to.

Also pre-existing, but I've changed 'the State' to 'the proxy', because I don't see what else it could be referring to. Maybe this was a comment that missed some name-changes...
Comment 6 Chris Lord 2020-11-20 01:38:46 PST
Created attachment 414663 [details]
Patch
Comment 7 EWS 2020-11-20 03:40:30 PST
Committed r270102: <https://trac.webkit.org/changeset/270102>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 414663 [details].
Comment 8 Radar WebKit Bug Importer 2020-11-20 03:41:19 PST
<rdar://problem/71622345>
Comment 9 Don Olmstead 2020-11-27 09:44:10 PST
This patch managed to use isSpaceThatNeedsReplacing which is defined statically in CanvasRenderingContext2D.cpp so it breaks non-unified builds.

Things seem happy if you move it into the CanvasRenderingContext2DBase.h but is there a better place for that?
Comment 10 Chris Lord 2020-11-27 09:48:13 PST
(In reply to Don Olmstead from comment #9)
> This patch managed to use isSpaceThatNeedsReplacing which is defined
> statically in CanvasRenderingContext2D.cpp so it breaks non-unified builds.
> 
> Things seem happy if you move it into the CanvasRenderingContext2DBase.h but
> is there a better place for that?

CanvasRenderingContext2DBase makes sense to me, and sorry I missed that... Is there a bug open about this?
Comment 11 Don Olmstead 2020-11-27 11:36:35 PST
(In reply to Chris Lord from comment #10)
> (In reply to Don Olmstead from comment #9)
> > This patch managed to use isSpaceThatNeedsReplacing which is defined
> > statically in CanvasRenderingContext2D.cpp so it breaks non-unified builds.
> > 
> > Things seem happy if you move it into the CanvasRenderingContext2DBase.h but
> > is there a better place for that?
> 
> CanvasRenderingContext2DBase makes sense to me, and sorry I missed that...
> Is there a bug open about this?

Actually Adrian got to it in https://trac.webkit.org/changeset/270197/webkit right after I mentioned it here.