Re: [csswg-drafts] [css-sizing] Resolved value of min size properties doesn't round-trip (#11716)

BTW, this is the logic in browsers.

- https://searchfox.org/mozilla-central/rev/1678bc7ae853954854542c5dcddd14f6600bb9d0/layout/style/nsComputedDOMStyle.cpp#1804-1819

    ```cpp
    /**
     * This function indicates whether we should return "auto" as the
     * getComputedStyle() result for the (default) "min-width: auto" and
     * "min-height: auto" CSS values.
     *
     * As of this writing, the CSS Sizing draft spec says this "auto" value
     * *always* computes to itself.  However, for now, we only make it compute to
     * itself for grid and flex items (the containers where "auto" has special
     * significance), because those are the only areas where the CSSWG has actually
     * resolved on this "computes-to-itself" behavior. For elements in other sorts
     * of containers, this function returns false, which will make us resolve
     * "auto" to 0.
     */
    bool nsComputedDOMStyle::ShouldHonorMinSizeAutoInAxis(PhysicalAxis aAxis) {
      return mOuterFrame && mOuterFrame->IsFlexOrGridItem();
    }
    ```

- https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/css/properties/computed_style_utils.cc;l=747-753;drc=ebb421b7cdc02be3ee4abf49d6bad7646b3da9ab

    ```cpp
    CSSValue* ComputedStyleUtils::MinWidthOrMinHeightAuto(
        const ComputedStyle& style) {
      if (style.IsFlexOrGridOrCustomItem() && !style.IsEnsuredInDisplayNone()) {
        return CSSIdentifierValue::Create(CSSValueID::kAuto);
      }
      return ZoomAdjustedPixelValue(0, style);
    }
    ```

- https://searchfox.org/wubkat/rev/7d784721e440d04932945e2decb933720c4e0fc7/Source/WebCore/css/ComputedStyleExtractor.cpp#4206-4219

    ```cpp
        case CSSPropertyMinHeight:
            if (style.minHeight().isAuto()) {
                if (isFlexOrGridItem(renderer))
                    return CSSPrimitiveValue::create(CSSValueAuto);
                return zoomAdjustedPixelValue(0, style);
            }
            return zoomAdjustedPixelValueForLength(style.minHeight(), style);
        case CSSPropertyMinWidth:
            if (style.minWidth().isAuto()) {
                if (isFlexOrGridItem(renderer))
                    return CSSPrimitiveValue::create(CSSValueAuto);
                return zoomAdjustedPixelValue(0, style);
            }
            return zoomAdjustedPixelValueForLength(style.minWidth(), style);
    ```

-- 
GitHub Notification of comment by Loirooriol
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11716#issuecomment-2719475074 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 13 March 2025 01:00:13 UTC