Bug 1436758 - Make color-adjust: exact not darken foreground colors. r=jwatt

Differential Revision: https://phabricator.services.mozilla.com/D85660
This commit is contained in:
Emilio Cobos Álvarez 2020-08-02 08:45:29 +00:00
parent c63127c59a
commit 4f644719ae
5 changed files with 47 additions and 9 deletions

View File

@ -6209,16 +6209,16 @@ static nscolor DarkenColor(nscolor aColor) {
// background images and colors are being suppressed, because that means
// light text will not be visible against the (presumed light-colored)
// background.
static bool ShouldDarkenColors(nsPresContext* aPresContext) {
return !aPresContext->GetBackgroundColorDraw() &&
!aPresContext->GetBackgroundImageDraw();
static bool ShouldDarkenColors(nsIFrame* aFrame) {
nsPresContext* pc = aFrame->PresContext();
if (pc->GetBackgroundColorDraw() || pc->GetBackgroundImageDraw()) {
return false;
}
return aFrame->StyleVisibility()->mColorAdjust != StyleColorAdjust::Exact;
}
nscolor nsLayoutUtils::DarkenColorIfNeeded(nsIFrame* aFrame, nscolor aColor) {
if (ShouldDarkenColors(aFrame->PresContext())) {
return DarkenColor(aColor);
}
return aColor;
return ShouldDarkenColors(aFrame) ? DarkenColor(aColor) : aColor;
}
gfxFloat nsLayoutUtils::GetSnappedBaselineY(nsIFrame* aFrame,

View File

@ -27,6 +27,8 @@ support-files =
printpreview_images_sw.html
printpreview_images_sw_ref.html
printpreview_images_sw.js
color_adjust.html
color_adjust_ref.html
test_document_adopted_styles.html
test_document_adopted_styles_ref.html
test_shadow_root_adopted_styles.html

View File

@ -0,0 +1,9 @@
<!doctype html>
<style>
.test {
background-color: black;
color: white;
color-adjust: exact;
}
</style>
<span class="test">Some text goes here</span>

View File

@ -0,0 +1,8 @@
<!doctype html>
<style>
.test {
background-color: black;
color: white;
}
</style>
<span class="test">Some text goes here</span>

View File

@ -440,7 +440,7 @@ async function compareFiles(src1, src2, options = {}) {
await messagePromise;
}
await printpreview(options);
await printpreview(options.test || options);
ctx1.drawWindow(frameElts[1].contentWindow, 0, 0, 400, 400, "rgb(255,255,255)");
exitprintpreview();
@ -449,7 +449,7 @@ async function compareFiles(src1, src2, options = {}) {
iframeElement.setAttribute("src", BASE + src2);
});
await printpreview(options);
await printpreview(options.ref || options);
ctx2.drawWindow(frameElts[1].contentWindow, 0, 0, 400, 400, "rgb(255,255,255)");
exitprintpreview();
@ -518,6 +518,25 @@ async function runTest18() {
},
});
requestAnimationFrame(() => setTimeout(runTest19));
}
async function runTest18() {
await compareFiles("color_adjust.html", "color_adjust_ref.html", {
test: {
settings: {
printBGColors: false,
printBGImages: false,
},
},
ref: {
settings: {
printBGColors: true,
printBGImages: true,
},
},
});
finish();
}