source: webkit/trunk/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp

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

Unprefix -webkit-mask
https://bugs.webkit.org/show_bug.cgi?id=229082

Patch by Matt Woodrow <[email protected]> on 2021-12-09
Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

  • web-platform-tests/css/css-masking/animations/mask-image-interpolation-expected.txt:
  • web-platform-tests/css/css-masking/animations/mask-position-interpolation-expected.txt:
  • web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-expected.html:
  • web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-filter-expected.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-expected.html.
  • web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-filter.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation.html.
  • web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-incompatible-shapes1-expected.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-expected.html.
  • web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-incompatible-shapes1.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation.html.
  • web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-incompatible-shapes2-expected.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-expected.html.
  • web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-incompatible-shapes2.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation.html.
  • web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-overflow-expected.html: Added.
  • web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-overflow.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation.html.
  • web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-three-keyframes1-expected.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-expected.html.
  • web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-three-keyframes1.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation.html.
  • web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-three-keyframes2-expected.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-expected.html.
  • web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-three-keyframes2.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation.html.
  • web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation.html:
  • web-platform-tests/css/css-masking/clip-path/animations/clip-path-transition-expected.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-expected.html.
  • web-platform-tests/css/css-masking/clip-path/animations/clip-path-transition.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation.html.
  • web-platform-tests/css/css-masking/clip-path/animations/w3c-import.log:
  • web-platform-tests/css/css-masking/clip-path/clip-path-columns-shape-002.html:
  • web-platform-tests/css/css-masking/clip-path/clip-path-descendant-text-mutated-001.html:
  • web-platform-tests/css/css-masking/clip-path/clip-path-element-userSpaceOnUse-001.html:
  • web-platform-tests/css/css-masking/clip-path/clip-path-element-userSpaceOnUse-002.html:
  • web-platform-tests/css/css-masking/clip-path/clip-path-element-userSpaceOnUse-003.html:
  • web-platform-tests/css/css-masking/clip-path/clip-path-element-userSpaceOnUse-004.html:
  • web-platform-tests/css/css-masking/clip-path/clip-path-fixed-scroll-expected.html: Added.
  • web-platform-tests/css/css-masking/clip-path/clip-path-fixed-scroll.html: Added.
  • web-platform-tests/css/css-masking/clip-path/clip-path-path-001-expected.html:
  • web-platform-tests/css/css-masking/clip-path/clip-path-path-002-expected.html:
  • web-platform-tests/css/css-masking/clip-path/clip-path-path-interpolation-001-expected.html:
  • web-platform-tests/css/css-masking/clip-path/clip-path-path-interpolation-002-expected.html:
  • web-platform-tests/css/css-masking/clip-path/clip-path-reference-restore.html:
  • web-platform-tests/css/css-masking/clip-path/clip-path-svg-invalidate-expected.html:
  • web-platform-tests/css/css-masking/clip-path/clip-path-svg-invalidate.html:
  • web-platform-tests/css/css-masking/clip-path/clip-path-svg-text-backdrop-filter.html:
  • web-platform-tests/css/css-masking/clip-path/clip-path-svg-text-font-loading.html:
  • web-platform-tests/css/css-masking/clip-path/clip-path-transform-mutated-001.html:
  • web-platform-tests/css/css-masking/clip-path/clip-path-transform-mutated-002.html:
  • web-platform-tests/css/css-masking/clip-path/clip-path-url-reference-change-from-empty.html:
  • web-platform-tests/css/css-masking/clip-path/clip-path-url-reference-change.html:
  • web-platform-tests/css/css-masking/clip-path/reference-local-url-with-base-001.html:
  • web-platform-tests/css/css-masking/clip-path/reference-mutated.html:
  • web-platform-tests/css/css-masking/clip-path/reference-nonexisting-existing-local.html:
  • web-platform-tests/css/css-masking/clip-path/w3c-import.log:
  • web-platform-tests/css/css-masking/clip-rule/clip-rule-001.html:
  • web-platform-tests/css/css-masking/clip-rule/clip-rule-002.html:
  • web-platform-tests/css/css-masking/hit-test/clip-path-element-objectboundingbox-001.html:
  • web-platform-tests/css/css-masking/hit-test/clip-path-element-objectboundingbox-002.html:
  • web-platform-tests/css/css-masking/hit-test/clip-path-element-userspaceonuse-001.html:
  • web-platform-tests/css/css-masking/idlharness.html:
  • web-platform-tests/css/css-masking/inheritance.sub-expected.txt:
  • web-platform-tests/css/css-masking/parsing/mask-position-valid-expected.txt:
  • web-platform-tests/css/css-masking/parsing/mask-valid.sub-expected.txt:

Source/WebCore:

Tests: fast/masking/parsing-webkit-mask.html

imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-filter.html
imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-incompatible-shapes1.html
imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-incompatible-shapes2.html
imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-overflow.html
imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-three-keyframes1.html
imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-animation-three-keyframes2.html
imported/w3c/web-platform-tests/css/css-masking/clip-path/animations/clip-path-transition.html
imported/w3c/web-platform-tests/css/css-masking/clip-path/clip-path-fixed-scroll.html
svg/masking/mask-external-reference-expected.svg
svg/masking/mask-external-reference.svg

  • animation/CSSPropertyAnimation.cpp:

(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::createPositionListForLayer):
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):

  • css/CSSImageValue.cpp:

(WebCore::ResolvedURL::isLocalURL const):
(WebCore::CSSImageValue::reresolvedURL const):

  • css/CSSImageValue.h:
  • css/CSSPrimitiveValue.h:

(WebCore::CSSPrimitiveValue::create):

  • css/CSSPrimitiveValueMappings.h:

(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator CompositeOperator const):
(WebCore::CSSPrimitiveValue::operator FillBox const):

  • css/CSSProperties.json:
  • css/CSSToStyleMap.cpp:

(WebCore::CSSToStyleMap::mapFillMaskMode):

  • css/CSSValueKeywords.in:
  • css/CSSValuePool.h:

(WebCore::CSSValuePool::createValue):

  • css/SVGCSSComputedStyleDeclaration.cpp:

(WebCore::ComputedStyleExtractor::svgPropertyValue):

  • css/StyleProperties.cpp:

(WebCore::StyleProperties::getPropertyValue const):
(WebCore::resolvedClipValue):
(WebCore::isSameAsInitialClipValue):
(WebCore::StyleProperties::getLayeredShorthandValue const):
(WebCore::StyleProperties::asText const):

  • css/parser/CSSPropertyParser.cpp:

(WebCore::consumeMaskClip):
(WebCore::consumePrefixedBackgroundComposite):
(WebCore::consumeBackgroundComposite):
(WebCore::consumeBackgroundComponent):
(WebCore::CSSPropertyParser::parseSingleValue):
(WebCore::consumeBackgroundPosition):
(WebCore::CSSPropertyParser::consumeBackgroundShorthand):
(WebCore::CSSPropertyParser::parseShorthand):

  • css/parser/CSSPropertyParserHelpers.cpp:

(WebCore::CSSPropertyParserHelpers::consumePositionCoordinates):

  • display/css/DisplayBoxDecorationPainter.cpp:

(WebCore::Display::BoxDecorationPainter::paintFillLayer const):

  • rendering/style/FillLayer.cpp:

(WebCore::clipMax):
(WebCore::FillLayer::computeClipMax const):

  • rendering/style/FillLayer.h:
  • rendering/style/RenderStyle.cpp:

(WebCore::rareNonInheritedDataChangeRequiresLayerRepaint):

  • rendering/style/RenderStyle.h:

(WebCore::RenderStyle::hasPositionedMask const):

  • rendering/style/RenderStyleConstants.cpp:

(WebCore::operator<<):

  • rendering/style/RenderStyleConstants.h:
  • rendering/style/SVGRenderStyle.cpp:

(WebCore::SVGRenderStyle::SVGRenderStyle):
(WebCore::SVGRenderStyle::operator== const):
(WebCore::SVGRenderStyle::copyNonInheritedFrom):
(WebCore::SVGRenderStyle::diff const):

  • rendering/style/SVGRenderStyle.h:

(WebCore::SVGRenderStyle::initialLightingColor):
(WebCore::SVGRenderStyle::y const):
(WebCore::SVGRenderStyle::hasFill const):
(WebCore::SVGRenderStyle::initialMaskerResource): Deleted.
(WebCore::SVGRenderStyle::maskerResource const): Deleted.
(WebCore::SVGRenderStyle::hasMasker const): Deleted.
(WebCore::SVGRenderStyle::isolatesBlending const): Deleted.
(WebCore::SVGRenderStyle::setMaskerResource): Deleted.

  • rendering/style/SVGRenderStyleDefs.cpp:

(WebCore::StyleResourceData::StyleResourceData): Deleted.
(WebCore::StyleResourceData::copy const): Deleted.
(WebCore::StyleResourceData::operator== const): Deleted.

  • rendering/style/SVGRenderStyleDefs.h:

(WebCore::StyleResourceData::create): Deleted.
(WebCore::StyleResourceData::operator!= const): Deleted.

  • rendering/style/StyleCachedImage.cpp:

(WebCore::StyleCachedImage::imageURL const):
(WebCore::StyleCachedImage::reresolvedURL const):
(WebCore::StyleCachedImage::imageURL): Deleted.

  • rendering/style/StyleCachedImage.h:
  • rendering/style/WillChangeData.cpp:

(WebCore::WillChangeData::propertyCreatesStackingContext):

  • rendering/svg/SVGRenderSupport.cpp:

(WebCore::SVGRenderSupport::isolatesBlending):
(WebCore::SVGRenderSupport::updateMaskedAncestorShouldIsolateBlending):

  • rendering/svg/SVGRenderTreeAsText.cpp:

(WebCore::writeResources):

  • rendering/svg/SVGRenderingContext.cpp:

(WebCore::SVGRenderingContext::prepareToRenderSVGContent):

  • rendering/svg/SVGResources.cpp:

(WebCore::SVGResources::buildCachedResources):

LayoutTests:

  • fast/masking/parsing-mask-expected.txt:
  • fast/masking/parsing-mask-mode.html:
  • fast/masking/parsing-mask.html:
  • fast/masking/parsing-webkit-mask-expected.txt: Copied from LayoutTests/fast/masking/parsing-mask-expected.txt.
  • fast/masking/parsing-webkit-mask.html: Copied from LayoutTests/fast/masking/parsing-mask.html.
  • platform/mac/imported/w3c/web-platform-tests/css/css-masking/animations/mask-image-interpolation-expected.png: Added.
  • platform/mac/imported/w3c/web-platform-tests/css/css-masking/parsing/mask-valid.sub-expected.png: Added.
  • svg/masking/mask-external-reference-expected.svg: Added.
  • svg/masking/mask-external-reference.svg: Added.
  • svg/masking/resources/mask-resource.svg: Added.
  • Property svn:eol-style set to native
