Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
css-text-decor: fix crash in ComputeWavyPatternRect for small curves
ComputeWavyPatternRect returns a rect representing the bounds of one cycle of the given wavy pattern, expanding the top and bottom edges to the nearest integer y values. In particular, we round the top y value to -∞ with -ceil(abs(y)), which requires us to assert that y<0 to ensure the sign doesn’t flip. Unfortunately this is not always true, because PrepareWavyStrokePath offsets the curve by (0,0.5) to reduce vertical antialiasing. x=0 |------------------------| |. .| | . . | y= 0 __|____.______________.____| 0.5 --|------+-----------.-----| | . . | | . . | | . . | |------------------------| If the amplitude of the curve is small enough, the StrokeBoundingRect can fall entirely between y=0 and y=1. x=0 y= 0 --|------------------------| |. .| | . . | | . . | 0.5 --|------+-----------.-----| | . . | | . . | | . . | 1 --|------------------------| This can happen even if the upper control point itself has y<0, since béziér curves can have tighter bounds than the min/max of all of their points. For example, given the following, the StrokeBoundingRect would be (-1.23219,0.0142169) 4.71437x0.971566, even though cp2 has y=-0.75: start = (-1.125,0.5) cp1 = (-0.375,1.75) cp2 = (-0.375,-0.75) end = (0.375,0.5) The correct assertion is y<0.5, but -ceil(abs(y)) would round small positive y values incorrectly anyway. This patch replaces it with floor(y), which always rounds towards -∞. Fixed: 1393709 Change-Id: I4557a67dd42eb06e1942f3bec4ebcbaeb79ef211 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4065062 Reviewed-by: Philip Rogers <pdr@chromium.org> Commit-Queue: Delan Azabani <dazabani@igalia.com> Reviewed-by: Koji Ishii <kojii@chromium.org> Cr-Commit-Position: refs/heads/main@{#1078150}
- Loading branch information