Checkboxes of the same size paint one pixel apart depending on where they sit

#41288048 Area: Blink>Paint / form controls CL 8649429 In Review

What happens

Theme parts are painted into ToPixelSnappedRect(paint_rect), which snaps both edges: the width it produces is round(offset + size) - round(offset), so a fractional size gives a different pixel size depending on the sub-pixel offset. For a 13.4px checkbox at offset .0 that is 13px, at offset .4 it is 14px. Resizing a window makes a row of identically sized checkboxes grow and shrink out of step, which is what the 2016 report describes.

The CL rounds the size of checkbox and radio parts on its own, in rendering coordinates (gfx::ToRoundedPoint + gfx::ToRoundedSize), so the painted size depends only on the layout size. Whole-pixel controls, i.e. nearly everything, are untouched, and all other theme parts keep snapping both edges so they stay flush with adjacent boxes. Behind the default-on ConsistentFormControlPaintSnapping kill switch.

10 checkboxes, 13.4px each, every second one 0.4px off the grid

Live, at your device pixel ratio. The effect needs a fractional layout size, so at 2x the same page can look uniform.
Before: alternating sizes
Without the patch the painted squares alternate 13x13 and 14x14.
After: uniform sizes
With the patch all ten paint 13x13.
Diff mask on every second checkbox
280 px differ -- the outline of every second checkbox.
measured painted sizes (content_shell, dsf 1)
buildpainted squares, left to right
before13, 14, 13, 14, 13, 14, ...
after13, 13, 13, 13, 13, 13, ...

Verification

Links

Issue 41288048 CL 8649429 standalone sampler.html capture_screenshots.py