Bug 1723938 - Keep looking for background-colors when finding a background-image with transparent background-color. r=morgan

Differential Revision: https://phabricator.services.mozilla.com/D121770
This commit is contained in:
Emilio Cobos Álvarez
2021-08-05 11:21:29 +00:00
parent 7ce6ca794c
commit a14e48ea16
4 changed files with 41 additions and 6 deletions

View File

@@ -235,13 +235,15 @@ static Maybe<nscolor> GetBackplateColor(nsIFrame* aFrame) {
if (!drawColor && !drawImage) { if (!drawColor && !drawImage) {
continue; continue;
} }
if (NS_GET_A(backgroundColor) != 0) { if (NS_GET_A(backgroundColor) == 0) {
// NOTE: We intentionally disregard the alpha channel here for the purpose // Even if there's a background image, if there's no background color we
// of the backplate, in order to guarantee contrast. // keep going up the frame tree, see bug 1723938.
return Some(NS_RGB(NS_GET_R(backgroundColor), NS_GET_G(backgroundColor), continue;
NS_GET_B(backgroundColor)));
} }
break; // NOTE: We intentionally disregard the alpha channel here for the purpose
// of the backplate, in order to guarantee contrast.
return Some(NS_RGB(NS_GET_R(backgroundColor), NS_GET_G(backgroundColor),
NS_GET_B(backgroundColor)));
} }
return Some(aFrame->PresContext()->DefaultBackgroundColor()); return Some(aFrame->PresContext()->DefaultBackgroundColor());
} }

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<style>
.outer {
/* Invert color/background so that it has more chances to disagree with the default background-color. */
color: Menu;
background-color: MenuText;
}
.inner {
height: 100px;
width: 100px;
}
</style>
<div class="outer">
<div class="size url">Some text</div>
</div>

View File

@@ -0,0 +1,17 @@
<!DOCTYPE html>
<style>
.outer {
/* Invert color/background so that it has more chances to disagree with the default background-color. */
color: Menu;
background-color: MenuText;
}
.inner {
height: 100px;
width: 100px;
background-image: url("green.png");
background-size: 0 0;
}
</style>
<div class="outer">
<div class="size url">Some text</div>
</div>

View File

@@ -27,6 +27,7 @@ test-pref(browser.display.suppress_canvas_background_image_on_forced_colors,true
test-pref(browser.display.suppress_canvas_background_image_on_forced_colors,false) != bg-image-root-001.html bg-image-root-001-ref.html test-pref(browser.display.suppress_canvas_background_image_on_forced_colors,false) != bg-image-root-001.html bg-image-root-001-ref.html
== bg-image-div-001.html bg-image-div-001-ref.html == bg-image-div-001.html bg-image-div-001-ref.html
== bg-image-div-002.html bg-image-div-002-ref.html
needs-focus == selection-001.html selection-001-ref.html needs-focus == selection-001.html selection-001-ref.html
pref(browser.display.document_color_use,0) needs-focus != selection-001.html selection-001-ref.html pref(browser.display.document_color_use,0) needs-focus != selection-001.html selection-001-ref.html