Changeset 291154 in webkit
- Timestamp:
- Mar 11, 2022 3:51:29 AM (4 months ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/ineligible-containment-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/rendering/RenderBlockFlow.cpp (modified) (1 diff)
-
Source/WebCore/rendering/RenderObject.cpp (modified) (1 diff)
-
Source/WebCore/rendering/RenderObject.h (modified) (1 diff)
-
Source/WebCore/style/ContainerQueryEvaluator.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r291148 r291154 1 2022-03-11 Antti Koivisto <antti@apple.com> 2 3 [CSS Container Queries] Only apply inline-size containment when it is allowed 4 https://bugs.webkit.org/show_bug.cgi?id=237761 5 6 Reviewed by Antoine Quint. 7 8 * web-platform-tests/css/css-contain/container-queries/ineligible-containment-expected.txt: 9 1 10 2022-03-10 Antoine Quint <graouts@webkit.org> 2 11 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/ineligible-containment-expected.txt
r288786 r291154 4 4 5 5 6 FAIL Container ineligible for containment assert_equals: expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" 7 FAIL Changing containment eligibility invalidates style assert_equals: expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" 6 PASS Container ineligible for containment 7 PASS Changing containment eligibility invalidates style 8 8 -
trunk/Source/WebCore/ChangeLog
r291153 r291154 1 2022-03-11 Antti Koivisto <antti@apple.com> 2 3 [CSS Container Queries] Only apply inline-size containment when it is allowed 4 https://bugs.webkit.org/show_bug.cgi?id=237761 5 6 Reviewed by Antoine Quint. 7 8 "Giving an element inline-size containment has no effect if any of the following are true: 9 10 if the element does not generate a principal box (as is the case with display: contents or display: none) 11 if its inner display type is table 12 if its principal box is an internal table box 13 if its principal box is an internal ruby box or a non-atomic inline-level box" 14 15 https://drafts.csswg.org/css-contain-3/#containment-inline-size 16 17 * rendering/RenderBlockFlow.cpp: 18 (WebCore::RenderBlockFlow::computeInlinePreferredLogicalWidths const): 19 20 Check for valid inline-size containment. 21 22 * rendering/RenderObject.cpp: 23 (WebCore::shouldApplyInlineSizeContainment): 24 * rendering/RenderObject.h: 25 * style/ContainerQueryEvaluator.cpp: 26 (WebCore::Style::ContainerQueryEvaluator::selectContainer const): 27 28 Cleanups. 29 30 (WebCore::Style::ContainerQueryEvaluator::evaluateSizeFeature const): 31 32 Check for valid size containment for the type, evaluate to unknown if it doesn't exist. 33 Also check layout containment. 34 1 35 2022-03-11 Zan Dobersek <zdobersek@igalia.com> 2 36 -
trunk/Source/WebCore/rendering/RenderBlockFlow.cpp
r291134 r291154 4096 4096 // "The inline-axis intrinsic sizes of the principal box are determined as if the element had no content." 4097 4097 // https://drafts.csswg.org/css-contain-3/#containment-inline-size 4098 if (s tyle().effectiveContainment().contains(Containment::InlineSize))4098 if (shouldApplyInlineSizeContainment(*this)) 4099 4099 return; 4100 4100 -
trunk/Source/WebCore/rendering/RenderObject.cpp
r290867 r291154 2604 2604 } 2605 2605 2606 bool WebCore::shouldApplyInlineSizeContainment(const WebCore::RenderObject& renderer) 2607 { 2608 return renderer.style().effectiveContainment().contains(Containment::InlineSize) && (!renderer.isInline() || renderer.isAtomicInlineLevelBox()) && !renderer.isRubyText() && (!renderer.isTablePart() || renderer.isTableCaption()) && !renderer.isTable(); 2609 } 2610 2606 2611 bool WebCore::shouldApplyStyleContainment(const WebCore::RenderObject& renderer) 2607 2612 { -
trunk/Source/WebCore/rendering/RenderObject.h
r290881 r291154 1211 1211 bool shouldApplyLayoutContainment(const RenderObject&); 1212 1212 bool shouldApplySizeContainment(const RenderObject&); 1213 bool shouldApplyInlineSizeContainment(const RenderObject&); 1213 1214 bool shouldApplyStyleContainment(const RenderObject&); 1214 1215 bool shouldApplyPaintContainment(const RenderObject&); -
trunk/Source/WebCore/style/ContainerQueryEvaluator.cpp
r291098 r291154 79 79 }; 80 80 81 auto computeUnsupportedAxes = [&](ContainerType containerType, const RenderElement* principalBox) -> OptionSet<CQ::Axis>{81 auto isValidContainerForRequiredAxes = [&](ContainerType containerType, const RenderElement* principalBox) { 82 82 switch (containerType) { 83 83 case ContainerType::Size: 84 return { };84 return true; 85 85 case ContainerType::InlineSize: 86 86 // Without a principal box the container matches but the query against it will evaluate to Unknown. 87 87 if (!principalBox) 88 return { };89 if ( !principalBox->isHorizontalWritingMode())90 return { CQ::Axis::Width, CQ::Axis::Block };91 return { CQ::Axis::Height, CQ::Axis::Block };88 return true; 89 if (filteredContainerQuery.axisFilter.contains(CQ::Axis::Block)) 90 return false; 91 return !filteredContainerQuery.axisFilter.contains(principalBox->isHorizontalWritingMode() ? CQ::Axis::Height : CQ::Axis::Width); 92 92 case ContainerType::None: 93 return { CQ::Axis::Width, CQ::Axis::Height, CQ::Axis::Inline, CQ::Axis::Block };93 return false; 94 94 } 95 95 RELEASE_ASSERT_NOT_REACHED(); … … 100 100 if (!style) 101 101 return false; 102 auto unsupportedAxes = computeUnsupportedAxes(style->containerType(), element.renderer()); 103 if (filteredContainerQuery.axisFilter.containsAny(unsupportedAxes)) 102 if (!isValidContainerForRequiredAxes(style->containerType(), element.renderer())) 104 103 return false; 105 104 if (filteredContainerQuery.nameFilter.isEmpty()) 106 105 return true; 107 return element.existingComputedStyle()->containerNames().contains(filteredContainerQuery.nameFilter);106 return style->containerNames().contains(filteredContainerQuery.nameFilter); 108 107 }; 109 108 … … 202 201 auto ContainerQueryEvaluator::evaluateSizeFeature(const CQ::SizeFeature& sizeFeature, const SelectedContainer& container) const -> EvaluationResult 203 202 { 204 // "If the query container does not have a principal box ... then the result of evaluating the size feature is unknown." 203 // "If the query container does not have a principal box, or the principal box is not a layout containment box, 204 // or the query container does not support container size queries on the relevant axes, then the result of 205 // evaluating the size feature is unknown." 205 206 // https://drafts.csswg.org/css-contain-3/#size-container 206 207 if (!container.renderer) … … 208 209 209 210 auto& renderer = *container.renderer; 211 212 auto hasEligibleContainment = [&] { 213 if (!shouldApplyLayoutContainment(renderer)) 214 return false; 215 switch (renderer.style().containerType()) { 216 case ContainerType::InlineSize: 217 return shouldApplyInlineSizeContainment(renderer); 218 case ContainerType::Size: 219 return shouldApplySizeContainment(renderer); 220 case ContainerType::None: 221 return true; 222 } 223 }; 224 225 if (!hasEligibleContainment()) 226 return EvaluationResult::Unknown; 210 227 211 228 auto compare = [](CQ::ComparisonOperator op, auto left, auto right) {
Note: See TracChangeset
for help on using the changeset viewer.