Skip to content

Commit c948de8

Browse files
Ahmad-S792Ahmad Saleem
authored andcommitted
stroke-dasharray applied to markers and cannot be overriden by ="0"
https://bugs.webkit.org/show_bug.cgi?id=192539 rdar://46607685 Reviewed by Nikolas Zimmermann. This patch aligns WebKit with Gecko / Firefox and Blink / Chromium. Further, this fixes issue for both LegacySVG and Layer Based SVG Engine (LBSE). SVG markers were inheriting stroke-dasharray from their parent elements, causing dashed strokes to appear on marker content even when explicitly set to "0" or "none". This occurred because the marker rendering context was not properly resetting the dash array state before painting. The original issue is stroke-dasharray should not propagate into marker content unless explicitly set on elements within the marker definition. This change ensures that when rendering markers, we reset the stroke dash array to empty before painting marker content, allowing marker- specific stroke-dasharray values (including "0") to be applied correctly without inheriting from the parent path or shape. * Source/WebCore/rendering/svg/RenderSVGPath.cpp: (WebCore::RenderSVGPath::drawMarkers): * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGPath.cpp: (WebCore::LegacyRenderSVGPath::drawMarkers): * LayoutTests/svg/custom/marker-stroke-dasharray-none-zero.svg: Added. * LayoutTests/svg/custom/marker-stroke-dasharray-none-zero-expected.svg: Added. (Added fuzziness in test due to Skia vs CG + known issue in CG of corner missing - which was leading to difference) Canonical link: https://commits.webkit.org/305042@main
1 parent 38380f0 commit c948de8

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed
Lines changed: 11 additions & 0 deletions
Loading
Lines changed: 12 additions & 0 deletions
Loading

Source/WebCore/rendering/svg/RenderSVGPath.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ void RenderSVGPath::drawMarkers(PaintInfo& paintInfo)
234234
auto& context = paintInfo.context();
235235
GraphicsContextStateSaver stateSaver(context);
236236

237+
context.setLineDash(DashArray(), 0);
237238
auto contentTransform = marker->markerTransformation(markerPosition.origin, markerPosition.angle, strokeWidth);
238239
marker->checkedLayer()->paintSVGResourceLayer(context, contentTransform);
239240
}

Source/WebCore/rendering/svg/legacy/LegacyRenderSVGPath.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,13 @@ void LegacyRenderSVGPath::drawMarkers(PaintInfo& paintInfo)
253253
float strokeWidth = this->strokeWidth();
254254
unsigned size = m_markerPositions.size();
255255
for (unsigned i = 0; i < size; ++i) {
256-
if (auto* marker = markerForType(m_markerPositions[i].type, markerStart, markerMid, markerEnd))
256+
if (auto* marker = markerForType(m_markerPositions[i].type, markerStart, markerMid, markerEnd)) {
257+
auto& context = paintInfo.context();
258+
GraphicsContextStateSaver stateSaver(context);
259+
260+
context.setLineDash(DashArray(), 0);
257261
marker->draw(paintInfo, marker->markerTransformation(m_markerPositions[i].origin, m_markerPositions[i].angle, strokeWidth));
262+
}
258263
}
259264
}
260265

0 commit comments

Comments
 (0)