Skip to content
Permalink
Browse files
Ship new perspective: 0 behavior from CSS3DTransformInteroperabilit…
…yEnabled

https://bugs.webkit.org/show_bug.cgi?id=245110
<rdar://99850527>

Reviewed by Simon Fraser.

This behavior is already to shipped by Chrome & Firefox, so it is web-compatible.
Also move it out from CSS3DTransformInteroperabilityEnabled, since it is not directly related to 3D transforms.

Tests:
- imported/w3c/web-platform-tests/css/css-transforms/perspective-zero-2.html
- imported/w3c/web-platform-tests/css/css-transforms/transform3d-perspective-005.html

* Source/WebCore/rendering/RenderLayer.cpp:
(WebCore::RenderLayer::perspectiveTransform const):
* Source/WebCore/rendering/RenderObject.cpp:
(WebCore::RenderObject::getTransformFromContainer const):
* Source/WebCore/rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::applyPerspective const):
(WebCore::RenderStyle::usedPerspective const): Deleted.
* Source/WebCore/rendering/style/RenderStyle.h:
(WebCore::RenderStyle::usedPerspective const):

Canonical link: https://commits.webkit.org/254420@main
  • Loading branch information
nt1m committed Sep 13, 2022
1 parent c808394 commit 5730d5c8fb455166bc00aaaef3689b3d07dcdc34
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
@@ -1840,7 +1840,7 @@ TransformationMatrix RenderLayer::perspectiveTransform() const

TransformationMatrix transform;
style.unapplyTransformOrigin(transform, transformOrigin);
style.applyPerspective(transform, renderer(), perspectiveOrigin);
style.applyPerspective(transform, perspectiveOrigin);
style.applyTransformOrigin(transform, transformOrigin);
return transform;
}
@@ -1461,7 +1461,7 @@ void RenderObject::getTransformFromContainer(const RenderObject* containerObject
FloatPoint perspectiveOrigin = downcast<RenderLayerModelObject>(*containerObject).layer()->perspectiveOrigin();

TransformationMatrix perspectiveMatrix;
perspectiveMatrix.applyPerspective(containerObject->style().usedPerspective(*this));
perspectiveMatrix.applyPerspective(containerObject->style().usedPerspective());

transform.translateRight3d(-perspectiveOrigin.x(), -perspectiveOrigin.y(), 0);
transform = perspectiveMatrix * transform;
@@ -1493,7 +1493,7 @@ FloatPoint RenderStyle::computePerspectiveOrigin(const FloatRect& boundingBox) c
return boundingBox.location() + floatPointForLengthPoint(perspectiveOrigin(), boundingBox.size());
}

void RenderStyle::applyPerspective(TransformationMatrix& transform, const RenderObject& renderer, const FloatPoint& originTranslate) const
void RenderStyle::applyPerspective(TransformationMatrix& transform, const FloatPoint& originTranslate) const
{
// https://www.w3.org/TR/css-transforms-2/#perspective
// The perspective matrix is computed as follows:
@@ -1503,7 +1503,7 @@ void RenderStyle::applyPerspective(TransformationMatrix& transform, const Render
transform.translate(originTranslate.x(), originTranslate.y());

// 3. Multiply by the matrix that would be obtained from the perspective() transform function, where the length is provided by the value of the perspective property
transform.applyPerspective(usedPerspective(renderer));
transform.applyPerspective(usedPerspective());

// 4. Translate by the negated computed X and Y values of perspective-origin
transform.translate(-originTranslate.x(), -originTranslate.y());
@@ -1914,11 +1914,6 @@ AnimationList& RenderStyle::ensureTransitions()
return *m_rareNonInheritedData->transitions;
}

float RenderStyle::usedPerspective(const RenderObject& object) const
{
return object.document().settings().css3DTransformInteroperabilityEnabled() ? std::max(1.0f, perspective()) : perspective();
}

const FontCascade& RenderStyle::fontCascade() const
{
return m_inheritedData->fontCascade;
@@ -719,7 +719,7 @@ class RenderStyle {
bool affectedByTransformOrigin() const;

FloatPoint computePerspectiveOrigin(const FloatRect& boundingBox) const;
void applyPerspective(TransformationMatrix&, const RenderObject&, const FloatPoint& originTranslate) const;
void applyPerspective(TransformationMatrix&, const FloatPoint& originTranslate) const;

FloatPoint3D computeTransformOrigin(const FloatRect& boundingBox) const;
void applyTransformOrigin(TransformationMatrix&, const FloatPoint3D& originTranslate) const;
@@ -767,7 +767,7 @@ class RenderStyle {

BackfaceVisibility backfaceVisibility() const { return static_cast<BackfaceVisibility>(m_rareNonInheritedData->backfaceVisibility); }
float perspective() const { return m_rareNonInheritedData->perspective; }
float usedPerspective(const RenderObject&) const;
float usedPerspective() const { return std::max(1.0f, perspective()); }
bool hasPerspective() const { return m_rareNonInheritedData->perspective != initialPerspective(); }
const Length& perspectiveOriginX() const { return m_rareNonInheritedData->perspectiveOriginX; }
const Length& perspectiveOriginY() const { return m_rareNonInheritedData->perspectiveOriginY; }

0 comments on commit 5730d5c

Please sign in to comment.