Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: eedb96ae03e843a4ef7ba20ab7ceab0bf0fa997b
      
https://github.com/WebKit/WebKit/commit/eedb96ae03e843a4ef7ba20ab7ceab0bf0fa997b
  Author: Sam Weinig <[email protected]>
  Date:   2025-06-12 (Thu, 12 Jun 2025)

  Changed paths:
    M LayoutTests/editing/style/apply-style-atomic-expected.txt
    M LayoutTests/editing/style/apply-style-atomic-live-range-expected.txt
    M Source/WebCore/CMakeLists.txt
    M Source/WebCore/Headers.cmake
    M Source/WebCore/SaferCPPExpectations/ForwardDeclCheckerExpectations
    M 
Source/WebCore/SaferCPPExpectations/UncountedLambdaCapturesCheckerExpectations
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/css/CSSProperties.json
    M Source/WebCore/css/values/primitives/CSSPrimitiveNumericRange.h
    M Source/WebCore/css/values/primitives/CSSPrimitiveNumericUnits.h
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/html/HTMLInputElement.cpp
    M Source/WebCore/html/HTMLTextFormControlElement.cpp
    M Source/WebCore/html/NumberInputType.cpp
    M Source/WebCore/html/SearchInputType.cpp
    M Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp
    M Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.cpp
    M Source/WebCore/html/shadow/ProgressShadowElement.cpp
    M Source/WebCore/html/shadow/TextControlInnerElements.cpp
    M Source/WebCore/layout/formattingContexts/FormattingGeometry.cpp
    M Source/WebCore/layout/formattingContexts/FormattingGeometry.h
    M Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.cpp
    M Source/WebCore/layout/formattingContexts/block/BlockFormattingQuirks.cpp
    M Source/WebCore/layout/formattingContexts/block/BlockMarginCollapse.cpp
    M Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp
    M Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp
    M Source/WebCore/layout/formattingContexts/table/TableFormattingQuirks.cpp
    M Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp
    M Source/WebCore/layout/layouttree/LayoutElementBox.cpp
    M Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp
    M Source/WebCore/page/LocalFrameView.cpp
    M Source/WebCore/page/ios/ContentChangeObserver.cpp
    M Source/WebCore/platform/Length.cpp
    M Source/WebCore/platform/Length.h
    M Source/WebCore/rendering/AutoTableLayout.cpp
    M Source/WebCore/rendering/AutoTableLayout.h
    M Source/WebCore/rendering/FixedTableLayout.cpp
    M Source/WebCore/rendering/FixedTableLayout.h
    M Source/WebCore/rendering/GridLayoutFunctions.cpp
    M Source/WebCore/rendering/GridMasonryLayout.cpp
    M Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp
    M Source/WebCore/rendering/GridTrackSizingAlgorithm.h
    M Source/WebCore/rendering/PositionedLayoutConstraints.cpp
    M Source/WebCore/rendering/RenderAttachment.cpp
    M Source/WebCore/rendering/RenderBlock.cpp
    M Source/WebCore/rendering/RenderBlockFlow.cpp
    M Source/WebCore/rendering/RenderBox.cpp
    M Source/WebCore/rendering/RenderBox.h
    M Source/WebCore/rendering/RenderBoxModelObject.cpp
    M Source/WebCore/rendering/RenderBoxModelObject.h
    M Source/WebCore/rendering/RenderButton.cpp
    M Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp
    M Source/WebCore/rendering/RenderElement.cpp
    M Source/WebCore/rendering/RenderFileUploadControl.cpp
    M Source/WebCore/rendering/RenderFlexibleBox.cpp
    M Source/WebCore/rendering/RenderFlexibleBox.h
    M Source/WebCore/rendering/RenderFragmentContainer.cpp
    M Source/WebCore/rendering/RenderGrid.cpp
    M Source/WebCore/rendering/RenderLayer.cpp
    M Source/WebCore/rendering/RenderListBox.cpp
    M Source/WebCore/rendering/RenderListMarker.cpp
    M Source/WebCore/rendering/RenderMenuList.cpp
    M Source/WebCore/rendering/RenderMultiColumnSet.cpp
    M Source/WebCore/rendering/RenderObject.cpp
    M Source/WebCore/rendering/RenderReplaced.cpp
    M Source/WebCore/rendering/RenderScrollbarPart.cpp
    M Source/WebCore/rendering/RenderSlider.cpp
    M Source/WebCore/rendering/RenderTable.cpp
    M Source/WebCore/rendering/RenderTable.h
    M Source/WebCore/rendering/RenderTableCell.cpp
    M Source/WebCore/rendering/RenderTableCell.h
    M Source/WebCore/rendering/RenderTableCellInlines.h
    M Source/WebCore/rendering/RenderTableSection.cpp
    M Source/WebCore/rendering/RenderTableSection.h
    M Source/WebCore/rendering/RenderTextControl.cpp
    M Source/WebCore/rendering/RenderTextControlMultiLine.cpp
    M Source/WebCore/rendering/RenderTextControlSingleLine.cpp
    M Source/WebCore/rendering/RenderTheme.cpp
    M Source/WebCore/rendering/RenderTheme.h
    M Source/WebCore/rendering/adwaita/RenderThemeAdwaita.cpp
    M Source/WebCore/rendering/adwaita/RenderThemeAdwaita.h
    M Source/WebCore/rendering/cocoa/RenderThemeCocoa.h
    M Source/WebCore/rendering/cocoa/RenderThemeCocoa.mm
    M Source/WebCore/rendering/ios/RenderThemeIOS.h
    M Source/WebCore/rendering/ios/RenderThemeIOS.mm
    M Source/WebCore/rendering/line/BreakingContext.h
    M Source/WebCore/rendering/mac/RenderThemeMac.h
    M Source/WebCore/rendering/mac/RenderThemeMac.mm
    M Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp
    M Source/WebCore/rendering/style/RenderStyle.cpp
    M Source/WebCore/rendering/style/RenderStyle.h
    M Source/WebCore/rendering/style/RenderStyleInlines.h
    M Source/WebCore/rendering/style/RenderStyleSetters.h
    M Source/WebCore/rendering/style/StyleBoxData.cpp
    M Source/WebCore/rendering/style/StyleBoxData.h
    M Source/WebCore/rendering/style/StyleFlexibleBoxData.cpp
    M Source/WebCore/rendering/style/StyleFlexibleBoxData.h
    M Source/WebCore/rendering/style/TextSizeAdjustment.cpp
    M Source/WebCore/rendering/svg/RenderSVGImage.cpp
    M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGImage.cpp
    M Source/WebCore/rendering/updating/RenderTreeBuilder.cpp
    M Source/WebCore/rendering/updating/RenderTreeUpdaterViewTransition.cpp
    M Source/WebCore/style/StyleAdjuster.cpp
    M Source/WebCore/style/StyleBuilderConverter.h
    M Source/WebCore/style/StyleBuilderCustom.h
    M Source/WebCore/style/StyleExtractorConverter.h
    M Source/WebCore/style/StyleExtractorCustom.h
    M Source/WebCore/style/StyleExtractorSerializer.h
    M Source/WebCore/style/StyleResolver.cpp
    M Source/WebCore/style/values/box/StyleMargin.h
    M Source/WebCore/style/values/box/StylePadding.h
    A Source/WebCore/style/values/flexbox/StyleFlexBasis.cpp
    A Source/WebCore/style/values/flexbox/StyleFlexBasis.h
    M Source/WebCore/style/values/position/StyleInset.h
    M 
