From a0eb07ee302f9f5739c85fb4da5db3afe7f59e37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 21 Jan 2019 22:24:06 +0100 Subject: [PATCH] Bug 1505222 - Pass TransformStyle::Preserve3d to WebRender more often for perspective display items. r=mattwoodrow See the comment. Differential Revision: https://phabricator.services.mozilla.com/D16768 --- layout/painting/nsDisplayList.cpp | 15 +++++++++++- .../preserve3d-nested-perspective-ref.html | 13 ++++++++++ .../preserve3d-nested-perspective.html | 24 +++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 testing/web-platform/tests/css/css-transforms/preserve3d-nested-perspective-ref.html create mode 100644 testing/web-platform/tests/css/css-transforms/preserve3d-nested-perspective.html diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index b544515e0fa0..3a4e38da25b4 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -8483,12 +8483,25 @@ bool nsDisplayPerspective::CreateWebRenderCommands( nsIFrame* perspectiveFrame = mFrame->GetContainingBlock(nsIFrame::SKIP_SCROLLED_FRAME); + // Passing true here is always correct, since perspective always combines + // transforms with the descendants. However that'd make WR do a lot of work + // that it doesn't really need to do if there aren't other transforms forming + // part of the 3D context. + // + // WR knows how to treat perspective in that case, so the only thing we need + // to do is to ensure we pass true when we're involved in a 3d context in any + // other way via the transform-style property on either the transformed frame + // or the perspective frame in order to not confuse WR's preserve-3d code in + // very awful ways. + bool preserve3D = + mFrame->Extend3DContext() || perspectiveFrame->Extend3DContext(); + nsTArray filters; StackingContextHelper sc( aSc, GetActiveScrolledRoot(), mFrame, this, aBuilder, filters, LayoutDeviceRect(), nullptr, nullptr, nullptr, &perspectiveMatrix, wr::ReferenceFrameKind::Perspective, gfx::CompositionOp::OP_OVER, - !BackfaceIsHidden(), perspectiveFrame->Extend3DContext()); + !BackfaceIsHidden(), preserve3D); return mList.CreateWebRenderCommands(aBuilder, aResources, sc, aManager, aDisplayListBuilder); diff --git a/testing/web-platform/tests/css/css-transforms/preserve3d-nested-perspective-ref.html b/testing/web-platform/tests/css/css-transforms/preserve3d-nested-perspective-ref.html new file mode 100644 index 000000000000..df0bfc417df0 --- /dev/null +++ b/testing/web-platform/tests/css/css-transforms/preserve3d-nested-perspective-ref.html @@ -0,0 +1,13 @@ + +CSS Test Reference + + + +
diff --git a/testing/web-platform/tests/css/css-transforms/preserve3d-nested-perspective.html b/testing/web-platform/tests/css/css-transforms/preserve3d-nested-perspective.html new file mode 100644 index 000000000000..368784c74f51 --- /dev/null +++ b/testing/web-platform/tests/css/css-transforms/preserve3d-nested-perspective.html @@ -0,0 +1,24 @@ + +CSS Test: nested preserve-3d and perspective without transformed items + + + + + + + + +
+
+
+
+
+
+