WebKit icon indicating copy to clipboard operation
WebKit copied to clipboard

CSS perspective should only affect direct DOM children.

Open mattwoodrow opened this issue 2 years ago โ€ข 4 comments

1f51474223ec6ae7e7cc1ede9c68baeb6b0ea3ab

CSS perspective should only affect direct DOM children.
https://bugs.webkit.org/show_bug.cgi?id=73268
<rdar://problem/100834757>

Reviewed by NOBODY (OOPS!).

CSS perspective should only be combined into the transform of direct DOM children, and shouldn't result in any intersections in 3d coordinate space.

We currently create a GraphicsLayer for the RenderLayer with perspective, which applies the perspective to all RenderLayer children (even if they belong
to a descendant that isn't a child), and enables intersections.
This change instead creates a wrapper GraphicsLayer for each transformed RenderLayer which should inherit perspective from its parent. This ensures that
we only apply perspective when correct, and no intersections can happens since the perspective wrapper only has a single child.
The downside is that we create extra GraphicsLayers, but there's no other way to get the desired CSS behaviour with the current API.

The perspective layer is sized the same as the parent layer, since the computed perspective transform gets applied relative to the anchor point of the
layer, and it's expected to be in the middle of the layer, so we need them to be the same size.

* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/css/css-transforms/3d-rendering-context-behavior-expected.txt:
* Source/WebCore/rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::destroyGraphicsLayers):
(WebCore::RenderLayerBacking::updateChildrenTransformAndAnchorPoint):
(WebCore::RenderLayerBacking::updateConfiguration):
(WebCore::RenderLayerBacking::updateInternalHierarchy):
(WebCore::RenderLayerBacking::updatePerspectiveLayer):
(WebCore::RenderLayerBacking::childForSuperlayers const):
* Source/WebCore/rendering/RenderLayerBacking.h:
* Source/WebCore/rendering/RenderLayerCompositor.cpp:
(WebCore::recompositeChangeRequiresGeometryUpdate):
(WebCore::recompositeChangeRequiresChildrenGeometryUpdate):
(WebCore::RenderLayerCompositor::layerStyleChanged):
* Source/WebCore/rendering/RenderObject.cpp:
(WebCore::RenderObject::getTransformFromContainer const):

https://github.com/WebKit/WebKit/commit/1f51474223ec6ae7e7cc1ede9c68baeb6b0ea3ab

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
โœ… ๐Ÿ›  watch โŒ ๐Ÿงช mac-AS-debug-wk2
โœ… ๐Ÿ›  watch-sim โœ… ๐Ÿงช mac-wk2-stress

mattwoodrow avatar Oct 12 '22 04:10 mattwoodrow

I couple of thoughts before I do a full review.

  1. perspective can be animated; do we map this to a hardware animation now? With your patch, do we correctly animate perspective on all the right layers?
  2. There's a parallax scrolling thing where perspective on an overflow:scroll affects the transform on scrolled, transformed layers, and this needs to continue to work.

smfr avatar Oct 12 '22 22:10 smfr