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/rendering/svg/RenderSVGPath.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/rendering/svg/RenderSVGPath.cpp')
-rw-r--r-- | Source/WebCore/rendering/svg/RenderSVGPath.cpp | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/Source/WebCore/rendering/svg/RenderSVGPath.cpp b/Source/WebCore/rendering/svg/RenderSVGPath.cpp index 353dd238c..208f11f8c 100644 --- a/Source/WebCore/rendering/svg/RenderSVGPath.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGPath.cpp @@ -26,8 +26,6 @@ */ #include "config.h" - -#if ENABLE(SVG) #include "RenderSVGPath.h" #include "SVGPathElement.h" @@ -35,8 +33,8 @@ namespace WebCore { -RenderSVGPath::RenderSVGPath(SVGGraphicsElement& element, PassRef<RenderStyle> style) - : RenderSVGShape(element, std::move(style)) +RenderSVGPath::RenderSVGPath(SVGGraphicsElement& element, RenderStyle&& style) + : RenderSVGShape(element, WTFMove(style)) { } @@ -66,19 +64,19 @@ FloatRect RenderSVGPath::calculateUpdatedStrokeBoundingBox() const return strokeBoundingBox; } -static void useStrokeStyleToFill(GraphicsContext* context) +static void useStrokeStyleToFill(GraphicsContext& context) { - if (Gradient* gradient = context->strokeGradient()) - context->setFillGradient(gradient); - else if (Pattern* pattern = context->strokePattern()) - context->setFillPattern(pattern); + if (Gradient* gradient = context.strokeGradient()) + context.setFillGradient(*gradient); + else if (Pattern* pattern = context.strokePattern()) + context.setFillPattern(*pattern); else - context->setFillColor(context->strokeColor(), context->strokeColorSpace()); + context.setFillColor(context.strokeColor()); } -void RenderSVGPath::strokeShape(GraphicsContext* context) const +void RenderSVGPath::strokeShape(GraphicsContext& context) const { - if (!style().svgStyle().hasVisibleStroke()) + if (!style().hasVisibleStroke()) return; RenderSVGShape::strokeShape(context); @@ -92,13 +90,13 @@ void RenderSVGPath::strokeShape(GraphicsContext* context) const if (hasNonScalingStroke()) nonScalingTransform = nonScalingStrokeTransform(); - GraphicsContextStateSaver stateSaver(*context, true); + GraphicsContextStateSaver stateSaver(context, true); useStrokeStyleToFill(context); for (size_t i = 0; i < m_zeroLengthLinecapLocations.size(); ++i) { usePath = zeroLengthLinecapPath(m_zeroLengthLinecapLocations[i]); if (hasNonScalingStroke()) usePath = nonScalingStrokePath(usePath, nonScalingTransform); - context->fillPath(*usePath); + context.fillPath(*usePath); } } @@ -107,15 +105,14 @@ bool RenderSVGPath::shapeDependentStrokeContains(const FloatPoint& point) if (RenderSVGShape::shapeDependentStrokeContains(point)) return true; - const SVGRenderStyle& svgStyle = style().svgStyle(); for (size_t i = 0; i < m_zeroLengthLinecapLocations.size(); ++i) { - ASSERT(svgStyle.hasStroke()); + ASSERT(style().svgStyle().hasStroke()); float strokeWidth = this->strokeWidth(); - if (svgStyle.capStyle() == SquareCap) { + if (style().capStyle() == SquareCap) { if (zeroLengthSubpathRect(m_zeroLengthLinecapLocations[i], strokeWidth).contains(point)) return true; } else { - ASSERT(svgStyle.capStyle() == RoundCap); + ASSERT(style().capStyle() == RoundCap); FloatPoint radiusVector(point.x() - m_zeroLengthLinecapLocations[i].x(), point.y() - m_zeroLengthLinecapLocations[i].y()); if (radiusVector.lengthSquared() < strokeWidth * strokeWidth * .25f) return true; @@ -128,20 +125,20 @@ bool RenderSVGPath::shouldStrokeZeroLengthSubpath() const { // Spec(11.4): Any zero length subpath shall not be stroked if the "stroke-linecap" property has a value of butt // but shall be stroked if the "stroke-linecap" property has a value of round or square - return style().svgStyle().hasStroke() && style().svgStyle().capStyle() != ButtCap; + return style().svgStyle().hasStroke() && style().capStyle() != ButtCap; } Path* RenderSVGPath::zeroLengthLinecapPath(const FloatPoint& linecapPosition) const { - DEFINE_STATIC_LOCAL(Path, tempPath, ()); + static NeverDestroyed<Path> tempPath; - tempPath.clear(); - if (style().svgStyle().capStyle() == SquareCap) - tempPath.addRect(zeroLengthSubpathRect(linecapPosition, this->strokeWidth())); + tempPath.get().clear(); + if (style().capStyle() == SquareCap) + tempPath.get().addRect(zeroLengthSubpathRect(linecapPosition, this->strokeWidth())); else - tempPath.addEllipse(zeroLengthSubpathRect(linecapPosition, this->strokeWidth())); + tempPath.get().addEllipse(zeroLengthSubpathRect(linecapPosition, this->strokeWidth())); - return &tempPath; + return &tempPath.get(); } FloatRect RenderSVGPath::zeroLengthSubpathRect(const FloatPoint& linecapPosition, float strokeWidth) const @@ -157,10 +154,17 @@ void RenderSVGPath::updateZeroLengthSubpaths() return; SVGSubpathData subpathData(m_zeroLengthLinecapLocations); - path().apply(&subpathData, SVGSubpathData::updateFromPathElement); + path().apply([&subpathData](const PathElement& pathElement) { + SVGSubpathData::updateFromPathElement(subpathData, pathElement); + }); subpathData.pathIsDone(); } +bool RenderSVGPath::isRenderingDisabled() const +{ + // For a polygon, polyline or path, rendering is disabled if there is no path data. + // No path data is possible in the case of a missing or empty 'd' or 'points' attribute. + return path().isEmpty(); } -#endif // ENABLE(SVG) +} |