Skip to content
Permalink
Browse files
[LBSE] Fix SVGImage container size propagation
https://bugs.webkit.org/show_bug.cgi?id=246034

Reviewed by Rob Buis.

Propagate container size in SVGImage also for RenderSVGRoot, not only LegacyRenderSVGRoot.
This requires to enable SVGImage to actually use LBSE for its documents, if the host document
has LBSE turned on.

This requires plumbing the 'layerBasedSVGEngineEnabled' flag from Settings (reachable via Document)
down to CachedImage / ImageObserver so that we can set the flag, if necessary, before constructing
the document from the network data. Otherwise SVGImage in LBSE will continue to use the legacy
SVG engine.

Update TestExpectations now that SVGImage uses LBSE as well.

* LayoutTests/platform/mac-monterey-wk2-lbse-text/TestExpectations:
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/as-background-image/svg-as-background-6-expected.png: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/as-image/svg-non-integer-scaled-image-expected.png: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/zoom/page/zoom-background-images-expected.png: Added.
* Source/WebCore/loader/cache/CachedImage.cpp:
(WebCore::CachedImage::load):
* Source/WebCore/loader/cache/CachedImage.h:
* Source/WebCore/platform/graphics/ImageObserver.h:
(WebCore::ImageObserver::layerBasedSVGEngineEnabled const):
* Source/WebCore/svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::setContainerSize):
(WebCore::SVGImage::containerSize const):
(WebCore::SVGImage::dataChanged):

Canonical link: https://commits.webkit.org/255625@main
  • Loading branch information
nikolaszimmermann committed Oct 17, 2022
1 parent 4ec10f6 commit 3c9c0209a07833427073f05c89566ef30cf1b243
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 96 deletions.
@@ -181,6 +181,16 @@ svg/paint-order/paint-order-normal.svg [ ImageOnlyFailure ]
svg/paint-order/paint-order-stroke-marker.svg [ ImageOnlyFailure ]
svg/paint-order/paint-order-stroke.svg [ ImageOnlyFailure ]

# SVGImage support incomplete
svg/as-image/image-respects-pageScaleFactor-change.html [ ImageOnlyFailure ]
svg/as-image/same-image-two-instances.html [ ImageOnlyFailure ]
svg/as-image/svg-as-image-with-relative-size.html [ ImageOnlyFailure ]
svg/custom/use-image-in-g.svg [ ImageOnlyFailure ]

# SVG document w/o viewBox + <img> sizing differs to FF/Chrome
svg/as-background-image/background-image-preserveaspectRatio-support.html [ ImageOnlyFailure ]
svg/as-image/img-preserveAspectRatio-support-1.html [ ImageOnlyFailure ]

# getBBox() / getBoundingClientRect() / getCTM() / getScreenCTM() / getIntersectionList / etc. return incorrect results
svg/animations/animate-mpath-insert.html [ Failure ]
svg/animations/fill-remove-support.html [ Failure ]
@@ -235,88 +245,96 @@ svg/zoom/text/zoom-hixie-mixed-008.xml [ ImageOnlyFail
svg/zoom/text/zoom-hixie-mixed-009.xml [ ImageOnlyFailure ]

# No gradients
svg/W3C-SVG-1.1-SE/pservers-grad-17-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1-SE/pservers-grad-20-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/color-prop-01-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/coords-units-01-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/painting-render-01-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-01-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-02-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-04-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-05-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-06-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-07-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-08-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-09-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-10-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-11-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-12-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-13-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-14-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-15-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-16-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-17-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-18-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-19-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/styling-inherit-01-b.svg [ ImageOnlyFailure ]
svg/carto.net/colourpicker.svg [ ImageOnlyFailure ]
svg/css/invalid-color-cascade.svg [ ImageOnlyFailure ]
svg/css/path-gradient-stroke-shadow.svg [ ImageOnlyFailure ]
svg/css/rect-gradient-stroke-shadow.svg [ ImageOnlyFailure ]
svg/css/text-gradient-shadow.svg [ ImageOnlyFailure ]
svg/custom/broken-internal-references.svg [ Failure ]
svg/custom/dominant-baseline-hanging.svg [ Failure ]
svg/custom/fill-fallback.svg [ Failure ]
svg/custom/gradient-add-stops.svg [ Failure ]
svg/custom/gradient-attr-update.svg [ Failure ]
svg/custom/gradient-cycle-detection.svg [ Failure ]
svg/custom/gradient-deep-referencing.svg [ Failure ]
svg/custom/gradient-rotated-bbox.svg [ Failure ]
svg/custom/gradient-stop-corner-cases.svg [ Failure ]
svg/custom/gradient-stop-style-change.svg [ Failure ]
svg/custom/gradient-stroke-width.svg [ Failure ]
svg/custom/gradient-userSpaceOnUse-with-percentage.svg [ Failure ]
svg/custom/gradient-with-1d-boundingbox.svg [ Failure ]
svg/custom/grayscale-gradient-mask-2.svg [ Failure ]
svg/custom/grayscale-gradient-mask.svg [ Failure ]
svg/custom/group-opacity.svg [ Failure ]
svg/custom/href-xlink-href-gradient-element.svg [ ImageOnlyFailure ]
svg/custom/inline-svg-in-xhtml.xml [ Failure ]
svg/custom/invalid-css.svg [ Failure ]
svg/custom/js-late-gradient-and-object-creation.svg [ Failure ]
svg/custom/js-late-gradient-creation.svg [ Failure ]
svg/custom/js-update-gradient.svg [ Failure ]
svg/custom/js-update-stop-linked-gradient.svg [ Failure ]
svg/custom/large-bounding-box-percents.svg [ Failure ]
svg/custom/local-url-reference-fill.html [ ImageOnlyFailure ]
svg/custom/local-url-reference-radial-gradient.html [ ImageOnlyFailure ]
svg/custom/local-url-reference-srcdoc.html [ ImageOnlyFailure ]
svg/custom/local-url-reference-stroke.html [ ImageOnlyFailure ]
svg/custom/non-scaling-stroke.svg [ Failure ]
svg/custom/radial-gradient-with-outstanding-focalPoint.svg [ Failure ]
svg/custom/radialGradient-focal-radius.svg [ Failure ]
svg/custom/recursive-gradient.svg [ Failure ]
svg/custom/relative-sized-content-with-resources.xhtml [ Failure ]
svg/custom/resource-client-removal.svg [ Failure ]
svg/custom/stroke-fallback.svg [ Failure ]
svg/custom/text-rotated-gradient.svg [ Failure ]
svg/custom/uri-reference-handling.svg [ Failure ]
svg/custom/xlink-custom-namespace.svg [ Failure ]
svg/gradients/spreadMethod.svg [ ImageOnlyFailure ]
svg/gradients/spreadMethodAlpha.svg [ ImageOnlyFailure ]
svg/gradients/spreadMethodClose2.svg [ ImageOnlyFailure ]
svg/gradients/spreadMethodDiagonal.svg [ ImageOnlyFailure ]
svg/gradients/spreadMethodDiagonal2.svg [ ImageOnlyFailure ]
svg/gradients/spreadMethodDiagonal3.svg [ ImageOnlyFailure ]
svg/gradients/spreadMethodDiagonal4.svg [ ImageOnlyFailure ]
svg/gradients/spreadMethodDuplicateStop.svg [ ImageOnlyFailure ]
svg/gradients/spreadMethodReversed.svg [ ImageOnlyFailure ]
svg/gradients/stopAlpha.svg [ ImageOnlyFailure ]
svg/hixie/perf/005.xml [ ImageOnlyFailure ]
svg/hixie/perf/006.xml [ ImageOnlyFailure ]
svg/text/selection-background-color.xhtml [ ImageOnlyFailure ]
svg/text/selection-styles.xhtml [ ImageOnlyFailure ]
svg/text/text-gradient-positioning.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1-SE/pservers-grad-17-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1-SE/pservers-grad-20-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/color-prop-01-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/coords-units-01-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/painting-render-01-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-01-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-02-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-04-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-05-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-06-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-07-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-08-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-09-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-10-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-11-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-12-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-13-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-14-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-15-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-16-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-17-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-18-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/pservers-grad-19-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/styling-inherit-01-b.svg [ ImageOnlyFailure ]
svg/as-background-image/background-image-tiled.html [ ImageOnlyFailure ]
svg/as-background-image/svg-as-background-2.html [ ImageOnlyFailure ]
svg/as-background-image/svg-as-background-3.html [ ImageOnlyFailure ]
svg/as-background-image/svg-as-background-with-relative-size.html [ ImageOnlyFailure ]
svg/carto.net/colourpicker.svg [ ImageOnlyFailure ]
svg/css/invalid-color-cascade.svg [ ImageOnlyFailure ]
svg/css/path-gradient-stroke-shadow.svg [ ImageOnlyFailure ]
svg/css/rect-gradient-stroke-shadow.svg [ ImageOnlyFailure ]
svg/css/text-gradient-shadow.svg [ ImageOnlyFailure ]
svg/custom/broken-internal-references.svg [ Failure ]
svg/custom/dominant-baseline-hanging.svg [ Failure ]
svg/custom/fill-fallback.svg [ Failure ]
svg/custom/gradient-add-stops.svg [ Failure ]
svg/custom/gradient-attr-update.svg [ Failure ]
svg/custom/gradient-cycle-detection.svg [ Failure ]
svg/custom/gradient-deep-referencing.svg [ Failure ]
svg/custom/gradient-rotated-bbox.svg [ Failure ]
svg/custom/gradient-stop-corner-cases.svg [ Failure ]
svg/custom/gradient-stop-style-change.svg [ Failure ]
svg/custom/gradient-stroke-width.svg [ Failure ]
svg/custom/gradient-userSpaceOnUse-with-percentage.svg [ Failure ]
svg/custom/gradient-with-1d-boundingbox.svg [ Failure ]
svg/custom/grayscale-gradient-mask-2.svg [ Failure ]
svg/custom/grayscale-gradient-mask.svg [ Failure ]
svg/custom/group-opacity.svg [ Failure ]
svg/custom/href-xlink-href-gradient-element.svg [ ImageOnlyFailure ]
svg/custom/inline-svg-in-xhtml.xml [ Failure ]
svg/custom/invalid-css.svg [ Failure ]
svg/custom/js-late-gradient-and-object-creation.svg [ Failure ]
svg/custom/js-late-gradient-creation.svg [ Failure ]
svg/custom/js-update-gradient.svg [ Failure ]
svg/custom/js-update-stop-linked-gradient.svg [ Failure ]
svg/custom/large-bounding-box-percents.svg [ Failure ]
svg/custom/local-url-reference-fill.html [ ImageOnlyFailure ]
svg/custom/local-url-reference-radial-gradient.html [ ImageOnlyFailure ]
svg/custom/local-url-reference-srcdoc.html [ ImageOnlyFailure ]
svg/custom/local-url-reference-stroke.html [ ImageOnlyFailure ]
svg/custom/non-scaling-stroke.svg [ Failure ]
svg/custom/radial-gradient-with-outstanding-focalPoint.svg [ Failure ]
svg/custom/radialGradient-focal-radius.svg [ Failure ]
svg/custom/recursive-gradient.svg [ Failure ]
svg/custom/relative-sized-content-with-resources.xhtml [ Failure ]
svg/custom/resource-client-removal.svg [ Failure ]
svg/custom/stroke-fallback.svg [ Failure ]
svg/custom/text-rotated-gradient.svg [ Failure ]
svg/custom/uri-reference-handling.svg [ Failure ]
svg/custom/xlink-custom-namespace.svg [ Failure ]
svg/gradients/spreadMethod.svg [ ImageOnlyFailure ]
svg/gradients/spreadMethodAlpha.svg [ ImageOnlyFailure ]
svg/gradients/spreadMethodClose2.svg [ ImageOnlyFailure ]
svg/gradients/spreadMethodDiagonal.svg [ ImageOnlyFailure ]
svg/gradients/spreadMethodDiagonal2.svg [ ImageOnlyFailure ]
svg/gradients/spreadMethodDiagonal3.svg [ ImageOnlyFailure ]
svg/gradients/spreadMethodDiagonal4.svg [ ImageOnlyFailure ]
svg/gradients/spreadMethodDuplicateStop.svg [ ImageOnlyFailure ]
svg/gradients/spreadMethodReversed.svg [ ImageOnlyFailure ]
svg/gradients/stopAlpha.svg [ ImageOnlyFailure ]
svg/hixie/perf/005.xml [ ImageOnlyFailure ]
svg/hixie/perf/006.xml [ ImageOnlyFailure ]
svg/text/selection-background-color.xhtml [ ImageOnlyFailure ]
svg/text/selection-styles.xhtml [ ImageOnlyFailure ]
svg/text/text-gradient-positioning.svg [ ImageOnlyFailure ]
svg/wicd/test-scalable-background-image1.xhtml [ ImageOnlyFailure ]
svg/wicd/test-scalable-background-image2.xhtml [ ImageOnlyFailure ]
svg/zoom/page/zoom-background-image-tiled.html [ ImageOnlyFailure ]
svg/zoom/page/zoom-svg-as-background-with-relative-size.html [ ImageOnlyFailure ]

# No patterns
svg/W3C-SVG-1.1-SE/pservers-pattern-04-f.svg [ ImageOnlyFailure ]
@@ -511,6 +529,7 @@ svg/transforms/text-with-mask-with-svg-transform.svg [ Failure ]
svg/zoom/page/zoom-mask-with-percentages.svg [ Failure ]

# Text rendering ignores SVG 'transform' attribute (e.g. <text transform="rotate(... " is not transformed during rendering)
svg/as-background-image/svg-as-background-5.html [ ImageOnlyFailure ]
svg/W3C-SVG-1.1-SE/types-dom-01-b.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/animate-elem-24-t.svg [ ImageOnlyFailure ]
svg/W3C-SVG-1.1/fonts-kern-01-t.svg [ ImageOnlyFailure ]
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -99,6 +99,10 @@ CachedImage::~CachedImage()
void CachedImage::load(CachedResourceLoader& loader)
{
m_skippingRevalidationDocument = loader.document();
#if ENABLE(LAYER_BASED_SVG_ENGINE)
m_layerBasedSVGEngineEnabled = loader.document() ? loader.document()->settings().layerBasedSVGEngineEnabled() : false;
#endif

if (loader.shouldPerformImageLoad(url()))
CachedResource::load(loader);
else
@@ -101,6 +101,8 @@ class CachedImage final : public CachedResource {
bool isVisibleInViewport(const Document&) const;
bool allowsAnimation(const Image&) const;

bool layerBasedSVGEngineEnabled() const { return m_layerBasedSVGEngineEnabled; }

private:
void clear();

@@ -161,6 +163,7 @@ class CachedImage final : public CachedResource {
void scheduleRenderingUpdate(const Image&) final;

bool allowsAnimation(const Image&) const final;
bool layerBasedSVGEngineEnabled() const final { return !m_cachedImages.isEmpty() ? (*m_cachedImages.begin())->m_layerBasedSVGEngineEnabled : false; }

HashSet<CachedImage*> m_cachedImages;
};
@@ -201,6 +204,7 @@ class CachedImage final : public CachedResource {
bool m_isManuallyCached : 1;
bool m_shouldPaintBrokenImage : 1;
bool m_forceUpdateImageDataEnabledForTesting : 1;
bool m_layerBasedSVGEngineEnabled : 1 { false };
};

} // namespace WebCore
@@ -54,6 +54,7 @@ class ImageObserver {
virtual void scheduleRenderingUpdate(const Image&) = 0;

virtual bool allowsAnimation(const Image&) const { return true; }
virtual bool layerBasedSVGEngineEnabled() const { return false; }
};

}

0 comments on commit 3c9c020

Please sign in to comment.