Skip to content

Refactor container-type into a Style value type#65594

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
kate-k-lee:eng/Refactor-container-type-into-a-Style-value-type
May 26, 2026
Merged

Refactor container-type into a Style value type#65594
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
kate-k-lee:eng/Refactor-container-type-into-a-Style-value-type

Conversation

@kate-k-lee
Copy link
Copy Markdown
Contributor

@kate-k-lee kate-k-lee commented May 25, 2026

d9dde2e

Refactor container-type into a Style value type
https://bugs.webkit.org/show_bug.cgi?id=315483

Reviewed by Sam Weinig and Tim Nguyen.

Migrate the computed value of the container-type property from the
ContainerType enum (a 2-bit bitfield in NonInheritedRareData) to a
Style::ContainerType value type with computed-style-storage-kind
"reference", matching the sibling properties stored in the same struct
(scrollbar-gutter -> Style::ScrollbarGutter, scroll-snap-type ->
Style::ScrollSnapType).

This is a preparatory, non-functional change: only normal, size and
inline-size are supported, exactly as before. Call sites that compared
against ContainerType::Normal now use the equivalent isNormal() /
hasSize() / hasInlineSize() accessors on Style::ContainerType.

No new tests, as there is no behavior change.

* Source/WebCore/Headers.cmake:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/css/CSSProperties.json:
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::updateLayoutIfDimensionsOutOfDate):
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::resolveComputedStyle):
* Source/WebCore/rendering/RenderBlock.cpp:
(WebCore::RenderBlock::establishesIndependentFormattingContextIgnoringDisplayType const):
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::willBeDestroyed):
(WebCore::RenderBox::styleWillChange):
* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::hasEligibleContainmentForSizeQuery const):
* Source/WebCore/rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::usedContain const):
* Source/WebCore/rendering/style/RenderStyleConstants.h:
* Source/WebCore/style/ContainerQueryEvaluator.cpp:
(WebCore::Style::ContainerQueryEvaluator::selectContainer):
* Source/WebCore/style/StyleBuilderCustom.h:
(WebCore::Style::forwardInheritedValue):
* Source/WebCore/style/StyleExtractor.cpp:
(WebCore::Style::hasValidStyleForProperty):
* Source/WebCore/style/StyleExtractorCustom.h:
(WebCore::Style::ExtractorCustom::extractContainerShorthand):
(WebCore::Style::ExtractorCustom::extractContainerShorthandSerialization):
* Source/WebCore/style/StyleScope.cpp:
(WebCore::Style::Scope::invalidateForContainerDependencies):
* Source/WebCore/style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::pushParent):
(WebCore::Style::TreeResolver::updateStateForQueryContainer):
* Source/WebCore/style/computed/StyleComputedStyleBase.h:
* Source/WebCore/style/computed/data/StyleNonInheritedRareData.cpp:
(WebCore::Style::NonInheritedRareData::NonInheritedRareData):
(WebCore::Style::NonInheritedRareData::operator== const):
(WebCore::Style::NonInheritedRareData::usedContain const):
(WebCore::Style::NonInheritedRareData::dumpDifferences const):
* Source/WebCore/style/computed/data/StyleNonInheritedRareData.h:
* Source/WebCore/style/values/contain/StyleContainerType.cpp: Added.
(WebCore::Style::CSSValueConversion<ContainerType>::operator):
* Source/WebCore/style/values/contain/StyleContainerType.h: Added.
(WebCore::Style::ContainerType::ContainerType):
(WebCore::Style::ContainerType::isNormal const):
(WebCore::Style::ContainerType::hasSize const):
(WebCore::Style::ContainerType::hasInlineSize const):
(WebCore::Style::ContainerType::hasSizeContainment const):
(WebCore::Style::ContainerType::switchOn const):
* Source/WebCore/style/values/primitives/StyleKeyword+Mappings.h:

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

6b5b32d

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 loading-orange 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt loading 🧪 api-mac-debug ✅ 🛠 gtk3-libwebrtc
✅ 🧪 api-ios ✅ 🧪 mac-wk1 ✅ 🛠 gtk
✅ 🛠 ios-safer-cpp ✅ 🧪 mac-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress 🛠 playstation
✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
loading 🛠 tv-sim ❌ 🧪 mac-site-isolation
✅ 🛠 watch
✅ 🛠 watch-sim

