Ignore:
Timestamp:
Nov 5, 2021, 10:18:00 AM (4 years ago)
Author:
[email protected]
Message:

Implement parsing and animation support for offset-path
https://bugs.webkit.org/show_bug.cgi?id=231801

Patch by Kiet Ho <Kiet Ho> on 2021-11-05
Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

Updated relevant test expectations.

  • web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
  • web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt:
  • web-platform-tests/css/cssom/getComputedStyle-detached-subtree-expected.txt:
  • web-platform-tests/css/motion/animation/offset-path-interpolation-001-expected.txt:
  • web-platform-tests/css/motion/animation/offset-path-interpolation-002-expected.txt:
  • web-platform-tests/css/motion/animation/offset-path-interpolation-003-expected.txt:
  • web-platform-tests/css/motion/animation/offset-path-interpolation-004-expected.txt:
  • web-platform-tests/css/motion/animation/offset-path-interpolation-005-expected.txt:
  • web-platform-tests/css/motion/inheritance-expected.txt:
  • web-platform-tests/css/motion/offset-path-serialization-expected.txt:
  • web-platform-tests/css/motion/offset-supports-calc-expected.txt:
  • web-platform-tests/css/motion/parsing/offset-path-computed-expected.txt:
  • web-platform-tests/css/motion/parsing/offset-path-parsing-valid-expected.txt:
  • web-platform-tests/css/motion/parsing/offset-shorthand-expected.txt:

Source/WebCore:

Implements parsing and animation support for offset-path based on clip-path.
offset-path additionally supports ray() shape, which will be implemented in a future patch.

Tests: imported/w3c/web-platform-tests/css/motion/inheritance.html

imported/w3c/web-platform-tests/css/motion/offset-path-serialization.html
imported/w3c/web-platform-tests/css/motion/animation/offset-path-interpolation-001.html
imported/w3c/web-platform-tests/css/motion/animation/offset-path-interpolation-002.html
imported/w3c/web-platform-tests/css/motion/animation/offset-path-interpolation-003.html
imported/w3c/web-platform-tests/css/motion/animation/offset-path-interpolation-004.html
imported/w3c/web-platform-tests/css/motion/animation/offset-path-interpolation-005.html
imported/w3c/web-platform-tests/css/motion/parsing/offset-path-computed.html
imported/w3c/web-platform-tests/css/motion/parsing/offset-path-parsing-invalid.html
imported/w3c/web-platform-tests/css/motion/parsing/offset-path-parsing-valid.html

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • animation/CSSPropertyAnimation.cpp:

(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
Added animation support for offset-path.

  • css/BasicShapeFunctions.cpp:

(WebCore::copySVGPathByteStream):
(WebCore::valueForBasicShape): Added enum to specify conversions done on the
resulting SVG path. So far, the only available conversion is converting relative
draw commands in a path to absolute. This is required when getting the computed value of
offset-path.

  • css/BasicShapeFunctions.h:
  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::valueForPathOperation): Moved logic to get value of PathOperation
into a separate method.
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle): Added support for
offset-path.

  • css/CSSProperties.json: Added entry for offset-path.
  • css/parser/CSSPropertyParser.cpp:

(WebCore::consumePathOperation): Renamed from consumeClipPath.
(WebCore::CSSPropertyParser::parseSingleValue): Added support for parsing offset-path.

  • rendering/style/RenderStyle.h: Added support for offset-path.

(WebCore::RenderStyle::offsetPath const):
(WebCore::RenderStyle::setOffsetPath):
(WebCore::RenderStyle::initialOffsetPath):

  • rendering/style/StyleRareNonInheritedData.cpp:

(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
(WebCore::StyleRareNonInheritedData::operator== const):

  • rendering/style/StyleRareNonInheritedData.h: Added storage space for offset-path.
  • style/StyleBuilderConverter.h:

(WebCore::Style::BuilderConverter::convertPathOperation): Renamed from convertClipPath

  • svg/SVGPathAbsoluteConverter.cpp: Added helper class to convert relative draw

commands in an SVG path to absolute.
(WebCore::SVGPathAbsoluteConverter::SVGPathAbsoluteConverter):
(WebCore::SVGPathAbsoluteConverter::incrementPathSegmentCount):
(WebCore::SVGPathAbsoluteConverter::continueConsuming):
(WebCore::SVGPathAbsoluteConverter::moveTo):
(WebCore::SVGPathAbsoluteConverter::lineTo):
(WebCore::SVGPathAbsoluteConverter::curveToCubic):
(WebCore::SVGPathAbsoluteConverter::closePath):
(WebCore::SVGPathAbsoluteConverter::lineToHorizontal):
(WebCore::SVGPathAbsoluteConverter::lineToVertical):
(WebCore::SVGPathAbsoluteConverter::curveToCubicSmooth):
(WebCore::SVGPathAbsoluteConverter::curveToQuadratic):
(WebCore::SVGPathAbsoluteConverter::curveToQuadraticSmooth):
(WebCore::SVGPathAbsoluteConverter::arcTo):

  • svg/SVGPathAbsoluteConverter.h: Added.
  • svg/SVGPathUtilities.cpp:

(WebCore::convertSVGPathByteStreamToAbsoluteCoordinates):

  • svg/SVGPathUtilities.h:

LayoutTests:

Updated relevant test expectations.

  • platform/gtk/imported/w3c/web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt:
  • platform/ios-wk2/imported/w3c/web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt:
  • platform/ios/imported/w3c/web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt:
  • platform/ios/imported/w3c/web-platform-tests/css/cssom/getComputedStyle-detached-subtree-expected.txt:
  • platform/wpe/imported/w3c/web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt:
  • platform/wpe/imported/w3c/web-platform-tests/css/cssom/getComputedStyle-detached-subtree-expected.txt:
File:
1 edited

Legend:

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

    r272805 r285343  
    6666}
    6767
    68 Ref<CSSPrimitiveValue> valueForBasicShape(const RenderStyle& style, const BasicShape& basicShape)
     68static std::unique_ptr<SVGPathByteStream> copySVGPathByteStream(const SVGPathByteStream& source, SVGPathConversion conversion)
     69{
     70    switch (conversion) {
     71    case SVGPathConversion::None:
     72        return source.copy();
     73
     74    case SVGPathConversion::ForceAbsolute:
     75        // Only returns the resulting absolute path if the conversion succeeds.
     76        if (auto result = convertSVGPathByteStreamToAbsoluteCoordinates(source))
     77            return result;
     78
     79        return source.copy();
     80    }
     81
     82    ASSERT_NOT_REACHED();
     83    return source.copy();
     84}
     85
     86Ref<CSSPrimitiveValue> valueForBasicShape(const RenderStyle& style, const BasicShape& basicShape, SVGPathConversion conversion)
    6987{
    7088    auto& cssValuePool = CSSValuePool::singleton();
     
    109127    case BasicShape::Type::Path: {
    110128        auto& pathShape = downcast<BasicShapePath>(basicShape);
    111         auto pathShapeValue = CSSBasicShapePath::create(pathShape.pathData()->copy());
     129
     130        ASSERT(pathShape.pathData());
     131        auto pathByteStream = copySVGPathByteStream(*pathShape.pathData(), conversion);
     132
     133        auto pathShapeValue = CSSBasicShapePath::create(WTFMove(pathByteStream));
    112134        pathShapeValue->setWindRule(pathShape.windRule());
    113135
    114136        basicShapeValue = WTFMove(pathShapeValue);
     137
    115138        break;
    116139    }
Note: See TracChangeset for help on using the changeset viewer.