Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ebdf09e290a7e7d7d49d4f2f924dafcc0d5bbe89
      
https://github.com/WebKit/WebKit/commit/ebdf09e290a7e7d7d49d4f2f924dafcc0d5bbe89
  Author: Antti Koivisto <[email protected]>
  Date:   2026-10-07 (Wed, 07 Oct 2026)

  Changed paths:
    M Source/WebCore/CMakeLists.txt
    M Source/WebCore/DerivedSources-output.xcfilelist
    M Source/WebCore/DerivedSources.make
    M Source/WebCore/Headers.cmake
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/css/CSSProperties.json
    M Source/WebCore/css/scripts/process-css-properties.py
    A 
Source/WebCore/css/scripts/test/TestCSSPropertiesResults/UsedStyleProperties.cpp
    A 
Source/WebCore/css/scripts/test/TestCSSPropertiesResults/UsedStyleProperties.h
    M Source/WebCore/layout/formattingContexts/FormattingGeometry.cpp
    M Source/WebCore/layout/integration/LayoutIntegrationBoxGeometryUpdater.cpp
    M 
Source/WebCore/layout/integration/LayoutIntegrationFormattingContextLayout.cpp
    M Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.cpp
    M Source/WebCore/rendering/FloatingObjects.cpp
    M Source/WebCore/rendering/RenderBlock.cpp
    M Source/WebCore/rendering/RenderBlockFlow.cpp
    M Source/WebCore/rendering/RenderBox.cpp
    M Source/WebCore/rendering/RenderBoxInlines.h
    M Source/WebCore/rendering/RenderBoxModelObject.cpp
    M Source/WebCore/rendering/RenderBoxModelObject.h
    M Source/WebCore/rendering/RenderBoxModelObjectInlines.h
    M Source/WebCore/rendering/RenderElement.h
    M Source/WebCore/rendering/RenderElementInlines.h
    M Source/WebCore/rendering/RenderReplaced.cpp
    M Source/WebCore/rendering/RenderScrollbarPart.cpp
    M Source/WebCore/rendering/RenderTable.cpp
    A Source/WebCore/rendering/style/UsedStyle.cpp
    A Source/WebCore/rendering/style/UsedStyle.h
    A Source/WebCore/rendering/style/UsedStyleReferenceSize.h
    M Source/WebCore/style/computed/StyleComputedStyle.cpp
    M Source/WebCore/style/computed/StyleComputedStyle.h
    M Tools/Scripts/webkitpy/style/checkers/cpp.py
    M Tools/Scripts/webkitpy/style/checkers/jsonchecker.py

  Log Message:
  -----------
  Introduce UsedStyle
https://bugs.webkit.org/show_bug.cgi?id=316654
rdar://179104082

Reviewed by Alan Baradlay.

UsedStyle is a stack type that maps ComputedStyle properties to the values used 
in layout, through
generated or hand-written getters chosen per-property via the `used-style` 
codegen property in
CSSProperties.json. (Close to, but not exactly, the spec's post-layout "used 
style".)

This first patch covers float, clear, and the four margin longhands, routing 
the matching layout
reads through usedStyle().

UsedStyle wraps a renderer and derives the computed style from it, so 
renderer-derived inputs
such as the containing block are resolved inside the view.

* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Headers.cmake:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/css/CSSProperties.json:
* Source/WebCore/css/scripts/process-css-properties.py:
(StylePropertyCodeGenProperties):

Add the GenerateUsedStyle generator and the used-style codegen property. Only 
opted-in properties
are emitted, and an unrecognized used-style value is rejected.

* Source/WebCore/css/scripts/test/TestCSSProperties.json:
* 
Source/WebCore/css/scripts/test/TestCSSPropertiesResults/UsedStyleProperties.cpp:
 Added.
* 
Source/WebCore/css/scripts/test/TestCSSPropertiesResults/UsedStyleProperties.h: 
Added.
(WebCore::UsedStyleProperties::UsedStyleProperties):
(WebCore::UsedStyleProperties::computedStyle const):

* Source/WebCore/layout/formattingContexts/FormattingGeometry.cpp:
(WebCore::Layout::FormattingGeometry::computedHorizontalMargin const):
(WebCore::Layout::FormattingGeometry::computedVerticalMargin const):

Read margins through UsedStyle; the std::optional result feeds the auto-margin 
solver.

* Source/WebCore/layout/integration/LayoutIntegrationBoxGeometryUpdater.cpp:
(WebCore::LayoutIntegration::BoxGeometryUpdater::horizontalLogicalMargin):
(WebCore::LayoutIntegration::BoxGeometryUpdater::verticalLogicalMargin):
* 
Source/WebCore/layout/integration/LayoutIntegrationFormattingContextLayout.cpp:
(WebCore::LayoutIntegration::populateIFCWithNewlyPlacedFloats):
* Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::preparePlacedFloats):
* Source/WebCore/rendering/FloatingObjects.cpp:
(WebCore::FloatingObject::FloatingObject):
* Source/WebCore/rendering/RenderBlock.cpp:
(WebCore::RenderBlock::intrinsicLogicalMarginStartAndEnd const):
(WebCore::RenderBlock::computeBlockIntrinsicLogicalWidths const):
* Source/WebCore/rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::selfCollapsingMarginBeforeWithClear):
(WebCore::RenderBlockFlow::marginBeforeEstimateForChild const):
(WebCore::RenderBlockFlow::computeLogicalLocationForFloat):
(WebCore::RenderBlockFlow::positionNewFloats):
(WebCore::RenderBlockFlow::computedClearDeltaForChild):
(WebCore::RenderBlockFlow::computeInlineIntrinsicLogicalWidths const):
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::computeLogicalWidth const):
(WebCore::RenderBox::computeBlockDirectionMargins const):
(WebCore::RenderBox::blockAxisMarginForStretch const):
* Source/WebCore/rendering/RenderBoxInlines.h:
(WebCore::RenderBox::marginBoxRect const):
* Source/WebCore/rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::computeStickyPositionConstraints const):
(WebCore::RenderBoxModelObject::marginTop const):
(WebCore::RenderBoxModelObject::marginBottom const):
(WebCore::RenderBoxModelObject::marginLeft const):
(WebCore::RenderBoxModelObject::marginRight const):
(WebCore::RenderBoxModelObject::marginBefore const):
(WebCore::RenderBoxModelObject::marginAfter const):
(WebCore::RenderBoxModelObject::marginStart const):
(WebCore::RenderBoxModelObject::marginEnd const):
* Source/WebCore/rendering/RenderBoxModelObject.h:
* Source/WebCore/rendering/RenderBoxModelObjectInlines.h:
(WebCore::RenderBoxModelObject::computedCSSMarginTop const): Deleted.
(WebCore::RenderBoxModelObject::computedCSSMarginBottom const): Deleted.
(WebCore::RenderBoxModelObject::computedCSSMarginLeft const): Deleted.
(WebCore::RenderBoxModelObject::computedCSSMarginRight const): Deleted.
(WebCore::RenderBoxModelObject::computedCSSMarginBefore const): Deleted.
(WebCore::RenderBoxModelObject::computedCSSMarginAfter const): Deleted.
(WebCore::RenderBoxModelObject::computedCSSMarginStart const): Deleted.
(WebCore::RenderBoxModelObject::computedCSSMarginEnd const): Deleted.

The margin getters resolve against ReferenceSize::ContainingBlockLogicalWidth, 
which is what the
computedCSSMargin helpers did via containingBlockLogicalWidthForContent().

* Source/WebCore/rendering/RenderElement.h:
* Source/WebCore/rendering/RenderElementInlines.h:
(WebCore::RenderElement::usedStyle const):
* Source/WebCore/rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::computeConstrainedLogicalWidth const):
* Source/WebCore/rendering/RenderScrollbarPart.cpp:
(WebCore::RenderScrollbarPart::computeScrollbarWidth):
(WebCore::RenderScrollbarPart::computeScrollbarHeight):
* Source/WebCore/rendering/RenderTable.cpp:
(WebCore::RenderTable::updateLogicalWidth):
* Source/WebCore/rendering/style/UsedStyle.cpp: Added.
(WebCore::UsedStyle::UsedStyle):

Construct a UsedStyle for a layout-tree box from the renderer it was built from.

(WebCore::UsedStyleProperties::resolveReferenceSize const):

Resolves a ReferenceSize to a LayoutUnit; ContainingBlockLogicalWidth visits 
the containing block.
Renderers that aren't box model objects (some SVG renderers) resolve to 0.

(WebCore::UsedStyle::floating const):
(WebCore::UsedStyle::clear const):

Map the computed value to physical left/right using the containing block's 
writing mode.

* Source/WebCore/rendering/style/UsedStyle.h: Added.
* Source/WebCore/rendering/style/UsedStyleReferenceSize.h: Added.

ReferenceSize names the renderer-derived percentage reference an 
evaluate-zoomed getter
resolves against, resolved lazily so the walk is not paid for fixed values. 
Callers that
already hold the reference pass a LayoutUnit instead.

* Source/WebCore/style/computed/StyleComputedStyle.cpp:
(WebCore::Style::ComputedStyle::usedClear): Deleted.
(WebCore::Style::ComputedStyle::usedFloat): Deleted.

Moved to UsedStyle.

* Source/WebCore/style/computed/StyleComputedStyle.h:
* Tools/Scripts/webkitpy/style/checkers/jsonchecker.py:
(JSONCSSPropertiesChecker.check_codegen_properties):

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



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

Reply via email to