Enable Canvas2d text methods to work without a presShell or presContext
Categories
(Core :: Layout: Text and Fonts, enhancement)
Tracking
()
Tracking | Status | |
---|---|---|
firefox102 | --- | fixed |
People
(Reporter: jfkthame, Assigned: jfkthame)
References
(Blocks 1 open bug)
Details
Attachments
(6 files)
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
The font/text code in CanvasRenderingContext2d (SetFontInternal, DrawOrMeasureText) assumes availability of a presShell and presContext; for offscreen-canvas/worker-thread use, we need to allow it to work independently of these.
Assignee | ||
Comment 1•3 years ago
|
||
Nothing uses this member, so remove it to make it clear we don't need to provide it
when setting up a CanvasRenderingContext2D.
Assignee | ||
Comment 2•3 years ago
|
||
We don't need to null-check the mCanvasElement and mDocShell members in these methods,
and bail out if neither is provided, because in that case the following GetPresShell() call
will return null and we'll bail out there anyhow.
Removing these extra checks will simplify the changes involved in enabling the canvas code
to be used in a Worker context, where it is not connected to a document.
Depends on D144184
Assignee | ||
Comment 3•3 years ago
|
||
These need to be atomic so that they can be accessed by canvas code when running on a worker thread
without calling main-thread-only Preferences APIs.
Depends on D144185
Assignee | ||
Comment 4•3 years ago
|
||
When running in a Worker, the canvas2d SetFontInternal method can't call GetFontStyleForServo
because it doesn't have a canvasElement or presShell to pass. But we can use the method
ServoCSSParser::ParseFontShorthandForMatching to parse the canvas 'font' property, if we
extend it so as to also return the size from the font shorthand.
Depends on D144186
Assignee | ||
Comment 5•3 years ago
|
||
This enables an offscreen-canvas Worker to do text rendering, but only with system-installed fonts
because we don't yet have a FontFaceSet available in the Worker. (That's bug 1758946.)
Depends on D144187
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Comment 6•3 years ago
|
||
I think it doesn't make sense to support em/percentages without
supporting smaller/bigger/other font-relative things.
I have many questions about how other units like viewport-units etc are
supposed to behave. Blink seems to resolve viewport units to zero:
Which might be reasonable, but I think keeping a simple model consistent
with what other code like DOMMatrix does seems better for now.
Updated•3 years ago
|
Updated•3 years ago
|
Assignee | ||
Updated•3 years ago
|
Updated•3 years ago
|
Assignee | ||
Comment 7•3 years ago
|
||
Queued the preliminary patches for landing, to avoid bit-rot and get them out of my local tree. Marking this as leave-open, pending review/landing of part 5.
Comment 9•3 years ago
|
||
bugherder |
Assignee | ||
Updated•3 years ago
|
Comment 10•3 years ago
|
||
Comment 11•3 years ago
|
||
bugherder |
Description
•