commit a298edf3cf170ae4ef4fd7d1b0a69c8554bca127
parent 196bb39b82855fd24c6c38e69b97bbdbebc17866
Author: Jonathan Kew <jkew@mozilla.com>
Date: Sun, 30 Nov 2025 08:30:15 +0000
Bug 2003060 - Pass the proper FontVisibilityProvider for offscreen canvas in GetCurrentFontStyle(). r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D274483
Diffstat:
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -5301,11 +5301,18 @@ gfxFontGroup* CanvasRenderingContext2D::GetCurrentFontStyle() {
nsPresContext* presContext =
presShell ? presShell->GetPresContext() : nullptr;
+ FontVisibilityProvider* visProvider = nullptr;
+ if (presContext) {
+ visProvider = presContext;
+ } else {
+ visProvider = mOffscreenCanvas;
+ }
+
// If we have a cached fontGroup, check that it is valid for the current
- // prescontext; if not, we need to discard and re-create it.
+ // prescontext or canvas; if not, we need to discard and re-create it.
RefPtr<gfxFontGroup>& fontGroup = CurrentState().fontGroup;
if (fontGroup) {
- if (fontGroup->GetFontVisibilityProvider() != presContext) {
+ if (fontGroup->GetFontVisibilityProvider() != visProvider) {
fontGroup = nullptr;
}
}
@@ -5333,7 +5340,7 @@ gfxFontGroup* CanvasRenderingContext2D::GetCurrentFontStyle() {
const auto* sans =
Servo_FontFamily_Generic(StyleGenericFontFamily::SansSerif);
fontGroup = new gfxFontGroup(
- presContext, sans->families, &style, language, explicitLanguage,
+ visProvider, sans->families, &style, language, explicitLanguage,
presContext ? presContext->GetTextPerfMetrics() : nullptr, nullptr,
devToCssSize, StyleFontVariantEmoji::Normal);
if (fontGroup) {