[webkit-changes] [WebKit/WebKit] faa093: [content-visibility] Lazily layout children

Rob Buis noreply at github.com
Fri Sep 22 06:47:34 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: faa0935aebd5fb9dfde94bf8c91262fd70479bc4
      https://github.com/WebKit/WebKit/commit/faa0935aebd5fb9dfde94bf8c91262fd70479bc4
  Author: Rob Buis <rbuis at igalia.com>
  Date:   2023-09-22 (Fri, 22 Sep 2023)

  Changed paths:
    M LayoutTests/TestExpectations
    M Source/WebCore/css/ComputedStyleExtractor.cpp
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/dom/Document.h
    M Source/WebCore/dom/Element.cpp
    M Source/WebCore/html/HTMLImageElement.cpp
    M Source/WebCore/html/ImageInputType.cpp
    M Source/WebCore/page/LocalFrameViewLayoutContext.h
    M Source/WebCore/rendering/RenderBlock.cpp
    M Source/WebCore/rendering/RenderBlockFlow.cpp
    M Source/WebCore/rendering/RenderElement.cpp
    M Source/WebCore/rendering/RenderElement.h
    M Source/WebCore/rendering/RenderGrid.cpp
    M Source/WebCore/rendering/RenderLayoutState.cpp
    M Source/WebCore/rendering/RenderLayoutState.h
    M Source/WebCore/rendering/RenderObject.cpp
    M Source/WebCore/rendering/RenderObject.h
    M Source/WebCore/svg/SVGGeometryElement.cpp
    M Source/WebCore/svg/SVGLocatable.cpp
    M Source/WebCore/svg/SVGPathElement.cpp
    M Source/WebCore/svg/SVGSVGElement.cpp
    M Source/WebCore/svg/SVGTextContentElement.cpp

  Log Message:
  -----------
  [content-visibility] Lazily layout children
https://bugs.webkit.org/show_bug.cgi?id=237369

Reviewed by Tim Nguyen.

This patch supports skipping layout of children in hidden content-visibility subtrees
for normal layout, since they do not count as content [1].

However DOM operations that require measuring do need an accurate layout, so
introduce the helper class ContentVisibilityForceLayoutScope to override ("forced layout")
the skipped layout mechanism for hidden content-visibility subtrees.

Roughly the skipping layout of children falls into two catagories:
- general block flows (note flexbox is part of this)
- grid containers

The existing perf tests under ContentVisibility/ improve a lot with this patch (up to 100x), but
the scrolling variants have only slight improvement since scrolling content into the viewport
means falling back to full layout.
Improving the perf tests of grid based content-visibility perf tests will be addressed in a future PR.

[1] https://w3c.github.io/csswg-drafts/css-contain/#skips-its-contents

* LayoutTests/TestExpectations:
* Source/WebCore/css/ComputedStyleExtractor.cpp: make sure layout is up-to-date for hidden content-visibility subtree.
(WebCore::ComputedStyleExtractor::propertyValue const):
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::updateLayout): forces layout on hidden content-visibility subtree if needed.
(WebCore::Document::updateLayoutIgnorePendingStylesheets):
(WebCore::Document::updateLayoutIfDimensionsOutOfDate):
* Source/WebCore/dom/Document.h:
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::offsetLeftForBindings):
(WebCore::Element::offsetTopForBindings):
(WebCore::Element::offsetLeftForBindings):
(WebCore::Element::offsetTopForBindings):
(WebCore::Element::scrollLeft):
(WebCore::Element::scrollTop):
(WebCore::Element::setScrollLeft):
(WebCore::Element::setScrollTop):
(WebCore::Element::getClientRects):
(WebCore::Element::boundingClientRect):
(WebCore::Element::innerText):
* Source/WebCore/html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::width):
(WebCore::HTMLImageElement::height):
(WebCore::HTMLImageElement::x const):
(WebCore::HTMLImageElement::y const):
* Source/WebCore/html/ImageInputType.cpp:
(WebCore::ImageInputType::height const):
(WebCore::ImageInputType::width const):
* Source/WebCore/page/LocalFrameViewLayoutContext.h: keep track of forced layout.
(WebCore::LocalFrameViewLayoutContext::needsSkippedContentLayout const):
* Source/WebCore/rendering/RenderBlock.cpp:
(WebCore::RenderBlock::layoutPositionedObject): skip layout in hidden content-visibility subtree.
* Source/WebCore/rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutInFlowChildren): skip layout in hidden content-visibility subtree.
* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::clearNeedsLayoutForDescendants): add helper to clear layout for subtree.
(WebCore::RenderElement::layoutIfNeeded): take isSkippedContentForLayout into account.
* Source/WebCore/rendering/RenderElement.h:
(WebCore::RenderElement::layoutIfNeeded): Deleted.
* Source/WebCore/rendering/RenderGrid.cpp:
(WebCore::RenderGrid::layoutPositionedObject): skip layout in hidden content-visibility subtree.
* Source/WebCore/rendering/RenderLayoutState.cpp: Add helper to force layout if there is a hidden content-visibility subtree.
(WebCore::ContentVisibilityForceLayoutScope::ContentVisibilityForceLayoutScope):
(WebCore::ContentVisibilityForceLayoutScope::~ContentVisibilityForceLayoutScope):
* Source/WebCore/rendering/RenderLayoutState.h:
* Source/WebCore/rendering/RenderObject.cpp:
(WebCore::RenderObject::isSkippedContentForLayout const): same as isSkippedContent but takes into account needsSkippedContentLayout.
* Source/WebCore/rendering/RenderObject.h:
* Source/WebCore/svg/SVGGeometryElement.cpp:
(WebCore::SVGGeometryElement::getTotalLength const):
(WebCore::SVGGeometryElement::getPointAtLength const):
(WebCore::SVGGeometryElement::isPointInFill):
(WebCore::SVGGeometryElement::isPointInStroke):
* Source/WebCore/svg/SVGLocatable.cpp:
(WebCore::SVGLocatable::getBBox):
(WebCore::SVGLocatable::computeCTM):
* Source/WebCore/svg/SVGPathElement.cpp:
(WebCore::SVGPathElement::getBBox):
* Source/WebCore/svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::getIntersectionList):
(WebCore::SVGSVGElement::getEnclosureList):
(WebCore::SVGSVGElement::checkIntersection):
(WebCore::SVGSVGElement::checkEnclosure):
* Source/WebCore/svg/SVGTextContentElement.cpp:
(WebCore::SVGTextContentElement::getNumberOfChars):
(WebCore::SVGTextContentElement::getComputedTextLength):
(WebCore::SVGTextContentElement::getCharNumAtPosition):
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks):

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




More information about the webkit-changes mailing list