The <meter> gauge is drawn entirely with CSS
background gradients on divs inside its user-agent shadow tree
(html.css). When printing, Blink forces backgrounds to white
unless "Background graphics" is checked in the print dialog
(print-color-adjust defaults to economy).
Actual the printout shows an empty box where the meter should be.
Expected the meter gauge is visible in the printout, like checkboxes, radios and progress bars are (those are painted natively, so the background stripping never affected them).
1. Open this page in Chrome / Chromium.
2. Press the print button below (or Ctrl+P) and look at the preview. Leave "Background graphics" unchecked (default).
3. Unfixed: the meters below render as empty boxes. Fixed: the colored gauges are visible.
| optimum (green) | |
| suboptimum (yellow) | |
| even-less-good (red) | |
| half full, defaults | |
| reference (progress, always printed) |
BoxPainterBase::ShouldForceWhiteBackgroundForPrintEconomy()
(core/paint/box_painter_base.cc) rewrites background color and
image to solid white while printing when the style's
print-color-adjust is economy and
"print backgrounds" is off. The meter shadow parts
(::-webkit-meter-bar, ::-webkit-meter-*-value)
never opted out, so the whole control paints as white-on-white.
/* third_party/blink/renderer/core/html/resources/html.css */
meter::-webkit-meter-bar,
meter::-webkit-meter-optimum-value,
meter::-webkit-meter-suboptimum-value,
meter::-webkit-meter-even-less-good-value {
print-color-adjust: exact;
}
Covered by the new unit test
PrintContextTest.MeterWithShouldPrintBackgroundDisabled
(core/page/print_context_test.cc): prints a page with a
<meter> while backgrounds are disabled and asserts that a
non-white fill is recorded.
Authors keep full control: setting
meter::-webkit-meter-bar { print-color-adjust: economy } (or
appearance: none plus custom styling) still overrides the UA
default.
In the print dialog, open "More settings" and check Background graphics.
Issue: issues.chromium.org/issues/41198413 (migrated from crbug.com/526384)