Changeset 291500 in webkit


Ignore:
Timestamp:
Mar 18, 2022 3:47:34 PM (4 months ago)
Author:
Antti Koivisto
Message:

[CSS Container Queries] Ensure container style changes are propagated to descendants
https://bugs.webkit.org/show_bug.cgi?id=238072

Reviewed by Alan Bujtas.

LayoutTests/imported/w3c:

  • web-platform-tests/css/css-contain/container-queries/container-name-invalidation-expected.txt:
  • web-platform-tests/css/css-contain/container-queries/container-type-invalidation-expected.txt:
  • web-platform-tests/css/css-contain/container-queries/container-units-selection-expected.txt:

Source/WebCore:

  • style/StyleChange.cpp:

(WebCore::Style::determineChange):

Ensure we recompute the descendants when container properties change.

  • style/StyleTreeResolver.cpp:

(WebCore::Style::TreeResolver::resolveComposedTree):
(WebCore::Style::TreeResolver::updateQueryContainer):

We need to ensure layout is up-to-date also when a query container stops being one.
Remove the unused m_resolvedQueryContainers maps.

  • style/StyleTreeResolver.h:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r291474 r291500  
     12022-03-18  Antti Koivisto  <antti@apple.com>
     2
     3        [CSS Container Queries] Ensure container style changes are propagated to descendants
     4        https://bugs.webkit.org/show_bug.cgi?id=238072
     5
     6        Reviewed by Alan Bujtas.
     7
     8        * web-platform-tests/css/css-contain/container-queries/container-name-invalidation-expected.txt:
     9        * web-platform-tests/css/css-contain/container-queries/container-type-invalidation-expected.txt:
     10        * web-platform-tests/css/css-contain/container-queries/container-units-selection-expected.txt:
     11
    1122022-03-18  Antti Koivisto  <antti@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-name-invalidation-expected.txt

    r289617 r291500  
    22
    33PASS Changing a named container invalidates relevant descendants
    4 FAIL Changing container-name invalidates relevant descendants assert_equals: expected "rgb(0, 0, 0)" but got "rgb(0, 128, 0)"
     4PASS Changing container-name invalidates relevant descendants
    55
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-invalidation-expected.txt

    r289742 r291500  
    11Test
    22
    3 FAIL Changing the container type invalidates relevant descendants assert_equals: expected "rgb(0, 0, 0)" but got "rgb(0, 128, 0)"
     3PASS Changing the container type invalidates relevant descendants
    44
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-units-selection-expected.txt

    r291474 r291500  
    11Test
    22
    3 FAIL Container units select the proper container assert_equals: expected "30px" but got "10px"
     3PASS Container units select the proper container
    44FAIL Units respond to the writing-mode of the element assert_equals: expected "40px" but got "30px"
    55
  • trunk/Source/WebCore/ChangeLog

    r291499 r291500  
     12022-03-18  Antti Koivisto  <antti@apple.com>
     2
     3        [CSS Container Queries] Ensure container style changes are propagated to descendants
     4        https://bugs.webkit.org/show_bug.cgi?id=238072
     5
     6        Reviewed by Alan Bujtas.
     7
     8        * style/StyleChange.cpp:
     9        (WebCore::Style::determineChange):
     10
     11        Ensure we recompute the descendants when container properties change.
     12
     13        * style/StyleTreeResolver.cpp:
     14        (WebCore::Style::TreeResolver::resolveComposedTree):
     15        (WebCore::Style::TreeResolver::updateQueryContainer):
     16
     17        We need to ensure layout is up-to-date also when a query container stops being one.
     18        Remove the unused m_resolvedQueryContainers maps.
     19
     20        * style/StyleTreeResolver.h:
     21
    1222022-03-18  Per Arne Vollan  <pvollan@apple.com>
    223
  • trunk/Source/WebCore/style/StyleChange.cpp

    r276902 r291500  
    6464        return Change::Inherited;
    6565
     66    // Query container changes affect descendant style.
     67    if (s1.containerType() != s2.containerType() || s1.containerNames() != s2.containerNames())
     68        return Change::Inherited;
     69
    6670    if (s1 != s2)
    6771        return Change::NonInherited;
  • trunk/Source/WebCore/style/StyleTreeResolver.cpp

    r290867 r291500  
    707707        auto change = Change::None;
    708708        auto descendantsToResolve = DescendantsToResolve::None;
     709        auto previousContainerType = style ? style->containerType() : ContainerType::None;
    709710
    710711        bool shouldResolve = shouldResolveElement(element, parent.descendantsToResolve);
     
    738739
    739740        if (shouldIterateChildren) {
    740             if (updateQueryContainer(element, *style) == QueryContainerAction::Layout)
     741            if (updateQueryContainer(element, *style, previousContainerType) == QueryContainerAction::Layout)
    741742                shouldIterateChildren = false;
    742743        }
     
    763764}
    764765
    765 auto TreeResolver::updateQueryContainer(Element& element, const RenderStyle& style) -> QueryContainerAction
    766 {
    767     if (style.containerType() == ContainerType::None)
     766auto TreeResolver::updateQueryContainer(Element& element, const RenderStyle& style, ContainerType previousContainerType) -> QueryContainerAction
     767{
     768    if (style.containerType() != ContainerType::None)
     769        scope().selectorMatchingState.queryContainers.append(element);
     770
     771    if (m_unresolvedQueryContainers.remove(&element))
     772        return QueryContainerAction::Continue;
     773
     774    // Render tree needs to be updated before proceeding to children also if we have a former query container
     775    // because container query resolution for descendants relies on it being up-to-date.
     776    if (style.containerType() == ContainerType::None && previousContainerType == ContainerType::None)
    768777        return QueryContainerAction::None;
    769778
    770     scope().selectorMatchingState.queryContainers.append(element);
    771 
    772     if (m_unresolvedQueryContainers.remove(&element)) {
    773         m_resolvedQueryContainers.add(&element);
     779    if (m_update->isEmpty())
    774780        return QueryContainerAction::Continue;
    775     }
    776 
    777     if (m_update->isEmpty()) {
    778         m_resolvedQueryContainers.add(&element);
    779         return QueryContainerAction::Continue;
    780     }
    781 
     781
     782    // Bail out from TreeResolver to build a render tree and do a layout. Resolution continues after.
    782783    m_unresolvedQueryContainers.add(&element);
    783 
    784784    return QueryContainerAction::Layout;
    785785}
  • trunk/Source/WebCore/style/StyleTreeResolver.h

    r290867 r291500  
    6464
    6565    enum class QueryContainerAction : uint8_t { None, Continue, Layout };
    66     QueryContainerAction updateQueryContainer(Element&, const RenderStyle&);
     66    QueryContainerAction updateQueryContainer(Element&, const RenderStyle&, ContainerType previousContainerType);
    6767
    6868    enum class DescendantsToResolve : uint8_t { None, ChildrenWithExplicitInherit, Children, All };
     
    128128
    129129    HashSet<RefPtr<Element>> m_unresolvedQueryContainers;
    130     HashSet<RefPtr<Element>> m_resolvedQueryContainers;
    131130
    132131    std::unique_ptr<Update> m_update;
Note: See TracChangeset for help on using the changeset viewer.