Changeset 251877 in webkit
- Timestamp:
- Oct 31, 2019 2:08:59 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r251840 r251877 1 2019-10-31 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 SVGGeometryElement.getPointAtLength should clamp its argument to [0, length] 4 https://bugs.webkit.org/show_bug.cgi?id=203687 5 6 Reviewed by Simon Fraser. 7 8 * web-platform-tests/svg/types/scripted/SVGGeometryElement.getPointAtLength-01-expected.txt: 9 1 10 2019-10-31 Antoine Quint <graouts@apple.com> 2 11 -
trunk/LayoutTests/imported/w3c/web-platform-tests/svg/types/scripted/SVGGeometryElement.getPointAtLength-01-expected.txt
r251777 r251877 1 1 2 FAIL SVGGeometryElement.prototype.getPointAtLength clamps its argument to [0, length], less than zero (SVGLineElement). assert_equals: starting x expected 50 but got 40 3 FAIL SVGGeometryElement.prototype.getPointAtLength clamps its argument to [0, length], less than zero (SVGPathElement). assert_equals: starting x expected 40 but got 30 2 PASS SVGGeometryElement.prototype.getPointAtLength clamps its argument to [0, length], less than zero (SVGLineElement). 3 PASS SVGGeometryElement.prototype.getPointAtLength clamps its argument to [0, length], less than zero (SVGPathElement). 4 4 PASS SVGGeometryElement.prototype.getPointAtLength clamps its argument to [0, length], greater than 'length' (SVGLineElement). 5 5 PASS SVGGeometryElement.prototype.getPointAtLength clamps its argument to [0, length], greater than 'length' (SVGPathElement). -
trunk/Source/WebCore/ChangeLog
r251874 r251877 1 2019-10-31 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 SVGGeometryElement.getPointAtLength should clamp its argument to [0, length] 4 https://bugs.webkit.org/show_bug.cgi?id=203687 5 6 Reviewed by Simon Fraser. 7 8 The spec link is: 9 https://svgwg.org/svg2-draft/types.html#__svg__SVGGeometryElement__getPointAtLength 10 11 -- Fix the SVGGeometryElement.idl to match the specs. 12 -- Fix the path utility functions to return zeros in case of an error. 13 The callers never used the return values. 14 15 * rendering/svg/RenderSVGShape.cpp: 16 (WebCore::RenderSVGShape::getPointAtLength const): 17 * rendering/svg/RenderSVGShape.h: 18 * svg/SVGGeometryElement.cpp: 19 (WebCore::SVGGeometryElement::getPointAtLength const): 20 * svg/SVGGeometryElement.h: 21 * svg/SVGGeometryElement.idl: 22 * svg/SVGPathElement.cpp: 23 (WebCore::SVGPathElement::getTotalLength const): 24 (WebCore::SVGPathElement::getPointAtLength const): 25 (WebCore::SVGPathElement::getPathSegAtLength const): 26 * svg/SVGPathElement.h: 27 * svg/SVGPathUtilities.cpp: 28 (WebCore::getSVGPathSegAtLengthFromSVGPathByteStream): 29 (WebCore::getTotalLengthOfSVGPathByteStream): 30 (WebCore::getPointAtLengthOfSVGPathByteStream): 31 * svg/SVGPathUtilities.h: 32 1 33 2019-10-31 Zan Dobersek <zdobersek@igalia.com> and Chris Lord <clord@igalia.com> 2 34 -
trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp
r251444 r251877 354 354 } 355 355 356 void RenderSVGShape::getPointAtLength(FloatPoint& point,float distance) const356 FloatPoint RenderSVGShape::getPointAtLength(float distance) const 357 357 { 358 358 if (!m_path) 359 return ;359 return { }; 360 360 361 361 bool isValid; 362 point =m_path->pointAtLength(distance, isValid);362 return m_path->pointAtLength(distance, isValid); 363 363 } 364 364 -
trunk/Source/WebCore/rendering/svg/RenderSVGShape.h
r238071 r251877 67 67 68 68 float getTotalLength() const; 69 void getPointAtLength(FloatPoint&,float distance) const;69 FloatPoint getPointAtLength(float distance) const; 70 70 71 71 bool hasPath() const { return m_path.get(); } -
trunk/Source/WebCore/svg/SVGGeometryElement.cpp
r246490 r251877 56 56 } 57 57 58 Ref<SVGPoint> SVGGeometryElement::getPointAtLength(float distance) const58 ExceptionOr<Ref<SVGPoint>> SVGGeometryElement::getPointAtLength(float distance) const 59 59 { 60 FloatPoint point { };61 62 60 document().updateLayoutIgnorePendingStylesheets(); 63 61 64 62 auto* renderer = downcast<RenderSVGShape>(this->renderer()); 65 if (renderer) 66 renderer->getPointAtLength(point, distance); 63 64 // Spec: If current element is a non-rendered element, throw an InvalidStateError. 65 if (!renderer) 66 return Exception { InvalidStateError }; 67 68 // Spec: Clamp distance to [0, length]. 69 distance = clampTo<float>(distance, 0, getTotalLength()); 67 70 68 return SVGPoint::create(point); 71 // Spec: Return a newly created, detached SVGPoint object. 72 return SVGPoint::create(renderer->getPointAtLength(distance)); 69 73 } 70 74 -
trunk/Source/WebCore/svg/SVGGeometryElement.h
r246490 r251877 36 36 public: 37 37 virtual float getTotalLength() const; 38 virtual Ref<SVGPoint> getPointAtLength(float distance) const;38 virtual ExceptionOr<Ref<SVGPoint>> getPointAtLength(float distance) const; 39 39 40 40 bool isPointInFill(DOMPointInit&&); -
trunk/Source/WebCore/svg/SVGGeometryElement.idl
r231739 r251877 26 26 // [Exposed=Window] 27 27 interface SVGGeometryElement : SVGGraphicsElement { 28 readonly attribute SVGAnimatedNumber pathLength; // FIXME: Should be [SameObject].28 [SameObject] readonly attribute SVGAnimatedNumber pathLength; 29 29 30 30 boolean isPointInFill(optional DOMPointInit point); 31 31 boolean isPointInStroke(optional DOMPointInit point); 32 32 unrestricted float getTotalLength(); 33 [NewObject ] SVGPoint getPointAtLength(float distance);33 [NewObject, MayThrowException] SVGPoint getPointAtLength(float distance); 34 34 }; -
trunk/Source/WebCore/svg/SVGPathElement.cpp
r251318 r251877 107 107 float SVGPathElement::getTotalLength() const 108 108 { 109 float totalLength = 0; 110 getTotalLengthOfSVGPathByteStream(pathByteStream(), totalLength); 111 return totalLength; 109 return getTotalLengthOfSVGPathByteStream(pathByteStream()); 112 110 } 113 111 114 Ref<SVGPoint> SVGPathElement::getPointAtLength(float length) const112 ExceptionOr<Ref<SVGPoint>> SVGPathElement::getPointAtLength(float distance) const 115 113 { 116 FloatPoint point; 117 getPointAtLengthOfSVGPathByteStream(pathByteStream(), length, point); 118 return SVGPoint::create(point); 114 // Spec: Clamp distance to [0, length]. 115 distance = clampTo<float>(distance, 0, getTotalLength()); 116 117 // Spec: Return a newly created, detached SVGPoint object. 118 return SVGPoint::create(getPointAtLengthOfSVGPathByteStream(pathByteStream(), distance)); 119 119 } 120 120 121 121 unsigned SVGPathElement::getPathSegAtLength(float length) const 122 122 { 123 unsigned pathSeg = 0; 124 getSVGPathSegAtLengthFromSVGPathByteStream(pathByteStream(), length, pathSeg); 125 return pathSeg; 123 return getSVGPathSegAtLengthFromSVGPathByteStream(pathByteStream(), length); 126 124 } 127 125 -
trunk/Source/WebCore/svg/SVGPathElement.h
r251318 r251877 89 89 90 90 float getTotalLength() const final; 91 Ref<SVGPoint> getPointAtLength(float distance) const final;91 ExceptionOr<Ref<SVGPoint>> getPointAtLength(float distance) const final; 92 92 unsigned getPathSegAtLength(float distance) const; 93 93 -
trunk/Source/WebCore/svg/SVGPathUtilities.cpp
r246034 r251877 194 194 } 195 195 196 bool getSVGPathSegAtLengthFromSVGPathByteStream(const SVGPathByteStream& stream, float length, unsigned& pathSeg)197 { 198 if (stream.isEmpty()) 199 return false;196 unsigned getSVGPathSegAtLengthFromSVGPathByteStream(const SVGPathByteStream& stream, float length) 197 { 198 if (stream.isEmpty()) 199 return 0; 200 200 201 201 PathTraversalState traversalState(PathTraversalState::Action::SegmentAtLength); … … 203 203 204 204 SVGPathByteStreamSource source(stream); 205 bool ok = SVGPathParser::parse(source, builder); 206 pathSeg = builder.pathSegmentIndex(); 207 return ok; 208 } 209 210 bool getTotalLengthOfSVGPathByteStream(const SVGPathByteStream& stream, float& totalLength) 211 { 212 if (stream.isEmpty()) 213 return false; 205 SVGPathParser::parse(source, builder); 206 return builder.pathSegmentIndex(); 207 } 208 209 float getTotalLengthOfSVGPathByteStream(const SVGPathByteStream& stream) 210 { 211 if (stream.isEmpty()) 212 return 0; 214 213 215 214 PathTraversalState traversalState(PathTraversalState::Action::TotalLength); … … 218 217 219 218 SVGPathByteStreamSource source(stream); 220 bool ok = SVGPathParser::parse(source, builder); 221 totalLength = builder.totalLength(); 222 return ok; 223 } 224 225 bool getPointAtLengthOfSVGPathByteStream(const SVGPathByteStream& stream, float length, FloatPoint& point) 226 { 227 if (stream.isEmpty()) 228 return false; 219 SVGPathParser::parse(source, builder); 220 return builder.totalLength(); 221 } 222 223 FloatPoint getPointAtLengthOfSVGPathByteStream(const SVGPathByteStream& stream, float length) 224 { 225 if (stream.isEmpty()) 226 return { }; 229 227 230 228 PathTraversalState traversalState(PathTraversalState::Action::VectorAtLength); … … 233 231 234 232 SVGPathByteStreamSource source(stream); 235 bool ok = SVGPathParser::parse(source, builder); 236 point = builder.currentPoint(); 237 return ok; 238 } 239 240 } 233 SVGPathParser::parse(source, builder); 234 return builder.currentPoint(); 235 } 236 237 } -
trunk/Source/WebCore/svg/SVGPathUtilities.h
r243555 r251877 54 54 bool addToSVGPathByteStream(SVGPathByteStream& streamToAppendTo, const SVGPathByteStream& from, unsigned repeatCount = 1); 55 55 56 bool getSVGPathSegAtLengthFromSVGPathByteStream(const SVGPathByteStream&, float length, unsigned& pathSeg);57 bool getTotalLengthOfSVGPathByteStream(const SVGPathByteStream&, float& totalLength);58 bool getPointAtLengthOfSVGPathByteStream(const SVGPathByteStream&, float length, FloatPoint&);56 unsigned getSVGPathSegAtLengthFromSVGPathByteStream(const SVGPathByteStream&, float length); 57 float getTotalLengthOfSVGPathByteStream(const SVGPathByteStream&); 58 FloatPoint getPointAtLengthOfSVGPathByteStream(const SVGPathByteStream&, float length); 59 59 60 60 } // namespace WebCore
Note: See TracChangeset
for help on using the changeset viewer.