Refactor background painting behind table cells

This is a preparation for adding box-shadow support for table rows
and sections.

Also improve performance by moving some common conditions out of
inner loops.

BUG=94871

Review-Url: https://codereview.chromium.org/1983853003
Cr-Commit-Position: refs/heads/master@{#394280}
8 files changed