@kate-k-lee kate-k-lee requested review from cdumez and rniwa as code owners May 25, 2026 02:55
@kate-k-lee kate-k-lee self-assigned this May 25, 2026
@kate-k-lee kate-k-lee added the CSS Cascading Style Sheets implementation label May 25, 2026
@kate-k-lee kate-k-lee force-pushed the eng/Refactor-container-type-into-a-Style-value-type branch from 89b70e0 to 6b5b32d Compare May 25, 2026 03:12
@nt1m nt1m requested a review from weinig May 25, 2026 04:51
@kate-k-lee kate-k-lee requested a review from nt1m May 25, 2026 10:36
Copy link
Copy Markdown
Contributor

@weinig weinig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look great.

@kate-k-lee
Copy link
Copy Markdown
Contributor Author

@weinig
Thanks for approving! Since I'm not a committer yet, I can't queue it myself. would you mind adding it to the merge-queue for me? Appreciate it!

@nt1m nt1m added the merge-queue Applied to send a pull request to merge-queue label May 26, 2026
https://bugs.webkit.org/show_bug.cgi?id=315483

Reviewed by Sam Weinig and Tim Nguyen.

Migrate the computed value of the container-type property from the
ContainerType enum (a 2-bit bitfield in NonInheritedRareData) to a
Style::ContainerType value type with computed-style-storage-kind
"reference", matching the sibling properties stored in the same struct
(scrollbar-gutter -> Style::ScrollbarGutter, scroll-snap-type ->
Style::ScrollSnapType).

This is a preparatory, non-functional change: only normal, size and
inline-size are supported, exactly as before. Call sites that compared
against ContainerType::Normal now use the equivalent isNormal() /
hasSize() / hasInlineSize() accessors on Style::ContainerType.

No new tests, as there is no behavior change.

* Source/WebCore/Headers.cmake:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/css/CSSProperties.json:
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::updateLayoutIfDimensionsOutOfDate):
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::resolveComputedStyle):
* Source/WebCore/rendering/RenderBlock.cpp:
(WebCore::RenderBlock::establishesIndependentFormattingContextIgnoringDisplayType const):
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::willBeDestroyed):
(WebCore::RenderBox::styleWillChange):
* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::hasEligibleContainmentForSizeQuery const):
* Source/WebCore/rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::usedContain const):
* Source/WebCore/rendering/style/RenderStyleConstants.h:
* Source/WebCore/style/ContainerQueryEvaluator.cpp:
(WebCore::Style::ContainerQueryEvaluator::selectContainer):
* Source/WebCore/style/StyleBuilderCustom.h:
(WebCore::Style::forwardInheritedValue):
* Source/WebCore/style/StyleExtractor.cpp:
(WebCore::Style::hasValidStyleForProperty):
* Source/WebCore/style/StyleExtractorCustom.h:
(WebCore::Style::ExtractorCustom::extractContainerShorthand):
(WebCore::Style::ExtractorCustom::extractContainerShorthandSerialization):
* Source/WebCore/style/StyleScope.cpp:
(WebCore::Style::Scope::invalidateForContainerDependencies):
* Source/WebCore/style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::pushParent):
(WebCore::Style::TreeResolver::updateStateForQueryContainer):
* Source/WebCore/style/computed/StyleComputedStyleBase.h:
* Source/WebCore/style/computed/data/StyleNonInheritedRareData.cpp:
(WebCore::Style::NonInheritedRareData::NonInheritedRareData):
(WebCore::Style::NonInheritedRareData::operator== const):
(WebCore::Style::NonInheritedRareData::usedContain const):
(WebCore::Style::NonInheritedRareData::dumpDifferences const):
* Source/WebCore/style/computed/data/StyleNonInheritedRareData.h:
* Source/WebCore/style/values/contain/StyleContainerType.cpp: Added.
(WebCore::Style::CSSValueConversion<ContainerType>::operator):
* Source/WebCore/style/values/contain/StyleContainerType.h: Added.
(WebCore::Style::ContainerType::ContainerType):
(WebCore::Style::ContainerType::isNormal const):
(WebCore::Style::ContainerType::hasSize const):
(WebCore::Style::ContainerType::hasInlineSize const):
(WebCore::Style::ContainerType::hasSizeContainment const):
(WebCore::Style::ContainerType::switchOn const):
* Source/WebCore/style/values/primitives/StyleKeyword+Mappings.h:

Canonical link: https://commits.webkit.org/313869@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Refactor-container-type-into-a-Style-value-type branch from 6b5b32d to d9dde2e Compare May 26, 2026 06:20
@webkit-commit-queue
Copy link
Copy Markdown
Collaborator

Committed 313869@main (d9dde2e): https://commits.webkit.org/313869@main

Reviewed commits have been landed. Closing PR #65594 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit d9dde2e into WebKit:main May 26, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CSS Cascading Style Sheets implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants