Skip to content

Commit a787642

Browse files
Ahmad-S792Ahmad Saleem
authored andcommitted
Fix MathML fraction bar not painted when thickness equals width
https://bugs.webkit.org/show_bug.cgi?id=308440 rdar://170934351 Reviewed by Frédéric Wang. GraphicsContext::drawLine() misidentifies horizontal lines as vertical when stroke thickness equals the distance between endpoints. This causes the fraction bar to not render when FractionRuleThickness produces a thickness equal to the bar width. Replace drawLine() with fillRect() to draw the fraction bar as an explicit rectangle, avoiding the heuristic entirely. * LayoutTests/TestExpectations: Progressions * Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp: (WebCore::RenderMathMLFraction::paint): Canonical link: https://commits.webkit.org/308025@main
1 parent 16bd64e commit a787642

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

LayoutTests/TestExpectations

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,10 +1995,7 @@ imported/w3c/web-platform-tests/html/browsers/windows/nested-browsing-contexts/f
19951995

19961996
# These MathML WPT tests fail.
19971997
webkit.org/b/180013 mathml/non-core/lengths-2.html [ ImageOnlyFailure ]
1998-
webkit.org/b/194952 imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-bar-001.html [ ImageOnlyFailure ]
19991998
imported/w3c/web-platform-tests/mathml/presentation-markup/direction/direction-overall-003.html [ ImageOnlyFailure ]
2000-
imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-bar-002.html [ ImageOnlyFailure ]
2001-
imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-default-padding.html [ ImageOnlyFailure ]
20021999
imported/w3c/web-platform-tests/mathml/presentation-markup/operators/embellished-op-1-2.html [ ImageOnlyFailure Pass ]
20032000
imported/w3c/web-platform-tests/mathml/presentation-markup/operators/embellished-op-1-3.html [ ImageOnlyFailure Pass ]
20042001
imported/w3c/web-platform-tests/mathml/presentation-markup/operators/embellished-op-1-4.html [ ImageOnlyFailure Pass ]
@@ -2051,7 +2048,6 @@ imported/w3c/web-platform-tests/mathml/relations/css-styling/clip.html [ ImageOn
20512048
imported/w3c/web-platform-tests/mathml/relations/css-styling/presentational-hints-001.html [ ImageOnlyFailure Pass ]
20522049
imported/w3c/web-platform-tests/mathml/relations/css-styling/transform.html [ ImageOnlyFailure ]
20532050

2054-
imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-bar-003.html [ ImageOnlyFailure ]
20552051
imported/w3c/web-platform-tests/mathml/presentation-markup/operators/mo-lspace-rspace-2.html [ ImageOnlyFailure ]
20562052
imported/w3c/web-platform-tests/mathml/presentation-markup/operators/mo-movablelimits-and-embellished-operator.html [ ImageOnlyFailure ]
20572053
imported/w3c/web-platform-tests/mathml/presentation-markup/operators/op-dict-8.html [ ImageOnlyFailure ]

Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,16 +293,18 @@ void RenderMathMLFraction::paint(PaintInfo& info, const LayoutPoint& paintOffset
293293
return;
294294

295295
LayoutUnit borderAndPaddingLeft = writingMode().isBidiLTR() ? borderAndPaddingStart() : borderAndPaddingEnd();
296-
auto adjustedPaintOffset = roundPointToDevicePixels(paintOffset + location() + LayoutPoint(borderAndPaddingLeft, borderAndPaddingBefore() + fractionAscent() - mathAxisHeight()), document().deviceScaleFactor());
296+
LayoutUnit barX = borderAndPaddingLeft;
297+
LayoutUnit barY = borderAndPaddingBefore() + fractionAscent() - mathAxisHeight() - thickness / 2;
298+
LayoutUnit barWidth = logicalWidth() - borderAndPaddingLogicalWidth();
299+
300+
auto barOrigin = roundPointToDevicePixels(paintOffset + location() + LayoutPoint(barX, barY), document().deviceScaleFactor());
301+
auto barEnd = roundPointToDevicePixels(paintOffset + location() + LayoutPoint(barX + barWidth, barY + thickness), document().deviceScaleFactor());
297302

298303
GraphicsContextStateSaver stateSaver(info.context());
299304

300-
info.context().setStrokeThickness(thickness);
301-
info.context().setStrokeStyle(StrokeStyle::SolidStroke);
302-
info.context().setStrokeColor(style().visitedDependentColorApplyingColorFilter());
303305
// MathML Core says the fraction bar takes the full width of the content box.
304-
auto endPoint = roundPointToDevicePixels({ adjustedPaintOffset.x() + logicalWidth() - borderAndPaddingLogicalWidth(), adjustedPaintOffset.y() }, document().deviceScaleFactor());
305-
info.context().drawLine(adjustedPaintOffset, endPoint);
306+
info.context().setFillColor(style().visitedDependentColorApplyingColorFilter());
307+
info.context().fillRect({ barOrigin, barEnd });
306308
}
307309

308310
std::optional<LayoutUnit> RenderMathMLFraction::firstLineBaseline() const

0 commit comments

Comments
 (0)