Index: third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceMarker.cpp |
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceMarker.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceMarker.cpp |
index 11cf345ab6bba5d210856d8b5df1a00a19d80e6a..ac8c652fdb64bac2342973da18e7e451ca4a5c97 100644 |
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceMarker.cpp |
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceMarker.cpp |
@@ -65,7 +65,8 @@ FloatRect LayoutSVGResourceMarker::markerBoundaries(const AffineTransform& marke |
{ |
FloatRect coordinates = LayoutSVGContainer::paintInvalidationRectInLocalSVGCoordinates(); |
- // Map paint invalidation rect into parent coordinate space, in which the marker boundaries have to be evaluated |
+ // Map paint invalidation rect into parent coordinate space, in which the |
+ // marker boundaries have to be evaluated. |
coordinates = localToSVGParentTransform().mapRect(coordinates); |
return markerTransformation.mapRect(coordinates); |
@@ -105,24 +106,34 @@ SVGMarkerOrientType LayoutSVGResourceMarker::orientType() const |
AffineTransform LayoutSVGResourceMarker::markerTransformation(const FloatPoint& origin, float autoAngle, float strokeWidth) const |
{ |
- bool useStrokeWidth = markerUnits() == SVGMarkerUnitsStrokeWidth; |
+ // Apply scaling according to markerUnits ('strokeWidth' or 'userSpaceOnUse'.) |
+ float markerScale = markerUnits() == SVGMarkerUnitsStrokeWidth ? strokeWidth : 1; |
AffineTransform transform; |
transform.translate(origin.x(), origin.y()); |
transform.rotate(orientType() == SVGMarkerOrientAngle ? angle() : autoAngle); |
- transform = markerContentTransformation(transform, referencePoint(), useStrokeWidth ? strokeWidth : -1); |
- return transform; |
+ return markerContentTransformation(transform, referencePoint(), markerScale); |
f(malita)
2016/04/27 14:15:17
nit: markerContentTransformation concats scale(mar
fs
2016/04/27 14:27:01
Yeah, folding it makes sense. Done.
|
} |
-AffineTransform LayoutSVGResourceMarker::markerContentTransformation(const AffineTransform& contentTransformation, const FloatPoint& origin, float strokeWidth) const |
+bool LayoutSVGResourceMarker::shouldPaint() const |
{ |
- // The 'origin' coordinate maps to SVGs refX/refY, given in coordinates relative to the viewport established by the marker |
+ // An empty viewBox disables rendering. |
+ SVGMarkerElement* marker = toSVGMarkerElement(element()); |
+ ASSERT(marker); |
+ return !marker->viewBox()->isSpecified() |
+ || !marker->viewBox()->currentValue()->isValid() |
+ || !marker->viewBox()->currentValue()->value().isEmpty(); |
+} |
+ |
+AffineTransform LayoutSVGResourceMarker::markerContentTransformation( |
+ const AffineTransform& contentTransformation, const FloatPoint& origin, float markerScale) const |
+{ |
+ // The 'origin' coordinate maps to SVGs refX/refY, given in coordinates |
+ // relative to the viewport established by the marker. |
FloatPoint mappedOrigin = viewportTransform().mapPoint(origin); |
AffineTransform transformation = contentTransformation; |
- if (strokeWidth != -1) |
- transformation.scaleNonUniform(strokeWidth, strokeWidth); |
- |
+ transformation.scale(markerScale); |
transformation.translate(-mappedOrigin.x(), -mappedOrigin.y()); |
return transformation; |
} |