Changeset 252563 in webkit


Ignore:
Timestamp:
Nov 18, 2019 1:45:40 PM (4 years ago)
Author:
commit-queue@webkit.org
Message:

Fix getTotalLength() and getPointAtLength() for optimized rect and ellipse renderers
https://bugs.webkit.org/show_bug.cgi?id=204213

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2019-11-18
Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

  • web-platform-tests/svg/types/elements/SVGGeometryElement-rect-expected.txt:

Source/WebCore:

If the renderer does not create a Path to draw the shape, we need to create
a temporary Path from the SVGElement then use it to answer the questions
of these functions and finally delete it.

  • platform/graphics/Path.cpp:

(WebCore::Path::traversalStateAtLength const):
(WebCore::Path::pointAtLength const):
No need for the 'success'. It is never used.

(WebCore::Path::normalAngleAtLength const): Deleted.
This function is not used.

  • platform/graphics/Path.h:
  • rendering/svg/RenderSVGShape.cpp:

(WebCore::RenderSVGShape::updateShapeFromElement):
Creating the Path from the SVGELement is moved to createPath().

(WebCore::RenderSVGShape::getTotalLength const):
(WebCore::RenderSVGShape::getPointAtLength const):
Create a temporary Path if the renderer draws the shape without creating
the Path.

(WebCore::RenderSVGShape::createPath const):

  • rendering/svg/RenderSVGShape.h:
  • rendering/svg/SVGTextLayoutEngine.cpp:

(WebCore::SVGTextLayoutEngine::layoutTextOnLineOrPath):

  • svg/SVGAnimateMotionElement.cpp:

(WebCore::SVGAnimateMotionElement::buildTransformForProgress):
Use PathTraversalState.success() to check instead of getting the same
value through an argument to traversalStateAtLength().

LayoutTests:

The following tests were added in r231955. The SVGElements in these were
defined such that a path has to be created to render any of them. Change
all the tests, except the polygon and the polyline, such that no path is
needed to render them. This will exercise the code path where we need to
create a temporary Path to answer the questions of getTotalLength() and
getPointAtLength().

  • svg/dom/SVGGeometry-circle-expected.txt:
  • svg/dom/SVGGeometry-circle.xhtml:
  • svg/dom/SVGGeometry-ellipse-expected.txt:
  • svg/dom/SVGGeometry-ellipse.xhtml:
  • svg/dom/SVGGeometry-line-expected.txt:
  • svg/dom/SVGGeometry-line.xhtml:
  • svg/dom/SVGGeometry-polygon-expected.txt:
  • svg/dom/SVGGeometry-polygon.xhtml:
  • svg/dom/SVGGeometry-polyline-expected.txt:
  • svg/dom/SVGGeometry-polyline.xhtml:
  • svg/dom/SVGGeometry-rect-expected.txt:
  • svg/dom/SVGGeometry-rect.xhtml:
Location:
trunk
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r252562 r252563  
     12019-11-18  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        Fix getTotalLength() and getPointAtLength() for optimized rect and ellipse renderers
     4        https://bugs.webkit.org/show_bug.cgi?id=204213
     5
     6        Reviewed by Simon Fraser.
     7
     8        The following tests were added in r231955. The SVGElements in these were
     9        defined such that a path has to be created to render any of them. Change
     10        all the tests, except the polygon and the polyline, such that no path is
     11        needed to render them. This will exercise the code path where we need to
     12        create a temporary Path to answer the questions of getTotalLength() and
     13        getPointAtLength().
     14
     15        * svg/dom/SVGGeometry-circle-expected.txt:
     16        * svg/dom/SVGGeometry-circle.xhtml:
     17        * svg/dom/SVGGeometry-ellipse-expected.txt:
     18        * svg/dom/SVGGeometry-ellipse.xhtml:
     19        * svg/dom/SVGGeometry-line-expected.txt:
     20        * svg/dom/SVGGeometry-line.xhtml:
     21        * svg/dom/SVGGeometry-polygon-expected.txt:
     22        * svg/dom/SVGGeometry-polygon.xhtml:
     23        * svg/dom/SVGGeometry-polyline-expected.txt:
     24        * svg/dom/SVGGeometry-polyline.xhtml:
     25        * svg/dom/SVGGeometry-rect-expected.txt:
     26        * svg/dom/SVGGeometry-rect.xhtml:
     27
    1282019-11-18  Zalan Bujtas  <zalan@apple.com>
    229
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r252561 r252563  
     12019-11-18  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        Fix getTotalLength() and getPointAtLength() for optimized rect and ellipse renderers
     4        https://bugs.webkit.org/show_bug.cgi?id=204213
     5
     6        Reviewed by Simon Fraser.
     7
     8        * web-platform-tests/svg/types/elements/SVGGeometryElement-rect-expected.txt:
     9
    1102019-11-18  Wenson Hsieh  <wenson_hsieh@apple.com>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/svg/types/elements/SVGGeometryElement-rect-expected.txt

    r251777 r252563  
    11
    2 FAIL getTotalLength and getPointAtLength do not take pathLength into account assert_equals: expected 600 but got 0
     2PASS getTotalLength and getPointAtLength do not take pathLength into account
    33FAIL getPointAtLength() returns instance of DOMPoint assert_true: expected true got false
    44
  • trunk/LayoutTests/svg/dom/SVGGeometry-circle-expected.txt

    r231955 r252563  
    77Test isPointInFill()
    88PASS c1.isPointInFill({}) is false
    9 PASS c1.isPointInFill({x: 50, y: 50}) is true
    10 PASS c1.isPointInFill({x: 0, y: 50}) is true
    11 PASS c1.isPointInFill({x: 100, y: 50}) is true
    12 PASS c1.isPointInFill({x: 50, y: 0}) is true
    13 PASS c1.isPointInFill({x: 50, y: 100}) is true
    14 PASS c1.isPointInFill({x: -1, y: 50}) is false
    15 PASS c1.isPointInFill({x: 101, y: 50}) is false
    16 PASS c1.isPointInFill({x: 50, y: -1}) is false
    17 PASS c1.isPointInFill({x: 50, y: 101}) is false
    18 PASS c1.isPointInFill({x: 90, y: 90}) is false
    19 PASS c1.isPointInFill({x: 10, y: 10}) is false
    20 PASS c1.isPointInFill({x: 90, y: 10}) is false
    21 PASS c1.isPointInFill({x: 10, y: 90}) is false
     9PASS c1.isPointInFill({x: 109, y: 60}) is true
     10PASS c1.isPointInFill({x: 111, y: 60}) is false
     11PASS c1.isPointInFill({x: 60, y: 109}) is true
     12PASS c1.isPointInFill({x: 60, y: 111}) is false
     13PASS c1.isPointInFill({x: 11, y: 60}) is true
     14PASS c1.isPointInFill({x: 9, y: 60}) is false
     15PASS c1.isPointInFill({x: 60, y: 11}) is true
     16PASS c1.isPointInFill({x: 60, y: 9}) is false
    2217
    2318Test isPointInStroke()
    2419PASS c1.isPointInStroke({}) is false
    25 PASS c1.isPointInStroke({x: 50, y: 50}) is false
    26 PASS c1.isPointInStroke({x: 100, y: 51}) is false
    27 PASS c1.isPointInStroke({x: 100, y: 49}) is true
    28 PASS c1.isPointInStroke({x: 0, y: 50}) is true
    29 PASS c1.isPointInStroke({x: 52, y: 100}) is true
    30 PASS c1.isPointInStroke({x: 48, y: 100}) is false
     20PASS c1.isPointInStroke({x: 101, y: 60}) is true
     21PASS c1.isPointInStroke({x: 99, y: 60}) is false
     22PASS c1.isPointInStroke({x: 60, y: 101}) is true
     23PASS c1.isPointInStroke({x: 60, y: 99}) is false
     24PASS c1.isPointInStroke({x: 19, y: 60}) is true
     25PASS c1.isPointInStroke({x: 21, y: 60}) is false
     26PASS c1.isPointInStroke({x: 60, y: 19}) is true
     27PASS c1.isPointInStroke({x: 60, y: 21}) is false
    3128
    3229Test getTotalLength()
     
    3431
    3532Test getPointAtLength()
    36 PASS c1.getPointAtLength(0).x is within 0.1 of 100
    37 PASS c1.getPointAtLength(0).y is within 0.1 of 50
    38 PASS c1.getPointAtLength(Math.PI * 100 / 4).x is within 0.1 of 50
    39 PASS c1.getPointAtLength(Math.PI * 100 / 4).y is within 0.1 of 100
    40 PASS c1.getPointAtLength(Math.PI * 100 / 2).x is within 0.1 of 0
    41 PASS c1.getPointAtLength(Math.PI * 100 / 2).y is within 0.1 of 50
    42 PASS c1.getPointAtLength(Math.PI * 100 / 8).x is within 1 of 85.35
    43 PASS c1.getPointAtLength(Math.PI * 100 / 8).y is within 1 of 85.35
    44 PASS c1.getPointAtLength(Math.PI * 100 * 2).x is within 0.1 of 100
    45 PASS c1.getPointAtLength(Math.PI * 100 * 2).y is within 0.1 of 50
     33PASS c1.getPointAtLength(0).x is within 0.1 of 110
     34PASS c1.getPointAtLength(0).y is within 0.1 of 60
     35PASS c1.getPointAtLength(Math.PI * 100 / 4).x is within 0.1 of 60
     36PASS c1.getPointAtLength(Math.PI * 100 / 4).y is within 0.1 of 110
     37PASS c1.getPointAtLength(Math.PI * 100 / 2).x is within 0.1 of 10
     38PASS c1.getPointAtLength(Math.PI * 100 / 2).y is within 0.1 of 60
     39PASS c1.getPointAtLength(Math.PI * 100 / 8).x is within 1 of 95.35
     40PASS c1.getPointAtLength(Math.PI * 100 / 8).y is within 1 of 95.35
     41PASS c1.getPointAtLength(Math.PI * 100 * 2).x is within 0.1 of 110
     42PASS c1.getPointAtLength(Math.PI * 100 * 2).y is within 0.1 of 60
    4643PASS successfullyParsed is true
    4744
  • trunk/LayoutTests/svg/dom/SVGGeometry-circle.xhtml

    r231955 r252563  
    55<body onload="run()">
    66<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="200" height="200">
    7     <circle id="c1" cx="50" cy="50" r="50" fill="none" stroke="black" stroke-width="20" stroke-dashoffset="20" stroke-dasharray="20 20"/>
     7    <circle id="c1" cx="60" cy="60" r="50" fill="none" stroke="black" stroke-width="20"/>
    88</svg>
    99<p id="description"></p>
     
    2020    debug("");
    2121    debug("Test isPointInFill()");
    22     shouldBe("c1.isPointInFill({})", "false");
    23     shouldBe("c1.isPointInFill({x: 50, y: 50})", "true");
    24     shouldBe("c1.isPointInFill({x: 0, y: 50})", "true");
    25     shouldBe("c1.isPointInFill({x: 100, y: 50})", "true");
    26     shouldBe("c1.isPointInFill({x: 50, y: 0})", "true");
    27     shouldBe("c1.isPointInFill({x: 50, y: 100})", "true");
    28     shouldBe("c1.isPointInFill({x: -1, y: 50})", "false");
    29     shouldBe("c1.isPointInFill({x: 101, y: 50})", "false");
    30     shouldBe("c1.isPointInFill({x: 50, y: -1})", "false");
    31     shouldBe("c1.isPointInFill({x: 50, y: 101})", "false");
    32     shouldBe("c1.isPointInFill({x: 90, y: 90})", "false");
    33     shouldBe("c1.isPointInFill({x: 10, y: 10})", "false");
    34     shouldBe("c1.isPointInFill({x: 90, y: 10})", "false");
    35     shouldBe("c1.isPointInFill({x: 10, y: 90})", "false");
     22    shouldBeFalse("c1.isPointInFill({})", "false");
     23    shouldBeTrue("c1.isPointInFill({x: 109, y: 60})");
     24    shouldBeFalse("c1.isPointInFill({x: 111, y: 60})");
     25    shouldBeTrue("c1.isPointInFill({x: 60, y: 109})");
     26    shouldBeFalse("c1.isPointInFill({x: 60, y: 111})");
     27    shouldBeTrue("c1.isPointInFill({x: 11, y: 60})");
     28    shouldBeFalse("c1.isPointInFill({x: 9, y: 60})");
     29    shouldBeTrue("c1.isPointInFill({x: 60, y: 11})");
     30    shouldBeFalse("c1.isPointInFill({x: 60, y: 9})");
    3631
    3732    debug("");
    3833    debug("Test isPointInStroke()");
    39     shouldBe("c1.isPointInStroke({})", "false");
    40     shouldBe("c1.isPointInStroke({x: 50, y: 50})", "false");
    41     shouldBe("c1.isPointInStroke({x: 100, y: 51})", "false");
    42     shouldBe("c1.isPointInStroke({x: 100, y: 49})", "true");
    43     shouldBe("c1.isPointInStroke({x: 0, y: 50})", "true");
    44     shouldBe("c1.isPointInStroke({x: 52, y: 100})", "true");
    45     shouldBe("c1.isPointInStroke({x: 48, y: 100})", "false");
     34    shouldBeFalse("c1.isPointInStroke({})");
     35    shouldBeTrue("c1.isPointInStroke({x: 101, y: 60})");
     36    shouldBeFalse("c1.isPointInStroke({x: 99, y: 60})");
     37    shouldBeTrue("c1.isPointInStroke({x: 60, y: 101})");
     38    shouldBeFalse("c1.isPointInStroke({x: 60, y: 99})");
     39    shouldBeTrue("c1.isPointInStroke({x: 19, y: 60})");
     40    shouldBeFalse("c1.isPointInStroke({x: 21, y: 60})");
     41    shouldBeTrue("c1.isPointInStroke({x: 60, y: 19})");
     42    shouldBeFalse("c1.isPointInStroke({x: 60, y: 21})");
    4643
    4744    debug("");
     
    5148    debug("");
    5249    debug("Test getPointAtLength()");
    53     shouldBeCloseTo("c1.getPointAtLength(0).x", 100, 0.1);
    54     shouldBeCloseTo("c1.getPointAtLength(0).y", 50, 0.1);
    55     shouldBeCloseTo("c1.getPointAtLength(Math.PI * 100 / 4).x", 50, 0.1);
    56     shouldBeCloseTo("c1.getPointAtLength(Math.PI * 100 / 4).y", 100, 0.1);
    57     shouldBeCloseTo("c1.getPointAtLength(Math.PI * 100 / 2).x", 0, 0.1);
    58     shouldBeCloseTo("c1.getPointAtLength(Math.PI * 100 / 2).y", 50, 0.1);
    59     shouldBeCloseTo("c1.getPointAtLength(Math.PI * 100 / 8).x", 85.35, 1);
    60     shouldBeCloseTo("c1.getPointAtLength(Math.PI * 100 / 8).y", 85.35, 1);
    61     shouldBeCloseTo("c1.getPointAtLength(Math.PI * 100 * 2).x", 100, 0.1);
    62     shouldBeCloseTo("c1.getPointAtLength(Math.PI * 100 * 2).y", 50, 0.1);
     50    shouldBeCloseTo("c1.getPointAtLength(0).x", 110, 0.1);
     51    shouldBeCloseTo("c1.getPointAtLength(0).y", 60, 0.1);
     52    shouldBeCloseTo("c1.getPointAtLength(Math.PI * 100 / 4).x", 60, 0.1);
     53    shouldBeCloseTo("c1.getPointAtLength(Math.PI * 100 / 4).y", 110, 0.1);
     54    shouldBeCloseTo("c1.getPointAtLength(Math.PI * 100 / 2).x", 10, 0.1);
     55    shouldBeCloseTo("c1.getPointAtLength(Math.PI * 100 / 2).y", 60, 0.1);
     56    shouldBeCloseTo("c1.getPointAtLength(Math.PI * 100 / 8).x", 95.35, 1);
     57    shouldBeCloseTo("c1.getPointAtLength(Math.PI * 100 / 8).y", 95.35, 1);
     58    shouldBeCloseTo("c1.getPointAtLength(Math.PI * 100 * 2).x", 110, 0.1);
     59    shouldBeCloseTo("c1.getPointAtLength(Math.PI * 100 * 2).y", 60, 0.1);
    6360
    6461    finishJSTest();
  • trunk/LayoutTests/svg/dom/SVGGeometry-ellipse-expected.txt

    r231955 r252563  
    77Test isPointInFill()
    88PASS e1.isPointInFill({}) is false
    9 PASS e1.isPointInFill({x: 75, y: 50}) is true
    10 PASS e1.isPointInFill({x: 0, y: 50}) is true
    11 PASS e1.isPointInFill({x: 150, y: 50}) is true
    12 PASS e1.isPointInFill({x: 75, y: 0}) is true
    13 PASS e1.isPointInFill({x: 75, y: 100}) is true
    14 PASS e1.isPointInFill({x: -1, y: 50}) is false
    15 PASS e1.isPointInFill({x: 151, y: 50}) is false
    16 PASS e1.isPointInFill({x: 75, y: -1}) is false
    17 PASS e1.isPointInFill({x: 75, y: 101}) is false
    18 PASS e1.isPointInFill({x: 140, y: 90}) is false
    19 PASS e1.isPointInFill({x: 10, y: 10}) is false
    20 PASS e1.isPointInFill({x: 140, y: 10}) is false
    21 PASS e1.isPointInFill({x: 10, y: 90}) is false
     9PASS e1.isPointInFill({x: 159, y: 60}) is true
     10PASS e1.isPointInFill({x: 161, y: 60}) is false
     11PASS e1.isPointInFill({x: 85, y: 109}) is true
     12PASS e1.isPointInFill({x: 85, y: 111}) is false
     13PASS e1.isPointInFill({x: 11, y: 60}) is true
     14PASS e1.isPointInFill({x: 9, y: 60}) is false
     15PASS e1.isPointInFill({x: 85, y: 11}) is true
     16PASS e1.isPointInFill({x: 85, y: 9}) is false
    2217
    2318Test isPointInStroke()
    2419PASS e1.isPointInStroke({}) is false
    25 PASS e1.isPointInStroke({x: 75, y: 50}) is false
    26 PASS e1.isPointInStroke({x: 150, y: 51}) is false
    27 PASS e1.isPointInStroke({x: 150, y: 49}) is true
    28 PASS e1.isPointInStroke({x: 0, y: 52}) is true
    29 PASS e1.isPointInStroke({x: 0, y: 48}) is false
    30 PASS e1.isPointInStroke({x: 77, y: 100}) is false
    31 PASS e1.isPointInStroke({x: 73, y: 100}) is true
     20PASS e1.isPointInStroke({x: 151, y: 60}) is true
     21PASS e1.isPointInStroke({x: 149, y: 60}) is false
     22PASS e1.isPointInStroke({x: 85, y: 101}) is true
     23PASS e1.isPointInStroke({x: 85, y: 99}) is false
     24PASS e1.isPointInStroke({x: 19, y: 60}) is true
     25PASS e1.isPointInStroke({x: 21, y: 60}) is false
     26PASS e1.isPointInStroke({x: 85, y: 19}) is true
     27PASS e1.isPointInStroke({x: 85, y: 21}) is false
    3228
    3329Test getTotalLength()
     
    3531
    3632Test getPointAtLength()
    37 PASS e1.getPointAtLength(0).x is within 0.1 of 150
    38 PASS e1.getPointAtLength(0).y is within 0.1 of 50
    39 PASS e1.getPointAtLength(Math.PI * (75 + 50) / 4).x is within 3 of 75
    40 PASS e1.getPointAtLength(Math.PI * (75 + 50) / 4).y is within 3 of 100
    41 PASS e1.getPointAtLength(Math.PI * (75 + 50) / 2).x is within 3 of 0
    42 PASS e1.getPointAtLength(Math.PI * (75 + 50) / 2).y is within 3 of 50
    43 PASS e1.getPointAtLength(Math.PI * (75 + 50) / 8).x is within 3 of 123
    44 PASS e1.getPointAtLength(Math.PI * (75 + 50) / 8).y is within 3 of 88
    45 PASS e1.getPointAtLength(Math.PI * (75 + 50) * 2).x is within 3 of 150
    46 PASS e1.getPointAtLength(Math.PI * (75 + 50) * 2).y is within 3 of 50
     33PASS e1.getPointAtLength(0).x is within 0.1 of 160
     34PASS e1.getPointAtLength(0).y is within 0.1 of 60
     35PASS e1.getPointAtLength(Math.PI * (75 + 50) / 4).x is within 3 of 85
     36PASS e1.getPointAtLength(Math.PI * (75 + 50) / 4).y is within 3 of 110
     37PASS e1.getPointAtLength(Math.PI * (75 + 50) / 2).x is within 3 of 10
     38PASS e1.getPointAtLength(Math.PI * (75 + 50) / 2).y is within 3 of 60
     39PASS e1.getPointAtLength(Math.PI * (75 + 50) / 8).x is within 3 of 133
     40PASS e1.getPointAtLength(Math.PI * (75 + 50) / 8).y is within 3 of 98
     41PASS e1.getPointAtLength(Math.PI * (75 + 50) * 2).x is within 3 of 160
     42PASS e1.getPointAtLength(Math.PI * (75 + 50) * 2).y is within 3 of 60
    4743PASS successfullyParsed is true
    4844
  • trunk/LayoutTests/svg/dom/SVGGeometry-ellipse.xhtml

    r231955 r252563  
    55<body onload="run()">
    66<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="200" height="200">
    7     <ellipse id="e1" cx="75" cy="50" rx="75" ry="50" fill="none" stroke="black" stroke-width="20" stroke-dashoffset="20" stroke-dasharray="20 20"/>
     7    <ellipse id="e1" cx="85" cy="60" rx="75" ry="50" fill="none" stroke="black" stroke-width="20"/>
    88</svg>
    99<p id="description"></p>
     
    2020    debug("");
    2121    debug("Test isPointInFill()");
    22     shouldBe("e1.isPointInFill({})", "false");
    23     shouldBe("e1.isPointInFill({x: 75, y: 50})", "true");
    24     shouldBe("e1.isPointInFill({x: 0, y: 50})", "true");
    25     shouldBe("e1.isPointInFill({x: 150, y: 50})", "true");
    26     shouldBe("e1.isPointInFill({x: 75, y: 0})", "true");
    27     shouldBe("e1.isPointInFill({x: 75, y: 100})", "true");
    28     shouldBe("e1.isPointInFill({x: -1, y: 50})", "false");
    29     shouldBe("e1.isPointInFill({x: 151, y: 50})", "false");
    30     shouldBe("e1.isPointInFill({x: 75, y: -1})", "false");
    31     shouldBe("e1.isPointInFill({x: 75, y: 101})", "false");
    32     shouldBe("e1.isPointInFill({x: 140, y: 90})", "false");
    33     shouldBe("e1.isPointInFill({x: 10, y: 10})", "false");
    34     shouldBe("e1.isPointInFill({x: 140, y: 10})", "false");
    35     shouldBe("e1.isPointInFill({x: 10, y: 90})", "false");
     22    shouldBeFalse("e1.isPointInFill({})");
     23    shouldBeTrue("e1.isPointInFill({x: 159, y: 60})");
     24    shouldBeFalse("e1.isPointInFill({x: 161, y: 60})");
     25
     26    shouldBeTrue("e1.isPointInFill({x: 85, y: 109})");
     27    shouldBeFalse("e1.isPointInFill({x: 85, y: 111})");
     28    shouldBeTrue("e1.isPointInFill({x: 11, y: 60})");
     29    shouldBeFalse("e1.isPointInFill({x: 9, y: 60})");
     30    shouldBeTrue("e1.isPointInFill({x: 85, y: 11})");
     31    shouldBeFalse("e1.isPointInFill({x: 85, y: 9})");
    3632
    3733    debug("");
    3834    debug("Test isPointInStroke()");
    39     shouldBe("e1.isPointInStroke({})", "false");
    40     shouldBe("e1.isPointInStroke({x: 75, y: 50})", "false");
    41     shouldBe("e1.isPointInStroke({x: 150, y: 51})", "false");
    42     shouldBe("e1.isPointInStroke({x: 150, y: 49})", "true");
    43     shouldBe("e1.isPointInStroke({x: 0, y: 52})", "true");
    44     shouldBe("e1.isPointInStroke({x: 0, y: 48})", "false");
    45     shouldBe("e1.isPointInStroke({x: 77, y: 100})", "false");
    46     shouldBe("e1.isPointInStroke({x: 73, y: 100})", "true");
     35    shouldBeFalse("e1.isPointInStroke({})");
     36    shouldBeTrue("e1.isPointInStroke({x: 151, y: 60})");
     37    shouldBeFalse("e1.isPointInStroke({x: 149, y: 60})");
     38    shouldBeTrue("e1.isPointInStroke({x: 85, y: 101})");
     39    shouldBeFalse("e1.isPointInStroke({x: 85, y: 99})");
     40    shouldBeTrue("e1.isPointInStroke({x: 19, y: 60})");
     41    shouldBeFalse("e1.isPointInStroke({x: 21, y: 60})");
     42    shouldBeTrue("e1.isPointInStroke({x: 85, y: 19})");
     43    shouldBeFalse("e1.isPointInStroke({x: 85, y: 21})");
    4744
    4845    debug("");
     
    5249    debug("");
    5350    debug("Test getPointAtLength()");
    54     shouldBeCloseTo("e1.getPointAtLength(0).x", 150, 0.1);
    55     shouldBeCloseTo("e1.getPointAtLength(0).y", 50, 0.1);
    56     shouldBeCloseTo("e1.getPointAtLength(Math.PI * (75 + 50) / 4).x", 75, 3);
    57     shouldBeCloseTo("e1.getPointAtLength(Math.PI * (75 + 50) / 4).y", 100, 3);
    58     shouldBeCloseTo("e1.getPointAtLength(Math.PI * (75 + 50) / 2).x", 0, 3);
    59     shouldBeCloseTo("e1.getPointAtLength(Math.PI * (75 + 50) / 2).y", 50, 3);
    60     shouldBeCloseTo("e1.getPointAtLength(Math.PI * (75 + 50) / 8).x", 123, 3);
    61     shouldBeCloseTo("e1.getPointAtLength(Math.PI * (75 + 50) / 8).y", 88, 3);
    62     shouldBeCloseTo("e1.getPointAtLength(Math.PI * (75 + 50) * 2).x", 150, 3);
    63     shouldBeCloseTo("e1.getPointAtLength(Math.PI * (75 + 50) * 2).y", 50, 3);
     51    shouldBeCloseTo("e1.getPointAtLength(0).x", 160, 0.1);
     52    shouldBeCloseTo("e1.getPointAtLength(0).y", 60, 0.1);
     53    shouldBeCloseTo("e1.getPointAtLength(Math.PI * (75 + 50) / 4).x", 85, 3);
     54    shouldBeCloseTo("e1.getPointAtLength(Math.PI * (75 + 50) / 4).y", 110, 3);
     55    shouldBeCloseTo("e1.getPointAtLength(Math.PI * (75 + 50) / 2).x", 10, 3);
     56    shouldBeCloseTo("e1.getPointAtLength(Math.PI * (75 + 50) / 2).y", 60, 3);
     57    shouldBeCloseTo("e1.getPointAtLength(Math.PI * (75 + 50) / 8).x", 133, 3);
     58    shouldBeCloseTo("e1.getPointAtLength(Math.PI * (75 + 50) / 8).y", 98, 3);
     59    shouldBeCloseTo("e1.getPointAtLength(Math.PI * (75 + 50) * 2).x", 160, 3);
     60    shouldBeCloseTo("e1.getPointAtLength(Math.PI * (75 + 50) * 2).y", 60, 3);
    6461
    6562    finishJSTest();
  • trunk/LayoutTests/svg/dom/SVGGeometry-line-expected.txt

    r231955 r252563  
    77Test isPointInFill()
    88PASS l1.isPointInFill({}) is false
    9 PASS l1.isPointInFill({x: 0, y: 50}) is true
    10 PASS l1.isPointInFill({x: 50, y: 50}) is true
    11 PASS l1.isPointInFill({x: 100, y: 50}) is true
    12 PASS l1.isPointInFill({x: 50, y: 49}) is false
    13 PASS l1.isPointInFill({x: 50, y: 51}) is false
     9PASS l1.isPointInFill({x: 0, y: 10}) is true
     10PASS l1.isPointInFill({x: 0, y: 11}) is false
     11PASS l1.isPointInFill({x: 100, y: 10}) is true
     12PASS l1.isPointInFill({x: 100, y: 11}) is false
     13PASS l1.isPointInFill({x: 101, y: 10}) is false
     14PASS l1.isPointInFill({x: 101, y: 11}) is false
    1415
    1516Test isPointInStroke()
    16 PASS l1.isPointInStroke({x: 19, y: 50}) is false
    17 PASS l1.isPointInStroke({x: 20, y: 50}) is true
    18 PASS l1.isPointInStroke({x: 39, y: 50}) is true
    19 PASS l1.isPointInStroke({x: 40, y: 50}) is true
    20 PASS l1.isPointInStroke({x: 41, y: 50}) is false
     17PASS l1.isPointInStroke({ }) is true
     18PASS l1.isPointInStroke({x: 0, y: 0}) is true
     19PASS l1.isPointInStroke({x: 0, y: 21}) is false
     20PASS l1.isPointInStroke({x: 50, y: 0}) is true
     21PASS l1.isPointInStroke({x: 50, y: 21}) is false
     22PASS l1.isPointInStroke({x: 100, y: 0}) is true
     23PASS l1.isPointInStroke({x: 100, y: 21}) is false
     24PASS l1.isPointInStroke({x: 101, y: 0}) is false
     25PASS l1.isPointInStroke({x: 101, y: 21}) is false
    2126
    2227Test getTotalLength()
    23 PASS l1.getTotalLength() is within 1 of 100
     28PASS l1.getTotalLength() is within 0.1 of 100
    2429
    2530Test getPointAtLength()
    2631PASS l1.getPointAtLength(0).x is within 0.1 of 0
    27 PASS l1.getPointAtLength(0).y is within 0.1 of 50
     32PASS l1.getPointAtLength(0).y is within 0.1 of 10
    2833PASS l1.getPointAtLength(50).x is within 0.1 of 50
    29 PASS l1.getPointAtLength(50).y is within 0.1 of 50
     34PASS l1.getPointAtLength(50).y is within 0.1 of 10
    3035PASS l1.getPointAtLength(100).x is within 0.1 of 100
    31 PASS l1.getPointAtLength(100).y is within 0.1 of 50
     36PASS l1.getPointAtLength(100).y is within 0.1 of 10
    3237PASS l1.getPointAtLength(150).x is within 0.1 of 100
    33 PASS l1.getPointAtLength(150).y is within 0.1 of 50
     38PASS l1.getPointAtLength(150).y is within 0.1 of 10
    3439PASS successfullyParsed is true
    3540
  • trunk/LayoutTests/svg/dom/SVGGeometry-line.xhtml

    r231955 r252563  
    55<body onload="run()">
    66<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="200" height="200">
    7     <line id="l1" x1="0" y1="50" x2="100" y2="50" fill="none" stroke="black" stroke-width="20" stroke-dashoffset="20" stroke-dasharray="20 20"/>
     7    <line id="l1" x1="0" y1="10" x2="100" y2="10" fill="none" stroke="black" stroke-width="20"/>
    88</svg>
    99<p id="description"></p>
     
    2121    debug("Test isPointInFill()");
    2222    shouldBe("l1.isPointInFill({})", "false");
    23     shouldBe("l1.isPointInFill({x: 0, y: 50})", "true");
    24     shouldBe("l1.isPointInFill({x: 50, y: 50})", "true");
    25     shouldBe("l1.isPointInFill({x: 100, y: 50})", "true");
    26     shouldBe("l1.isPointInFill({x: 50, y: 49})", "false");
    27     shouldBe("l1.isPointInFill({x: 50, y: 51})", "false");
     23    shouldBeTrue("l1.isPointInFill({x: 0, y: 10})");
     24    shouldBeFalse("l1.isPointInFill({x: 0, y: 11})");
     25    shouldBeTrue("l1.isPointInFill({x: 100, y: 10})");
     26    shouldBeFalse("l1.isPointInFill({x: 100, y: 11})");
     27    shouldBeFalse("l1.isPointInFill({x: 101, y: 10})");
     28    shouldBeFalse("l1.isPointInFill({x: 101, y: 11})");
    2829
    2930    debug("");
    3031    debug("Test isPointInStroke()");
    31     shouldBe("l1.isPointInStroke({x: 19, y: 50})", "false");
    32     shouldBe("l1.isPointInStroke({x: 20, y: 50})", "true");
    33     shouldBe("l1.isPointInStroke({x: 39, y: 50})", "true");
    34     shouldBe("l1.isPointInStroke({x: 40, y: 50})", "true");
    35     shouldBe("l1.isPointInStroke({x: 41, y: 50})", "false");
     32    shouldBeTrue("l1.isPointInStroke({ })");
     33    shouldBeTrue("l1.isPointInStroke({x: 0, y: 0})");
     34    shouldBeFalse("l1.isPointInStroke({x: 0, y: 21})");
     35    shouldBeTrue("l1.isPointInStroke({x: 50, y: 0})");
     36    shouldBeFalse("l1.isPointInStroke({x: 50, y: 21})");
     37    shouldBeTrue("l1.isPointInStroke({x: 100, y: 0})");
     38    shouldBeFalse("l1.isPointInStroke({x: 100, y: 21})");
     39    shouldBeFalse("l1.isPointInStroke({x: 101, y: 0})");
     40    shouldBeFalse("l1.isPointInStroke({x: 101, y: 21})");
    3641
    3742    debug("");
    3843    debug("Test getTotalLength()");
    39     shouldBeCloseTo("l1.getTotalLength()", 100, 1);
     44    shouldBeCloseTo("l1.getTotalLength()", 100, 0.1);
    4045
    4146    debug("");
    4247    debug("Test getPointAtLength()");
    4348    shouldBeCloseTo("l1.getPointAtLength(0).x", 0, 0.1);
    44     shouldBeCloseTo("l1.getPointAtLength(0).y", 50, 0.1);
     49    shouldBeCloseTo("l1.getPointAtLength(0).y", 10, 0.1);
    4550    shouldBeCloseTo("l1.getPointAtLength(50).x", 50, 0.1);
    46     shouldBeCloseTo("l1.getPointAtLength(50).y", 50, 0.1);
     51    shouldBeCloseTo("l1.getPointAtLength(50).y", 10, 0.1);
    4752    shouldBeCloseTo("l1.getPointAtLength(100).x", 100, 0.1);
    48     shouldBeCloseTo("l1.getPointAtLength(100).y", 50, 0.1);
     53    shouldBeCloseTo("l1.getPointAtLength(100).y", 10, 0.1);
    4954    shouldBeCloseTo("l1.getPointAtLength(150).x", 100, 0.1);
    50     shouldBeCloseTo("l1.getPointAtLength(150).y", 50, 0.1);
     55    shouldBeCloseTo("l1.getPointAtLength(150).y", 10, 0.1);
    5156
    5257    finishJSTest();
  • trunk/LayoutTests/svg/dom/SVGGeometry-polygon-expected.txt

    r231955 r252563  
    66
    77Test isPointInFill()
    8 PASS p1.isPointInFill({}) is true
    9 PASS p1.isPointInFill({x: 100, y: 0}) is true
    10 PASS p1.isPointInFill({x: 152, y: 0}) is false
    11 PASS p1.isPointInFill({x: 150, y: 50}) is true
    12 PASS p1.isPointInFill({x: 150, y: 100}) is true
    13 PASS p1.isPointInFill({x: 150, y: 101}) is false
    14 PASS p1.isPointInFill({x: 100, y: 100}) is true
    15 PASS p1.isPointInFill({x: 75, y: 50}) is true
     8PASS p1.isPointInFill({}) is false
     9PASS p1.isPointInFill({x: 9, y: 9}) is false
     10PASS p1.isPointInFill({x: 10, y: 10}) is true
     11PASS p1.isPointInFill({x: 159, y: 9}) is false
     12PASS p1.isPointInFill({x: 160, y: 10}) is true
     13PASS p1.isPointInFill({x: 161, y: 110}) is false
     14PASS p1.isPointInFill({x: 160, y: 109}) is true
     15PASS p1.isPointInFill({x: 9, y: 109}) is false
     16PASS p1.isPointInFill({x: 10, y: 110}) is true
    1617
    1718Test isPointInStroke()
    18 PASS p1.isPointInStroke({x: 0, y: 0}) is false
    19 PASS p1.isPointInStroke({x: 20, y: 0}) is true
    20 PASS p1.isPointInStroke({x: 150, y: 0}) is true
    21 PASS p1.isPointInStroke({x: 150, y: 35}) is true
    22 PASS p1.isPointInStroke({x: 75, y: 50}) is false
     19PASS p1.isPointInStroke({x: 20, y: 20}) is true
     20PASS p1.isPointInStroke({x: 21, y: 21}) is false
     21PASS p1.isPointInStroke({x: 150, y:  20}) is true
     22PASS p1.isPointInStroke({x: 149, y: 21}) is false
     23PASS p1.isPointInStroke({x: 150, y: 100}) is true
     24PASS p1.isPointInStroke({x: 149, y: 99}) is false
     25PASS p1.isPointInStroke({x: 20, y: 100}) is true
     26PASS p1.isPointInStroke({x: 21, y: 99}) is false
    2327
    2428Test getTotalLength()
     
    2630
    2731Test getPointAtLength()
    28 PASS p1.getPointAtLength(0).x is within 0.1 of 0
    29 PASS p1.getPointAtLength(0).y is within 0.1 of 0
    30 PASS p1.getPointAtLength(150).x is within 0.1 of 150
    31 PASS p1.getPointAtLength(150).y is within 0.1 of 0
    32 PASS p1.getPointAtLength(200).x is within 0.1 of 150
    33 PASS p1.getPointAtLength(200).y is within 0.1 of 50
    34 PASS p1.getPointAtLength(300).x is within 0.1 of 100
    35 PASS p1.getPointAtLength(300).y is within 0.1 of 100
    36 PASS p1.getPointAtLength(450).x is within 0.1 of 0
    37 PASS p1.getPointAtLength(450).y is within 0.1 of 50
     32PASS p1.getPointAtLength(0).x is within 0.1 of 10
     33PASS p1.getPointAtLength(0).y is within 0.1 of 10
     34PASS p1.getPointAtLength(150).x is within 0.1 of 160
     35PASS p1.getPointAtLength(150).y is within 0.1 of 10
     36PASS p1.getPointAtLength(250).x is within 0.1 of 160
     37PASS p1.getPointAtLength(250).y is within 0.1 of 110
     38PASS p1.getPointAtLength(400).x is within 0.1 of 10
     39PASS p1.getPointAtLength(400).y is within 0.1 of 110
     40PASS p1.getPointAtLength(500).x is within 0.1 of 10
     41PASS p1.getPointAtLength(500).y is within 0.1 of 10
    3842PASS successfullyParsed is true
    3943
  • trunk/LayoutTests/svg/dom/SVGGeometry-polygon.xhtml

    r231955 r252563  
    55<body onload="run()">
    66<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="200" height="200">
    7     <polygon id="p1" points="0,0 150,0 150,100 0,100" fill="none" stroke="black" stroke-width="20" stroke-dashoffset="20" stroke-dasharray="20 20"/>
     7    <polygon id="p1" points="10,10 160,10 160,110 10,110" fill="none" stroke="black" stroke-width="20"/>
    88</svg>
    99<p id="description"></p>
     
    2020    debug("");
    2121    debug("Test isPointInFill()");
    22     shouldBe("p1.isPointInFill({})", "true");
    23     shouldBe("p1.isPointInFill({x: 100, y: 0})", "true");
    24     shouldBe("p1.isPointInFill({x: 152, y: 0})", "false");
    25     shouldBe("p1.isPointInFill({x: 150, y: 50})", "true");
    26     shouldBe("p1.isPointInFill({x: 150, y: 100})", "true");
    27     shouldBe("p1.isPointInFill({x: 150, y: 101})", "false");
    28     shouldBe("p1.isPointInFill({x: 100, y: 100})", "true");
    29     shouldBe("p1.isPointInFill({x: 75, y: 50})", "true");
     22    shouldBeFalse("p1.isPointInFill({})");
     23    shouldBeFalse("p1.isPointInFill({x: 9, y: 9})");
     24    shouldBeTrue("p1.isPointInFill({x: 10, y: 10})");
     25    shouldBeFalse("p1.isPointInFill({x: 159, y: 9})");
     26    shouldBeTrue("p1.isPointInFill({x: 160, y: 10})");
     27    shouldBeFalse("p1.isPointInFill({x: 161, y: 110})");
     28    shouldBeTrue("p1.isPointInFill({x: 160, y: 109})");
     29    shouldBeFalse("p1.isPointInFill({x: 9, y: 109})");
     30    shouldBeTrue("p1.isPointInFill({x: 10, y: 110})");
    3031
    3132    debug("");
    3233    debug("Test isPointInStroke()");
    33     shouldBe("p1.isPointInStroke({x: 0, y: 0})", "false");
    34     shouldBe("p1.isPointInStroke({x: 20, y: 0})", "true");
    35     shouldBe("p1.isPointInStroke({x: 150, y: 0})", "true");
    36     shouldBe("p1.isPointInStroke({x: 150, y: 35})", "true");
    37     shouldBe("p1.isPointInStroke({x: 75, y: 50})", "false");
     34    shouldBeTrue("p1.isPointInStroke({x: 20, y: 20})");
     35    shouldBeFalse("p1.isPointInStroke({x: 21, y: 21})");
     36    shouldBeTrue("p1.isPointInStroke({x: 150, y:  20})");
     37    shouldBeFalse("p1.isPointInStroke({x: 149, y: 21})");
     38    shouldBeTrue("p1.isPointInStroke({x: 150, y: 100})");
     39    shouldBeFalse("p1.isPointInStroke({x: 149, y: 99})");
     40    shouldBeTrue("p1.isPointInStroke({x: 20, y: 100})");
     41    shouldBeFalse("p1.isPointInStroke({x: 21, y: 99})");
    3842
    3943    debug("");
     
    4347    debug("");
    4448    debug("Test getPointAtLength()");
    45     shouldBeCloseTo("p1.getPointAtLength(0).x", 0, 0.1);
    46     shouldBeCloseTo("p1.getPointAtLength(0).y", 0, 0.1);
    47     shouldBeCloseTo("p1.getPointAtLength(150).x", 150, 0.1);
    48     shouldBeCloseTo("p1.getPointAtLength(150).y", 0, 0.1);
    49     shouldBeCloseTo("p1.getPointAtLength(200).x", 150, 0.1);
    50     shouldBeCloseTo("p1.getPointAtLength(200).y", 50, 0.1);
    51     shouldBeCloseTo("p1.getPointAtLength(300).x", 100, 0.1);
    52     shouldBeCloseTo("p1.getPointAtLength(300).y", 100, 0.1);
    53     shouldBeCloseTo("p1.getPointAtLength(450).x", 0, 0.1);
    54     shouldBeCloseTo("p1.getPointAtLength(450).y", 50, 0.1);
     49    shouldBeCloseTo("p1.getPointAtLength(0).x", 10, 0.1);
     50    shouldBeCloseTo("p1.getPointAtLength(0).y", 10, 0.1);
     51    shouldBeCloseTo("p1.getPointAtLength(150).x", 160, 0.1);
     52    shouldBeCloseTo("p1.getPointAtLength(150).y", 10, 0.1);
     53    shouldBeCloseTo("p1.getPointAtLength(250).x", 160, 0.1);
     54    shouldBeCloseTo("p1.getPointAtLength(250).y", 110, 0.1);
     55    shouldBeCloseTo("p1.getPointAtLength(400).x", 10, 0.1);
     56    shouldBeCloseTo("p1.getPointAtLength(400).y", 110, 0.1);
     57    shouldBeCloseTo("p1.getPointAtLength(500).x", 10, 0.1);
     58    shouldBeCloseTo("p1.getPointAtLength(500).y", 10, 0.1);
    5559
    5660    finishJSTest();
  • trunk/LayoutTests/svg/dom/SVGGeometry-polyline-expected.txt

    r231955 r252563  
    66
    77Test isPointInFill()
    8 PASS p1.isPointInFill({}) is true
    9 PASS p1.isPointInFill({x: 100, y: 0}) is true
    10 PASS p1.isPointInFill({x: 152, y: 0}) is false
    11 PASS p1.isPointInFill({x: 150, y: 50}) is true
    12 PASS p1.isPointInFill({x: 150, y: 100}) is true
    13 PASS p1.isPointInFill({x: 150, y: 101}) is false
    14 PASS p1.isPointInFill({x: 100, y: 100}) is true
    15 PASS p1.isPointInFill({x: 75, y: 50}) is true
     8PASS p1.isPointInFill({}) is false
     9PASS p1.isPointInFill({x: 9, y: 9}) is false
     10PASS p1.isPointInFill({x: 10, y: 10}) is true
     11PASS p1.isPointInFill({x: 159, y: 9}) is false
     12PASS p1.isPointInFill({x: 160, y: 10}) is true
     13PASS p1.isPointInFill({x: 161, y: 110}) is false
     14PASS p1.isPointInFill({x: 160, y: 109}) is true
     15PASS p1.isPointInFill({x: 9, y: 109}) is false
     16PASS p1.isPointInFill({x: 10, y: 110}) is true
    1617
    1718Test isPointInStroke()
    18 PASS p1.isPointInStroke({x: 0, y: 0}) is false
    19 PASS p1.isPointInStroke({x: 20, y: 0}) is true
    20 PASS p1.isPointInStroke({x: 150, y: 0}) is true
    21 PASS p1.isPointInStroke({x: 150, y: 35}) is true
    22 PASS p1.isPointInStroke({x: 75, y: 50}) is false
     19PASS p1.isPointInStroke({x: 20, y: 20}) is true
     20PASS p1.isPointInStroke({x: 21, y: 21}) is false
     21PASS p1.isPointInStroke({x: 150, y:  20}) is true
     22PASS p1.isPointInStroke({x: 149, y: 21}) is false
     23PASS p1.isPointInStroke({x: 150, y: 100}) is true
     24PASS p1.isPointInStroke({x: 149, y: 99}) is false
     25PASS p1.isPointInStroke({x: 20, y: 100}) is true
     26PASS p1.isPointInStroke({x: 21, y: 99}) is false
    2327
    2428Test getTotalLength()
     
    2630
    2731Test getPointAtLength()
    28 PASS p1.getPointAtLength(0).x is within 0.1 of 0
    29 PASS p1.getPointAtLength(0).y is within 0.1 of 0
    30 PASS p1.getPointAtLength(150).x is within 0.1 of 150
    31 PASS p1.getPointAtLength(150).y is within 0.1 of 0
    32 PASS p1.getPointAtLength(200).x is within 0.1 of 150
    33 PASS p1.getPointAtLength(200).y is within 0.1 of 50
    34 PASS p1.getPointAtLength(300).x is within 0.1 of 100
    35 PASS p1.getPointAtLength(300).y is within 0.1 of 100
    36 PASS p1.getPointAtLength(450).x is within 0.1 of 0
    37 PASS p1.getPointAtLength(450).y is within 0.1 of 100
     32PASS p1.getPointAtLength(0).x is within 0.1 of 10
     33PASS p1.getPointAtLength(0).y is within 0.1 of 10
     34PASS p1.getPointAtLength(150).x is within 0.1 of 160
     35PASS p1.getPointAtLength(150).y is within 0.1 of 10
     36PASS p1.getPointAtLength(200).x is within 0.1 of 160
     37PASS p1.getPointAtLength(200).y is within 0.1 of 60
     38PASS p1.getPointAtLength(300).x is within 0.1 of 110
     39PASS p1.getPointAtLength(300).y is within 0.1 of 110
     40PASS p1.getPointAtLength(450).x is within 0.1 of 10
     41PASS p1.getPointAtLength(450).y is within 0.1 of 110
    3842PASS successfullyParsed is true
    3943
  • trunk/LayoutTests/svg/dom/SVGGeometry-polyline.xhtml

    r231955 r252563  
    55<body onload="run()">
    66<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="200" height="200">
    7     <polyline id="p1" points="0,0 150,0 150,100 0,100" fill="none" stroke="black" stroke-width="20" stroke-dashoffset="20" stroke-dasharray="20 20"/>
     7    <polyline id="p1" points="10,10 160,10 160,110 10,110" fill="none" stroke="black" stroke-width="20"/>
    88</svg>
    99<p id="description"></p>
     
    2020    debug("");
    2121    debug("Test isPointInFill()");
    22     shouldBe("p1.isPointInFill({})", "true");
    23     shouldBe("p1.isPointInFill({x: 100, y: 0})", "true");
    24     shouldBe("p1.isPointInFill({x: 152, y: 0})", "false");
    25     shouldBe("p1.isPointInFill({x: 150, y: 50})", "true");
    26     shouldBe("p1.isPointInFill({x: 150, y: 100})", "true");
    27     shouldBe("p1.isPointInFill({x: 150, y: 101})", "false");
    28     shouldBe("p1.isPointInFill({x: 100, y: 100})", "true");
    29     shouldBe("p1.isPointInFill({x: 75, y: 50})", "true");
     22    shouldBeFalse("p1.isPointInFill({})");
     23    shouldBeFalse("p1.isPointInFill({x: 9, y: 9})");
     24    shouldBeTrue("p1.isPointInFill({x: 10, y: 10})");
     25    shouldBeFalse("p1.isPointInFill({x: 159, y: 9})");
     26    shouldBeTrue("p1.isPointInFill({x: 160, y: 10})");
     27    shouldBeFalse("p1.isPointInFill({x: 161, y: 110})");
     28    shouldBeTrue("p1.isPointInFill({x: 160, y: 109})");
     29    shouldBeFalse("p1.isPointInFill({x: 9, y: 109})");
     30    shouldBeTrue("p1.isPointInFill({x: 10, y: 110})");
    3031
    3132    debug("");
    3233    debug("Test isPointInStroke()");
    33     shouldBe("p1.isPointInStroke({x: 0, y: 0})", "false");
    34     shouldBe("p1.isPointInStroke({x: 20, y: 0})", "true");
    35     shouldBe("p1.isPointInStroke({x: 150, y: 0})", "true");
    36     shouldBe("p1.isPointInStroke({x: 150, y: 35})", "true");
    37     shouldBe("p1.isPointInStroke({x: 75, y: 50})", "false");
     34    shouldBeTrue("p1.isPointInStroke({x: 20, y: 20})");
     35    shouldBeFalse("p1.isPointInStroke({x: 21, y: 21})");
     36    shouldBeTrue("p1.isPointInStroke({x: 150, y:  20})");
     37    shouldBeFalse("p1.isPointInStroke({x: 149, y: 21})");
     38    shouldBeTrue("p1.isPointInStroke({x: 150, y: 100})");
     39    shouldBeFalse("p1.isPointInStroke({x: 149, y: 99})");
     40    shouldBeTrue("p1.isPointInStroke({x: 20, y: 100})");
     41    shouldBeFalse("p1.isPointInStroke({x: 21, y: 99})");
    3842
    3943    debug("");
     
    4347    debug("");
    4448    debug("Test getPointAtLength()");
    45     shouldBeCloseTo("p1.getPointAtLength(0).x", 0, 0.1);
    46     shouldBeCloseTo("p1.getPointAtLength(0).y", 0, 0.1);
    47     shouldBeCloseTo("p1.getPointAtLength(150).x", 150, 0.1);
    48     shouldBeCloseTo("p1.getPointAtLength(150).y", 0, 0.1);
    49     shouldBeCloseTo("p1.getPointAtLength(200).x", 150, 0.1);
    50     shouldBeCloseTo("p1.getPointAtLength(200).y", 50, 0.1);
    51     shouldBeCloseTo("p1.getPointAtLength(300).x", 100, 0.1);
    52     shouldBeCloseTo("p1.getPointAtLength(300).y", 100, 0.1);
    53     shouldBeCloseTo("p1.getPointAtLength(450).x", 0, 0.1);
    54     shouldBeCloseTo("p1.getPointAtLength(450).y", 100, 0.1);
     49    shouldBeCloseTo("p1.getPointAtLength(0).x", 10, 0.1);
     50    shouldBeCloseTo("p1.getPointAtLength(0).y", 10, 0.1);
     51    shouldBeCloseTo("p1.getPointAtLength(150).x", 160, 0.1);
     52    shouldBeCloseTo("p1.getPointAtLength(150).y", 10, 0.1);
     53    shouldBeCloseTo("p1.getPointAtLength(200).x", 160, 0.1);
     54    shouldBeCloseTo("p1.getPointAtLength(200).y", 60, 0.1);
     55    shouldBeCloseTo("p1.getPointAtLength(300).x", 110, 0.1);
     56    shouldBeCloseTo("p1.getPointAtLength(300).y", 110, 0.1);
     57    shouldBeCloseTo("p1.getPointAtLength(450).x", 10, 0.1);
     58    shouldBeCloseTo("p1.getPointAtLength(450).y", 110, 0.1);
    5559
    5660    finishJSTest();
  • trunk/LayoutTests/svg/dom/SVGGeometry-rect-expected.txt

    r231955 r252563  
    77Test isPointInFill()
    88PASS r1.isPointInFill({}) is false
    9 PASS r1.isPointInFill({x: 48, y: 0}) is false
    10 PASS r1.isPointInFill({x: 52, y: 0}) is true
    11 PASS r1.isPointInFill({x: 98, y: 0}) is true
    12 PASS r1.isPointInFill({x: 102, y: 0}) is false
    13 PASS r1.isPointInFill({x: 150, y: 38}) is false
    14 PASS r1.isPointInFill({x: 150, y: 42}) is true
    15 PASS r1.isPointInFill({x: 150, y: 58}) is true
    16 PASS r1.isPointInFill({x: 150, y: 62}) is false
    17 PASS r1.isPointInFill({x: 48, y: 100}) is false
    18 PASS r1.isPointInFill({x: 52, y: 100}) is true
    19 PASS r1.isPointInFill({x: 98, y: 100}) is true
    20 PASS r1.isPointInFill({x: 102, y: 100}) is false
    21 PASS r1.isPointInFill({x: 0, y: 38}) is false
    22 PASS r1.isPointInFill({x: 0, y: 42}) is true
    23 PASS r1.isPointInFill({x: 0, y: 58}) is true
    24 PASS r1.isPointInFill({x: 0, y: 62}) is false
    25 PASS r1.isPointInFill({x: 75, y: 50}) is true
     9PASS r1.isPointInFill({x: 9, y: 9}) is false
     10PASS r1.isPointInFill({x: 10, y: 10}) is true
     11PASS r1.isPointInFill({x: 159, y: 9}) is false
     12PASS r1.isPointInFill({x: 160, y: 10}) is true
     13PASS r1.isPointInFill({x: 161, y: 110}) is false
     14PASS r1.isPointInFill({x: 160, y: 109}) is true
     15PASS r1.isPointInFill({x: 9, y: 109}) is false
     16PASS r1.isPointInFill({x: 10, y: 110}) is true
    2617
    2718Test isPointInStroke()
    28 PASS r1.isPointInStroke({x: 52, y: 0}) is false
    29 PASS r1.isPointInStroke({x: 72, y: 0}) is true
    30 PASS r1.isPointInStroke({x: 92, y: 0}) is false
    31 PASS r1.isPointInStroke({x: 112, y: 10}) is true
     19PASS r1.isPointInStroke({x: 20, y: 20}) is true
     20PASS r1.isPointInStroke({x: 21, y: 21}) is false
     21PASS r1.isPointInStroke({x: 150, y:  20}) is true
     22PASS r1.isPointInStroke({x: 149, y: 21}) is false
     23PASS r1.isPointInStroke({x: 150, y: 100}) is true
     24PASS r1.isPointInStroke({x: 149, y: 99}) is false
     25PASS r1.isPointInStroke({x: 20, y: 100}) is true
     26PASS r1.isPointInStroke({x: 21, y: 99}) is false
    3227
    3328Test getTotalLength()
    34 PASS r1.getTotalLength() is within 1 of 424
     29PASS r1.getTotalLength() is within 0.1 of 500
    3530
    3631Test getPointAtLength()
    37 PASS r1.getPointAtLength(0).x is within 1 of 50
    38 PASS r1.getPointAtLength(0).y is within 1 of 0
    39 PASS r1.getPointAtLength(25).x is within 1 of 75
    40 PASS r1.getPointAtLength(25).y is within 1 of 0
    41 PASS r1.getPointAtLength(200).x is within 3 of 112
    42 PASS r1.getPointAtLength(200).y is within 3 of 100
    43 PASS r1.getPointAtLength(300).x is within 3 of 14
    44 PASS r1.getPointAtLength(300).y is within 3 of 88
    45 PASS r1.getPointAtLength(400).x is within 3 of 27
    46 PASS r1.getPointAtLength(400).y is within 3 of 5
     32PASS r1.getPointAtLength(0).x is within 0.1 of 10
     33PASS r1.getPointAtLength(0).y is within 0.1 of 10
     34PASS r1.getPointAtLength(150).x is within 0.1 of 160
     35PASS r1.getPointAtLength(150).y is within 0.1 of 10
     36PASS r1.getPointAtLength(250).x is within 0.1 of 160
     37PASS r1.getPointAtLength(250).y is within 0.1 of 110
     38PASS r1.getPointAtLength(400).x is within 0.1 of 10
     39PASS r1.getPointAtLength(400).y is within 0.1 of 110
     40PASS r1.getPointAtLength(500).x is within 0.1 of 10
     41PASS r1.getPointAtLength(500).y is within 0.1 of 10
    4742PASS successfullyParsed is true
    4843
  • trunk/LayoutTests/svg/dom/SVGGeometry-rect.xhtml

    r231955 r252563  
    55<body onload="run()">
    66<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="200" height="200">
    7     <rect id="r1" rx="50" ry="40" width="150" height="100" fill="none" stroke="black" stroke-width="20" stroke-dashoffset="20" stroke-dasharray="20 20"/>
     7    <rect id="r1" x="10" y="10" width="150" height="100" fill="none" stroke="black" stroke-width="20"/>
    88</svg>
    99<p id="description"></p>
     
    2020    debug("");
    2121    debug("Test isPointInFill()");
    22     shouldBe("r1.isPointInFill({})", "false");
    23     shouldBe("r1.isPointInFill({x: 48, y: 0})", "false");
    24     shouldBe("r1.isPointInFill({x: 52, y: 0})", "true");
    25     shouldBe("r1.isPointInFill({x: 98, y: 0})", "true");
    26     shouldBe("r1.isPointInFill({x: 102, y: 0})", "false");
    27     shouldBe("r1.isPointInFill({x: 150, y: 38})", "false");
    28     shouldBe("r1.isPointInFill({x: 150, y: 42})", "true");
    29     shouldBe("r1.isPointInFill({x: 150, y: 58})", "true");
    30     shouldBe("r1.isPointInFill({x: 150, y: 62})", "false");
    31     shouldBe("r1.isPointInFill({x: 48, y: 100})", "false");
    32     shouldBe("r1.isPointInFill({x: 52, y: 100})", "true");
    33     shouldBe("r1.isPointInFill({x: 98, y: 100})", "true");
    34     shouldBe("r1.isPointInFill({x: 102, y: 100})", "false");
    35     shouldBe("r1.isPointInFill({x: 0, y: 38})", "false");
    36     shouldBe("r1.isPointInFill({x: 0, y: 42})", "true");
    37     shouldBe("r1.isPointInFill({x: 0, y: 58})", "true");
    38     shouldBe("r1.isPointInFill({x: 0, y: 62})", "false");
    39     shouldBe("r1.isPointInFill({x: 75, y: 50})", "true");
     22    shouldBeFalse("r1.isPointInFill({})");
     23    shouldBeFalse("r1.isPointInFill({x: 9, y: 9})");
     24    shouldBeTrue("r1.isPointInFill({x: 10, y: 10})");
     25    shouldBeFalse("r1.isPointInFill({x: 159, y: 9})");
     26    shouldBeTrue("r1.isPointInFill({x: 160, y: 10})");
     27    shouldBeFalse("r1.isPointInFill({x: 161, y: 110})");
     28    shouldBeTrue("r1.isPointInFill({x: 160, y: 109})");
     29    shouldBeFalse("r1.isPointInFill({x: 9, y: 109})");
     30    shouldBeTrue("r1.isPointInFill({x: 10, y: 110})");
    4031
    4132    debug("");
    4233    debug("Test isPointInStroke()");
    43     shouldBe("r1.isPointInStroke({x: 52, y: 0})", "false");
    44     shouldBe("r1.isPointInStroke({x: 72, y: 0})", "true");
    45     shouldBe("r1.isPointInStroke({x: 92, y: 0})", "false");
    46     shouldBe("r1.isPointInStroke({x: 112, y: 10})", "true");
     34    shouldBeTrue("r1.isPointInStroke({x: 20, y: 20})");
     35    shouldBeFalse("r1.isPointInStroke({x: 21, y: 21})");
     36    shouldBeTrue("r1.isPointInStroke({x: 150, y:  20})");
     37    shouldBeFalse("r1.isPointInStroke({x: 149, y: 21})");
     38    shouldBeTrue("r1.isPointInStroke({x: 150, y: 100})");
     39    shouldBeFalse("r1.isPointInStroke({x: 149, y: 99})");
     40    shouldBeTrue("r1.isPointInStroke({x: 20, y: 100})");
     41    shouldBeFalse("r1.isPointInStroke({x: 21, y: 99})");
    4742
    4843    debug("");
    4944    debug("Test getTotalLength()");
    50     shouldBeCloseTo("r1.getTotalLength()", 424, 1);
     45    shouldBeCloseTo("r1.getTotalLength()", 500, 0.1);
    5146
    5247    debug("");
    5348    debug("Test getPointAtLength()");
    54     shouldBeCloseTo("r1.getPointAtLength(0).x", 50, 1);
    55     shouldBeCloseTo("r1.getPointAtLength(0).y", 0, 1);
    56     shouldBeCloseTo("r1.getPointAtLength(25).x", 75, 1);
    57     shouldBeCloseTo("r1.getPointAtLength(25).y", 0, 1);
    58     shouldBeCloseTo("r1.getPointAtLength(200).x", 112, 3);
    59     shouldBeCloseTo("r1.getPointAtLength(200).y", 100, 3);
    60     shouldBeCloseTo("r1.getPointAtLength(300).x", 14, 3);
    61     shouldBeCloseTo("r1.getPointAtLength(300).y", 88, 3);
    62     shouldBeCloseTo("r1.getPointAtLength(400).x", 27, 3);
    63     shouldBeCloseTo("r1.getPointAtLength(400).y", 5, 3);
     49    shouldBeCloseTo("r1.getPointAtLength(0).x", 10, 0.1);
     50    shouldBeCloseTo("r1.getPointAtLength(0).y", 10, 0.1);
     51    shouldBeCloseTo("r1.getPointAtLength(150).x", 160, 0.1);
     52    shouldBeCloseTo("r1.getPointAtLength(150).y", 10, 0.1);
     53    shouldBeCloseTo("r1.getPointAtLength(250).x", 160, 0.1);
     54    shouldBeCloseTo("r1.getPointAtLength(250).y", 110, 0.1);
     55    shouldBeCloseTo("r1.getPointAtLength(400).x", 10, 0.1);
     56    shouldBeCloseTo("r1.getPointAtLength(400).y", 110, 0.1);
     57    shouldBeCloseTo("r1.getPointAtLength(500).x", 10, 0.1);
     58    shouldBeCloseTo("r1.getPointAtLength(500).y", 10, 0.1);
    6459
    6560    finishJSTest();
  • trunk/Source/WebCore/ChangeLog

    r252562 r252563  
     12019-11-18  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        Fix getTotalLength() and getPointAtLength() for optimized rect and ellipse renderers
     4        https://bugs.webkit.org/show_bug.cgi?id=204213
     5
     6        Reviewed by Simon Fraser.
     7
     8        If the renderer does not create a Path to draw the shape, we need to create
     9        a temporary Path from the SVGElement then use it to answer the questions
     10        of these functions and finally delete it.
     11
     12        * platform/graphics/Path.cpp:
     13        (WebCore::Path::traversalStateAtLength const):
     14        (WebCore::Path::pointAtLength const):
     15        No need for the 'success'. It is never used.
     16
     17        (WebCore::Path::normalAngleAtLength const): Deleted.
     18        This function is not used.
     19
     20        * platform/graphics/Path.h:
     21        * rendering/svg/RenderSVGShape.cpp:
     22        (WebCore::RenderSVGShape::updateShapeFromElement):
     23        Creating the Path from the SVGELement is moved to createPath().
     24
     25        (WebCore::RenderSVGShape::getTotalLength const):
     26        (WebCore::RenderSVGShape::getPointAtLength const):
     27        Create a temporary Path if the renderer draws the shape without creating
     28        the Path.
     29
     30        (WebCore::RenderSVGShape::createPath const):
     31        * rendering/svg/RenderSVGShape.h:
     32
     33        * rendering/svg/SVGTextLayoutEngine.cpp:
     34        (WebCore::SVGTextLayoutEngine::layoutTextOnLineOrPath):
     35        * svg/SVGAnimateMotionElement.cpp:
     36        (WebCore::SVGAnimateMotionElement::buildTransformForProgress):
     37        Use PathTraversalState.success() to check instead of getting the same
     38        value through an argument to traversalStateAtLength().
     39
    1402019-11-18  Zalan Bujtas  <zalan@apple.com>
    241
  • trunk/Source/WebCore/platform/graphics/Path.cpp

    r222253 r252563  
    5454#endif
    5555
    56 PathTraversalState Path::traversalStateAtLength(float length, bool& success) const
     56PathTraversalState Path::traversalStateAtLength(float length) const
    5757{
    5858    PathTraversalState traversalState(PathTraversalState::Action::VectorAtLength, length);
     
    6262    });
    6363
    64     success = traversalState.success();
    6564    return traversalState;
    6665}
    6766
    68 FloatPoint Path::pointAtLength(float length, bool& success) const
    69 {
    70     return traversalStateAtLength(length, success).current();
    71 }
    72 
    73 float Path::normalAngleAtLength(float length, bool& success) const
    74 {
    75     return traversalStateAtLength(length, success).normalAngle();
     67FloatPoint Path::pointAtLength(float length) const
     68{
     69    return traversalStateAtLength(length).current();
    7670}
    7771
  • trunk/Source/WebCore/platform/graphics/Path.h

    r250492 r252563  
    135135
    136136        float length() const;
    137         PathTraversalState traversalStateAtLength(float length, bool& success) const;
    138         FloatPoint pointAtLength(float length, bool& success) const;
    139         float normalAngleAtLength(float length, bool& success) const;
     137        PathTraversalState traversalStateAtLength(float length) const;
     138        FloatPoint pointAtLength(float length) const;
    140139
    141140        WEBCORE_EXPORT void clear();
  • trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp

    r252069 r252563  
    8080void RenderSVGShape::updateShapeFromElement()
    8181{
    82     m_path = makeUnique<Path>(pathFromGraphicsElement(&graphicsElement()));
     82    m_path = createPath();
    8383    processMarkerPositions();
    8484
     
    348348float RenderSVGShape::getTotalLength() const
    349349{
    350     if (m_path)
    351         return m_path->length();
    352 
    353     return 0;
     350    return hasPath() ? path().length() : createPath()->length();
    354351}
    355352
    356353FloatPoint RenderSVGShape::getPointAtLength(float distance) const
    357354{
    358     if (!m_path)
    359         return { };
    360 
    361     bool isValid;
    362     return m_path->pointAtLength(distance, isValid);
     355    return hasPath() ? path().pointAtLength(distance) : createPath()->pointAtLength(distance);
    363356}
    364357
     
    504497}
    505498
     499std::unique_ptr<Path> RenderSVGShape::createPath() const
     500{
     501    return makeUnique<Path>(pathFromGraphicsElement(&graphicsElement()));
     502}
     503
    506504void RenderSVGShape::processMarkerPositions()
    507505{
  • trunk/Source/WebCore/rendering/svg/RenderSVGShape.h

    r251877 r252563  
    123123    bool shouldGenerateMarkerPositions() const;
    124124    FloatRect markerRect(float strokeWidth) const;
     125   
     126    std::unique_ptr<Path> createPath() const;
    125127    void processMarkerPositions();
    126128
  • trunk/Source/WebCore/rendering/svg/SVGTextLayoutEngine.cpp

    r225117 r252563  
    532532                break;
    533533
    534             bool success = false;
    535             auto traversalState(m_textPath.traversalStateAtLength(textPathOffset, success));
    536             ASSERT(success);
     534            auto traversalState(m_textPath.traversalStateAtLength(textPathOffset));
     535            ASSERT(traversalState.success());
    537536
    538537            FloatPoint point = traversalState.current();
  • trunk/Source/WebCore/svg/SVGAnimateMotionElement.cpp

    r251809 r252563  
    191191    ASSERT(!m_animationPath.isEmpty());
    192192
    193     bool success = false;
    194193    float positionOnPath = m_animationPath.length() * percentage;
    195     auto traversalState(m_animationPath.traversalStateAtLength(positionOnPath, success));
    196     if (!success)
     194    auto traversalState(m_animationPath.traversalStateAtLength(positionOnPath));
     195    if (!traversalState.success())
    197196        return;
    198197
Note: See TracChangeset for help on using the changeset viewer.