Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: bef989fc4f32b25f059932a2ff84c9bbb1b32238
https://github.com/WebKit/WebKit/commit/bef989fc4f32b25f059932a2ff84c9bbb1b32238
Author: Karl Dubost <[email protected]>
Date: 2026-02-13 (Fri, 13 Feb 2026)
Changed paths:
M LayoutTests/TestExpectations
M Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp
M Source/WebCore/svg/SVGFitToViewBox.cpp
M Source/WebCore/svg/SVGFitToViewBox.h
M Source/WebCore/svg/SVGSVGElement.cpp
Log Message:
-----------
Fix viewBox rendering to ignore invalid negative dimensions
https://bugs.webkit.org/show_bug.cgi?id=307634
rdar://170214971
Reviewed by Nikolas Zimmermann.
When negative width/height values are set on svg.viewBox.baseVal via
JavaScript, WebKit was incorrectly treating them as "empty" viewBox and
disabling rendering. Per SVG spec and matching Firefox/Chrome behavior,
negative dimensions should be stored and returned via DOM API, but
ignored during rendering (render as if no viewBox attribute exists).
The root cause was that hasEmptyViewBox() was using FloatRect::isEmpty()
which returns true for negative values (width <= 0). This caused invalid
viewBox to be treated the same as empty viewBox (both disabled rendering).
The fix changes hasEmptyViewBox() to first check hasValidViewBox(),
ensuring only valid-but-empty viewBox (width = 0) disables rendering,
while invalid viewBox (width < 0) is ignored and content renders normally.
Test:
imported/w3c/web-platform-tests/svg/coordinate-systems/viewBox-baseVal-change-invalid.html
* LayoutTests/TestExpectations:
* Source/WebCore/rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::updateLayerTransform):
* Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp:
(WebCore::RenderSVGViewportContainer::updateLayerTransform):
(WebCore::RenderSVGViewportContainer::overflowClipRect const):
* Source/WebCore/svg/SVGFitToViewBox.cpp:
(WebCore::SVGFitToViewBox::viewBoxToViewTransform):
* Source/WebCore/svg/SVGFitToViewBox.h:
(WebCore::SVGFitToViewBox::hasValidViewBox const):
(WebCore::SVGFitToViewBox::hasEmptyViewBox const):
* Source/WebCore/svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::localCoordinateSpaceTransform const):
(WebCore::SVGSVGElement::currentViewBoxRect const):
(WebCore::SVGSVGElement::viewBoxToViewTransform const):
Canonical link: https://commits.webkit.org/307463@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications