source: webkit/trunk/Source/WebCore/css/BasicShapeFunctions.h

Last change on this file was 285343, checked in by [email protected], 4 years ago

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 size: 2.0 KB
Line 
1/*
2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer.
11 * 2. Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following
13 * disclaimer in the documentation and/or other materials
14 * provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#pragma once
31
32#include <wtf/Ref.h>
33
34namespace WebCore {
35
36class BasicShape;
37class BasicShapeCenterCoordinate;
38class CSSBasicShape;
39class CSSToLengthConversionData;
40class CSSPrimitiveValue;
41class RenderStyle;
42
43// Specifies a conversion done to an SVG path.
44enum class SVGPathConversion : uint8_t {
45 None,
46 ForceAbsolute
47};
48
49Ref<CSSPrimitiveValue> valueForBasicShape(const RenderStyle&, const BasicShape&, SVGPathConversion = SVGPathConversion::None);
50Ref<BasicShape> basicShapeForValue(const CSSToLengthConversionData&, const CSSBasicShape&, float zoom = 1);
51float floatValueForCenterCoordinate(const BasicShapeCenterCoordinate&, float);
52
53}
Note: See TracBrowser for help on using the repository browser.