Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ae45cfcca596a58a0202e585a88ce6dfcba4147a
      
https://github.com/WebKit/WebKit/commit/ae45cfcca596a58a0202e585a88ce6dfcba4147a
  Author: Sammy Gill <[email protected]>
  Date:   2026-07-24 (Fri, 24 Jul 2026)

  Changed paths:
    M Source/WebCore/layout/formattingContexts/grid/GridLayoutUtils.cpp
    M Source/WebCore/layout/layouttree/LayoutElementBox.cpp
    M Source/WebCore/layout/layouttree/LayoutElementBox.h

  Log Message:
  -----------
  [GFC] Implement initial logic for automatic sizes of replaced elements
https://bugs.webkit.org/show_bug.cgi?id=319995
rdar://182927210

Reviewed by Alan Baradlay.

https://drafts.csswg.org/css-grid-1/#grid-item-sizing

When a replaced element is not being stretched due to its alignment then
we try to size it to its natrual sizes. This falls into the logic that
comes from the rules of block-level elements from CSS2. There is extra
work that is needed for the case where a repalced element does not have
a natural size, but we defer to do that in a later patch since this
should be the common case.

After this there should only be two cases left that we need to figure
out in terms of computing the automatic sizes for grid items. These are
the replaced elements without a natural size and non-replaced elements
with a preferred aspect ratio that are documented in the FIXME.

Also, we work with the assumption that the content is all horizontal-tb
since that is the only thing allowed into GFC. Incorporating other
writing modes will ideally just be a small API changing to make sure the
mapping is done correctly and the core logic this patch introduces
should remain the same.

* Source/WebCore/layout/layouttree/LayoutElementBox.cpp:
(WebCore::Layout::ElementBox::hasNaturalWidth const):
(WebCore::Layout::ElementBox::hasNaturalHeight const):
(WebCore::Layout::ElementBox::naturalWidth const):
(WebCore::Layout::ElementBox::naturalHeight const):
We had an API that checked the box for an intrinsic width/height, but
those also handle cases where the box is a non-replaced element which is
something we are not concerned with for this portion of the spec. I
added a set of natural size APIs that is similar but is targeted only
boxes which are replaced elements since that is the type of content that
has natural sizes.

https://www.w3.org/TR/css-images-3/#natural-size
Canonical link: https://commits.webkit.org/317874@main



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

Reply via email to