Incorrect painting of outline for huge outline-offset values

#41269582 Filed 2016-08-11 Status: Accepted (P4) CL 8608187

Summary

Problem

An element with outline: 5px solid red and an outline-offset near INT_MAX is inflated in LayoutUnit space inside OutlinePainter::PaintOutlineRects. The sum saturates at LayoutUnit::Max(), so the far edges of the ring fold back into the paintable area and render as spurious red strokes near the element. The bug has been open since 2016 and has outlived two re-enable attempts of fast/css/outline-offset-large.html.

Fix (CL 8608187)

In the single-rect branch of OutlinePainter::PaintOutlineRects, cap the per-side offset passed to AdjustedOutlineOffset at LayoutUnit::Max() / 4. That bounds the inflated rect to half the LayoutUnit range, leaves room for the rect itself and the outline width, and keeps any capped offset far outside the paintable area. Gated by OutlineOffsetSaturationCap (status: "stable") as a kill switch.

Repro

outline-offset: 2147483000px (near INT_MAX). With the composited layer (transform: translateZ(0)) and a huge offset, the pre-fix painter folds the far edges of the saturated rect back into the viewport. After the fix, the capped offset lives far outside the paintable area, so the outline is correctly invisible on this stage.

huge -- outline-offset: 2147483000px

Live render. On an unpatched Chrome you should see red fold-back strokes near the green box; on a patched Chrome (or Firefox) only the green box is visible.
Expected: only green box, no red artifact
content_shell with the fix enabled -- no spurious red strokes.
Diff mask: pixels that change between before/after
Magenta pixels show where the before/after rendering differs (2976 px): exactly the fold-back strokes removed by the fix.

content_shell: before / after

Before: red fold-back strokes next to green box
beforeLayoutUnit saturation folds the outline back into the viewport
After: only green box
afteroffset capped, outline painted off-screen

References

crbug.com/41269582 -- original report (filed 2016-08-11)

CL 8608187 -- Cap single-rect outline offset below LayoutUnit saturation

CL 1548423 / CL 1553953 -- 2019 re-enable + revert of the layout test

CSS UI 4 -- outline-offset

standalone sampler.html