Source/WebCore/style/values/primitives/StylePrimitiveNumericTypes+Evaluation.h
    M Source/WebCore/style/values/primitives/StyleUnevaluatedCalculation.cpp
    M Source/WebCore/style/values/primitives/StyleUnevaluatedCalculation.h
    M Source/WebCore/style/values/scroll-snap/StyleScrollMargin.h
    M Source/WebCore/style/values/scroll-snap/StyleScrollPadding.h
    A Source/WebCore/style/values/sizing/StyleMaximumSize.cpp
    A Source/WebCore/style/values/sizing/StyleMaximumSize.h
    A Source/WebCore/style/values/sizing/StyleMinimumSize.cpp
    A Source/WebCore/style/values/sizing/StyleMinimumSize.h
    A Source/WebCore/style/values/sizing/StylePreferredSize.cpp
    A Source/WebCore/style/values/sizing/StylePreferredSize.h
    M Source/WebCore/svg/SVGLengthContext.cpp
    M Source/WebCore/svg/SVGLengthContext.h

  Log Message:
  -----------
  [Style] Use strong Style value types for size types width, height, min-width, 
min-height, max-width, max-height, and flex-basis
https://bugs.webkit.org/show_bug.cgi?id=294041

Reviewed by Darin Adler.

Adds types to represent "preferred size", "minimum size", "maximum size" and 
"flex basis":

    Style::PreferredSize (wraps WebCore::Length) - used for the `width` and 
