Skip to content

Commit

Permalink
Fixes for SVGPathElement IDLs and a bad assert.
Browse files Browse the repository at this point in the history
The SVGPathElement IDLs were allowing undefined arguments, optional
arguments, and were not type checking. This patch removes the optional
portion, adds StrictTypeChecking (although that is not implemented in
the IDL compiler yet) and adds testing.

We also remove an assert that is simply wrong. It is OK to try to
commit a change to an SVGPathSegList chunk before it is added to a
list. The role is set from Undefined to Unaltered when it is added
to the list, which is the correct behavior.

R=pdr,fmalita
BUG=311246

Review URL: https://codereview.chromium.org/54893002

git-svn-id: svn://svn.chromium.org/blink/trunk@161130 bbb929c8-8fbe-4397-9dbb-9b2b20218538
  • Loading branch information
schenney@chromium.org committed Nov 1, 2013
1 parent e6ab25e commit 72808e1
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 62 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<body>
<script src="../../fast/js/resources/js-test-pre.js"></script>
<script>
var pathElement = document.createElementNS("http://www.w3.org/2000/svg","path");

var pathSegment = pathElement.createSVGPathSegCurvetoCubicAbs(0.0, 1.0, 2.0, 3.0, 4.0, 5.0);
pathSegment.x1 = -1.0;

shouldBe('pathSegment.x1', '-1.0');
</script>
<p id="description">Test that there is no assertion when setting values on a new path segment not in any segment list.</p>
<div id="console"></div>
<script src="../../fast/js/resources/js-test-post.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
function go() {
var oSVGPolygon = document.createElementNS("http://www.w3.org/2000/svg", "polygon");
var oSVGPath = document.createElementNS("http://www.w3.org/2000/svg", "path");
var oSVGPoint1 = oSVGPath.getPointAtLength();
var oSVGPoint1 = oSVGPath.getPointAtLength(0.0);
oSVGPolygon.points.initialize(oSVGPoint1);
oSVGPolygon.points.removeItem(-9223372036854775802);
alert("Accessing old oSVGPoint1.x: " + oSVGPoint1.x);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!DOCTYPE html>
<html>
<body>
<script src="../../fast/js/resources/js-test-pre.js"></script>
<script>
var pathElement = document.createElementNS("http://www.w3.org/2000/svg","path");

shouldThrow('pathElement.getPointAtLength()',
'"TypeError: Failed to execute \'getPointAtLength\' on \'SVGPathElement\': 1 argument required, but only 0 present."');

shouldThrow('pathElement.getPathSegAtLength()',
'"TypeError: Failed to execute \'getPathSegAtLength\' on \'SVGPathElement\': 1 argument required, but only 0 present."');

shouldThrow('pathElement.createSVGPathSegMovetoAbs(0.0)',
'"TypeError: Failed to execute \'createSVGPathSegMovetoAbs\' on \'SVGPathElement\': 2 arguments required, but only 1 present."');

shouldThrow('pathElement.createSVGPathSegMovetoRel(0.0)',
'"TypeError: Failed to execute \'createSVGPathSegMovetoRel\' on \'SVGPathElement\': 2 arguments required, but only 1 present."');

shouldThrow('pathElement.createSVGPathSegLinetoAbs(0.0)',
'"TypeError: Failed to execute \'createSVGPathSegLinetoAbs\' on \'SVGPathElement\': 2 arguments required, but only 1 present."');

shouldThrow('pathElement.createSVGPathSegLinetoRel(0.0)',
'"TypeError: Failed to execute \'createSVGPathSegLinetoRel\' on \'SVGPathElement\': 2 arguments required, but only 1 present."');

shouldThrow('pathElement.createSVGPathSegCurvetoCubicAbs(0.0, 1.0, 2.0, 3.0, 4.0)',
'"TypeError: Failed to execute \'createSVGPathSegCurvetoCubicAbs\' on \'SVGPathElement\': 6 arguments required, but only 5 present."');

shouldThrow('pathElement.createSVGPathSegCurvetoCubicRel(0.0, 1.0, 2.0, 3.0, 4.0)',
'"TypeError: Failed to execute \'createSVGPathSegCurvetoCubicRel\' on \'SVGPathElement\': 6 arguments required, but only 5 present."');

shouldThrow('pathElement.createSVGPathSegCurvetoQuadraticAbs(0.0, 1.0, 2.0)',
'"TypeError: Failed to execute \'createSVGPathSegCurvetoQuadraticAbs\' on \'SVGPathElement\': 4 arguments required, but only 3 present."');

shouldThrow('pathElement.createSVGPathSegCurvetoQuadraticRel(0.0, 1.0, 2.0)',
'"TypeError: Failed to execute \'createSVGPathSegCurvetoQuadraticRel\' on \'SVGPathElement\': 4 arguments required, but only 3 present."');

shouldThrow('pathElement.createSVGPathSegArcAbs(0.0, 1.0, 2.0, 3.0, 4.0, true)',
'"TypeError: Failed to execute \'createSVGPathSegArcAbs\' on \'SVGPathElement\': 7 arguments required, but only 6 present."');

shouldThrow('pathElement.createSVGPathSegArcRel(0.0, 1.0, 2.0, 3.0, 4.0, true)',
'"TypeError: Failed to execute \'createSVGPathSegArcRel\' on \'SVGPathElement\': 7 arguments required, but only 6 present."');

shouldThrow('pathElement.createSVGPathSegLinetoHorizontalAbs()',
'"TypeError: Failed to execute \'createSVGPathSegLinetoHorizontalAbs\' on \'SVGPathElement\': 1 argument required, but only 0 present."');

shouldThrow('pathElement.createSVGPathSegLinetoHorizontalRel()',
'"TypeError: Failed to execute \'createSVGPathSegLinetoHorizontalRel\' on \'SVGPathElement\': 1 argument required, but only 0 present."');

shouldThrow('pathElement.createSVGPathSegLinetoVerticalAbs()',
'"TypeError: Failed to execute \'createSVGPathSegLinetoVerticalAbs\' on \'SVGPathElement\': 1 argument required, but only 0 present."');

shouldThrow('pathElement.createSVGPathSegLinetoVerticalRel()',
'"TypeError: Failed to execute \'createSVGPathSegLinetoVerticalRel\' on \'SVGPathElement\': 1 argument required, but only 0 present."');

shouldThrow('pathElement.createSVGPathSegCurvetoCubicSmoothAbs(0.0, 1.0, 2.0)',
'"TypeError: Failed to execute \'createSVGPathSegCurvetoCubicSmoothAbs\' on \'SVGPathElement\': 4 arguments required, but only 3 present."');

shouldThrow('pathElement.createSVGPathSegCurvetoCubicSmoothRel(0.0, 1.0, 2.0)',
'"TypeError: Failed to execute \'createSVGPathSegCurvetoCubicSmoothRel\' on \'SVGPathElement\': 4 arguments required, but only 3 present."');

shouldThrow('pathElement.createSVGPathSegCurvetoQuadraticSmoothAbs(0.0)',
'"TypeError: Failed to execute \'createSVGPathSegCurvetoQuadraticSmoothAbs\' on \'SVGPathElement\': 2 arguments required, but only 1 present."');

shouldThrow('pathElement.createSVGPathSegCurvetoQuadraticSmoothRel(0.0)',
'"TypeError: Failed to execute \'createSVGPathSegCurvetoQuadraticSmoothRel\' on \'SVGPathElement\': 2 arguments required, but only 1 present."');
</script>
<p id="description">Test that correct exceptions are thrown from SVGPathElement methods.</p>
<div id="console"></div>
<script src="../../fast/js/resources/js-test-post.js"></script>
</body>
</html>
86 changes: 26 additions & 60 deletions third_party/WebKit/Source/core/svg/SVGPathElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -28,77 +28,43 @@ interface SVGPathElement : SVGGraphicsElement {
readonly attribute SVGAnimatedNumber pathLength;

float getTotalLength();
SVGPoint getPointAtLength([Default=Undefined] optional float distance);
unsigned long getPathSegAtLength([Default=Undefined] optional float distance);
[StrictTypeChecking] SVGPoint getPointAtLength(float distance);
[StrictTypeChecking] unsigned long getPathSegAtLength(float distance);

SVGPathSegClosePath createSVGPathSegClosePath();

SVGPathSegMovetoAbs createSVGPathSegMovetoAbs([Default=Undefined] optional float x,
[Default=Undefined] optional float y);
SVGPathSegMovetoRel createSVGPathSegMovetoRel([Default=Undefined] optional float x,
[Default=Undefined] optional float y);
[StrictTypeChecking] SVGPathSegMovetoAbs createSVGPathSegMovetoAbs(float x, float y);
[StrictTypeChecking] SVGPathSegMovetoRel createSVGPathSegMovetoRel(float x, float y);

SVGPathSegLinetoAbs createSVGPathSegLinetoAbs([Default=Undefined] optional float x,
[Default=Undefined] optional float y);
SVGPathSegLinetoRel createSVGPathSegLinetoRel([Default=Undefined] optional float x,
[Default=Undefined] optional float y);
[StrictTypeChecking] SVGPathSegLinetoAbs createSVGPathSegLinetoAbs(float x, float y);
[StrictTypeChecking] SVGPathSegLinetoRel createSVGPathSegLinetoRel(float x, float y);

SVGPathSegCurvetoCubicAbs createSVGPathSegCurvetoCubicAbs([Default=Undefined] optional float x,
[Default=Undefined] optional float y,
[Default=Undefined] optional float x1,
[Default=Undefined] optional float y1,
[Default=Undefined] optional float x2,
[Default=Undefined] optional float y2);
SVGPathSegCurvetoCubicRel createSVGPathSegCurvetoCubicRel([Default=Undefined] optional float x,
[Default=Undefined] optional float y,
[Default=Undefined] optional float x1,
[Default=Undefined] optional float y1,
[Default=Undefined] optional float x2,
[Default=Undefined] optional float y2);
[StrictTypeChecking] SVGPathSegCurvetoCubicAbs
createSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2);
[StrictTypeChecking] SVGPathSegCurvetoCubicRel
createSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2);

SVGPathSegCurvetoQuadraticAbs createSVGPathSegCurvetoQuadraticAbs([Default=Undefined] optional float x,
[Default=Undefined] optional float y,
[Default=Undefined] optional float x1,
[Default=Undefined] optional float y1);
SVGPathSegCurvetoQuadraticRel createSVGPathSegCurvetoQuadraticRel([Default=Undefined] optional float x,
[Default=Undefined] optional float y,
[Default=Undefined] optional float x1,
[Default=Undefined] optional float y1);
[StrictTypeChecking] SVGPathSegCurvetoQuadraticAbs
createSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1);
[StrictTypeChecking] SVGPathSegCurvetoQuadraticRel
createSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1);

SVGPathSegArcAbs createSVGPathSegArcAbs([Default=Undefined] optional float x,
[Default=Undefined] optional float y,
[Default=Undefined] optional float r1,
[Default=Undefined] optional float r2,
[Default=Undefined] optional float angle,
[Default=Undefined] optional boolean largeArcFlag,
[Default=Undefined] optional boolean sweepFlag);
SVGPathSegArcRel createSVGPathSegArcRel([Default=Undefined] optional float x,
[Default=Undefined] optional float y,
[Default=Undefined] optional float r1,
[Default=Undefined] optional float r2,
[Default=Undefined] optional float angle,
[Default=Undefined] optional boolean largeArcFlag,
[Default=Undefined] optional boolean sweepFlag);
[StrictTypeChecking] SVGPathSegArcAbs
createSVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, boolean largeArcFlag, boolean sweepFlag);
[StrictTypeChecking] SVGPathSegArcRel
createSVGPathSegArcRel(float x, float y, float r1, float r2, float angle, boolean largeArcFlag, boolean sweepFlag);

SVGPathSegLinetoHorizontalAbs createSVGPathSegLinetoHorizontalAbs([Default=Undefined] optional float x);
SVGPathSegLinetoHorizontalRel createSVGPathSegLinetoHorizontalRel([Default=Undefined] optional float x);
[StrictTypeChecking] SVGPathSegLinetoHorizontalAbs createSVGPathSegLinetoHorizontalAbs(float x);
[StrictTypeChecking] SVGPathSegLinetoHorizontalRel createSVGPathSegLinetoHorizontalRel(float x);

SVGPathSegLinetoVerticalAbs createSVGPathSegLinetoVerticalAbs([Default=Undefined] optional float y);
SVGPathSegLinetoVerticalRel createSVGPathSegLinetoVerticalRel([Default=Undefined] optional float y);
[StrictTypeChecking] SVGPathSegLinetoVerticalAbs createSVGPathSegLinetoVerticalAbs(float y);
[StrictTypeChecking] SVGPathSegLinetoVerticalRel createSVGPathSegLinetoVerticalRel(float y);

SVGPathSegCurvetoCubicSmoothAbs createSVGPathSegCurvetoCubicSmoothAbs([Default=Undefined] optional float x,
[Default=Undefined] optional float y,
[Default=Undefined] optional float x2,
[Default=Undefined] optional float y2);
SVGPathSegCurvetoCubicSmoothRel createSVGPathSegCurvetoCubicSmoothRel([Default=Undefined] optional float x,
[Default=Undefined] optional float y,
[Default=Undefined] optional float x2,
[Default=Undefined] optional float y2);
[StrictTypeChecking] SVGPathSegCurvetoCubicSmoothAbs createSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2);
[StrictTypeChecking] SVGPathSegCurvetoCubicSmoothRel createSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2);

SVGPathSegCurvetoQuadraticSmoothAbs createSVGPathSegCurvetoQuadraticSmoothAbs([Default=Undefined] optional float x,
[Default=Undefined] optional float y);
SVGPathSegCurvetoQuadraticSmoothRel createSVGPathSegCurvetoQuadraticSmoothRel([Default=Undefined] optional float x,
[Default=Undefined] optional float y);
[StrictTypeChecking] SVGPathSegCurvetoQuadraticSmoothAbs createSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y);
[StrictTypeChecking] SVGPathSegCurvetoQuadraticSmoothRel createSVGPathSegCurvetoQuadraticSmoothRel(float x, float y);

readonly attribute SVGPathSegList pathSegList;
readonly attribute SVGPathSegList normalizedPathSegList;
Expand Down
1 change: 0 additions & 1 deletion third_party/WebKit/Source/core/svg/SVGPathSegWithContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class SVGPathSegWithContext : public SVGPathSeg {
return;
}

ASSERT(m_role != PathSegUndefinedRole);
m_element->pathSegListChanged(m_role);
}

Expand Down

0 comments on commit 72808e1

Please sign in to comment.