diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp')
-rw-r--r-- | Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp | 92 |
1 files changed, 42 insertions, 50 deletions
diff --git a/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp b/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp index a204cb96b..8217efb94 100644 --- a/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp +++ b/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp @@ -19,19 +19,18 @@ */ #include "config.h" - -#if ENABLE(SVG) #include "CSSComputedStyleDeclaration.h" #include "CSSPrimitiveValueMappings.h" #include "CSSPropertyNames.h" +#include "CSSValueList.h" #include "Document.h" +#include "Element.h" #include "RenderStyle.h" -#include "SVGPaint.h" namespace WebCore { -static PassRefPtr<CSSPrimitiveValue> glyphOrientationToCSSPrimitiveValue(EGlyphOrientation orientation) +static RefPtr<CSSPrimitiveValue> glyphOrientationToCSSPrimitiveValue(EGlyphOrientation orientation) { switch (orientation) { case GO_0DEG: @@ -43,44 +42,55 @@ static PassRefPtr<CSSPrimitiveValue> glyphOrientationToCSSPrimitiveValue(EGlyphO case GO_270DEG: return CSSPrimitiveValue::create(270.0f, CSSPrimitiveValue::CSS_DEG); default: - return 0; + return nullptr; } } -static PassRefPtr<CSSValue> strokeDashArrayToCSSValueList(const Vector<SVGLength>& dashes) +static RefPtr<CSSValue> strokeDashArrayToCSSValueList(const Vector<SVGLengthValue>& dashes) { if (dashes.isEmpty()) return CSSPrimitiveValue::createIdentifier(CSSValueNone); - RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); - const Vector<SVGLength>::const_iterator end = dashes.end(); - for (Vector<SVGLength>::const_iterator it = dashes.begin(); it != end; ++it) - list->append(SVGLength::toCSSPrimitiveValue(*it)); + auto list = CSSValueList::createCommaSeparated(); + for (auto& length : dashes) + list->append(SVGLengthValue::toCSSPrimitiveValue(length)); - return list.release(); + return WTFMove(list); } -PassRefPtr<SVGPaint> ComputedStyleExtractor::adjustSVGPaintForCurrentColor(PassRefPtr<SVGPaint> newPaint, RenderStyle* style) const +RefPtr<CSSValue> ComputedStyleExtractor::adjustSVGPaintForCurrentColor(SVGPaintType paintType, const String& url, const Color& color, const Color& currentColor) const { - RefPtr<SVGPaint> paint = newPaint; - if (paint->paintType() == SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR || paint->paintType() == SVGPaint::SVG_PAINTTYPE_URI_CURRENTCOLOR) - paint->setColor(style->color()); - return paint.release(); + if (paintType >= SVG_PAINTTYPE_URI_NONE) { + RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated(); + values->append(CSSPrimitiveValue::create(url, CSSPrimitiveValue::UnitType::CSS_URI)); + if (paintType == SVG_PAINTTYPE_URI_NONE) + values->append(CSSPrimitiveValue::createIdentifier(CSSValueNone)); + else if (paintType == SVG_PAINTTYPE_URI_CURRENTCOLOR) + values->append(CSSPrimitiveValue::create(currentColor)); + else if (paintType == SVG_PAINTTYPE_URI_RGBCOLOR) + values->append(CSSPrimitiveValue::create(color)); + return values; + } + if (paintType == SVG_PAINTTYPE_NONE) + return CSSPrimitiveValue::createIdentifier(CSSValueNone); + if (paintType == SVG_PAINTTYPE_CURRENTCOLOR) + return CSSPrimitiveValue::create(currentColor); + + return CSSPrimitiveValue::create(color); } -PassRefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const +RefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) { - Node* node = m_node.get(); - if (!node) - return 0; + if (!m_element) + return nullptr; // Make sure our layout is up to date before we allow a query on these attributes. if (updateLayout) - node->document().updateLayout(); + m_element->document().updateLayout(); - RenderStyle* style = node->computedStyle(); + auto* style = m_element->computedStyle(); if (!style) - return 0; + return nullptr; const SVGRenderStyle& svgStyle = style->svgStyle(); @@ -103,10 +113,6 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID prop return CSSPrimitiveValue::create(svgStyle.colorRendering()); case CSSPropertyShapeRendering: return CSSPrimitiveValue::create(svgStyle.shapeRendering()); - case CSSPropertyStrokeLinecap: - return CSSPrimitiveValue::create(svgStyle.capStyle()); - case CSSPropertyStrokeLinejoin: - return CSSPrimitiveValue::create(svgStyle.joinStyle()); case CSSPropertyStrokeMiterlimit: return CSSPrimitiveValue::create(svgStyle.strokeMiterLimit(), CSSPrimitiveValue::CSS_NUMBER); case CSSPropertyStrokeOpacity: @@ -117,8 +123,6 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID prop return CSSPrimitiveValue::create(svgStyle.dominantBaseline()); case CSSPropertyTextAnchor: return CSSPrimitiveValue::create(svgStyle.textAnchor()); - case CSSPropertyWritingMode: - return CSSPrimitiveValue::create(svgStyle.writingMode()); case CSSPropertyClipPath: if (!svgStyle.clipperResource().isEmpty()) return CSSPrimitiveValue::create(svgStyle.clipperResource(), CSSPrimitiveValue::CSS_URI); @@ -127,10 +131,6 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID prop if (!svgStyle.maskerResource().isEmpty()) return CSSPrimitiveValue::create(svgStyle.maskerResource(), CSSPrimitiveValue::CSS_URI); return CSSPrimitiveValue::createIdentifier(CSSValueNone); - case CSSPropertyFilter: - if (!svgStyle.filterResource().isEmpty()) - return CSSPrimitiveValue::create(svgStyle.filterResource(), CSSPrimitiveValue::CSS_URI); - return CSSPrimitiveValue::createIdentifier(CSSValueNone); case CSSPropertyFloodColor: return currentColorOrValidColor(style, svgStyle.floodColor()); case CSSPropertyLightingColor: @@ -138,9 +138,9 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID prop case CSSPropertyStopColor: return currentColorOrValidColor(style, svgStyle.stopColor()); case CSSPropertyFill: - return adjustSVGPaintForCurrentColor(SVGPaint::create(svgStyle.fillPaintType(), svgStyle.fillPaintUri(), svgStyle.fillPaintColor()), style); + return adjustSVGPaintForCurrentColor(svgStyle.fillPaintType(), svgStyle.fillPaintUri(), svgStyle.fillPaintColor(), style->color()); case CSSPropertyKerning: - return SVGLength::toCSSPrimitiveValue(svgStyle.kerning()); + return SVGLengthValue::toCSSPrimitiveValue(svgStyle.kerning()); case CSSPropertyMarkerEnd: if (!svgStyle.markerEndResource().isEmpty()) return CSSPrimitiveValue::create(svgStyle.markerEndResource(), CSSPrimitiveValue::CSS_URI); @@ -154,13 +154,9 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID prop return CSSPrimitiveValue::create(svgStyle.markerStartResource(), CSSPrimitiveValue::CSS_URI); return CSSPrimitiveValue::createIdentifier(CSSValueNone); case CSSPropertyStroke: - return adjustSVGPaintForCurrentColor(SVGPaint::create(svgStyle.strokePaintType(), svgStyle.strokePaintUri(), svgStyle.strokePaintColor()), style); + return adjustSVGPaintForCurrentColor(svgStyle.strokePaintType(), svgStyle.strokePaintUri(), svgStyle.strokePaintColor(), style->color()); case CSSPropertyStrokeDasharray: return strokeDashArrayToCSSValueList(svgStyle.strokeDashArray()); - case CSSPropertyStrokeDashoffset: - return SVGLength::toCSSPrimitiveValue(svgStyle.strokeDashOffset()); - case CSSPropertyStrokeWidth: - return SVGLength::toCSSPrimitiveValue(svgStyle.strokeWidth()); case CSSPropertyBaselineShift: { switch (svgStyle.baselineShift()) { case BS_BASELINE: @@ -170,10 +166,10 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID prop case BS_SUB: return CSSPrimitiveValue::createIdentifier(CSSValueSub); case BS_LENGTH: - return SVGLength::toCSSPrimitiveValue(svgStyle.baselineShiftValue()); + return SVGLengthValue::toCSSPrimitiveValue(svgStyle.baselineShiftValue()); } ASSERT_NOT_REACHED(); - return 0; + return nullptr; } case CSSPropertyBufferedRendering: return CSSPrimitiveValue::create(svgStyle.bufferedRendering()); @@ -181,15 +177,15 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID prop return glyphOrientationToCSSPrimitiveValue(svgStyle.glyphOrientationHorizontal()); case CSSPropertyGlyphOrientationVertical: { if (RefPtr<CSSPrimitiveValue> value = glyphOrientationToCSSPrimitiveValue(svgStyle.glyphOrientationVertical())) - return value.release(); + return value; if (svgStyle.glyphOrientationVertical() == GO_AUTO) return CSSPrimitiveValue::createIdentifier(CSSValueAuto); - return 0; + return nullptr; } case CSSPropertyWebkitSvgShadow: - return valueForShadow(svgStyle.shadow(), propertyID, style); + return valueForShadow(svgStyle.shadow(), propertyID, *style); case CSSPropertyVectorEffect: return CSSPrimitiveValue::create(svgStyle.vectorEffect()); case CSSPropertyMaskType: @@ -205,11 +201,7 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID prop ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propertyID); } LOG_ERROR("unimplemented propertyID: %d", propertyID); - return 0; + return nullptr; } } - -#endif // ENABLE(SVG) - -// vim:ts=4:noet |