`height` properties.
    Style::MinimumSize (wraps WebCore::Length) - used for the `min-width` and 
`min-height` properties.
    Style::MaximumSize (wraps WebCore::Length) - used for the `max-width` and 
`max-height` properties.
    Style::FlexBasis (wraps WebCore::Length) - used for the `flex-basis` 
property.

The size types are purely zero-cost wrappers of `WebCore::Length`, meaning there
should be no runtime overhead here. The goal of the types is to enforce what
keywords (e.g. 'auto') and value ranges (all or nonnegative) are allowed, just
like with the recently added edge types.

Additionally, instead of allowing direct access to the underlying 
`WebCore::Length`
or to `WebCore::Length::value()`, the numeric value can be accessed via 
functions
like `tryFixed()` which return `std::optional<Style::Length<R>>` or via 
`WTF::switchOn`
which allows switch-statement like access to all alternatives. This means the
old idiomatic way for getting the value:

```
    if (size.isFixed())
        useValue(size.value());
```

is now replaced with:

```
    if (auto fixedValue = size.tryFixed())
        useValue(fixedValue->value);
```

or

```
    WTF::switchOn(size,
        [&](const SizeType::Fixed& fixedValue) {
            useValue(fixedValue.value);
        },
        [&]...
    );
```

This ensures that the numeric value is not used without checking the type.

The biggest changes are in `RenderBox` and `RenderFlexibleBox` where functions 
that took
a `WebCore::Length` and a "size type" parameter now are overloaded for each 
relevant size
type. Where it made sense, a single template function implementation of the 
function was
used with overloads used only to allow the template function to stay 
out-of-line. In some
cases, however, the behavior for the different size types was distinct enough 
that just
using overloads was more appropriate. In some cases, overloads for each keyword 
term was
used. This allowed callers that know the exact type (say, `max-content`) to 
call directly
to the implementation for that type without going through the additional 
dispatch it used to.

* LayoutTests/editing/style/apply-style-atomic-expected.txt:
* LayoutTests/editing/style/apply-style-atomic-live-range-expected.txt:
    - Enforcement of nonnegative numeric range for width/height caught this
      issue where were setting the size to -100% for progress bars.

* Source/WebCore/CMakeLists.txt:
* Source/WebCore/Headers.cmake:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/style/values/flexbox/StyleFlexBasis.cpp: Added.
* Source/WebCore/style/values/flexbox/StyleFlexBasis.h: Added.
* Source/WebCore/style/values/sizing/StyleMaximumSize.cpp: Added.
* Source/WebCore/style/values/sizing/StyleMaximumSize.h: Added.
* Source/WebCore/style/values/sizing/StyleMinimumSize.cpp: Added.
* Source/WebCore/style/values/sizing/StyleMinimumSize.h: Added.
* Source/WebCore/style/values/sizing/StylePreferredSize.cpp: Added.
* Source/WebCore/style/values/sizing/StylePreferredSize.h: Added.
    - Add new files.

* Source/WebCore/style/values/box/StyleMargin.h:
* Source/WebCore/style/values/box/StylePadding.h:
* Source/WebCore/style/values/position/StyleInset.h:
* Source/WebCore/style/values/scroll-snap/StyleScrollMargin.h:
* Source/WebCore/style/values/scroll-snap/StyleScrollPadding.h:
    - Update existing Length wrapping style types to be consistent with
      new formatting and functions. A change in the future will unify these
      with a single base class so keeping them consistent is helpful.

