Ignore:
Timestamp:
Apr 7, 2022, 3:06:46 AM (3 years ago)
Author:
Nikolas Zimmermann
Message:

Unify 'transform-box' reference box computation
https://bugs.webkit.org/show_bug.cgi?id=237554

Reviewed by Simon Fraser.

Currently the code to compute the reference box, according to the CSS 'transform-box'
property is sprinkled over various places: CSSComputedStyleDeclaration, SVGRenderSupport,
RenderBox, parts in RenderLayer.

Cleanup and unify the code in a new 'FloatRect referenceBoxRect(CSSBoxType) const' method.
RenderElement::referenceBoxRect(CSSBoxType) contains the SVG specific implementation, and
RenderBox::referenceBoxRect() the HTML/CSS one (previously named referenceBox()).

File:
1 edited

Legend:

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

    r292467 r292525  
    569569}
    570570
    571 static FloatRect transformReferenceBox(const RenderStyle& style, const RenderElement& renderer)
    572 {
    573     if (is<RenderBox>(renderer))
    574         return downcast<RenderBox>(renderer).referenceBox(transformBoxToCSSBoxType(style.transformBox()));
    575 
    576     if (is<SVGElement>(renderer.element()))
    577         return SVGRenderSupport::transformReferenceBox(renderer, downcast<SVGElement>(*renderer.element()), style);
    578 
    579     return { };
    580 }
    581 
    582571static Ref<CSSFunctionValue> matrixTransformValue(const TransformationMatrix& transform, const RenderStyle& style)
    583572{
     
    632621
    633622    TransformationMatrix transform;
    634     style.applyTransform(transform, transformReferenceBox(style, *renderer), { });
     623    style.applyTransform(transform, renderer->transformReferenceBoxRect(style), { });
     624
    635625    // Note that this does not flatten to an affine transform if ENABLE(3D_TRANSFORMS) is off, by design.
    636626
     
    38233813            auto list = CSSValueList::createSpaceSeparated();
    38243814            if (renderer) {
    3825                 auto box = transformReferenceBox(style, *renderer);
     3815                auto box = renderer->transformReferenceBoxRect(style);
    38263816                list->append(zoomAdjustedPixelValue(minimumValueForLength(style.perspectiveOriginX(), box.width()), style));
    38273817                list->append(zoomAdjustedPixelValue(minimumValueForLength(style.perspectiveOriginY(), box.height()), style));
     
    38793869            auto list = CSSValueList::createSpaceSeparated();
    38803870            if (renderer) {
    3881                 auto box = transformReferenceBox(style, *renderer);
     3871                auto box = renderer->transformReferenceBoxRect(style);
    38823872                list->append(zoomAdjustedPixelValue(minimumValueForLength(style.transformOriginX(), box.width()), style));
    38833873                list->append(zoomAdjustedPixelValue(minimumValueForLength(style.transformOriginY(), box.height()), style));
Note: See TracChangeset for help on using the changeset viewer.