Commit 46f1514c authored by Alison Maher's avatar Alison Maher Committed by Commit Bot

Ignore inline background images in forced colors mode

Inline background images are painted after backplates are drawn in
forced colors mode. This breaks the ensured level of contrast for such
elements. To account for this, background images are ignored for inline
elements when forced colors mode is enabled and forced-color-adjust is
auto.

Bug: 970285
Change-Id: I609eb1779ed3a9d964cb6165e5452b9d2a9666e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1757685
Commit-Queue: Alison Maher <almaher@microsoft.com>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Reviewed-by: default avatarKevin Babbitt <kbabbitt@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#689095}
parent 6fbdf7bc
...@@ -129,7 +129,8 @@ BoxPainterBase::FillLayerInfo BoxModelObjectPainter::GetFillLayerInfo( ...@@ -129,7 +129,8 @@ BoxPainterBase::FillLayerInfo BoxModelObjectPainter::GetFillLayerInfo(
box_model_.GetDocument(), box_model_.StyleRef(), box_model_.GetDocument(), box_model_.StyleRef(),
box_model_.HasOverflowClip(), color, bg_layer, bleed_avoidance, box_model_.HasOverflowClip(), color, bg_layer, bleed_avoidance,
(flow_box_ ? flow_box_->IncludeLogicalLeftEdge() : true), (flow_box_ ? flow_box_->IncludeLogicalLeftEdge() : true),
(flow_box_ ? flow_box_->IncludeLogicalRightEdge() : true)); (flow_box_ ? flow_box_->IncludeLogicalRightEdge() : true),
box_model_.IsInline());
} }
} // namespace blink } // namespace blink
...@@ -274,7 +274,8 @@ BoxPainterBase::FillLayerInfo::FillLayerInfo( ...@@ -274,7 +274,8 @@ BoxPainterBase::FillLayerInfo::FillLayerInfo(
const FillLayer& layer, const FillLayer& layer,
BackgroundBleedAvoidance bleed_avoidance, BackgroundBleedAvoidance bleed_avoidance,
bool include_left, bool include_left,
bool include_right) bool include_right,
bool is_inline)
: image(layer.GetImage()), : image(layer.GetImage()),
color(bg_color), color(bg_color),
include_left_edge(include_left), include_left_edge(include_left),
...@@ -301,6 +302,13 @@ BoxPainterBase::FillLayerInfo::FillLayerInfo( ...@@ -301,6 +302,13 @@ BoxPainterBase::FillLayerInfo::FillLayerInfo(
} }
} }
// Background images are not allowed at the inline level in forced colors
// mode when forced-color-adjust is auto. This ensures that the inline images
// are not painted on top of the forced colors mode backplate.
if (doc.InForcedColorsMode() && is_inline &&
style.ForcedColorAdjust() != EForcedColorAdjust::kNone)
image = nullptr;
const bool has_rounded_border = const bool has_rounded_border =
style.HasBorderRadius() && (include_left_edge || include_right_edge); style.HasBorderRadius() && (include_left_edge || include_right_edge);
// BorderFillBox radius clipping is taken care of by // BorderFillBox radius clipping is taken care of by
......
...@@ -113,7 +113,8 @@ class BoxPainterBase { ...@@ -113,7 +113,8 @@ class BoxPainterBase {
const FillLayer&, const FillLayer&,
BackgroundBleedAvoidance, BackgroundBleedAvoidance,
bool include_left_edge, bool include_left_edge,
bool include_right_edge); bool include_right_edge,
bool is_inline);
// FillLayerInfo is a temporary, stack-allocated container which cannot // FillLayerInfo is a temporary, stack-allocated container which cannot
// outlive the StyleImage. This would normally be a raw pointer, if not for // outlive the StyleImage. This would normally be a raw pointer, if not for
......
...@@ -1107,7 +1107,8 @@ BoxPainterBase::FillLayerInfo NGBoxFragmentPainter::GetFillLayerInfo( ...@@ -1107,7 +1107,8 @@ BoxPainterBase::FillLayerInfo NGBoxFragmentPainter::GetFillLayerInfo(
return BoxPainterBase::FillLayerInfo( return BoxPainterBase::FillLayerInfo(
fragment.GetLayoutObject()->GetDocument(), fragment.Style(), fragment.GetLayoutObject()->GetDocument(), fragment.Style(),
fragment.HasOverflowClip(), color, bg_layer, bleed_avoidance, fragment.HasOverflowClip(), color, bg_layer, bleed_avoidance,
border_edges.line_left, border_edges.line_right); border_edges.line_left, border_edges.line_right,
fragment.GetLayoutObject()->IsInline());
} }
bool NGBoxFragmentPainter::IsInSelfHitTestingPhase(HitTestAction action) const { bool NGBoxFragmentPainter::IsInSelfHitTestingPhase(HitTestAction action) const {
......
<!doctype html>
<style>
div {
background-image: url("resources/test-image.jpg");
display: inline;
}
#adjustnone {
forced-color-adjust: none;
}
</style>
<body>
<div>
The background image behind this text should be ignored in forced colors
mode.
</div>
<div id="adjustnone">
The background image behind this text should NOT be ignored in forced
colors mode.
</div>
</body>
<!doctype html>
<title>
Forced colors mode.
Tests that inline images are ignored in forced colors mode when
forced-color-adjust is auto.
</title>
<style>
div {
background-image: url("resources/test-image.jpg");
display: inline;
}
#adjustnone {
forced-color-adjust: none;
}
</style>
<body>
<div>
The background image behind this text should be ignored in forced colors
mode.
</div>
<div id="adjustnone">
The background image behind this text should NOT be ignored in forced
colors mode.
</div>
</body>
<!doctype html>
<style>
body {
forced-color-adjust: none;
}
div {
display: inline;
}
#adjustnone {
background-image:
url("../../../../../fast/css/forced-colors-mode/resources/test-image.jpg");
}
</style>
<body>
<div>
The background image behind this text should be ignored in forced colors
mode.
</div>
<div id="adjustnone">
The background image behind this text should NOT be ignored in forced
colors mode.
</div>
</body>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment