Bug 1665064 - Honor print background image settings on WebRender too. r=kats,jwatt CLOSED TREE

We usually suppress background images in
nsCSSRendering::PaintStyleImageLayerWithSC, but that codepath isn't hit
by WebRender, so instead do it during display list building, the same
way we suppress background colors.

Differential Revision: https://phabricator.services.mozilla.com/D90278
This commit is contained in:
Emilio Cobos Álvarez 2020-09-15 16:26:05 +00:00
Родитель 38f63aa9b6
Коммит ba7373413f
3 изменённых файлов: 29 добавлений и 13 удалений

Просмотреть файл

@ -672,6 +672,16 @@ async function runTest25() {
async function runTest26() {
await compareFiles("printpreview_downloadable_font_in_iframe.html", "printpreview_downloadable_font_in_iframe_ref.html");
requestAnimationFrame(() => setTimeout(runTest27));
}
async function runTest27() {
await compareFiles("data:text/html,<style>:root { background-color: red; background-image: linear-gradient(red, red) }</style>", "data:text/html,", {
settings: {
printBGColors: false,
printBGImages: false,
}
});
finish();
}

Просмотреть файл

@ -515,15 +515,23 @@ void nsCanvasFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
bool needBlendContainer = false;
nsDisplayListBuilder::AutoContainerASRTracker contASRTracker(aBuilder);
// In high-contrast-mode, we suppress background-image on the canvas frame
// (even when backplating), because users expect site backgrounds to conform
// to their HCM background color when a solid color is rendered, and some
// websites use solid-color images instead of an overwritable background
// color.
const bool suppressBackgroundImage =
!PresContext()->PrefSheetPrefs().mUseDocumentColors &&
StaticPrefs::
browser_display_suppress_canvas_background_image_on_forced_colors();
const bool suppressBackgroundImage = [&] {
// Handle print settings.
if (!ComputeShouldPaintBackground().mImage) {
return true;
}
// In high-contrast-mode, we suppress background-image on the canvas frame
// (even when backplating), because users expect site backgrounds to
// conform to their HCM background color when a solid color is rendered,
// and some websites use solid-color images instead of an overwritable
// background color.
if (!PresContext()->PrefSheetPrefs().mUseDocumentColors &&
StaticPrefs::
browser_display_suppress_canvas_background_image_on_forced_colors()) {
return true;
}
return false;
}();
// Create separate items for each background layer.
const nsStyleImageLayers& layers = bg->StyleBackground()->mImage;

Просмотреть файл

@ -3509,11 +3509,9 @@ bool nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
}
bool drawBackgroundColor = false;
// Dummy initialisation to keep Valgrind/Memcheck happy.
// See bug 1122375 comment 1.
bool drawBackgroundImage = false;
nscolor color = NS_RGBA(0, 0, 0, 0);
if (!nsCSSRendering::IsCanvasFrame(aFrame) && bg) {
bool drawBackgroundImage;
color = nsCSSRendering::DetermineBackgroundColor(
presContext, bgSC, aFrame, drawBackgroundImage, drawBackgroundColor);
}
@ -3593,7 +3591,7 @@ bool nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
return true;
}
if (!bg) {
if (!bg || !drawBackgroundImage) {
aList->AppendToTop(&bgItemList);
return false;
}