Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 4e524359e8b3ece60ed6f81250c0ce2d71eddcb6
      
https://github.com/WebKit/WebKit/commit/4e524359e8b3ece60ed6f81250c0ce2d71eddcb6
  Author: Nikolas Zimmermann <[email protected]>
  Date:   2023-11-20 (Mon, 20 Nov 2023)

  Changed paths:
    A 
LayoutTests/platform/mac-sonoma-wk2-lbse-text/svg/custom/svg-fonts-in-html-expected.png
    M 
LayoutTests/platform/mac-sonoma-wk2-lbse-text/svg/custom/svg-fonts-in-html-expected.txt
    M 
LayoutTests/platform/mac-sonoma-wk2-lbse-text/svg/repaint/repaint-non-scaling-stroke-text-decoration-expected.txt
    M 
LayoutTests/platform/mac-sonoma-wk2-lbse-text/svg/repaint/repaint-non-scaling-stroke-text-expected.txt
    M LayoutTests/svg/repaint/clip-path-object-bounding-box-expected.txt
    M LayoutTests/svg/repaint/clip-path-object-bounding-box-shrink-expected.txt
    M LayoutTests/svg/repaint/clip-path-object-bounding-box-shrink.html
    M 
LayoutTests/svg/repaint/clip-path-object-bounding-box-transformed-expected.txt
    M LayoutTests/svg/repaint/clip-path-user-space-on-use-expected.txt
    M LayoutTests/svg/repaint/clip-path-user-space-on-use-shrink-expected.txt
    M LayoutTests/svg/repaint/clip-path-user-space-on-use-shrink.html
    M 
LayoutTests/svg/repaint/clip-path-user-space-on-use-transformed-expected.txt
    M 
LayoutTests/svg/resource-invalidation/clip-path-resource-invalidation-expected.html
    M LayoutTests/svg/resource-invalidation/clip-path-resource-invalidation.html
    M Source/WebCore/dom/TreeScope.cpp
    M Source/WebCore/dom/TreeScope.h
    M Source/WebCore/rendering/ReferencedSVGResources.cpp
    M Source/WebCore/rendering/ReferencedSVGResources.h
    M Source/WebCore/rendering/RenderElement.cpp
    M Source/WebCore/rendering/RenderElement.h
    M Source/WebCore/rendering/RenderLayer.cpp
    M Source/WebCore/rendering/RenderLayer.h
    M Source/WebCore/rendering/RenderLayerInlines.h
    M Source/WebCore/rendering/RenderLayerModelObject.cpp
    M Source/WebCore/rendering/RenderLayerModelObject.h
    M Source/WebCore/rendering/RenderObject.h
    M Source/WebCore/rendering/svg/RenderSVGContainer.cpp
    M Source/WebCore/rendering/svg/RenderSVGImage.cpp
    M Source/WebCore/rendering/svg/RenderSVGPath.cpp
    M Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp
    M Source/WebCore/rendering/svg/RenderSVGResourceClipper.h
    M Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp
    M Source/WebCore/rendering/svg/RenderSVGResourceContainer.h
    M Source/WebCore/rendering/svg/RenderSVGRoot.cpp
    M Source/WebCore/rendering/svg/SVGBoundingBoxComputation.cpp
    M Source/WebCore/rendering/svg/SVGContainerLayout.cpp
    M Source/WebCore/rendering/svg/SVGContainerLayout.h
    M Source/WebCore/rendering/svg/SVGRenderSupport.cpp
    M Source/WebCore/rendering/svg/SVGRenderSupport.h
    M Source/WebCore/rendering/svg/SVGRenderingContext.cpp
    M Source/WebCore/rendering/svg/SVGResourcesCache.cpp
    M Source/WebCore/rendering/svg/SVGResourcesCycleSolver.cpp
    M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResource.cpp
    M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceMarker.h
    M Source/WebCore/rendering/updating/RenderTreeUpdater.cpp
    M Source/WebCore/svg/SVGFEImageElement.cpp
    M Source/WebCore/svg/SVGSVGElement.cpp

  Log Message:
  -----------
  [LBSE] Rework SVG resource invalidation
https://bugs.webkit.org/show_bug.cgi?id=264230

Reviewed by Rob Buis.

Overhaul of repainting / resource invalidating logic for LBSE.

- Stop communicating resource invalidation via layout(). The legacy
  SVG engine used to relayout all resource clients upon resource
  changes. This is very inefficient, and leads to lots of unnecessary
  layouts.

  `RenderElement::styleDidChange` is the main entry point for resource
  invalidation -- re-using the existing concept from CSS. After the
  difference between the old and new RenderStyle is computed, we know
  if a layout needs to be performed (~ 'StyleDifference::Layout') or
  if a repaint is sufficient (~ 'StyleDifference::Repaint').

  e.g. Changing the 'x' attribute of a SVGRectElement results in a
       'StyleDifference::Layout' asynchronously requesting a relayout
       of the affected rectangle. Changing only the e.g. 'fill' color
       will lead to a 'StyleDifference::Repaint' indicating that repaint
       is sufficient, and a costly layout can be avoided.

  Inject a call to 'repaintClientsOfReferencedSVGResources()' in
  'RenderElement::styleDidChange()' if the style change leads to a
  repaint. Whenever a renderer needs a repaint, we have to check if
  it is a RenderSVGResourceContainer (such as RenderSVGResourceClipper)
  or enclosed by a RenderSVGResourceContainer. If true, the clients
  that reference the RenderSVGResourceContainer are the renderers that
  need a repaint, not the original renderer, whose style got changed.

  'RenderElement::repaintClientsOfReferencedSVGResources()' queries
  'SVGElement::referencingCSSClients()' to lookup all SVG DOM elements
  that reference the element, associated with the renderer. These clients
  are asked to repaint themselves, if they've got an associated renderer.

- Get rid of TreeScope::addPendingSVGResource & friends for LBSE.
  The code remains only for the legacy SVG engine. LBSE will
  exclusively rely on 'ReferencedSVGResources' for tracking SVG
  resources <-> ID mapping based on the DOM tree, not render tree.

- Teach ReferencedSVGResources about marker/mask references - clipPath
  were already supported.

- Move RenderLayer::clipperFromStyle() -> 
RenderLayerModelObject::svgClipperResourceFromStyle().
  This method shall be used to get access to the RenderSVGResourceClipper in 
LBSE, properly taking
  care of 'pending resource handling' (if the requested resource, is not found 
in the DOM tree,
  we remember that, and notify the renderer that wanted to use the 
not-yet-existing-resource, once
  it appears).

- Make sure there are no more 
"LegacyRenderSVGResource::markForLayoutAndParentResourceInvalidation"
  sledgehammer calls in LBSE -- only careful case-by-case decisions on what we 
need to do.

- Stop inheriting RenderSVGResourceContainer from LegacySVGResource. Stop using 
SVGResources
  and SVGResourcesCache in LBSE -- place RELEASE_ASSERTS in prominent places to 
be sure this is
  all no longer used for LBSE.

This work will be completed, once all resources are converted to the new 
mechanisms in LBSE.

Covered by existing tests -- progressions with LBSE.

* 
LayoutTests/platform/mac-sonoma-wk2-lbse-text/svg/custom/svg-fonts-in-html-expected.png:
 Added.
* 
LayoutTests/platform/mac-sonoma-wk2-lbse-text/svg/custom/svg-fonts-in-html-expected.txt:
* 
LayoutTests/platform/mac-sonoma-wk2-lbse-text/svg/repaint/repaint-non-scaling-stroke-text-decoration-expected.txt:
* 
LayoutTests/platform/mac-sonoma-wk2-lbse-text/svg/repaint/repaint-non-scaling-stroke-text-expected.txt:
* LayoutTests/svg/repaint/clip-path-object-bounding-box-expected.txt:
* LayoutTests/svg/repaint/clip-path-object-bounding-box-shrink-expected.txt:
* LayoutTests/svg/repaint/clip-path-object-bounding-box-shrink.html:
* 
LayoutTests/svg/repaint/clip-path-object-bounding-box-transformed-expected.txt:
* LayoutTests/svg/repaint/clip-path-user-space-on-use-expected.txt:
* LayoutTests/svg/repaint/clip-path-user-space-on-use-shrink-expected.txt:
* LayoutTests/svg/repaint/clip-path-user-space-on-use-shrink.html:
* LayoutTests/svg/repaint/clip-path-user-space-on-use-transformed-expected.txt:
* 
LayoutTests/svg/resource-invalidation/clip-path-resource-invalidation-expected.html:
 Fix incorrect expectation, due to duplicated 'c6' element.