* Source/WebCore/css/CSSProperties.json:
* Source/WebCore/style/StyleBuilderConverter.h:
* Source/WebCore/style/StyleBuilderCustom.h:
* Source/WebCore/style/StyleExtractorConverter.h:
* Source/WebCore/style/StyleExtractorCustom.h:
* Source/WebCore/style/StyleExtractorSerializer.h:
    - Update properties to use new types and associated builder/extractor 
functions.

* Source/WebCore/platform/Length.cpp:
* Source/WebCore/platform/Length.h:
    - Add support for using Length's empty value for 
WTF::HashTableEmptyValueType.
    - Rename isIntrinsicOrAuto() to isIntrinsicOrLegacyIntrinsicOrAuto() to 
make it
      more clear what it actual does.
    - Adds additional isIntrinsicOrLegacyIntrinsic() helper, for when auto is 
not
      wanted.
    - Added tryFixed() and tryPercentage() to allow using Length in generic 
contexts
      with the new style types.

* Source/WebCore/style/StyleResolver.cpp:
    - Ensure that we always have a root element style for the resolver state. 
More
      strict checking of length conversion caught this.

* 
Source/WebCore/style/values/primitives/StylePrimitiveNumericTypes+Evaluation.h:
    - Add missing template parameter needed for non-double Style::Percentage 
evaluation.

* Source/WebCore/style/values/primitives/StyleUnevaluatedCalculation.cpp:
* Source/WebCore/style/values/primitives/StyleUnevaluatedCalculation.h:
    - Add constructor for UnevaluatedCalculation that takes a CalculationValue& 
to allow
      construction from Length without including CalculationValue.h in more 
places.

* Source/WebCore/css/values/primitives/CSSPrimitiveNumericUnits.h:
    - Adds support for multiplication of a unit literal with a scalar.
    - Adds support for division of a unit literal by a scalar.

* Source/WebCore/platform/Theme.cpp:
* Source/WebCore/platform/Theme.h:
* Source/WebCore/platform/adwaita/ThemeAdwaita.cpp:
* Source/WebCore/platform/adwaita/ThemeAdwaita.h:
* Source/WebCore/platform/mac/ThemeMac.h:
* Source/WebCore/platform/mac/ThemeMac.mm:
* Source/WebCore/rendering/RenderTheme.cpp:
* Source/WebCore/rendering/RenderTheme.h:
* Source/WebCore/rendering/adwaita/RenderThemeAdwaita.cpp:
* Source/WebCore/rendering/adwaita/RenderThemeAdwaita.h:
* Source/WebCore/rendering/cocoa/RenderThemeCocoa.mm:
* Source/WebCore/rendering/ios/RenderThemeIOS.mm:
* Source/WebCore/rendering/mac/RenderThemeMac.h:
* Source/WebCore/rendering/mac/RenderThemeMac.mm:
    - Move controlSize() and minimumControlSize() to RenderTheme.

* Source/WebCore/dom/Document.cpp:
    - Removes variable `hasSpecifiedLogicalHeight` which was always false due 
to the expression
      `renderer->style().logicalMaxHeight().isAuto()` always being false. This 
was caught statically
      by the fact that `logicalMaxHeight()` now returns a `Style::MaximumSize` 
which has no `isAuto()`
      function on it.

* Source/WebCore/html/shadow/ProgressShadowElement.cpp:
    - Don't allow negative size values to be set here as the property is 
defined to take nonnegative lengths only.

