Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: a09cbd759c1a2625ac0e34ddf8a488dc154fe582
https://github.com/WebKit/WebKit/commit/a09cbd759c1a2625ac0e34ddf8a488dc154fe582
Author: Ahmad Saleem <[email protected]>
Date: 2026-09-06 (Sun, 06 Sep 2026)
Changed paths:
M Source/WebCore/html/HTMLCanvasElement.cpp
M Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
M Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h
Log Message:
-----------
[Canvas] Modernize CanvasRenderingContext2DBase/HTMLCanvasElement constants
to constexpr
https://bugs.webkit.org/show_bug.cgi?id=323442
rdar://186675589
Reviewed by Chris Dumez.
Turn a handful of canvas constants into compile-time constants. This
removes a runtime sqrtf() initializer (and its thread-safe-init guard)
for the stroke-rect approximation, and lets the default font-size,
font-family, and default canvas dimensions be plain
constexpr values
instead of out-of-line static definitions. No behavior change.
* Source/WebCore/html/HTMLCanvasElement.cpp:
Make defaultWidth/defaultHeight constexpr.
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:
Replace static const float root2 = sqrtf(2) with
static constexpr float root2 = std::numbers::sqrt2_v<float>, and drop
the out-of-line DefaultFontSize/DefaultFontFamily definitions now that
they are initialized in the header.
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h:
Make DefaultFontSize/DefaultFontFamily static constexpr auto with
in-class initializers.
Canonical link:
https://flagged.apple.com:443/proxy?t2=DG2z9A5gk1&o=aHR0cHM6Ly9jb21taXRzLndlYmtpdC5vcmcvMzIwNTk4QG1haW4=&emid=0dab2e14-0f16-428f-bd19-2084df53141a&c=11
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications