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/CSSComputedStyleDeclaration.cpp

    r284876 r285343  
    14551455
    14561456    return valueForPosition(style, position);
     1457}
     1458
     1459static Ref<CSSValue> valueForPathOperation(const RenderStyle& style, const PathOperation* operation, SVGPathConversion conversion = SVGPathConversion::None)
     1460{
     1461    auto& cssValuePool = CSSValuePool::singleton();
     1462
     1463    if (!operation)
     1464        return cssValuePool.createIdentifierValue(CSSValueNone);
     1465
     1466    if (is<ReferencePathOperation>(*operation))
     1467        return CSSPrimitiveValue::create(downcast<ReferencePathOperation>(*operation).url(), CSSUnitType::CSS_URI);
     1468
     1469    auto list = CSSValueList::createSpaceSeparated();
     1470    if (is<ShapePathOperation>(*operation)) {
     1471        auto& shapeOperation = downcast<ShapePathOperation>(*operation);
     1472        list->append(valueForBasicShape(style, shapeOperation.basicShape(), conversion));
     1473        if (shapeOperation.referenceBox() != CSSBoxType::BoxMissing)
     1474            list->append(cssValuePool.createValue(shapeOperation.referenceBox()));
     1475    }
     1476
     1477    if (is<BoxPathOperation>(*operation))
     1478        list->append(cssValuePool.createValue(downcast<BoxPathOperation>(*operation).referenceBox()));
     1479
     1480    return list;
    14571481}
    14581482
     
    31803204        case CSSPropertyObjectPosition:
    31813205            return valueForPosition(style, style.objectPosition());
     3206        case CSSPropertyOffsetPath:
     3207            // The computed value of offset-path must only contain absolute draw commands.
     3208            // https://github.com/w3c/fxtf-drafts/issues/225#issuecomment-334322738
     3209            return valueForPathOperation(style, style.offsetPath(), SVGPathConversion::ForceAbsolute);
    31823210        case CSSPropertyOffsetDistance:
    31833211            return cssValuePool.createValue(style.offsetDistance(), style);
     
    37903818        case CSSPropertyCounterReset:
    37913819            return counterToCSSValue(style, propertyID);
    3792         case CSSPropertyClipPath: {
    3793             auto* operation = style.clipPath();
    3794             if (!operation)
    3795                 return cssValuePool.createIdentifierValue(CSSValueNone);
    3796             if (is<ReferencePathOperation>(*operation))
    3797                 return CSSPrimitiveValue::create(downcast<ReferencePathOperation>(*operation).url(), CSSUnitType::CSS_URI);
    3798             auto list = CSSValueList::createSpaceSeparated();
    3799             if (is<ShapePathOperation>(*operation)) {
    3800                 auto& shapeOperation = downcast<ShapePathOperation>(*operation);
    3801                 list->append(valueForBasicShape(style, shapeOperation.basicShape()));
    3802                 if (shapeOperation.referenceBox() != CSSBoxType::BoxMissing)
    3803                     list->append(cssValuePool.createValue(shapeOperation.referenceBox()));
    3804             }
    3805             if (is<BoxPathOperation>(*operation))
    3806                 list->append(cssValuePool.createValue(downcast<BoxPathOperation>(*operation).referenceBox()));
    3807             return list;
    3808         }
     3820        case CSSPropertyClipPath:
     3821            return valueForPathOperation(style, style.clipPath());
    38093822        case CSSPropertyShapeMargin:
    38103823            return cssValuePool.createValue(style.shapeMargin(), style);
Note: See TracChangeset for help on using the changeset viewer.