File size: 8.2 KB
Line 
1/*
2 Copyright (C) 2007 Eric Seidel <[email protected]>
3 Copyright (C) 2007 Alexey Proskuryakov <[email protected]>
4 Copyright (C) 2019 Apple Inc. All rights reserved.
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20 */
21
22#include "config.h"
23#include "CSSComputedStyleDeclaration.h"
24
25#include "CSSPrimitiveValueMappings.h"
26#include "CSSPropertyNames.h"
27#include "CSSValueList.h"
28#include "Document.h"
29#include "Element.h"
30#include "RenderStyle.h"
31
32namespace WebCore {
33
34static RefPtr<CSSPrimitiveValue> glyphOrientationToCSSPrimitiveValue(GlyphOrientation orientation)
35{
36 switch (orientation) {
37 case GlyphOrientation::Degrees0:
38 return CSSPrimitiveValue::create(0.0f, CSSUnitType::CSS_DEG);
39 case GlyphOrientation::Degrees90:
40 return CSSPrimitiveValue::create(90.0f, CSSUnitType::CSS_DEG);
41 case GlyphOrientation::Degrees180:
42 return CSSPrimitiveValue::create(180.0f, CSSUnitType::CSS_DEG);
43 case GlyphOrientation::Degrees270:
44 return CSSPrimitiveValue::create(270.0f, CSSUnitType::CSS_DEG);
45 case GlyphOrientation::Auto:
46 return nullptr;
47 }
48
49 RELEASE_ASSERT_NOT_REACHED();
50}
51
52static Ref<CSSValue> strokeDashArrayToCSSValueList(const Vector<SVGLengthValue>& dashes)
53{
54 if (dashes.isEmpty())
55 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
56
57 auto list = CSSValueList::createCommaSeparated();
58 for (auto& length : dashes)
59 list->append(SVGLengthValue::toCSSPrimitiveValue(length));
60
61 return list;
62}
63
64Ref<CSSValue> ComputedStyleExtractor::adjustSVGPaintForCurrentColor(SVGPaintType paintType, const String& url, const Color& color, const Color& currentColor) const
65{
66 if (paintType >= SVGPaintType::URINone) {
67 auto values = CSSValueList::createSpaceSeparated();
68 values->append(CSSPrimitiveValue::create(url, CSSUnitType::CSS_URI));
69 if (paintType == SVGPaintType::URINone)
70 values->append(CSSPrimitiveValue::createIdentifier(CSSValueNone));
71 else if (paintType == SVGPaintType::URICurrentColor)
72 values->append(CSSPrimitiveValue::create(currentColor));
73 else if (paintType == SVGPaintType::URIRGBColor)
74 values->append(CSSPrimitiveValue::create(color));
75 return values;
76 }
77 if (paintType == SVGPaintType::None)
78 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
79 if (paintType == SVGPaintType::CurrentColor)
80 return CSSPrimitiveValue::create(currentColor);
81
82 return CSSPrimitiveValue::create(color);
83}
84
85RefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID propertyID)
86{
87 if (!m_element)
88 return nullptr;
89
90 auto* style = m_element->computedStyle();
91 if (!style)
92 return nullptr;
93
94 const SVGRenderStyle& svgStyle = style->svgStyle();
95
96 switch (propertyID) {
97 case CSSPropertyClipRule:
98 return CSSPrimitiveValue::create(svgStyle.clipRule());
99 case CSSPropertyFloodOpacity:
100 return CSSPrimitiveValue::create(svgStyle.floodOpacity(), CSSUnitType::CSS_NUMBER);
101 case CSSPropertyStopOpacity:
102 return CSSPrimitiveValue::create(svgStyle.stopOpacity(), CSSUnitType::CSS_NUMBER);
103 case CSSPropertyColorInterpolation:
104 return CSSPrimitiveValue::create(svgStyle.colorInterpolation());
105 case CSSPropertyColorInterpolationFilters:
106 return CSSPrimitiveValue::create(svgStyle.colorInterpolationFilters());
107 case CSSPropertyFillOpacity:
108 return CSSPrimitiveValue::create(svgStyle.fillOpacity(), CSSUnitType::CSS_NUMBER);
109 case CSSPropertyFillRule:
110 return CSSPrimitiveValue::create(svgStyle.fillRule());
111 case CSSPropertyShapeRendering:
112 return CSSPrimitiveValue::create(svgStyle.shapeRendering());
113 case CSSPropertyStrokeOpacity:
114 return CSSPrimitiveValue::create(svgStyle.strokeOpacity(), CSSUnitType::CSS_NUMBER);
115 case CSSPropertyAlignmentBaseline:
116 return CSSPrimitiveValue::create(svgStyle.alignmentBaseline());
117 case CSSPropertyDominantBaseline:
118 return CSSPrimitiveValue::create(svgStyle.dominantBaseline());
119 case CSSPropertyTextAnchor:
120 return CSSPrimitiveValue::create(svgStyle.textAnchor());
121 case CSSPropertyFloodColor:
122 return currentColorOrValidColor(style, svgStyle.floodColor());
123 case CSSPropertyLightingColor:
124 return currentColorOrValidColor(style, svgStyle.lightingColor());
125 case CSSPropertyStopColor:
126 return currentColorOrValidColor(style, svgStyle.stopColor());
127 case CSSPropertyFill:
128 return adjustSVGPaintForCurrentColor(svgStyle.fillPaintType(), svgStyle.fillPaintUri(), svgStyle.fillPaintColor(), style->color());
129 case CSSPropertyKerning:
130 return SVGLengthValue::toCSSPrimitiveValue(svgStyle.kerning());
131 case CSSPropertyMarkerEnd:
132 if (!svgStyle.markerEndResource().isEmpty())
133 return CSSPrimitiveValue::create(makeString('#', svgStyle.markerEndResource()), CSSUnitType::CSS_URI);
134 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
135 case CSSPropertyMarkerMid:
136 if (!svgStyle.markerMidResource().isEmpty())
137 return CSSPrimitiveValue::create(makeString('#', svgStyle.markerMidResource()), CSSUnitType::CSS_URI);
138 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
139 case CSSPropertyMarkerStart:
140 if (!svgStyle.markerStartResource().isEmpty())
141 return CSSPrimitiveValue::create(makeString('#', svgStyle.markerStartResource()), CSSUnitType::CSS_URI);
142 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
143 case CSSPropertyStroke:
144 return adjustSVGPaintForCurrentColor(svgStyle.strokePaintType(), svgStyle.strokePaintUri(), svgStyle.strokePaintColor(), style->color());
145 case CSSPropertyStrokeDasharray:
146 return strokeDashArrayToCSSValueList(svgStyle.strokeDashArray());
147 case CSSPropertyBaselineShift: {
148 switch (svgStyle.baselineShift()) {
149 case BaselineShift::Baseline:
150 return CSSPrimitiveValue::createIdentifier(CSSValueBaseline);
151 case BaselineShift::Super:
152 return CSSPrimitiveValue::createIdentifier(CSSValueSuper);
153 case BaselineShift::Sub:
154 return CSSPrimitiveValue::createIdentifier(CSSValueSub);
155 case BaselineShift::Length:
156 return SVGLengthValue::toCSSPrimitiveValue(svgStyle.baselineShiftValue());
157 }
158 ASSERT_NOT_REACHED();
159 return nullptr;
160 }
161 case CSSPropertyBufferedRendering:
162 return CSSPrimitiveValue::create(svgStyle.bufferedRendering());
163 case CSSPropertyGlyphOrientationHorizontal:
164 return glyphOrientationToCSSPrimitiveValue(svgStyle.glyphOrientationHorizontal());
165 case CSSPropertyGlyphOrientationVertical: {
166 if (RefPtr<CSSPrimitiveValue> value = glyphOrientationToCSSPrimitiveValue(svgStyle.glyphOrientationVertical()))
167 return value;
168
169 if (svgStyle.glyphOrientationVertical() == GlyphOrientation::Auto)
170 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
171
172 return nullptr;
173 }
174 case CSSPropertyVectorEffect:
175 return CSSPrimitiveValue::create(svgStyle.vectorEffect());
176 case CSSPropertyMaskType:
177 return CSSPrimitiveValue::create(svgStyle.maskType());
178 case CSSPropertyMarker:
179 // this property is not yet implemented in the engine
180 break;
181 default:
182 // If you crash here, it's because you added a css property and are not handling it
183 // in either this switch statement or the one in CSSComputedStyleDelcaration::getPropertyCSSValue
184 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propertyID);
185 }
186 return nullptr;
187}
188
189}
Note: See TracBrowser for help on using the repository browser.