Diff
Modified: trunk/Source/WebCore/ChangeLog (253915 => 253916)
--- trunk/Source/WebCore/ChangeLog 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/ChangeLog 2019-12-26 19:01:03 UTC (rev 253916)
@@ -1,3 +1,68 @@
+2019-12-26 Wenson Hsieh <[email protected]>
+
+ Minor code cleanup around WebCore::Path
+ https://bugs.webkit.org/show_bug.cgi?id=205574
+
+ Reviewed by Anders Carlsson.
+
+ Carry out some minor refactoring in WebCore::Path:
+ - Change PathElementType into an 8-bit-wide enum class, and move it under PathElement's namespace as simply Type.
+ - Change PathElement's `FloatPoint*` that points to an array of 3 FloatPoints into a `FloatPoint[3]`.
+ - Change Path::strokeContains() to take a `StrokeStyleApplier&` instead of a `StrokeStyleApplier*`, since it
+ assumes that the given `StrokeStyleApplier` is nonnull anyways.
+ - Change Path::RoundedRectStrategy into an 8-bit enum class.
+ - Other miscellaneous style fixes.
+
+ No change in behavior.
+
+ * accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
+ (convertPathToScreenSpaceFunction):
+ * html/canvas/CanvasRenderingContext2DBase.cpp:
+ (WebCore::CanvasRenderingContext2DBase::isPointInStrokeInternal):
+ * inspector/InspectorOverlay.cpp:
+ (WebCore::drawShapeHighlight):
+ * platform/graphics/FontCascade.cpp:
+ (WebCore::findPathIntersections):
+ * platform/graphics/Path.cpp:
+ (WebCore::Path::addRoundedRect):
+ (WebCore::operator<<):
+ * platform/graphics/Path.h:
+ (WebCore::Path::encode const):
+ (WebCore::Path::decode):
+ * platform/graphics/PathTraversalState.cpp:
+ (WebCore::PathTraversalState::appendPathElement):
+ (WebCore::PathTraversalState::processPathElement):
+ * platform/graphics/PathTraversalState.h:
+ * platform/graphics/cairo/PathCairo.cpp:
+ (WebCore::Path::strokeContains const):
+ (WebCore::Path::apply const):
+ * platform/graphics/cg/PathCG.cpp:
+ (WebCore::Path::strokeContains const):
+ (WebCore::CGPathApplierToPathApplier):
+ * platform/graphics/win/PathDirect2D.cpp:
+ (WebCore::Path::strokeContains const):
+ * rendering/shapes/BoxShape.cpp:
+ (WebCore::BoxShape::buildDisplayPaths const):
+ * rendering/shapes/RectangleShape.cpp:
+ (WebCore::RectangleShape::buildDisplayPaths const):
+ * rendering/svg/RenderSVGShape.cpp:
+ (WebCore::RenderSVGShape::shapeDependentStrokeContains):
+ * rendering/svg/SVGMarkerData.h:
+ (WebCore::SVGMarkerData::updateMarkerDataForPathElement):
+ * rendering/svg/SVGPathData.cpp:
+ (WebCore::pathFromRectElement):
+ * rendering/svg/SVGSubpathData.h:
+ (WebCore::SVGSubpathData::updateFromPathElement):
+ * svg/SVGPathTraversalStateBuilder.cpp:
+ (WebCore::SVGPathTraversalStateBuilder::moveTo):
+ (WebCore::SVGPathTraversalStateBuilder::lineTo):
+ (WebCore::SVGPathTraversalStateBuilder::curveToCubic):
+ (WebCore::SVGPathTraversalStateBuilder::closePath):
+ * svg/SVGPathUtilities.cpp:
+ (WebCore::buildStringFromPath):
+ * testing/Internals.cpp:
+ (WebCore::Internals::pathStringWithShrinkWrappedRects):
+
2019-12-26 Zalan Bujtas <[email protected]>
[LFC][IFC] When align the inline content we need to align the line as well
Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm (253915 => 253916)
--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm 2019-12-26 19:01:03 UTC (rev 253916)
@@ -367,7 +367,7 @@
CGMutablePathRef newPath = conversion.path;
FloatRect rect;
switch (element.type) {
- case PathElementMoveToPoint:
+ case PathElement::Type::MoveToPoint:
{
rect = FloatRect(element.points[0], FloatSize());
CGPoint newPoint = [wrapper convertRectToSpace:rect space:AccessibilityConversionSpace::Screen].origin;
@@ -374,7 +374,7 @@
CGPathMoveToPoint(newPath, nil, newPoint.x, newPoint.y);
break;
}
- case PathElementAddLineToPoint:
+ case PathElement::Type::AddLineToPoint:
{
rect = FloatRect(element.points[0], FloatSize());
CGPoint newPoint = [wrapper convertRectToSpace:rect space:AccessibilityConversionSpace::Screen].origin;
@@ -381,7 +381,7 @@
CGPathAddLineToPoint(newPath, nil, newPoint.x, newPoint.y);
break;
}
- case PathElementAddQuadCurveToPoint:
+ case PathElement::Type::AddQuadCurveToPoint:
{
rect = FloatRect(element.points[0], FloatSize());
CGPoint newPoint1 = [wrapper convertRectToSpace:rect space:AccessibilityConversionSpace::Screen].origin;
@@ -391,7 +391,7 @@
CGPathAddQuadCurveToPoint(newPath, nil, newPoint1.x, newPoint1.y, newPoint2.x, newPoint2.y);
break;
}
- case PathElementAddCurveToPoint:
+ case PathElement::Type::AddCurveToPoint:
{
rect = FloatRect(element.points[0], FloatSize());
CGPoint newPoint1 = [wrapper convertRectToSpace:rect space:AccessibilityConversionSpace::Screen].origin;
@@ -404,7 +404,7 @@
CGPathAddCurveToPoint(newPath, nil, newPoint1.x, newPoint1.y, newPoint2.x, newPoint2.y, newPoint3.x, newPoint3.y);
break;
}
- case PathElementCloseSubpath:
+ case PathElement::Type::CloseSubpath:
{
CGPathCloseSubpath(newPath);
break;
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp (253915 => 253916)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp 2019-12-26 19:01:03 UTC (rev 253916)
@@ -1216,7 +1216,7 @@
return false;
CanvasStrokeStyleApplier applier(this);
- return path.strokeContains(&applier, transformedPoint);
+ return path.strokeContains(applier, transformedPoint);
}
void CanvasRenderingContext2DBase::clearRect(float x, float y, float width, float height)
Modified: trunk/Source/WebCore/inspector/InspectorOverlay.cpp (253915 => 253916)
--- trunk/Source/WebCore/inspector/InspectorOverlay.cpp 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/inspector/InspectorOverlay.cpp 2019-12-26 19:01:03 UTC (rev 253916)
@@ -315,23 +315,23 @@
};
switch (pathElement.type) {
- case PathElementMoveToPoint:
+ case PathElement::Type::MoveToPoint:
newPath.moveTo(localToRoot(0));
break;
- case PathElementAddLineToPoint:
+ case PathElement::Type::AddLineToPoint:
newPath.addLineTo(localToRoot(0));
break;
- case PathElementAddCurveToPoint:
+ case PathElement::Type::AddCurveToPoint:
newPath.addBezierCurveTo(localToRoot(0), localToRoot(1), localToRoot(2));
break;
- case PathElementAddQuadCurveToPoint:
+ case PathElement::Type::AddQuadCurveToPoint:
newPath.addQuadCurveTo(localToRoot(0), localToRoot(1));
break;
- case PathElementCloseSubpath:
+ case PathElement::Type::CloseSubpath:
newPath.closeSubpath();
break;
}
Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (253915 => 253916)
--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2019-12-26 19:01:03 UTC (rev 253916)
@@ -1706,23 +1706,23 @@
bool doIntersection = false;
FloatPoint point = FloatPoint();
switch (element.type) {
- case PathElementMoveToPoint:
+ case PathElement::Type::MoveToPoint:
state.startingPoint = element.points[0];
state.currentPoint = element.points[0];
break;
- case PathElementAddLineToPoint:
+ case PathElement::Type::AddLineToPoint:
doIntersection = true;
point = element.points[0];
break;
- case PathElementAddQuadCurveToPoint:
+ case PathElement::Type::AddQuadCurveToPoint:
doIntersection = true;
point = element.points[1];
break;
- case PathElementAddCurveToPoint:
+ case PathElement::Type::AddCurveToPoint:
doIntersection = true;
point = element.points[2];
break;
- case PathElementCloseSubpath:
+ case PathElement::Type::CloseSubpath:
doIntersection = true;
point = state.startingPoint;
break;
Modified: trunk/Source/WebCore/platform/graphics/Path.cpp (253915 => 253916)
--- trunk/Source/WebCore/platform/graphics/Path.cpp 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/platform/graphics/Path.cpp 2019-12-26 19:01:03 UTC (rev 253916)
@@ -111,7 +111,7 @@
return;
}
- if (strategy == PreferNativeRoundedRect) {
+ if (strategy == RoundedRectStrategy::PreferNative) {
#if USE(CG) || USE(DIRECT2D)
platformAddPathForRoundedRect(rect, radii.topLeft(), radii.topRight(), radii.bottomLeft(), radii.bottomRight());
return;
@@ -192,19 +192,19 @@
stream << ", ";
isFirst = false;
switch (element.type) {
- case PathElementMoveToPoint: // The points member will contain 1 value.
+ case PathElement::Type::MoveToPoint: // The points member will contain 1 value.
stream << "move to " << element.points[0];
break;
- case PathElementAddLineToPoint: // The points member will contain 1 value.
+ case PathElement::Type::AddLineToPoint: // The points member will contain 1 value.
stream << "add line to " << element.points[0];
break;
- case PathElementAddQuadCurveToPoint: // The points member will contain 2 values.
+ case PathElement::Type::AddQuadCurveToPoint: // The points member will contain 2 values.
stream << "add quad curve to " << element.points[0] << " " << element.points[1];
break;
- case PathElementAddCurveToPoint: // The points member will contain 3 values.
+ case PathElement::Type::AddCurveToPoint: // The points member will contain 3 values.
stream << "add curve to " << element.points[0] << " " << element.points[1] << " " << element.points[2];
break;
- case PathElementCloseSubpath: // The points member will contain no values.
+ case PathElement::Type::CloseSubpath: // The points member will contain no values.
stream << "close subpath";
break;
}
Modified: trunk/Source/WebCore/platform/graphics/Path.h (253915 => 253916)
--- trunk/Source/WebCore/platform/graphics/Path.h 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/platform/graphics/Path.h 2019-12-26 19:01:03 UTC (rev 253916)
@@ -91,20 +91,20 @@
class RoundedRect;
class StrokeStyleApplier;
-enum PathElementType {
- PathElementMoveToPoint, // The points member will contain 1 value.
- PathElementAddLineToPoint, // The points member will contain 1 value.
- PathElementAddQuadCurveToPoint, // The points member will contain 2 values.
- PathElementAddCurveToPoint, // The points member will contain 3 values.
- PathElementCloseSubpath // The points member will contain no values.
-};
-
// The points in the structure are the same as those that would be used with the
// add... method. For example, a line returns the endpoint, while a cubic returns
// two tangent points and the endpoint.
struct PathElement {
- PathElementType type;
- FloatPoint* points;
+ enum class Type : uint8_t {
+ MoveToPoint, // The points member will contain 1 value.
+ AddLineToPoint, // The points member will contain 1 value.
+ AddQuadCurveToPoint, // The points member will contain 2 values.
+ AddCurveToPoint, // The points member will contain 3 values.
+ CloseSubpath // The points member will contain no values.
+ };
+
+ FloatPoint points[3];
+ Type type;
};
using PathApplierFunction = WTF::Function<void(const PathElement&)>;
@@ -126,7 +126,7 @@
static Path polygonPathFromPoints(const Vector<FloatPoint>&);
bool contains(const FloatPoint&, WindRule = WindRule::NonZero) const;
- bool strokeContains(StrokeStyleApplier*, const FloatPoint&) const;
+ bool strokeContains(StrokeStyleApplier&, const FloatPoint&) const;
// fastBoundingRect() should equal or contain boundingRect(); boundingRect()
// should perfectly bound the points within the path.
FloatRect boundingRect() const;
@@ -157,13 +157,13 @@
void addEllipse(FloatPoint, float radiusX, float radiusY, float rotation, float startAngle, float endAngle, bool anticlockwise);
void addEllipse(const FloatRect&);
- enum RoundedRectStrategy {
- PreferNativeRoundedRect,
- PreferBezierRoundedRect
+ enum class RoundedRectStrategy : uint8_t {
+ PreferNative,
+ PreferBezier
};
- WEBCORE_EXPORT void addRoundedRect(const FloatRect&, const FloatSize& roundingRadii, RoundedRectStrategy = PreferNativeRoundedRect);
- WEBCORE_EXPORT void addRoundedRect(const FloatRoundedRect&, RoundedRectStrategy = PreferNativeRoundedRect);
+ WEBCORE_EXPORT void addRoundedRect(const FloatRect&, const FloatSize& roundingRadii, RoundedRectStrategy = RoundedRectStrategy::PreferNative);
+ WEBCORE_EXPORT void addRoundedRect(const FloatRoundedRect&, RoundedRectStrategy = RoundedRectStrategy::PreferNative);
void addRoundedRect(const RoundedRect&);
void addPath(const Path&, const AffineTransform&);
@@ -239,22 +239,22 @@
encoder.encodeEnum(element.type);
switch (element.type) {
- case PathElementMoveToPoint:
+ case PathElement::Type::MoveToPoint:
encoder << element.points[0];
break;
- case PathElementAddLineToPoint:
+ case PathElement::Type::AddLineToPoint:
encoder << element.points[0];
break;
- case PathElementAddQuadCurveToPoint:
+ case PathElement::Type::AddQuadCurveToPoint:
encoder << element.points[0];
encoder << element.points[1];
break;
- case PathElementAddCurveToPoint:
+ case PathElement::Type::AddCurveToPoint:
encoder << element.points[0];
encoder << element.points[1];
encoder << element.points[2];
break;
- case PathElementCloseSubpath:
+ case PathElement::Type::CloseSubpath:
break;
}
});
@@ -270,12 +270,12 @@
path.clear();
for (uint64_t i = 0; i < numPoints; ++i) {
- PathElementType elementType;
+ PathElement::Type elementType;
if (!decoder.decodeEnum(elementType))
return WTF::nullopt;
switch (elementType) {
- case PathElementMoveToPoint: {
+ case PathElement::Type::MoveToPoint: {
FloatPoint point;
if (!decoder.decode(point))
return WTF::nullopt;
@@ -282,7 +282,7 @@
path.moveTo(point);
break;
}
- case PathElementAddLineToPoint: {
+ case PathElement::Type::AddLineToPoint: {
FloatPoint point;
if (!decoder.decode(point))
return WTF::nullopt;
@@ -289,7 +289,7 @@
path.addLineTo(point);
break;
}
- case PathElementAddQuadCurveToPoint: {
+ case PathElement::Type::AddQuadCurveToPoint: {
FloatPoint controlPoint;
if (!decoder.decode(controlPoint))
return WTF::nullopt;
@@ -301,7 +301,7 @@
path.addQuadCurveTo(controlPoint, endPoint);
break;
}
- case PathElementAddCurveToPoint: {
+ case PathElement::Type::AddCurveToPoint: {
FloatPoint controlPoint1;
if (!decoder.decode(controlPoint1))
return WTF::nullopt;
@@ -317,7 +317,7 @@
path.addBezierCurveTo(controlPoint1, controlPoint2, endPoint);
break;
}
- case PathElementCloseSubpath:
+ case PathElement::Type::CloseSubpath:
path.closeSubpath();
break;
}
Modified: trunk/Source/WebCore/platform/graphics/PathTraversalState.cpp (253915 => 253916)
--- trunk/Source/WebCore/platform/graphics/PathTraversalState.cpp 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/platform/graphics/PathTraversalState.cpp 2019-12-26 19:01:03 UTC (rev 253916)
@@ -243,22 +243,22 @@
return m_success;
}
-bool PathTraversalState::appendPathElement(PathElementType type, const FloatPoint* points)
+bool PathTraversalState::appendPathElement(PathElement::Type type, const FloatPoint* points)
{
switch (type) {
- case PathElementMoveToPoint:
+ case PathElement::Type::MoveToPoint:
moveTo(points[0]);
break;
- case PathElementAddLineToPoint:
+ case PathElement::Type::AddLineToPoint:
lineTo(points[0]);
break;
- case PathElementAddQuadCurveToPoint:
+ case PathElement::Type::AddQuadCurveToPoint:
quadraticBezierTo(points[0], points[1]);
break;
- case PathElementAddCurveToPoint:
+ case PathElement::Type::AddCurveToPoint:
cubicBezierTo(points[0], points[1], points[2]);
break;
- case PathElementCloseSubpath:
+ case PathElement::Type::CloseSubpath:
closeSubpath();
break;
}
@@ -266,7 +266,7 @@
return finalizeAppendPathElement();
}
-bool PathTraversalState::processPathElement(PathElementType type, const FloatPoint* points)
+bool PathTraversalState::processPathElement(PathElement::Type type, const FloatPoint* points)
{
if (m_success)
return true;
Modified: trunk/Source/WebCore/platform/graphics/PathTraversalState.h (253915 => 253916)
--- trunk/Source/WebCore/platform/graphics/PathTraversalState.h 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/platform/graphics/PathTraversalState.h 2019-12-26 19:01:03 UTC (rev 253916)
@@ -43,7 +43,7 @@
PathTraversalState(Action, float desiredLength = 0);
public:
- bool processPathElement(PathElementType, const FloatPoint*);
+ bool processPathElement(PathElement::Type, const FloatPoint*);
bool processPathElement(const PathElement& element) { return processPathElement(element.type, element.points); }
Action action() const { return m_action; }
@@ -65,7 +65,7 @@
void cubicBezierTo(const FloatPoint&, const FloatPoint&, const FloatPoint&);
bool finalizeAppendPathElement();
- bool appendPathElement(PathElementType, const FloatPoint*);
+ bool appendPathElement(PathElement::Type, const FloatPoint*);
private:
Action m_action;
Modified: trunk/Source/WebCore/platform/graphics/cairo/PathCairo.cpp (253915 => 253916)
--- trunk/Source/WebCore/platform/graphics/cairo/PathCairo.cpp 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/platform/graphics/cairo/PathCairo.cpp 2019-12-26 19:01:03 UTC (rev 253916)
@@ -394,16 +394,15 @@
return contains;
}
-bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const
+bool Path::strokeContains(StrokeStyleApplier& applier, const FloatPoint& point) const
{
if (isNull())
return false;
- ASSERT(applier);
cairo_t* cr = platformPath()->context();
{
- GraphicsContext gc(GraphicsContextImplCairo::createFactory(cr));
- applier->strokeStyle(&gc);
+ GraphicsContext graphicsContext(GraphicsContextImplCairo::createFactory(cr));
+ applier.strokeStyle(&graphicsContext);
}
return cairo_in_stroke(cr, point.x(), point.y());
@@ -417,33 +416,31 @@
cairo_t* cr = platformPath()->context();
auto pathCopy = cairo_copy_path(cr);
cairo_path_data_t* data;
- PathElement pelement;
- FloatPoint points[3];
- pelement.points = points;
+ PathElement pathElement;
for (int i = 0; i < pathCopy->num_data; i += pathCopy->data[i].header.length) {
data = ""
switch (data->header.type) {
case CAIRO_PATH_MOVE_TO:
- pelement.type = PathElementMoveToPoint;
- pelement.points[0] = FloatPoint(data[1].point.x,data[1].point.y);
- function(pelement);
+ pathElement.type = PathElement::Type::MoveToPoint;
+ pathElement.points[0] = FloatPoint(data[1].point.x, data[1].point.y);
+ function(pathElement);
break;
case CAIRO_PATH_LINE_TO:
- pelement.type = PathElementAddLineToPoint;
- pelement.points[0] = FloatPoint(data[1].point.x,data[1].point.y);
- function(pelement);
+ pathElement.type = PathElement::Type::AddLineToPoint;
+ pathElement.points[0] = FloatPoint(data[1].point.x, data[1].point.y);
+ function(pathElement);
break;
case CAIRO_PATH_CURVE_TO:
- pelement.type = PathElementAddCurveToPoint;
- pelement.points[0] = FloatPoint(data[1].point.x,data[1].point.y);
- pelement.points[1] = FloatPoint(data[2].point.x,data[2].point.y);
- pelement.points[2] = FloatPoint(data[3].point.x,data[3].point.y);
- function(pelement);
+ pathElement.type = PathElement::Type::AddCurveToPoint;
+ pathElement.points[0] = FloatPoint(data[1].point.x, data[1].point.y);
+ pathElement.points[1] = FloatPoint(data[2].point.x, data[2].point.y);
+ pathElement.points[2] = FloatPoint(data[3].point.x, data[3].point.y);
+ function(pathElement);
break;
case CAIRO_PATH_CLOSE_PATH:
- pelement.type = PathElementCloseSubpath;
- function(pelement);
+ pathElement.type = PathElement::Type::CloseSubpath;
+ function(pathElement);
break;
}
}
Modified: trunk/Source/WebCore/platform/graphics/cg/PathCG.cpp (253915 => 253916)
--- trunk/Source/WebCore/platform/graphics/cg/PathCG.cpp 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/platform/graphics/cg/PathCG.cpp 2019-12-26 19:01:03 UTC (rev 253916)
@@ -185,13 +185,11 @@
return ret;
}
-bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const
+bool Path::strokeContains(StrokeStyleApplier& applier, const FloatPoint& point) const
{
if (isNull())
return false;
- ASSERT(applier);
-
CGContextRef context = scratchContext();
CGContextSaveGState(context);
@@ -198,8 +196,8 @@
CGContextBeginPath(context);
CGContextAddPath(context, platformPath());
- GraphicsContext gc(context);
- applier->strokeStyle(&gc);
+ GraphicsContext graphicsContext(context);
+ applier.strokeStyle(&graphicsContext);
bool hitSuccess = CGContextPathContainsPoint(context, point, kCGPathStroke);
CGContextRestoreGState(context);
@@ -429,29 +427,27 @@
static void CGPathApplierToPathApplier(void* info, const CGPathElement* element)
{
const PathApplierFunction& function = *(PathApplierFunction*)info;
- FloatPoint points[3];
- PathElement pelement;
- pelement.type = (PathElementType)element->type;
- pelement.points = points;
+ PathElement pathElement;
+ pathElement.type = (PathElement::Type)element->type;
CGPoint* cgPoints = element->points;
switch (element->type) {
case kCGPathElementMoveToPoint:
case kCGPathElementAddLineToPoint:
- points[0] = cgPoints[0];
+ pathElement.points[0] = cgPoints[0];
break;
case kCGPathElementAddQuadCurveToPoint:
- points[0] = cgPoints[0];
- points[1] = cgPoints[1];
+ pathElement.points[0] = cgPoints[0];
+ pathElement.points[1] = cgPoints[1];
break;
case kCGPathElementAddCurveToPoint:
- points[0] = cgPoints[0];
- points[1] = cgPoints[1];
- points[2] = cgPoints[2];
+ pathElement.points[0] = cgPoints[0];
+ pathElement.points[1] = cgPoints[1];
+ pathElement.points[2] = cgPoints[2];
break;
case kCGPathElementCloseSubpath:
break;
}
- function(pelement);
+ function(pathElement);
}
void Path::apply(const PathApplierFunction& function) const
Modified: trunk/Source/WebCore/platform/graphics/win/PathDirect2D.cpp (253915 => 253916)
--- trunk/Source/WebCore/platform/graphics/win/PathDirect2D.cpp 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/platform/graphics/win/PathDirect2D.cpp 2019-12-26 19:01:03 UTC (rev 253916)
@@ -225,16 +225,14 @@
return contains;
}
-bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const
+bool Path::strokeContains(StrokeStyleApplier& applier, const FloatPoint& point) const
{
if (isNull())
return false;
- ASSERT(applier);
-
PlatformContextDirect2D scratchContextD2D(scratchRenderTarget());
GraphicsContext scratchContext(&scratchContextD2D, GraphicsContext::BitmapRenderingContextType::GPUMemory);
- applier->strokeStyle(&scratchContext);
+ applier.strokeStyle(&scratchContext);
#if !ASSERT_DISABLED
unsigned before = refCount(m_path.get());
Modified: trunk/Source/WebCore/rendering/shapes/BoxShape.cpp (253915 => 253916)
--- trunk/Source/WebCore/rendering/shapes/BoxShape.cpp 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/rendering/shapes/BoxShape.cpp 2019-12-26 19:01:03 UTC (rev 253916)
@@ -159,9 +159,9 @@
void BoxShape::buildDisplayPaths(DisplayPaths& paths) const
{
- paths.shape.addRoundedRect(m_bounds, Path::PreferBezierRoundedRect);
+ paths.shape.addRoundedRect(m_bounds, Path::RoundedRectStrategy::PreferBezier);
if (shapeMargin())
- paths.marginShape.addRoundedRect(shapeMarginBounds(), Path::PreferBezierRoundedRect);
+ paths.marginShape.addRoundedRect(shapeMarginBounds(), Path::RoundedRectStrategy::PreferBezier);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/shapes/RectangleShape.cpp (253915 => 253916)
--- trunk/Source/WebCore/rendering/shapes/RectangleShape.cpp 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/rendering/shapes/RectangleShape.cpp 2019-12-26 19:01:03 UTC (rev 253916)
@@ -90,9 +90,9 @@
void RectangleShape::buildDisplayPaths(DisplayPaths& paths) const
{
- paths.shape.addRoundedRect(m_bounds, FloatSize(m_radii.width(), m_radii.height()), Path::PreferBezierRoundedRect);
+ paths.shape.addRoundedRect(m_bounds, FloatSize(m_radii.width(), m_radii.height()), Path::RoundedRectStrategy::PreferBezier);
if (shapeMargin())
- paths.marginShape.addRoundedRect(shapeMarginBounds(), FloatSize(m_radii.width() + shapeMargin(), m_radii.height() + shapeMargin()), Path::PreferBezierRoundedRect);
+ paths.marginShape.addRoundedRect(shapeMarginBounds(), FloatSize(m_radii.width() + shapeMargin(), m_radii.height() + shapeMargin()), Path::RoundedRectStrategy::PreferBezier);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp (253915 => 253916)
--- trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp 2019-12-26 19:01:03 UTC (rev 253916)
@@ -120,10 +120,10 @@
AffineTransform nonScalingTransform = nonScalingStrokeTransform();
Path* usePath = nonScalingStrokePath(m_path.get(), nonScalingTransform);
- return usePath->strokeContains(&applier, nonScalingTransform.mapPoint(point));
+ return usePath->strokeContains(applier, nonScalingTransform.mapPoint(point));
}
- return m_path->strokeContains(&applier, point);
+ return m_path->strokeContains(applier, point);
}
bool RenderSVGShape::shapeDependentFillContains(const FloatPoint& point, const WindRule fillRule) const
Modified: trunk/Source/WebCore/rendering/svg/SVGMarkerData.h (253915 => 253916)
--- trunk/Source/WebCore/rendering/svg/SVGMarkerData.h 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/rendering/svg/SVGMarkerData.h 2019-12-26 19:01:03 UTC (rev 253916)
@@ -111,26 +111,26 @@
void updateMarkerDataForPathElement(const PathElement& element)
{
- FloatPoint* points = element.points;
+ auto& points = element.points;
switch (element.type) {
- case PathElementAddQuadCurveToPoint:
- // FIXME: https://bugs.webkit.org/show_bug.cgi?id=33115 (PathElementAddQuadCurveToPoint not handled for <marker>)
+ case PathElement::Type::AddQuadCurveToPoint:
+ // FIXME: https://bugs.webkit.org/show_bug.cgi?id=33115 (PathElement::Type::AddQuadCurveToPoint not handled for <marker>)
m_origin = points[1];
break;
- case PathElementAddCurveToPoint:
+ case PathElement::Type::AddCurveToPoint:
m_inslopePoints[0] = points[1];
m_inslopePoints[1] = points[2];
m_origin = points[2];
break;
- case PathElementMoveToPoint:
+ case PathElement::Type::MoveToPoint:
m_subpathStart = points[0];
FALLTHROUGH;
- case PathElementAddLineToPoint:
+ case PathElement::Type::AddLineToPoint:
updateInslope(points[0]);
m_origin = points[0];
break;
- case PathElementCloseSubpath:
+ case PathElement::Type::CloseSubpath:
updateInslope(points[0]);
m_origin = m_subpathStart;
m_subpathStart = FloatPoint();
Modified: trunk/Source/WebCore/rendering/svg/SVGPathData.cpp (253915 => 253916)
--- trunk/Source/WebCore/rendering/svg/SVGPathData.cpp 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/rendering/svg/SVGPathData.cpp 2019-12-26 19:01:03 UTC (rev 253916)
@@ -161,7 +161,7 @@
// FIXME: We currently enforce using beziers here, as at least on CoreGraphics/Lion, as
// the native method uses a different line dash origin, causing svg/custom/dashOrigin.svg to fail.
// See bug https://bugs.webkit.org/show_bug.cgi?id=79932 which tracks this issue.
- path.addRoundedRect(FloatRect(x, y, width, height), FloatSize(rx, ry), Path::PreferBezierRoundedRect);
+ path.addRoundedRect(FloatRect(x, y, width, height), FloatSize(rx, ry), Path::RoundedRectStrategy::PreferBezier);
return path;
}
Modified: trunk/Source/WebCore/rendering/svg/SVGSubpathData.h (253915 => 253916)
--- trunk/Source/WebCore/rendering/svg/SVGSubpathData.h 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/rendering/svg/SVGSubpathData.h 2019-12-26 19:01:03 UTC (rev 253916)
@@ -34,7 +34,7 @@
static void updateFromPathElement(SVGSubpathData& subpathFinder, const PathElement& element)
{
switch (element.type) {
- case PathElementMoveToPoint:
+ case PathElement::Type::MoveToPoint:
if (subpathFinder.m_pathIsZeroLength && !subpathFinder.m_haveSeenMoveOnly)
subpathFinder.m_zeroLengthSubpathLocations.append(subpathFinder.m_lastPoint);
subpathFinder.m_lastPoint = subpathFinder.m_movePoint = element.points[0];
@@ -41,7 +41,7 @@
subpathFinder.m_haveSeenMoveOnly = true;
subpathFinder.m_pathIsZeroLength = true;
break;
- case PathElementAddLineToPoint:
+ case PathElement::Type::AddLineToPoint:
if (subpathFinder.m_lastPoint != element.points[0]) {
subpathFinder.m_pathIsZeroLength = false;
subpathFinder.m_lastPoint = element.points[0];
@@ -48,7 +48,7 @@
}
subpathFinder.m_haveSeenMoveOnly = false;
break;
- case PathElementAddQuadCurveToPoint:
+ case PathElement::Type::AddQuadCurveToPoint:
if (subpathFinder.m_lastPoint != element.points[0] || element.points[0] != element.points[1]) {
subpathFinder.m_pathIsZeroLength = false;
subpathFinder.m_lastPoint = element.points[1];
@@ -55,7 +55,7 @@
}
subpathFinder.m_haveSeenMoveOnly = false;
break;
- case PathElementAddCurveToPoint:
+ case PathElement::Type::AddCurveToPoint:
if (subpathFinder.m_lastPoint != element.points[0] || element.points[0] != element.points[1] || element.points[1] != element.points[2]) {
subpathFinder.m_pathIsZeroLength = false;
subpathFinder.m_lastPoint = element.points[2];
@@ -62,7 +62,7 @@
}
subpathFinder.m_haveSeenMoveOnly = false;
break;
- case PathElementCloseSubpath:
+ case PathElement::Type::CloseSubpath:
if (subpathFinder.m_pathIsZeroLength)
subpathFinder.m_zeroLengthSubpathLocations.append(subpathFinder.m_lastPoint);
subpathFinder.m_haveSeenMoveOnly = true; // This is an implicit move for the next element
Modified: trunk/Source/WebCore/svg/SVGPathTraversalStateBuilder.cpp (253915 => 253916)
--- trunk/Source/WebCore/svg/SVGPathTraversalStateBuilder.cpp 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/svg/SVGPathTraversalStateBuilder.cpp 2019-12-26 19:01:03 UTC (rev 253916)
@@ -36,12 +36,12 @@
void SVGPathTraversalStateBuilder::moveTo(const FloatPoint& targetPoint, bool, PathCoordinateMode)
{
- m_traversalState.processPathElement(PathElementMoveToPoint, &targetPoint);
+ m_traversalState.processPathElement(PathElement::Type::MoveToPoint, &targetPoint);
}
void SVGPathTraversalStateBuilder::lineTo(const FloatPoint& targetPoint, PathCoordinateMode)
{
- m_traversalState.processPathElement(PathElementAddLineToPoint, &targetPoint);
+ m_traversalState.processPathElement(PathElement::Type::AddLineToPoint, &targetPoint);
}
void SVGPathTraversalStateBuilder::curveToCubic(const FloatPoint& point1, const FloatPoint& point2, const FloatPoint& targetPoint, PathCoordinateMode)
@@ -48,12 +48,12 @@
{
FloatPoint points[] = { point1, point2, targetPoint };
- m_traversalState.processPathElement(PathElementAddCurveToPoint, points);
+ m_traversalState.processPathElement(PathElement::Type::AddCurveToPoint, points);
}
void SVGPathTraversalStateBuilder::closePath()
{
- m_traversalState.processPathElement(PathElementCloseSubpath, nullptr);
+ m_traversalState.processPathElement(PathElement::Type::CloseSubpath, nullptr);
}
bool SVGPathTraversalStateBuilder::continueConsuming()
Modified: trunk/Source/WebCore/svg/SVGPathUtilities.cpp (253915 => 253916)
--- trunk/Source/WebCore/svg/SVGPathUtilities.cpp 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/svg/SVGPathUtilities.cpp 2019-12-26 19:01:03 UTC (rev 253916)
@@ -58,19 +58,19 @@
if (!path.isNull() && !path.isEmpty()) {
path.apply([&builder] (const PathElement& element) {
switch (element.type) {
- case PathElementMoveToPoint:
+ case PathElement::Type::MoveToPoint:
builder.append('M');
builder.appendNumber(element.points[0].x());
builder.append(' ');
builder.appendNumber(element.points[0].y());
break;
- case PathElementAddLineToPoint:
+ case PathElement::Type::AddLineToPoint:
builder.append('L');
builder.appendNumber(element.points[0].x());
builder.append(' ');
builder.appendNumber(element.points[0].y());
break;
- case PathElementAddQuadCurveToPoint:
+ case PathElement::Type::AddQuadCurveToPoint:
builder.append('Q');
builder.appendNumber(element.points[0].x());
builder.append(' ');
@@ -80,7 +80,7 @@
builder.append(' ');
builder.appendNumber(element.points[1].y());
break;
- case PathElementAddCurveToPoint:
+ case PathElement::Type::AddCurveToPoint:
builder.append('C');
builder.appendNumber(element.points[0].x());
builder.append(' ');
@@ -94,7 +94,7 @@
builder.append(' ');
builder.appendNumber(element.points[2].y());
break;
- case PathElementCloseSubpath:
+ case PathElement::Type::CloseSubpath:
builder.append('Z');
break;
}
Modified: trunk/Source/WebCore/testing/Internals.cpp (253915 => 253916)
--- trunk/Source/WebCore/testing/Internals.cpp 2019-12-26 16:01:43 UTC (rev 253915)
+++ trunk/Source/WebCore/testing/Internals.cpp 2019-12-26 19:01:03 UTC (rev 253916)
@@ -4418,19 +4418,19 @@
SVGPathStringBuilder builder;
PathUtilities::pathWithShrinkWrappedRects(rects, radius).apply([&builder](const PathElement& element) {
switch (element.type) {
- case PathElementMoveToPoint:
+ case PathElement::Type::MoveToPoint:
builder.moveTo(element.points[0], false, AbsoluteCoordinates);
return;
- case PathElementAddLineToPoint:
+ case PathElement::Type::AddLineToPoint:
builder.lineTo(element.points[0], AbsoluteCoordinates);
return;
- case PathElementAddQuadCurveToPoint:
+ case PathElement::Type::AddQuadCurveToPoint:
builder.curveToQuadratic(element.points[0], element.points[1], AbsoluteCoordinates);
return;
- case PathElementAddCurveToPoint:
+ case PathElement::Type::AddCurveToPoint:
builder.curveToCubic(element.points[0], element.points[1], element.points[2], AbsoluteCoordinates);
return;
- case PathElementCloseSubpath:
+ case PathElement::Type::CloseSubpath:
builder.closePath();
return;
}