* LayoutTests/svg/resource-invalidation/clip-path-resource-invalidation.html: 
Make testcase work in browser, not only in the test runner.
* Source/WebCore/dom/TreeScope.cpp:
(WebCore::TreeScope::removeSVGResource):
(WebCore::TreeScope::lookupSVGResourceById const): Deleted.
* Source/WebCore/dom/TreeScope.h:
* Source/WebCore/rendering/ReferencedSVGResources.cpp:
(WebCore::ReferencedSVGResources::referencedMarkerElement):
(WebCore::ReferencedSVGResources::referencedMaskElement):
* Source/WebCore/rendering/ReferencedSVGResources.h:
* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::styleDidChange):
(WebCore::RenderElement::repaintRendererOrClientsOfReferencedSVGResources 
const):
(WebCore::RenderElement::repaintClientsOfReferencedSVGResources const):
* Source/WebCore/rendering/RenderElement.h:
* Source/WebCore/rendering/RenderLayer.cpp:
(WebCore::RenderLayer::paintSVGResourceLayer):
(WebCore::RenderLayer::setupClipPath):
(WebCore::RenderLayer::calculateClipRects const):
* Source/WebCore/rendering/RenderLayer.h:
* Source/WebCore/rendering/RenderLayerInlines.h:
(WebCore::RenderLayer::hasNonOpacityTransparency const):
* Source/WebCore/rendering/RenderLayerModelObject.cpp:
(WebCore::RenderLayerModelObject::svgClipperResourceFromStyle const):
(WebCore::RenderLayerModelObject::repaintOrRelayoutAfterSVGTransformChange):
* Source/WebCore/rendering/RenderLayerModelObject.h:
* Source/WebCore/rendering/RenderObject.h:
(WebCore::RenderObject::isLegacyRenderSVGResourceMarker const):
* Source/WebCore/rendering/svg/RenderSVGContainer.cpp:
(WebCore::RenderSVGContainer::layoutChildren):
* Source/WebCore/rendering/svg/RenderSVGImage.cpp:
(WebCore::RenderSVGImage::imageChanged):
* Source/WebCore/rendering/svg/RenderSVGPath.cpp:
(WebCore::RenderSVGPath::shouldGenerateMarkerPositions const):
(WebCore::RenderSVGPath::drawMarkers):
(WebCore::RenderSVGPath::computeMarkerBoundingBox const):
(WebCore::RenderSVGPath::processMarkerPositions):
* Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp:
(WebCore::RenderSVGResourceClipper::applyMaskClipping):
(WebCore::RenderSVGResourceClipper::resourceBoundingBox):
* Source/WebCore/rendering/svg/RenderSVGResourceClipper.h:
* Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp:
(WebCore::RenderSVGResourceContainer::willBeDestroyed):
(WebCore::RenderSVGResourceContainer::idChanged):
(WebCore::RenderSVGResourceContainer::registerResource):
(WebCore::RenderSVGResourceContainer::repaintAllClients const):
* Source/WebCore/rendering/svg/RenderSVGResourceContainer.h:
* Source/WebCore/rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::layoutChildren):
(WebCore::RenderSVGRoot::paintObject):
* Source/WebCore/rendering/svg/SVGBoundingBoxComputation.cpp:
(WebCore::SVGBoundingBoxComputation::adjustBoxForClippingAndEffects const):
* Source/WebCore/rendering/svg/SVGContainerLayout.cpp:
(WebCore::SVGContainerLayout::layoutChildren):
(WebCore::SVGContainerLayout::layoutDifferentRootIfNeeded): Deleted.
(WebCore::SVGContainerLayout::invalidateResourcesOfChildren): Deleted.
* Source/WebCore/rendering/svg/SVGContainerLayout.h:
* Source/WebCore/rendering/svg/SVGRenderSupport.cpp:
(WebCore::SVGRenderSupport::pointInClippingArea):
(WebCore::SVGRenderSupport::paintSVGClippingMask):
* Source/WebCore/rendering/svg/SVGRenderSupport.h:
* Source/WebCore/rendering/svg/SVGRenderingContext.cpp:
(WebCore::SVGRenderingContext::prepareToRenderSVGContent):
* Source/WebCore/rendering/svg/SVGResourcesCache.cpp:
(WebCore::SVGResourcesCache::addResourcesFromRenderer):
(WebCore::SVGResourcesCache::removeResourcesFromRenderer):
(WebCore::resourcesCacheFromRenderer):
(WebCore::SVGResourcesCache::clientLayoutChanged):
(WebCore::SVGResourcesCache::clientStyleChanged):
(WebCore::SVGResourcesCache::clientWasAddedToTree):
(WebCore::SVGResourcesCache::clientWillBeRemovedFromTree):
(WebCore::SVGResourcesCache::clientDestroyed):
(WebCore::SVGResourcesCache::resourceDestroyed):
(WebCore::SVGResourcesCache::SetStyleForScope::setStyle):
* Source/WebCore/rendering/svg/SVGResourcesCycleSolver.cpp:
(WebCore::SVGResourcesCycleSolver::resolveCycles):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResource.cpp:
(WebCore::requestPaintingResource):
(WebCore::LegacyRenderSVGResource::markForLayoutAndParentResourceInvalidationIfNeeded):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceMarker.h:
(isType):
* Source/WebCore/rendering/updating/RenderTreeUpdater.cpp:
(WebCore::RenderTreeUpdater::updateSVGRenderer):
* Source/WebCore/svg/SVGFEImageElement.cpp:
(WebCore::SVGFEImageElement::notifyFinished):
* Source/WebCore/svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::scrollToFragment):
(WebCore::SVGSVGElement::resetScrollAnchor):

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


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to