diff options
author | Konstantin Tokarev <annulen@yandex.ru> | 2016-08-25 19:20:41 +0300 |
---|---|---|
committer | Konstantin Tokarev <annulen@yandex.ru> | 2017-02-02 12:30:55 +0000 |
commit | 6882a04fb36642862b11efe514251d32070c3d65 (patch) | |
tree | b7959826000b061fd5ccc7512035c7478742f7b0 /Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp | |
parent | ab6df191029eeeb0b0f16f127d553265659f739e (diff) | |
download | qtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz |
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f
Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp')
-rw-r--r-- | Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp | 167 |
1 files changed, 94 insertions, 73 deletions
diff --git a/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp b/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp index 3867145a3..8937a88aa 100644 --- a/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp +++ b/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp @@ -19,8 +19,6 @@ */ #include "config.h" - -#if ENABLE(SVG) #include "CSSComputedStyleDeclaration.h" #include "CSSPrimitiveValueMappings.h" @@ -31,7 +29,42 @@ namespace WebCore { -static PassRefPtr<CSSPrimitiveValue> glyphOrientationToCSSPrimitiveValue(EGlyphOrientation orientation) +static Ref<CSSValue> paintOrder(PaintOrder paintOrder) +{ + Ref<CSSValueList> paintOrderList = CSSValueList::createSpaceSeparated(); + Ref<CSSValue> fill = CSSPrimitiveValue::createIdentifier(CSSValueFill); + Ref<CSSValue> stroke = CSSPrimitiveValue::createIdentifier(CSSValueStroke); + Ref<CSSValue> markers = CSSPrimitiveValue::createIdentifier(CSSValueMarkers); + + switch (paintOrder) { + case PaintOrderNormal: + return CSSPrimitiveValue::createIdentifier(CSSValueNormal); + case PaintOrderFill: + paintOrderList->append(WTFMove(fill)); + break; + case PaintOrderFillMarkers: + paintOrderList->append(WTFMove(fill)); + paintOrderList->append(WTFMove(markers)); + break; + case PaintOrderStroke: + paintOrderList->append(WTFMove(stroke)); + break; + case PaintOrderStrokeMarkers: + paintOrderList->append(WTFMove(stroke)); + paintOrderList->append(WTFMove(markers)); + break; + case PaintOrderMarkers: + paintOrderList->append(WTFMove(markers)); + break; + case PaintOrderMarkersStroke: + paintOrderList->append(WTFMove(markers)); + paintOrderList->append(WTFMove(stroke)); + break; + } + return WTFMove(paintOrderList); +} + +static RefPtr<CSSPrimitiveValue> glyphOrientationToCSSPrimitiveValue(EGlyphOrientation orientation) { switch (orientation) { case GO_0DEG: @@ -43,11 +76,11 @@ 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<SVGLength>& dashes) { if (dashes.isEmpty()) return CSSPrimitiveValue::createIdentifier(CSSValueNone); @@ -57,114 +90,104 @@ static PassRefPtr<CSSValue> strokeDashArrayToCSSValueList(const Vector<SVGLength for (Vector<SVGLength>::const_iterator it = dashes.begin(); it != end; ++it) list->append(SVGLength::toCSSPrimitiveValue(*it)); - return list.release(); + return list; } -PassRefPtr<SVGPaint> ComputedStyleExtractor::adjustSVGPaintForCurrentColor(PassRefPtr<SVGPaint> newPaint, RenderStyle* style) const +RefPtr<SVGPaint> ComputedStyleExtractor::adjustSVGPaintForCurrentColor(PassRefPtr<SVGPaint> newPaint, RenderStyle* style) 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(); + return paint; } -PassRefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const +RefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const { Node* node = m_node.get(); if (!node) - return 0; + return nullptr; // Make sure our layout is up to date before we allow a query on these attributes. if (updateLayout) - node->document()->updateLayout(); + node->document().updateLayout(); RenderStyle* style = node->computedStyle(); if (!style) - return 0; + return nullptr; - const SVGRenderStyle* svgStyle = style->svgStyle(); - if (!svgStyle) - return 0; + const SVGRenderStyle& svgStyle = style->svgStyle(); switch (propertyID) { case CSSPropertyClipRule: - return CSSPrimitiveValue::create(svgStyle->clipRule()); + return CSSPrimitiveValue::create(svgStyle.clipRule()); case CSSPropertyFloodOpacity: - return CSSPrimitiveValue::create(svgStyle->floodOpacity(), CSSPrimitiveValue::CSS_NUMBER); + return CSSPrimitiveValue::create(svgStyle.floodOpacity(), CSSPrimitiveValue::CSS_NUMBER); case CSSPropertyStopOpacity: - return CSSPrimitiveValue::create(svgStyle->stopOpacity(), CSSPrimitiveValue::CSS_NUMBER); + return CSSPrimitiveValue::create(svgStyle.stopOpacity(), CSSPrimitiveValue::CSS_NUMBER); case CSSPropertyColorInterpolation: - return CSSPrimitiveValue::create(svgStyle->colorInterpolation()); + return CSSPrimitiveValue::create(svgStyle.colorInterpolation()); case CSSPropertyColorInterpolationFilters: - return CSSPrimitiveValue::create(svgStyle->colorInterpolationFilters()); + return CSSPrimitiveValue::create(svgStyle.colorInterpolationFilters()); case CSSPropertyFillOpacity: - return CSSPrimitiveValue::create(svgStyle->fillOpacity(), CSSPrimitiveValue::CSS_NUMBER); + return CSSPrimitiveValue::create(svgStyle.fillOpacity(), CSSPrimitiveValue::CSS_NUMBER); case CSSPropertyFillRule: - return CSSPrimitiveValue::create(svgStyle->fillRule()); + return CSSPrimitiveValue::create(svgStyle.fillRule()); case CSSPropertyColorRendering: - return CSSPrimitiveValue::create(svgStyle->colorRendering()); + return CSSPrimitiveValue::create(svgStyle.colorRendering()); case CSSPropertyShapeRendering: - return CSSPrimitiveValue::create(svgStyle->shapeRendering()); + return CSSPrimitiveValue::create(svgStyle.shapeRendering()); case CSSPropertyStrokeLinecap: - return CSSPrimitiveValue::create(svgStyle->capStyle()); + return CSSPrimitiveValue::create(svgStyle.capStyle()); case CSSPropertyStrokeLinejoin: - return CSSPrimitiveValue::create(svgStyle->joinStyle()); + return CSSPrimitiveValue::create(svgStyle.joinStyle()); case CSSPropertyStrokeMiterlimit: - return CSSPrimitiveValue::create(svgStyle->strokeMiterLimit(), CSSPrimitiveValue::CSS_NUMBER); + return CSSPrimitiveValue::create(svgStyle.strokeMiterLimit(), CSSPrimitiveValue::CSS_NUMBER); case CSSPropertyStrokeOpacity: - return CSSPrimitiveValue::create(svgStyle->strokeOpacity(), CSSPrimitiveValue::CSS_NUMBER); + return CSSPrimitiveValue::create(svgStyle.strokeOpacity(), CSSPrimitiveValue::CSS_NUMBER); case CSSPropertyAlignmentBaseline: - return CSSPrimitiveValue::create(svgStyle->alignmentBaseline()); + return CSSPrimitiveValue::create(svgStyle.alignmentBaseline()); case CSSPropertyDominantBaseline: - return CSSPrimitiveValue::create(svgStyle->dominantBaseline()); + return CSSPrimitiveValue::create(svgStyle.dominantBaseline()); case CSSPropertyTextAnchor: - return CSSPrimitiveValue::create(svgStyle->textAnchor()); + return CSSPrimitiveValue::create(svgStyle.textAnchor()); case CSSPropertyWritingMode: - return CSSPrimitiveValue::create(svgStyle->writingMode()); + return CSSPrimitiveValue::create(svgStyle.writingMode()); case CSSPropertyClipPath: - if (!svgStyle->clipperResource().isEmpty()) - return CSSPrimitiveValue::create(svgStyle->clipperResource(), CSSPrimitiveValue::CSS_URI); + if (!svgStyle.clipperResource().isEmpty()) + return CSSPrimitiveValue::create(svgStyle.clipperResource(), CSSPrimitiveValue::CSS_URI); return CSSPrimitiveValue::createIdentifier(CSSValueNone); case CSSPropertyMask: - 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); + if (!svgStyle.maskerResource().isEmpty()) + return CSSPrimitiveValue::create(svgStyle.maskerResource(), CSSPrimitiveValue::CSS_URI); return CSSPrimitiveValue::createIdentifier(CSSValueNone); case CSSPropertyFloodColor: - return currentColorOrValidColor(style, svgStyle->floodColor()); + return currentColorOrValidColor(style, svgStyle.floodColor()); case CSSPropertyLightingColor: - return currentColorOrValidColor(style, svgStyle->lightingColor()); + return currentColorOrValidColor(style, svgStyle.lightingColor()); case CSSPropertyStopColor: - return currentColorOrValidColor(style, svgStyle->stopColor()); + return currentColorOrValidColor(style, svgStyle.stopColor()); case CSSPropertyFill: - return adjustSVGPaintForCurrentColor(SVGPaint::create(svgStyle->fillPaintType(), svgStyle->fillPaintUri(), svgStyle->fillPaintColor()), style); + return adjustSVGPaintForCurrentColor(SVGPaint::create(svgStyle.fillPaintType(), svgStyle.fillPaintUri(), svgStyle.fillPaintColor()), style); case CSSPropertyKerning: - return SVGLength::toCSSPrimitiveValue(svgStyle->kerning()); + return SVGLength::toCSSPrimitiveValue(svgStyle.kerning()); case CSSPropertyMarkerEnd: - if (!svgStyle->markerEndResource().isEmpty()) - return CSSPrimitiveValue::create(svgStyle->markerEndResource(), CSSPrimitiveValue::CSS_URI); + if (!svgStyle.markerEndResource().isEmpty()) + return CSSPrimitiveValue::create(svgStyle.markerEndResource(), CSSPrimitiveValue::CSS_URI); return CSSPrimitiveValue::createIdentifier(CSSValueNone); case CSSPropertyMarkerMid: - if (!svgStyle->markerMidResource().isEmpty()) - return CSSPrimitiveValue::create(svgStyle->markerMidResource(), CSSPrimitiveValue::CSS_URI); + if (!svgStyle.markerMidResource().isEmpty()) + return CSSPrimitiveValue::create(svgStyle.markerMidResource(), CSSPrimitiveValue::CSS_URI); return CSSPrimitiveValue::createIdentifier(CSSValueNone); case CSSPropertyMarkerStart: - if (!svgStyle->markerStartResource().isEmpty()) - return CSSPrimitiveValue::create(svgStyle->markerStartResource(), CSSPrimitiveValue::CSS_URI); + if (!svgStyle.markerStartResource().isEmpty()) + 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(SVGPaint::create(svgStyle.strokePaintType(), svgStyle.strokePaintUri(), svgStyle.strokePaintColor()), style); case CSSPropertyStrokeDasharray: - return strokeDashArrayToCSSValueList(svgStyle->strokeDashArray()); - case CSSPropertyStrokeDashoffset: - return SVGLength::toCSSPrimitiveValue(svgStyle->strokeDashOffset()); - case CSSPropertyStrokeWidth: - return SVGLength::toCSSPrimitiveValue(svgStyle->strokeWidth()); + return strokeDashArrayToCSSValueList(svgStyle.strokeDashArray()); case CSSPropertyBaselineShift: { - switch (svgStyle->baselineShift()) { + switch (svgStyle.baselineShift()) { case BS_BASELINE: return CSSPrimitiveValue::createIdentifier(CSSValueBaseline); case BS_SUPER: @@ -172,30 +195,32 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID prop case BS_SUB: return CSSPrimitiveValue::createIdentifier(CSSValueSub); case BS_LENGTH: - return SVGLength::toCSSPrimitiveValue(svgStyle->baselineShiftValue()); + return SVGLength::toCSSPrimitiveValue(svgStyle.baselineShiftValue()); } ASSERT_NOT_REACHED(); - return 0; + return nullptr; } case CSSPropertyBufferedRendering: - return CSSPrimitiveValue::create(svgStyle->bufferedRendering()); + return CSSPrimitiveValue::create(svgStyle.bufferedRendering()); case CSSPropertyGlyphOrientationHorizontal: - return glyphOrientationToCSSPrimitiveValue(svgStyle->glyphOrientationHorizontal()); + return glyphOrientationToCSSPrimitiveValue(svgStyle.glyphOrientationHorizontal()); case CSSPropertyGlyphOrientationVertical: { - if (RefPtr<CSSPrimitiveValue> value = glyphOrientationToCSSPrimitiveValue(svgStyle->glyphOrientationVertical())) + if (RefPtr<CSSPrimitiveValue> value = glyphOrientationToCSSPrimitiveValue(svgStyle.glyphOrientationVertical())) return value.release(); - if (svgStyle->glyphOrientationVertical() == GO_AUTO) + 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()); + return CSSPrimitiveValue::create(svgStyle.vectorEffect()); case CSSPropertyMaskType: - return CSSPrimitiveValue::create(svgStyle->maskType()); + return CSSPrimitiveValue::create(svgStyle.maskType()); + case CSSPropertyPaintOrder: + return paintOrder(svgStyle.paintOrder()); case CSSPropertyMarker: case CSSPropertyEnableBackground: case CSSPropertyColorProfile: @@ -207,11 +232,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 |