Changeset 286591 in webkit


Ignore:
Timestamp:
Dec 7, 2021 12:27:13 AM (8 months ago)
Author:
Martin Robinson
Message:

perspective() <= 1px should be clamped to 1px
https://bugs.webkit.org/show_bug.cgi?id=232619
<rdar://problem/85197362>

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

  • web-platform-tests/css/css-transforms/animation/transform-interpolation-verify-reftests-expected.txt: Update to show newly passing subtests.

Source/WebCore:

No new tests. This is covered by the newly passing WPT tests
in this change.

When the CSS 3D transform interoperability experimental feature is turned on,
round perspectives that are < 1 pixel to 1 pixel. This behavior is described
in the specification, but breaks backward compatibility. The reasoning provided
by the specification is:

As very small <length> values can produce bizarre rendering results and
stress the numerical accuracy of transform calculations, values less than
1px must be treated as 1px for rendering purposes.

  • platform/graphics/transforms/PerspectiveTransformOperation.h: When getting

the floating point perspective value, round to 1px.

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::perspectiveTransform const): Use usedPerspective from
RenderSTyle.

  • rendering/RenderObject.cpp:

(WebCore::RenderObject::getTransformFromContainer const): Ditto.

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::usedPerspective const): Added this method which rounds
to 1px.

  • rendering/style/RenderStyle.h:

LayoutTests:

  • TestExpectations: Mark tests as passing.
  • transforms/3d/general/3dtransform-values.html:
  • transforms/3d/general/prefixed-3dtransform-values.html:
  • transforms/3d/general/3dtransform-values-expected.txt:
  • transforms/3d/general/prefixed-3dtransform-values-expected.txt:
Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r286589 r286591  
     12021-12-07  Martin Robinson  <mrobinson@webkit.org>
     2
     3        perspective() <= 1px should be clamped to 1px
     4        https://bugs.webkit.org/show_bug.cgi?id=232619
     5        <rdar://problem/85197362>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * TestExpectations: Mark tests as passing.
     10        * transforms/3d/general/3dtransform-values.html:
     11        * transforms/3d/general/prefixed-3dtransform-values.html:
     12        * transforms/3d/general/3dtransform-values-expected.txt:
     13        * transforms/3d/general/prefixed-3dtransform-values-expected.txt:
     14
    1152021-12-06  Said Abou-Hallawa  <said@apple.com>
    216
  • trunk/LayoutTests/TestExpectations

    r286546 r286591  
    39233923webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/perspective-containing-block-dynamic-1b.html [ ImageOnlyFailure ]
    39243924webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/perspective-transforms-equivalence.html [ ImageOnlyFailure ]
    3925 webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/perspective-zero-2.html [ ImageOnlyFailure ]
    3926 webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/perspective-zero-3.html [ ImageOnlyFailure ]
    3927 webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/perspective-zero.html [ ImageOnlyFailure ]
    39283925webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/preserve3d-and-filter-no-perspective.html [ ImageOnlyFailure ]
    39293926webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/rotateY-180deg-with-overflow-scroll.html [ ImageOnlyFailure ]
     
    39883985webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/transform3d-perspective-003.html [ ImageOnlyFailure ]
    39893986webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/transform3d-perspective-004.html [ ImageOnlyFailure ]
    3990 webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/transform3d-perspective-005.html [ ImageOnlyFailure ]
    39913987webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/transform3d-preserve3d-006.html [ Pass ImageOnlyFailure ]
    39923988webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/transform3d-preserve3d-007.html [ Pass ImageOnlyFailure ]
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r286550 r286591  
     12021-12-07  Martin Robinson  <mrobinson@webkit.org>
     2
     3        perspective() <= 1px should be clamped to 1px
     4        https://bugs.webkit.org/show_bug.cgi?id=232619
     5        <rdar://problem/85197362>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * web-platform-tests/css/css-transforms/animation/transform-interpolation-verify-reftests-expected.txt: Update to show newly passing subtests.
     10
    1112021-12-06  Tadeu Zagallo  <tzagallo@apple.com>
    212
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-transforms/animation/transform-interpolation-verify-reftests-expected.txt

    r286289 r286591  
    156156PASS CSS Animations: property <transform> from [perspective(100px) translateZ(15px)] to [perspective(25px) translateZ(15px)] at (0.5) should be [perspective(40px) translateZ(15px)]
    157157PASS Web Animations: property <transform> from [perspective(100px) translateZ(15px)] to [perspective(25px) translateZ(15px)] at (0.5) should be [perspective(40px) translateZ(15px)]
    158 FAIL CSS Transitions: property <transform> from [perspective(0.1px) translateZ(0.25px)] to [perspective(0.1px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.25 , 0.75 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 10 , 0 , 0 , 0.25 , - 1.5 ) "
    159 FAIL CSS Transitions with transition: all: property <transform> from [perspective(0.1px) translateZ(0.25px)] to [perspective(0.1px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.25 , 0.75 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 10 , 0 , 0 , 0.25 , - 1.5 ) "
    160 FAIL CSS Animations: property <transform> from [perspective(0.1px) translateZ(0.25px)] to [perspective(0.1px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.25 , 0.75 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 10 , 0 , 0 , 0.25 , - 1.5 ) "
    161 FAIL Web Animations: property <transform> from [perspective(0.1px) translateZ(0.25px)] to [perspective(0.1px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.25 , 0.75 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 10 , 0 , 0 , 0.25 , - 1.5 ) "
    162 FAIL CSS Transitions: property <transform> from [perspective(0px) translateZ(0.25px)] to [perspective(0px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.25 , 0.75 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0.25 , 1 ) "
    163 FAIL CSS Transitions with transition: all: property <transform> from [perspective(0px) translateZ(0.25px)] to [perspective(0px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.25 , 0.75 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0.25 , 1 ) "
     158PASS CSS Transitions: property <transform> from [perspective(0.1px) translateZ(0.25px)] to [perspective(0.1px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)]
     159PASS CSS Transitions with transition: all: property <transform> from [perspective(0.1px) translateZ(0.25px)] to [perspective(0.1px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)]
     160PASS CSS Animations: property <transform> from [perspective(0.1px) translateZ(0.25px)] to [perspective(0.1px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)]
     161PASS Web Animations: property <transform> from [perspective(0.1px) translateZ(0.25px)] to [perspective(0.1px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)]
     162PASS CSS Transitions: property <transform> from [perspective(0px) translateZ(0.25px)] to [perspective(0px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)]
     163PASS CSS Transitions with transition: all: property <transform> from [perspective(0px) translateZ(0.25px)] to [perspective(0px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)]
    164164FAIL CSS Animations: property <transform> from [perspective(0px) translateZ(0.25px)] to [perspective(0px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.25 , 0.75 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0.25 , 1 ) "
    165165FAIL Web Animations: property <transform> from [perspective(0px) translateZ(0.25px)] to [perspective(0px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.25 , 0.75 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0.25 , 1 ) "
     
    172172PASS CSS Animations: property <transform> from [perspective(10px) translateZ(0.5px)] to [perspective(1px) translateZ(0.5px)] at (-1) should be [translateZ(0.5px)]
    173173PASS Web Animations: property <transform> from [perspective(10px) translateZ(0.5px)] to [perspective(1px) translateZ(0.5px)] at (-1) should be [translateZ(0.5px)]
    174 FAIL CSS Transitions: property <transform> from [perspective(1px) translateZ(0.5px)] to [perspective(10px) translateZ(0.5px)] at (-1) should be [perspective(1px) translateZ(0.5px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.5 , 0.5 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1.9 , 0 , 0 , 0.5 , 0.05 ) "
    175 FAIL CSS Transitions with transition: all: property <transform> from [perspective(1px) translateZ(0.5px)] to [perspective(10px) translateZ(0.5px)] at (-1) should be [perspective(1px) translateZ(0.5px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.5 , 0.5 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1.9 , 0 , 0 , 0.5 , 0.05 ) "
    176 FAIL CSS Animations: property <transform> from [perspective(1px) translateZ(0.5px)] to [perspective(10px) translateZ(0.5px)] at (-1) should be [perspective(1px) translateZ(0.5px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.5 , 0.5 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1.9 , 0 , 0 , 0.5 , 0.05 ) "
    177 FAIL Web Animations: property <transform> from [perspective(1px) translateZ(0.5px)] to [perspective(10px) translateZ(0.5px)] at (-1) should be [perspective(1px) translateZ(0.5px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.5 , 0.5 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1.9 , 0 , 0 , 0.5 , 0.05 ) "
     174PASS CSS Transitions: property <transform> from [perspective(1px) translateZ(0.5px)] to [perspective(10px) translateZ(0.5px)] at (-1) should be [perspective(1px) translateZ(0.5px)]
     175PASS CSS Transitions with transition: all: property <transform> from [perspective(1px) translateZ(0.5px)] to [perspective(10px) translateZ(0.5px)] at (-1) should be [perspective(1px) translateZ(0.5px)]
     176PASS CSS Animations: property <transform> from [perspective(1px) translateZ(0.5px)] to [perspective(10px) translateZ(0.5px)] at (-1) should be [perspective(1px) translateZ(0.5px)]
     177PASS Web Animations: property <transform> from [perspective(1px) translateZ(0.5px)] to [perspective(10px) translateZ(0.5px)] at (-1) should be [perspective(1px) translateZ(0.5px)]
    178178
  • trunk/LayoutTests/transforms/3d/general/3dtransform-values-expected.txt

    r180441 r286591  
    1616transform "perspective(50%)" expected "none" : PASS
    1717transform "perspective(-400)" expected "none" : PASS
    18 transform "perspective(0)" expected "matrix(1, 0, 0, 1, 0, 0)" : PASS
     18transform "perspective(0)" expected "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1)" : PASS
     19transform "perspective(none)" expected "matrix(1, 0, 0, 1, 0, 0)" : PASS
    1920transform "perspective(400deg)" expected "none" : PASS
    2021transform "perspective(banana)" expected "none" : PASS
  • trunk/LayoutTests/transforms/3d/general/3dtransform-values.html

    r180441 r286591  
    4444      { 'transform' : 'perspective(50%)', 'result' : 'none' },
    4545      { 'transform' : 'perspective(-400)', 'result' : 'none' },
    46       { 'transform' : 'perspective(0)', 'result' : 'matrix(1, 0, 0, 1, 0, 0)' },
     46      { 'transform' : 'perspective(0)', 'result' : 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1)' },
     47      { 'transform' : 'perspective(none)', 'result' : 'matrix(1, 0, 0, 1, 0, 0)' },
    4748      { 'transform' : 'perspective(400deg)', 'result' : 'none' }, // unit must be length
    4849      { 'transform' : 'perspective(banana)', 'result' : 'none' }, // unit must be length
  • trunk/LayoutTests/transforms/3d/general/prefixed-3dtransform-values-expected.txt

    r181832 r286591  
    1616transform "perspective(50%)" expected "none" : PASS
    1717transform "perspective(-400)" expected "none" : PASS
    18 transform "perspective(0)" expected "matrix(1, 0, 0, 1, 0, 0)" : PASS
     18transform "perspective(0)" expected "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1)" : PASS
     19transform "perspective(none)" expected "matrix(1, 0, 0, 1, 0, 0)" : PASS
    1920transform "perspective(400deg)" expected "none" : PASS
    2021transform "perspective(banana)" expected "none" : PASS
  • trunk/LayoutTests/transforms/3d/general/prefixed-3dtransform-values.html

    r181832 r286591  
    4444      { 'transform' : 'perspective(50%)', 'result' : 'none' },
    4545      { 'transform' : 'perspective(-400)', 'result' : 'none' },
    46       { 'transform' : 'perspective(0)', 'result' : 'matrix(1, 0, 0, 1, 0, 0)' },
     46      { 'transform' : 'perspective(0)', 'result' : 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1)' },
     47      { 'transform' : 'perspective(none)', 'result' : 'matrix(1, 0, 0, 1, 0, 0)' },
    4748      { 'transform' : 'perspective(400deg)', 'result' : 'none' }, // unit must be length
    4849      { 'transform' : 'perspective(banana)', 'result' : 'none' }, // unit must be length
  • trunk/Source/WebCore/ChangeLog

    r286589 r286591  
     12021-12-07  Martin Robinson  <mrobinson@webkit.org>
     2
     3        perspective() <= 1px should be clamped to 1px
     4        https://bugs.webkit.org/show_bug.cgi?id=232619
     5        <rdar://problem/85197362>
     6
     7        Reviewed by Simon Fraser.
     8
     9        No new tests. This is covered by the newly passing WPT tests
     10        in this change.
     11
     12        When the CSS 3D transform interoperability experimental feature is turned on,
     13        round perspectives that are < 1 pixel to 1 pixel. This behavior is described
     14        in the specification, but breaks backward compatibility. The reasoning provided
     15        by the specification is:
     16
     17            As very small <length> values can produce bizarre rendering results and
     18            stress the numerical accuracy of transform calculations, values less than
     19            1px must be treated as 1px for rendering purposes.
     20
     21        * platform/graphics/transforms/PerspectiveTransformOperation.h: When getting
     22        the floating point perspective value, round to 1px.
     23        * rendering/RenderLayer.cpp:
     24        (WebCore::RenderLayer::perspectiveTransform const): Use usedPerspective from
     25        RenderSTyle.
     26        * rendering/RenderObject.cpp:
     27        (WebCore::RenderObject::getTransformFromContainer const): Ditto.
     28        * rendering/style/RenderStyle.cpp:
     29        (WebCore::RenderStyle::usedPerspective const): Added this method which rounds
     30        to 1px.
     31        * rendering/style/RenderStyle.h:
     32
    1332021-12-06  Said Abou-Hallawa  <said@apple.com>
    234
  • trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h

    r286289 r286591  
    6161        if (!m_p)
    6262            return { };
    63         return floatValueForLength(*m_p, 1.0);
     63
     64        // From https://www.w3.org/TR/css-transforms-2/#perspective-property:
     65        // "As very small <length> values can produce bizarre rendering results and stress the numerical accuracy of
     66        // transform calculations, values less than 1px must be treated as 1px for rendering purposes. (This clamping
     67        // does not affect the underlying value, so perspective: 0; in a stylesheet will still serialize back as 0.)"
     68        return std::max(1.0f, floatValueForLength(*m_p, 1.0));
    6469    }
    6570
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r286542 r286591  
    17651765    TransformationMatrix t;
    17661766    t.translate(perspectiveOrigin.x(), perspectiveOrigin.y());
    1767     t.applyPerspective(style.perspective());
     1767    t.applyPerspective(style.usedPerspective(renderer()));
    17681768    t.translate(-perspectiveOrigin.x(), -perspectiveOrigin.y());
    17691769
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r286542 r286591  
    13901390
    13911391        TransformationMatrix perspectiveMatrix;
    1392         perspectiveMatrix.applyPerspective(containerObject->style().perspective());
     1392        perspectiveMatrix.applyPerspective(containerObject->style().usedPerspective(*this));
    13931393       
    13941394        transform.translateRight3d(-perspectiveOrigin.x(), -perspectiveOrigin.y(), 0);
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r286085 r286591  
    18121812        m_rareNonInheritedData.access().transitions = AnimationList::create();
    18131813    return *m_rareNonInheritedData->transitions;
     1814}
     1815
     1816float RenderStyle::usedPerspective(const RenderObject& object) const
     1817{
     1818    return object.document().settings().css3DTransformInteroperabilityEnabled() ? std::max(1.0f, perspective()) : perspective();
    18141819}
    18151820
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r286085 r286591  
    731731    BackfaceVisibility backfaceVisibility() const { return static_cast<BackfaceVisibility>(m_rareNonInheritedData->backfaceVisibility); }
    732732    float perspective() const { return m_rareNonInheritedData->perspective; }
     733    float usedPerspective(const RenderObject&) const;
    733734    bool hasPerspective() const { return m_rareNonInheritedData->perspective != initialPerspective(); }
    734735    const Length& perspectiveOriginX() const { return m_rareNonInheritedData->perspectiveOriginX; }
Note: See TracChangeset for help on using the changeset viewer.