Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 5fb77d6068fb458d3b75048ea19c074eb8970cf2
https://github.com/WebKit/WebKit/commit/5fb77d6068fb458d3b75048ea19c074eb8970cf2
Author: Ahmad Saleem <[email protected]>
Date: 2026-08-23 (Sun, 23 Aug 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/layers/2d.layer.layer-rendering-state-reset-in-layer-expected.txt
M Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
Log Message:
-----------
2D canvas beginLayer() resets shadowColor to opaque black and re-parses
constant strings
https://bugs.webkit.org/show_bug.cgi?id=322172
rdar://185404307
Reviewed by Gerald Squelart.
beginLayer() reset the layer rendering state by calling the public setters with
constant strings. That was both wrong and expensive.
Wrong: setShadowColor("black") parses to opaque black, but the initial value of
shadowColor -- and the value beginLayer() is specified to reset to -- is
transparent black. Any shadowBlur or shadowOffset set inside the layer therefore
painted a shadow that should not exist, and ctx.shadowColor read back "#000000"
instead of "rgba(0, 0, 0, 0)". Separately, setFilterString() gives up when the
canvas has no computed style, so a non-rendered canvas kept its filter inside
the
layer and applied it twice.
Expensive: setGlobalCompositeOperation() and setShadowColor() parse before
checking whether the value changed, so every beginLayer() ran a composite
operator parse and a full CSS color parse. setFilterString() goes through
setFilterStringWithoutUpdatingStyle(), which calls
Document::updateStyleIfNeeded()
-- a synchronous style recalc in the middle of beginLayer().
Set the state fields directly instead, and push only what the layer's
GraphicsContext needs: the transparency-layer switcher draws into the
destination
context, so alpha, composite operator and shadow still have to be applied there.
*
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/layers/2d.layer.layer-rendering-state-reset-in-layer-expected.txt:
Progression
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::beginLayer):
Canonical link: https://commits.webkit.org/319675@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications