Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LBSE] Outermost <svg> elements are not device-pixel aligned #4158

Conversation

nikolaszimmermann
Copy link
Contributor

@nikolaszimmermann nikolaszimmermann commented Sep 9, 2022

de2323d

[LBSE] Outermost <svg> elements are not device-pixel aligned
https://bugs.webkit.org/show_bug.cgi?id=244966

Reviewed by Rob Buis.

RenderLayer::paintLayerByApplingTransform() already contains all the code necessary to place
outer <svg> elements on device-pixel aligned boundaries. The subpixelOffset is applied as
transformation once for the outermost <svg> and thus to all descendants, since the
outermost <svg> establishes a stacking context. The subpixelOffset is not relevant below
RenderSVGRoot, since the rest of the SVG render tree is not applying device-pixel alignment.

This fixes a few rendering differences between LBSE / legacy, as indicated by the LBSE
specific expected.png removal.

Add two new tests covering inline SVG positioning non non-integer coordinates, probing the
sub-pixel / device-pixel alignment is done correctly.

A follow-up patch will revisit this topic, considering also composited elements, testing
their behaviour with respect to sub-pixel positioning + SVG + overflow + 3D transforms...

* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/custom/absolute-sized-svg-in-xhtml-expected.png: Removed.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/custom/createImageElement2-expected.png: Removed.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/custom/embedding-external-svgs-expected.png: Removed.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/custom/image-parent-translation-expected.png: Removed.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/custom/junk-data-expected.png: Removed.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/custom/path-bad-data-expected.png: Removed.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/custom/rootmost-svg-xy-attrs-expected.png:
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/hixie/error/012-expected.png: Removed.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/transforms/animated-path-inside-transformed-html-expected.png: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/transforms/svg-css-transforms-expected.png: Removed.
* LayoutTests/svg/compositing/outermost-svg-with-border-padding.html: Allow 1px more difference (seen by ews-mac-debug-wk2).
* LayoutTests/svg/in-html/inline-svg-non-integer-position-display-block-expected.html: Added.
* LayoutTests/svg/in-html/inline-svg-non-integer-position-display-block.html: Added.
* LayoutTests/svg/in-html/inline-svg-non-integer-position-display-inline-expected.html: Added.
* LayoutTests/svg/in-html/inline-svg-non-integer-position-display-inline.html: Added.
* Source/WebCore/rendering/RenderLayerBacking.cpp:
(WebCore::snappedGraphicsLayer):
(WebCore::RenderLayerBacking::computeParentGraphicsLayerRect const):
(WebCore::RenderLayerBacking::updateGeometry):
(WebCore::RenderLayerBacking::adjustOverflowControlsPositionRelativeToAncestor):
(WebCore::RenderLayerBacking::updateMaskingLayerGeometry):
(WebCore::RenderLayerBacking::updateContentsRects):
(WebCore::RenderLayerBacking::updateClippingStackLayerGeometry):
(WebCore::RenderLayerBacking::setContentsNeedDisplayInRect):
* Source/WebCore/rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::paintingAffectedByExternalOffset const):
(WebCore::RenderSVGRoot::updateFromStyle):
* Source/WebCore/rendering/svg/RenderSVGRoot.h:

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

c983d0b

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  πŸ§ͺ win
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim   πŸ›  mac-debug βœ… πŸ›  gtk βœ… πŸ›  wincairo
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv   πŸ§ͺ mac-wk1
βœ… πŸ›  tv-sim ❌ πŸ§ͺ mac-wk2
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch   πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  watch-sim βœ… πŸ§ͺ mac-wk2-stress

@nikolaszimmermann nikolaszimmermann changed the title [LBSE] [LBSE] Outermost <svg> elements are not device-pixel aligned Sep 9, 2022
@nikolaszimmermann
Copy link
Contributor Author

This depends on PR #4157.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Sep 9, 2022
@nikolaszimmermann nikolaszimmermann removed the merging-blocked Applied to prevent a change from being merged label Sep 9, 2022
@nikolaszimmermann nikolaszimmermann force-pushed the eng/LBSE-Outermost-svg-elements-are-not-device-pixel-aligned branch from b777164 to 541e0ba Compare September 9, 2022 21:53
@nikolaszimmermann
Copy link
Contributor Author

This depends on PR #4157.
It is in -- rebased this branch, ready for review.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Sep 10, 2022
Copy link
Contributor

@rwlbuis rwlbuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@nikolaszimmermann nikolaszimmermann removed the request for review from smfr September 16, 2022 12:35
@nikolaszimmermann nikolaszimmermann removed the merging-blocked Applied to prevent a change from being merged label Sep 16, 2022
@nikolaszimmermann
Copy link
Contributor Author

mac-AS-debug-wk2 shows one test with 1px more in fuzziness 852 -> 853 pixels (it was already a range, so it's fine to raise).

@nikolaszimmermann nikolaszimmermann force-pushed the eng/LBSE-Outermost-svg-elements-are-not-device-pixel-aligned branch from 541e0ba to c983d0b Compare September 16, 2022 12:36
@nikolaszimmermann nikolaszimmermann added the merge-queue Applied to send a pull request to merge-queue label Sep 16, 2022
https://bugs.webkit.org/show_bug.cgi?id=244966

Reviewed by Rob Buis.

RenderLayer::paintLayerByApplingTransform() already contains all the code necessary to place
outer <svg> elements on device-pixel aligned boundaries. The subpixelOffset is applied as
transformation once for the outermost <svg> and thus to all descendants, since the
outermost <svg> establishes a stacking context. The subpixelOffset is not relevant below
RenderSVGRoot, since the rest of the SVG render tree is not applying device-pixel alignment.

This fixes a few rendering differences between LBSE / legacy, as indicated by the LBSE
specific expected.png removal.

Add two new tests covering inline SVG positioning non non-integer coordinates, probing the
sub-pixel / device-pixel alignment is done correctly.

A follow-up patch will revisit this topic, considering also composited elements, testing
their behaviour with respect to sub-pixel positioning + SVG + overflow + 3D transforms...

* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/custom/absolute-sized-svg-in-xhtml-expected.png: Removed.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/custom/createImageElement2-expected.png: Removed.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/custom/embedding-external-svgs-expected.png: Removed.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/custom/image-parent-translation-expected.png: Removed.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/custom/junk-data-expected.png: Removed.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/custom/path-bad-data-expected.png: Removed.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/custom/rootmost-svg-xy-attrs-expected.png:
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/hixie/error/012-expected.png: Removed.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/transforms/animated-path-inside-transformed-html-expected.png: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/transforms/svg-css-transforms-expected.png: Removed.
* LayoutTests/svg/compositing/outermost-svg-with-border-padding.html: Allow 1px more difference (seen by ews-mac-debug-wk2).
* LayoutTests/svg/in-html/inline-svg-non-integer-position-display-block-expected.html: Added.
* LayoutTests/svg/in-html/inline-svg-non-integer-position-display-block.html: Added.
* LayoutTests/svg/in-html/inline-svg-non-integer-position-display-inline-expected.html: Added.
* LayoutTests/svg/in-html/inline-svg-non-integer-position-display-inline.html: Added.
* Source/WebCore/rendering/RenderLayerBacking.cpp:
(WebCore::snappedGraphicsLayer):
(WebCore::RenderLayerBacking::computeParentGraphicsLayerRect const):
(WebCore::RenderLayerBacking::updateGeometry):
(WebCore::RenderLayerBacking::adjustOverflowControlsPositionRelativeToAncestor):
(WebCore::RenderLayerBacking::updateMaskingLayerGeometry):
(WebCore::RenderLayerBacking::updateContentsRects):
(WebCore::RenderLayerBacking::updateClippingStackLayerGeometry):
(WebCore::RenderLayerBacking::setContentsNeedDisplayInRect):
* Source/WebCore/rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::paintingAffectedByExternalOffset const):
(WebCore::RenderSVGRoot::updateFromStyle):
* Source/WebCore/rendering/svg/RenderSVGRoot.h:

Canonical link: https://commits.webkit.org/254558@main
@webkit-early-warning-system webkit-early-warning-system force-pushed the eng/LBSE-Outermost-svg-elements-are-not-device-pixel-aligned branch from c983d0b to de2323d Compare September 16, 2022 15:46
@webkit-commit-queue
Copy link
Collaborator

Committed 254558@main (de2323d): https://commits.webkit.org/254558@main

Reviewed commits have been landed. Closing PR #4158 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system merged commit de2323d into WebKit:main Sep 16, 2022
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Sep 16, 2022
@nikolaszimmermann nikolaszimmermann deleted the eng/LBSE-Outermost-svg-elements-are-not-device-pixel-aligned branch September 16, 2022 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SVG For bugs in the SVG implementation.
Projects
None yet
5 participants