Changeset 292382 in webkit


Ignore:
Timestamp:
Apr 5, 2022 1:03:38 AM (4 months ago)
Author:
Nikos Mouchtaris
Message:

Support rendering url(), CSS basic shapes other than path(), and coord-box for offset-path
https://bugs.webkit.org/show_bug.cgi?id=233382

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

  • web-platform-tests/css/motion/offset-path-shape-expected.html: Added.
  • web-platform-tests/css/motion/offset-path-shape.html: Added.
  • web-platform-tests/css/motion/offset-path-url-expected.html: Added.
  • web-platform-tests/css/motion/offset-path-url.html: Added.

Source/WebCore:

Introduce support for url(), CSS basic shapes, and coord-box. Url() allows references to SVG
shapes, so we check for either an SVGPathElement or SVGGeometryElement (which includes
circles, polygons, etc.). We can then get a Path object for that particular SVGElement

using pathFromGraphicsElement(). For coord-box, we check the value for the BoxPathOperation

(if it exists) in updateTransform(), and choose the corresponding reference box to the
referenceBox() value of the BoxPathOperation.

Tests: imported/w3c/web-platform-tests/css/motion/offset-path-shape.html

imported/w3c/web-platform-tests/css/motion/offset-path-url.html

  • Sources.txt:
  • rendering/PathOperation.cpp: Added.

(WebCore::ReferencePathOperation::create):
(WebCore::ReferencePathOperation::ReferencePathOperation):
(WebCore::ReferencePathOperation::element const):

  • rendering/PathOperation.h:
  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::updateTransform):

  • rendering/style/RenderStyle.cpp:

(WebCore::getPathFromPathOperation):

  • style/StyleBuilderConverter.h:

(WebCore::Style::BuilderConverter::convertPathOperation):

Location:
trunk
Files:
7 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r292376 r292382  
     12022-04-05  Nikolaos Mouchtaris  <nmouchtaris@apple.com>
     2
     3        Support rendering url(), CSS basic shapes other than path(), and coord-box for offset-path
     4        https://bugs.webkit.org/show_bug.cgi?id=233382
     5
     6        Reviewed by Simon Fraser.
     7
     8        * web-platform-tests/css/motion/offset-path-shape-expected.html: Added.
     9        * web-platform-tests/css/motion/offset-path-shape.html: Added.
     10        * web-platform-tests/css/motion/offset-path-url-expected.html: Added.
     11        * web-platform-tests/css/motion/offset-path-url.html: Added.
     12
    1132022-04-04  Ziran Sun  <zsun@igalia.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r292381 r292382  
     12022-04-05  Nikolaos Mouchtaris  <nmouchtaris@apple.com>
     2
     3        Support rendering url(), CSS basic shapes other than path(), and coord-box for offset-path
     4        https://bugs.webkit.org/show_bug.cgi?id=233382
     5
     6        Reviewed by Simon Fraser.
     7
     8        Introduce support for url(), CSS basic shapes, and coord-box. Url() allows references to SVG
     9        shapes, so we check for either an SVGPathElement or SVGGeometryElement (which includes
     10        circles, polygons, etc.). We can then get a Path object for that particular SVGElement
     11         using pathFromGraphicsElement(). For coord-box, we check the value for the BoxPathOperation
     12        (if it exists) in updateTransform(), and choose the corresponding reference box to the
     13        referenceBox() value of the BoxPathOperation.
     14
     15        Tests: imported/w3c/web-platform-tests/css/motion/offset-path-shape.html
     16               imported/w3c/web-platform-tests/css/motion/offset-path-url.html
     17
     18        * Sources.txt:
     19        * rendering/PathOperation.cpp: Added.
     20        (WebCore::ReferencePathOperation::create):
     21        (WebCore::ReferencePathOperation::ReferencePathOperation):
     22        (WebCore::ReferencePathOperation::element const):
     23        * rendering/PathOperation.h:
     24        * rendering/RenderLayer.cpp:
     25        (WebCore::RenderLayer::updateTransform):
     26        * rendering/style/RenderStyle.cpp:
     27        (WebCore::getPathFromPathOperation):
     28        * style/StyleBuilderConverter.h:
     29        (WebCore::Style::BuilderConverter::convertPathOperation):
     30
    1312022-04-05  Megan Gardner  <megan_gardner@apple.com>
    232
  • trunk/Source/WebCore/Sources.txt

    r292210 r292382  
    23282328rendering/MarkedText.cpp
    23292329rendering/OrderIterator.cpp
     2330rendering/PathOperation.cpp
    23302331rendering/PointerEventsHitRules.cpp
    23312332rendering/ReferencedSVGResources.cpp
  • trunk/Source/WebCore/rendering/PathOperation.h

    r286086 r292382  
    3939namespace WebCore {
    4040
     41class SVGElement;
     42
    4143class PathOperation : public RefCounted<PathOperation> {
    4244public:
     
    6769class ReferencePathOperation final : public PathOperation {
    6870public:
    69     static Ref<ReferencePathOperation> create(const String& url, const String& fragment)
    70     {
    71         return adoptRef(*new ReferencePathOperation(url, fragment));
    72     }
    73 
     71    static Ref<ReferencePathOperation> create(const String& url, const String& fragment, const RefPtr<SVGElement>);
    7472    const String& url() const { return m_url; }
    7573    const String& fragment() const { return m_fragment; }
     74    const SVGElement* element() const;
    7675
    7776private:
     
    8483    }
    8584
    86     ReferencePathOperation(const String& url, const String& fragment)
    87         : PathOperation(Reference)
    88         , m_url(url)
    89         , m_fragment(fragment)
    90     {
    91     }
     85    ReferencePathOperation(const String& url, const String& fragment, const RefPtr<SVGElement>);
    9286
    9387    String m_url;
    9488    String m_fragment;
     89    RefPtr<SVGElement> m_element;
    9590};
    9691
     
    143138        return path;
    144139    }
     140   
     141    void setPathForReferenceRect(const FloatRoundedRect& boundingRect)
     142    {
     143        m_path.clear();
     144        m_path.addRoundedRect(boundingRect);
     145    }
     146   
     147    const Path getPath() const { return m_path; }
    145148    CSSBoxType referenceBox() const { return m_referenceBox; }
    146149
     
    159162    {
    160163    }
    161 
     164    Path m_path;
    162165    CSSBoxType m_referenceBox;
    163166};
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r292364 r292382  
    13351335        // FIXME: [LBSE] Upstream reference box computation for RenderSVGModelObject derived renderers
    13361336        FloatRect referenceBox;
    1337         if (is<RenderBox>(renderer()))
     1337        if (is<RenderBox>(renderer())) {
    13381338            referenceBox = snapRectToDevicePixels(downcast<RenderBox>(renderer()).referenceBox(transformBoxToCSSBoxType(renderer().style().transformBox())), renderer().document().deviceScaleFactor());
     1339            if (auto pathOperation = renderer().style().offsetPath()) {
     1340                if (is<BoxPathOperation>(pathOperation)) {
     1341                    auto boxPathOperation = downcast<BoxPathOperation>(pathOperation);
     1342                    boxPathOperation->setPathForReferenceRect(FloatRoundedRect(snapRectToDevicePixels(downcast<RenderBox>(renderer()).referenceBox(boxPathOperation->referenceBox()), renderer().document().deviceScaleFactor())));
     1343                }
     1344            }
     1345        }
    13391346
    13401347        renderer().applyTransform(*m_transform, referenceBox);
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r291946 r292382  
    4242#include "RenderObject.h"
    4343#include "RenderTheme.h"
     44#include "SVGPathData.h"
    4445#include "ScaleTransformOperation.h"
    4546#include "ShadowData.h"
     
    15241525static std::optional<Path> getPathFromPathOperation(const FloatRect& box, const PathOperation& operation)
    15251526{
    1526     if (operation.type() == PathOperation::Shape)
     1527    switch (operation.type()) {
     1528    case PathOperation::Shape:
    15271529        return downcast<ShapePathOperation>(operation).pathForReferenceRect(box);
    1528 
    1529     // FIXME: support Reference and Box type.
    1530     // https://bugs.webkit.org/show_bug.cgi?id=233382
    1531     return std::nullopt;
     1530    case PathOperation::Reference:
     1531        if (!is<SVGPathElement>(downcast<ReferencePathOperation>(operation).element()) && !is<SVGGeometryElement>(downcast<ReferencePathOperation>(operation).element()))
     1532            return std::nullopt;
     1533        return pathFromGraphicsElement(downcast<ReferencePathOperation>(operation).element());
     1534    case PathOperation::Box:
     1535        return downcast<BoxPathOperation>(operation).getPath();
     1536    case PathOperation::Ray:
     1537        // FIXME: implement ray- https://bugs.webkit.org/show_bug.cgi?id=233344
     1538        return std::nullopt;
     1539    }
    15321540}
    15331541
  • trunk/Source/WebCore/style/StyleBuilderConverter.h

    r291956 r292382  
    5656#include "QuotesData.h"
    5757#include "RuntimeEnabledFeatures.h"
     58#include "SVGElementTypeHelpers.h"
     59#include "SVGPathElement.h"
    5860#include "SVGURIReference.h"
    5961#include "Settings.h"
     
    634636            String fragment = SVGURIReference::fragmentIdentifierFromIRIString(cssURLValue, builderState.document());
    635637            // FIXME: It doesn't work with external SVG references (see https://bugs.webkit.org/show_bug.cgi?id=126133)
    636             return ReferencePathOperation::create(cssURLValue, fragment);
     638            auto target = SVGURIReference::targetElementFromIRIString(cssURLValue, builderState.document());
     639            return ReferencePathOperation::create(cssURLValue, fragment, downcast<SVGElement>(target.element.get()));
    637640        }
    638641        ASSERT(primitiveValue.valueID() == CSSValueNone);
Note: See TracChangeset for help on using the changeset viewer.