Changeset 231739 in webkit
- Timestamp:
- May 13, 2018 2:25:44 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r231737 r231739 1 2018-05-13 Dirk Schulze <krit@webkit.org> 2 3 Implement SVGGeometryElement's isPointInFill and isPointInStroke 4 https://bugs.webkit.org/show_bug.cgi?id=185580 5 6 Reviewed by Antti Koivisto. 7 8 Implement isPointInFill and isPointInStroke methods for 9 SVGGeometryElement interface from SVG2. 10 11 https://svgwg.org/svg2-draft/types.html#InterfaceSVGGeometryElement 12 13 * svg/dom/SVGGeometry-isPointInFill-expected.txt: Added. 14 * svg/dom/SVGGeometry-isPointInFill.xhtml: Added. 15 * svg/dom/SVGGeometry-isPointInStroke-expected.txt: Added. 16 * svg/dom/SVGGeometry-isPointInStroke.xhtml: Added. 17 1 18 2018-05-12 Wenson Hsieh <wenson_hsieh@apple.com> 2 19 -
trunk/Source/WebCore/ChangeLog
r231735 r231739 1 2018-05-13 Dirk Schulze <krit@webkit.org> 2 3 Implement SVGGeometryElement's isPointInFill and isPointInStroke 4 https://bugs.webkit.org/show_bug.cgi?id=185580 5 6 Reviewed by Antti Koivisto. 7 8 Implement isPointInFill and isPointInStroke methods for 9 SVGGeometryElement interface from SVG2. 10 11 https://svgwg.org/svg2-draft/types.html#InterfaceSVGGeometryElement 12 13 Tests: svg/dom/SVGGeometry-isPointInFill.xhtml 14 svg/dom/SVGGeometry-isPointInStroke.xhtml 15 16 * rendering/svg/RenderSVGEllipse.cpp: 17 (WebCore::RenderSVGEllipse::shapeDependentStrokeContains): Flag 18 to switch between local and "global" coordinate space for hit testing. 19 * rendering/svg/RenderSVGEllipse.h: 20 * rendering/svg/RenderSVGPath.cpp: 21 (WebCore::RenderSVGPath::shapeDependentStrokeContains): Flag 22 to switch between local and "global" coordinate space for hit testing. 23 * rendering/svg/RenderSVGPath.h: 24 * rendering/svg/RenderSVGRect.cpp: 25 (WebCore::RenderSVGRect::shapeDependentStrokeContains): Flag 26 to switch between local and "global" coordinate space for hit testing. 27 * rendering/svg/RenderSVGRect.h: 28 * rendering/svg/RenderSVGShape.cpp: 29 (WebCore::RenderSVGShape::shapeDependentStrokeContains): Flag 30 to switch between local and "global" coordinate space for hit testing. 31 (WebCore::RenderSVGShape::isPointInFill): Take the winding rule given by 32 `fill-rule` to test if a given point is in the fill area of a path. 33 (WebCore::RenderSVGShape::isPointInStroke): Take stroke properties into 34 account to check if a point is on top of the stroke area. 35 * rendering/svg/RenderSVGShape.h: 36 * svg/SVGGeometryElement.cpp: 37 (WebCore::SVGGeometryElement::isPointInFill): 38 (WebCore::SVGGeometryElement::isPointInStroke): 39 (WebCore::SVGGeometryElement::createElementRenderer): Deleted. This is getting implemented 40 by inheriting classes. No need to create RenderSVGPath here. 41 * svg/SVGGeometryElement.h: 42 * svg/SVGGeometryElement.idl: 43 1 44 2018-05-12 Zalan Bujtas <zalan@apple.com> 2 45 -
trunk/Source/WebCore/rendering/svg/RenderSVGEllipse.cpp
r224537 r231739 114 114 } 115 115 116 bool RenderSVGEllipse::shapeDependentStrokeContains(const FloatPoint& point )116 bool RenderSVGEllipse::shapeDependentStrokeContains(const FloatPoint& point, PointCoordinateSpace pointCoordinateSpace) 117 117 { 118 118 // The optimized contains code below does not support non-smooth strokes so we need … … 121 121 if (!hasPath()) 122 122 RenderSVGShape::updateShapeFromElement(); 123 return RenderSVGShape::shapeDependentStrokeContains(point );123 return RenderSVGShape::shapeDependentStrokeContains(point, pointCoordinateSpace); 124 124 } 125 125 -
trunk/Source/WebCore/rendering/svg/RenderSVGEllipse.h
r224537 r231739 45 45 void fillShape(GraphicsContext&) const override; 46 46 void strokeShape(GraphicsContext&) const override; 47 bool shapeDependentStrokeContains(const FloatPoint& ) override;47 bool shapeDependentStrokeContains(const FloatPoint&, PointCoordinateSpace = GlobalCoordinateSpace) override; 48 48 bool shapeDependentFillContains(const FloatPoint&, const WindRule) const override; 49 49 void calculateRadiiAndCenter(); -
trunk/Source/WebCore/rendering/svg/RenderSVGPath.cpp
r224537 r231739 102 102 } 103 103 104 bool RenderSVGPath::shapeDependentStrokeContains(const FloatPoint& point )104 bool RenderSVGPath::shapeDependentStrokeContains(const FloatPoint& point, PointCoordinateSpace pointCoordinateSpace) 105 105 { 106 if (RenderSVGShape::shapeDependentStrokeContains(point ))106 if (RenderSVGShape::shapeDependentStrokeContains(point, pointCoordinateSpace)) 107 107 return true; 108 108 -
trunk/Source/WebCore/rendering/svg/RenderSVGPath.h
r224537 r231739 44 44 45 45 void strokeShape(GraphicsContext&) const override; 46 bool shapeDependentStrokeContains(const FloatPoint& ) override;46 bool shapeDependentStrokeContains(const FloatPoint&, PointCoordinateSpace = GlobalCoordinateSpace) override; 47 47 48 48 bool shouldStrokeZeroLengthSubpath() const; -
trunk/Source/WebCore/rendering/svg/RenderSVGRect.cpp
r224537 r231739 135 135 } 136 136 137 bool RenderSVGRect::shapeDependentStrokeContains(const FloatPoint& point )137 bool RenderSVGRect::shapeDependentStrokeContains(const FloatPoint& point, PointCoordinateSpace pointCoordinateSpace) 138 138 { 139 139 // The optimized contains code below does not support non-smooth strokes so we need … … 142 142 if (!hasPath()) 143 143 RenderSVGShape::updateShapeFromElement(); 144 return RenderSVGShape::shapeDependentStrokeContains(point );144 return RenderSVGShape::shapeDependentStrokeContains(point, pointCoordinateSpace); 145 145 } 146 146 -
trunk/Source/WebCore/rendering/svg/RenderSVGRect.h
r224537 r231739 51 51 void fillShape(GraphicsContext&) const override; 52 52 void strokeShape(GraphicsContext&) const override; 53 bool shapeDependentStrokeContains(const FloatPoint& ) override;53 bool shapeDependentStrokeContains(const FloatPoint&, PointCoordinateSpace = GlobalCoordinateSpace) override; 54 54 bool shapeDependentFillContains(const FloatPoint&, const WindRule) const override; 55 55 -
trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp
r224537 r231739 9 9 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> 10 10 * Copyright (C) 2011 University of Szeged 11 * Copyright (C) 2018 Adobe Systems Incorporated. All rights reserved. 11 12 * 12 13 * This library is free software; you can redistribute it and/or … … 111 112 } 112 113 113 bool RenderSVGShape::shapeDependentStrokeContains(const FloatPoint& point )114 bool RenderSVGShape::shapeDependentStrokeContains(const FloatPoint& point, PointCoordinateSpace pointCoordinateSpace) 114 115 { 115 116 ASSERT(m_path); 116 117 BoundingRectStrokeStyleApplier applier(*this); 117 118 118 if (hasNonScalingStroke() ) {119 if (hasNonScalingStroke() && pointCoordinateSpace != LocalCoordinateSpace) { 119 120 AffineTransform nonScalingTransform = nonScalingStrokeTransform(); 120 121 Path* usePath = nonScalingStrokePath(m_path.get(), nonScalingTransform); … … 332 333 } 333 334 335 bool RenderSVGShape::isPointInFill(const FloatPoint& point) 336 { 337 return shapeDependentFillContains(point, style().svgStyle().fillRule()); 338 } 339 340 bool RenderSVGShape::isPointInStroke(const FloatPoint& point) 341 { 342 if (!style().svgStyle().hasStroke()) 343 return false; 344 345 return shapeDependentStrokeContains(point, LocalCoordinateSpace); 346 } 347 334 348 bool RenderSVGShape::nodeAtFloatPoint(const HitTestRequest& request, HitTestResult& result, const FloatPoint& pointInParent, HitTestAction hitTestAction) 335 349 { -
trunk/Source/WebCore/rendering/svg/RenderSVGShape.h
r224537 r231739 46 46 WTF_MAKE_ISO_ALLOCATED(RenderSVGShape); 47 47 public: 48 enum PointCoordinateSpace { 49 GlobalCoordinateSpace, 50 LocalCoordinateSpace 51 }; 48 52 RenderSVGShape(SVGGraphicsElement&, RenderStyle&&); 49 53 virtual ~RenderSVGShape(); … … 58 62 virtual void strokeShape(GraphicsContext&) const; 59 63 virtual bool isRenderingDisabled() const = 0; 64 65 bool isPointInFill(const FloatPoint&); 66 bool isPointInStroke(const FloatPoint&); 60 67 61 68 bool hasPath() const { return m_path.get(); } … … 72 79 virtual void updateShapeFromElement(); 73 80 virtual bool isEmpty() const; 74 virtual bool shapeDependentStrokeContains(const FloatPoint& );81 virtual bool shapeDependentStrokeContains(const FloatPoint&, PointCoordinateSpace = GlobalCoordinateSpace); 75 82 virtual bool shapeDependentFillContains(const FloatPoint&, const WindRule) const; 76 83 float strokeWidth() const; -
trunk/Source/WebCore/svg/SVGGeometryElement.cpp
r230829 r231739 24 24 #include "SVGGeometryElement.h" 25 25 26 #include "DOMPoint.h" 26 27 #include "RenderSVGPath.h" 27 28 #include "RenderSVGResource.h" … … 50 51 { 51 52 registerAnimatedPropertiesForSVGGeometryElement(); 53 } 54 55 bool SVGGeometryElement::isPointInFill(DOMPointInit&& pointInit) 56 { 57 document().updateLayoutIgnorePendingStylesheets(); 58 59 auto* renderer = downcast<RenderSVGShape>(this->renderer()); 60 if (!renderer) 61 return false; 62 63 FloatPoint point {static_cast<float>(pointInit.x), static_cast<float>(pointInit.y)}; 64 return renderer->isPointInFill(point); 65 } 66 67 bool SVGGeometryElement::isPointInStroke(DOMPointInit&& pointInit) 68 { 69 document().updateLayoutIgnorePendingStylesheets(); 70 71 auto* renderer = downcast<RenderSVGShape>(this->renderer()); 72 if (!renderer) 73 return false; 74 75 FloatPoint point {static_cast<float>(pointInit.x), static_cast<float>(pointInit.y)}; 76 return renderer->isPointInStroke(point); 52 77 } 53 78 … … 88 113 } 89 114 90 RenderPtr<RenderElement> SVGGeometryElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)91 {92 return createRenderer<RenderSVGPath>(*this, WTFMove(style));93 115 } 94 95 } -
trunk/Source/WebCore/svg/SVGGeometryElement.h
r230829 r231739 31 31 namespace WebCore { 32 32 33 struct DOMPointInit; 33 34 class SVGPoint; 34 35 … … 39 40 virtual float getTotalLength() const = 0; 40 41 virtual Ref<SVGPoint> getPointAtLength(float distance) const = 0; 42 43 bool isPointInFill(DOMPointInit&&); 44 bool isPointInStroke(DOMPointInit&&); 41 45 42 46 protected: … … 50 54 DECLARE_ANIMATED_NUMBER(PathLength, pathLength) 51 55 END_DECLARE_ANIMATED_PROPERTIES 52 53 RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;54 56 }; 55 57 -
trunk/Source/WebCore/svg/SVGGeometryElement.idl
r230829 r231739 28 28 readonly attribute SVGAnimatedNumber pathLength; // FIXME: Should be [SameObject]. 29 29 30 // boolean isPointInFill(DOMPointInit point);31 // boolean isPointInStroke(DOMPointInit point);30 boolean isPointInFill(optional DOMPointInit point); 31 boolean isPointInStroke(optional DOMPointInit point); 32 32 unrestricted float getTotalLength(); 33 33 [NewObject] SVGPoint getPointAtLength(float distance);
Note: See TracChangeset
for help on using the changeset viewer.