Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6b879687ee9429781c5dacc0d123e73105f06511
      
https://github.com/WebKit/WebKit/commit/6b879687ee9429781c5dacc0d123e73105f06511
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M LayoutTests/TestExpectations
    M Source/WebCore/rendering/BackgroundPainter.cpp

  Log Message:
  -----------
  background-size: cover paints nothing for an SVG image with an extreme 
natural aspect ratio
https://bugs.webkit.org/show_bug.cgi?id=322736
rdar://186006463

Reviewed by Simon Fraser.

An SVG image whose natural aspect ratio is extreme e.g. a viewBox of
"0 0 1 2147483647" with one specified dimension, rounds the derived
dimension of its resolved intrinsic size down to zero in
RenderBoxModelObject::calculateImageIntrinsicDimensions() (8 * 1 / 2147483647
floors to 0 as a LayoutUnit). BackgroundPainter::calculateFillTileSize()'s
cover/contain handling then scales that intrinsic size by a single factor,
which can never recover the lost dimension: it hits the isEmpty() guard and
returns an empty tile, so nothing is painted. cover on such an image is
supposed to fill the positioning area.

The cover and contain concrete object size depends only on the natural aspect
ratio and the constraint rectangle, not on the (possibly sub-pixel, rounded)
intrinsic pixel size. When the resolved intrinsic size has collapsed to empty
but the image still reports a non-empty natural ratio, derive the concrete
size from the ratio and the positioning area directly:

  "A contain constraint is resolved by setting the concrete object size to the
   largest rectangle that has the object's natural aspect ratio and
   additionally has neither width nor height larger than the constraint
   rectangle's [...]. A cover constraint is resolved by setting the concrete
   object size to the smallest rectangle that has the object's natural aspect
   ratio and additionally has neither width nor height smaller than the
   constraint rectangle's [...]." [1]

For an extreme ratio contain collapses the tiny axis to zero (empty, matching
the -empty references) while cover expands it to fill the area (matching the
-lime references). The new path only runs when the resolved intrinsic size is
empty and a natural ratio exists, so ordinary cover/contain sizing is
unchanged.

This is CSS box code shared by both the legacy and layer-based SVG engines;
the SVG image's natural ratio comes from SVGImage::computeIntrinsicDimensions.

[1] https://drafts.csswg.org/css-images-3/#cover-contain

* LayoutTests/TestExpectations: Unskip now passing tests
* Source/WebCore/rendering/BackgroundPainter.cpp:
(WebCore::BackgroundPainter::calculateFillTileSize):

Canonical link: https://commits.webkit.org/320008@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to