Ignore:
Timestamp:
Sep 11, 2021, 6:41:08 PM (4 years ago)
Author:
Simon Fraser
Message:

css/css-transforms/translate-getComputedStyle.html fails
https://bugs.webkit.org/show_bug.cgi?id=230178

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

The interpolation test appears to regress, but do so because we now correctly output calc()
in computed style (we just serialize the calc incorrectly).

  • web-platform-tests/css/css-transforms/animation/translate-composition-expected.txt:
  • web-platform-tests/css/css-transforms/animation/translate-interpolation-expected.txt:
  • web-platform-tests/css/css-transforms/transforms-support-calc-expected.txt:
  • web-platform-tests/css/css-transforms/translate-getComputedStyle-expected.txt:
  • web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-002-expected.txt:

Source/WebCore:

https://drafts.csswg.org/css-transforms-2/#propdef-translate says that the computed value of
the translate property is "the keyword none or a pair of computed <length-percentage> values
and an absolute length" and has a note saying "Note: The resolved value of the translate
property is the computed value, and thus getComputedStyle() includes percentage values in
its results." so implement that.

Tested by imported/w3c/web-platform-tests/css/css-transforms/translate-getComputedStyle.html

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::computedTranslate):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r282234 r282315  
    624624}
    625625
     626// https://drafts.csswg.org/css-transforms-2/#propdef-translate
     627// Computed value: the keyword none or a pair of computed <length-percentage> values and an absolute length
    626628static Ref<CSSValue> computedTranslate(RenderObject* renderer, const RenderStyle& style)
    627629{
     
    630632        return CSSValuePool::singleton().createIdentifierValue(CSSValueNone);
    631633
    632     FloatRect pixelSnappedRect;
    633     if (is<RenderBox>(*renderer))
    634         pixelSnappedRect = snapRectToDevicePixels(downcast<RenderBox>(*renderer).borderBoxRect(), renderer->document().deviceScaleFactor());
    635 
    636     TransformationMatrix transform;
    637     translate->apply(transform, pixelSnappedRect.size());
    638 
    639634    auto list = CSSValueList::createSpaceSeparated();
    640     if (transform.isAffine()) {
    641         list->append(zoomAdjustedPixelValue(transform.e(), style));
    642         if (transform.f())
    643             list->append(zoomAdjustedPixelValue(transform.f(), style));
    644     } else {
    645         list->append(zoomAdjustedPixelValue(transform.m41(), style));
    646         list->append(zoomAdjustedPixelValue(transform.m42(), style));
    647         list->append(zoomAdjustedPixelValue(transform.m43(), style));
    648     }
     635    list->append(zoomAdjustedPixelValueForLength(translate->x(), style));
     636
     637    if (!translate->y().isZero() || !translate->z().isZero())
     638        list->append(zoomAdjustedPixelValueForLength(translate->y(), style));
     639
     640    if (!translate->z().isZero())
     641        list->append(zoomAdjustedPixelValueForLength(translate->z(), style));
    649642
    650643    return list;
Note: See TracChangeset for help on using the changeset viewer.