* Source/WebCore/html/NumberInputType.cpp:
* Source/WebCore/html/SearchInputType.cpp:
* Source/WebCore/html/HTMLInputElement.cpp:
* Source/WebCore/html/HTMLTextFormControlElement.cpp:
* Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp:
* Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.cpp:
* Source/WebCore/html/shadow/TextControlInnerElements.cpp:
* Source/WebCore/layout/formattingContexts/FormattingGeometry.cpp:
* Source/WebCore/layout/formattingContexts/FormattingGeometry.h:
* Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.cpp:
* Source/WebCore/layout/formattingContexts/block/BlockFormattingQuirks.cpp:
* Source/WebCore/layout/formattingContexts/block/BlockMarginCollapse.cpp:
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp:
* Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp:
* Source/WebCore/layout/formattingContexts/table/TableFormattingQuirks.cpp:
* Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp:
* Source/WebCore/layout/layouttree/LayoutElementBox.cpp:
* Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp:
* Source/WebCore/page/LocalFrameView.cpp:
* Source/WebCore/rendering/AutoTableLayout.cpp:
* Source/WebCore/rendering/AutoTableLayout.h:
* Source/WebCore/rendering/FixedTableLayout.cpp:
* Source/WebCore/rendering/FixedTableLayout.h:
* Source/WebCore/rendering/GridLayoutFunctions.cpp:
* Source/WebCore/rendering/GridMasonryLayout.cpp:
* Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp:
* Source/WebCore/rendering/GridTrackSizingAlgorithm.h:
* Source/WebCore/rendering/PositionedLayoutConstraints.cpp:
* Source/WebCore/rendering/RenderAttachment.cpp:
* Source/WebCore/rendering/RenderBlock.cpp:
* Source/WebCore/rendering/RenderBlockFlow.cpp:
* Source/WebCore/rendering/RenderBox.cpp:
* Source/WebCore/rendering/RenderBox.h:
* Source/WebCore/rendering/RenderBoxModelObject.cpp:
* Source/WebCore/rendering/RenderBoxModelObject.h:
* Source/WebCore/rendering/RenderButton.cpp:
* Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp:
* Source/WebCore/rendering/RenderElement.cpp:
* Source/WebCore/rendering/RenderFileUploadControl.cpp:
* Source/WebCore/rendering/RenderFlexibleBox.cpp:
* Source/WebCore/rendering/RenderFlexibleBox.h:
* Source/WebCore/rendering/RenderFragmentContainer.cpp:
* Source/WebCore/rendering/RenderGrid.cpp:
* Source/WebCore/rendering/RenderLayer.cpp:
* Source/WebCore/rendering/RenderListBox.cpp:
* Source/WebCore/rendering/RenderListMarker.cpp:
* Source/WebCore/rendering/RenderMenuList.cpp:
* Source/WebCore/rendering/RenderMultiColumnSet.cpp:
* Source/WebCore/rendering/RenderObject.cpp:
* Source/WebCore/rendering/RenderReplaced.cpp:
* Source/WebCore/rendering/RenderScrollbarPart.cpp:
* Source/WebCore/rendering/RenderSlider.cpp:
* Source/WebCore/rendering/RenderTable.cpp:
* Source/WebCore/rendering/RenderTable.h:
* Source/WebCore/rendering/RenderTableCell.cpp:
* Source/WebCore/rendering/RenderTableCell.h:
* Source/WebCore/rendering/RenderTableCellInlines.h:
* Source/WebCore/rendering/RenderTableSection.cpp:
* Source/WebCore/rendering/RenderTableSection.h:
* Source/WebCore/rendering/RenderTextControl.cpp:
* Source/WebCore/rendering/RenderTextControlMultiLine.cpp:
* Source/WebCore/rendering/RenderTextControlSingleLine.cpp:
* Source/WebCore/rendering/line/BreakingContext.h:
* Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp:
* Source/WebCore/rendering/style/RenderStyle.cpp:
* Source/WebCore/rendering/style/RenderStyle.h:
* Source/WebCore/rendering/style/RenderStyleInlines.h:
* Source/WebCore/rendering/style/RenderStyleSetters.h:
* Source/WebCore/rendering/style/StyleBoxData.cpp:
* Source/WebCore/rendering/style/StyleBoxData.h:
* Source/WebCore/rendering/style/StyleFlexibleBoxData.cpp:
* Source/WebCore/rendering/style/StyleFlexibleBoxData.h:
* Source/WebCore/rendering/style/TextSizeAdjustment.cpp:
* Source/WebCore/rendering/svg/RenderSVGImage.cpp:
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGImage.cpp:
* Source/WebCore/rendering/updating/RenderTreeBuilder.cpp:
* Source/WebCore/rendering/updating/RenderTreeUpdaterViewTransition.cpp:
* Source/WebCore/style/StyleAdjuster.cpp:
* Source/WebCore/svg/SVGLengthContext.cpp:
* Source/WebCore/svg/SVGLengthContext.h:
    - Update for new types.

Originally-landed-as: 296045@main (4bf6d54fbdaf). 
https://bugs.webkit.org/show_bug.cgi?id=294041
Canonical link: https://commits.webkit.org/296172@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to