Don't use a magic value for 'auto' oriented <marker>s
The value -1 (degrees) is a valid angle, so using it to indicate that
'auto' orientation should be used does not work out.
Just check 'orientType' directly instead and simplify the angle getter.
BUG=606345
Review URL: https://codereview.chromium.org/1916173003
Cr-Commit-Position: refs/heads/master@{#390029}
diff --git a/third_party/WebKit/LayoutTests/svg/markers/marker-orientation-minus-one-expected.html b/third_party/WebKit/LayoutTests/svg/markers/marker-orientation-minus-one-expected.html
new file mode 100644
index 0000000..f718ea6
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/svg/markers/marker-orientation-minus-one-expected.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<div style="width: 100px; height: 100px; background-color: green"></div>
diff --git a/third_party/WebKit/LayoutTests/svg/markers/marker-orientation-minus-one.html b/third_party/WebKit/LayoutTests/svg/markers/marker-orientation-minus-one.html
new file mode 100644
index 0000000..34ba68c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/svg/markers/marker-orientation-minus-one.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<svg>
+ <marker id="m" orient="-1" overflow="visible">
+ <rect width="100" height="100" fill="green"/>
+ </marker>
+ <path marker-start="url(#m)" d="M0,0v50" transform="rotate(1)" fill="none" stroke="red"/>
+</svg>
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceMarker.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceMarker.cpp
index 5d1cc7d..11cf345a 100644
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceMarker.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceMarker.cpp
@@ -90,13 +90,7 @@
float LayoutSVGResourceMarker::angle() const
{
- ASSERT(element());
-
- float angle = -1;
- if (orientType() == SVGMarkerOrientAngle)
- angle = toSVGMarkerElement(*element()).orientAngle()->currentValue()->value();
-
- return angle;
+ return toSVGMarkerElement(element())->orientAngle()->currentValue()->value();
}
SVGMarkerUnitsType LayoutSVGResourceMarker::markerUnits() const
@@ -111,12 +105,11 @@
AffineTransform LayoutSVGResourceMarker::markerTransformation(const FloatPoint& origin, float autoAngle, float strokeWidth) const
{
- float markerAngle = angle();
bool useStrokeWidth = markerUnits() == SVGMarkerUnitsStrokeWidth;
AffineTransform transform;
transform.translate(origin.x(), origin.y());
- transform.rotate(markerAngle == -1 ? autoAngle : markerAngle);
+ transform.rotate(orientType() == SVGMarkerOrientAngle ? angle() : autoAngle);
transform = markerContentTransformation(transform, referencePoint(), useStrokeWidth ? strokeWidth : -1);
return transform;
}
diff --git a/third_party/WebKit/Source/core/layout/svg/SVGLayoutTreeAsText.cpp b/third_party/WebKit/Source/core/layout/svg/SVGLayoutTreeAsText.cpp
index e800cb7..8fbbbca 100644
--- a/third_party/WebKit/Source/core/layout/svg/SVGLayoutTreeAsText.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/SVGLayoutTreeAsText.cpp
@@ -519,7 +519,7 @@
writeNameValuePair(ts, "markerUnits", marker->markerUnits());
ts << " [ref at " << marker->referencePoint() << "]";
ts << " [angle=";
- if (marker->angle() == -1)
+ if (marker->orientType() != SVGMarkerOrientAngle)
ts << marker->orientType() << "]\n";
else
ts << marker->angle() << "]\n";