Ignore:
Timestamp:
Nov 19, 2021, 4:56:18 PM (3 years ago)
Author:
[email protected]
Message:

Implement parsing and animation support for ray() shape accepted by offset-path
https://bugs.webkit.org/show_bug.cgi?id=233153

Patch by Kiet Ho <Kiet Ho> on 2021-11-19
Reviewed by Dean Jackson.

LayoutTests/imported/w3c:

Rebaselined tests that now should pass.

  • web-platform-tests/css/motion/animation/offset-path-composition-expected.txt:
  • web-platform-tests/css/motion/animation/offset-path-interpolation-005-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-computed.html:
  • web-platform-tests/css/motion/parsing/offset-path-parsing-valid-expected.txt:

Source/WebCore:

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

imported/w3c/web-platform-tests/css/motion/animation/offset-path-interpolation-005.html
imported/w3c/web-platform-tests/css/motion/offset-supports-calc.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::blendFunc): Added support for blending between ray()s.

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::valueIDForRaySize):
(WebCore::valueForPathOperation): Added support for getting the computed value of ray().

  • css/CSSRayValue.cpp: Added.

(WebCore::CSSRayValue::customCSSText const):
(WebCore::CSSRayValue::equals const):

  • css/CSSRayValue.h: Added.
  • css/CSSValue.cpp:

(WebCore::CSSValue::equals const):
(WebCore::CSSValue::cssText const):
(WebCore::CSSValue::destroy):

  • css/CSSValue.h:

(WebCore::CSSValue::isRayValue const):

  • css/CSSValueKeywords.in: Added new keywords used by ray().
  • css/parser/CSSPropertyParser.cpp:

(WebCore::consumeRayShape): Added method to consume ray().
(WebCore::consumePathOperation): Added a switch to control whether to accept
ray() or not. Both clip-path and offset-path uses this function, however clip-path
doesn't support the ray shape, while offset-path does, hence the switch.
(WebCore::CSSPropertyParser::parseSingleValue):

  • rendering/PathOperation.h: Added a new subclass of PathOperation called RayPathOperation

to represent ray().

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::hitTestClipPath const):

  • style/StyleBuilderConverter.h:

(WebCore::Style::BuilderConverter::convertPathOperation): Added support for converting CSSRayValue
to RayPathOperation.

File:
1 edited

Legend:

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

    r285904 r286086  
    4242#include "CSSPropertyNames.h"
    4343#include "CSSPropertyParser.h"
     44#include "CSSRayValue.h"
    4445#include "CSSReflectValue.h"
    4546#include "CSSSelector.h"
     
    14571458}
    14581459
     1460static CSSValueID valueIDForRaySize(RayPathOperation::Size size)
     1461{
     1462    switch (size) {
     1463    case RayPathOperation::Size::ClosestCorner:
     1464        return CSSValueClosestCorner;
     1465    case RayPathOperation::Size::ClosestSide:
     1466        return CSSValueClosestSide;
     1467    case RayPathOperation::Size::FarthestCorner:
     1468        return CSSValueFarthestCorner;
     1469    case RayPathOperation::Size::FarthestSide:
     1470        return CSSValueFarthestSide;
     1471    case RayPathOperation::Size::Sides:
     1472        return CSSValueSides;
     1473    }
     1474
     1475    ASSERT_NOT_REACHED();
     1476    return CSSValueInvalid;
     1477}
     1478
    14591479static Ref<CSSValue> valueForPathOperation(const RenderStyle& style, const PathOperation* operation, SVGPathConversion conversion = SVGPathConversion::None)
    14601480{
     
    14641484        return cssValuePool.createIdentifierValue(CSSValueNone);
    14651485
    1466     if (is<ReferencePathOperation>(*operation))
     1486    switch (operation->type()) {
     1487    case PathOperation::Reference:
    14671488        return CSSPrimitiveValue::create(downcast<ReferencePathOperation>(*operation).url(), CSSUnitType::CSS_URI);
    14681489
    1469     auto list = CSSValueList::createSpaceSeparated();
    1470     if (is<ShapePathOperation>(*operation)) {
     1490    case PathOperation::Shape: {
     1491        auto list = CSSValueList::createSpaceSeparated();
     1492
    14711493        auto& shapeOperation = downcast<ShapePathOperation>(*operation);
    14721494        list->append(valueForBasicShape(style, shapeOperation.basicShape(), conversion));
     1495
    14731496        if (shapeOperation.referenceBox() != CSSBoxType::BoxMissing)
    14741497            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;
     1498
     1499        return list;
     1500    }
     1501
     1502    case PathOperation::Box:
     1503        return cssValuePool.createValue(downcast<BoxPathOperation>(*operation).referenceBox());
     1504
     1505    case PathOperation::Ray: {
     1506        auto& ray = downcast<RayPathOperation>(*operation);
     1507
     1508        auto angle = cssValuePool.createValue(ray.angle(), CSSUnitType::CSS_DEG);
     1509        auto size = cssValuePool.createIdentifierValue(valueIDForRaySize(ray.size()));
     1510
     1511        return CSSRayValue::create(WTFMove(angle), WTFMove(size), ray.isContaining());
     1512    }
     1513    }
     1514
     1515    ASSERT_NOT_REACHED();
     1516    return cssValuePool.createIdentifierValue(CSSValueNone);
    14811517}
    14821518
Note: See TracChangeset for help on using the changeset viewer.