-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
- Loading branch information
1 parent
e3fed8d
commit 4e52435
Showing
47 changed files
with
425 additions
and
246 deletions.
There are no files selected for viewing
Binary file added
BIN
+76.6 KB
...sts/platform/mac-sonoma-wk2-lbse-text/svg/custom/svg-fonts-in-html-expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...-sonoma-wk2-lbse-text/svg/repaint/repaint-non-scaling-stroke-text-decoration-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
Hello | ||
(repaint rects | ||
(rect 13 16 40 22) | ||
(rect 9 12 48 30) | ||
) | ||
|
1 change: 0 additions & 1 deletion
1
...latform/mac-sonoma-wk2-lbse-text/svg/repaint/repaint-non-scaling-stroke-text-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
Hello | ||
(repaint rects | ||
(rect 13 16 40 22) | ||
(rect 9 12 48 30) | ||
) | ||
|
2 changes: 1 addition & 1 deletion
2
LayoutTests/svg/repaint/clip-path-object-bounding-box-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
(repaint rects | ||
(rect 0 0 100 100) | ||
(rect 25 25 50 50) | ||
) | ||
|
3 changes: 2 additions & 1 deletion
3
LayoutTests/svg/repaint/clip-path-object-bounding-box-shrink-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
(repaint rects | ||
(rect 0 0 100 100) | ||
(rect 50 50 50 50) | ||
(rect 0 0 50 50) | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
LayoutTests/svg/repaint/clip-path-object-bounding-box-transformed-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
(repaint rects | ||
(rect 25 25 50 50) | ||
) | ||
|
2 changes: 1 addition & 1 deletion
2
LayoutTests/svg/repaint/clip-path-user-space-on-use-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
(repaint rects | ||
(rect 0 0 100 100) | ||
(rect 25 25 50 50) | ||
) | ||
|
3 changes: 2 additions & 1 deletion
3
LayoutTests/svg/repaint/clip-path-user-space-on-use-shrink-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
(repaint rects | ||
(rect 0 0 100 100) | ||
(rect 50 50 50 50) | ||
(rect 0 0 50 50) | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
LayoutTests/svg/repaint/clip-path-user-space-on-use-transformed-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
(repaint rects | ||
(rect 25 25 50 50) | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.