[webkit-changes] [WebKit/WebKit] b39fee: [content-visibility] Add support for css content-v...

Rob Buis noreply at github.com
Sat Jul 15 08:29:29 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b39fee5ba22e0f62398d7e869e271415f3d6ec84
      https://github.com/WebKit/WebKit/commit/b39fee5ba22e0f62398d7e869e271415f3d6ec84
  Author: Rob Buis <rbuis at igalia.com>
  Date:   2023-07-15 (Sat, 15 Jul 2023)

  Changed paths:
    M LayoutTests/TestExpectations
    M LayoutTests/imported/w3c/resources/resource-files.json
    M LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-048-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-068-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-070-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-071-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-072-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-with-popover-top-layer-006-expected.txt
    A LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-with-popover-top-layer-and-auto-descendant-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-with-popover-top-layer-and-auto-descendant-ref.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-with-popover-top-layer-and-auto-descendant.html
    M LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-with-top-layer-006-expected.txt
    A LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-with-top-layer-and-auto-descendant-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-with-top-layer-and-auto-descendant-ref.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-with-top-layer-and-auto-descendant.html
    M LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/w3c-import.log
    M LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/auto-003-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/auto-012-expected.txt
    M LayoutTests/platform/ios/TestExpectations
    M LayoutTests/platform/mac-wk1/TestExpectations
    M LayoutTests/platform/mac-wk2/TestExpectations
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    A Source/WebCore/dom/ContentVisibilityDocumentState.cpp
    A Source/WebCore/dom/ContentVisibilityDocumentState.h
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/dom/Document.h
    M Source/WebCore/dom/Element.cpp
    M Source/WebCore/dom/Element.h
    M Source/WebCore/dom/ElementRareData.cpp
    M Source/WebCore/dom/ElementRareData.h
    M Source/WebCore/page/LocalFrameView.cpp
    M Source/WebCore/page/Page.cpp
    M Source/WebCore/page/Page.h
    M Source/WebCore/rendering/RenderElement.cpp
    M Source/WebCore/rendering/RenderElement.h
    M Source/WebCore/rendering/RenderElementInlines.h
    M Source/WebCore/rendering/RenderObject.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/style/StyleAdjuster.cpp
    M Source/WebCore/style/StyleSharingResolver.cpp

  Log Message:
  -----------
  [content-visibility] Add support for css content-visibility: auto
https://bugs.webkit.org/show_bug.cgi?id=236711

Reviewed by Tim Nguyen.

This patch implements support for content-visibility: auto [1].

To keep track of whether an element is relevant to the user [2] and
decide to whether it should skip contents [3] the following is done:
- state is kept using ContentRelevancyStatus enum class whether the
  content-visibility: auto subtree contains any visible, focused or
  selected elements, since that means it is relevant to the user.
- an IntersectionObserver is installed as soon as content-visibility: auto
  is set on an Element. This keeps track whether the Element is in the
  viewport or not and thus if it is relevant to the user.
- updating of c-v: auto elements relevancy and its effect on its subtree
  is done as part of "Update the Rendering", see [4].

The methods focus() [4.3.6] and scrollIntoView() [4.3.5] treat any previously
skipped content as becoming relevant to the user before doing any scrolling.

Handling selected elements will be done in a future patch.

[1] https://drafts.csswg.org/css-contain/#valdef-content-visibility-auto
[2] https://drafts.csswg.org/css-contain/#relevant-to-the-user
[3] https://drafts.csswg.org/css-contain/#skips-its-contents
[4] https://drafts.csswg.org/css-contain/#cv-notes (point 3)

* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/resources/resource-files.json:
* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-048-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-068-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-070-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-071-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-072-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-with-popover-top-layer-006-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-with-popover-top-layer-and-auto-descendant-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-with-popover-top-layer-and-auto-descendant-ref.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-with-popover-top-layer-and-auto-descendant.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-with-top-layer-006-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-with-top-layer-and-auto-descendant-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-with-top-layer-and-auto-descendant-ref.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-with-top-layer-and-auto-descendant.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/w3c-import.log:
* LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/auto-003-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/auto-012-expected.txt:
* LayoutTests/platform/ios/TestExpectations:
* LayoutTests/platform/mac-wk1/TestExpectations:
* LayoutTests/platform/mac-wk2/TestExpectations:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/dom/ContentVisibilityDocumentState.cpp: Added.
(WebCore::ContentVisibilityDocumentState::observe):
(WebCore::ContentVisibilityDocumentState::unobserve):
(WebCore::ContentVisibilityDocumentState::intersectionObserver):
(WebCore::ContentVisibilityDocumentState::updateRelevancyOfContentVisibilityElements): integration into "Update the Rendering", see [4]
(WebCore::ContentVisibilityDocumentState::updateContentRelevancyStatusForScrollIfNeeded): helper around lack of scroll anchoring.
(WebCore::ContentVisibilityDocumentState::updateOnScreenObservationTarget):
* Source/WebCore/dom/ContentVisibilityDocumentState.h: Added.
(WebCore::ContentVisibilityDocumentState::hasObservationTargets const):
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::setFocusedElement): handle all focus changes.
(WebCore::Document::contentVisibilityDocumentState): keep track of observers for content-visibility: auto elements.
(WebCore::Document::isObservingContentVisibilityTargets const):
(WebCore::Document::updateRelevancyOfContentVisibilityElements): integration into "Update the Rendering", see [4]
(WebCore::Document::scheduleContentRelevancyUpdate): integration into "Update the Rendering", see [4]
* Source/WebCore/dom/Document.h:
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::focus): make sure scrolled to element is in visible subtree.
(WebCore::Element::hasFocusableStyle const): only test focus for c-v: hidden subtrees.
(WebCore::Element::scrollIntoView): make sure scrolled to element is in visible subtree.
(WebCore::Element::scrollIntoViewIfNeeded): make sure scrolled to element is in visible subtree.
(WebCore::Element::focus): make sure scrolled to element is in visible subtree.
(WebCore::Element::addToTopLayer): make sure element is in visible subtree.
(WebCore::Element::removeFromTopLayer): make sure element is not in visible subtree anymore.
(WebCore::Element::isRelevantToUser const): see [2].
(WebCore::Element::contentRelevancyStatus const):
(WebCore::Element::setContentRelevancyStatus):
(WebCore::Element::contentVisibilityViewportChange): handle changed visibility in viewport status.
* Source/WebCore/dom/Element.h:
* Source/WebCore/dom/ElementRareData.cpp:
* Source/WebCore/dom/ElementRareData.h:
(WebCore::ElementRareData::contentRelevancyStatus):
(WebCore::ElementRareData::setContentRelevancyStatus):
* Source/WebCore/dom/NodeRareData.h: keep track of whether content is relevant to the user.
* Source/WebCore/page/LocalFrameView.cpp:
(WebCore::FrameView::maintainScrollPositionAtAnchor): handle anchor scrolls.
* Source/WebCore/page/Page.cpp:
(WebCore::Page::updateRendering): integration into "Update the Rendering", see https://drafts.csswg.org/css-contain/#cv-notes
(WebCore::operator<<):
* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::styleWillChange): add/remove observation for content-visibility: auto element.
(WebCore::RenderElement::willBeDestroyed): remove observation for content-visibility: auto element.
(WebCore::RenderElement::isSkippedContentRoot const):
* Source/WebCore/rendering/RenderElement.h:
(WebCore::RenderObject::isSkippedContentRoot const):
* Source/WebCore/rendering/RenderElementInlines.h:
(WebCore::RenderElement::shouldApplyInlineSizeContainment const): take into account current value of effectiveSkippedContent.
(WebCore::RenderElement::shouldApplySizeContainment const): take into account current value of effectiveSkippedContent.
(WebCore::RenderElement::shouldApplySizeOrInlineSizeContainment const): take into account current value of effectiveSkippedContent.
(WebCore::RenderObject::isSkippedContentRoot const):
* Source/WebCore/rendering/RenderElementInlines.h:
(WebCore::RenderElement::shouldApplyInlineSizeContainment const):
(WebCore::RenderElement::shouldApplySizeOrInlineSizeContainment const):
* Source/WebCore/rendering/RenderObject.cpp:
(WebCore::RenderObject::shouldSkipContent const): Deleted.
* Source/WebCore/rendering/style/RenderStyle.cpp:
(WebCore::rareInheritedDataChangeRequiresLayout): a change in effectiveSkippedContent requires a layout.
* Source/WebCore/rendering/style/RenderStyle.h:
* Source/WebCore/rendering/style/RenderStyleInlines.h:
(WebCore::isSkippedContentRoot):
* Source/WebCore/style/StyleAdjuster.cpp:
(WebCore::Style::Adjuster::adjust const): take content-visibility: auto into account.
* Source/WebCore/style/StyleSharingResolver.cpp:
(WebCore::Style::SharingResolver::canShareStyleWithElement const): do not share styles with different isRelevantToUser values.

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




More information about the webkit-changes mailing list